Mercurial > pidgin
comparison src/protocols/yahoo/yay.c @ 2153:0befa2d2e540
[gaim-migrate @ 2163]
moving mail notifications to the core. this makes things much easier on the protocols. next steps: make buddy right-click menu stuff generated by the core (based on information provided by the protocols, similar to the away menu stuff); make entry-widget protocol-specific user options generated by the core based on what the protocols tell it (in a similar way).
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 22 Aug 2001 21:11:58 +0000 |
parents | 91223be78b70 |
children | cff133e0ec0c |
comparison
equal
deleted
inserted
replaced
2152:f631cfc8e824 | 2153:0befa2d2e540 |
---|---|
195 do_error_dialog(buf, _("Gaim - Buddy")); | 195 do_error_dialog(buf, _("Gaim - Buddy")); |
196 | 196 |
197 return 1; | 197 return 1; |
198 } | 198 } |
199 | 199 |
200 static void des_win(GtkWidget *w, struct yahoo_data *yd) { | |
201 gtk_widget_destroy(yd->email_win); | |
202 if (yd->email_win == w) | |
203 yd->email_win = NULL; | |
204 yd->email_label = NULL; | |
205 } | |
206 | |
207 static int yahoo_newmail(struct yahoo_session *sess, ...) { | 200 static int yahoo_newmail(struct yahoo_session *sess, ...) { |
208 struct gaim_connection *gc = sess->user_data; | 201 struct gaim_connection *gc = sess->user_data; |
209 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
210 char buf[2048]; | |
211 | 202 |
212 va_list ap; | 203 va_list ap; |
213 int count; | 204 int count; |
214 | 205 |
215 va_start(ap, sess); | 206 va_start(ap, sess); |
216 count = va_arg(ap, int); | 207 count = va_arg(ap, int); |
217 va_end(ap); | 208 va_end(ap); |
218 | 209 |
219 if (gc->user->proto_opt[USEROPT_MAIL][0] != '1') | 210 connection_has_mail(gc, count, NULL, NULL); |
220 return 1; | |
221 | |
222 if (count) { | |
223 g_snprintf(buf, sizeof buf, "%s has %d new message%s on Yahoo Mail.", | |
224 gc->username, count, count == 1 ? "" : "s"); | |
225 if (!yd->email_win) { | |
226 GtkWidget *close; | |
227 | |
228 yd->email_win = gtk_dialog_new(); | |
229 gtk_window_set_policy(GTK_WINDOW(yd->email_win), 0, 0, 1); | |
230 gtk_container_set_border_width(GTK_CONTAINER(yd->email_win), 5); | |
231 gtk_window_set_title(GTK_WINDOW(yd->email_win), "New Mail"); | |
232 gtk_signal_connect(GTK_OBJECT(yd->email_win), "destroy", | |
233 GTK_SIGNAL_FUNC(des_win), yd); | |
234 gtk_widget_realize(yd->email_win); | |
235 aol_icon(yd->email_win->window); | |
236 | |
237 yd->email_label = gtk_label_new(buf); | |
238 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(yd->email_win)->vbox), | |
239 yd->email_label, 0, 0, 5); | |
240 gtk_widget_show(yd->email_label); | |
241 | |
242 close = picture_button(yd->email_win, _("Close"), cancel_xpm); | |
243 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(yd->email_win)->action_area), | |
244 close, 0, 0, 5); | |
245 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(des_win), yd); | |
246 | |
247 gtk_widget_show(yd->email_win); | |
248 } | |
249 gtk_label_set_text(GTK_LABEL(yd->email_label), buf); | |
250 } else if (yd->email_win) | |
251 gtk_widget_destroy(yd->email_win); | |
252 | 211 |
253 return 1; | 212 return 1; |
254 } | 213 } |
255 | 214 |
256 static int yahoo_disconn(struct yahoo_session *sess, ...) { | 215 static int yahoo_disconn(struct yahoo_session *sess, ...) { |
696 m = g_list_append(m, "Activate ID"); | 655 m = g_list_append(m, "Activate ID"); |
697 | 656 |
698 return m; | 657 return m; |
699 } | 658 } |
700 | 659 |
701 struct mod_usr_opt { | |
702 struct aim_user *user; | |
703 int opt; | |
704 }; | |
705 | |
706 static void mod_opt(GtkWidget *b, struct mod_usr_opt *m) | |
707 { | |
708 if (m->user->proto_opt[m->opt][0] == '1') | |
709 m->user->proto_opt[m->opt][0] = '\0'; | |
710 else | |
711 strcpy(m->user->proto_opt[m->opt],"1"); | |
712 } | |
713 | |
714 static void free_muo(GtkWidget *b, struct mod_usr_opt *m) | |
715 { | |
716 g_free(m); | |
717 } | |
718 | |
719 static GtkWidget *yahoo_protoopt_button(const char *text, struct aim_user *u, int option, GtkWidget *box) | |
720 { | |
721 GtkWidget *button; | |
722 struct mod_usr_opt *muo = g_new0(struct mod_usr_opt, 1); | |
723 button = gtk_check_button_new_with_label(text); | |
724 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (u->proto_opt[option][0] == '1')); | |
725 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); | |
726 muo->user = u; | |
727 muo->opt = option; | |
728 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(mod_opt), muo); | |
729 gtk_signal_connect(GTK_OBJECT(button), "destroy", GTK_SIGNAL_FUNC(free_muo), muo); | |
730 gtk_widget_show(button); | |
731 return button; | |
732 } | |
733 | |
734 static void yahoo_print_option(GtkEntry *entry, struct aim_user *user) { | 660 static void yahoo_print_option(GtkEntry *entry, struct aim_user *user) { |
735 int entrynum; | 661 int entrynum; |
736 | 662 |
737 entrynum = (int) gtk_object_get_user_data(GTK_OBJECT(entry)); | 663 entrynum = (int) gtk_object_get_user_data(GTK_OBJECT(entry)); |
738 | 664 |
765 vbox = gtk_vbox_new(FALSE, 5); | 691 vbox = gtk_vbox_new(FALSE, 5); |
766 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); | 692 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
767 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("Yahoo Options")); | 693 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("Yahoo Options")); |
768 gtk_widget_show(vbox); | 694 gtk_widget_show(vbox); |
769 | 695 |
770 yahoo_protoopt_button("Notify me of new Yahoo! Mail", user, USEROPT_MAIL, vbox); | |
771 hbox = gtk_hbox_new(FALSE, 5); | 696 hbox = gtk_hbox_new(FALSE, 5); |
772 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 697 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
773 gtk_widget_show(hbox); | 698 gtk_widget_show(hbox); |
774 | 699 |
775 label = gtk_label_new("Yahoo Auth Host:"); | 700 label = gtk_label_new("Yahoo Auth Host:"); |
906 static struct prpl *my_protocol = NULL; | 831 static struct prpl *my_protocol = NULL; |
907 | 832 |
908 void yahoo_init(struct prpl *ret) { | 833 void yahoo_init(struct prpl *ret) { |
909 /* the NULL's aren't required but they're nice to have */ | 834 /* the NULL's aren't required but they're nice to have */ |
910 ret->protocol = PROTO_YAHOO; | 835 ret->protocol = PROTO_YAHOO; |
836 ret->options = OPT_PROTO_MAIL_CHECK; | |
911 ret->name = yahoo_name; | 837 ret->name = yahoo_name; |
912 ret->list_icon = yahoo_list_icon; | 838 ret->list_icon = yahoo_list_icon; |
913 ret->away_states = yahoo_away_states; | 839 ret->away_states = yahoo_away_states; |
914 ret->actions = yahoo_actions; | 840 ret->actions = yahoo_actions; |
915 ret->do_action = yahoo_do_action; | 841 ret->do_action = yahoo_do_action; |