# HG changeset patch # User Stu Tomlinson # Date 1141394743 0 # Node ID b6772b3209c4a7e126d5ff1c3a30522314d9c5ea # Parent 0a8b72b12cef86fd57cec447464b54b34b422e24 [gaim-migrate @ 15762] Working parsing for the new MSN profiles. Much of this is #if 0'd out as it adds new strings - someone should remind me to undo that when we've thawed. committer: Tailor Script diff -r 0a8b72b12cef -r b6772b3209c4 src/protocols/msn/msn.c --- a/src/protocols/msn/msn.c Fri Mar 03 08:45:59 2006 +0000 +++ b/src/protocols/msn/msn.c Fri Mar 03 14:05:43 2006 +0000 @@ -1395,23 +1395,20 @@ char *p; char *it = NULL; - p = strstr(url_text, " title=\"Click to see the full-size photo.\">"); + if ((p = strstr(url_text, " contactparams:photopreauthurl=")) != NULL) + { + p += strlen(" contactparams:photopreauthurl="); + } - if (p) + if (p && (strncmp(p, "\"http://", 8) == 0)) { - /* Search backwards for "http://". This is stupid, but it works. */ - for (; !it && p > url_text; p -= 1) + char *q; + p += 1; /* skip only the " */ + q = strchr(p, '"'); + + if (q) { - if (strncmp(p, "\"http://", 8) == 0) - { - char *q; - p += 1; /* skip only the " */ - q = strchr(p, '"'); - if (q) - { - it = g_strndup(p, q - p); - } - } + it = g_strndup(p, q - p); } } @@ -1422,6 +1419,7 @@ #endif +#if 0 static char *msn_info_date_reformat(const char *field, size_t len) { char *tmp = g_strndup(field, len); @@ -1430,6 +1428,13 @@ g_free(tmp); return g_strdup(gaim_date_format_short(localtime(&t))); } +#endif + +#define MSN_GOT_INFO_GET_FIELD(a, b) \ + found = gaim_markup_extract_info_field(stripped, stripped_len, s, \ + "\n" a "\t", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \ + if (found) \ + sect_info = TRUE; static void msn_got_info(void *data, const char *url_text, size_t len) @@ -1441,9 +1446,14 @@ char *user_url = NULL; gboolean found; gboolean has_info = FALSE; + gboolean sect_info = FALSE; const char* title = NULL; char *url_buffer; - GString *s; +#if 0 /* XXX: undo this when strings have thawed */ + char *personal = NULL; + char *business = NULL; +#endif + GString *s, *s2; int stripped_len; #if PHOTO_SUPPORT char *photo_url_text = NULL; @@ -1470,6 +1480,7 @@ /* If they have a homepage link, MSN masks it such that we need to * fetch the url out before gaim_markup_strip_html() nukes it */ + /* I don't think this works with the new spaces profiles - Stu 3/2/06 */ if ((p = strstr(url_text, "Take a look at my */ + g_string_truncate(s, strlen(s->str) - 4); +#if 0 /* XXX: undo this when strings have thawed */ + g_string_append_printf(s2, _("%sGeneral
%s"), (tooltip_text != NULL) ? "
" : "", s->str); +#else + g_string_append(s2, s->str); +#endif + s = g_string_truncate(s, 0); has_info = TRUE; + sect_info = FALSE; + } + + /* Social */ + MSN_GOT_INFO_GET_FIELD("Marital status", _("Marital Status")); +#if 0 /* XXX: undo this when strings have thawed */ + MSN_GOT_INFO_GET_FIELD("Interested in", _("Interested in")); + MSN_GOT_INFO_GET_FIELD("Pets", _("Pets")); + MSN_GOT_INFO_GET_FIELD("Hometown", _("Hometown")); + MSN_GOT_INFO_GET_FIELD("Places lived", _("Places lived")); + MSN_GOT_INFO_GET_FIELD("Fashion", _("Fashion")); + MSN_GOT_INFO_GET_FIELD("Humor", _("Humor")); + MSN_GOT_INFO_GET_FIELD("Music", _("Music")); +#endif + MSN_GOT_INFO_GET_FIELD("Favorite quote", _("Favorite Quote")); + + if (sect_info) + { +#if 0 /* XXX: undo this when strings have thawed */ + g_string_append_printf(s2, _("%sSocial
%s"), has_info ? "

