diff 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
line wrap: on
line diff
--- a/src/protocols/yahoo/yay.c	Wed Aug 22 17:25:33 2001 +0000
+++ b/src/protocols/yahoo/yay.c	Wed Aug 22 21:11:58 2001 +0000
@@ -197,17 +197,8 @@
 	return 1;
 }
 
-static void des_win(GtkWidget *w, struct yahoo_data *yd) {
-	gtk_widget_destroy(yd->email_win);
-	if (yd->email_win == w)
-		yd->email_win = NULL;
-	yd->email_label = NULL;
-}
-
 static int yahoo_newmail(struct yahoo_session *sess, ...) {
 	struct gaim_connection *gc = sess->user_data;
-	struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
-	char buf[2048];
 
 	va_list ap;
 	int count;
@@ -216,39 +207,7 @@
 	count = va_arg(ap, int);
 	va_end(ap);
 
-	if (gc->user->proto_opt[USEROPT_MAIL][0] != '1')
-		return 1;
-
-	if (count) {
-		g_snprintf(buf, sizeof buf, "%s has %d new message%s on Yahoo Mail.",
-				gc->username, count, count == 1 ? "" : "s");
-		if (!yd->email_win) {
-			GtkWidget *close;
-
-			yd->email_win = gtk_dialog_new();
-			gtk_window_set_policy(GTK_WINDOW(yd->email_win), 0, 0, 1);
-			gtk_container_set_border_width(GTK_CONTAINER(yd->email_win), 5);
-			gtk_window_set_title(GTK_WINDOW(yd->email_win), "New Mail");
-			gtk_signal_connect(GTK_OBJECT(yd->email_win), "destroy",
-					   GTK_SIGNAL_FUNC(des_win), yd);
-			gtk_widget_realize(yd->email_win);
-			aol_icon(yd->email_win->window);
-
-			yd->email_label = gtk_label_new(buf);
-			gtk_box_pack_start(GTK_BOX(GTK_DIALOG(yd->email_win)->vbox),
-				yd->email_label, 0, 0, 5);
-			gtk_widget_show(yd->email_label);
-
-			close = picture_button(yd->email_win, _("Close"), cancel_xpm);
-			gtk_box_pack_start(GTK_BOX(GTK_DIALOG(yd->email_win)->action_area),
-					close, 0, 0, 5);
-			gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(des_win), yd);
-
-			gtk_widget_show(yd->email_win);
-		}
-		gtk_label_set_text(GTK_LABEL(yd->email_label), buf);
-	} else if (yd->email_win)
-		gtk_widget_destroy(yd->email_win);
+	connection_has_mail(gc, count, NULL, NULL);
 
 	return 1;
 }
@@ -698,39 +657,6 @@
 	return m;
 }
 
-struct mod_usr_opt {
-	struct aim_user *user;
-	int opt;
-};
-
-static void mod_opt(GtkWidget *b, struct mod_usr_opt *m)
-{
-	if (m->user->proto_opt[m->opt][0] == '1')
-		m->user->proto_opt[m->opt][0] = '\0';
-	else
-		strcpy(m->user->proto_opt[m->opt],"1");
-}
-
-static void free_muo(GtkWidget *b, struct mod_usr_opt *m)
-{
-	g_free(m);
-}
-
-static GtkWidget *yahoo_protoopt_button(const char *text, struct aim_user *u, int option, GtkWidget *box)
-{
-	GtkWidget *button;
-	struct mod_usr_opt *muo = g_new0(struct mod_usr_opt, 1);
-	button = gtk_check_button_new_with_label(text);
-	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (u->proto_opt[option][0] == '1'));
-	gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
-	muo->user = u;
-	muo->opt = option;
-	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(mod_opt), muo);
-	gtk_signal_connect(GTK_OBJECT(button), "destroy", GTK_SIGNAL_FUNC(free_muo), muo);
-	gtk_widget_show(button);
-	return button;
-}
-
 static void yahoo_print_option(GtkEntry *entry, struct aim_user *user) {
 	int entrynum;
 	
@@ -767,7 +693,6 @@
 	gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("Yahoo Options"));
 	gtk_widget_show(vbox);
 
-	yahoo_protoopt_button("Notify me of new Yahoo! Mail", user, USEROPT_MAIL, vbox);
 	hbox = gtk_hbox_new(FALSE, 5);
 	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
 	gtk_widget_show(hbox);
@@ -908,6 +833,7 @@
 void yahoo_init(struct prpl *ret) {
 	/* the NULL's aren't required but they're nice to have */
 	ret->protocol = PROTO_YAHOO;
+	ret->options = OPT_PROTO_MAIL_CHECK;
 	ret->name = yahoo_name;
 	ret->list_icon = yahoo_list_icon;
 	ret->away_states = yahoo_away_states;