changeset 19744:4f21c73a0c48

[gaim-migrate @ 16613] add oim retrieve,can get oim message write the framework of oim send Committed by MaYuan <mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Wed, 02 Aug 2006 05:44:42 +0000
parents 7e36832172a9
children bddd32f36bde
files src/protocols/msn/contact.c src/protocols/msn/contact.h src/protocols/msn/oim.c src/protocols/msn/oim.h src/protocols/msn/soap.c
diffstat 5 files changed, 106 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/contact.c	Sun Jul 30 15:55:30 2006 +0000
+++ b/src/protocols/msn/contact.c	Wed Aug 02 05:44:42 2006 +0000
@@ -419,35 +419,39 @@
 void
 msn_add_contact(MsnContact *contact)
 {
-
+	gaim_debug_info("MaYuan","msn add a contact...\n");
 }
 
 /*delete a Contact*/
 void
 msn_delete_contact(MsnContact *contact)
 {	
-
+	gaim_debug_info("MaYuan","msn delete a contact...\n");
 }
 
 /*block a Contact*/
 void
 msn_block_contact(MsnContact *contact)
 {	
-
+	gaim_debug_info("MaYuan","msn block a contact...\n");
 }
 
 /*unblock a contact*/
 void
 msn_unblock_contact(MsnContact *contact)
 {	
-
+	gaim_debug_info("MaYuan","msn unblock a contact...\n");
 }
 
 /*get the gleams info*/
 void
 msn_get_gleams(MsnContact *contact)
 {
-
+	gaim_debug_info("MaYuan","msn get gleams info...\n");
+	/*build SOAP and POST it*/
+	contact->soapconn->login_path = g_strdup(MSN_GET_ADDRESS_POST_URL);
+	contact->soapconn->soap_action = g_strdup(MSN_GET_ADDRESS_SOAP_ACTION);
+	msn_soap_post(contact->soapconn,MSN_GLEAMS_TEMPLATE,msn_address_written_cb);
 }
 
 void
--- a/src/protocols/msn/contact.h	Sun Jul 30 15:55:30 2006 +0000
+++ b/src/protocols/msn/contact.h	Wed Aug 02 05:44:42 2006 +0000
@@ -81,7 +81,7 @@
 "</soap:Envelope>"
 
 /*Gleams SOAP request template*/
-#define MSN_GLEAMS_TEMPLATE = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\
+#define MSN_GLEAMS_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\">"\
--- a/src/protocols/msn/oim.c	Sun Jul 30 15:55:30 2006 +0000
+++ b/src/protocols/msn/oim.c	Wed Aug 02 05:44:42 2006 +0000
@@ -27,6 +27,9 @@
 #include "soap.h"
 #include "oim.h"
 
+/*Local Function Prototype*/
+static void msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid);
+
 /*new a OIM object*/
 MsnOim *
 msn_oim_new(MsnSession *session)
@@ -36,6 +39,7 @@
 	oim = g_new0(MsnOim, 1);
 	oim->session = session;
 	oim->retrieveconn = msn_soap_new(session,oim,1);
+	oim->oim_list	= NULL;
 	oim->sendconn = msn_soap_new(session,oim,1);
 
 	return oim;
@@ -82,12 +86,54 @@
 	g_return_if_fail(session != NULL);
 }
 
+static void
+msn_oim_send_read_cb(gpointer data, GaimSslConnection *gsc,
+				 GaimInputCondition cond)
+{
+	MsnSoapConn * soapconn = data;	
+	MsnOim * msnoim;
+
+	gaim_debug_info("MaYuan","read buffer:{%s}\n",soapconn->body);
+}
+
+static void
+msn_oim_send_written_cb(gpointer data, gint source, GaimInputCondition cond)
+{
+	MsnSoapConn * soapconn = data;	
+
+	soapconn->read_cb = msn_oim_send_read_cb;
+	msn_soap_read_cb(data,source,cond);
+}
+
+/*pose single message to oim server*/
+void msn_oim_send_single_msg(MsnOim *oim,char * msg)
+{
+	const char *oimsoapbody,*t,*p;
+
+	gaim_debug_info("MaYuan","send single OIM Message\n");
+	oim->sendconn->login_path = g_strdup(MSN_OIM_SEND_URL);
+	oim->sendconn->soap_action = g_strdup(MSN_OIM_SEND_SOAP_ACTION);
+	t = oim->session->passport_info.t;
+	p = oim->session->passport_info.p;
+#if 0
+	oimsoapbody = g_strdup_printf(MSN_OIM_SEND_TEMPLATE,
+					membername,
+					friendname,
+					tomember,
+					mspauth,
+					prod_id,
+					lock_key,
+					msg_num,
+					msg
+					);
+#endif
+	msn_soap_post(oim->retrieveconn, oimsoapbody, msn_oim_send_written_cb);
+
+}
+
 void msn_oim_send_msg(MsnOim *oim,char *msg)
 {
 	if(msn_soap_connected(oim->sendconn) == -1){
-		msn_soap_init(oim->sendconn,MSN_OIM_SEND_HOST,1,
-					msn_oim_send_connect_cb,
-					msn_oim_send_error_cb);
 	}
 	
 }
