Mercurial > pidgin
comparison src/protocols/yahoo/yay.c @ 2231:8c4ff1a368bd
[gaim-migrate @ 2241]
blue:~/gaim/app/src/protocols $ ./gtk
icq: 0
irc: 0
jabber: 52
msn: 0
napster: 0
oscar: 7
toc: 17
yahoo: 0
zephyr: 1
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 07 Sep 2001 08:09:22 +0000 |
parents | 3a6fd1e8f00a |
children | 2abf9cc183a0 |
comparison
equal
deleted
inserted
replaced
2230:cfc9abe45db2 | 2231:8c4ff1a368bd |
---|---|
24 #include "config.h" | 24 #include "config.h" |
25 #endif | 25 #endif |
26 | 26 |
27 | 27 |
28 #include <netdb.h> | 28 #include <netdb.h> |
29 #include <gtk/gtk.h> | |
30 #include <unistd.h> | 29 #include <unistd.h> |
31 #include <errno.h> | 30 #include <errno.h> |
32 #include <netinet/in.h> | 31 #include <netinet/in.h> |
33 #include <arpa/inet.h> | 32 #include <arpa/inet.h> |
34 #include <string.h> | 33 #include <string.h> |
72 GtkWidget *email_win; | 71 GtkWidget *email_win; |
73 GtkWidget *email_label; | 72 GtkWidget *email_label; |
74 char *active_id; | 73 char *active_id; |
75 GList *conns; | 74 GList *conns; |
76 gboolean logged_in; | 75 gboolean logged_in; |
77 GSList *offline; | |
78 }; | 76 }; |
79 | 77 |
80 static char *yahoo_name() { | 78 static char *yahoo_name() { |
81 return "Yahoo"; | 79 return "Yahoo"; |
82 } | 80 } |
388 return TRUE; | 386 return TRUE; |
389 } | 387 } |
390 | 388 |
391 static void yahoo_close(struct gaim_connection *gc) { | 389 static void yahoo_close(struct gaim_connection *gc) { |
392 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | 390 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
393 while (yd->offline) { | |
394 g_free(yd->offline->data); | |
395 yd->offline = g_slist_remove(yd->offline, yd->offline->data); | |
396 } | |
397 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); | 391 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL); |
398 g_hash_table_destroy(yd->hash); | 392 g_hash_table_destroy(yd->hash); |
399 yahoo_disconnect(yd->sess); | 393 yahoo_disconnect(yd->sess); |
400 yahoo_delete(yd->sess); | 394 yahoo_delete(yd->sess); |
401 g_free(yd); | 395 g_free(yd); |
402 } | 396 } |
403 | 397 |
404 static int yahoo_send_im(struct gaim_connection *gc, char *who, char *message, int away) { | 398 static int yahoo_send_im(struct gaim_connection *gc, char *who, char *message, int flags) { |
405 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | 399 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
406 GSList *l = yd->offline; | 400 |
407 | 401 if ((flags & IM_FLAG_AWAY)|| !strlen(message)) return 0; |
408 if (away || !strlen(message)) return 0; | 402 |
409 | 403 if (flags & IM_FLAG_CHECKBOX) |
410 while (l) { | |
411 if (!strcmp(who, l->data)) | |
412 break; | |
413 l = l->next; | |
414 } | |
415 | |
416 if (l) | |
417 yahoo_send_message(yd->sess, yd->active_id, who, message); | 404 yahoo_send_message(yd->sess, yd->active_id, who, message); |
418 else | 405 else |
419 yahoo_send_message_offline(yd->sess, yd->active_id, who, message); | 406 yahoo_send_message_offline(yd->sess, yd->active_id, who, message); |
420 return 0; | 407 return 0; |
421 } | 408 } |
691 m = g_list_append(m, puo); | 678 m = g_list_append(m, puo); |
692 | 679 |
693 return m; | 680 return m; |
694 } | 681 } |
695 | 682 |
696 static void toggle_offline(GtkToggleButton *button, struct conversation *c) | |
697 { | |
698 struct gaim_connection *gc = gtk_object_get_user_data(GTK_OBJECT(button)); | |
699 struct yahoo_data *yd = gc->proto_data; | |
700 GSList *l = yd->offline; | |
701 | |
702 while (l) { | |
703 if (!strcmp(c->name, l->data)) | |
704 break; | |
705 l = l->next; | |
706 } | |
707 if (l) { | |
708 g_free(l->data); | |
709 yd->offline = g_slist_remove(yd->offline, l->data); | |
710 } else | |
711 yd->offline = g_slist_append(yd->offline, g_strdup(c->name)); | |
712 } | |
713 | |
714 static void yahoo_insert_convo(struct gaim_connection *gc, struct conversation *c) | |
715 { | |
716 GtkWidget *button; | |
717 struct yahoo_data *yd = gc->proto_data; | |
718 GSList *l = yd->offline; | |
719 struct buddy *b = find_buddy(gc, c->name); | |
720 | |
721 button = gtk_check_button_new_with_label("Send offline message"); | |
722 gtk_box_pack_start(GTK_BOX(c->lbox), button, FALSE, FALSE, 5); | |
723 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_offline), c); | |
724 gtk_object_set_user_data(GTK_OBJECT(button), gc); | |
725 while (l) { | |
726 if (!strcmp(c->name, l->data)) | |
727 break; | |
728 l = l->next; | |
729 } | |
730 if (l || (b && !b->present)) | |
731 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); | |
732 gtk_widget_show(button); | |
733 } | |
734 | |
735 static void yahoo_remove_convo(struct gaim_connection *gc, struct conversation *c) | |
736 { | |
737 while (GTK_BOX(c->lbox)->children) | |
738 gtk_container_remove(GTK_CONTAINER(c->lbox), | |
739 ((GtkBoxChild *)GTK_BOX(c->lbox)->children->data)->widget); | |
740 } | |
741 | |
742 static struct prpl *my_protocol = NULL; | 683 static struct prpl *my_protocol = NULL; |
743 | 684 |
744 void yahoo_init(struct prpl *ret) { | 685 void yahoo_init(struct prpl *ret) { |
745 /* the NULL's aren't required but they're nice to have */ | 686 /* the NULL's aren't required but they're nice to have */ |
746 ret->protocol = PROTO_YAHOO; | 687 ret->protocol = PROTO_YAHOO; |
747 ret->options = OPT_PROTO_MAIL_CHECK; | 688 ret->options = OPT_PROTO_MAIL_CHECK; |
689 ret->checkbox = _("Send offline message"); | |
748 ret->name = yahoo_name; | 690 ret->name = yahoo_name; |
749 ret->list_icon = yahoo_list_icon; | 691 ret->list_icon = yahoo_list_icon; |
750 ret->away_states = yahoo_away_states; | 692 ret->away_states = yahoo_away_states; |
751 ret->actions = yahoo_actions; | 693 ret->actions = yahoo_actions; |
752 ret->do_action = yahoo_do_action; | 694 ret->do_action = yahoo_do_action; |
753 ret->buddy_menu = yahoo_buddy_menu; | 695 ret->buddy_menu = yahoo_buddy_menu; |
754 ret->user_opts = yahoo_user_opts; | 696 ret->user_opts = yahoo_user_opts; |
755 ret->insert_convo = yahoo_insert_convo; | |
756 ret->remove_convo = yahoo_remove_convo; | |
757 ret->login = yahoo_login; | 697 ret->login = yahoo_login; |
758 ret->close = yahoo_close; | 698 ret->close = yahoo_close; |
759 ret->send_im = yahoo_send_im; | 699 ret->send_im = yahoo_send_im; |
760 ret->set_info = NULL; | 700 ret->set_info = NULL; |
761 ret->get_info = NULL; | 701 ret->get_info = NULL; |