changeset 25506:fb0b82b40f98

propagate from branch 'im.pidgin.pidgin' (head f68bc95ec93e616afdf0527fc982ff5f226f5463) to branch 'im.pidgin.pidgin.yaz' (head 3fceb38f40e52c22e3be0bb7598c427acadd3454)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 11 Jun 2007 05:49:32 +0000
parents e7cc85ad9a6e (current diff) 6d3d7ee05b06 (diff)
children 2dca564c2465
files libpurple/protocols/oscar/oscar.c pidgin/gtkconv.c pidgin/gtkimhtml.c
diffstat 8 files changed, 127 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/blist.c	Sun Jun 10 18:41:41 2007 +0000
+++ b/libpurple/blist.c	Mon Jun 11 05:49:32 2007 +0000
@@ -1774,7 +1774,7 @@
 
 	node = (PurpleBlistNode *)buddy;
 	cnode = node->parent;
-	gnode = cnode->parent;
+	gnode = (cnode != NULL) ? cnode->parent : NULL;
 	contact = (PurpleContact *)cnode;
 	group = (PurpleGroup *)gnode;
 
@@ -1783,35 +1783,37 @@
 		node->prev->next = node->next;
 	if (node->next)
 		node->next->prev = node->prev;
-	if (cnode->child == node)
+	if ((cnode != NULL) && (cnode->child == node))
 		cnode->child = node->next;
 
 	/* Adjust size counts */
-	if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
-		contact->online--;
-		if (contact->online == 0)
-			group->online--;
+	if (contact != NULL) {
+		if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
+			contact->online--;
+			if (contact->online == 0)
+				group->online--;
+		}
+		if (purple_account_is_connected(buddy->account)) {
+			contact->currentsize--;
+			if (contact->currentsize == 0)
+				group->currentsize--;
+		}
+		contact->totalsize--;
+
+		/* Re-sort the contact */
+		if (cnode->child && contact->priority == buddy) {
+			purple_contact_invalidate_priority_buddy(contact);
+			if (ops && ops->update)
+				ops->update(purplebuddylist, cnode);
+		}
 	}
-	if (purple_account_is_connected(buddy->account)) {
-		contact->currentsize--;
-		if (contact->currentsize == 0)
-			group->currentsize--;
-	}
-	contact->totalsize--;
 
 	purple_blist_schedule_save();
 
-	/* Re-sort the contact */
-	if (cnode->child && contact->priority == buddy) {
-		purple_contact_invalidate_priority_buddy(contact);
-		if (ops && ops->update)
-			ops->update(purplebuddylist, cnode);
-	}
-
 	/* Remove this buddy from the buddies hash table */
 	hb.name = g_strdup(purple_normalize(buddy->account, buddy->name));
 	hb.account = buddy->account;
-	hb.group = ((PurpleBlistNode*)buddy)->parent->parent;
+	hb.group = gnode;
 	g_hash_table_remove(purplebuddylist->buddies, &hb);
 	g_free(hb.name);
 
@@ -1841,7 +1843,7 @@
 	while (g_source_remove_by_user_data((gpointer *)buddy));
 
 	/* If the contact is empty then remove it */
-	if (!cnode->child)
+	if ((contact != NULL) && !cnode->child)
 		purple_blist_remove_contact(contact);
 }
 
--- a/libpurple/protocols/Makefile.mingw	Sun Jun 10 18:41:41 2007 +0000
+++ b/libpurple/protocols/Makefile.mingw	Mon Jun 11 05:49:32 2007 +0000
@@ -8,7 +8,7 @@
 PIDGIN_TREE_TOP := ../..
 include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak
 
-SUBDIRS = gg irc jabber msn novell null oscar qq sametime silc simple yahoo bonjour
+SUBDIRS = gg irc jabber msn novell null oscar qq sametime silc10 simple yahoo bonjour
 
 .PHONY: all install clean
 
--- a/libpurple/protocols/msn/notification.c	Sun Jun 10 18:41:41 2007 +0000
+++ b/libpurple/protocols/msn/notification.c	Mon Jun 11 05:49:32 2007 +0000
@@ -591,12 +591,23 @@
 static void
 qng_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
 {
+	MsnSession *session;
 	static int count = 0;
-	MsnSession *session = cmdproc->session;
+	const char *passport;
+	PurpleAccount *account;
+
+	session = cmdproc->session;
+	account = session->account;
 
 	if (session->passport_info.file == NULL)
 		return;
 
+	passport = purple_normalize(account, purple_account_get_username(account));
+
+	if ((strstr(passport, "@hotmail.") != NULL) ||
+		(strstr(passport, "@msn.com") != NULL))
+		return;
+
 	if (count++ < 26)
 		return;
 
--- a/libpurple/protocols/msn/session.c	Sun Jun 10 18:41:41 2007 +0000
+++ b/libpurple/protocols/msn/session.c	Mon Jun 11 05:49:32 2007 +0000
@@ -386,6 +386,7 @@
 	PurpleAccount *account;
 	PurpleConnection *gc;
 	PurpleStoredImage *img;
+	const char *passport;
 
 	if (session->logged_in)
 		return;
@@ -409,5 +410,12 @@
 	 * and @msn.com accounts don't automatically get the initial email
 	 * notification so we always request it on login
 	 */
-	msn_cmdproc_send(session->notification->cmdproc, "URL", "%s", "INBOX");
+
+	passport = purple_normalize(account, purple_account_get_username(account));
+
+	if ((strstr(passport, "@hotmail.") != NULL) ||
+		(strstr(passport, "@msn.com") != NULL))
+	{
+		msn_cmdproc_send(session->notification->cmdproc, "URL", "%s", "INBOX");
+	}
 }
