changeset 19755:90f89601d6d3

[gaim-migrate @ 16758] change to support Showing Yahoo Message committed by MaYuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Mon, 14 Aug 2006 16:07:20 +0000
parents da3f8f7ec3ce
children 4a832e480178
files src/protocols/msn/notification.c src/protocols/msn/oim.c src/protocols/msn/session.c src/protocols/msn/session.h
diffstat 4 files changed, 83 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/notification.c	Sun Aug 13 16:01:52 2006 +0000
+++ b/src/protocols/msn/notification.c	Mon Aug 14 16:07:20 2006 +0000
@@ -426,6 +426,8 @@
 {
 	MsnMessage *msg;
 	GaimConnection *gc;
+	const char *passport;
+	const char *content_type;
 
 	gaim_debug_info("MaYuan","Process UBM payload:%s\n",payload);
 	msg = msn_message_new_from_cmd(cmdproc->session, cmd);
@@ -435,35 +437,62 @@
 	msn_message_show_readable(msg, "Notification", TRUE);
 #endif
 
-	gaim_debug_info("MaYuan","type:%d\n",msg->type);
-	if(msg->type == MSN_MSG_TEXT){
+	gc = cmdproc->session->account->gc;
+	passport = msg->remote_user;
+
+	content_type = msn_message_get_content_type(msg);
+	gaim_debug_info("MaYuan","type:%d\n",content_type);
+	if(!strcmp(content_type,"text/plain")){
 		const char *value;
 		const char *body;
 		char *body_str;
 		char *body_enc;
 		char *body_final;
 		size_t body_len;
-		const char *passport;
 
 		body = msn_message_get_bin_data(msg, &body_len);
 		body_str = g_strndup(body, body_len);
 		body_enc = g_markup_escape_text(body_str, -1);
 		g_free(body_str);
 
-		passport = msg->remote_user;
-		gc = cmdproc->session->account->gc;
-			if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL)	{
-					char *pre, *post;
+		if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL)	{
+			char *pre, *post;
 
-				msn_parse_format(value, &pre, &post);
-				body_final = g_strdup_printf("%s%s%s", pre ? pre : "",
-								body_enc ? body_enc : "", post ? post : "");
-				g_free(pre);
-				g_free(post);
-				g_free(body_enc);
+			msn_parse_format(value, &pre, &post);
+			body_final = g_strdup_printf("%s%s%s", pre ? pre : "",
+							body_enc ? body_enc : "", post ? post : "");
+			g_free(pre);
+			g_free(post);
+			g_free(body_enc);
 		}
 		serv_got_im(gc, passport, body_final, 0, time(NULL));
 	}
+	if(!strcmp(content_type,"text/x-msmsgscontrol")){
+		if(msn_message_get_attr(msg, "TypingUser") != NULL){
+			serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT,
+						GAIM_TYPING);
+		}
+	}
+	if(!strcmp(content_type,"text/x-msnmsgr-datacast")){
+		char *username, *str;
+		GaimAccount *account;
+		GaimBuddy *buddy;
+		const char *user;
+
+		account = cmdproc->session->account;
+		user = msg->remote_user;
+
+		if ((buddy = gaim_find_buddy(account, user)) != NULL){
+			username = g_markup_escape_text(gaim_buddy_get_alias(buddy), -1);
+		}else{
+			username = g_markup_escape_text(user, -1);
+		}
+
+		str = g_strdup_printf(_("%s just sent you a Nudge!"), username);
+		g_free(username);
+		msn_session_report_user(cmdproc->session,user,str,GAIM_MESSAGE_SYSTEM);
+		g_free(str);
+	}
 	msn_message_destroy(msg);
 }
 
@@ -650,43 +679,6 @@
 }
 
 static void
