--- gaim-0.64.orig/src/gaim.h 2003-05-30 18:08:44.000000000 -0500 +++ gaim-0.64/src/gaim.h 2003-06-03 18:32:10.000000000 -0500 @@ -371,6 +371,7 @@ extern gchar *strip_html(const gchar *); extern void html_to_xhtml(const char *, char **, char **); struct g_url *parse_url(char *url); +extern int info_extract_field(char *, char *, char *, int, char *, char, char *, char *, int, char *); /* Functions in idle.c */ extern gint check_idle(gpointer); --- gaim-0.64.orig/src/html.c 2003-05-25 08:53:11.000000000 -0500 +++ gaim-0.64/src/html.c 2003-06-03 18:53:17.000000000 -0500 @@ -627,3 +627,52 @@ g_string_free(xhtml, TRUE); g_string_free(plain, TRUE); } + +int info_extract_field(char *original, char *add_to, char *start_tok, int skip, + char *end_tok, char check_value, char *no_value_tok, char *display_name, + int islink, char *link_prefix) +{ + char *p, *q; + char buf[1024]; + + if (!original || !add_to || !start_tok || + !end_tok || !display_name) + return 0; + + p = strstr(original, start_tok); + if (p) { + p += strlen(start_tok) + skip; + if (!check_value || (*p != check_value)) { + q = strstr(p, end_tok); + if (q && (!no_value_tok || + (no_value_tok && strncmp(p, no_value_tok, strlen(no_value_tok))))) { + strcat(add_to, ""); + strcat(add_to, display_name); + strcat(add_to, ": "); + if (islink) { + strcat(add_to, "
"); + if (link_prefix) + strcat(add_to, link_prefix); + strcat(add_to, buf); + strcat(add_to, ""); + } else { + memcpy(buf, p, q-p); + buf[q-p] = '\0'; + strcat(add_to, buf); + } + strcat(add_to, "
\n"); + return 1; + } else + return 0; + } else + return 0; + } else + return 0; +} + --- gaim-0.64.orig/src/protocols/yahoo/yahoo.c 2003-05-25 20:46:58.000000000 -0500 +++ gaim-0.64/src/protocols/yahoo/yahoo.c 2003-06-03 19:07:45.000000000 -0500 @@ -1419,6 +1419,160 @@ yahoo_packet_free(pkt); } +static void yahoo_got_info(gpointer data, char *url_text, unsigned long len) +{ + char *stripped,*p; + char buf[1024]; + + if (!url_text) { + g_show_info_text(NULL, NULL, 2, + "Error retrieving profile", NULL); + return; + } + + /* we don't yet support the multiple link level of the warning page for + * 'adult' profiles, not to mention the fact that yahoo wants you to be + * logged in (on the website) to be able to view an 'adult' profile. for + * now, just tell them that we can't help them, and provide a link to the + * profile if they want to do the web browser thing. + */ + p = strstr(url_text, "Adult Profiles Warning Message"); + if (p) { + strcpy(buf, "Sorry, profiles marked as containing adult content are "); + strcat(buf, "not supported at this time.

\n"); + + info_extract_field(url_text, buf, ".idname=", 0, "%26", 0, NULL, + "If you wish to view this profile, you will need to visit this link in your web browser", + 1, YAHOO_PROFILE_URL); + + strcat(buf, "\n"); + g_show_info_text(NULL, NULL, 2, buf, NULL); + return; + } + + /* strip_html() doesn't strip out character entities like   and · + */ + while ((p = strstr(url_text, " ")) != NULL) { + memmove(p, p + 6, strlen(p + 6)); + url_text[strlen(url_text) - 6] = '\0'; + } + while ((p = strstr(url_text, "·")) != NULL) { + memmove(p, p + 6, strlen(p + 6)); + url_text[strlen(url_text) - 6] = '\0'; + } + /* nuke the nasty \r's */ + while ((p = strchr(url_text, '\r')) != NULL) { + memmove(p, p + 1, strlen(p + 1)); + url_text[strlen(url_text) - 1] = '\0'; + } + + /* nuke the html, it's easier than trying to parse the horrid stuff */ + stripped = strip_html(url_text); + + /* gonna re-use the memory we've already got for url_text */ + strcpy(url_text, "\n"); + + /* extract their Yahoo! ID and put it in */ + info_extract_field(stripped, url_text, "Yahoo! ID:", 2, "\n", 0, + NULL, "Yahoo! ID", 0, NULL); + + /* extract their Email address and put it in */ + info_extract_field(stripped, url_text, "My Email", 5, "\n", 0, + "Private", "Email", 0, NULL); + + /* extract the Nickname if it exists */ + info_extract_field(stripped, url_text, "Nickname:", 1, "\n", '\n', + NULL, "Nickname", 0, NULL); + + /* extract their RealName and put it in */ + info_extract_field(stripped, url_text, "RealName:", 1, "\n", '\n', + NULL, "Real Name", 0, NULL); + + /* extract their Location and put it in */ + info_extract_field(stripped, url_text, "Location:", 2, "\n", '\n', + NULL, "Location", 0, NULL); + + /* extract their Age and put it in */ + info_extract_field(stripped, url_text, "Age:", 3, "\n", '\n', + NULL, "Age", 0, NULL); + + /* extract their MaritalStatus and put it in */ + info_extract_field(stripped, url_text, "MaritalStatus:", 3, "\n", '\n', + "No Answer", "Marital Status", 0, NULL); + + /* extract their Gender and put it in */ + info_extract_field(stripped, url_text, "Gender:", 3, "\n", '\n', + "No Answer", "Gender", 0, NULL); + + /* extract their Occupation and put it in */ + info_extract_field(stripped, url_text, "Occupation:", 2, "\n", '\n', + NULL, "Occupation", 0, NULL); + + /* Hobbies, Latest News, and Favorite Quote are a bit different, since the + * values can contain embedded newlines... but any or all of them can also + * not appear. The way we delimit them is to successively look for the next + * one that _could_ appear, and if all else fails, we end the section by + * looking for the 'Links' heading, which is the next thing to follow this + * bunch. + */ + if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Latest News", + '\n', NULL, "Hobbies", 0, NULL)) + if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Favorite Quote", + '\n', NULL, "Hobbies", 0, NULL)) + info_extract_field(stripped, url_text, "Hobbies:", 1, "Links", + '\n', NULL, "Hobbies", 0, NULL); + + if (!info_extract_field(stripped, url_text, "Latest News:", 1, "Favorite Quote", + '\n', NULL, "Latest News", 0, NULL)) + info_extract_field(stripped, url_text, "Latest News:", 1, "Links", + '\n', NULL, "Latest News", 0, NULL); + + info_extract_field(stripped, url_text, "Favorite Quote:", 0, "Links", + '\n', NULL, "Favorite Quote", 0, NULL); + + /* Home Page will either be "No home page specified", + * or "Home Page: " and a link. */ + p = strstr(stripped, "No home page specified"); + if (!p) + info_extract_field(stripped, url_text, "Home Page:", 1, " ", 0, NULL, + "Home Page", 1, NULL); + + /* Cool Link {1,2,3} is also different. If "No cool link specified" exists, + * then we have none. If we have one however, we'll need to check and see if + * we have a second one. If we have a second one, we have to check to see if + * we have a third one. + */ + p = strstr(stripped,"No cool link specified"); + if (!p) + if (info_extract_field(stripped, url_text, "Cool Link 1:", 1, " ", 0, NULL, + "Cool Link 1", 1, NULL)) + if (info_extract_field(stripped, url_text, "Cool Link 2:", 1, " ", 0, NULL, + "Cool Link 2", 1, NULL)) + info_extract_field(stripped, url_text, "Cool Link 3:", 1, " ", 0, NULL, + "Cool Link 3", 1, NULL); + + /* see if Member Since is there, and if so, extract it. */ + info_extract_field(stripped, url_text, "Member Since:", 1, "Last Updated:", + '\n', NULL, "Member Since", 0, NULL); + + /* extract the Last Updated date and put it in */ + info_extract_field(stripped, url_text, "Last Updated:", 1, "\n", '\n', NULL, + "Last Updated", 0, NULL); + + strcat(url_text, "\n"); + g_free(stripped); + + g_show_info_text(NULL, NULL, 2, url_text, NULL); +} + +static void yahoo_get_info(struct gaim_connection *gc, const char *name) +{ + /* 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); +} + static GaimPlugin *my_protocol = NULL; #if 0 @@ -1489,7 +1643,7 @@ yahoo_send_im, NULL, yahoo_send_typing, - NULL, + yahoo_get_info, yahoo_set_away, NULL, NULL,