changeset 27603:a12574d982a1

merge of '6bf1ed8cefd6bb5b980baf7501bcf6936634bd8d' and 'aff31bc617044d2074a9f5dc1c1b838061c496fd'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 13 Jul 2009 05:40:12 +0000
parents 07cb59d47685 (current diff) a350c546f5a5 (diff)
children 8cfc45425ac7
files ChangeLog libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/google.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/presence.c libpurple/protocols/msn/msn.c libpurple/protocols/yahoo/libymsg.c pidgin/gtkconv.c
diffstat 13 files changed, 144 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jul 13 04:11:19 2009 +0000
+++ b/ChangeLog	Mon Jul 13 05:40:12 2009 +0000
@@ -12,8 +12,6 @@
 	* Fixed NTLM authentication on big-endian systems.
 	* Various memory cleanups when unloading libpurple. (Nick Hebner)
 	* Report idle time 'From last message sent' should work properly.
-	* Show the invite message for buddies that requested authorization
-	  from you on MSN.
 	* DNS servers are re-read when DNS queries fail in case the system has
 	  moved to a new network and the old servers are not accessible.
 	* DNS SRV records with equal priority are sorted with respect to their
@@ -33,6 +31,10 @@
 	* Fix a leak when the UI provides its own DNS resolving UI op.
 	  (Aman Gupta)
 	* Don't fork a DNS resolver process to resolve IP addresses.  (Aman Gupta)
+	* Show the invite message for buddies that requested authorization
+	  from you on MSN.
+	* Support sending an invite message to buddies when requesting authorization
+	  from them on MSN.
 
 	AIM and ICQ:
 	* Preliminary support for a new authentication scheme called
--- a/libpurple/protocols/jabber/buddy.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Mon Jul 13 05:40:12 2009 +0000
@@ -168,7 +168,7 @@
 	jbr->priority = priority;
 	jbr->state = state;
 	g_free(jbr->status);
-	jbr->status = status != NULL ? g_markup_escape_text(status, -1) : NULL;
+	jbr->status = g_strdup(status);
 
 	return jbr;
 }
@@ -702,7 +702,7 @@
 		const char *status_name = jabber_buddy_state_get_name(jbr->state);
 
 		if (jbr->status) {
-			purdy = purple_strdup_withhtml(jbr->status);
+			purdy = g_markup_escape_text(jbr->status, -1);
 
 			if (purple_strequal(status_name, purdy))
 				status_name = NULL;
--- a/libpurple/protocols/jabber/google.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/jabber/google.c	Mon Jul 13 05:40:12 2009 +0000
@@ -1291,9 +1291,10 @@
 {
 	if (!js->googletalk)
 		return;
-	if (jbr->status && !strncmp(jbr->status, "♫ ", strlen("♫ "))) {
+	if (jbr->status && purple_str_has_prefix(jbr->status, "♫ ")) {
 		purple_prpl_got_user_status(js->gc->account, user, "tune",
 					    PURPLE_TUNE_TITLE, jbr->status + strlen("♫ "), NULL);
+		g_free(jbr->status);
 		jbr->status = NULL;
 	} else {
 		purple_prpl_got_user_status_deactive(js->gc->account, user, "tune");
--- a/libpurple/protocols/jabber/jabber.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Mon Jul 13 05:40:12 2009 +0000
@@ -1976,21 +1976,16 @@
 	} else {
 		PurplePresence *presence = purple_buddy_get_presence(b);
 		PurpleStatus *status = purple_presence_get_active_status(presence);
-		char *stripped;
-
-		if(!(stripped = purple_markup_strip_html(purple_status_get_attr_string(status, "message")))) {
-			if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
-				PurpleStatus *status = purple_presence_get_status(presence, "tune");
-				const char *title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
-				const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
-				const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM);
-				stripped = purple_util_format_song_info(title, artist, album, NULL);
-			}
-		}
-
-		if(stripped) {
-			ret = g_markup_escape_text(stripped, -1);
-			g_free(stripped);
+		const char *message;
+
+		if((message = purple_status_get_attr_string(status, "message"))) {
+			ret = g_markup_escape_text(message, -1);
+		} else if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
+			PurpleStatus *status = purple_presence_get_status(presence, "tune");
+			const char *title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
+			const char *artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);
+			const char *album = purple_status_get_attr_string(status, PURPLE_TUNE_ALBUM);
+			ret = purple_util_format_song_info(title, artist, album, NULL);
 		}
 	}
 
@@ -2007,12 +2002,7 @@
 	const char *state;
 
 	if(jbr->status) {
-		char *tmp;
-		text = purple_strreplace(jbr->status, "\n", "<br />\n");
-		tmp = purple_markup_strip_html(text);
-		g_free(text);
-		text = g_markup_escape_text(tmp, -1);
-		g_free(tmp);
+		text = g_markup_escape_text(jbr->status, -1);
 	}
 
 	if(jbr->name)
