# HG changeset patch # User Christian Hammond # Date 1063685639 0 # Node ID 17514a2f976a97d38f9d9fcf536ed6dbc98e2a24 # Parent 885c6528843b0d79e538cb861d40cd7c665921eb [gaim-migrate @ 7404] The old MSN Get Info code was messy, and I'm a neat-freak when it comes to code. committer: Tailor Script diff -r 885c6528843b -r 17514a2f976a src/protocols/msn/msn.c --- a/src/protocols/msn/msn.c Tue Sep 16 03:56:54 2003 +0000 +++ b/src/protocols/msn/msn.c Tue Sep 16 04:13:59 2003 +0000 @@ -1193,132 +1193,209 @@ static void msn_got_info(gpointer data, char *url_text, unsigned long len) { - char *stripped,*p,*q; + char *stripped, *p, *q; char buf[1024]; char *user_url = NULL; + gboolean found; - if (!url_text || !strcmp(url_text,"")) { + if (url_text == NULL || strcmp(url_text,"") == 0) + { g_show_info_text(NULL, NULL, 2, - _("Error retrieving profile"), NULL); + _("Error retrieving profile"), + NULL); + return; } - /* if they have a homepage link, MSN masks it such that we need to + /* If they have a homepage link, MSN masks it such that we need to * fetch the url out before strip_html() nukes it */ - if((p = strstr(url_text, "Take a look at my \n"); - /* extract their Name and put it in */ + /* Extract their Name and put it in */ info_extract_field(stripped, url_text, "\tName", 0, "\t", '\n', - "Undisclosed", _("Name"), 0, NULL); + "Undisclosed", _("Name"), 0, NULL); - /* extract their Age and put it in */ + /* Extract their Age and put it in */ info_extract_field(stripped, url_text, "\tAge", 0, "\t", '\n', - "Undisclosed", _("Age"), 0, NULL); + "Undisclosed", _("Age"), 0, NULL); - /* extract their Gender and put it in */ + /* Extract their Gender and put it in */ info_extract_field(stripped, url_text, "\tGender", 6, "\t", '\n', - "Undisclosed", _("Gender"), 0, NULL); + "Undisclosed", _("Gender"), 0, NULL); - /* extract their MaritalStatus and put it in */ + /* Extract their MaritalStatus and put it in */ info_extract_field(stripped, url_text, "\tMaritalStatus", 0, "\t", '\n', - "Undisclosed", _("Marital Status"), 0, NULL); + "Undisclosed", _("Marital Status"), 0, NULL); - /* extract their Location and put it in */ + /* Extract their Location and put it in */ info_extract_field(stripped, url_text, "\tLocation", 0, "\t", '\n', - "Undisclosed", _("Location"), 0, NULL); + "Undisclosed", _("Location"), 0, NULL); - /* extract their Occupation and put it in */ + /* Extract their Occupation and put it in */ info_extract_field(stripped, url_text, "\t Occupation", 6, "\t", '\n', - "Undisclosed", _("Occupation"), 0, NULL); + "Undisclosed", _("Occupation"), 0, NULL); - /* the fields, 'A Little About Me', 'Favorite Things', 'Hobbies and Interests', - * 'Favorite Quote', and 'My Homepage' may or may not appear, in any combination. - * however, they do appear in certain order, so we can successively search to - * pin down the distinct values. + /* + * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies + * and Interests', 'Favorite Quote', and 'My Homepage' may or may + * not appear, in any combination. However, they do appear in + * certain order, so we can successively search to pin down the + * distinct values. */ - /* check if they have A Little About Me */ - if(!info_extract_field(stripped, url_text, "\tA Little About Me", 1, "Favorite Things", '\n', - NULL, _("A Little About Me"), 0, NULL)) - if(!info_extract_field(stripped, url_text, "\tA Little About Me", 1, "Hobbies and Interests", '\n', - NULL, _("A Little About Me"), 0, NULL)) - if(!info_extract_field(stripped, url_text, "\tA Little About Me", 1, "Favorite Quote", '\n', - NULL, _("A Little About Me"), 0, NULL)) - if(!info_extract_field(stripped, url_text, "\tA Little About Me", 1, "My Homepage\tTake a look", '\n', - NULL, _("A Little About Me"), 0, NULL)) - info_extract_field(stripped, url_text, "\tA Little About Me", 1, "last updated", '\n', - NULL, _("A Little About Me"), 0, NULL); + /* Check if they have A Little About Me */ + found = info_extract_field(stripped, url_text, "\tA Little About Me", + 1, "Favorite Things", '\n', NULL, + _("A Little About Me"), 0, NULL); - /* check if they have Favorite Things */ - if(!info_extract_field(stripped, url_text, "Favorite Things", 1, "Hobbies and Interests", '\n', - NULL, _("Favorite Things"), 0, NULL)) - if(!info_extract_field(stripped, url_text, "Favorite Things", 1, "Favorite Quote", '\n', - NULL, "Favorite Things", 0, NULL)) - if(info_extract_field(stripped, url_text, "Favorite Things", 1, "My Homepage\tTake a look", '\n', - NULL, _("Favorite Things"), 0, NULL)) - info_extract_field(stripped, url_text, "Favorite Things", 1, "last updated", '\n', - NULL, _("Favorite Things"), 0, NULL); + if (!found) + { + found = info_extract_field(stripped, url_text, + "\tA Little About Me", 1, + "Hobbies and Interests", '\n', NULL, + _("A Little About Me"), 0, NULL); + } + + if (!found) + { + found = info_extract_field(stripped, url_text, + "\tA Little About Me", 1, + "Favorite Quote", '\n', NULL, + _("A Little About Me"), 0, NULL); + } - /* check if they have Hobbies and Interests */ - if(!info_extract_field(stripped, url_text, "Hobbies and Interests", 1, "Favorite Quote", '\n', - NULL, _("Hobbies and Interests"), 0, NULL)) - if(info_extract_field(stripped, url_text, "Hobbies and Interests", 1, "My Homepage\tTake a look", '\n', - NULL, _("Hobbies and Interests"), 0, NULL)) - info_extract_field(stripped, url_text, "Hobbies and Interests", 1, "last updated", '\n', - NULL, _("Hobbies and Interests"), 0, NULL); + if (!found) + { + found = info_extract_field(stripped, url_text, + "\tA Little About Me", 1, + "My Homepage\tTake a look", '\n', NULL, + _("A Little About Me"), 0, NULL); + } + + if (!found) + { + info_extract_field(stripped, url_text, "\tA Little About Me", 1, + "last updated", '\n', + NULL, _("A Little About Me"), 0, NULL); + } - /* check if they have Favorite Quote */ - if(!info_extract_field(stripped, url_text, "Favorite Quote", 1, "My Homepage\tTake a look", '\n', - NULL, _("Favorite Quote"), 0, NULL)) - info_extract_field(stripped, url_text, "Favorite Quote", 1, "last updated", '\n', - NULL, _("Favorite Quote"), 0, NULL); + /* Check if they have Favorite Things */ + found = info_extract_field(stripped, url_text, "Favorite Things", 1, + "Hobbies and Interests", '\n', NULL, + _("Favorite Things"), 0, NULL); - /* extract the last updated date and put it in */ - info_extract_field(stripped, url_text, "\tlast updated:", 1, "\n", '\n', - NULL, _("Last Updated"), 0, NULL); + if (!found) + { + found = info_extract_field(stripped, url_text, "Favorite Things", 1, + "Favorite Quote", '\n', NULL, + "Favorite Things", 0, NULL); + } - /* if we were able to fetch a homepage url earlier, stick it in there */ - if(user_url) + if (!found) { - g_snprintf(buf,sizeof(buf),"%s:
%s
\n",_("Homepage"),user_url,user_url); - strcat(url_text,buf); + found = info_extract_field(stripped, url_text, "Favorite Things", 1, + "My Homepage\tTake a look", '\n', NULL, + _("Favorite Things"), 0, NULL); } - /* finish it off, and show it to them */ + if (!found) + { + info_extract_field(stripped, url_text, "Favorite Things", 1, + "last updated", '\n', NULL, + _("Favorite Things"), 0, NULL); + } + + /* Check if they have Hobbies and Interests */ + found = info_extract_field(stripped, url_text, "Hobbies and Interests", + 1, "Favorite Quote", '\n', NULL, + _("Hobbies and Interests"), 0, NULL); + + if (!found) + { + found = info_extract_field(stripped, url_text, + "Hobbies and Interests", 1, + "My Homepage\tTake a look", '\n', NULL, + _("Hobbies and Interests"), 0, NULL); + } + + if (!found) + { + info_extract_field(stripped, url_text, "Hobbies and Interests", + 1, "last updated", '\n', NULL, + _("Hobbies and Interests"), 0, NULL); + } + + /* Check if they have Favorite Quote */ + found = info_extract_field(stripped, url_text, "Favorite Quote", 1, + "My Homepage\tTake a look", '\n', NULL, + _("Favorite Quote"), 0, NULL); + + if (!found) + { + info_extract_field(stripped, url_text, "Favorite Quote", 1, + "last updated", '\n', NULL, + _("Favorite Quote"), 0, NULL); + } + + /* Extract the last updated date and put it in */ + info_extract_field(stripped, url_text, "\tlast updated:", 1, "\n", '\n', + NULL, _("Last Updated"), 0, NULL); + + /* 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); + + strcat(url_text, buf); + } + + /* Finish it off, and show it to them */ strcat(url_text, "\n"); g_show_info_text(NULL, NULL, 2, url_text, NULL); g_free(stripped);