Mercurial > pidgin
changeset 26852:0b97f73fa3d2
correctly NULL terminate all the arrays since that's what gtknotify assumes,
also fixed a memory leak in gmail notification
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sun, 10 May 2009 22:06:08 +0000 |
parents | 04af21d4be27 |
children | 55a8fe9d8247 657d42e865dd |
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 |
diffstat | 7 files changed, 44 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/google.c Fri May 08 03:54:58 2009 +0000 +++ b/libpurple/protocols/jabber/google.c Sun May 10 22:06:08 2009 +0000 @@ -638,7 +638,6 @@ const char *to, *url; const char *in_str; char *to_name; - char *default_tos[1]; int i, count = 1, returned_count; @@ -658,14 +657,20 @@ /* 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; } @@ -673,10 +678,10 @@ * 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); @@ -726,16 +731,12 @@ 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 < count; i++) + g_free(subjects[i]); g_free(subjects); g_free(urls);
--- a/libpurple/protocols/msn/notification.c Fri May 08 03:54:58 2009 +0000 +++ b/libpurple/protocols/msn/notification.c Sun May 10 22:06:08 2009 +0000 @@ -1891,14 +1891,11 @@ if (count > 0) { - const char *passport; - const char *url; - - passport = msn_user_get_passport(session->user); - 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 }; purple_notify_emails(gc, count, FALSE, NULL, NULL, - &passport, &url, NULL, NULL); + passports, urls, NULL, NULL); } } @@ -1960,14 +1957,11 @@ if (count > 0) { - const char *passport; - const char *url; - - passport = msn_user_get_passport(session->user); - 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 }; purple_notify_emails(gc, count, FALSE, NULL, NULL, - &passport, &url, NULL, NULL); + passports, urls, NULL, NULL); } }
--- a/libpurple/protocols/msn/oim.c Fri May 08 03:54:58 2009 +0000 +++ b/libpurple/protocols/msn/oim.c Sun May 10 22:06:08 2009 +0000 @@ -764,14 +764,14 @@ 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); }
--- a/libpurple/protocols/msnp9/notification.c Fri May 08 03:54:58 2009 +0000 +++ b/libpurple/protocols/msnp9/notification.c Sun May 10 22:06:08 2009 +0000 @@ -1280,14 +1280,11 @@ 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); } }
--- a/libpurple/protocols/myspace/myspace.c Fri May 08 03:54:58 2009 +0000 +++ b/libpurple/protocols/myspace/myspace.c Sun May 10 22:06:08 2009 +0000 @@ -847,8 +847,6 @@ 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 { @@ -863,16 +861,22 @@ { "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[ARRAY_LENGTH(message_types) + 1] = { "" }, + *tos[ARRAY_LENGTH(message_types) + 1] = { "" }, + *urls[ARRAY_LENGTH(message_types) + 1] = { "" }, + *subjects[ARRAY_LENGTH(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)
--- a/libpurple/protocols/oscar/oscar.c Fri May 08 03:54:58 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.c Sun May 10 22:06:08 2009 +0000 @@ -3571,8 +3571,10 @@ purple_account_get_username(account), emailinfo->domain ? "@" : "", emailinfo->domain ? emailinfo->domain : ""); + const char *tos[2] = { to }; + const char *urls[2] = { emailinfo->url }; purple_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, - (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); + tos, urls, NULL, NULL); g_free(to); }
--- a/libpurple/protocols/yahoo/yahoo.c Fri May 08 03:54:58 2009 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Sun May 10 22:06:08 2009 +0000 @@ -1520,10 +1520,10 @@ 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; - - purple_notify_emails(gc, count, FALSE, NULL, NULL, &to, &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, tos, urls, NULL, NULL); } }