@@ -122,6 +168,10 @@
 
 	session = oim->session;
 	g_return_if_fail(session != NULL);
+
+	gaim_debug_info("MaYuan","oim get SOAP Server connected!\n");
+	/*call to get the message*/
+	msn_oim_get_msg(oim);
 }
 
 static void
@@ -145,7 +195,7 @@
 
 /*get the conversation*/
 static GaimConversation *
-msn_oim_get_conv(MsnOim *oim,char *passport)
+msn_oim_get_conv(MsnOim *oim,const char *passport)
 {
 	GaimAccount *account;
 	GaimConversation * conv;
@@ -193,21 +243,21 @@
 		nickname = xmlnode_get_data(nNode);
 		gaim_debug_info("MaYuan","E:{%s},I:{%s},rTime:{%s}\n",passport,msgid,rTime);
 //		msn_oim_report_user(oim,passport,"hello");
-		msn_oim_get_msg(oim,msgid);
+		oim->oim_list = g_list_append(oim->oim_list,msgid);
 	}
+	if(msn_soap_connected(oim->retrieveconn) == -1){
+		gaim_debug_info("MaYuan","retreive OIM server not connected! We need to connect it first\n");
+		msn_oim_connect(oim);
+		return;
+	}
+	msn_oim_get_msg(oim);
 }
 
-/*MSN OIM get SOAP request*/
-void msn_oim_get_msg(MsnOim *oim,char *msgid)
+static void msn_oim_post_single_get_msg(MsnOim *oim,const char *msgid)
 {
-	const char *oimid ,*oimsoapbody,*t,*p;
+	const char *oimsoapbody,*t,*p;
 
-	if(msn_soap_connected(oim->retrieveconn) == -1){
-		gaim_debug_info("MaYuan","retreive OIM server not connected!\n");
-		return;
-	}
-
-	gaim_debug_info("MaYuan","Get OIM with SOAP \n");
+	gaim_debug_info("MaYuan","Get single OIM Message\n");
 	oim->retrieveconn->login_path = g_strdup(MSN_OIM_RETRIEVE__URL);
 	oim->retrieveconn->soap_action = g_strdup(MSN_OIM_GET_SOAP_ACTION);
 	t = oim->session->passport_info.t;
@@ -219,6 +269,20 @@
 					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);
+	}
 }
 
 /*msn oim server connect*/
@@ -227,12 +291,17 @@
 {
 	gaim_debug_info("MaYuan","msn_oim_connect...\n");
 
-	msn_soap_init(oim->retrieveconn,MSN_OIM_RETRIEVE_HOST,1,
+	if(msn_soap_connected(oim->retrieveconn) == -1){
+		msn_soap_init(oim->retrieveconn,MSN_OIM_RETRIEVE_HOST,1,
 					msn_oim_get_connect_cb,
 					msn_oim_get_error_cb);
-	msn_soap_init(oim->sendconn,MSN_OIM_SEND_HOST,1,
+	}
+
+	if(msn_soap_connected(oim->sendconn) == -1){
+		msn_soap_init(oim->sendconn,MSN_OIM_SEND_HOST,1,
 					msn_oim_send_connect_cb,
 					msn_oim_send_error_cb);
+	}
 }
 
 /*endof oim.c*/
--- a/src/protocols/msn/oim.h	Sun Jul 30 15:55:30 2006 +0000
+++ b/src/protocols/msn/oim.h	Wed Aug 02 05:44:42 2006 +0000
@@ -90,18 +90,26 @@
 	MsnSession *session;
 
 	MsnSoapConn *retrieveconn;
+	GList * oim_list;
 
 	MsnSoapConn *sendconn;
 	gint	LockKeyChallenge;
 };
 
-/*function prototype*/
+/****************************************************
+ * function prototype
+ * **************************************************/
 MsnOim * msn_oim_new(MsnSession *session);
 void msn_oim_destroy(MsnOim *oim);
 void msn_oim_connect(MsnOim *oim);
 
 void msn_parse_oim_msg(MsnOim *oim,char *xmlmsg);
 
-void msn_oim_get_msg(MsnOim *oim,char *msgid);
+/*get the OIM message*/
+void msn_oim_get_msg(MsnOim *oim);
+
+/*report the oim message to the conversation*/
+void msn_oim_report_user(MsnOim *oim,const char *passport,char *msg);
+
 #endif/* _MSN_OIM_H_*/
 /*endof oim.h*/
--- a/src/protocols/msn/soap.c	Sun Jul 30 15:55:30 2006 +0000
+++ b/src/protocols/msn/soap.c	Wed Aug 02 05:44:42 2006 +0000
@@ -399,7 +399,7 @@
 	char * soap_body = NULL;
 	char * request_str = NULL;
 
-	gaim_debug_info("MaYuan","msn_get_address_book()...\n");
+	gaim_debug_info("MaYuan","msn_soap_post()...\n");
 	soap_body = g_strdup_printf(body);
 	soap_head = g_strdup_printf(
 					"POST %s HTTP/1.1\r\n"