pidgin.next.minor: 8cdcfae0: Add a purple_notify_user_info_add_pair_p...
markdoliner at pidgin.im
markdoliner at pidgin.im
Thu Jul 8 18:41:29 EDT 2010
----------------------------------------------------------------------
Revision: 8cdcfae03192b964373cd95a73342d30ed15d13a
Parent: a05f9dbbd922edf216d109c8e60e95718b4c9692
Author: markdoliner at pidgin.im
Date: 07/08/10 18:38:33
Branch: im.pidgin.pidgin.next.minor
URL: http://d.pidgin.im/viewmtn/revision/info/8cdcfae03192b964373cd95a73342d30ed15d13a
Changelog:
Add a purple_notify_user_info_add_pair_plaintext function that accepts a
plaintext value and escapes it. This is a convenience function. Previously
callers would have to escape the value themselves.
The motivation for this is that a lot of callers didn't escape the value
when they should have. See these screenshots for an example of the problem
this causes:
Here's what I set my jabber info to:
http://img29.imageshack.us/i/screenshotafter.png/
Here's what the old code displayed when I viewed info for myself (incorrect):
http://img691.imageshack.us/i/screenshotbeforev.png/
Here's what the new code displays (correct):
http://img192.imageshack.us/i/screenshotafter.png/
Changes against parent a05f9dbbd922edf216d109c8e60e95718b4c9692
patched ChangeLog.API
patched libpurple/notify.c
patched libpurple/notify.h
patched libpurple/protocols/jabber/buddy.c
patched libpurple/protocols/msn/msn.c
patched libpurple/protocols/yahoo/libymsg.c
patched libpurple/protocols/yahoo/yahoo_profile.c
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msn.c 6a005f8d2d4114210f8ed43face793d0733a3181
+++ libpurple/protocols/msn/msn.c 6513ab3b48ccad32e814c3aee37e15cac7b9cc82
@@ -884,7 +884,6 @@ msn_tooltip_text(PurpleBuddy *buddy, Pur
const char *psm, *name;
const char *mediatype = NULL;
char *currentmedia = NULL;
- char *tmp;
psm = purple_status_get_attr_string(status, "message");
if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
@@ -928,9 +927,7 @@ msn_tooltip_text(PurpleBuddy *buddy, Pur
}
if (psm != NULL && *psm) {
- tmp = g_markup_escape_text(psm, -1);
- purple_notify_user_info_add_pair(user_info, tmp2, tmp);
- g_free(tmp);
+ purple_notify_user_info_add_pair_plaintext(user_info, tmp2, psm);
} else {
purple_notify_user_info_add_pair(user_info, _("Status"), tmp2);
}
@@ -938,13 +935,11 @@ msn_tooltip_text(PurpleBuddy *buddy, Pur
g_free(tmp2);
} else {
if (psm != NULL && *psm) {
- tmp = g_markup_escape_text(psm, -1);
if (purple_presence_is_idle(presence)) {
- purple_notify_user_info_add_pair(user_info, _("Idle"), tmp);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Idle"), psm);
} else {
- purple_notify_user_info_add_pair(user_info, _("Status"), tmp);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), psm);
}
- g_free(tmp);
} else {
if (purple_presence_is_idle(presence)) {
purple_notify_user_info_add_pair(user_info, _("Status"),
@@ -2122,9 +2117,7 @@ msn_tooltip_extract_info_text(PurpleNoti
alias = purple_buddy_get_local_buddy_alias(b);
if (alias && alias[0])
{
- char *aliastext = g_markup_escape_text(alias, -1);
- purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext);
- g_free(aliastext);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Alias"), alias);
}
if ((alias = purple_buddy_get_server_alias(b)) != NULL)
============================================================
--- libpurple/protocols/yahoo/libymsg.c 6090714a7b0fb9c74656b7346d20c6be74c9176e
+++ libpurple/protocols/yahoo/libymsg.c 6aa84ff96639decd52cfe3084c084cc797a4bda8
@@ -3974,7 +3974,6 @@ void yahoo_tooltip_text(PurpleBuddy *b,
void yahoo_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
{
YahooFriend *f;
- char *escaped;
char *status = NULL;
const char *presence = NULL;
PurpleAccount *account;
@@ -4013,14 +4012,12 @@ void yahoo_tooltip_text(PurpleBuddy *b,
}
if (status != NULL) {
- escaped = g_markup_escape_text(status, strlen(status));
- purple_notify_user_info_add_pair(user_info, _("Status"), escaped);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status);
g_free(status);
- g_free(escaped);
}
if (presence != NULL)
- purple_notify_user_info_add_pair(user_info, _("Presence"), presence);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Presence"), presence);
if (f && full) {
YahooPersonalDetails *ypd = &f->ypd;
============================================================
--- libpurple/notify.c 3d493ad80fda5870ddc9a7aeb89221c6b4d916e5
+++ libpurple/notify.c 7110d5940b0743e117730aebc9f3e18a2e8c959c
@@ -602,6 +602,18 @@ void
}
void
+purple_notify_user_info_add_pair_plaintext(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
+{
+ gchar *escaped;
+ PurpleNotifyUserInfoEntry *entry;
+
+ escaped = g_markup_escape_text(value, -1);
+ entry = purple_notify_user_info_entry_new(label, escaped);
+ g_free(escaped);
+ user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry);
+}
+
+void
purple_notify_user_info_prepend_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
{
PurpleNotifyUserInfoEntry *entry;
============================================================
--- libpurple/notify.h 7f0ec15f9a265e079c8d0585a9c4fdd65f3dded3
+++ libpurple/notify.h 37a8aa775ee077a7770b0917d10576d62256f8cd
@@ -540,13 +540,28 @@ char *purple_notify_user_info_get_text_w
* a colon. If NULL, value will be displayed without a
* label.
* @param value The value, which might be displayed by a UI after
- * the label. If NULL, label will still be displayed;
- * the UI should then treat label as independent and not
+ * the label. This should be valid HTML. If you want
+ * to insert plaintext then use
+ * purple_notify_user_info_add_pair_plaintext(), instead.
+ * If this is NULL the label will still be displayed;
+ * the UI should treat label as independent and not
* include a colon if it would otherwise.
*/
+/*
+ * TODO: In 3.0.0 this function should be renamed to
+ * purple_notify_user_info_add_pair_html(). And optionally
+ * purple_notify_user_info_add_pair_plaintext() could be renamed to
+ * purple_notify_user_info_add_pair().
+ */
void purple_notify_user_info_add_pair(PurpleNotifyUserInfo *user_info, const char *label, const char *value);
/**
+ * Like purple_notify_user_info_add_pair, but value should be plaintext
+ * and will be escaped using g_markup_escape_text().
+ */
+void purple_notify_user_info_add_pair_plaintext(PurpleNotifyUserInfo *user_info, const char *label, const char *value);
+
+/**
* Prepend a label/value pair to a PurpleNotifyUserInfo object
*
* @param user_info The PurpleNotifyUserInfo
============================================================
--- libpurple/protocols/jabber/buddy.c a46c6993b2db1ff61f27f5bf298ac04a472c5e97
+++ libpurple/protocols/jabber/buddy.c 8d93189d3e40fef86adcc4d1e889e1671ade9f27
@@ -1021,7 +1021,7 @@ static void jabber_vcard_parse(JabberStr
if (!serverside_alias)
serverside_alias = g_strdup(text);
- purple_notify_user_info_add_pair(user_info, _("Full Name"), text);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Full Name"), text);
} else if(!strcmp(child->name, "N")) {
for(child2 = child->child; child2; child2 = child2->next)
{
@@ -1032,11 +1032,11 @@ static void jabber_vcard_parse(JabberStr
text2 = xmlnode_get_data(child2);
if(text2 && !strcmp(child2->name, "FAMILY")) {
- purple_notify_user_info_add_pair(user_info, _("Family Name"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Family Name"), text2);
} else if(text2 && !strcmp(child2->name, "GIVEN")) {
- purple_notify_user_info_add_pair(user_info, _("Given Name"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Given Name"), text2);
} else if(text2 && !strcmp(child2->name, "MIDDLE")) {
- purple_notify_user_info_add_pair(user_info, _("Middle Name"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Middle Name"), text2);
}
g_free(text2);
}
@@ -1047,10 +1047,10 @@ static void jabber_vcard_parse(JabberStr
g_free(serverside_alias);
serverside_alias = g_strdup(text);
- purple_notify_user_info_add_pair(user_info, _("Nickname"), text);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Nickname"), text);
}
} else if(text && !strcmp(child->name, "BDAY")) {
- purple_notify_user_info_add_pair(user_info, _("Birthday"), text);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Birthday"), text);
} else if(!strcmp(child->name, "ADR")) {
gboolean address_line_added = FALSE;
@@ -1074,25 +1074,25 @@ static void jabber_vcard_parse(JabberStr
}
if(!strcmp(child2->name, "POBOX")) {
- purple_notify_user_info_add_pair(user_info, _("P.O. Box"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("P.O. Box"), text2);
} else if (g_str_equal(child2->name, "EXTADD") || g_str_equal(child2->name, "EXTADR")) {
/*
* EXTADD is correct, EXTADR is generated by other
* clients. The next time someone reads this, remove
* EXTADR.
*/
- purple_notify_user_info_add_pair(user_info, _("Extended Address"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Extended Address"), text2);
} else if(!strcmp(child2->name, "STREET")) {
- purple_notify_user_info_add_pair(user_info, _("Street Address"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Street Address"), text2);
} else if(!strcmp(child2->name, "LOCALITY")) {
- purple_notify_user_info_add_pair(user_info, _("Locality"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Locality"), text2);
} else if(!strcmp(child2->name, "REGION")) {
- purple_notify_user_info_add_pair(user_info, _("Region"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Region"), text2);
} else if(!strcmp(child2->name, "PCODE")) {
- purple_notify_user_info_add_pair(user_info, _("Postal Code"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Postal Code"), text2);
} else if(!strcmp(child2->name, "CTRY")
|| !strcmp(child2->name, "COUNTRY")) {
- purple_notify_user_info_add_pair(user_info, _("Country"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Country"), text2);
}
g_free(text2);
}
@@ -1106,13 +1106,13 @@ static void jabber_vcard_parse(JabberStr
/* show what kind of number it is */
number = xmlnode_get_data(child2);
if(number) {
- purple_notify_user_info_add_pair(user_info, _("Telephone"), number);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number);
g_free(number);
}
} else if((number = xmlnode_get_data(child))) {
/* lots of clients (including purple) do this, but it's
* out of spec */
- purple_notify_user_info_add_pair(user_info, _("Telephone"), number);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number);
g_free(number);
}
} else if(!strcmp(child->name, "EMAIL")) {
@@ -1153,18 +1153,18 @@ static void jabber_vcard_parse(JabberStr
text2 = xmlnode_get_data(child2);
if(text2 && !strcmp(child2->name, "ORGNAME")) {
- purple_notify_user_info_add_pair(user_info, _("Organization Name"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Organization Name"), text2);
} else if(text2 && !strcmp(child2->name, "ORGUNIT")) {
- purple_notify_user_info_add_pair(user_info, _("Organization Unit"), text2);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Organization Unit"), text2);
}
g_free(text2);
}
} else if(text && !strcmp(child->name, "TITLE")) {
- purple_notify_user_info_add_pair(user_info, _("Job Title"), text);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Job Title"), text);
} else if(text && !strcmp(child->name, "ROLE")) {
- purple_notify_user_info_add_pair(user_info, _("Role"), text);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Role"), text);
} else if(text && !strcmp(child->name, "DESC")) {
- purple_notify_user_info_add_pair(user_info, _("Description"), text);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Description"), text);
} else if(!strcmp(child->name, "PHOTO") ||
!strcmp(child->name, "LOGO")) {
char *bintext = NULL;
============================================================
--- ChangeLog.API ad4d2158b18809b9627b9f0d5c87003b305c9d42
+++ ChangeLog.API 59caa95c88f641df11771386dac9a44bba33d5f3
@@ -1,5 +1,10 @@ Pidgin and Finch: The Pimpin' Penguin IM
Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
+version 2.8.0 (??/??/????):
+ libpurple:
+ Added:
+ * purple_notify_user_info_add_pair_plaintext
+
version 2.7.2 (??/??/????):
libpurple:
Fixed:
============================================================
--- libpurple/protocols/yahoo/yahoo_profile.c c6458d75e5bd8794c6b8830ed4665e97e30fad66
+++ libpurple/protocols/yahoo/yahoo_profile.c 86635aa6e8bb4df05b9828d99c18b2be8213dd1f
@@ -701,14 +701,12 @@ static void yahoo_extract_user_info_text
if (b) {
const char *balias = purple_buddy_get_local_buddy_alias(b);
if(balias && balias[0]) {
- char *aliastext = g_markup_escape_text(balias, -1);
- purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext);
- g_free(aliastext);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Alias"), balias);
}
#if 0
if (b->idle > 0) {
char *idletime = purple_str_seconds_to_string(time(NULL) - b->idle);
- purple_notify_user_info_add_pair(user_info, _("Idle"), idletime);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Idle"), idletime);
g_free(idletime);
}
#endif
@@ -719,7 +717,7 @@ static void yahoo_extract_user_info_text
if ((f = yahoo_friend_find(info_data->gc, purple_buddy_get_name(b)))) {
const char *ip;
if ((ip = yahoo_friend_get_ip(f)))
- purple_notify_user_info_add_pair(user_info, _("IP Address"), ip);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("IP Address"), ip);
}
}
}
More information about the Commits
mailing list