# HG changeset patch # User Luke Schierer # Date 1061347531 0 # Node ID 7c14b35bc9846e5a80039660bc2f4bad0b60f0e6 # Parent 785a272be6ce458da87050be6e56a69ec096f16b [gaim-migrate @ 7033] reversed the last yahoo info patch and applied this one instead, which includes msn info support. ChipX86: if this messes you up, tell me and i'll switch it back. committer: Tailor Script diff -r 785a272be6ce -r 7c14b35bc984 src/gtkprefs.c --- a/src/gtkprefs.c Wed Aug 20 01:55:25 2003 +0000 +++ b/src/gtkprefs.c Wed Aug 20 02:45:31 2003 +0000 @@ -538,7 +538,7 @@ /* We'll check this just to make sure. This also lets us do something different on * other platforms, if need be */ - grab_url(name, TRUE, theme_got_url, ".tgz"); + grab_url(name, TRUE, theme_got_url, ".tgz", NULL, 0); } gtk_drag_finish(dc, TRUE, FALSE, t); diff -r 785a272be6ce -r 7c14b35bc984 src/html.c --- a/src/html.c Wed Aug 20 01:55:25 2003 +0000 +++ b/src/html.c Wed Aug 20 02:45:31 2003 +0000 @@ -81,7 +81,7 @@ /* hyphen at end includes it in control set */ char addr_ctrl[] = "A-Za-z0-9.-"; char port_ctrl[] = "0-9"; - char page_ctrl[] = "A-Za-z0-9.~_/&%%?=+^-"; + char page_ctrl[] = "A-Za-z0-9.~_/:*!@&%%?=+^-"; if((turl=strstr(url, "http://")) || (turl=strstr(url, "HTTP://"))) url=turl+=7; @@ -111,6 +111,8 @@ struct g_url *website; char *url; gboolean full; + char *user_agent; + int http11; int inpa; @@ -167,13 +169,14 @@ "Redirecting to %s\n", new_url); /* Try again, with this new location. */ - grab_url(new_url, full, gunk->callback, gunk->data); + grab_url(new_url, full, gunk->callback, gunk->data, gunk->user_agent, gunk->http11); /* Free up. */ g_free(new_url); g_free(gunk->webdata); g_free(gunk->website); g_free(gunk->url); + g_free(gunk->user_agent); g_free(gunk); return TRUE; @@ -201,16 +204,31 @@ gunk->callback(gunk->data, NULL, 0); g_free(gunk->website); g_free(gunk->url); + g_free(gunk->user_agent); g_free(gunk); return; } if (!gunk->sentreq) { - char buf[256]; + char buf[1024]; - g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", gunk->full ? "" : "/", - gunk->full ? gunk->url : gunk->website->page); + if(gunk->user_agent) { + if(gunk->http11) + g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.1\r\nUser-Agent: \"%s\"\r\nHost: %s\r\n\r\n", gunk->full ? "" : "/", + gunk->full ? gunk->url : gunk->website->page, gunk->user_agent, gunk->website->address); + else + g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\nUser-Agent: \"%s\"\r\n\r\n", gunk->full ? "" : "/", + gunk->full ? gunk->url : gunk->website->page, gunk->user_agent); + } + else { + if(gunk->http11) + g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.1\r\nHost: %s\r\n\r\n", gunk->full ? "" : "/", + gunk->full ? gunk->url : gunk->website->page, gunk->website->address); + else + g_snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", gunk->full ? "" : "/", + gunk->full ? gunk->url : gunk->website->page); + } gaim_debug(GAIM_DEBUG_MISC, "grab_url_callback", "Request: %s\n", buf); @@ -288,6 +306,7 @@ g_free(gunk->webdata); g_free(gunk->website); g_free(gunk->url); + g_free(gunk->user_agent); g_free(gunk); } else { gaim_input_remove(gunk->inpa); @@ -297,11 +316,13 @@ g_free(gunk->webdata); g_free(gunk->website); g_free(gunk->url); + g_free(gunk->user_agent); g_free(gunk); } } -void grab_url(char *url, gboolean full, void callback(gpointer, char *, unsigned long), gpointer data) +void grab_url(char *url, gboolean full, void callback(gpointer, char *, unsigned long), + gpointer data, char *user_agent, int http11) { int sock; struct grab_url_data *gunk = g_new0(struct grab_url_data, 1); @@ -309,6 +330,8 @@ gunk->callback = callback; gunk->data = data; gunk->url = g_strdup(url); + gunk->user_agent = (user_agent) ? g_strdup(user_agent) : NULL; + gunk->http11 = http11; gunk->website = parse_url(url); gunk->full = full; @@ -317,6 +340,7 @@ gunk)) < 0) { g_free(gunk->website); g_free(gunk->url); + g_free(gunk->user_agent); g_free(gunk); callback(data, g_strdup(_("g003: Error opening connection.\n")), 0); } diff -r 785a272be6ce -r 7c14b35bc984 src/html.h --- a/src/html.h Wed Aug 20 01:55:25 2003 +0000 +++ b/src/html.h Wed Aug 20 02:45:31 2003 +0000 @@ -31,7 +31,7 @@ void grab_url(char *url, gboolean full, void (*callback)(gpointer, char *, unsigned long), - gpointer data); + gpointer data, char *, int); gchar *strip_html(const gchar *text); void html_to_xhtml(const char *html, char **xhtml_out, char **plain_out); diff -r 785a272be6ce -r 7c14b35bc984 src/protocols/msn/msn.c --- a/src/protocols/msn/msn.c Wed Aug 20 01:55:25 2003 +0000 +++ b/src/protocols/msn/msn.c Wed Aug 20 02:45:31 2003 +0000 @@ -28,6 +28,7 @@ #include "state.h" #include "utils.h" #include "multi.h" +#include "html.h" #define BUDDY_ALIAS_MAXLEN 388 @@ -1157,6 +1158,150 @@ return buf; } +static void +msn_got_info(gpointer data, char *url_text, unsigned long len) +{ + char *stripped,*p,*q; + int count; + char buf[1024]; + char *user_url = NULL; + + if (!url_text || !strcmp(url_text,"")) { + g_show_info_text(NULL, NULL, 2, + "Error retrieving profile", NULL); + return; + } + + /* 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 */ + info_extract_field(stripped, url_text, "\tName", 0, "\t", '\n', + "Undisclosed", "Name", 0, NULL); + + /* extract their Age and put it in */ + info_extract_field(stripped, url_text, "\tAge", 0, "\t", '\n', + "Undisclosed", "Age", 0, NULL); + + /* extract their Gender and put it in */ + info_extract_field(stripped, url_text, "\tGender", 6, "\t", '\n', + "Undisclosed", "Gender", 0, NULL); + + /* extract their MaritalStatus and put it in */ + info_extract_field(stripped, url_text, "\tMaritalStatus", 0, "\t", '\n', + "Undisclosed", "Marital Status", 0, NULL); + + /* extract their Location and put it in */ + info_extract_field(stripped, url_text, "\tLocation", 0, "\t", '\n', + "Undisclosed", "Location", 0, NULL); + + /* extract their Occupation and put it in */ + info_extract_field(stripped, url_text, "\t Occupation", 6, "\t", '\n', + "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. + */ + + /* 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 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); + + /* 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); + + /* 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); + + /* 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) + { + g_snprintf(buf,sizeof(buf),"Home Page:
%s
\n",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); +} + +static void +msn_get_info(GaimConnection *gc, const char *name) +{ + /* MsnSession *session = (MsnSession *)gc->proto_data; */ + char url[256]; + g_snprintf(url, sizeof url, "%s%s", PROFILE_URL, name); + grab_url(url, FALSE, msn_got_info, NULL,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",1); +} + static GaimPluginProtocolInfo prpl_info = { GAIM_PROTO_MSN, @@ -1176,7 +1321,7 @@ msn_send_im, NULL, msn_send_typing, - NULL, + msn_get_info, msn_set_away, NULL, NULL, diff -r 785a272be6ce -r 7c14b35bc984 src/protocols/msn/msn.h --- a/src/protocols/msn/msn.h Wed Aug 20 01:55:25 2003 +0000 +++ b/src/protocols/msn/msn.h Wed Aug 20 02:45:31 2003 +0000 @@ -59,6 +59,7 @@ #define HOTMAIL_URL "http://www.hotmail.com/cgi-bin/folders" #define PASSPORT_URL "http://lc1.law13.hotmail.passport.com/cgi-bin/dologin?login=" +#define PROFILE_URL "http://members.msn.com/" #define USEROPT_HOTMAIL 0 diff -r 785a272be6ce -r 7c14b35bc984 src/protocols/toc/toc.c --- a/src/protocols/toc/toc.c Wed Aug 20 01:55:25 2003 +0000 +++ b/src/protocols/toc/toc.c Wed Aug 20 02:45:31 2003 +0000 @@ -898,7 +898,7 @@ g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, gaim_account_get_int(gc->account, "port", TOC_PORT), url); - grab_url(tmp, FALSE, toc_got_info, NULL); + grab_url(tmp, FALSE, toc_got_info, NULL, NULL, 0); } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { diff -r 785a272be6ce -r 7c14b35bc984 src/protocols/yahoo/yahoo.c --- a/src/protocols/yahoo/yahoo.c Wed Aug 20 01:55:25 2003 +0000 +++ b/src/protocols/yahoo/yahoo.c Wed Aug 20 02:45:31 2003 +0000 @@ -1541,7 +1541,7 @@ /* struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; */ char url[256]; g_snprintf(url, sizeof url, "%s%s", YAHOO_PROFILE_URL, name); - grab_url(url, FALSE, yahoo_got_info, NULL); + grab_url(url, FALSE, yahoo_got_info, NULL, NULL, 0); } static GaimPlugin *my_protocol = NULL;