" : "", s->str); +#else + g_string_append_printf(s2, "%s%s", has_info ? "

" : "", s->str); +#endif + s = g_string_truncate(s, 0); + has_info = TRUE; + sect_info = FALSE; + } + +#if 0 /* XXX: undo this when strings have thawed */ + /* Contact 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")); + MSN_GOT_INFO_GET_FIELD("Home phone 2", _("Home phone 2")); + MSN_GOT_INFO_GET_FIELD("Home address", _("Home address")); + MSN_GOT_INFO_GET_FIELD("Personal Mobile", _("Personal Mobile")); + MSN_GOT_INFO_GET_FIELD("Home fax", _("Home fax")); + MSN_GOT_INFO_GET_FIELD("Personal e-mail", _("Personal e-mail")); + MSN_GOT_INFO_GET_FIELD("Personal IM", _("Personal IM")); + MSN_GOT_INFO_GET_FIELD("Birthday", _("Birthday")); + MSN_GOT_INFO_GET_FIELD("Anniversary", _("Anniversary")); + MSN_GOT_INFO_GET_FIELD("Notes", _("Notes")); + + if (sect_info) + { + personal = g_strdup_printf(_("
Personal
%s"), s->str); + s = g_string_truncate(s, 0); + sect_info = FALSE; + } + + /* Business */ + MSN_GOT_INFO_GET_FIELD("Name", _("Name")); + MSN_GOT_INFO_GET_FIELD("Job title", _("Job title")); + MSN_GOT_INFO_GET_FIELD("Company", _("Company")); + MSN_GOT_INFO_GET_FIELD("Department", _("Department")); + MSN_GOT_INFO_GET_FIELD("Profession", _("Profession")); + MSN_GOT_INFO_GET_FIELD("Work phone 1", _("Work phone 1")); + MSN_GOT_INFO_GET_FIELD("Work phone 2", _("Work phone 2")); + MSN_GOT_INFO_GET_FIELD("Work address", _("Work address")); + MSN_GOT_INFO_GET_FIELD("Work mobile", _("Work mobile")); + MSN_GOT_INFO_GET_FIELD("Work pager", _("Work pager")); + MSN_GOT_INFO_GET_FIELD("Work fax", _("Work fax")); + MSN_GOT_INFO_GET_FIELD("Work e-mail", _("Work e-mail")); + MSN_GOT_INFO_GET_FIELD("Work IM", _("Work IM")); + MSN_GOT_INFO_GET_FIELD("Start date", _("Start date")); + MSN_GOT_INFO_GET_FIELD("Notes", _("Notes")); + + if (sect_info) + { + business = g_strdup_printf(_("
Business
%s"), s->str); + s = g_string_truncate(s, 0); + sect_info = FALSE; + } + + if ((personal != NULL) || (business != NULL)) + { + /* trim off the trailing
*/ + g_string_truncate(s2, strlen(s2->str) - 4); + has_info = TRUE; + g_string_append_printf(s2, _("%sContact Info%s%s"), + has_info ? "
" : "", + personal ? personal : "", + business ? business : ""); + } + + g_free(personal); + g_free(business); +#endif + 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 * and Interests', 'Favorite Quote', and 'My Homepage' may or may @@ -1683,6 +1777,7 @@ if (found) has_info = TRUE; +#endif /* If we were able to fetch a homepage url earlier, stick it in there */ if (user_url != NULL) @@ -1705,7 +1800,10 @@ * Note that if we have a nonempty tooltip_text, we know the user * exists. */ + /* This doesn't work with the new spaces profiles - Stu 3/2/06 char *p = strstr(url_buffer, "Unknown Member "); + * This might not work for long either ... */ + 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

", @@ -1720,9 +1818,13 @@ "any information in the user's profile. " "The user most likely does not exist."))); } - /* put a link to the actual profile URL */ +#if 0 /* XXX: undo when strings thawed */ + g_string_append_printf(s, _("
%s: "), _("Profile URL")); +#else + g_string_append(s, "
"); g_string_append_printf(s, _("%s: "), _("Profile URL")); +#endif g_string_append_printf(s, "
%s%s
", PROFILE_URL, info_data->name, PROFILE_URL, info_data->name);