--- a/libpurple/protocols/jabber/presence.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/jabber/presence.c	Mon Jul 13 05:40:12 2009 +0000
@@ -1064,11 +1064,8 @@
 			formatted_msg = purple_status_get_attr_string(status, "message");
 
 			/* if the message is blank, then there really isn't a message */
-			if(formatted_msg && !*formatted_msg)
-				formatted_msg = NULL;
-
-			if(formatted_msg)
-				*msg = purple_markup_strip_html(formatted_msg);
+			if(formatted_msg && *formatted_msg)
+				*msg = g_strdup(formatted_msg);
 		}
 
 		if(priority)
--- a/libpurple/protocols/msn/contact.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/msn/contact.c	Mon Jul 13 05:40:12 2009 +0000
@@ -1159,7 +1159,7 @@
 {
 	MsnUserList *userlist;
 	MsnUser *user;
-	gchar *body = NULL, *contact_xml;
+	gchar *body = NULL, *contact_xml, *invite;
 
 	g_return_if_fail(passport != NULL);
 	g_return_if_fail(groupId != NULL);
@@ -1207,7 +1207,23 @@
 		contact_xml = g_strdup_printf(MSN_CONTACT_XML, passport);
 	}
 
-	body = g_strdup_printf(MSN_ADD_CONTACT_GROUP_TEMPLATE, groupId, contact_xml);
+	if (user->invite_message) {
+		char *tmp;
+		body = g_markup_escape_text(user->invite_message, -1);
+		tmp = g_markup_escape_text(purple_connection_get_display_name(session->account->gc), -1);
+		invite = g_strdup_printf(MSN_CONTACT_INVITE_MESSAGE_XML, body, tmp);
+		g_free(body);
+		g_free(tmp);
+
+		/* We can free this now */
+		g_free(user->invite_message);
+		user->invite_message = NULL;
+
+	} else {
+		invite = g_strdup("");
+	}
+
+	body = g_strdup_printf(MSN_ADD_CONTACT_GROUP_TEMPLATE, groupId, contact_xml, invite);
 
 	state->body = xmlnode_from_str(body, -1);
 	state->post_action = MSN_ADD_CONTACT_GROUP_SOAP_ACTION;
@@ -1215,6 +1231,7 @@
 	state->cb = msn_add_contact_to_group_read_cb;
 	msn_contact_request(state);
 
+	g_free(invite);
 	g_free(contact_xml);
 	g_free(body);
 }
--- a/libpurple/protocols/msn/contact.h	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/msn/contact.h	Mon Jul 13 05:40:12 2009 +0000
@@ -232,6 +232,17 @@
 		"</contactInfo>"\
 	"</Contact>"
 
+#define MSN_CONTACT_INVITE_MESSAGE_XML \
+	"<MessengerMemberInfo>"\
+		"<PendingAnnotations>"\
+			"<Annotation>"\
+				"<Name>MSN.IM.InviteMessage</Name>"\
+				"<Value>%s</Value>"\
+			"</Annotation>"\
+		"</PendingAnnotations>"\
+		"<DisplayName>%s</DisplayName>"\
+	"</MessengerMemberInfo>"
+
 #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\""\
@@ -290,6 +301,7 @@
 				"<fGenerateMissingQuickName>true</fGenerateMissingQuickName>"\
 				"<EnableAllowListManagement>true</EnableAllowListManagement>"\
 			"</groupContactAddOptions>"\
+			"%s"\
 		"</ABGroupContactAdd>"\
 	"</soap:Body>"\
 "</soap:Envelope>"
--- a/libpurple/protocols/msn/msg.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/msn/msg.c	Mon Jul 13 05:40:12 2009 +0000
@@ -767,8 +767,7 @@
 		g_string_append_printf(str, "SUB ID:     %u\r\n", msg->msnslp_header.ack_sub_id);
 		g_string_append_printf(str, "ACK Size:   %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.ack_size);
 
-#ifdef MSN_DEBUG_SLP_VERBOSE
-		if (body != NULL)
+		if (purple_debug_is_verbose() && body != NULL)
 		{
 			if (text_body)
 			{
@@ -792,7 +791,6 @@
 				g_string_append(str, "\r\n");
 			}
 		}
-#endif
 
 		g_string_append_printf(str, "Footer:     %u\r\n", msg->msnslp_footer.value);
 	}
--- a/libpurple/protocols/msn/msn.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/msn/msn.c	Mon Jul 13 05:40:12 2009 +0000
@@ -92,6 +92,13 @@
 	MsnObject *obj;
 } MsnEmoticon;
 