--- a/libpurple/protocols/oscar/oscar.c	Sun Jun 10 18:41:41 2007 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Mon Jun 11 05:49:32 2007 +0000
@@ -4193,6 +4193,7 @@
 	PeerConnection *conn;
 	int ret;
 	char *tmp1, *tmp2;
+	gboolean is_html;
 
 	od = (OscarData *)gc->proto_data;
 	account = purple_connection_get_account(gc);
@@ -4211,7 +4212,6 @@
 	} else {
 		struct buddyinfo *bi;
 		struct aim_sendimext_args args;
-		gsize len;
 		PurpleConversation *conv;
 		PurpleStoredImage *img;
 
@@ -4302,22 +4302,43 @@
 		if (aim_sn_is_sms(name)) {
 			/* Messaging an SMS (mobile) user */
 			tmp2 = purple_markup_strip_html(tmp1);
+			is_html = FALSE;
 		} else if (aim_sn_is_icq(purple_account_get_username(account))) {
-			if (aim_sn_is_icq(name))
+			if (aim_sn_is_icq(name)) {
 				/* From ICQ to ICQ */
 				tmp2 = purple_markup_strip_html(tmp1);
-			else
+				is_html = FALSE;
+			} else {
 				/* From ICQ to AIM */
 				tmp2 = g_strdup(tmp1);
+				is_html = TRUE;
+			}
 		} else {
 			/* From AIM to AIM and AIM to ICQ */
 			tmp2 = g_strdup(tmp1);
+			is_html = TRUE;
 		}
 		g_free(tmp1);
 		tmp1 = tmp2;
-		len = strlen(tmp1);
 
 		purple_plugin_oscar_convert_to_best_encoding(gc, name, tmp1, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset);
+		if (is_html && (args.msglen > MAXMSGLEN)) {
+			/* If the length was too long, try stripping the HTML and then running it back through
+			* purple_strdup_withhtml() and the encoding process. The result may be shorter. */
+			g_free((char *)args.msg);
+			
+			tmp2 = purple_markup_strip_html(tmp1);
+			g_free(tmp1);
+			
+			tmp1 = purple_strdup_withhtml(tmp2);
+			g_free(tmp2);
+			
+			purple_plugin_oscar_convert_to_best_encoding(gc, name, tmp1, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset);
+
+			purple_debug_info("oscar", "Sending %s as %s because the original was too long.",
+								  message, (char *)args.msg);
+		}
+
 		purple_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n",
 						args.charset, args.charsubset, args.msglen);
 		ret = aim_im_sendch1_ext(od, &args);
@@ -5350,7 +5371,7 @@
 	OscarData *od = (OscarData *)gc->proto_data;
 	PurpleConversation *conv = NULL;
 	struct chat_connection *c = NULL;
-	char *buf, *buf2;
+	char *buf, *buf2, *buf3;
 	guint16 charset, charsubset;
 	char *charsetstr = NULL;
 	int len;
@@ -5362,7 +5383,6 @@
 		return -EINVAL;
 
 	buf = purple_strdup_withhtml(message);
-	len = strlen(buf);
 
 	if (strstr(buf, "<IMG "))
 		purple_conversation_write(conv, "",
@@ -5376,8 +5396,28 @@
 	 * visible characters" and not "number of bytes"
 	 */
 	if ((len > c->maxlen) || (len > c->maxvis)) {
+		/* If the length was too long, try stripping the HTML and then running it back through
+		 * purple_strdup_withhtml() and the encoding process. The result may be shorter. */
 		g_free(buf2);
-		return -E2BIG;
+
+		buf3 = purple_markup_strip_html(buf);
+		g_free(buf);
+
+		buf = purple_strdup_withhtml(buf3);
+		g_free(buf3);
+
+		purple_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset);
+
+		if ((len > c->maxlen) || (len > c->maxvis)) {
+			purple_debug_warning("oscar", "Could not send %s because (%i > maxlen %i) or (%i > maxvis %i)",
+					buf2, len, c->maxlen, len, c->maxvis);
+			g_free(buf);
+			g_free(buf2);
+			return -E2BIG;
+		}
+
+		purple_debug_info("oscar", "Sending %s as %s because the original was too long.",
+				message, buf2);
 	}
 
 	if (charset == AIM_CHARSET_ASCII)
