changeset 19795:38e4a4b404e5

[gaim-migrate @ 16685] add delte group SOAP operation code ok committed by MaYuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Thu, 10 Aug 2006 15:43:55 +0000
parents b22d13f55232
children 3a15b4e5c336
files src/protocols/msn/contact.c src/protocols/msn/contact.h src/protocols/msn/msn.c src/protocols/msn/notification.c src/protocols/msn/userlist.c
diffstat 5 files changed, 52 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/contact.c	Thu Aug 10 04:38:13 2006 +0000
+++ b/src/protocols/msn/contact.c	Thu Aug 10 15:43:55 2006 +0000
@@ -495,27 +495,59 @@
 	msn_soap_post(contact->soapconn,MSN_GLEAMS_TEMPLATE,msn_address_written_cb);
 }
 
+/***************************************************************
+ * Group Operation
+ ***************************************************************/
+static void
+msn_group_read_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+	gaim_debug_info("MaYuan","Group read \n");
+}
+
+static void
+msn_group_written_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+	MsnSoapConn * soapconn = data;	
+
+	gaim_debug_info("MaYuan","finish Group written\n");
+	soapconn->read_cb = msn_group_read_cb;
+	msn_soap_read_cb(data,source,cond);
+}
+
 /*add group*/
-void msn_add_group(MsnContact *contact,const char* group_name)
+void msn_add_group(MsnSession *session,const char* group_name)
 {
+	char *body = NULL;
+	MsnContact *contact ;
+
+	g_return_if_fail(session != NULL);
+	contact = session->contact;
 	gaim_debug_info("MaYuan","msn add group...\n");
 
+	body = g_strdup_printf(MSN_GROUP_ADD_TEMPLATE,group_name);
 	/*build SOAP and POST it*/
 	contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL);
 	contact->soapconn->soap_action = g_strdup(MSN_GROUP_ADD_SOAP_ACTION);
-	msn_soap_post(contact->soapconn,MSN_GROUP_ADD_TEMPLATE,msn_address_written_cb);
+	msn_soap_post(contact->soapconn,body,msn_group_written_cb);
+	g_free(body);
 }
 
 /*delete a group*/
-void msn_del_group(MsnContact *contact,const char *guid)
+void msn_del_group(MsnSession *session,const char *guid)
 {
+	MsnContact *contact;
+	char *body = NULL;
+
+	g_return_if_fail(session != NULL);
+	contact = session->contact;
 	gaim_debug_info("MaYuan","msn del group...\n");
 
+	body = g_strdup_printf(MSN_GROUP_DEL_TEMPLATE,guid);
 	/*build SOAP and POST it*/
 	contact->soapconn->login_path = g_strdup(MSN_ADDRESS_BOOK_POST_URL);
 	contact->soapconn->soap_action = g_strdup(MSN_GROUP_DEL_SOAP_ACTION);
-	msn_soap_post(contact->soapconn,MSN_GROUP_DEL_TEMPLATE,msn_address_written_cb);
-
+	msn_soap_post(contact->soapconn,body,msn_group_written_cb);
+	g_free(body);
 }
 
 void
--- a/src/protocols/msn/contact.h	Thu Aug 10 04:38:13 2006 +0000
+++ b/src/protocols/msn/contact.h	Thu Aug 10 15:43:55 2006 +0000
@@ -158,7 +158,9 @@
 	MsnSoapConn *soapconn;
 };
 
-/*function prototype*/
+/************************************************
+ * function prototype
+ ************************************************/
 MsnContact * msn_contact_new(MsnSession *session);
 void msn_contact_destroy(MsnContact *contact);
 
@@ -166,5 +168,8 @@
 void msn_get_contact_list(MsnContact * contact);
 void msn_get_address_book(MsnContact *contact);
 
+/*group operation*/
+void msn_add_group(MsnSession *session,const char* group_name);
+void msn_del_group(MsnSession *session,const char *guid);
 #endif/* _MSN_CMDPROC_H_*/
 
--- a/src/protocols/msn/msn.c	Thu Aug 10 04:38:13 2006 +0000
+++ b/src/protocols/msn/msn.c	Thu Aug 10 15:43:55 2006 +0000
@@ -1268,6 +1268,7 @@
 	cmdproc = session->notification->cmdproc;
 	enc_new_group_name = gaim_url_encode(group->name);
 
+	gaim_debug_info("MaYuan","rename group:old{%s},new{%s}",old_name,enc_new_group_name);
 	old_gid = msn_userlist_find_group_id(session->userlist, old_name);
 
 	if (old_gid != NULL){
--- a/src/protocols/msn/notification.c	Thu Aug 10 04:38:13 2006 +0000
+++ b/src/protocols/msn/notification.c	Thu Aug 10 15:43:55 2006 +0000
@@ -301,7 +301,7 @@
 	g_snprintf(proto_str, sizeof(proto_str), "MSNP%d", session->protocol_ver);
 
 	for (i = 1; i < cmd->param_count -1; i++){
-		gaim_debug_info("MaYuan","%s\,proto_str:%s\n",cmd->params[i],proto_str);
+		gaim_debug_info("MaYuan","%s,proto_str:%s\n",cmd->params[i],proto_str);
 		if (strcmp(cmd->params[i], proto_str) >= 0)	{
 			protocol_supported = TRUE;
 			break;
@@ -531,11 +531,14 @@
 	MsnTransaction *trans;
 	char * payload;
 
+	gaim_debug_info("MaYuan","Process ADL\n");
+#if 0
 	trans = msn_transaction_new(cmdproc, "RML","");
 
 	msn_transaction_set_payload(trans, payload, strlen(payload));
 
 	msn_cmdproc_send_trans(cmdproc, trans);
+#endif
 }
 
 static void
@@ -1414,6 +1417,8 @@
 	}
 
 	g_strfreev(elems);
+/* test code for add group*/
+//	msn_add_group(session,"hello");
 }
 
 static void
@@ -1591,7 +1596,7 @@
 	msn_table_add_cmd(cbs_table, NULL, "NOT", not_cmd);
 
 	msn_table_add_cmd(cbs_table, NULL, "CHL", chl_cmd);
-	msn_table_add_cmd(cbs_table, NULL, "REM", rem_cmd);
+	msn_table_add_cmd(cbs_table, NULL, "RML", rml_cmd);
 	msn_table_add_cmd(cbs_table, NULL, "ADL", adl_cmd);
 
 	msn_table_add_cmd(cbs_table, NULL, "QRY", NULL);
--- a/src/protocols/msn/userlist.c	Thu Aug 10 04:38:13 2006 +0000
+++ b/src/protocols/msn/userlist.c	Thu Aug 10 15:43:55 2006 +0000
@@ -187,7 +187,6 @@
 					  const char *old_group_name, const char *new_group_name)
 {
 	MsnCmdProc *cmdproc;
-//	MsnTransaction *trans;
 	MsnMoveBuddy *data;
 
 	cmdproc = userlist->session->notification->cmdproc;
@@ -199,6 +198,7 @@
 		data->old_group_name = g_strdup(old_group_name);
 
 	/*TODO:add new group via SOAP action*/
+
 }
 
 /**************************************************************************