Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/notification.c @ 31292:47b6eda87723
propagate from branch 'im.pidgin.pidgin' (head 07d0765c444a097af45c2650f54323afb900a07b)
to branch 'im.pidgin.soc.2010.msn-tlc' (head f3998422a4724ab424e4e2328f58fc0504856557)
author | masca@cpw.pidgin.im |
---|---|
date | Mon, 19 Jul 2010 21:11:32 +0000 |
parents | 88a047f92c39 c7fa7c7aca7d |
children | 23be655cc688 |
comparison
equal
deleted
inserted
replaced
30698:e874875a74a7 | 31292:47b6eda87723 |
---|---|
19 * | 19 * |
20 * You should have received a copy of the GNU General Public License | 20 * You should have received a copy of the GNU General Public License |
21 * along with this program; if not, write to the Free Software | 21 * along with this program; if not, write to the Free Software |
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
23 */ | 23 */ |
24 #include "msn.h" | 24 |
25 #include "internal.h" | |
26 #include "cipher.h" | |
27 #include "core.h" | |
28 #include "debug.h" | |
29 | |
25 #include "notification.h" | 30 #include "notification.h" |
31 | |
26 #include "contact.h" | 32 #include "contact.h" |
27 #include "state.h" | |
28 #include "error.h" | 33 #include "error.h" |
29 #include "msnutils.h" | 34 #include "msnutils.h" |
30 #include "page.h" | 35 #include "state.h" |
31 | |
32 #include "userlist.h" | 36 #include "userlist.h" |
33 #include "sync.h" | |
34 #include "slplink.h" | |
35 | 37 |
36 static MsnTable *cbs_table; | 38 static MsnTable *cbs_table; |
37 | 39 |
38 /************************************************************************** | 40 /************************************************************************** |
39 * Main | 41 * Main |
90 static void | 92 static void |
91 connect_cb(MsnServConn *servconn) | 93 connect_cb(MsnServConn *servconn) |
92 { | 94 { |
93 MsnCmdProc *cmdproc; | 95 MsnCmdProc *cmdproc; |
94 MsnSession *session; | 96 MsnSession *session; |
97 MsnTransaction *trans; | |
95 PurpleAccount *account; | 98 PurpleAccount *account; |
96 GString *vers; | 99 GString *vers; |
97 const char *ver_str; | 100 const char *ver_str; |
98 int i; | 101 int i; |
99 | 102 |
115 else | 118 else |
116 msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE2); | 119 msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE2); |
117 | 120 |
118 /* Skip the initial space */ | 121 /* Skip the initial space */ |
119 ver_str = (vers->str + 1); | 122 ver_str = (vers->str + 1); |
120 msn_cmdproc_send(cmdproc, "VER", "%s", ver_str); | 123 trans = msn_transaction_new(cmdproc, "VER", "%s", ver_str); |
124 msn_cmdproc_send_trans(cmdproc, trans); | |
121 | 125 |
122 g_string_free(vers, TRUE); | 126 g_string_free(vers, TRUE); |
123 } | 127 } |
124 | 128 |
125 gboolean | 129 gboolean |
154 | 158 |
155 void | 159 void |
156 msn_got_login_params(MsnSession *session, const char *ticket, const char *response) | 160 msn_got_login_params(MsnSession *session, const char *ticket, const char *response) |
157 { | 161 { |
158 MsnCmdProc *cmdproc; | 162 MsnCmdProc *cmdproc; |
163 MsnTransaction *trans; | |
159 | 164 |
160 cmdproc = session->notification->cmdproc; | 165 cmdproc = session->notification->cmdproc; |
161 | 166 |
162 msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_END); | 167 msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_END); |
163 | 168 |
164 msn_cmdproc_send(cmdproc, "USR", "SSO S %s %s", ticket, response); | 169 if (session->protocol_ver >= 16) |
170 trans = msn_transaction_new(cmdproc, "USR", "SSO S %s %s %s", ticket, response, session->guid); | |
171 else | |
172 trans = msn_transaction_new(cmdproc, "USR", "SSO S %s %s", ticket, response); | |
173 | |
174 msn_cmdproc_send_trans(cmdproc, trans); | |
165 } | 175 } |
166 | 176 |
167 static void | 177 static void |
168 cvr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | 178 cvr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
169 { | 179 { |
170 PurpleAccount *account; | 180 PurpleAccount *account; |
181 MsnTransaction *trans; | |
171 | 182 |
172 account = cmdproc->session->account; | 183 account = cmdproc->session->account; |
173 | 184 |
174 msn_cmdproc_send(cmdproc, "USR", "SSO I %s", purple_account_get_username(account)); | 185 trans = msn_transaction_new(cmdproc, "USR", "SSO I %s", purple_account_get_username(account)); |
186 msn_cmdproc_send_trans(cmdproc, trans); | |
175 } | 187 } |
176 | 188 |
177 static void | 189 static void |
178 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | 190 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
179 { | 191 { |
229 | 241 |
230 static void | 242 static void |
231 ver_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | 243 ver_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
232 { | 244 { |
233 MsnSession *session; | 245 MsnSession *session; |
246 MsnTransaction *trans; | |
234 PurpleAccount *account; | 247 PurpleAccount *account; |
235 gboolean protocol_supported = FALSE; | 248 gboolean protocol_supported = FALSE; |
236 char proto_str[8]; | 249 int proto_ver; |
237 size_t i; | 250 size_t i; |
238 | 251 |
239 session = cmdproc->session; | 252 session = cmdproc->session; |
240 account = session->account; | 253 account = session->account; |
241 | 254 |
242 g_snprintf(proto_str, sizeof(proto_str), "MSNP%d", session->protocol_ver); | 255 session->protocol_ver = 0; |
243 | |
244 for (i = 1; i < cmd->param_count; i++) | 256 for (i = 1; i < cmd->param_count; i++) |
245 { | 257 { |
246 if (!strcmp(cmd->params[i], proto_str)) | 258 if (sscanf(cmd->params[i], "MSNP%d", &proto_ver) == 1) { |
247 { | 259 if (proto_ver >= WLM_MIN_PROTOCOL |
248 protocol_supported = TRUE; | 260 && proto_ver <= WLM_MAX_PROTOCOL |
249 break; | 261 && proto_ver > session->protocol_ver) { |
262 protocol_supported = TRUE; | |
263 session->protocol_ver = proto_ver; | |
264 } | |
250 } | 265 } |
251 } | 266 } |
252 | 267 |
253 if (!protocol_supported) | 268 if (!protocol_supported) |
254 { | 269 { |
255 msn_session_set_error(session, MSN_ERROR_UNSUPPORTED_PROTOCOL, | 270 msn_session_set_error(session, MSN_ERROR_UNSUPPORTED_PROTOCOL, |
256 NULL); | 271 NULL); |
257 return; | 272 return; |
258 } | 273 } |
274 | |
275 purple_debug_info("msn", "Negotiated protocol version %d with the server.\n", session->protocol_ver); | |
259 | 276 |
260 /* | 277 /* |
261 * Windows Live Messenger 8.5 | 278 * Windows Live Messenger 8.5 |
262 * Notice :CVR String discriminate! | 279 * Notice :CVR String discriminate! |
263 * reference of http://www.microsoft.com/globaldev/reference/oslocversion.mspx | 280 * reference of http://www.microsoft.com/globaldev/reference/oslocversion.mspx |
264 * to see the Local ID | 281 * to see the Local ID |
265 */ | 282 */ |
266 msn_cmdproc_send(cmdproc, "CVR", | 283 trans = msn_transaction_new(cmdproc, "CVR", |
267 "0x0409 winnt 5.1 i386 MSNMSGR 8.5.1302 BC01 %s", | 284 "0x0409 winnt 5.1 i386 MSNMSGR 8.5.1302 BC01 %s", |
268 purple_account_get_username(account)); | 285 purple_account_get_username(account)); |
286 msn_cmdproc_send_trans(cmdproc, trans); | |
269 } | 287 } |
270 | 288 |
271 /************************************************************************** | 289 /************************************************************************** |
272 * Log out | 290 * Log out |
273 **************************************************************************/ | 291 **************************************************************************/ |
285 } | 303 } |
286 | 304 |
287 void | 305 void |
288 msn_notification_close(MsnNotification *notification) | 306 msn_notification_close(MsnNotification *notification) |
289 { | 307 { |
308 MsnTransaction *trans; | |
309 | |
290 g_return_if_fail(notification != NULL); | 310 g_return_if_fail(notification != NULL); |
291 | 311 |
292 if (!notification->in_use) | 312 if (!notification->in_use) |
293 return; | 313 return; |
294 | 314 |
295 msn_cmdproc_send_quick(notification->cmdproc, "OUT", NULL, NULL); | 315 trans = msn_transaction_new(notification->cmdproc, "OUT", NULL); |
316 msn_transaction_set_saveable(trans, FALSE); | |
317 msn_cmdproc_send_trans(notification->cmdproc, trans); | |
296 | 318 |
297 msn_notification_disconnect(notification); | 319 msn_notification_disconnect(notification); |
298 } | 320 } |
299 | 321 |
300 /************************************************************************** | 322 /************************************************************************** |
1001 MsnSession *session; | 1023 MsnSession *session; |
1002 PurpleAccount *account; | 1024 PurpleAccount *account; |
1003 PurpleConnection *gc; | 1025 PurpleConnection *gc; |
1004 MsnUser *user; | 1026 MsnUser *user; |
1005 MsnObject *msnobj = NULL; | 1027 MsnObject *msnobj = NULL; |
1006 unsigned long clientid; | 1028 unsigned long clientid, extcaps; |
1029 char *extcap_str; | |
1007 int networkid = 0; | 1030 int networkid = 0; |
1008 const char *state, *passport; | 1031 const char *state, *passport; |
1009 char *friendly; | 1032 char *friendly; |
1010 | 1033 |
1011 session = cmdproc->session; | 1034 session = cmdproc->session; |
1022 | 1045 |
1023 if (cmd->param_count == 8) { | 1046 if (cmd->param_count == 8) { |
1024 /* Yahoo! Buddy, looks like */ | 1047 /* Yahoo! Buddy, looks like */ |
1025 networkid = atoi(cmd->params[3]); | 1048 networkid = atoi(cmd->params[3]); |
1026 friendly = g_strdup(purple_url_decode(cmd->params[4])); | 1049 friendly = g_strdup(purple_url_decode(cmd->params[4])); |
1027 clientid = strtoul(cmd->params[5], NULL, 10); | 1050 clientid = strtoul(cmd->params[5], &extcap_str, 10); |
1051 if (session->protocol_ver >= 16 && extcap_str && *extcap_str) | |
1052 extcaps = strtoul(extcap_str+1, NULL, 10); | |
1053 else | |
1054 extcaps = 0; | |
1028 | 1055 |
1029 /* cmd->params[7] seems to be a URL to a Yahoo! icon: | 1056 /* cmd->params[7] seems to be a URL to a Yahoo! icon: |
1030 https://sec.yimg.com/i/us/nt/b/purpley.1.0.png | 1057 https://sec.yimg.com/i/us/nt/b/purpley.1.0.png |
1031 ... and it's purple, HAH! | 1058 ... and it's purple, HAH! |
1032 */ | 1059 */ |
1033 } else if (cmd->param_count == 7) { | 1060 } else if (cmd->param_count == 7) { |
1034 /* MSNP14+ with Display Picture object */ | 1061 /* MSNP14+ with Display Picture object */ |
1035 networkid = atoi(cmd->params[3]); | 1062 networkid = atoi(cmd->params[3]); |
1036 friendly = g_strdup(purple_url_decode(cmd->params[4])); | 1063 friendly = g_strdup(purple_url_decode(cmd->params[4])); |
1037 clientid = strtoul(cmd->params[5], NULL, 10); | 1064 clientid = strtoul(cmd->params[5], &extcap_str, 10); |
1065 if (session->protocol_ver >= 16 && extcap_str && *extcap_str) | |
1066 extcaps = strtoul(extcap_str+1, NULL, 10); | |
1067 else | |
1068 extcaps = 0; | |
1038 msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[6])); | 1069 msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[6])); |
1039 } else if (cmd->param_count == 6) { | 1070 } else if (cmd->param_count == 6) { |
1040 /* Yes, this is 5. The friendly name could start with a number, | 1071 /* Yes, this is 5. The friendly name could start with a number, |
1041 but the display picture object can't... */ | 1072 but the display picture object can't... */ |
1042 if (isdigit(cmd->params[5][0])) { | 1073 if (isdigit(cmd->params[5][0])) { |
1043 /* MSNP14 without Display Picture object */ | 1074 /* MSNP14 without Display Picture object */ |
1044 networkid = atoi(cmd->params[3]); | 1075 networkid = atoi(cmd->params[3]); |
1045 friendly = g_strdup(purple_url_decode(cmd->params[4])); | 1076 friendly = g_strdup(purple_url_decode(cmd->params[4])); |
1046 clientid = strtoul(cmd->params[5], NULL, 10); | 1077 clientid = strtoul(cmd->params[5], &extcap_str, 10); |
1078 if (session->protocol_ver >= 16 && extcap_str && *extcap_str) | |
1079 extcaps = strtoul(extcap_str+1, NULL, 10); | |
1080 else | |
1081 extcaps = 0; | |
1047 } else { | 1082 } else { |
1048 /* MSNP8+ with Display Picture object */ | 1083 /* MSNP8+ with Display Picture object */ |
1049 friendly = g_strdup(purple_url_decode(cmd->params[3])); | 1084 friendly = g_strdup(purple_url_decode(cmd->params[3])); |
1050 clientid = strtoul(cmd->params[4], NULL, 10); | 1085 clientid = strtoul(cmd->params[4], &extcap_str, 10); |
1086 if (session->protocol_ver >= 16 && extcap_str && *extcap_str) | |
1087 extcaps = strtoul(extcap_str+1, NULL, 10); | |
1088 else | |
1089 extcaps = 0; | |
1051 msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[5])); | 1090 msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[5])); |
1052 } | 1091 } |
1053 } else if (cmd->param_count == 5) { | 1092 } else if (cmd->param_count == 5) { |
1054 /* MSNP8+ without Display Picture object */ | 1093 /* MSNP8+ without Display Picture object */ |
1055 friendly = g_strdup(purple_url_decode(cmd->params[3])); | 1094 friendly = g_strdup(purple_url_decode(cmd->params[3])); |
1056 clientid = strtoul(cmd->params[4], NULL, 10); | 1095 clientid = strtoul(cmd->params[4], &extcap_str, 10); |
1096 if (session->protocol_ver >= 16 && extcap_str && *extcap_str) | |
1097 extcaps = strtoul(extcap_str+1, NULL, 10); | |
1098 else | |
1099 extcaps = 0; | |
1057 } else { | 1100 } else { |
1058 purple_debug_warning("msn", "Received ILN with unknown number of parameters.\n"); | 1101 purple_debug_warning("msn", "Received ILN with unknown number of parameters.\n"); |
1059 return; | 1102 return; |
1060 } | 1103 } |
1061 | 1104 |
1066 | 1109 |
1067 msn_user_set_object(user, msnobj); | 1110 msn_user_set_object(user, msnobj); |
1068 | 1111 |
1069 user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->extinfo && user->extinfo->phone_mobile && user->extinfo->phone_mobile[0] == '+'); | 1112 user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->extinfo && user->extinfo->phone_mobile && user->extinfo->phone_mobile[0] == '+'); |
1070 msn_user_set_clientid(user, clientid); | 1113 msn_user_set_clientid(user, clientid); |
1114 msn_user_set_extcaps(user, extcaps); | |
1071 msn_user_set_network(user, networkid); | 1115 msn_user_set_network(user, networkid); |
1072 | 1116 |
1073 msn_user_set_state(user, state); | 1117 msn_user_set_state(user, state); |
1074 msn_user_update(user); | 1118 msn_user_update(user); |
1075 } | 1119 } |
1204 MsnSession *session; | 1248 MsnSession *session; |
1205 PurpleAccount *account; | 1249 PurpleAccount *account; |
1206 PurpleConnection *gc; | 1250 PurpleConnection *gc; |
1207 MsnUser *user; | 1251 MsnUser *user; |
1208 MsnObject *msnobj; | 1252 MsnObject *msnobj; |
1209 unsigned long clientid; | 1253 unsigned long clientid, extcaps; |
1254 char *extcap_str; | |
1210 int networkid; | 1255 int networkid; |
1211 const char *state, *passport, *friendly; | 1256 const char *state, *passport, *friendly; |
1212 | 1257 |
1213 session = cmdproc->session; | 1258 session = cmdproc->session; |
1214 account = session->account; | 1259 account = session->account; |
1217 state = cmd->params[0]; | 1262 state = cmd->params[0]; |
1218 passport = cmd->params[1]; | 1263 passport = cmd->params[1]; |
1219 networkid = atoi(cmd->params[2]); | 1264 networkid = atoi(cmd->params[2]); |
1220 friendly = purple_url_decode(cmd->params[3]); | 1265 friendly = purple_url_decode(cmd->params[3]); |
1221 | 1266 |
1222 user = msn_userlist_find_user(session->userlist, passport); | 1267 if (g_str_equal(passport, session->user->passport)) |
1268 user = session->user; | |
1269 else | |
1270 user = msn_userlist_find_user(session->userlist, passport); | |
1223 if (user == NULL) return; | 1271 if (user == NULL) return; |
1224 | 1272 |
1225 if (msn_user_set_friendly_name(user, friendly)) | 1273 if (msn_user_set_friendly_name(user, friendly)) |
1226 { | 1274 { |
1227 msn_update_contact(session, passport, MSN_UPDATE_DISPLAY, friendly); | 1275 msn_update_contact(session, passport, MSN_UPDATE_DISPLAY, friendly); |
1235 else | 1283 else |
1236 { | 1284 { |
1237 msn_user_set_object(user, NULL); | 1285 msn_user_set_object(user, NULL); |
1238 } | 1286 } |
1239 | 1287 |
1240 clientid = strtoul(cmd->params[4], NULL, 10); | 1288 clientid = strtoul(cmd->params[4], &extcap_str, 10); |
1289 if (session->protocol_ver >= 16 && extcap_str && *extcap_str) | |
1290 extcaps = strtoul(extcap_str+1, NULL, 10); | |
1291 else | |
1292 extcaps = 0; | |
1293 | |
1241 user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->extinfo && user->extinfo->phone_mobile && user->extinfo->phone_mobile[0] == '+'); | 1294 user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->extinfo && user->extinfo->phone_mobile && user->extinfo->phone_mobile[0] == '+'); |
1242 | 1295 |
1243 msn_user_set_clientid(user, clientid); | 1296 msn_user_set_clientid(user, clientid); |
1297 msn_user_set_extcaps(user, extcaps); | |
1244 msn_user_set_network(user, networkid); | 1298 msn_user_set_network(user, networkid); |
1245 | 1299 |
1246 msn_user_set_state(user, state); | 1300 msn_user_set_state(user, state); |
1247 msn_user_update(user); | 1301 msn_user_update(user); |
1248 } | 1302 } |
1506 { | 1560 { |
1507 purple_debug_info("msn", "Processing SBS... \n"); | 1561 purple_debug_info("msn", "Processing SBS... \n"); |
1508 /*get the payload content*/ | 1562 /*get the payload content*/ |
1509 } | 1563 } |
1510 | 1564 |
1565 static void | |
1566 parse_user_endpoints(MsnUser *user, xmlnode *payloadNode) | |
1567 { | |
1568 xmlnode *epNode, *capsNode; | |
1569 MsnUserEndpoint data; | |
1570 const char *id; | |
1571 char *caps, *tmp; | |
1572 | |
1573 purple_debug_info("msn", "Get EndpointData\n"); | |
1574 | |
1575 for (epNode = xmlnode_get_child(payloadNode, "EndpointData"); | |
1576 epNode; | |
1577 epNode = xmlnode_get_next_twin(epNode)) { | |
1578 id = xmlnode_get_attrib(epNode, "id"); | |
1579 capsNode = xmlnode_get_child(epNode, "Capabilities"); | |
1580 | |
1581 if (capsNode != NULL) { | |
1582 caps = xmlnode_get_data(capsNode); | |
1583 | |
1584 data.clientid = strtoul(caps, &tmp, 10); | |
1585 if (tmp && *tmp) | |
1586 data.extcaps = strtoul(tmp + 1, NULL, 10); | |
1587 else | |
1588 data.extcaps = 0; | |
1589 | |
1590 g_free(caps); | |
1591 | |
1592 } else { | |
1593 data.clientid = 0; | |
1594 data.extcaps = 0; | |
1595 } | |
1596 | |
1597 msn_user_set_endpoint_data(user, id, &data); | |
1598 } | |
1599 | |
1600 /* Need to shortcut this check, probably... */ | |
1601 if (user == user->userlist->session->user) { | |
1602 for (epNode = xmlnode_get_child(payloadNode, "PrivateEndpointData"); | |
1603 epNode; | |
1604 epNode = xmlnode_get_next_twin(epNode)) { | |
1605 MsnUserEndpoint *ep; | |
1606 xmlnode *nameNode, *clientNode; | |
1607 | |
1608 /* <PrivateEndpointData id='{GUID}'> | |
1609 <EpName>Endpoint Name</EpName> | |
1610 <Idle>true/false</Idle> | |
1611 <ClientType>1</ClientType> | |
1612 <State>NLN</State> | |
1613 </PrivateEndpointData> | |
1614 */ | |
1615 id = xmlnode_get_attrib(epNode, "id"); | |
1616 ep = msn_user_get_endpoint_data(user, id); | |
1617 | |
1618 if (ep != NULL) { | |
1619 nameNode = xmlnode_get_child(epNode, "EpName"); | |
1620 if (nameNode != NULL) { | |
1621 g_free(ep->name); | |
1622 ep->name = xmlnode_get_data(nameNode); | |
1623 } | |
1624 | |
1625 clientNode = xmlnode_get_child(epNode, "ClientType"); | |
1626 if (clientNode != NULL) { | |
1627 tmp = xmlnode_get_data(clientNode); | |
1628 ep->type = strtoul(tmp, NULL, 10); | |
1629 g_free(tmp); | |
1630 } | |
1631 } | |
1632 } | |
1633 } | |
1634 } | |
1635 | |
1511 static void parse_currentmedia(MsnUser *user, const char *cmedia) | 1636 static void parse_currentmedia(MsnUser *user, const char *cmedia) |
1512 { | 1637 { |
1513 char **cmedia_array; | 1638 char **cmedia_array; |
1514 int strings = 0; | 1639 int strings = 0; |
1515 | 1640 |
1572 { | 1697 { |
1573 MsnSession *session; | 1698 MsnSession *session; |
1574 PurpleAccount *account; | 1699 PurpleAccount *account; |
1575 MsnUser *user; | 1700 MsnUser *user; |
1576 const char *passport; | 1701 const char *passport; |
1577 char *str; | 1702 xmlnode *payloadNode; |
1703 char *psm_str, *str; | |
1578 | 1704 |
1579 session = cmdproc->session; | 1705 session = cmdproc->session; |
1580 account = session->account; | 1706 account = session->account; |
1581 | 1707 |
1582 passport = cmd->params[0]; | 1708 passport = cmd->params[0]; |
1583 user = msn_userlist_find_user(session->userlist, passport); | 1709 if (g_str_equal(passport, session->user->passport)) |
1710 user = session->user; | |
1711 else | |
1712 user = msn_userlist_find_user(session->userlist, passport); | |
1584 if (user == NULL) { | 1713 if (user == NULL) { |
1585 str = g_strndup(payload, len); | 1714 char *str = g_strndup(payload, len); |
1586 purple_debug_info("msn", "unknown user %s, payload is %s\n", | 1715 purple_debug_info("msn", "unknown user %s, payload is %s\n", |
1587 passport, str); | 1716 passport, str); |
1588 g_free(str); | 1717 g_free(str); |
1589 return; | 1718 return; |
1590 } | 1719 } |
1599 user->extinfo->media_title = NULL; | 1728 user->extinfo->media_title = NULL; |
1600 user->extinfo->media_type = CURRENT_MEDIA_UNKNOWN; | 1729 user->extinfo->media_type = CURRENT_MEDIA_UNKNOWN; |
1601 } | 1730 } |
1602 | 1731 |
1603 if (len != 0) { | 1732 if (len != 0) { |
1604 str = msn_get_psm(cmd->payload,len); | 1733 payloadNode = xmlnode_from_str(payload, len); |
1605 msn_user_set_statusline(user, str); | 1734 if (!payloadNode) { |
1606 g_free(str); | 1735 purple_debug_error("msn", "UBX XML parse Error!\n"); |
1607 | 1736 |
1608 str = msn_get_currentmedia(cmd->payload, len); | 1737 msn_user_set_statusline(user, NULL); |
1738 | |
1739 msn_user_update(user); | |
1740 return; | |
1741 } | |
1742 | |
1743 psm_str = msn_get_psm(payloadNode); | |
1744 msn_user_set_statusline(user, psm_str); | |
1745 g_free(psm_str); | |
1746 | |
1747 str = msn_get_currentmedia(payloadNode); | |
1609 parse_currentmedia(user, str); | 1748 parse_currentmedia(user, str); |
1610 g_free(str); | 1749 g_free(str); |
1750 | |
1751 parse_user_endpoints(user, payloadNode); | |
1752 | |
1753 xmlnode_free(payloadNode); | |
1754 | |
1611 } else { | 1755 } else { |
1612 msn_user_set_statusline(user, NULL); | 1756 msn_user_set_statusline(user, NULL); |
1613 } | 1757 } |
1614 | 1758 |
1615 msn_user_update(user); | 1759 msn_user_update(user); |
1638 purple_debug_misc("msn", "UUX received.\n"); | 1782 purple_debug_misc("msn", "UUX received.\n"); |
1639 cmdproc->last_cmd->payload_cb = uux_cmd_post; | 1783 cmdproc->last_cmd->payload_cb = uux_cmd_post; |
1640 cmd->payload_len = atoi(cmd->params[1]); | 1784 cmd->payload_len = atoi(cmd->params[1]); |
1641 } | 1785 } |
1642 | 1786 |
1787 void | |
1788 msn_notification_send_uux(MsnSession *session, const char *payload) | |
1789 { | |
1790 MsnTransaction *trans; | |
1791 MsnCmdProc *cmdproc; | |
1792 size_t len = strlen(payload); | |
1793 | |
1794 cmdproc = session->notification->cmdproc; | |
1795 purple_debug_misc("msn", "Sending UUX command with payload: %s\n", payload); | |
1796 trans = msn_transaction_new(cmdproc, "UUX", "%" G_GSIZE_FORMAT, len); | |
1797 msn_transaction_set_payload(trans, payload, len); | |
1798 msn_cmdproc_send_trans(cmdproc, trans); | |
1799 } | |
1800 | |
1801 void msn_notification_send_uux_endpointdata(MsnSession *session) | |
1802 { | |
1803 xmlnode *epDataNode; | |
1804 xmlnode *capNode; | |
1805 char *caps; | |
1806 char *payload; | |
1807 int length; | |
1808 | |
1809 epDataNode = xmlnode_new("EndpointData"); | |
1810 | |
1811 capNode = xmlnode_new_child(epDataNode, "Capabilities"); | |
1812 if (session->protocol_ver >= 16) | |
1813 caps = g_strdup_printf("%d:%02d", MSN_CLIENT_ID_CAPABILITIES, MSN_CLIENT_ID_EXT_CAPS); | |
1814 else | |
1815 caps = g_strdup_printf("%d", MSN_CLIENT_ID_CAPABILITIES); | |
1816 xmlnode_insert_data(capNode, caps, -1); | |
1817 g_free(caps); | |
1818 | |
1819 payload = xmlnode_to_str(epDataNode, &length); | |
1820 | |
1821 msn_notification_send_uux(session, payload); | |
1822 | |
1823 xmlnode_free(epDataNode); | |
1824 g_free(payload); | |
1825 } | |
1826 | |
1827 void msn_notification_send_uux_private_endpointdata(MsnSession *session) | |
1828 { | |
1829 xmlnode *private; | |
1830 const char *name; | |
1831 xmlnode *epname; | |
1832 xmlnode *idle; | |
1833 GHashTable *ui_info; | |
1834 const gchar *ui_type; | |
1835 xmlnode *client_type; | |
1836 xmlnode *state; | |
1837 char *payload; | |
1838 int length; | |
1839 | |
1840 private = xmlnode_new("PrivateEndpointData"); | |
1841 | |
1842 name = purple_account_get_string(session->account, "endpoint-name", NULL); | |
1843 epname = xmlnode_new_child(private, "EpName"); | |
1844 xmlnode_insert_data(epname, name, -1); | |
1845 | |
1846 idle = xmlnode_new_child(private, "Idle"); | |
1847 xmlnode_insert_data(idle, "false", -1); | |
1848 | |
1849 /* ClientType info (from amsn guys): | |
1850 0: None | |
1851 1: Computer | |
1852 2: Website | |
1853 3: Mobile / none | |
1854 4: Xbox / phone /mobile | |
1855 9: MsnGroup | |
1856 32: Email member, currently Yahoo! | |
1857 */ | |
1858 client_type = xmlnode_new_child(private, "ClientType"); | |
1859 ui_info = purple_core_get_ui_info(); | |
1860 ui_type = ui_info ? g_hash_table_lookup(ui_info, "client_type") : NULL; | |
1861 if (ui_type) { | |
1862 if (strcmp(ui_type, "pc") == 0) | |
1863 xmlnode_insert_data(client_type, "1", -1); | |
1864 else if (strcmp(ui_type, "web") == 0) | |
1865 xmlnode_insert_data(client_type, "2", -1); | |
1866 else if (strcmp(ui_type, "phone") == 0) | |
1867 xmlnode_insert_data(client_type, "3", -1); | |
1868 else if (strcmp(ui_type, "handheld") == 0) | |
1869 xmlnode_insert_data(client_type, "3", -1); | |
1870 else | |
1871 xmlnode_insert_data(client_type, "1", -1); | |
1872 } | |
1873 else | |
1874 xmlnode_insert_data(client_type, "1", -1); | |
1875 | |
1876 state = xmlnode_new_child(private, "State"); | |
1877 xmlnode_insert_data(state, msn_state_get_text(msn_state_from_account(session->account)), -1); | |
1878 | |
1879 payload = xmlnode_to_str(private, &length); | |
1880 | |
1881 msn_notification_send_uux(session, payload); | |
1882 | |
1883 xmlnode_free(private); | |
1884 g_free(payload); | |
1885 } | |
1886 | |
1887 static void | |
1888 ubn_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, | |
1889 size_t len) | |
1890 { | |
1891 /* Do Nothing, right now. */ | |
1892 if (payload != NULL) | |
1893 purple_debug_info("msn", "UBN payload:\n%s\n", payload); | |
1894 } | |
1895 | |
1896 static void | |
1897 ubn_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
1898 { | |
1899 purple_debug_misc("msn", "UBN received from %s.\n", cmd->params[0]); | |
1900 cmdproc->last_cmd->payload_cb = ubn_cmd_post; | |
1901 cmd->payload_len = atoi(cmd->params[2]); | |
1902 } | |
1903 | |
1904 static void | |
1905 uun_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, | |
1906 size_t len) | |
1907 { | |
1908 /* Do Nothing, right now. */ | |
1909 if (payload != NULL) | |
1910 purple_debug_info("msn", "UUN payload:\n%s\n", payload); | |
1911 } | |
1912 | |
1913 static void | |
1914 uun_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
1915 { | |
1916 if (strcmp(cmd->params[1], "OK") != 0) { | |
1917 purple_debug_misc("msn", "UUN received.\n"); | |
1918 cmdproc->last_cmd->payload_cb = uun_cmd_post; | |
1919 cmd->payload_len = atoi(cmd->params[1]); | |
1920 } | |
1921 else | |
1922 purple_debug_misc("msn", "UUN OK received.\n"); | |
1923 } | |
1924 | |
1925 void | |
1926 msn_notification_send_uun(MsnSession *session, const char *user, | |
1927 MsnUnifiedNotificationType type, const char *payload) | |
1928 { | |
1929 MsnTransaction *trans; | |
1930 MsnCmdProc *cmdproc; | |
1931 size_t len = strlen(payload); | |
1932 | |
1933 cmdproc = session->notification->cmdproc; | |
1934 purple_debug_misc("msn", "Sending UUN command %d to %s with payload: %s\n", | |
1935 type, user, payload); | |
1936 trans = msn_transaction_new(cmdproc, "UUN", "%s %d %" G_GSIZE_FORMAT, | |
1937 user, type, len); | |
1938 msn_transaction_set_payload(trans, payload, len); | |
1939 msn_cmdproc_send_trans(cmdproc, trans); | |
1940 } | |
1941 | |
1643 /************************************************************************** | 1942 /************************************************************************** |
1644 * Message Types | 1943 * Message Types |
1645 **************************************************************************/ | 1944 **************************************************************************/ |
1646 | 1945 |
1647 static void | 1946 static void |
1655 | 1954 |
1656 if (strcmp(msg->remote_user, "Hotmail")) | 1955 if (strcmp(msg->remote_user, "Hotmail")) |
1657 /* This isn't an official message. */ | 1956 /* This isn't an official message. */ |
1658 return; | 1957 return; |
1659 | 1958 |
1660 if ((value = msn_message_get_attr(msg, "kv")) != NULL) | 1959 if ((value = msn_message_get_header_value(msg, "kv")) != NULL) |
1661 { | 1960 { |
1662 g_free(session->passport_info.kv); | 1961 g_free(session->passport_info.kv); |
1663 session->passport_info.kv = g_strdup(value); | 1962 session->passport_info.kv = g_strdup(value); |
1664 } | 1963 } |
1665 | 1964 |
1666 if ((value = msn_message_get_attr(msg, "sid")) != NULL) | 1965 if ((value = msn_message_get_header_value(msg, "sid")) != NULL) |
1667 { | 1966 { |
1668 g_free(session->passport_info.sid); | 1967 g_free(session->passport_info.sid); |
1669 session->passport_info.sid = g_strdup(value); | 1968 session->passport_info.sid = g_strdup(value); |
1670 } | 1969 } |
1671 | 1970 |
1672 if ((value = msn_message_get_attr(msg, "MSPAuth")) != NULL) | 1971 if ((value = msn_message_get_header_value(msg, "MSPAuth")) != NULL) |
1673 { | 1972 { |
1674 g_free(session->passport_info.mspauth); | 1973 g_free(session->passport_info.mspauth); |
1675 session->passport_info.mspauth = g_strdup(value); | 1974 session->passport_info.mspauth = g_strdup(value); |
1676 } | 1975 } |
1677 | 1976 |
1678 if ((value = msn_message_get_attr(msg, "ClientIP")) != NULL) | 1977 if ((value = msn_message_get_header_value(msg, "ClientIP")) != NULL) |
1679 { | 1978 { |
1680 g_free(session->passport_info.client_ip); | 1979 g_free(session->passport_info.client_ip); |
1681 session->passport_info.client_ip = g_strdup(value); | 1980 session->passport_info.client_ip = g_strdup(value); |
1682 } | 1981 } |
1683 | 1982 |
1684 if ((value = msn_message_get_attr(msg, "ClientPort")) != NULL) | 1983 if ((value = msn_message_get_header_value(msg, "ClientPort")) != NULL) |
1685 { | 1984 { |
1686 session->passport_info.client_port = ntohs(atoi(value)); | 1985 session->passport_info.client_port = ntohs(atoi(value)); |
1687 } | 1986 } |
1688 | 1987 |
1689 if ((value = msn_message_get_attr(msg, "LoginTime")) != NULL) | 1988 if ((value = msn_message_get_header_value(msg, "LoginTime")) != NULL) |
1690 session->passport_info.sl = atol(value); | 1989 session->passport_info.sl = atol(value); |
1691 | 1990 |
1692 if ((value = msn_message_get_attr(msg, "EmailEnabled")) != NULL) | 1991 if ((value = msn_message_get_header_value(msg, "EmailEnabled")) != NULL) |
1693 session->passport_info.email_enabled = (gboolean)atol(value); | 1992 session->passport_info.email_enabled = (gboolean)atol(value); |
1694 | 1993 |
1695 /*starting retrieve the contact list*/ | 1994 /*starting retrieve the contact list*/ |
1696 clLastChange = purple_account_get_string(session->account, "CLLastChange", NULL); | 1995 clLastChange = purple_account_get_string(session->account, "CLLastChange", NULL); |
1697 #ifdef MSN_PARTIAL_LISTS | 1996 #ifdef MSN_PARTIAL_LISTS |
2090 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); | 2389 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); |
2091 msn_table_add_cmd(cbs_table, NULL, "RNG", rng_cmd); | 2390 msn_table_add_cmd(cbs_table, NULL, "RNG", rng_cmd); |
2092 | 2391 |
2093 msn_table_add_cmd(cbs_table, NULL, "UBX", ubx_cmd); | 2392 msn_table_add_cmd(cbs_table, NULL, "UBX", ubx_cmd); |
2094 msn_table_add_cmd(cbs_table, NULL, "UUX", uux_cmd); | 2393 msn_table_add_cmd(cbs_table, NULL, "UUX", uux_cmd); |
2394 | |
2395 msn_table_add_cmd(cbs_table, NULL, "UBN", ubn_cmd); | |
2396 msn_table_add_cmd(cbs_table, NULL, "UUN", uun_cmd); | |
2095 | 2397 |
2096 msn_table_add_cmd(cbs_table, NULL, "URL", url_cmd); | 2398 msn_table_add_cmd(cbs_table, NULL, "URL", url_cmd); |
2097 | 2399 |
2098 msn_table_add_cmd(cbs_table, "fallback", "XFR", xfr_cmd); | 2400 msn_table_add_cmd(cbs_table, "fallback", "XFR", xfr_cmd); |
2099 | 2401 |