diff -r 6775ac53169c -r f642029b2f97 libgaim/protocols/msn/msn.c
--- a/libgaim/protocols/msn/msn.c Sat Dec 09 20:20:17 2006 +0000
+++ b/libgaim/protocols/msn/msn.c Sun Dec 10 02:53:09 2006 +0000
@@ -67,10 +67,8 @@
MsnGetInfoData *info_data;
char *stripped;
char *url_buffer;
- GString *s;
+ GaimNotifyUserInfo *user_info;
char *photo_url_text;
- char *tooltip_text;
- const char *title;
} MsnGetInfoStepTwoData;
@@ -533,7 +531,7 @@
}
static void
-msn_tooltip_text(GaimBuddy *buddy, GString *str, gboolean full)
+msn_tooltip_text(GaimBuddy *buddy, GaimNotifyUserInfo *user_info, gboolean full)
{
MsnUser *user;
GaimPresence *presence = gaim_buddy_get_presence(buddy);
@@ -541,27 +539,27 @@
user = buddy->proto_data;
+
if (gaim_presence_is_online(presence))
{
- g_string_append_printf(str, _("\n%s: %s"), _("Status"),
- gaim_presence_is_idle(presence) ?
- _("Idle") : gaim_status_get_name(status));
+ gaim_notify_user_info_add_pair(user_info, _("Status"),
+ (gaim_presence_is_idle(presence) ? _("Idle") : gaim_status_get_name(status)));
}
-
+
if (full && user)
{
- g_string_append_printf(str, _("\n%s: %s"), _("Has you"),
- (user->list_op & (1 << MSN_LIST_RL)) ?
- _("Yes") : _("No"));
+ gaim_notify_user_info_add_pair(user_info, _("Has you"),
+ ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No")));
+ }
/* XXX: This is being shown in non-full tooltips because the
* XXX: blocked icon overlay isn't always accurate for MSN.
* XXX: This can die as soon as gaim_privacy_check() knows that
* XXX: this prpl always honors both the allow and deny lists. */
if (user)
- g_string_append_printf(str, _("\n%s: %s"), _("Blocked"),
- (user->list_op & (1 << MSN_LIST_BL)) ?
- _("Yes") : _("No"));
+ {
+ gaim_notify_user_info_add_pair(user_info, _("Blocked"),
+ ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No")));
}
}
@@ -1341,47 +1339,44 @@
}
}
-static char *
-msn_tooltip_info_text(MsnGetInfoData *info_data)
+/**
+ * Extract info text from info_data and add it to user_info
+ */
+static gboolean
+msn_tooltip_extract_info_text(GaimNotifyUserInfo *user_info, MsnGetInfoData *info_data)
{
- GString *s;
GaimBuddy *b;
- s = g_string_sized_new(80); /* wild guess */
-
b = gaim_find_buddy(gaim_connection_get_account(info_data->gc),
info_data->name);
if (b)
{
- GString *str = g_string_new("");
char *tmp;
if (b->alias && b->alias[0])
{
char *aliastext = g_markup_escape_text(b->alias, -1);
- g_string_append_printf(s, _("Alias: %s
"), aliastext);
+ gaim_notify_user_info_add_pair(user_info, _("Alias"), aliastext);
g_free(aliastext);
}
if (b->server_alias)
{
char *nicktext = g_markup_escape_text(b->server_alias, -1);
- g_string_append_printf(s, _("%s: "), _("Nickname"));
- g_string_append_printf(s, "%s
",
- nicktext);
+ tmp = g_strdup_printf("%s
", nicktext);
+ gaim_notify_user_info_add_pair(user_info, _("Nickname"), tmp);
+ g_free(tmp);
g_free(nicktext);
}
- msn_tooltip_text(b, str, TRUE);
- tmp = gaim_strreplace((*str->str == '\n' ? str->str + 1 : str->str),
- "\n", "
");
- g_string_free(str, TRUE);
- g_string_append_printf(s, "%s
", tmp);
- g_free(tmp);
+ /* Add the tooltip information */
+ msn_tooltip_text(b, user_info, TRUE);
+
+ return TRUE;
}
- return g_string_free(s, FALSE);
+ return FALSE;
}
#if PHOTO_SUPPORT
@@ -1419,7 +1414,7 @@
#endif
#define MSN_GOT_INFO_GET_FIELD(a, b) \
- found = gaim_markup_extract_info_field(stripped, stripped_len, s, \
+ found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, \
"\n" a ":", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \
if (found) \
sect_info = TRUE;
@@ -1429,17 +1424,15 @@
const gchar *url_text, size_t len, const gchar *error_message)
{
MsnGetInfoData *info_data = (MsnGetInfoData *)data;
- char *stripped, *p, *q;
- char buf[1024];
- char *tooltip_text;
+ GaimNotifyUserInfo *user_info;
+ char *stripped, *p, *q, *tmp;
char *user_url = NULL;
gboolean found;
+ gboolean has_tooltip_text = FALSE;
gboolean has_info = FALSE;
gboolean sect_info = FALSE;
- const char* title = NULL;
+ gboolean has_contact_info = FALSE;
char *url_buffer;
- char *personal = NULL;
- char *business = NULL;
GString *s, *s2;
int stripped_len;
#if PHOTO_SUPPORT
@@ -1458,17 +1451,18 @@
return;
}
- tooltip_text = msn_tooltip_info_text(info_data);
- title = _("MSN Profile");
+ user_info = gaim_notify_user_info_new();
+ has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data);
if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0)
{
- g_snprintf(buf, 1024, "
%s%s",
- tooltip_text, _("Error retrieving profile"));
+ tmp = g_strdup_printf("%s", _("Error retrieving profile"));
+ gaim_notify_user_info_add_pair(user_info, NULL, tmp);
+ g_free(tmp);
- gaim_notify_userinfo(info_data->gc, info_data->name, buf, NULL, NULL);
+ gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL);
+ gaim_notify_user_info_destroy(user_info);
- g_free(tooltip_text);
g_free(info_data->name);
g_free(info_data);
return;
@@ -1528,10 +1522,16 @@
/* No we're not. */
s = g_string_sized_new(strlen(url_buffer));
s2 = g_string_sized_new(strlen(url_buffer));
-
+
+ /* General section header */
+ if (has_tooltip_text)
+ gaim_notify_user_info_add_section_break(user_info);
+
+ gaim_notify_user_info_add_section_header(user_info, _("General"));
+
/* Extract their Name and put it in */
- MSN_GOT_INFO_GET_FIELD("Name", _("Name"))
-
+ MSN_GOT_INFO_GET_FIELD("Name", _("Name"));
+
/* General */
MSN_GOT_INFO_GET_FIELD("Nickname", _("Nickname"));
MSN_GOT_INFO_GET_FIELD("Age", _("Age"));
@@ -1540,7 +1540,7 @@
MSN_GOT_INFO_GET_FIELD("Location", _("Location"));
/* Extract their Interests and put it in */
- found = gaim_markup_extract_info_field(stripped, stripped_len, s,
+ found = gaim_markup_extract_info_field(stripped, stripped_len, user_info,
"\nInterests\t", 0, " (/default.aspx?page=searchresults", 0,
"Undisclosed", _("Hobbies and Interests") /* _("Interests") */,
0, NULL, NULL);
@@ -1549,20 +1549,24 @@
sect_info = TRUE;
MSN_GOT_INFO_GET_FIELD("More about me", _("A Little About Me"));
-
+
if (sect_info)
{
- /* trim off the trailing "
\n" */
- g_string_truncate(s, strlen(s->str) - 5);
- g_string_append_printf(s2, _("%sGeneral
%s"),
- (*tooltip_text) ? "
" : "", s->str);
- s = g_string_truncate(s, 0);
has_info = TRUE;
sect_info = FALSE;
}
-
-
+ else
+ {
+ /* Remove the section header */
+ gaim_notify_user_info_remove_last_item(user_info);
+ if (has_tooltip_text)
+ gaim_notify_user_info_remove_last_item(user_info);
+ }
+
/* Social */
+ gaim_notify_user_info_add_section_break(user_info);
+ gaim_notify_user_info_add_section_header(user_info, _("Social"));
+
MSN_GOT_INFO_GET_FIELD("Marital status", _("Marital Status"));
MSN_GOT_INFO_GET_FIELD("Interested in", _("Interests"));
MSN_GOT_INFO_GET_FIELD("Pets", _("Pets"));
@@ -1575,14 +1579,22 @@
if (sect_info)
{
- g_string_append_printf(s2, _("%sSocial
%s"), has_info ? "
" : "", s->str);
- s = g_string_truncate(s, 0);
has_info = TRUE;
sect_info = FALSE;
}
+ else
+ {
+ /* Remove the section header */
+ gaim_notify_user_info_remove_last_item(user_info);
+ gaim_notify_user_info_remove_last_item(user_info);
+ }
/* Contact Info */
/* Personal */
+ gaim_notify_user_info_add_section_break(user_info);
+ gaim_notify_user_info_add_section_header(user_info, _("Contact Info"));
+ gaim_notify_user_info_add_section_header(user_info, _("Personal"));
+
MSN_GOT_INFO_GET_FIELD("Name", _("Name"));
MSN_GOT_INFO_GET_FIELD("Significant other", _("Significant Other"));
MSN_GOT_INFO_GET_FIELD("Home phone", _("Home Phone"));
@@ -1598,13 +1610,18 @@
if (sect_info)
{
- personal = g_strdup_printf(_("
Personal
%s"), s->str);
- s = g_string_truncate(s, 0);
+ has_info = TRUE;
sect_info = FALSE;
- has_info = TRUE;
+ has_contact_info = TRUE;
+ }
+ else
+ {
+ /* Remove the section header */
+ gaim_notify_user_info_remove_last_item(user_info);
}
/* Business */
+ gaim_notify_user_info_add_section_header(user_info, _("Work"));
MSN_GOT_INFO_GET_FIELD("Name", _("Name"));
MSN_GOT_INFO_GET_FIELD("Job title", _("Job Title"));
MSN_GOT_INFO_GET_FIELD("Company", _("Company"));
@@ -1623,27 +1640,22 @@
if (sect_info)
{
- business = g_strdup_printf(_("
Business
%s"), s->str);
- s = g_string_truncate(s, 0);
+ has_info = TRUE;
sect_info = FALSE;
+ has_contact_info = TRUE;
+ }
+ else
+ {
+ /* Remove the section header */
+ gaim_notify_user_info_remove_last_item(user_info);
}
- if ((personal != NULL) || (business != NULL))
+ if (!has_contact_info)
{
- /* trim off the trailing "
\n" */
- g_string_truncate(s, strlen(s->str) - 5);
-
- has_info = TRUE;
- g_string_append_printf(s2, _("
Contact Info%s%s"),
- personal ? personal : "",
- business ? business : "");
+ /* Remove the Contact Info section header */
+ gaim_notify_user_info_remove_last_item(user_info);
}
- g_free(personal);
- g_free(business);
- g_string_free(s, TRUE);
- s = s2;
-
#if 0 /* these probably don't show up any more */
/*
* The fields, 'A Little About Me', 'Favorite Things', 'Hobbies
@@ -1768,12 +1780,9 @@
/* If we were able to fetch a homepage url earlier, stick it in there */
if (user_url != NULL)
{
- g_snprintf(buf, sizeof(buf),
- "%s:
%s
\n",
- _("Homepage"), user_url, user_url);
-
- g_string_append(s, buf);
-
+ tmp = g_strdup_printf("%s", user_url, user_url);
+ gaim_notify_user_info_add_pair(user_info, _("Homepage"), tmp);
+ g_free(tmp);
g_free(user_url);
has_info = TRUE;
@@ -1792,25 +1801,22 @@
char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\"");
GaimBuddy *b = gaim_find_buddy
(gaim_connection_get_account(info_data->gc), info_data->name);
- g_string_append_printf(s, "
%s
%s
",
- _("Error retrieving profile"),
- ((p && b)?
- _("The user has not created a public profile."):
- p? _("MSN reported not being able to find the user's profile. "
- "This either means that the user does not exist, "
- "or that the user exists "
- "but has not created a public profile."):
- _("Gaim could not find " /* This should never happen */
- "any information in the user's profile. "
- "The user most likely does not exist.")));
+ gaim_notify_user_info_add_pair(user_info, _("Error retrieving profile"),
+ ((p && b) ? _("The user has not created a public profile.") :
+ (p ? _("MSN reported not being able to find the user's profile. "
+ "This either means that the user does not exist, "
+ "or that the user exists "
+ "but has not created a public profile.") :
+ _("Gaim could not find " /* This should never happen */
+ "any information in the user's profile. "
+ "The user most likely does not exist."))));
}
+
/* put a link to the actual profile URL */
- g_string_append_printf(s, _("
%s: "), _("Profile URL"));
- g_string_append_printf(s, "
%s%s
",
- PROFILE_URL, info_data->name, PROFILE_URL, info_data->name);
-
- /* Finish it off, and show it to them */
- g_string_append(s, "