comparison src/protocols/msn/msn.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 f631cfc8e824
children a464da684307
comparison
equal deleted inserted replaced
2152:f631cfc8e824 2153:0befa2d2e540
243 return msg; 243 return msg;
244 } 244 }
245 245
246 static void handle_hotmail(struct gaim_connection *gc, char *data) 246 static void handle_hotmail(struct gaim_connection *gc, char *data)
247 { 247 {
248 char *mailct, *mailp, *from = NULL, *subj = NULL, notice[MSN_BUF_LEN]; 248 if (strstr(data, "Content-Type: text/x-msmsgsinitialemailnotification;")) {
249 249 char *x = strstr(data, "Inbox-Unread:");
250 if (gc->user->proto_opt[USEROPT_HOTMAIL][0] != '1') return; 250 if (!x) return;
251 mailct = strstr(data, "Content-Type: "); 251 x += strlen("Inbox-Unread: ");
252 mailp = strstr(mailct, ";"); 252 connection_has_mail(gc, atoi(x), NULL, NULL);
253 if (mailct && mailp && (mailp > mailct) && 253 } else if (strstr(data, "Content-Type: text/x-msmsgsemailnotification;")) {
254 !strncmp(mailct, "Content-Type: text/x-msmsgsemailnotification", mailp - mailct - 1)) { 254 char *from = strstr(data, "From:");
255 from = strstr(mailp, "From: "); 255 char *subject = strstr(data, "Subject:");
256 subj = strstr(mailp, "Subject: "); 256 char *x;
257 } 257 if (!from || !subject) {
258 258 connection_has_mail(gc, 1, NULL, NULL);
259 if (!from || !subj) 259 return;
260 return; 260 }
261 261 from += strlen("From: ");
262 from += strlen("From: "); 262 x = strstr(from, "\r\n"); *x = 0;
263 mailp = strstr(from, "\r\n"); 263 subject += strlen("Subject: ");
264 if (!mailp) return; 264 x = strstr(subject, "\r\n"); *x = 0;
265 *mailp = 0; 265 connection_has_mail(gc, -1, from, subject);
266 266 }
267 subj += strlen("Subject: ");
268 mailp = strstr(from, "\r\n");
269 if (!mailp) return;
270 *mailp = 0;
271
272 g_snprintf(notice, sizeof(notice), "Mail from %s, re: %s", from, subj);
273 do_error_dialog(notice, "New MSN Mail");
274 } 267 }
275 268
276 static struct msn_switchboard *msn_find_switch(struct gaim_connection *gc, char *id) 269 static struct msn_switchboard *msn_find_switch(struct gaim_connection *gc, char *id)
277 { 270 {
278 struct msn_data *md = gc->proto_data; 271 struct msn_data *md = gc->proto_data;
1338 button = gtk_menu_item_new_with_label(buf); 1331 button = gtk_menu_item_new_with_label(buf);
1339 gtk_menu_append(GTK_MENU(menu), button); 1332 gtk_menu_append(GTK_MENU(menu), button);
1340 gtk_widget_show(button); 1333 gtk_widget_show(button);
1341 } 1334 }
1342 1335
1343 struct mod_usr_opt {
1344 struct aim_user *user;
1345 int opt;
1346 };
1347
1348 static void mod_opt(GtkWidget *b, struct mod_usr_opt *m)
1349 {
1350 if (m->user) {
1351 if (m->user->proto_opt[m->opt][0] == '1')
1352 m->user->proto_opt[m->opt][0] = '\0';
1353 else
1354 strcpy(m->user->proto_opt[m->opt],"1");
1355 }
1356 }
1357
1358 static void free_muo(GtkWidget *b, struct mod_usr_opt *m)
1359 {
1360 g_free(m);
1361 }
1362
1363 static GtkWidget *msn_protoopt_button(const char *text, struct aim_user *u, int option, GtkWidget *box)
1364 {
1365 GtkWidget *button;
1366 struct mod_usr_opt *muo = g_new0(struct mod_usr_opt, 1);
1367 button = gtk_check_button_new_with_label(text);
1368 if (u)
1369 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (u->proto_opt[option][0] == '1'));
1370 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
1371 muo->user = u;
1372 muo->opt = option;
1373 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(mod_opt), muo);
1374 gtk_signal_connect(GTK_OBJECT(button), "destroy", GTK_SIGNAL_FUNC(free_muo), muo);
1375 gtk_widget_show(button);
1376
1377 return button;
1378 }
1379
1380 static void msn_user_opts(GtkWidget* book, struct aim_user *user)
1381 {
1382 GtkWidget *vbox;
1383
1384 vbox = gtk_vbox_new(FALSE, 5);
1385 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1386 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("MSN Options"));
1387 gtk_widget_show(vbox);
1388
1389 msn_protoopt_button("Notify me of new HotMail",user,USEROPT_HOTMAIL,vbox);
1390 }
1391
1392 static void msn_add_buddy(struct gaim_connection *gc, char *who) 1336 static void msn_add_buddy(struct gaim_connection *gc, char *who)
1393 { 1337 {
1394 struct msn_data *md = gc->proto_data; 1338 struct msn_data *md = gc->proto_data;
1395 char buf[MSN_BUF_LEN]; 1339 char buf[MSN_BUF_LEN];
1396 GSList *l = md->fl; 1340 GSList *l = md->fl;
1428 static struct prpl *my_protocol = NULL; 1372 static struct prpl *my_protocol = NULL;
1429 1373
1430 void msn_init(struct prpl *ret) 1374 void msn_init(struct prpl *ret)
1431 { 1375 {
1432 ret->protocol = PROTO_MSN; 1376 ret->protocol = PROTO_MSN;
1377 ret->options = OPT_PROTO_MAIL_CHECK;
1433 ret->name = msn_name; 1378 ret->name = msn_name;
1434 ret->list_icon = msn_list_icon; 1379 ret->list_icon = msn_list_icon;
1435 ret->buddy_menu = msn_buddy_menu; 1380 ret->buddy_menu = msn_buddy_menu;
1436 ret->user_opts = msn_user_opts;
1437 ret->login = msn_login; 1381 ret->login = msn_login;
1438 ret->close = msn_close; 1382 ret->close = msn_close;
1439 ret->send_im = msn_send_im; 1383 ret->send_im = msn_send_im;
1440 ret->away_states = msn_away_states; 1384 ret->away_states = msn_away_states;
1441 ret->set_away = msn_set_away; 1385 ret->set_away = msn_set_away;