+typedef struct
+{
+	PurpleConnection *pc;
+	PurpleBuddy *buddy;
+	PurpleGroup *group;
+} MsnAddReqData;
+
 static const char *
 msn_normalize(const PurpleAccount *account, const char *str)
 {
@@ -178,8 +185,12 @@
 	cmdproc = session->notification->cmdproc;
 	account = purple_connection_get_account(gc);
 
-	if(entry && strlen(entry))
-		alias = purple_url_encode(entry);
+	if (entry && *entry)
+	{
+		char *tmp = g_strdup(entry);
+		alias = purple_url_encode(g_strstrip(tmp));
+		g_free(tmp);
+	}
 	else
 		alias = "";
 
@@ -195,7 +206,6 @@
 	}
 
 	msn_cmdproc_send(cmdproc, "PRP", "MFN %s", alias);
-
 }
 
 static void
@@ -1421,33 +1431,27 @@
 }
 
 static void
-msn_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
+finish_auth_request(MsnAddReqData *data, char *msg)
 {
+	PurpleConnection *pc;
+	PurpleBuddy *buddy;
+	PurpleGroup *group;
 	PurpleAccount *account;
 	MsnSession *session;
 	MsnUserList *userlist;
-	const char *bname, *who, *gname;
+	const char *who, *gname;
 	MsnUser *user;
 
-	account = purple_connection_get_account(gc);
-	session = gc->proto_data;
+	pc = data->pc;
+	buddy = data->buddy;
+	group = data->group;
+	g_free(data);
+
+	account = purple_connection_get_account(pc);
+	session = pc->proto_data;
 	userlist = session->userlist;
-	bname = purple_buddy_get_name(buddy);
-
-	if (!purple_email_is_valid(bname)) {
-		gchar *buf;
-		buf = g_strdup_printf(_("Unable to add the buddy %s because the username is invalid.  Usernames must be a valid email address."), bname);
-		if (!purple_conv_present_error(bname, account, buf))
-			purple_notify_error(gc, NULL, _("Unable to Add"), buf);
-		g_free(buf);
-
-		/* Remove from local list */
-		purple_blist_remove_buddy(buddy);
-
-		return;
-	}
-
-	who = msn_normalize(account, bname);
+
+	who = msn_normalize(account, purple_buddy_get_name(buddy));
 	gname = group ? purple_group_get_name(group) : NULL;
 	purple_debug_info("msn", "Add user:%s to group:%s\n", who, gname ? gname : "(null)");
 	if (!session->logged_in)
@@ -1464,12 +1468,14 @@
 	if ((user != NULL) && (user->networkid != MSN_NETWORK_UNKNOWN)) {
 		/* We already know this buddy and their network. This function knows
 		   what to do with users already in the list and stuff... */
+		msn_user_set_invite_message(user, msg);
 		msn_userlist_add_buddy(userlist, who, gname);
 	} else {
 		char **tokens;
 		char *fqy;
 		/* We need to check the network for this buddy first */
 		user = msn_user_new(userlist, who, NULL);
+		msn_user_set_invite_message(user, msg);
 		msn_user_set_pending_group(user, gname);
 		msn_user_set_network(user, MSN_NETWORK_UNKNOWN);
 		tokens = g_strsplit(who, "@", 2);
@@ -1484,6 +1490,49 @@
 }
 
 static void
+cancel_auth_request(MsnAddReqData *data, char *msg)
+{
+	/* Remove from local list */
+	purple_blist_remove_buddy(data->buddy);
+	
+	g_free(data);
+}
+
+static void
+msn_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
+{
+	const char *bname;
+	MsnAddReqData *data;
+
+	bname = purple_buddy_get_name(buddy);
+
+	if (!purple_email_is_valid(bname)) {
+		gchar *buf;
+		buf = g_strdup_printf(_("Unable to add the buddy %s because the username is invalid.  Usernames must be a valid email address."), bname);
+		if (!purple_conv_present_error(bname, purple_connection_get_account(gc), buf))
+			purple_notify_error(gc, NULL, _("Unable to Add"), buf);
+		g_free(buf);
+
+		/* Remove from local list */
+		purple_blist_remove_buddy(buddy);
+
+		return;
+	}
+
+	data = g_new0(MsnAddReqData, 1);
+	data->pc = gc;
+	data->buddy = buddy;
+	data->group = group;
+
+	purple_request_input(gc, NULL, _("Authorization Request Message:"),
+	                     NULL, _("Please authorize me!"), TRUE, FALSE, NULL,
+	                     _("_OK"), G_CALLBACK(finish_auth_request),
+	                     _("_Cancel"), G_CALLBACK(cancel_auth_request),
+	                     purple_connection_get_account(gc), bname, NULL,
+	                     data);
+}
+
+static void
 msn_rem_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
 {
 	MsnSession *session;
--- a/libpurple/protocols/msn/msnutils.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/msn/msnutils.c	Mon Jul 13 05:40:12 2009 +0000
@@ -222,7 +222,7 @@
 	const char *c;
 	char *msg;
 	char *fontface = NULL;
-	char fonteffect[4];
+	char fonteffect[5];
 	char fontcolor[7];
 	char direction = '0';
 
--- a/libpurple/protocols/msn/slplink.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/msn/slplink.c	Mon Jul 13 05:40:12 2009 +0000
@@ -65,9 +65,8 @@
 
 	slplink = g_new0(MsnSlpLink, 1);
 
-#ifdef MSN_DEBUG_SLPLINK
-	purple_debug_info("msn", "slplink_new: slplink(%p)\n", slplink);
-#endif
+	if (purple_debug_is_verbose())
+		purple_debug_info("msn", "slplink_new: slplink(%p)\n", slplink);
 
 	slplink->session = session;
 	slplink->slp_seq_id = rand() % 0xFFFFFF00 + 4;
@@ -87,9 +86,8 @@
 {
 	MsnSession *session;
 
-#ifdef MSN_DEBUG_SLPLINK
-	purple_debug_info("msn", "slplink_destroy: slplink(%p)\n", slplink);
-#endif
+	if (purple_debug_is_verbose())
+		purple_debug_info("msn", "slplink_destroy: slplink(%p)\n", slplink);
 
 	g_return_if_fail(slplink != NULL);
 
@@ -269,9 +267,8 @@
 		msg->msnslp_header.length = len;
 	}
 
-#ifdef MSN_DEBUG_SLP
-	msn_message_show_readable(msg, slpmsg->info, slpmsg->text_body);
-#endif
+	if (purple_debug_is_verbose())
+		msn_message_show_readable(msg, slpmsg->info, slpmsg->text_body);
 
 #ifdef MSN_DEBUG_SLP_FILES
 	debug_msg_to_file(msg, TRUE);
@@ -441,10 +438,7 @@
 	slpmsg->ack_id     = msg->msnslp_header.id;
 	slpmsg->ack_sub_id = msg->msnslp_header.ack_id;
 	slpmsg->ack_size   = msg->msnslp_header.total_size;
-
-#ifdef MSN_DEBUG_SLP
 	slpmsg->info = "SLP ACK";
-#endif
 
 	msn_slplink_send_slpmsg(slplink, slpmsg);
 }
@@ -459,9 +453,8 @@
 	slpmsg = msn_slpmsg_new(slpcall->slplink);
 	slpmsg->slpcall = slpcall;
 	slpmsg->flags = 0x1000030;
-#ifdef MSN_DEBUG_SLP
 	slpmsg->info = "SLP FILE";
-#endif
+
 	xfer = (PurpleXfer *)slpcall->xfer;
 	purple_xfer_start(slpcall->xfer, 0, NULL, 0);
 	slpmsg->fp = xfer->dest_fp;
@@ -496,9 +489,8 @@
 	guint64 offset;
 	gsize len;
 
-#ifdef MSN_DEBUG_SLP
-	msn_slpmsg_show(msg);
-#endif
+	if (purple_debug_is_verbose())
+		msn_slpmsg_show(msg);
 
 #ifdef MSN_DEBUG_SLP_FILES
 	debug_msg_to_file(msg, FALSE);
--- a/libpurple/protocols/yahoo/libymsg.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/libpurple/protocols/yahoo/libymsg.c	Mon Jul 13 05:40:12 2009 +0000
@@ -1825,7 +1825,7 @@
 					break;
 				default:
 					/* Unknown error! */
-					error_reason = g_strdup(_("Unknown error"));
+					error_reason = g_strdup_printf(_("Unknown error (%d)"), response_no);
 					error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
 					break;
 			}
--- a/pidgin/gtkconv.c	Mon Jul 13 04:11:19 2009 +0000
+++ b/pidgin/gtkconv.c	Mon Jul 13 05:40:12 2009 +0000
@@ -6985,12 +6985,20 @@
 		icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv));
 
 		if (icon == NULL)
+		{
+			gtk_widget_set_size_request(gtkconv->u.im->icon_container,
+			                            -1, BUDDYICON_SIZE_MIN);
 			return;
+		}
 
 		data = purple_buddy_icon_get_data(icon, &len);
 
 		if (data == NULL)
+		{
+			gtk_widget_set_size_request(gtkconv->u.im->icon_container,
+			                            -1, BUDDYICON_SIZE_MIN);
 			return;
+		}
 	}
 
 	loader = gdk_pixbuf_loader_new();