Mercurial > pidgin
changeset 19822:509383ef25f8
[gaim-migrate @ 17015]
delete oim integration ok
committed by MaYuan<mayuan2006@gmail.com>
committer: Ethan Blanton <elb@pidgin.im>
author | Ma Yuan <mayuan2006@gmail.com> |
---|---|
date | Thu, 24 Aug 2006 16:38:30 +0000 |
parents | 0af038b3b7fe |
children | 1b6c631012d9 |
files | src/protocols/msn/README src/protocols/msn/notification.c src/protocols/msn/oim.c src/protocols/msn/oim.h src/protocols/msn/soap.c src/protocols/msn/soap.h |
diffstat | 6 files changed, 122 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/msn/README Thu Aug 24 14:21:43 2006 +0000 +++ b/src/protocols/msn/README Thu Aug 24 16:38:30 2006 +0000 @@ -2,29 +2,31 @@ by Ma Yuan<mayuan2006@gmail.com> 1. Introduction +------------- MSNP14 Protocol, proposed by Windows Live Messenger, is new, and there is no available implementation except the official one on Windows Platform. It has introduced many new features attractable to many users, such as: * Offline Instant Message -You can send the offline Message to the offline User, + You can send the offline Message to the offline User, The message will be posted to that user the next time when he is online. - * Communicate with Yahoo User +* Communicate with Yahoo User U can chat with the Yahoo User in MSN, That's Fantastic! Till now , you can send text/Nudge to Yahoo User. - * Windows Live ID authentition +* Windows Live ID authentition WLM use the Window Live ID Authentication process,Known as Passport 3.0, The procedure is totally different to the previous Passport 2.0 - * Video/Audio Conversation - U can communicate with other's via Video/Audio. +* Video/Audio Conversation + U can communicate with other's via Video/Audio. (Though very interesting, not implemented in this version) 2.New Features Added +----------------- -till Now, This project has implemented the following Feature: +Till now, This project has implemented the following Feature: * Windows Live ID authentication. * Offline Instant Message @@ -33,9 +35,11 @@ * Communicate with Yahoo User Can send/receive Message/Nudge to Yahoo User. -3. Changes to made to fit MSNP14 Protocol +*. Changes to made to fit MSNP14 Protocol -4. Reference +3. Reference +------------- + The very useful sites of MSN Protocol: MSNpiki site: reverse engineer of MSN Protocol.up to dated.
--- a/src/protocols/msn/notification.c Thu Aug 24 14:21:43 2006 +0000 +++ b/src/protocols/msn/notification.c Thu Aug 24 16:38:30 2006 +0000 @@ -1612,6 +1612,12 @@ // msn_add_group(session,"hello"); } +/*offline Message Notification*/ +static void +delete_oim_msg(MsnCmdProc *cmdproc, MsnMessage *msg) +{ +} + static void email_msg(MsnCmdProc *cmdproc, MsnMessage *msg) { @@ -1852,6 +1858,10 @@ msn_table_add_msg_type(cbs_table, "text/x-msmsgsemailnotification", email_msg); + /*delete an offline Message notification*/ + msn_table_add_msg_type(cbs_table, + "text/x-msmsgsactivemailnotification", + delete_oim_msg); msn_table_add_msg_type(cbs_table, "application/x-msmsgssystemmessage", system_msg);
--- a/src/protocols/msn/oim.c Thu Aug 24 14:21:43 2006 +0000 +++ b/src/protocols/msn/oim.c Thu Aug 24 16:38:30 2006 +0000 @@ -149,6 +149,54 @@ /**************************************** * OIM delete SOAP request * **************************************/ +static void +msn_oim_delete_read_cb(gpointer data, GaimSslConnection *gsc, + GaimInputCondition cond) +{ + MsnSoapConn * soapconn = data; + MsnOim * oim = soapconn->session->oim; + + gaim_debug_info("MaYuan","OIM delete read buffer:{%s}\n",soapconn->body); + + msn_soap_free_read_buf(soapconn); + /*get next single Offline Message*/ + msn_soap_post(soapconn,NULL,msn_oim_retrieve_connect_init); +} + +static void +msn_oim_delete_written_cb(gpointer data, gint source, GaimInputCondition cond) +{ + MsnSoapConn * soapconn = data; + + soapconn->read_cb = msn_oim_delete_read_cb; +} + +/*Post to get the Offline Instant Message*/ +static void +msn_oim_post_delete_msg(MsnOim *oim,const char *msgid) +{ + MsnSoapReq *soap_request; + const char *soap_body,*t,*p; + + g_return_if_fail(oim != NULL); + g_return_if_fail(msgid != NULL); + + gaim_debug_info("MaYuan","Delete single OIM Message {%s}\n",msgid); + t = oim->session->passport_info.t; + p = oim->session->passport_info.p; + + soap_body = g_strdup_printf(MSN_OIM_DEL_TEMPLATE, + t, + p, + msgid + ); + soap_request = msn_soap_request_new(MSN_OIM_RETRIEVE_HOST, + MSN_OIM_RETRIEVE_URL,MSN_OIM_DEL_SOAP_ACTION, + soap_body, + msn_oim_delete_read_cb, + msn_oim_delete_written_cb); + msn_soap_post(oim->retrieveconn,soap_request,msn_oim_retrieve_connect_init); +} /**************************************** * OIM get SOAP request @@ -162,6 +210,7 @@ session = soapconn->session; g_return_if_fail(session != NULL); + msn_soap_clean_unhandled_request(soapconn); // msn_session_set_error(session, MSN_ERROR_SERV_DOWN, _("Unable to connect to OIM server")); } @@ -184,6 +233,7 @@ gaim_debug_info("MaYuan","oim get SOAP Server connected!\n"); } +/*Post the Offline Instant Message to User Conversation*/ void msn_oim_report_to_user(MsnOim *oim,char *msg_str) { @@ -194,6 +244,7 @@ char *start,*end; int has_nick = 0; char *passport_str,*passport; + char *msg_id; message = msn_message_new(MSN_MSG_UNKNOWN); @@ -225,24 +276,37 @@ gaim_debug_info("MaYuan","oim Date:{%s},passport{%s}\n",date,passport); msn_session_report_user(oim->session,passport,decode_msg,GAIM_MESSAGE_SYSTEM); + + /*Now get the oim message ID from the oim_list. + * and append to read list to prepare for deleting the Offline Message when sign out + */ + if(oim->oim_list != NULL){ + msg_id = oim->oim_list->data; + msn_oim_post_delete_msg(oim,msg_id); + oim->oim_list = g_list_remove(oim->oim_list, oim->oim_list->data); + } + g_free(passport); } +/* Parse the XML data, + * prepare to report the OIM to user + */ void -msn_oim_process(MsnOim *oim,char *oim_msg) +msn_oim_get_process(MsnOim *oim,char *oim_msg) { xmlnode *oimNode,*bodyNode,*responseNode,*msgNode; char *msg_data,*msg_str; oimNode = xmlnode_from_str(oim_msg, strlen(oim_msg)); bodyNode = xmlnode_get_child(oimNode,"Body"); -// gaim_debug_misc("xml","body{%p},name:%s\n",bodyNode,bodyNode->name); responseNode = xmlnode_get_child(bodyNode,"GetMessageResponse"); msgNode = xmlnode_get_child(responseNode,"GetMessageResult"); msg_data = xmlnode_get_data(msgNode); msg_str = g_strdup(msg_data); gaim_debug_info("OIM","msg:{%s}\n",msg_str); msn_oim_report_to_user(oim,msg_str); + g_free(msg_str); } @@ -256,10 +320,10 @@ gaim_debug_info("MaYuan","OIM get read buffer:{%s}\n",soapconn->body); /*we need to process the read message!*/ - msn_oim_process(oim,soapconn->body); + msn_oim_get_process(oim,soapconn->body); msn_soap_free_read_buf(soapconn); + /*get next single Offline Message*/ -// oim->oim_list = g_list_remove(oim->oim_list, oim->oim_list->data); msn_soap_post(soapconn,NULL,msn_oim_retrieve_connect_init); } @@ -272,7 +336,9 @@ // msn_soap_read_cb(data,source,cond); } -/*parse the oim XML data*/ +/* parse the oim XML data + * and post it to the soap server to get the Offline Message + * */ void msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg) { @@ -291,13 +357,15 @@ nNode = xmlnode_get_child(mNode,"N"); nickname = xmlnode_get_data(nNode); gaim_debug_info("MaYuan","E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime); -// msn_session_report_user(oim->session,passport,"hello"); + oim->oim_list = g_list_append(oim->oim_list,msgid); msn_oim_post_single_get_msg(oim,msgid); } } -static void msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid) +/*Post to get the Offline Instant Message*/ +static void +msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid) { MsnSoapReq *soap_request; const char *soap_body,*t,*p; @@ -329,6 +397,7 @@ msn_oim_get_error_cb); } +/*Msn OIM Send Server Connect Init Function*/ void msn_oim_send_connect_init(MsnSoapConn *sendconn) { gaim_debug_info("MaYuan","msn oim send connect init...\n");
--- a/src/protocols/msn/oim.h Thu Aug 24 14:21:43 2006 +0000 +++ b/src/protocols/msn/oim.h Thu Aug 24 16:38:30 2006 +0000 @@ -25,10 +25,10 @@ #ifndef _MSN_OIM_H_ #define _MSN_OIM_H_ +/*OIM Retrieve SOAP Template*/ #define MSN_OIM_RETRIEVE_HOST "rsi.hotmail.com" #define MSN_OIM_RETRIEVE_URL "/rsi/rsi.asmx" #define MSN_OIM_GET_SOAP_ACTION "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/GetMessage" -#define MSN_OIM_DEL_SOAP_ACTION "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/DeleteMessages" #define MSN_OIM_GET_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"\ @@ -46,6 +46,9 @@ "</soap:Body>"\ "</soap:Envelope>" +/*OIM Delete SOAP Template*/ +#define MSN_OIM_DEL_SOAP_ACTION "http://www.hotmail.msn.com/ws/2004/09/oim/rsi/DeleteMessages" + #define MSN_OIM_DEL_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"\ "<soap:Header>"\ @@ -63,6 +66,7 @@ "</soap:Body>"\ "</soap:Envelope>" +/*OIM Send SOAP Template*/ #define MSN_OIM_SEND_HOST "ows.messenger.msn.com" #define MSN_OIM_SEND_URL "/OimWS/oim.asmx" #define MSN_OIM_SEND_SOAP_ACTION "http://messenger.msn.com/ws/2004/09/oim/Store"
--- a/src/protocols/msn/soap.c Thu Aug 24 14:21:43 2006 +0000 +++ b/src/protocols/msn/soap.c Thu Aug 24 16:38:30 2006 +0000 @@ -141,12 +141,23 @@ msn_soap_set_process_step(soapconn,MSN_SOAP_UNCONNECTED); } +/*clean the unhandled SOAP request*/ +void +msn_soap_clean_unhandled_request(MsnSoapConn *soapconn) +{ + MsnSoapReq *request; + + g_return_if_fail(soapconn != NULL); + + while ((request = g_queue_pop_head(soapconn->soap_queue)) != NULL){ + msn_soap_request_free(request); + } +} + /*destroy the soap connection*/ void msn_soap_destroy(MsnSoapConn *soapconn) { - MsnSoapReq *request; - if(soapconn->login_host) g_free(soapconn->login_host); @@ -168,9 +179,8 @@ msn_soap_close(soapconn); /*process the unhandled soap request*/ - while ((request = g_queue_pop_head(soapconn->soap_queue)) != NULL){ - msn_soap_request_free(request); - } + msn_soap_clean_unhandled_request(soapconn); + g_queue_free(soapconn->soap_queue); g_free(soapconn); } @@ -551,7 +561,7 @@ "Content-Type:text/xml; charset=utf-8\r\n" "Cookie: MSPAuth=%s\r\n" "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" - "Accept: text/*\r\n" + "Accept: */*\r\n" "Host: %s\r\n" "Content-Length: %d\r\n" "Connection: Keep-Alive\r\n"
--- a/src/protocols/msn/soap.h Thu Aug 24 14:21:43 2006 +0000 +++ b/src/protocols/msn/soap.h Thu Aug 24 16:38:30 2006 +0000 @@ -133,6 +133,9 @@ void msn_soap_connect_cb(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond); void msn_soap_read_cb(gpointer data, gint source, GaimInputCondition cond); +/*clean the unhandled request*/ +void msn_soap_clean_unhandled_request(MsnSoapConn *soapconn); + /*check if the soap connection is connected*/ int msn_soap_connected(MsnSoapConn *soapconn);