comparison src/protocols/msn/notification.c @ 5318:bd98232872a3

[gaim-migrate @ 5690] Renaming a group on the buddy list now renames the group on the server-stored buddy list. Also, we updated to MSNP7 on the notification server as well! Yay! committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 06 May 2003 23:07:12 +0000
parents 89948fedf782
children a4d017bee1de
comparison
equal deleted inserted replaced
5317:2b437c18719e 5318:bd98232872a3
108 108
109 static gboolean 109 static gboolean
110 __unknown_cmd(MsnServConn *servconn, const char *command, const char **params, 110 __unknown_cmd(MsnServConn *servconn, const char *command, const char **params,
111 size_t param_count) 111 size_t param_count)
112 { 112 {
113 struct gaim_connection *gc = servconn->session->account->gc; 113 char buf[MSN_BUF_LEN];
114 114
115 if (isdigit(*command)) { 115 g_snprintf(buf, sizeof(buf), "MSN Error: %s\n",
116 hide_login_progress(gc, (char *)msn_error_get_text(atoi(command))); 116 (isdigit(*command)
117 } 117 ? msn_error_get_text(atoi(command))
118 else 118 : "Unable to parse message."));
119 hide_login_progress(gc, _("Unable to parse message.")); 119
120 120 do_error_dialog(buf, NULL, GAIM_ERROR);
121 signoff(gc); 121
122 122 return TRUE;
123 return FALSE;
124 } 123 }
125 124
126 125
127 /************************************************************************** 126 /**************************************************************************
128 * Login 127 * Login
438 { 437 {
439 MsnSession *session = servconn->session; 438 MsnSession *session = servconn->session;
440 struct group *g; 439 struct group *g;
441 const char *name; 440 const char *name;
442 int group_num, num_groups, group_id; 441 int group_num, num_groups, group_id;
442 gint *group_id_1, *group_id_2;
443 443
444 group_num = atoi(params[2]); 444 group_num = atoi(params[2]);
445 num_groups = atoi(params[3]); 445 num_groups = atoi(params[3]);
446 group_id = atoi(params[4]); 446 group_id = atoi(params[4]);
447 name = msn_url_decode(params[5]); 447 name = msn_url_decode(params[5]);
448 448
449 if (num_groups == 0)
450 return TRUE;
451
449 if (group_num == 1) { 452 if (group_num == 1) {
450 session->groups = g_hash_table_new_full(g_int_hash, g_int_equal, 453 session->group_names = g_hash_table_new_full(g_int_hash, g_int_equal,
451 NULL, g_free); 454 g_free, g_free);
452 } 455 session->group_ids = g_hash_table_new_full(g_str_hash, g_str_equal,
453 456 g_free, g_free);
454 g_hash_table_insert(session->groups, GINT_TO_POINTER(group_id), 457 }
455 g_strdup(name)); 458
459 group_id_1 = g_new(gint, 1);
460 group_id_2 = g_new(gint, 1);
461
462 *group_id_1 = group_id;
463 *group_id_2 = group_id;
464
465 g_hash_table_insert(session->group_names, group_id_1, g_strdup(name));
466 g_hash_table_insert(session->group_ids, g_strdup(name), group_id_2);
456 467
457 if ((g = gaim_find_group(name)) == NULL) { 468 if ((g = gaim_find_group(name)) == NULL) {
458 g = gaim_group_new(name); 469 g = gaim_group_new(name);
459 gaim_blist_add_group(g, NULL); 470 gaim_blist_add_group(g, NULL);
460 } 471 }
583 int group_id; 594 int group_id;
584 595
585 group_id = msn_user_get_group_id(user); 596 group_id = msn_user_get_group_id(user);
586 597
587 if (group_id > -1) { 598 if (group_id > -1) {
588 group_name = g_hash_table_lookup(session->groups, 599 group_name = g_hash_table_lookup(session->group_names,
589 GINT_TO_POINTER(group_id)); 600 &group_id);
590 } 601 }
591 602
592 if (group_name == NULL) { 603 if (group_name == NULL) {
593 gaim_debug(GAIM_DEBUG_WARNING, "msn", 604 gaim_debug(GAIM_DEBUG_WARNING, "msn",
594 "Group ID %d for user %s was not defined.\n", 605 "Group ID %d for user %s was not defined.\n",
668 char *friend; 679 char *friend;
669 680
670 friend = msn_url_decode(params[2]); 681 friend = msn_url_decode(params[2]);
671 682
672 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend); 683 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend);
684
685 return TRUE;
686 }
687
688 static gboolean
689 __reg_cmd(MsnServConn *servconn, const char *command, const char **params,
690 size_t param_count)
691 {
692 MsnSession *session = servconn->session;
693 gint *group_id;
694 char *group_name;
695
696 group_id = g_new(gint, 1);
697 *group_id = atoi(params[2]);
698
699 group_name = msn_url_decode(params[3]);
700
701 gaim_debug(GAIM_DEBUG_INFO, "msn", "Renamed group %s to %s\n",
702 g_hash_table_lookup(session->group_names, group_id),
703 group_name);
704
705 g_hash_table_replace(session->group_names, group_id, g_strdup(group_name));
706
707 g_hash_table_remove(session->group_ids, group_name);
708 g_hash_table_insert(session->group_ids, group_name, group_id);
673 709
674 return TRUE; 710 return TRUE;
675 } 711 }
676 712
677 /************************************************************************** 713 /**************************************************************************
971 1007
972 if (notification->fd != source) 1008 if (notification->fd != source)
973 notification->fd = source; 1009 notification->fd = source;
974 1010
975 if (!msn_servconn_send_command(notification, "VER", 1011 if (!msn_servconn_send_command(notification, "VER",
976 "MSNP6 MSNP5 MSNP4 CVR0")) { 1012 "MSNP7 MSNP6 MSNP5 MSNP4 CVR0")) {
977 hide_login_progress(gc, _("Unable to write to server")); 1013 hide_login_progress(gc, _("Unable to write to server"));
978 signoff(gc); 1014 signoff(gc);
979 return FALSE; 1015 return FALSE;
980 } 1016 }
981 1017
1025 msn_servconn_register_command(notification, "OUT", __out_cmd); 1061 msn_servconn_register_command(notification, "OUT", __out_cmd);
1026 msn_servconn_register_command(notification, "PRP", __blank_cmd); 1062 msn_servconn_register_command(notification, "PRP", __blank_cmd);
1027 msn_servconn_register_command(notification, "QNG", __blank_cmd); 1063 msn_servconn_register_command(notification, "QNG", __blank_cmd);
1028 msn_servconn_register_command(notification, "QRY", __blank_cmd); 1064 msn_servconn_register_command(notification, "QRY", __blank_cmd);
1029 msn_servconn_register_command(notification, "REA", __rea_cmd); 1065 msn_servconn_register_command(notification, "REA", __rea_cmd);
1066 msn_servconn_register_command(notification, "REG", __reg_cmd);
1030 msn_servconn_register_command(notification, "REM", __blank_cmd); 1067 msn_servconn_register_command(notification, "REM", __blank_cmd);
1031 msn_servconn_register_command(notification, "RNG", __rng_cmd); 1068 msn_servconn_register_command(notification, "RNG", __rng_cmd);
1032 msn_servconn_register_command(notification, "SYN", __blank_cmd); 1069 msn_servconn_register_command(notification, "SYN", __blank_cmd);
1033 msn_servconn_register_command(notification, "URL", __url_cmd); 1070 msn_servconn_register_command(notification, "URL", __url_cmd);
1034 msn_servconn_register_command(notification, "USR", __usr_cmd); 1071 msn_servconn_register_command(notification, "USR", __usr_cmd);