Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/notification.c @ 21100:29d8c86c14cd
propagate from branch 'im.pidgin.pidgin' (head cd2be742f6c45c200000003fc5a6341297bbe857)
to branch 'im.pidgin.cpw.khc.msnp14.soap' (head 1d7d51174ae87c7f03bb1290a8e447bf2a1704a5)
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Thu, 04 Oct 2007 06:13:01 +0000 |
parents | c49b886231d5 58ce69a8582d |
children | 741c3b5eac21 |
comparison
equal
deleted
inserted
replaced
20537:c49b886231d5 | 21100:29d8c86c14cd |
---|---|
99 connect_cb(MsnServConn *servconn) | 99 connect_cb(MsnServConn *servconn) |
100 { | 100 { |
101 MsnCmdProc *cmdproc; | 101 MsnCmdProc *cmdproc; |
102 MsnSession *session; | 102 MsnSession *session; |
103 PurpleAccount *account; | 103 PurpleAccount *account; |
104 char **a, **c, *vers; | 104 GString *vers; |
105 const char *ver_str; | |
105 int i; | 106 int i; |
106 | 107 |
107 g_return_if_fail(servconn != NULL); | 108 g_return_if_fail(servconn != NULL); |
108 | 109 |
109 cmdproc = servconn->cmdproc; | 110 cmdproc = servconn->cmdproc; |
110 session = servconn->session; | 111 session = servconn->session; |
111 account = session->account; | 112 account = session->account; |
112 | 113 |
113 /* Allocate an array for CVR0, NULL, and all the versions */ | 114 vers = g_string_new(""); |
114 // a = c = g_new0(char *, session->protocol_ver - WLM_MIN_PROTOCOL + 3); | 115 |
115 a = c = g_new0(char *, WLM_MAX_PROTOCOL - WLM_MIN_PROTOCOL + 3); | 116 /* for (i = session->protocol_ver; i >= WLM_MIN_PROTOCOL; i--) */ |
116 | |
117 // for (i = session->protocol_ver; i >= WLM_MIN_PROTOCOL; i--) | |
118 for (i = WLM_MAX_PROTOCOL; i >= WLM_MIN_PROTOCOL; i--) | 117 for (i = WLM_MAX_PROTOCOL; i >= WLM_MIN_PROTOCOL; i--) |
119 *c++ = g_strdup_printf("MSNP%d", i); | 118 g_string_append_printf(vers, " MSNP%d", i); |
120 | 119 |
121 *c++ = g_strdup("CVR0"); | 120 g_string_append(vers, " CVR0"); |
122 | |
123 vers = g_strjoinv(" ", a); | |
124 | 121 |
125 if (session->login_step == MSN_LOGIN_STEP_START) | 122 if (session->login_step == MSN_LOGIN_STEP_START) |
126 { | |
127 msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE); | 123 msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE); |
128 } | |
129 else | 124 else |
130 { | |
131 msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE2); | 125 msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE2); |
132 } | 126 |
133 | 127 /* Skip the initial space */ |
134 msn_cmdproc_send(cmdproc, "VER", "%s", vers); | 128 ver_str = (vers->str + 1); |
135 | 129 msn_cmdproc_send(cmdproc, "VER", "%s", ver_str); |
136 g_strfreev(a); | 130 |
137 g_free(vers); | 131 g_string_free(vers, TRUE); |
138 } | 132 } |
139 | 133 |
140 gboolean | 134 gboolean |
141 msn_notification_connect(MsnNotification *notification, const char *host, int port) | 135 msn_notification_connect(MsnNotification *notification, const char *host, int port) |
142 { | 136 { |
187 else | 181 else |
188 { | 182 { |
189 const char *group_name; | 183 const char *group_name; |
190 group_name = msn_userlist_find_group_name(session->userlist,group_id); | 184 group_name = msn_userlist_find_group_name(session->userlist,group_id); |
191 reason = g_strdup_printf(_("%s is not a valid group."), | 185 reason = g_strdup_printf(_("%s is not a valid group."), |
192 group_name); | 186 group_name ? group_name : ""); |
193 } | 187 } |
194 } | 188 } |
195 else | 189 else |
196 { | 190 { |
197 reason = g_strdup(_("Unknown error.")); | 191 reason = g_strdup(_("Unknown error.")); |
586 static void | 580 static void |
587 msn_add_contact_xml(MsnSession *session, xmlnode *mlNode,const char *passport, MsnListOp list_op, MsnUserType type) | 581 msn_add_contact_xml(MsnSession *session, xmlnode *mlNode,const char *passport, MsnListOp list_op, MsnUserType type) |
588 { | 582 { |
589 xmlnode *d_node,*c_node; | 583 xmlnode *d_node,*c_node; |
590 char **tokens; | 584 char **tokens; |
591 char *email,*domain; | 585 const char *email,*domain; |
592 char *list_op_str,*type_str; | 586 char fmt_str[3]; |
587 | |
588 g_return_if_fail(passport != NULL); | |
593 | 589 |
594 purple_debug_info("MSNP14","Passport: %s, type: %d\n", passport, type); | 590 purple_debug_info("MSNP14","Passport: %s, type: %d\n", passport, type); |
595 tokens = g_strsplit(passport, "@", 2); | 591 tokens = g_strsplit(passport, "@", 2); |
596 email = tokens[0]; | 592 email = tokens[0]; |
597 domain = tokens[1]; | 593 domain = tokens[1]; |
598 | 594 |
595 if (email == NULL || domain == NULL) { | |
596 purple_debug_error("msn", "Invalid passport (%s) specified to add to contact xml.\n", passport); | |
597 g_strfreev(tokens); | |
598 g_return_if_reached(); | |
599 } | |
600 | |
599 /*find a domain Node*/ | 601 /*find a domain Node*/ |
600 for(d_node = xmlnode_get_child(mlNode,"d"); d_node; d_node = xmlnode_get_next_twin(d_node)) | 602 for(d_node = xmlnode_get_child(mlNode,"d"); d_node; d_node = xmlnode_get_next_twin(d_node)) |
601 { | 603 { |
602 const char * attr = NULL; | 604 const char *attr = xmlnode_get_attrib(d_node,"n"); |
603 purple_debug_info("MSNP14","d_node: %s\n",d_node->name); | 605 if (attr == NULL) |
604 attr = xmlnode_get_attrib(d_node,"n"); | |
605 if(attr == NULL){ | |
606 continue; | 606 continue; |
607 } | 607 if (!strcmp(attr,domain)) |
608 if(!strcmp(attr,domain)){ | |
609 break; | 608 break; |
610 } | 609 } |
611 } | 610 |
612 if(d_node == NULL) | 611 if(d_node == NULL) |
613 { | 612 { |
614 /*domain not found, create a new domain Node*/ | 613 /*domain not found, create a new domain Node*/ |
615 purple_debug_info("MSNP14","get No d_node\n"); | 614 purple_debug_info("msn", "Didn't find existing domain node, adding one.\n"); |
616 d_node = xmlnode_new("d"); | 615 d_node = xmlnode_new("d"); |
617 xmlnode_set_attrib(d_node,"n",domain); | 616 xmlnode_set_attrib(d_node, "n", domain); |
618 xmlnode_insert_child(mlNode,d_node); | 617 xmlnode_insert_child(mlNode, d_node); |
619 } | 618 } |
620 | 619 |
621 /*create contact node*/ | 620 /*create contact node*/ |
622 c_node = xmlnode_new("c"); | 621 c_node = xmlnode_new("c"); |
623 xmlnode_set_attrib(c_node,"n",email); | 622 xmlnode_set_attrib(c_node, "n", email); |
624 | 623 |
625 list_op_str = g_strdup_printf("%d",list_op); | 624 purple_debug_info("MSNP14", "list_op: %d\n", list_op); |
626 purple_debug_info("MSNP14","list_op: %d\n",list_op); | 625 g_snprintf(fmt_str, sizeof(fmt_str), "%d", list_op); |
627 xmlnode_set_attrib(c_node,"l",list_op_str); | 626 xmlnode_set_attrib(c_node, "l", fmt_str); |
628 g_free(list_op_str); | 627 |
629 | 628 if (type != MSN_USER_TYPE_UNKNOWN) |
630 if (type != MSN_USER_TYPE_UNKNOWN) { | 629 g_snprintf(fmt_str, sizeof(fmt_str), "%d", type); |
631 type_str = g_strdup_printf("%d", type); | 630 else if (msn_user_is_yahoo(session->account, passport)) |
632 } else { | 631 g_snprintf(fmt_str, sizeof(fmt_str), "%d", MSN_USER_TYPE_YAHOO); |
633 if (msn_user_is_yahoo(session->account, passport)) | 632 else |
634 type_str = g_strdup_printf("%d", MSN_USER_TYPE_YAHOO); | 633 g_snprintf(fmt_str, sizeof(fmt_str), "%d", MSN_USER_TYPE_PASSPORT); |
635 else | 634 |
636 type_str = g_strdup_printf("%d", MSN_USER_TYPE_PASSPORT); | |
637 } | |
638 /*mobile*/ | 635 /*mobile*/ |
639 //type_str = g_strdup_printf("4"); | 636 //type_str = g_strdup_printf("4"); |
640 xmlnode_set_attrib(c_node,"t",type_str); | 637 xmlnode_set_attrib(c_node, "t", fmt_str); |
641 g_free(type_str); | |
642 | 638 |
643 xmlnode_insert_child(d_node, c_node); | 639 xmlnode_insert_child(d_node, c_node); |
644 | 640 |
645 g_strfreev(tokens); | 641 g_strfreev(tokens); |
646 } | 642 } |
1202 static void | 1198 static void |
1203 prp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | 1199 prp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
1204 { | 1200 { |
1205 MsnSession *session = cmdproc->session; | 1201 MsnSession *session = cmdproc->session; |
1206 const char *type, *value, *friendlyname; | 1202 const char *type, *value, *friendlyname; |
1207 | |
1208 purple_debug_info("MSN Notification", "prp_cmd()\n"); | |
1209 | 1203 |
1210 g_return_if_fail(cmd->param_count >= 3); | 1204 g_return_if_fail(cmd->param_count >= 3); |
1211 | 1205 |
1212 type = cmd->params[2]; | 1206 type = cmd->params[2]; |
1213 | 1207 |