Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/oim.c @ 23391:5c70d953a497
propagate from branch 'im.pidgin.pidgin.2.4.3' (head 709ec9c29e9d76eebbded25061107ef0a2a2b148)
to branch 'im.pidgin.pidgin' (head e8d624d4b86e9505bb225f2a6e7b29ec6c8affed)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 26 Jun 2008 09:07:56 +0000 |
parents | ca2e48afba25 5cdd93dac7a2 |
children | 9b58bc7adfc7 |
comparison
equal
deleted
inserted
replaced
23057:d04d24b1db9b | 23391:5c70d953a497 |
---|---|
1 /** | 1 /** |
2 * @file oim.c | 2 * @file oim.c |
3 * get and send MSN offline Instant Message via SOAP request | 3 * get and send MSN offline Instant Message via SOAP request |
4 * Author | 4 * Author |
5 * MaYuan<mayuan2006@gmail.com> | 5 * MaYuan<mayuan2006@gmail.com> |
6 * purple | 6 * purple |
7 * | 7 * |
89 static MsnOimSendReq * | 89 static MsnOimSendReq * |
90 msn_oim_new_send_req(const char *from_member, const char*friendname, | 90 msn_oim_new_send_req(const char *from_member, const char*friendname, |
91 const char* to_member, const char *msg) | 91 const char* to_member, const char *msg) |
92 { | 92 { |
93 MsnOimSendReq *request; | 93 MsnOimSendReq *request; |
94 | 94 |
95 request = g_new0(MsnOimSendReq, 1); | 95 request = g_new0(MsnOimSendReq, 1); |
96 request->from_member = g_strdup(from_member); | 96 request->from_member = g_strdup(from_member); |
97 request->friendname = g_strdup(friendname); | 97 request->friendname = g_strdup(friendname); |
98 request->to_member = g_strdup(to_member); | 98 request->to_member = g_strdup(to_member); |
99 request->oim_msg = g_strdup(msg); | 99 request->oim_msg = g_strdup(msg); |
107 | 107 |
108 g_free(req->from_member); | 108 g_free(req->from_member); |
109 g_free(req->friendname); | 109 g_free(req->friendname); |
110 g_free(req->to_member); | 110 g_free(req->to_member); |
111 g_free(req->oim_msg); | 111 g_free(req->oim_msg); |
112 | 112 |
113 g_free(req); | 113 g_free(req); |
114 } | 114 } |
115 | 115 |
116 /**************************************** | 116 /**************************************** |
117 * OIM send SOAP request | 117 * OIM send SOAP request |
119 /*encode the message to OIM Message Format*/ | 119 /*encode the message to OIM Message Format*/ |
120 static gchar * | 120 static gchar * |
121 msn_oim_msg_to_str(MsnOim *oim, const char *body) | 121 msn_oim_msg_to_str(MsnOim *oim, const char *body) |
122 { | 122 { |
123 char *oim_body,*oim_base64; | 123 char *oim_body,*oim_base64; |
124 | 124 |
125 purple_debug_info("MSN OIM","encode OIM Message...\n"); | 125 purple_debug_info("MSN OIM","encode OIM Message...\n"); |
126 oim_base64 = purple_base64_encode((const guchar *)body, strlen(body)); | 126 oim_base64 = purple_base64_encode((const guchar *)body, strlen(body)); |
127 purple_debug_info("MSN OIM","encoded base64 body:{%s}\n",oim_base64); | 127 purple_debug_info("MSN OIM","encoded base64 body:{%s}\n",oim_base64); |
128 oim_body = g_strdup_printf(MSN_OIM_MSG_TEMPLATE, | 128 oim_body = g_strdup_printf(MSN_OIM_MSG_TEMPLATE, |
129 oim->run_id,oim->send_seq,oim_base64); | 129 oim->run_id,oim->send_seq,oim_base64); |
130 g_free(oim_base64); | 130 g_free(oim_base64); |
131 | 131 |
132 return oim_body; | 132 return oim_body; |
211 g_queue_push_tail(oim->send_queue, | 211 g_queue_push_tail(oim->send_queue, |
212 msn_oim_new_send_req(membername, friendname, tomember, msg)); | 212 msn_oim_new_send_req(membername, friendname, tomember, msg)); |
213 } | 213 } |
214 | 214 |
215 /*post send single message request to oim server*/ | 215 /*post send single message request to oim server*/ |
216 void | 216 void |
217 msn_oim_send_msg(MsnOim *oim) | 217 msn_oim_send_msg(MsnOim *oim) |
218 { | 218 { |
219 MsnOimSendReq *oim_request; | 219 MsnOimSendReq *oim_request; |
220 char *soap_body,*mspauth; | 220 char *soap_body,*mspauth; |
221 char *msg_body; | 221 char *msg_body; |
331 &t.tm_mday, month_str, &t.tm_year, | 331 &t.tm_mday, month_str, &t.tm_year, |
332 &t.tm_hour, &t.tm_min, &t.tm_sec, tz_str) == 7) { | 332 &t.tm_hour, &t.tm_min, &t.tm_sec, tz_str) == 7) { |
333 gboolean offset_positive = TRUE; | 333 gboolean offset_positive = TRUE; |
334 int tzhrs; | 334 int tzhrs; |
335 int tzmins; | 335 int tzmins; |
336 | 336 |
337 for (t.tm_mon = 0; | 337 for (t.tm_mon = 0; |
338 months[t.tm_mon] != NULL && | 338 months[t.tm_mon] != NULL && |
339 strcmp(months[t.tm_mon], month_str) != 0; t.tm_mon++); | 339 strcmp(months[t.tm_mon], month_str) != 0; t.tm_mon++); |
340 if (months[t.tm_mon] != NULL) { | 340 if (months[t.tm_mon] != NULL) { |
341 if (*tz_str == '-') { | 341 if (*tz_str == '-') { |
460 } else { | 460 } else { |
461 purple_debug_info("msnoim", "Failed to get OIM\n"); | 461 purple_debug_info("msnoim", "Failed to get OIM\n"); |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 static void | 465 /* parse the oim XML data |
466 msn_parse_oim_xml(MsnOim *oim, xmlnode *node) | 466 * and post it to the soap server to get the Offline Message |
467 { | 467 * */ |
468 xmlnode *mNode; | 468 void |
469 msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg) | |
470 { | |
471 xmlnode *node, *mNode; | |
469 xmlnode *iu_node; | 472 xmlnode *iu_node; |
470 MsnSession *session = oim->session; | 473 MsnSession *session = oim->session; |
471 | 474 |
472 g_return_if_fail(node != NULL); | 475 purple_debug_info("MSNP14:OIM", "%s\n", xmlmsg); |
473 | 476 |
477 node = xmlnode_from_str(xmlmsg, -1); | |
474 if (strcmp(node->name, "MD") != 0) { | 478 if (strcmp(node->name, "MD") != 0) { |
475 char *xmlmsg = xmlnode_to_str(node, NULL); | |
476 purple_debug_info("msnoim", "WTF is this? %s\n", xmlmsg); | 479 purple_debug_info("msnoim", "WTF is this? %s\n", xmlmsg); |
477 g_free(xmlmsg); | 480 xmlnode_free(node); |
478 return; | 481 return; |
479 } | 482 } |
480 | 483 |
481 iu_node = msn_soap_xml_get(node, "E/IU"); | 484 iu_node = msn_soap_xml_get(node, "E/IU"); |
482 | 485 |
523 g_free(passport); | 526 g_free(passport); |
524 g_free(msgid); | 527 g_free(msgid); |
525 g_free(rtime); | 528 g_free(rtime); |
526 g_free(nickname); | 529 g_free(nickname); |
527 } | 530 } |
528 } | 531 |
529 | 532 xmlnode_free(node); |
530 /* parse the oim XML data | |
531 * and post it to the soap server to get the Offline Message | |
532 * */ | |
533 void | |
534 msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg) | |
535 { | |
536 xmlnode *node; | |
537 | |
538 purple_debug_info("MSNP14:OIM", "%s\n", xmlmsg); | |
539 | |
540 if (!strcmp(xmlmsg, "too-large")) { | |
541 /* Too many OIM's to send via NS, so we need to request them | |
542 * via SOAP. */ | |
543 purple_debug_info("msnoim", "too many OIMs, not supported yet\n"); | |
544 } else { | |
545 node = xmlnode_from_str(xmlmsg, -1); | |
546 msn_parse_oim_xml(oim, node); | |
547 xmlnode_free(node); | |
548 } | |
549 } | 533 } |
550 | 534 |
551 /*Post to get the Offline Instant Message*/ | 535 /*Post to get the Offline Instant Message*/ |
552 static void | 536 static void |
553 msn_oim_post_single_get_msg(MsnOim *oim, char *msgid) | 537 msn_oim_post_single_get_msg(MsnOim *oim, char *msgid) |