@@ -5388,6 +5428,7 @@
 		charsetstr = "iso-8859-1";
 	aim_chat_send_im(od, c->conn, 0, buf2, len, charsetstr, "JA");
 	g_free(buf2);
+	g_free(buf);
 
 	return 0;
 }
--- a/pidgin/gtkconv.c	Sun Jun 10 18:41:41 2007 +0000
+++ b/pidgin/gtkconv.c	Mon Jun 11 05:49:32 2007 +0000
@@ -1860,6 +1860,9 @@
 				if (!gtkconv->send_history)
 					break;
 
+				if (gtkconv->entry != entry)
+					break;
+
 				if (!gtkconv->send_history->prev) {
 					GtkTextIter start, end;
 
@@ -1908,6 +1911,9 @@
 				if (!gtkconv->send_history)
 					break;
 
+				if (gtkconv->entry != entry)
+					break;
+
 				if (gtkconv->send_history->prev && gtkconv->send_history->prev->data) {
 					GObject *object;
 					GtkTextIter iter;
@@ -2011,6 +2017,8 @@
 		switch (event->keyval)
 		{
 			case GDK_Tab:
+				if (gtkconv->entry != entry)
+					break;
 				return tab_complete(conv);
 				break;
 
@@ -4283,6 +4291,8 @@
 
 		gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0);
 		gtk_widget_show(gtkchat->topic_text);
+		g_signal_connect(G_OBJECT(gtkchat->topic_text), "key_press_event",
+			             G_CALLBACK(entry_key_press_cb), gtkconv);
 	}
 
 	/* Setup the horizontal pane. */
--- a/pidgin/gtkft.c	Sun Jun 10 18:41:41 2007 +0000
+++ b/pidgin/gtkft.c	Mon Jun 11 05:49:32 2007 +0000
@@ -248,10 +248,10 @@
 
 	get_xfer_info_strings(xfer, &kbsec, &time_elapsed, &time_remaining);
 
-	status = g_strdup_printf("%ld%% (%ld of %ld bytes)",
-							 (unsigned long)(purple_xfer_get_progress(xfer)*100),
-							 (unsigned long)purple_xfer_get_bytes_sent(xfer),
-							 (unsigned long)purple_xfer_get_size(xfer));
+	status = g_strdup_printf("%d%% (%" G_GSIZE_FORMAT " of %" G_GSIZE_FORMAT " bytes)",
+							 (int)(purple_xfer_get_progress(xfer)*100),
+							 purple_xfer_get_bytes_sent(xfer),
+							 purple_xfer_get_size(xfer));
 
 	if (purple_xfer_is_completed(xfer)) {
 
--- a/pidgin/gtkimhtml.c	Sun Jun 10 18:41:41 2007 +0000
+++ b/pidgin/gtkimhtml.c	Mon Jun 11 05:49:32 2007 +0000
@@ -3181,6 +3181,7 @@
 	char *basename = g_path_get_basename(filename);
 	char *ext = strrchr(basename, '.');
 #endif
+	char *newfilename;
 
 	gtk_widget_destroy(image->filesel);
 	image->filesel = NULL;
@@ -3195,7 +3196,7 @@
 			gchar *fmt_ext = extensions[0];
 			const gchar* file_ext = filename + strlen(filename) - strlen(fmt_ext);
 
-			if(!strcmp(fmt_ext, file_ext)){
+			if(!g_ascii_strcasecmp(fmt_ext, file_ext)){
 				type = gdk_pixbuf_format_get_name(format);
 				break;
 			}
@@ -3228,6 +3229,7 @@
 	/* If I can't find a valid type, I will just tell the user about it and then assume
 	   it's a png */
 	if (!type){
+		char *basename, *tmp;
 #if GTK_CHECK_VERSION(2,4,0)
 		GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
 						_("<span size='larger' weight='bold'>Unrecognized file type</span>\n\nDefaulting to PNG."));
@@ -3238,10 +3240,26 @@
 
 		g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog);
 		gtk_widget_show(dialog);
+
 		type = g_strdup("png");
+		basename = g_path_get_basename(filename);
+		tmp = strrchr(basename, '.');
+		if (tmp != NULL)
+			tmp[0] = '\0';
+		newfilename = g_strdup_printf("%s.png", basename);
+		g_free(basename);
+	} else {
+		/*
+		 * We're able to save the file in it's original format, so we
+		 * can use the original file name.
+		 */
+		newfilename = g_strdup(filename);
 	}
 
-	gdk_pixbuf_save(image->pixbuf, filename, type, &error, NULL);
+	gdk_pixbuf_save(image->pixbuf, newfilename, type, &error, NULL);
+
+	g_free(newfilename);
+	g_free(type);
 
 	if (error){
 #if GTK_CHECK_VERSION(2,4,0)
@@ -3255,8 +3273,6 @@
 		gtk_widget_show(dialog);
 		g_error_free(error);
 	}
-
-	g_free(type);
 }
 
 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */