comparison libpurple/protocols/msn/notification.c @ 23520:f85450504940

propagate from branch 'im.pidgin.pidgin' (head 5387bc28fa09b238593c3dc292863ec3ce5f3c4e) to branch 'im.pidgin.cpw.qulogic.msn' (head f2d5cd45d05d5b074677524bb08f2069d0683b09)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 14 Jun 2008 07:47:38 +0000
parents 27f7fae4a361 9a53c441f8c1
children fd124c21ebb7
comparison
equal deleted inserted replaced
23367:ef4dbd2bb696 23520:f85450504940
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 #include "msn.h"
25 #include "notification.h" 25 #include "notification.h"
26 #include "contact.h"
26 #include "state.h" 27 #include "state.h"
27 #include "error.h" 28 #include "error.h"
28 #include "msnutils.h" 29 #include "msnutils.h"
29 #include "page.h" 30 #include "page.h"
30 31
193 /************************************************************************** 194 /**************************************************************************
194 * Login 195 * Login
195 **************************************************************************/ 196 **************************************************************************/
196 197
197 void 198 void
198 msn_got_login_params(MsnSession *session, const char *login_params) 199 msn_got_login_params(MsnSession *session, const char *ticket, const char *response)
199 { 200 {
200 MsnCmdProc *cmdproc; 201 MsnCmdProc *cmdproc;
201 202
202 cmdproc = session->notification->cmdproc; 203 cmdproc = session->notification->cmdproc;
203 204
204 msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_END); 205 msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_END);
205 206
206 msn_cmdproc_send(cmdproc, "USR", "TWN S %s", login_params); 207 msn_cmdproc_send(cmdproc, "USR", "SSO S %s %s", ticket, response);
207 } 208 }
208 209
209 static void 210 static void
210 cvr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 211 cvr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
211 { 212 {
212 PurpleAccount *account; 213 PurpleAccount *account;
213 214
214 account = cmdproc->session->account; 215 account = cmdproc->session->account;
215 msn_cmdproc_send(cmdproc, "USR", "TWN I %s", 216
216 purple_account_get_username(account)); 217 msn_cmdproc_send(cmdproc, "USR", "SSO I %s", purple_account_get_username(account));
217 } 218 }
218 219
219 static void 220 static void
220 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 221 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
221 { 222 {
237 msn_session_set_login_step(session, MSN_LOGIN_STEP_SYN); 238 msn_session_set_login_step(session, MSN_LOGIN_STEP_SYN);
238 239
239 // msn_cmdproc_send(cmdproc, "SYN", "%s", "0"); 240 // msn_cmdproc_send(cmdproc, "SYN", "%s", "0");
240 //TODO we should use SOAP contact to fetch contact list 241 //TODO we should use SOAP contact to fetch contact list
241 } 242 }
242 else if (!g_ascii_strcasecmp(cmd->params[1], "TWN")) 243 else if (!g_ascii_strcasecmp(cmd->params[1], "SSO"))
243 { 244 {
244 /* Passport authentication */ 245 /* RPS authentication */
245 char **elems, **cur, **tokens;
246 246
247 session->nexus = msn_nexus_new(session); 247 session->nexus = msn_nexus_new(session);
248 248
249 /* Parse the challenge data. */ 249 session->nexus->policy = g_strdup(cmd->params[3]);
250 session->nexus->challenge_data_str = g_strdup(cmd->params[3]); 250 session->nexus->nonce = g_strdup(cmd->params[4]);
251 elems = g_strsplit(cmd->params[3], ",", 0);
252
253 for (cur = elems; *cur != NULL; cur++)
254 {
255 tokens = g_strsplit(*cur, "=", 2);
256 if(tokens[0] && tokens[1])
257 {
258 purple_debug_info("MSNP14","challenge %p,key:%s,value:%s\n",
259 session->nexus->challenge_data,tokens[0],tokens[1]);
260 g_hash_table_insert(session->nexus->challenge_data, tokens[0], tokens[1]);
261 /* Don't free each of the tokens, only the array. */
262 g_free(tokens);
263 } else
264 g_strfreev(tokens);
265 }
266
267 g_strfreev(elems);
268 251
269 msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_START); 252 msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_START);
270 253
271 msn_nexus_connect(session->nexus); 254 msn_nexus_connect(session->nexus);
272 } 255 }
325 NULL); 308 NULL);
326 return; 309 return;
327 } 310 }
328 311
329 /* 312 /*
330 * Windows Live Messenger 8.0 313 * Windows Live Messenger 8.5
331 * Notice :CVR String discriminate! 314 * Notice :CVR String discriminate!
332 * reference of http://www.microsoft.com/globaldev/reference/oslocversion.mspx 315 * reference of http://www.microsoft.com/globaldev/reference/oslocversion.mspx
333 * to see the Local ID 316 * to see the Local ID
334 */ 317 */
335 msn_cmdproc_send(cmdproc, "CVR", 318 msn_cmdproc_send(cmdproc, "CVR",
336 // "0x0409 winnt 5.1 i386 MSG80BETA 8.0.0689 msmsgs %s", 319 // "0x0409 winnt 5.1 i386 MSG80BETA 8.0.0689 msmsgs %s",
337 "0x0804 winnt 5.1 i386 MSNMSGR 8.0.0792 msmsgs %s", 320 // "0x0804 winnt 5.1 i386 MSNMSGR 8.0.0792 msmsgs %s",
321 "0x0409 winnt 5.1 i386 MSNMSGR 8.5.1288 msmsgs %s",
338 purple_account_get_username(account)); 322 purple_account_get_username(account));
339 } 323 }
340 324
341 /************************************************************************** 325 /**************************************************************************
342 * Log out 326 * Log out
543 #if 0 527 #if 0
544 cipher = purple_ciphers_find_cipher("md5"); 528 cipher = purple_ciphers_find_cipher("md5");
545 context = purple_cipher_context_new(cipher, NULL); 529 context = purple_cipher_context_new(cipher, NULL);
546 purple_cipher_context_append(context, (const guchar *)cmd->params[1], 530 purple_cipher_context_append(context, (const guchar *)cmd->params[1],
547 strlen(cmd->params[1])); 531 strlen(cmd->params[1]));
548 challenge_resp = MSNP13_WLM_PRODUCT_KEY; 532 challenge_resp = MSNP15_WLM_PRODUCT_KEY;
549 533
550 purple_cipher_context_append(context, (const guchar *)challenge_resp, 534 purple_cipher_context_append(context, (const guchar *)challenge_resp,
551 strlen(challenge_resp)); 535 strlen(challenge_resp));
552 purple_cipher_context_digest(context, sizeof(digest), digest, NULL); 536 purple_cipher_context_digest(context, sizeof(digest), digest, NULL);
553 purple_cipher_context_destroy(context); 537 purple_cipher_context_destroy(context);
558 } 542 }
559 #else 543 #else
560 msn_handle_chl(cmd->params[1], buf); 544 msn_handle_chl(cmd->params[1], buf);
561 #endif 545 #endif
562 // purple_debug_info("MSNP14","<<challenge:{%s}:{%s}\n",cmd->params[1],buf); 546 // purple_debug_info("MSNP14","<<challenge:{%s}:{%s}\n",cmd->params[1],buf);
563 trans = msn_transaction_new(cmdproc, "QRY", "%s 32", MSNP13_WLM_PRODUCT_ID); 547 trans = msn_transaction_new(cmdproc, "QRY", "%s 32", MSNP15_WLM_PRODUCT_ID);
564 548
565 msn_transaction_set_payload(trans, buf, 32); 549 msn_transaction_set_payload(trans, buf, 32);
566 550
567 msn_cmdproc_send_trans(cmdproc, trans); 551 msn_cmdproc_send_trans(cmdproc, trans);
568 } 552 }
780 // } 764 // }
781 765
782 if (list_op & MSN_LIST_RL_OP) { 766 if (list_op & MSN_LIST_RL_OP) {
783 /* someone is adding us */ 767 /* someone is adding us */
784 // got_new_entry(cmdproc->session->account->gc, passport, decoded_friendly_name); 768 // got_new_entry(cmdproc->session->account->gc, passport, decoded_friendly_name);
785 msn_get_contact_list(cmdproc->session->contact, MSN_PS_PENDING_LIST, NULL); 769 msn_get_contact_list(cmdproc->session, MSN_PS_PENDING_LIST, NULL);
786 } 770 }
787 771
788 // g_free(decoded_friendly_name); 772 // g_free(decoded_friendly_name);
789 // g_free(passport); 773 // g_free(passport);
790 } 774 }
837 fqy_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, 821 fqy_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload,
838 size_t len) 822 size_t len)
839 { 823 {
840 purple_debug_info("MSN Notification","FQY payload:\n%s\n", payload); 824 purple_debug_info("MSN Notification","FQY payload:\n%s\n", payload);
841 g_return_if_fail(cmdproc->session != NULL); 825 g_return_if_fail(cmdproc->session != NULL);
842 g_return_if_fail(cmdproc->session->contact != NULL);
843 // msn_notification_post_adl(cmdproc, payload, len); 826 // msn_notification_post_adl(cmdproc, payload, len);
844 // msn_get_address_book(cmdproc->session->contact, MSN_AB_SAVE_CONTACT, NULL, NULL); 827 // msn_get_address_book(cmdproc->session, MSN_AB_SAVE_CONTACT, NULL, NULL);
845 } 828 }
846 829
847 static void 830 static void
848 fqy_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) 831 fqy_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
849 { 832 {
1290 else { 1273 else {
1291 type = cmd->params[1]; 1274 type = cmd->params[1];
1292 if (!strcmp(type, "MFN")) { 1275 if (!strcmp(type, "MFN")) {
1293 friendlyname = purple_url_decode(cmd->params[2]); 1276 friendlyname = purple_url_decode(cmd->params[2]);
1294 1277
1295 msn_update_contact(session->contact, friendlyname); 1278 msn_update_contact(session, "Me", MSN_UPDATE_DISPLAY, friendlyname);
1296 1279
1297 purple_connection_set_display_name( 1280 purple_connection_set_display_name(
1298 purple_account_get_connection(session->account), 1281 purple_account_get_connection(session->account),
1299 friendlyname); 1282 friendlyname);
1300 } 1283 }
1772 if ((value = msn_message_get_attr(msg, "LoginTime")) != NULL) 1755 if ((value = msn_message_get_attr(msg, "LoginTime")) != NULL)
1773 session->passport_info.sl = atol(value); 1756 session->passport_info.sl = atol(value);
1774 1757
1775 /*starting retrieve the contact list*/ 1758 /*starting retrieve the contact list*/
1776 clLastChange = purple_account_get_string(session->account, "CLLastChange", NULL); 1759 clLastChange = purple_account_get_string(session->account, "CLLastChange", NULL);
1777 session->contact = msn_contact_new(session);
1778 #ifdef MSN_PARTIAL_LISTS 1760 #ifdef MSN_PARTIAL_LISTS
1779 /* msn_userlist_load defeats all attempts at trying to detect blist sync issues */ 1761 /* msn_userlist_load defeats all attempts at trying to detect blist sync issues */
1780 msn_userlist_load(session); 1762 msn_userlist_load(session);
1781 msn_get_contact_list(session->contact, MSN_PS_INITIAL, clLastChange); 1763 msn_get_contact_list(session, MSN_PS_INITIAL, clLastChange);
1782 #else 1764 #else
1783 /* always get the full list? */ 1765 /* always get the full list? */
1784 msn_get_contact_list(session->contact, MSN_PS_INITIAL, NULL); 1766 msn_get_contact_list(session, MSN_PS_INITIAL, NULL);
1785 #endif 1767 #endif
1786 #if 0 1768 #if 0
1787 msn_contact_connect(session->contact); 1769 msn_contact_connect(session);
1788 #endif 1770 #endif
1789 } 1771 }
1790 1772
1791 static void 1773 static void
1792 initial_email_msg(MsnCmdProc *cmdproc, MsnMessage *msg) 1774 initial_email_msg(MsnCmdProc *cmdproc, MsnMessage *msg)