-add_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
-{
-	MsnSession *session;
-	MsnUser *user;
-	const char *list;
-	const char *passport;
-	const char *friendly;
-	MsnListId list_id;
-	int group_id;
-
-	list     = cmd->params[1];
-	passport = cmd->params[3];
-	friendly = gaim_url_decode(cmd->params[4]);
-
-	session = cmdproc->session;
-
-	user = msn_userlist_find_user(session->userlist, passport);
-
-	if (user == NULL){
-		user = msn_user_new(session->userlist, passport, friendly);
-		msn_userlist_add_user(session->userlist, user);
-	}else{
-		msn_user_set_friendly_name(user, friendly);
-	}
-
-	list_id = msn_get_list_id(list);
-
-	if (cmd->param_count >= 6)
-		group_id = atoi(cmd->params[5]);
-	else
-		group_id = -1;
-
-	msn_got_add_user(session, user, list_id, group_id);
-	msn_user_update(user);
-}
-
-static void
 add_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error)
 {
 	MsnSession *session;
@@ -1707,7 +1699,6 @@
 	/* Synchronous */
 	msn_table_add_cmd(cbs_table, "CHG", "CHG", NULL);
 	msn_table_add_cmd(cbs_table, "CHG", "ILN", iln_cmd);
-	msn_table_add_cmd(cbs_table, "ADD", "ADD", add_cmd);
 	msn_table_add_cmd(cbs_table, "ADL", "ILN", iln_cmd);
 	msn_table_add_cmd(cbs_table, "REM", "REM", rem_cmd);
 	msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd);
--- a/src/protocols/msn/oim.c	Sun Aug 13 16:01:52 2006 +0000
+++ b/src/protocols/msn/oim.c	Mon Aug 14 16:07:20 2006 +0000
@@ -202,35 +202,6 @@
 	msn_soap_read_cb(data,source,cond);
 }
 
-/*get the conversation*/
-static GaimConversation *
-msn_oim_get_conv(MsnOim *oim,const char *passport)
-{
-	GaimAccount *account;
-	GaimConversation * conv;
-
-	g_return_val_if_fail(oim != NULL, NULL);
-	account = oim->session->account;
-
-	conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM,
-									passport, account);
-	if(conv == NULL){
-		conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, passport);
-	}
-	return conv;
-}
-
-/*put the OIM Message to User Conversation*/
-void
-msn_oim_report_user(MsnOim *oim,const char *passport,char *msg)
-{
-	GaimConversation * conv;
-
-	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*/
 void
 msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg)
@@ -250,7 +221,7 @@
 		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_oim_report_user(oim,passport,"hello");
+//		msn_session_report_user(oim->session,passport,"hello");
 		oim->oim_list = g_list_append(oim->oim_list,msgid);
 	}
 	if(msn_soap_connected(oim->retrieveconn) == -1){
--- a/src/protocols/msn/session.c	Sun Aug 13 16:01:52 2006 +0000
+++ b/src/protocols/msn/session.c	Mon Aug 14 16:07:20 2006 +0000
@@ -163,6 +163,38 @@
 	return NULL;
 }
 
+/*get the conversation*/
+GaimConversation *
+msn_session_get_conv(MsnSession *session,const char *passport)
+{
+	GaimAccount *account;
+	GaimConversation * conv;
+
+	g_return_val_if_fail(session != NULL, NULL);
+	account = session->account;
+
+	conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM,
+									passport, account);
+	if(conv == NULL){
+		conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, passport);
+	}
+	return conv;
+}
+
+/* put Message to User Conversation
+ *
+ * 	passport - the one want to talk to you
+ */
+void
+msn_session_report_user(MsnSession *session,const char *passport,char *msg,GaimMessageFlags flags)
+{
+	GaimConversation * conv;
+
+	if ((conv = msn_session_get_conv(session,passport)) != NULL){
+		gaim_conversation_write(conv, NULL, msg, flags, time(NULL));
+	}
+}
+
 MsnSwitchBoard *
 msn_session_find_swboard_with_conv(MsnSession *session, GaimConversation *conv)
 {
--- a/src/protocols/msn/session.h	Sun Aug 13 16:01:52 2006 +0000
+++ b/src/protocols/msn/session.h	Mon Aug 14 16:07:20 2006 +0000
@@ -234,4 +234,12 @@
  */
 void msn_session_finish_login(MsnSession *session);
 
+/*get conversation via session,
+ * If has one, return that,else create a new one;
+ */
+GaimConversation *msn_session_get_conv(MsnSession *session,const char *passport);
+
+/*post message to User*/
+void msn_session_report_user(MsnSession *session,const char *passport,
+							char *msg,GaimMessageFlags flags);
 #endif /* _MSN_SESSION_H_ */