Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/notification.c @ 23506:d756a0477c06
propagate from branch 'im.pidgin.pidgin' (head e1c49c9ec5c6869ed9813feccd8ee41d2ca40f35)
to branch 'im.pidgin.pidgin.khc.msnp15' (head cee4156a103d7f7b90a8d4e3a3ebf10950baf0aa)
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Wed, 14 May 2008 04:38:26 +0000 |
parents | 69af5301e1a7 f05da3bc20d9 |
children | 1ac5faa72c8d |
comparison
equal
deleted
inserted
replaced
23505:a1652ea8f252 | 23506:d756a0477c06 |
---|---|
396 } | 396 } |
397 else | 397 else |
398 { | 398 { |
399 g_return_if_fail(cmd->payload_cb != NULL); | 399 g_return_if_fail(cmd->payload_cb != NULL); |
400 | 400 |
401 purple_debug_info("MSNP14","MSG payload:{%.*s}\n",cmd->payload_len, cmd->payload); | 401 #if 0 /* glib on win32 doesn't correctly support precision modifiers for a string */ |
402 purple_debug_info("MSNP14", "MSG payload:{%.*s}\n", cmd->payload_len, cmd->payload); | |
403 #endif | |
402 cmd->payload_cb(cmdproc, cmd, cmd->payload, cmd->payload_len); | 404 cmd->payload_cb(cmdproc, cmd, cmd->payload, cmd->payload_len); |
403 } | 405 } |
404 } | 406 } |
405 | 407 |
406 /*send Message to Yahoo Messenger*/ | 408 /*send Message to Yahoo Messenger*/ |
414 int type; | 416 int type; |
415 | 417 |
416 cmdproc = session->notification->cmdproc; | 418 cmdproc = session->notification->cmdproc; |
417 g_return_if_fail(msg != NULL); | 419 g_return_if_fail(msg != NULL); |
418 payload = msn_message_gen_payload(msg, &payload_len); | 420 payload = msn_message_gen_payload(msg, &payload_len); |
419 purple_debug_info("MSNP14","send UUM,payload{%s},strlen:%d,len:%d\n", | 421 purple_debug_info("MSNP14", |
420 payload,strlen(payload),payload_len); | 422 "send UUM, payload{%s}, strlen:%" G_GSIZE_FORMAT ", len:%" G_GSIZE_FORMAT "\n", |
423 payload, strlen(payload), payload_len); | |
421 type = msg->type; | 424 type = msg->type; |
422 trans = msn_transaction_new(cmdproc, "UUM","%s 32 %d %d",msg->remote_user,type,payload_len); | 425 trans = msn_transaction_new(cmdproc, "UUM", "%s 32 %d %" G_GSIZE_FORMAT, |
426 msg->remote_user, type, payload_len); | |
423 msn_transaction_set_payload(trans, payload, strlen(payload)); | 427 msn_transaction_set_payload(trans, payload, strlen(payload)); |
424 msn_cmdproc_send_trans(cmdproc, trans); | 428 msn_cmdproc_send_trans(cmdproc, trans); |
425 } | 429 } |
426 | 430 |
427 static void | 431 static void |
431 MsnMessage *msg; | 435 MsnMessage *msg; |
432 PurpleConnection *gc; | 436 PurpleConnection *gc; |
433 const char *passport; | 437 const char *passport; |
434 const char *content_type; | 438 const char *content_type; |
435 | 439 |
436 purple_debug_info("MSNP14","Process UBM payload:%.*s\n", len, payload); | 440 purple_debug_info("MSNP14","Process UBM payload:%.*s\n", (guint)len, payload); |
437 msg = msn_message_new_from_cmd(cmdproc->session, cmd); | 441 msg = msn_message_new_from_cmd(cmdproc->session, cmd); |
438 | 442 |
439 msn_message_parse_payload(msg, payload, len,MSG_LINE_DEM,MSG_BODY_DEM); | 443 msn_message_parse_payload(msg, payload, len,MSG_LINE_DEM,MSG_BODY_DEM); |
440 #ifdef MSN_DEBUG_NS | 444 #ifdef MSN_DEBUG_NS |
441 msn_message_show_readable(msg, "Notification", TRUE); | 445 msn_message_show_readable(msg, "Notification", TRUE); |
443 | 447 |
444 gc = cmdproc->session->account->gc; | 448 gc = cmdproc->session->account->gc; |
445 passport = msg->remote_user; | 449 passport = msg->remote_user; |
446 | 450 |
447 content_type = msn_message_get_content_type(msg); | 451 content_type = msn_message_get_content_type(msg); |
448 purple_debug_info("MSNP14","type:%d\n",content_type); | 452 purple_debug_info("MSNP14", "type:%s\n", content_type); |
449 if(!strcmp(content_type,"text/plain")){ | 453 if(!strcmp(content_type,"text/plain")){ |
450 const char *value; | 454 const char *value; |
451 const char *body; | 455 const char *body; |
452 char *body_enc; | 456 char *body_enc; |
453 char *body_final = NULL; | 457 char *body_final = NULL; |
512 cmdproc->last_cmd->payload_cb = ubm_cmd_post; | 516 cmdproc->last_cmd->payload_cb = ubm_cmd_post; |
513 cmdproc->servconn->payload_len = atoi(cmd->params[2]); | 517 cmdproc->servconn->payload_len = atoi(cmd->params[2]); |
514 }else{ | 518 }else{ |
515 g_return_if_fail(cmd->payload_cb != NULL); | 519 g_return_if_fail(cmd->payload_cb != NULL); |
516 | 520 |
517 purple_debug_info("MSNP14","UBM payload:{%.*s}\n", cmd->payload_len, cmd->payload); | 521 purple_debug_info("MSNP14", "UBM payload:{%.*s}\n", (guint)(cmd->payload_len), cmd->payload); |
518 ubm_cmd_post(cmdproc, cmd, cmd->payload, cmd->payload_len); | 522 ubm_cmd_post(cmdproc, cmd, cmd->payload, cmd->payload_len); |
519 } | 523 } |
520 } | 524 } |
521 | 525 |
522 /************************************************************************** | 526 /************************************************************************** |
627 static void | 631 static void |
628 msn_notification_post_adl(MsnCmdProc *cmdproc, const char *payload, int payload_len) | 632 msn_notification_post_adl(MsnCmdProc *cmdproc, const char *payload, int payload_len) |
629 { | 633 { |
630 MsnTransaction *trans; | 634 MsnTransaction *trans; |
631 purple_debug_info("MSN Notification","Sending ADL with payload: %s\n", payload); | 635 purple_debug_info("MSN Notification","Sending ADL with payload: %s\n", payload); |
632 trans = msn_transaction_new(cmdproc, "ADL","%d", strlen(payload)); | 636 trans = msn_transaction_new(cmdproc, "ADL","%" G_GSIZE_FORMAT, payload_len); |
633 msn_transaction_set_payload(trans, payload, strlen(payload)); | 637 msn_transaction_set_payload(trans, payload, payload_len); |
634 msn_cmdproc_send_trans(cmdproc, trans); | 638 msn_cmdproc_send_trans(cmdproc, trans); |
635 } | 639 } |
636 | 640 |
637 /*dump contact info to NS*/ | 641 /*dump contact info to NS*/ |
638 void | 642 void |
711 tokens = g_strsplit(passport, "@", 2); | 715 tokens = g_strsplit(passport, "@", 2); |
712 email = tokens[0]; | 716 email = tokens[0]; |
713 domain = tokens[1]; | 717 domain = tokens[1]; |
714 | 718 |
715 payload = g_strdup_printf("<ml><d n=\"%s\"><c n=\"%s\"/></d></ml>", domain, email); | 719 payload = g_strdup_printf("<ml><d n=\"%s\"><c n=\"%s\"/></d></ml>", domain, email); |
716 trans = msn_transaction_new(cmdproc, "FQY","%d", strlen(payload)); | 720 trans = msn_transaction_new(cmdproc, "FQY","%" G_GSIZE_FORMAT, strlen(payload)); |
717 msn_transaction_set_payload(trans, payload, strlen(payload)); | 721 msn_transaction_set_payload(trans, payload, strlen(payload)); |
718 msn_cmdproc_send_trans(cmdproc, trans); | 722 msn_cmdproc_send_trans(cmdproc, trans); |
719 | 723 |
720 g_free(payload); | 724 g_free(payload); |
721 g_strfreev(tokens); | 725 g_strfreev(tokens); |
982 if (session->passport_info.file == NULL) | 986 if (session->passport_info.file == NULL) |
983 return; | 987 return; |
984 | 988 |
985 passport = purple_normalize(account, purple_account_get_username(account)); | 989 passport = purple_normalize(account, purple_account_get_username(account)); |
986 | 990 |
987 if ((strstr(passport, "@hotmail.") != NULL) || | 991 if ((strstr(passport, "@hotmail.") == NULL) && |
988 (strstr(passport, "@msn.com") != NULL)) | 992 (strstr(passport, "@live.com") == NULL) && |
993 (strstr(passport, "@msn.com") == NULL)) | |
989 return; | 994 return; |
990 | 995 |
991 if (count++ < 26) | 996 if (count++ < 26) |
992 return; | 997 return; |
993 | 998 |
1020 MsnSession *session; | 1025 MsnSession *session; |
1021 PurpleAccount *account; | 1026 PurpleAccount *account; |
1022 PurpleConnection *gc; | 1027 PurpleConnection *gc; |
1023 MsnUser *user; | 1028 MsnUser *user; |
1024 MsnObject *msnobj; | 1029 MsnObject *msnobj; |
1030 unsigned long clientid; | |
1025 int wlmclient; | 1031 int wlmclient; |
1026 const char *state, *passport, *friendly; | 1032 const char *state, *passport, *friendly; |
1027 | 1033 |
1028 session = cmdproc->session; | 1034 session = cmdproc->session; |
1029 account = session->account; | 1035 account = session->account; |
1045 { | 1051 { |
1046 msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[6])); | 1052 msnobj = msn_object_new_from_string(purple_url_decode(cmd->params[6])); |
1047 msn_user_set_object(user, msnobj); | 1053 msn_user_set_object(user, msnobj); |
1048 } | 1054 } |
1049 | 1055 |
1056 clientid = strtoul(cmd->params[5], NULL, 10); | |
1057 user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone.mobile && user->phone.mobile[0] == '+'); | |
1058 | |
1050 msn_user_set_state(user, state); | 1059 msn_user_set_state(user, state); |
1051 msn_user_update(user); | 1060 msn_user_update(user); |
1052 } | 1061 } |
1053 | 1062 |
1054 static void | 1063 static void |
1055 ipg_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, size_t len) | 1064 ipg_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, size_t len) |
1056 { | 1065 { |
1057 #if 0 | 1066 PurpleConnection *gc; |
1067 MsnUserList *userlist; | |
1068 char *who = NULL, *text = NULL; | |
1069 xmlnode *payloadNode, *from, *textNode; | |
1070 | |
1058 purple_debug_misc("msn", "Incoming Page: {%s}\n", payload); | 1071 purple_debug_misc("msn", "Incoming Page: {%s}\n", payload); |
1059 #endif | 1072 |
1073 userlist = cmdproc->session->userlist; | |
1074 gc = purple_account_get_connection(cmdproc->session->account); | |
1075 | |
1076 /* payload looks like this: | |
1077 <?xml version="1.0"?> | |
1078 <NOTIFICATION id="0" siteid="111100400" siteurl="http://mobile.msn.com/"> | |
1079 <TO name="passport@example.com"> | |
1080 <VIA agent="mobile"/> | |
1081 </TO> | |
1082 <FROM name="tel:+XXXXXXXXXXX"/> | |
1083 <MSG pri="1" id="1"> | |
1084 <CAT Id="110110001"/> | |
1085 <ACTION url="2wayIM.asp"/> | |
1086 <SUBSCR url="2wayIM.asp"/> | |
1087 <BODY lcid="1033"> | |
1088 <TEXT>Message was here</TEXT> | |
1089 </BODY> | |
1090 </MSG> | |
1091 </NOTIFICATION> | |
1092 */ | |
1093 | |
1094 if (!(payloadNode = xmlnode_from_str(payload, len)) || | |
1095 !(from = xmlnode_get_child(payloadNode, "FROM")) || | |
1096 !(textNode = xmlnode_get_child(payloadNode, "MSG/BODY/TEXT"))) | |
1097 return; | |
1098 | |
1099 who = g_strdup(xmlnode_get_attrib(from, "name")); | |
1100 if (!who) return; | |
1101 | |
1102 text = xmlnode_get_data(textNode); | |
1103 | |
1104 /* Match number to user's mobile number, FROM is a phone number if the | |
1105 other side page you using your phone number */ | |
1106 if(!strncmp(who, "tel:+", 5)) { | |
1107 MsnUser *user = | |
1108 msn_userlist_find_user_with_mobile_phone(userlist, who + 4); | |
1109 | |
1110 if(user && user->passport) { | |
1111 g_free(who); | |
1112 who = g_strdup(user->passport); | |
1113 } | |
1114 } | |
1115 | |
1116 serv_got_im(gc, who, text, 0, time(NULL)); | |
1117 | |
1118 g_free(text); | |
1119 g_free(who); | |
1120 xmlnode_free(payloadNode); | |
1060 } | 1121 } |
1061 | 1122 |
1062 static void | 1123 static void |
1063 ipg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | 1124 ipg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
1064 { | 1125 { |
1108 msn_user_set_object(user, NULL); | 1169 msn_user_set_object(user, NULL); |
1109 } | 1170 } |
1110 } | 1171 } |
1111 | 1172 |
1112 clientid = strtoul(cmd->params[4], NULL, 10); | 1173 clientid = strtoul(cmd->params[4], NULL, 10); |
1113 user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE); | 1174 user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone.mobile && user->phone.mobile[0] == '+'); |
1114 | 1175 |
1115 msn_user_set_state(user, state); | 1176 msn_user_set_state(user, state); |
1116 msn_user_update(user); | 1177 msn_user_update(user); |
1117 } | 1178 } |
1118 | 1179 |
1628 str = msn_get_currentmedia(cmd->payload, len); | 1689 str = msn_get_currentmedia(cmd->payload, len); |
1629 if (msn_parse_currentmedia(str, &media)) | 1690 if (msn_parse_currentmedia(str, &media)) |
1630 msn_user_set_currentmedia(user, &media); | 1691 msn_user_set_currentmedia(user, &media); |
1631 else | 1692 else |
1632 msn_user_set_currentmedia(user, NULL); | 1693 msn_user_set_currentmedia(user, NULL); |
1694 g_free(media.title); | |
1695 g_free(media.album); | |
1696 g_free(media.artist); | |
1633 g_free(str); | 1697 g_free(str); |
1634 | 1698 |
1635 msn_user_update(user); | 1699 msn_user_update(user); |
1636 } | 1700 } |
1637 | 1701 |
1994 | 2058 |
1995 payload = xmlnode_to_str(rml_node, &payload_len); | 2059 payload = xmlnode_to_str(rml_node, &payload_len); |
1996 xmlnode_free(rml_node); | 2060 xmlnode_free(rml_node); |
1997 | 2061 |
1998 purple_debug_info("MSN Notification","Send RML with payload:\n%s\n", payload); | 2062 purple_debug_info("MSN Notification","Send RML with payload:\n%s\n", payload); |
1999 trans = msn_transaction_new(cmdproc, "RML","%d", strlen(payload)); | 2063 trans = msn_transaction_new(cmdproc, "RML","%" G_GSIZE_FORMAT, strlen(payload)); |
2000 msn_transaction_set_payload(trans, payload, strlen(payload)); | 2064 msn_transaction_set_payload(trans, payload, strlen(payload)); |
2001 msn_cmdproc_send_trans(cmdproc, trans); | 2065 msn_cmdproc_send_trans(cmdproc, trans); |
2002 g_free(payload); | 2066 g_free(payload); |
2003 } | 2067 } |
2004 | 2068 |