pidgin.2.5.6: fdee7971: *** Plucked rev f9080d0b (khc at pidgin.im)...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun May 10 19:30:21 EDT 2009


-----------------------------------------------------------------
Revision: fdee7971253e93bb0901daf84807b9d35dc8f506
Ancestor: b61d4041b364e1dc67590000472f86f9c92717d3
Author: darkrain42 at pidgin.im
Date: 2009-05-10T23:25:26
Branch: im.pidgin.pidgin.2.5.6
URL: http://d.pidgin.im/viewmtn/revision/info/fdee7971253e93bb0901daf84807b9d35dc8f506

Modified files:
        libpurple/protocols/jabber/google.c
        libpurple/protocols/msn/notification.c
        libpurple/protocols/msn/oim.c
        libpurple/protocols/msnp9/notification.c
        libpurple/protocols/myspace/myspace.c
        libpurple/protocols/oscar/oscar.c
        libpurple/protocols/yahoo/yahoo.c

ChangeLog: 

*** Plucked rev f9080d0b (khc at pidgin.im):
correctly NULL terminate all the arrays since that's what gtknotify assumes,
also fixed a memory leak in gmail notification

*** Plucked rev a543de79 (khc at pidgin.im):
Qulogic pointed out that glib has G_N_ELEMENTS already

*** Plucked rev 19b202a7 (khc at pidgin.im):
used the wrong count variable here


-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/google.c	f0624dcce3f7675f95224023738a5bc83d8f8fbb
+++ libpurple/protocols/jabber/google.c	eb36981db65b68f60823a3f2d2609b5bc690ae21
@@ -39,7 +39,6 @@ jabber_gmail_parse(JabberStream *js, xml
 	char *subject;
 	const char *in_str;
 	char *to_name;
-	char *default_tos[1];
 
 	int i, count = 1, returned_count;
 
@@ -59,14 +58,20 @@ jabber_gmail_parse(JabberStream *js, xml
 
 	/* If Gmail doesn't tell us who the mail is to, let's use our JID */
 	to = xmlnode_get_attrib(packet, "to");
-	default_tos[0] = jabber_get_bare_jid(to);
 
 	message = xmlnode_get_child(child, "mail-thread-info");
 
 	if (count == 0 || !message) {
-		if (count > 0)
-			purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL);
-		g_free(default_tos[0]);
+		if (count > 0) {
+			char *bare_jid = jabber_get_bare_jid(to);
+			const char *default_tos[2] = { bare_jid };
+
+			purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL);
+			g_free(bare_jid);
+		} else {
+			purple_notify_emails(js->gc, count, FALSE, NULL, NULL, NULL, NULL, NULL, NULL);
+		}
+
 		return;
 	}
 
@@ -74,10 +79,10 @@ jabber_gmail_parse(JabberStream *js, xml
 	 * accordingly */
 	for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message));
 
-	froms    = g_new0(const char* , returned_count);
-	tos      = g_new0(const char* , returned_count);
-	subjects = g_new0(char* , returned_count);
-	urls     = g_new0(const char* , returned_count);
+	froms    = g_new0(const char* , returned_count + 1);
+	tos      = g_new0(const char* , returned_count + 1);
+	subjects = g_new0(char* , returned_count + 1);
+	urls     = g_new0(const char* , returned_count + 1);
 
 	to = xmlnode_get_attrib(packet, "to");
 	to_name = jabber_get_bare_jid(to);
@@ -123,16 +128,12 @@ jabber_gmail_parse(JabberStream *js, xml
 	if (i>0)
 		purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos,
 				urls, NULL, NULL);
-	else
-		purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL);
 
-
 	g_free(to_name);
 	g_free(tos);
-	g_free(default_tos[0]);
 	g_free(froms);
-	for (; i > 0; i--)
-		g_free(subjects[i - 1]);
+	for (i = 0; i < returned_count; i++)
+		g_free(subjects[i]);
 	g_free(subjects);
 	g_free(urls);
 
============================================================
--- libpurple/protocols/msn/notification.c	de6a67e356d52a2fac3cf0207737f0f6db9a3dfd
+++ libpurple/protocols/msn/notification.c	4b5b8c5d060df9d6b666315f8384d9cf2224005d
@@ -1891,14 +1891,11 @@ initial_email_msg(MsnCmdProc *cmdproc, M
 
 		if (count > 0)
 		{
-			const char *passport;
-			const char *url;
+			const char *passports[2] = { msn_user_get_passport(session->user) };
+			const char *urls[2] = { session->passport_info.mail_url };
 
-			passport = msn_user_get_passport(session->user);
-			url = session->passport_info.mail_url;
-
 			purple_notify_emails(gc, count, FALSE, NULL, NULL,
-							   &passport, &url, NULL, NULL);
+							   passports, urls, NULL, NULL);
 		}
 	}
 
@@ -1960,14 +1957,11 @@ initial_mdata_msg(MsnCmdProc *cmdproc, M
 
 		if (count > 0)
 		{
-			const char *passport;
-			const char *url;
+			const char *passports[2] = { msn_user_get_passport(session->user) };
+			const char *urls[2] = { session->passport_info.mail_url };
 
-			passport = msn_user_get_passport(session->user);
-			url = session->passport_info.mail_url;
-
 			purple_notify_emails(gc, count, FALSE, NULL, NULL,
-							   &passport, &url, NULL, NULL);
+							   passports, urls, NULL, NULL);
 		}
 	}
 
