summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMa Yuan <mayuan2006@gmail.com>2006-08-12 10:30:30 +0000
committerMa Yuan <mayuan2006@gmail.com>2006-08-12 10:30:30 +0000
commit17371425d0b933fb9fc374af51b9decf424d5aa2 (patch)
tree4d182fe15cc509e33950551a906eea123645fc46
parentc473cbbb1e5ed0e2ba883aa09f631c91e57498f6 (diff)
downloadpidgin-17371425d0b933fb9fc374af51b9decf424d5aa2.tar.gz
[gaim-migrate @ 16716]
add/delete contact function OK committed by MaYuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
-rw-r--r--src/protocols/msn/contact.c123
-rw-r--r--src/protocols/msn/contact.h11
-rw-r--r--src/protocols/msn/msn.c1
-rw-r--r--src/protocols/msn/notification.c164
-rw-r--r--src/protocols/msn/notification.h2
-rw-r--r--src/protocols/msn/oim.c22
-rw-r--r--src/protocols/msn/soap.c22
-rw-r--r--src/protocols/msn/soap.h2
-rw-r--r--src/protocols/msn/state.c15
-rw-r--r--src/protocols/msn/userlist.c12
10 files changed, 270 insertions, 104 deletions
diff --git a/src/protocols/msn/contact.c b/src/protocols/msn/contact.c
index 606506cbc9..59992d19fa 100644
--- a/src/protocols/msn/contact.c
+++ b/src/protocols/msn/contact.c
@@ -195,7 +195,7 @@ msn_get_contact_list_cb(gpointer data, gint source, GaimInputCondition cond)
}
static void
-msn_contact_written_cb(gpointer data, gint source, GaimInputCondition cond)
+msn_get_contact_written_cb(gpointer data, gint source, GaimInputCondition cond)
{
MsnSoapConn * soapconn = data;
@@ -210,7 +210,7 @@ msn_get_contact_list(MsnContact * contact)
gaim_debug_info("MaYuan","msn_get_contact_list()...\n");
contact->soapconn->login_path = g_strdup(MSN_GET_CONTACT_POST_URL);
contact->soapconn->soap_action = g_strdup(MSN_GET_CONTACT_SOAP_ACTION);
- msn_soap_post(contact->soapconn,MSN_GET_CONTACT_TEMPLATE,msn_contact_written_cb);
+ msn_soap_post(contact->soapconn,MSN_GET_CONTACT_TEMPLATE,msn_get_contact_written_cb);
}
static void
@@ -372,7 +372,7 @@ msn_parse_addressbook(MsnContact * contact)
xmlnode_free(node);
msn_soap_free_read_buf(contact->soapconn);
- dump_adl_cmd(session);
+ msn_notification_dump_contact(session);
msn_set_psm(session);
msn_session_finish_login(session);
}
@@ -415,44 +415,99 @@ msn_get_address_book(MsnContact *contact)
msn_soap_post(contact->soapconn,MSN_GET_ADDRESS_TEMPLATE,msn_address_written_cb);
}
+static void
+msn_add_contact_read_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ gaim_debug_info("MaYuan","block read done\n");
+}
+
+static void
+msn_add_contact_written_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ MsnSoapConn * soapconn = data;
+
+ gaim_debug_info("MaYuan","finish unblock written\n");
+ soapconn->read_cb = msn_add_contact_read_cb;
+ msn_soap_read_cb(data,source,cond);
+}
+
/*add a Contact */
void
-msn_add_contact(MsnContact *contact,const char *passport)
+msn_add_contact(MsnContact *contact,const char *passport,char *groupId)
{
char *body = NULL;
char *contact_xml = NULL;
gaim_debug_info("MaYuan","msn add a contact...\n");
contact_xml = g_strdup_printf(MSN_CONTACT_XML,passport);
- body = g_strdup_printf(MSN_ADD_CONTACT_TEMPLATE,contact_xml);
- g_free(contact_xml);
-
- /*build SOAP and POST it*/
- contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL);
- contact->soapconn->soap_action = g_strdup(MSN_CONTACT_ADD_SOAP_ACTION);
- msn_soap_post(contact->soapconn,body,msn_address_written_cb);
+ if(groupId == NULL){
+ body = g_strdup_printf(MSN_ADD_CONTACT_TEMPLATE,contact_xml);
+ g_free(contact_xml);
+ /*build SOAP and POST it*/
+ contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL);
+ contact->soapconn->soap_action = g_strdup(MSN_CONTACT_ADD_SOAP_ACTION);
+ }else{
+ body = g_strdup_printf(MSN_ADD_CONTACT_GROUP_TEMPLATE,groupId,contact_xml);
+ g_free(contact_xml);
+ /*build SOAP and POST it*/
+ contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL);
+ contact->soapconn->soap_action = g_strdup(MSN_ADD_CONTACT_GROUP_SOAP_ACTION);
+ }
+ msn_soap_post(contact->soapconn,body,msn_add_contact_written_cb);
g_free(body);
}
+static void
+msn_delete_contact_read_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ gaim_debug_info("MaYuan","delete contact read done\n");
+}
+
+static void
+msn_delete_contact_written_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ MsnSoapConn * soapconn = data;
+
+ gaim_debug_info("MaYuan","delete contact written\n");
+ soapconn->read_cb = msn_delete_contact_read_cb;
+ msn_soap_read_cb(data,source,cond);
+}
+
/*delete a Contact*/
void
-msn_delete_contact(MsnContact *contact,const char *passport_id)
+msn_delete_contact(MsnContact *contact,const char *contactId)
{
char *body = NULL;
char *contact_xml = NULL ;
- gaim_debug_info("MaYuan","msn delete a contact...\n");
- contact_xml = g_strdup_printf(MSN_CONTACTS_DEL_XML,passport_id);
+ gaim_debug_info("MaYuan","msn delete a contact,contactId:{%s}...\n",contactId);
+ contact_xml = g_strdup_printf(MSN_CONTACTS_DEL_XML,contactId);
body = g_strdup_printf(MSN_DEL_CONTACT_TEMPLATE,contact_xml);
g_free(contact_xml);
/*build SOAP and POST it*/
contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL);
contact->soapconn->soap_action = g_strdup(MSN_CONTACT_DEL_SOAP_ACTION);
- msn_soap_post(contact->soapconn,body,msn_address_written_cb);
+ msn_soap_post(contact->soapconn,body,msn_delete_contact_written_cb);
g_free(body);
}
+static void
+msn_block_read_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ gaim_debug_info("MaYuan","block read done\n");
+}
+
+static void
+msn_block_written_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ MsnSoapConn * soapconn = data;
+
+ gaim_debug_info("MaYuan","finish unblock written\n");
+ soapconn->read_cb = msn_block_read_cb;
+ msn_soap_read_cb(data,source,cond);
+}
+
/*block a Contact*/
void
msn_block_contact(MsnContact *contact,const char* membership_id)
@@ -464,10 +519,26 @@ msn_block_contact(MsnContact *contact,const char* membership_id)
/*build SOAP and POST it*/
contact->soapconn->login_path = g_strdup(MSN_SHARE_POST_URL);
contact->soapconn->soap_action = g_strdup(MSN_CONTACT_BLOCK_SOAP_ACTION);
- msn_soap_post(contact->soapconn,body,msn_address_written_cb);
+ msn_soap_post(contact->soapconn,body,msn_block_written_cb);
g_free(body);
}
+static void
+msn_unblock_read_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ gaim_debug_info("MaYuan","unblock read done\n");
+}
+
+static void
+msn_unblock_written_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ MsnSoapConn * soapconn = data;
+
+ gaim_debug_info("MaYuan","finish unblock written\n");
+ soapconn->read_cb = msn_unblock_read_cb;
+ msn_soap_read_cb(data,source,cond);
+}
+
/*unblock a contact*/
void
msn_unblock_contact(MsnContact *contact,const char* passport)
@@ -480,10 +551,26 @@ msn_unblock_contact(MsnContact *contact,const char* passport)
/*build SOAP and POST it*/
contact->soapconn->login_path = g_strdup(MSN_SHARE_POST_URL);
contact->soapconn->soap_action = g_strdup(MSN_CONTACT_UNBLOCK_SOAP_ACTION);
- msn_soap_post(contact->soapconn,body,msn_address_written_cb);
+ msn_soap_post(contact->soapconn,body,msn_unblock_written_cb);
g_free(body);
}
+static void
+msn_gleams_read_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ gaim_debug_info("MaYuan","Gleams read done\n");
+}
+
+static void
+msn_gleams_written_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+ MsnSoapConn * soapconn = data;
+
+ gaim_debug_info("MaYuan","finish Group written\n");
+ soapconn->read_cb = msn_gleams_read_cb;
+ msn_soap_read_cb(data,source,cond);
+}
+
/*get the gleams info*/
void
msn_get_gleams(MsnContact *contact)
@@ -492,7 +579,7 @@ msn_get_gleams(MsnContact *contact)
/*build SOAP and POST it*/
contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL);
contact->soapconn->soap_action = g_strdup(MSN_GET_GLEAMS_SOAP_ACTION);
- msn_soap_post(contact->soapconn,MSN_GLEAMS_TEMPLATE,msn_address_written_cb);
+ msn_soap_post(contact->soapconn,MSN_GLEAMS_TEMPLATE,msn_gleams_written_cb);
}
/***************************************************************
diff --git a/src/protocols/msn/contact.h b/src/protocols/msn/contact.h
index 6c7827a113..9854bd32bf 100644
--- a/src/protocols/msn/contact.h
+++ b/src/protocols/msn/contact.h
@@ -25,7 +25,7 @@
#ifndef _MSN_CONTACT_H_
#define _MSN_CONTACT_H_
-#define MSN_CONTACT_SERVER "contacts.msn.com"
+#define MSN_CONTACT_SERVER "omega.contacts.msn.com"
/*get contact list soap request template*/
#define MSN_GET_CONTACT_POST_URL "/abservice/SharingService.asmx"
@@ -116,6 +116,10 @@
#define MSN_ADD_CONTACT_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"><soap:Header><ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ApplicationId>09607671-1C32-421F-A6A6-CBFAA51AB5F4</ApplicationId><IsMigration>false</IsMigration><PartnerScenario>ContactSave</PartnerScenario></ABApplicationHeader><ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ManagedGroupRequest>false</ManagedGroupRequest></ABAuthHeader></soap:Header><soap:Body><ABContactAdd xmlns=\"http://www.msn.com/webservices/AddressBook\"><abId>00000000-0000-0000-0000-000000000000</abId><contacts>%s</contacts><options><EnableAllowListManagement>true</EnableAllowListManagement></options></ABContactAdd></soap:Body></soap:Envelope>"
+/*Contact Group Add*/
+#define MSN_ADD_CONTACT_GROUP_SOAP_ACTION "http://www.msn.com/webservices/AddressBook/ABGroupContactAdd"
+#define MSN_ADD_CONTACT_GROUP_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"><soap:Header><ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ApplicationId>09607671-1C32-421F-A6A6-CBFAA51AB5F4</ApplicationId><IsMigration>false</IsMigration><PartnerScenario>ContactSave</PartnerScenario></ABApplicationHeader><ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ManagedGroupRequest>false</ManagedGroupRequest></ABAuthHeader></soap:Header><soap:Body><ABGroupContactAdd xmlns=\"http://www.msn.com/webservices/AddressBook\"><abId>00000000-0000-0000-0000-000000000000</abId><groupFilter><groupIds><guid>%s</guid></groupIds></groupFilter><contacts>%s</contacts><groupContactAddOptions><fGenerateMissingQuickName>true</fGenerateMissingQuickName><EnableAllowListManagement>true</EnableAllowListManagement></groupContactAddOptions></ABGroupContactAdd></soap:Body></soap:Envelope>"
+
/*delete contact from contact list soap request template*/
#define MSN_CONTACT_DEL_SOAP_ACTION "http://www.msn.com/webservices/AddressBook/ABContactDelete"
#define MSN_CONTACTS_DEL_XML "<Contact><contactId>%s</contactId></Contact>"
@@ -168,6 +172,11 @@ void msn_contact_connect(MsnContact *contact);
void msn_get_contact_list(MsnContact * contact);
void msn_get_address_book(MsnContact *contact);
+/*contact SOAP Operation*/
+void msn_add_contact(MsnContact *contact,const char *passport,char *groupId);
+void msn_delete_contact(MsnContact *contact,const char *contactId);
+
+
/*group operation*/
void msn_add_group(MsnSession *session,const char* group_name);
void msn_del_group(MsnSession *session,const char *guid);
diff --git a/src/protocols/msn/msn.c b/src/protocols/msn/msn.c
index 06cbc1f15b..49a9475829 100644
--- a/src/protocols/msn/msn.c
+++ b/src/protocols/msn/msn.c
@@ -972,6 +972,7 @@ msn_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group)
userlist = session->userlist;
who = msn_normalize(gc->account, buddy->name);
+ gaim_debug_info("MaYuan","add user:{%s} to group:{%s}\n",who,group->name);
if (!session->logged_in)
{
#if 0
diff --git a/src/protocols/msn/notification.c b/src/protocols/msn/notification.c
index d481d555f6..d7d97845f4 100644
--- a/src/protocols/msn/notification.c
+++ b/src/protocols/msn/notification.c
@@ -34,6 +34,11 @@
static MsnTable *cbs_table;
+/****************************************************************************
+ * Local Function Prototype
+ ****************************************************************************/
+void msn_add_contact_xml(xmlnode *mlNode,char *passport,int list_op,int type);
+
/**************************************************************************
* Main
**************************************************************************/
@@ -434,19 +439,70 @@ chl_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
/**************************************************************************
* Buddy Lists
**************************************************************************/
+/* add contact to xmlnode */
+void
+msn_add_contact_xml(xmlnode *mlNode,char *passport,int list_op,int type)
+{
+ xmlnode *d_node,*c_node;
+ char **tokens;
+ char *email,*domain;
+ char *list_op_str,*type_str;
+
+ gaim_debug_info("MaYuan","passport:%s\n",passport);
+ tokens = g_strsplit(passport, "@", 2);
+ email = tokens[0];
+ domain = tokens[1];
+
+ /*find a domain Node*/
+ for(d_node = xmlnode_get_child(mlNode,"d"); d_node; d_node = xmlnode_get_next_twin(d_node)){
+ const char * attr = NULL;
+ gaim_debug_info("MaYuan","d_node:%s\n",d_node->name);
+ attr = xmlnode_get_attrib(d_node,"n");
+ if(attr == NULL){
+ continue;
+ }
+ if(!strcmp(attr,domain)){
+ break;
+ }
+ }
+ if(d_node == NULL){
+ /*domain not found, create a new domain Node*/
+ gaim_debug_info("MaYuan","get No d_node\n");
+ d_node = xmlnode_new("d");
+ xmlnode_set_attrib(d_node,"n",domain);
+ xmlnode_insert_child(mlNode,d_node);
+ }
+
+ /*create contact node*/
+ c_node = xmlnode_new("c");
+ xmlnode_set_attrib(c_node,"n",email);
+
+ list_op_str = g_strdup_printf("%d",list_op);
+ gaim_debug_info("MaYuan","list_op:%d\n",list_op_str);
+ xmlnode_set_attrib(c_node,"l",list_op_str);
+ g_free(list_op_str);
+#if 0
+ type_str = g_strdup_printf("%d",type);
+ xmlnode_set_attrib(c_node,"t",type_str);
+#else
+ type_str = g_strdup_printf("1");
+ xmlnode_set_attrib(c_node,"t",type_str);
+ g_free(type_str);
+#endif
+ xmlnode_insert_child(d_node, c_node);
+}
+
+/*dump contact info to NS*/
void
-dump_adl_cmd(MsnSession *session)
+msn_notification_dump_contact(MsnSession *session)
{
MsnCmdProc *cmdproc;
MsnTransaction *trans;
MsnUserList *userlist;
MsnUser *user;
GList *l;
- xmlnode *adl_node,*d_node,*c_node;
- char **tokens;
- char *email,*domain;
+ xmlnode *adl_node;
char *payload;
- char *list_op,*type;
int payload_len;
cmdproc = session->notification->cmdproc;
@@ -458,58 +514,15 @@ dump_adl_cmd(MsnSession *session)
/*get the userlist*/
for (l = userlist->users; l != NULL; l = l->next){
user = l->data;
-
- gaim_debug_info("MaYuan","passport:%s\n",user->passport);
- tokens = g_strsplit(user->passport, "@", 2);
- email = tokens[0];
- domain = tokens[1];
-
- /*find a domain node*/
- for(d_node = xmlnode_get_child(adl_node,"d"); d_node; d_node = xmlnode_get_next_twin(d_node)){
- const char * attr = NULL;
- gaim_debug_info("MaYuan","d_node:%s\n",d_node->name);
- attr = xmlnode_get_attrib(d_node,"n");
- if(attr == NULL){
- continue;
- }
- if(!strcmp(attr,domain)){
- break;
- }
- }
- if(d_node == NULL){
- gaim_debug_info("MaYuan","get No d_node\n");
- d_node = xmlnode_new("d");
- xmlnode_set_attrib(d_node,"n",domain);
- xmlnode_insert_child(adl_node,d_node);
- }
-
- /*create contact node*/
- c_node = xmlnode_new("c");
- xmlnode_set_attrib(c_node,"n",email);
-
- list_op = g_strdup_printf("%d",user->list_op);
- gaim_debug_info("MaYuan","list_op:%d\n",user->list_op);
- xmlnode_set_attrib(c_node,"l",list_op);
-#if 0
- type = g_strdup_printf("%d",user->type);
- xmlnode_set_attrib(c_node,"t",type);
-#else
- type = g_strdup_printf("1");
- xmlnode_set_attrib(c_node,"t",type);
-#endif
- xmlnode_insert_child(d_node, c_node);
-
- g_free(list_op);
- g_free(type);
+ msn_add_contact_xml(adl_node,user->passport,user->list_op,user->type);
}
payload = xmlnode_to_str(adl_node,&payload_len);
+ xmlnode_free(adl_node);
gaim_debug_info("MaYuan","ADL{%s}\n",payload);
trans = msn_transaction_new(cmdproc, "ADL","%d",strlen(payload));
-
msn_transaction_set_payload(trans, payload, strlen(payload));
-
msn_cmdproc_send_trans(cmdproc, trans);
}
@@ -1530,16 +1543,29 @@ msn_notification_add_buddy(MsnNotification *notification, const char *list,
const char *group_id)
{
MsnCmdProc *cmdproc;
- cmdproc = notification->servconn->cmdproc;
+ MsnTransaction *trans;
+ xmlnode *adl_node;
+ char *payload;
+ int payload_len;
- if (group_id != NULL && !strcmp(list, "FL"))
+ cmdproc = notification->servconn->cmdproc;
- if (group_id >= 0){
- msn_cmdproc_send(cmdproc, "ADD", "%s %s %s %d",
- list, who, store_name, group_id);
- }else{
- msn_cmdproc_send(cmdproc, "ADD", "%s %s %s", list, who, store_name);
+ if (strcmp(list, "FL") != 0){
}
+
+ adl_node = xmlnode_new("ml");
+ adl_node->child = NULL;
+ xmlnode_set_attrib(adl_node, "l", "1");
+
+ msn_add_contact_xml(adl_node,who,3,1);
+
+ payload = xmlnode_to_str(adl_node,&payload_len);
+ xmlnode_free(adl_node);
+
+ gaim_debug_info("MaYuan","ADL{%s}\n",payload);
+ trans = msn_transaction_new(cmdproc, "ADL","%d",strlen(payload));
+ msn_transaction_set_payload(trans, payload, strlen(payload));
+ msn_cmdproc_send_trans(cmdproc, trans);
}
void
@@ -1547,19 +1573,31 @@ msn_notification_rem_buddy(MsnNotification *notification, const char *list,
const char *who, const char *group_id)
{
MsnCmdProc *cmdproc;
+ MsnTransaction *trans;
+ xmlnode *rml_node;
+ char *payload;
+ int payload_len;
+
cmdproc = notification->servconn->cmdproc;
- if (group_id != NULL){
- msn_cmdproc_send(cmdproc, "REM", "%s %s %d", list, who, group_id);
- }else{
- msn_cmdproc_send(cmdproc, "REM", "%s %s", list, who);
- }
+ rml_node = xmlnode_new("ml");
+ rml_node->child = NULL;
+ xmlnode_set_attrib(rml_node, "l", "1");
+
+ msn_add_contact_xml(rml_node,who,3,1);
+
+ payload = xmlnode_to_str(rml_node,&payload_len);
+ xmlnode_free(rml_node);
+
+ gaim_debug_info("MaYuan","RML{%s}\n",payload);
+ trans = msn_transaction_new(cmdproc, "RML","%d",strlen(payload));
+ msn_transaction_set_payload(trans, payload, strlen(payload));
+ msn_cmdproc_send_trans(cmdproc, trans);
}
/**************************************************************************
* Init
**************************************************************************/
-
void
msn_notification_init(void)
{
diff --git a/src/protocols/msn/notification.h b/src/protocols/msn/notification.h
index ef176cf3da..a38bf00020 100644
--- a/src/protocols/msn/notification.h
+++ b/src/protocols/msn/notification.h
@@ -63,7 +63,7 @@ void msn_notification_destroy(MsnNotification *notification);
gboolean msn_notification_connect(MsnNotification *notification,
const char *host, int port);
void msn_notification_disconnect(MsnNotification *notification);
-void dump_adl_cmd(MsnSession *session);
+void msn_notification_dump_contact(MsnSession *session);
/**
* Closes a notification.
diff --git a/src/protocols/msn/oim.c b/src/protocols/msn/oim.c
index ecbcacb622..5ad10536d9 100644
--- a/src/protocols/msn/oim.c
+++ b/src/protocols/msn/oim.c
@@ -106,7 +106,8 @@ msn_oim_send_written_cb(gpointer data, gint source, GaimInputCondition cond)
}
/*pose single message to oim server*/
-void msn_oim_send_single_msg(MsnOim *oim,char * msg)
+void
+msn_oim_send_single_msg(MsnOim *oim,char * msg)
{
const char *oimsoapbody,*t,*p;
@@ -139,6 +140,10 @@ void msn_oim_send_msg(MsnOim *oim,char *msg)
}
/****************************************
+ * OIM delete SOAP request
+ * **************************************/
+
+/****************************************
* OIM get SOAP request
* **************************************/
/*oim SOAP server login error*/
@@ -179,9 +184,13 @@ msn_oim_get_read_cb(gpointer data, GaimSslConnection *gsc,
GaimInputCondition cond)
{
MsnSoapConn * soapconn = data;
- MsnOim * msnoim;
+ MsnOim * oim = soapconn->session->oim;
gaim_debug_info("MaYuan","OIM get read buffer:{%s}\n",soapconn->body);
+
+ /*get next single Offline Message*/
+ oim->oim_list = g_list_remove(oim->oim_list, oim->oim_list->data);
+// msn_oim_get_msg(oim);
}
static void
@@ -220,7 +229,6 @@ msn_oim_report_user(MsnOim *oim,const char *passport,char *msg)
if ((conv = msn_oim_get_conv(oim,passport)) != NULL){
gaim_conversation_write(conv, NULL, msg, GAIM_MESSAGE_SYSTEM, time(NULL));
}
-
}
/*parse the oim XML data*/
@@ -269,19 +277,15 @@ static void msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid)
msgid
);
msn_soap_post(oim->retrieveconn, oimsoapbody, msn_oim_get_written_cb);
-
}
/*MSN OIM get SOAP request*/
void msn_oim_get_msg(MsnOim *oim)
{
- GList *list;
-
gaim_debug_info("MaYuan","Get OIM with SOAP \n");
// gaim_debug_info("MaYuan","oim->oim_list:%p,data:%s \n",oim->oim_list,oim->oim_list->data);
- for(list = oim->oim_list; list!= NULL;list = g_list_next(list)){
- msn_oim_post_single_get_msg(oim,list->data);
- oim->oim_list = g_list_remove(oim->oim_list, list->data);
+ if(oim->oim_list !=NULL){
+ msn_oim_post_single_get_msg(oim,oim->oim_list->data);
}
}
diff --git a/src/protocols/msn/soap.c b/src/protocols/msn/soap.c
index 9ad6857918..7ee6f299d5 100644
--- a/src/protocols/msn/soap.c
+++ b/src/protocols/msn/soap.c
@@ -146,12 +146,12 @@ msn_soap_read(MsnSoapConn *soapconn)
{
gssize len;
gssize total_len = 0;
- char temp_buf[10240];
+ char temp_buf[MSN_SOAP_READ_BUFF_SIZE];
if(soapconn->ssl_conn){
- len = gaim_ssl_read(soapconn->gsc, temp_buf,sizeof(temp_buf));
+ len = gaim_ssl_read(soapconn->gsc, temp_buf,MSN_SOAP_READ_BUFF_SIZE);
}else{
- len = read(soapconn->fd, temp_buf,sizeof(temp_buf));
+ len = read(soapconn->fd, temp_buf,MSN_SOAP_READ_BUFF_SIZE);
}
if(len >0){
total_len += len;
@@ -162,6 +162,7 @@ msn_soap_read(MsnSoapConn *soapconn)
soapconn->read_len += len;
soapconn->read_buf[soapconn->read_len] = '\0';
}
+ gaim_debug_info("MaYuan","++soap ssl read:{%d}\n",total_len);
// gaim_debug_info("MaYuan","nexus ssl read:{%s}\n",soapconn->read_buf);
return total_len;
}
@@ -209,6 +210,7 @@ msn_soap_read_cb(gpointer data, gint source, GaimInputCondition cond)
/* Redirect. */
char *location, *c;
+ gaim_debug_error("MaYuan", "soap redirect\n");
location = strstr(soapconn->read_buf, "Location: ");
if (location == NULL)
{
@@ -244,6 +246,7 @@ msn_soap_read_cb(gpointer data, gint source, GaimInputCondition cond)
{
const char *error;
+ gaim_debug_error("MaYuan", "soap 401\n");
if ((error = strstr(soapconn->read_buf, "WWW-Authenticate")) != NULL)
{
if ((error = strstr(error, "cbtxt=")) != NULL)
@@ -284,12 +287,11 @@ msn_soap_read_cb(gpointer data, gint source, GaimInputCondition cond)
/*setup the conn body */
soapconn->body = body_start;
soapconn->body_len = atoi(body_len);
- // gaim_debug_misc("MaYuan","content length :%d",soapconn->body_len);
+ gaim_debug_misc("MaYuan","SOAP Read length :%d,body len:%d\n",soapconn->read_len,soapconn->body_len);
- if(soapconn->read_len < body_start - soapconn->read_buf + atoi(body_len)){
+ if(soapconn->read_len < body_start - soapconn->read_buf + soapconn->body_len){
return;
}
-
g_free(body_len);
#if 1
@@ -313,6 +315,7 @@ msn_soap_read_cb(gpointer data, gint source, GaimInputCondition cond)
// soapconn->gsc = NULL;
#endif
}
+ return;
}
void
@@ -342,6 +345,13 @@ msn_soap_write_cb(gpointer data, gint source, GaimInputCondition cond)
MsnSoapConn *soapconn = data;
int len, total_len;
+ g_return_if_fail(soapconn != NULL);
+ if(soapconn->write_buf == NULL){
+ gaim_debug_error("MaYuan","soap buffer is NULL\n");
+ gaim_input_remove(soapconn->output_handler);
+ soapconn->output_handler = -1;
+ return;
+ }
total_len = strlen(soapconn->write_buf);
/*
diff --git a/src/protocols/msn/soap.h b/src/protocols/msn/soap.h
index a2d79a4e6b..307adff4da 100644
--- a/src/protocols/msn/soap.h
+++ b/src/protocols/msn/soap.h
@@ -26,6 +26,8 @@
#ifndef _MSN_SOAP_H_
#define _MSN_SOAP_H_
+#define MSN_SOAP_READ_BUFF_SIZE 8192
+
/*MSN Https connection structure*/
typedef struct _MsnSoapConn MsnSoapConn;
diff --git a/src/protocols/msn/state.c b/src/protocols/msn/state.c
index 116b5da5ef..634b7fdfe3 100644
--- a/src/protocols/msn/state.c
+++ b/src/protocols/msn/state.c
@@ -38,6 +38,17 @@ static const char *away_text[] =
N_("Available")
};
+/* Local Function Prototype*/
+char * msn_build_psm(char * psmstr,char *mediastr,char * guidstr);
+
+/*
+ * WLM media PSM info build prcedure
+ *
+ * Result can like:
+ * <CurrentMedia>\0Music\01\0{0} - {1}\0 Song Title\0Song Artist\0Song Album\0\0</CurrentMedia>\
+ * <CurrentMedia>\0Games\01\0Playing {0}\0Game Name\0</CurrentMedia>\
+ * <CurrentMedia>\0Office\01\0Office Message\0Office App Name\0</CurrentMedia>"
+ */
char *
msn_build_psm(char * psmstr,char *mediastr,char * guidstr)
{
@@ -53,10 +64,6 @@ msn_build_psm(char * psmstr,char *mediastr,char * guidstr)
}
xmlnode_insert_child(dataNode,psmNode);
-//"<CurrentMedia>\0Music\01\0{0} - {1}\0 Song Title\0Song Artist\0Song Album\0\0</CurrentMedia>\
-<CurrentMedia>\0Games\01\0Playing {0}\0Game Name\0</CurrentMedia>\
-<CurrentMedia>\0Office\01\0Office Message\0Office App Name\0</CurrentMedia>"
-
mediaNode = xmlnode_new("CurrentMedia");
if(mediastr != NULL){
xmlnode_insert_data(psmNode,mediastr,strlen(mediastr));
diff --git a/src/protocols/msn/userlist.c b/src/protocols/msn/userlist.c
index 11f736c21e..aadf8baaaf 100644
--- a/src/protocols/msn/userlist.c
+++ b/src/protocols/msn/userlist.c
@@ -591,6 +591,10 @@ msn_userlist_rem_buddy(MsnUserList *userlist,
const char *list;
user = msn_userlist_find_user(userlist, who);
+
+ /*delete the contact from address book via soap action*/
+ msn_delete_contact(userlist->session->contact,user->uid);
+
group_id = NULL;
if (group_name != NULL){
@@ -614,7 +618,7 @@ msn_userlist_rem_buddy(MsnUserList *userlist,
/* Then request the rem to the server. */
list = lists[list_id];
- msn_notification_rem_buddy(userlist->session->notification, list, who, group_id);
+// msn_notification_rem_buddy(userlist->session->notification, list, who, group_id);
}
/*add buddy*/
@@ -628,6 +632,7 @@ msn_userlist_add_buddy(MsnUserList *userlist,
const char *list;
const char *store_name;
+ gaim_debug_info("MaYuan", "userlist add buddy,name:{%s},group:{%s}\n",who ,group_name);
group_id = NULL;
if (!gaim_email_is_valid(who)){
@@ -668,8 +673,11 @@ msn_userlist_add_buddy(MsnUserList *userlist,
/* Then request the add to the server. */
list = lists[list_id];
- msn_notification_add_buddy(userlist->session->notification, list, who,
+ gaim_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id);
+ msn_add_contact(userlist->session->contact,who,group_id);
+/* msn_notification_add_buddy(userlist->session->notification, list, who,
store_name, group_id);
+ */
}
void