============================================================
--- libpurple/protocols/msn/oim.c	5671d21f5fd46800410767e4be9176ac756afdfd
+++ libpurple/protocols/msn/oim.c	a5cc7fef73ce88953245d5132e740cd10b78ed28
@@ -764,14 +764,14 @@ msn_parse_oim_xml(MsnOim *oim, xmlnode *
 	if (iu_node != NULL && purple_account_get_check_mail(session->account))
 	{
 		char *unread = xmlnode_get_data(iu_node);
-		const char *passport = msn_user_get_passport(session->user);
-		const char *url = session->passport_info.mail_url;
+		const char *passports[2] = { msn_user_get_passport(session->user) };
+		const char *urls[2] = { session->passport_info.mail_url };
 		int count = atoi(unread);
 
 		/* XXX/khc: pretty sure this is wrong */
 		if (count > 0)
 			purple_notify_emails(session->account->gc, count, FALSE, NULL,
-				NULL, &passport, &url, NULL, NULL);
+				NULL, passports, urls, NULL, NULL);
 		g_free(unread);
 	}
 
============================================================
--- libpurple/protocols/msnp9/notification.c	e93ac247f6cd58a84db21287ff78e6d35c8697fa
+++ libpurple/protocols/msnp9/notification.c	2f99e8cc5ad2beb7019ae007e46cab2ff860fd22
@@ -1280,14 +1280,11 @@ initial_email_msg(MsnCmdProc *cmdproc, M
 
 		if (count > 0)
 		{
-			const char *passport;
-			const char *url;
+			const char *passports[2] = { msn_user_get_passport(session->user) };
+			const char *urls[2] = { session->passport_info.file };
 
-			passport = msn_user_get_passport(session->user);
-			url = session->passport_info.file;
-
-			purple_notify_emails(gc, atoi(unread), FALSE, NULL, NULL,
-							   &passport, &url, NULL, NULL);
+			purple_notify_emails(gc, count, FALSE, NULL, NULL,
+							   passports, urls, NULL, NULL);
 		}
 	}
 
============================================================
--- libpurple/protocols/myspace/myspace.c	2cddce1882f370033f51a5683c446097447e04ff
+++ libpurple/protocols/myspace/myspace.c	60c329056587d03ad0036cf8159c6dce3eff4f3b
@@ -840,8 +840,6 @@ msim_check_inbox_cb(MsimSession *session
 	MsimMessage *body;
 	guint old_inbox_status;
 	guint i, n;
-	const gchar *froms[5], *tos[5], *urls[5], *subjects[5];
-
 	/* Information for each new inbox message type. */
 	static struct
 	{
@@ -856,16 +854,22 @@ msim_check_inbox_cb(MsimSession *session
 		{ "FriendRequest", MSIM_INBOX_FRIEND_REQUEST, "http://messaging.myspace.com/index.cfm?fuseaction=mail.friendRequests", NULL },
 		{ "PictureComment", MSIM_INBOX_PICTURE_COMMENT, "http://home.myspace.com/index.cfm?fuseaction=user", NULL }
 	};
+	const gchar *froms[G_N_ELEMENTS(message_types) + 1] = { "" },
+		*tos[G_N_ELEMENTS(message_types) + 1] = { "" },
+		*urls[G_N_ELEMENTS(message_types) + 1] = { "" },
+		*subjects[G_N_ELEMENTS(message_types) + 1] = { "" };
 
+	g_return_if_fail(reply != NULL);
+
 	/* Can't write _()'d strings in array initializers. Workaround. */
+	/* khc: then use N_() in the array initializer and use _() when they are
+	   used */
 	message_types[0].text = _("New mail messages");
 	message_types[1].text = _("New blog comments");
 	message_types[2].text = _("New profile comments");
 	message_types[3].text = _("New friend requests!");
 	message_types[4].text = _("New picture comments");
 
-	g_return_if_fail(reply != NULL);
-
 	body = msim_msg_get_dictionary(reply, "body");
 
 	if (body == NULL)
@@ -875,7 +879,7 @@ msim_check_inbox_cb(MsimSession *session
 
 	n = 0;
 
-	for (i = 0; i < sizeof(message_types) / sizeof(message_types[0]); ++i) {
+	for (i = 0; i < G_N_ELEMENTS(message_types); ++i) {
 		const gchar *key;
 		guint bit;
 
============================================================
--- libpurple/protocols/oscar/oscar.c	5f4b5d44258be75292f3c1e87f1aef4635b6141e
+++ libpurple/protocols/oscar/oscar.c	21b76f1d4cf14275ad190156b09d271b4b94c6c9
@@ -3560,8 +3560,10 @@ static int purple_email_parseupdate(Osca
 		gchar *to = g_strdup_printf("%s%s%s", purple_account_get_username(purple_connection_get_account(gc)),
 									emailinfo->domain ? "@" : "",
 									emailinfo->domain ? emailinfo->domain : "");
+		const char *tos[2] = { to };
+		const char *urls[2] = {emailinfo->url }; 
 		if (emailinfo->unread && havenewmail)
-			purple_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL);
+			purple_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, tos, urls, NULL, NULL);
 		g_free(to);
 	}
 
============================================================
--- libpurple/protocols/yahoo/yahoo.c	c16021dc090ee14832b0941c3919a04c4ede6885
+++ libpurple/protocols/yahoo/yahoo.c	ec9f4e1f699abde029195f3b2d1da5ec915dbce3
@@ -1333,10 +1333,10 @@ static void yahoo_process_mail(PurpleCon
 		g_free(dec_subj);
 		g_free(from);
 	} else if (count > 0) {
-		const char *to = purple_account_get_username(account);
-		const char *url = yahoo_mail_url;
+		const char *tos[2] = { purple_account_get_username(account) };
+		const char *urls[2] = { yahoo_mail_url };
 
-		purple_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url,
+		purple_notify_emails(gc, count, FALSE, NULL, NULL, tos, urls,
 						   NULL, NULL);
 	}
 }


More information about the Commits mailing list