From: Tim R. <ma...@us...> - 2004-06-02 00:45:00
|
Update of /cvsroot/gaim/gaim/src/protocols/yahoo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30536/src/protocols/yahoo Modified Files: Makefile.am yahoo.c yahoo.h Log Message: wing added support for yahoo profiles in, well pretty much every language. Looks pretty impressive to me. Someone may want to double check his src/util.c changes. I think we have some crazy patch writers who know those functions better than me. This also introduces a couple of warning because wing didn't add his new util.c function to util.h. Rather than adding it myself, I'm going to bug him to add it and document it. Index: Makefile.am =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/yahoo/Makefile.am,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -p -r1.21 -r1.22 --- Makefile.am 27 Feb 2004 00:24:20 -0000 1.21 +++ Makefile.am 2 Jun 2004 00:44:51 -0000 1.22 @@ -13,7 +13,8 @@ YAHOOSOURCES = \ yahoochat.c \ util.c \ yahoo_filexfer.h \ - yahoo_filexfer.c + yahoo_filexfer.c \ + yahoo_profile.c AM_CFLAGS = $(st) Index: yahoo.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/yahoo/yahoo.c,v retrieving revision 1.231 retrieving revision 1.232 diff -u -d -p -r1.231 -r1.232 --- yahoo.c 25 May 2004 23:18:00 -0000 1.231 +++ yahoo.c 2 Jun 2004 00:44:51 -0000 1.232 @@ -43,13 +43,6 @@ extern char *yahoo_crypt(const char *, const char *); -typedef struct -{ - GaimConnection *gc; - char *name; -} YahooGetInfoData; - - /* #define YAHOO_DEBUG */ static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *); @@ -3016,257 +3009,6 @@ static gboolean yahoo_unload_plugin(Gaim return TRUE; } -static void yahoo_got_info(void *data, const char *url_text, size_t len) -{ - YahooGetInfoData *info_data = (YahooGetInfoData *)data; - char *stripped, *p; - char buf[1024]; - gboolean found = FALSE; - char *url_buffer; - GString *s; - int stripped_len; - - gaim_debug_info("yahoo", "In yahoo_got_info\n"); - - /* we failed to grab the profile URL */ - if (url_text == NULL || strcmp(url_text, "") == 0) { - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, - _("<html><body><b>Error retrieving profile</b></body></html>"), - NULL, NULL); - - g_free(info_data->name); - g_free(info_data); - 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) { - g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>", - _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n"), - _("If you wish to view this profile, you will need to visit this link in your web browser<br>"), - YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name); - - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, - buf, NULL, NULL); - - g_free(info_data->name); - g_free(info_data); - return; - } - - /* at the moment we don't support profile pages with languages other than - * english. the problem is, that every user may choose his/her own profile - * language. this language has nothing to do with the preferences of the - * user which looks at the profile - */ - p = strstr(url_text, "Last Updated:"); - if (!p) { - p = strstr(url_text, "Last Updated "); - } - if (!p) { - g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>", - _("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n"), - _("If you wish to view this profile, you will need to visit this link in your web browser<br>"), - YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name); - - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, - buf, NULL, NULL); - - g_free(info_data->name); - g_free(info_data); - return; - } - - url_buffer = g_strdup(url_text); - - /* - * gaim_markup_strip_html() doesn't strip out character entities like - * and · - */ - while ((p = strstr(url_buffer, " ")) != NULL) { - memmove(p, p + 6, strlen(p + 6)); - url_buffer[strlen(url_buffer) - 6] = '\0'; - } - while ((p = strstr(url_buffer, "·")) != NULL) { - memmove(p, p + 6, strlen(p + 6)); - url_buffer[strlen(url_buffer) - 6] = '\0'; - } - - /* nuke the nasty \r's */ - while ((p = strchr(url_buffer, '\r')) != NULL) { - memmove(p, p + 1, strlen(p + 1)); - url_buffer[strlen(url_buffer) - 1] = '\0'; - } - - /* nuke the html, it's easier than trying to parse the horrid stuff */ - stripped = gaim_markup_strip_html(url_buffer); - stripped_len = strlen(stripped); - - gaim_debug_misc("yahoo", "stripped = %p\n", stripped); - gaim_debug_misc("yahoo", "url_buffer = %p\n", url_buffer); - - /* gonna re-use the memory we've already got for url_buffer */ - /* no we're not */ - s = g_string_sized_new(strlen(url_buffer)); - g_string_append(s, "<html><body>\n"); - - /* extract their Yahoo! ID and put it in. Don't bother marking has_info as - * true, since the Yahoo! ID will always be there */ - if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Yahoo! ID:", 2, "\n", 0, - NULL, _("Yahoo! ID"), 0, NULL)) - g_string_append_printf(s, "<b>%s:</b> %s<br>", _("Yahoo! ID"), info_data->name); - - - /* extract their Email address and put it in */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "My Email", 5, "\n", 0, - "Private", _("Email"), 0, NULL); - - /* extract the Nickname if it exists */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Nickname:", 1, "\n", '\n', - NULL, _("Nickname"), 0, NULL); - - /* extract their RealName and put it in */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "RealName:", 1, "\n", '\n', - NULL, _("Realname"), 0, NULL); - - /* extract their Location and put it in */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Location:", 2, "\n", '\n', - NULL, _("Location"), 0, NULL); - - /* extract their Age and put it in */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Age:", 3, "\n", '\n', - NULL, _("Age"), 0, NULL); - - /* extract their MaritalStatus and put it in */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "MaritalStatus:", 3, "\n", '\n', - "No Answer", _("Marital Status"), 0, NULL); - - /* extract their Gender and put it in */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Gender:", 3, "\n", '\n', - "No Answer", _("Gender"), 0, NULL); - - /* extract their Occupation and put it in */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "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 (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Hobbies:", 1, "Latest News", - '\n', NULL, _("Hobbies"), 0, NULL)) - { - if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Hobbies:", 1, "Favorite Quote", - '\n', NULL, _("Hobbies"), 0, NULL)) - { - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Hobbies:", 1, "Links", - '\n', NULL, _("Hobbies"), 0, NULL); - } - else - found = TRUE; - } - else - found = TRUE; - - if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Latest News:", 1, "Favorite Quote", - '\n', NULL, _("Latest News"), 0, NULL)) - { - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Latest News:", 1, "Links", - '\n', NULL, _("Latest News"), 0, NULL); - } - else - found = TRUE; - - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "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) - { - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "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 (gaim_markup_extract_info_field(stripped, stripped_len, s, "Cool Link 1:", 1, " ", 0, NULL, - _("Cool Link 1"), 1, NULL)) - { - found = TRUE; - if (gaim_markup_extract_info_field(stripped, stripped_len, s, "Cool Link 2:", 1, " ", 0, NULL, - _("Cool Link 2"), 1, NULL)) - gaim_markup_extract_info_field(stripped, stripped_len, s, "Cool Link 3:", 1, " ", 0, NULL, - _("Cool Link 3"), 1, NULL); - } - } - - /* see if Member Since is there, and if so, extract it. */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Member Since:", 1, "Last Updated:", - '\n', NULL, _("Member Since"), 0, NULL); - - /* extract the Last Updated date and put it in */ - found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Last Updated:", 1, "\n", '\n', NULL, - _("Last Updated"), 0, NULL); - - /* finish off the html */ - g_string_append(s, "</body></html>\n"); - g_free(stripped); - - if(found) - { - /* show it to the user */ - gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, - s->str, NULL, NULL); - } - else - { - char *primary; - primary = g_strdup_printf(_("User information for %s unavailable"), info_data->name); - gaim_notify_error(info_data->gc, NULL, primary, - _("The user's profile is empty.")); - g_free(primary); - } - - g_free(url_buffer); - g_string_free(s, TRUE); - g_free(info_data->name); - g_free(info_data); -} - -static void yahoo_get_info(GaimConnection *gc, const char *name) -{ - YahooGetInfoData *data; - char *url; - - data = g_new0(YahooGetInfoData, 1); - data->gc = gc; - data->name = g_strdup(name); - - url = g_strdup_printf("%s%s", YAHOO_PROFILE_URL, name); - - gaim_url_fetch(url, FALSE, NULL, FALSE, yahoo_got_info, data); - - g_free(url); -} - static void yahoo_change_buddys_group(GaimConnection *gc, const char *who, const char *old_group, const char *new_group) { Index: yahoo.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/yahoo/yahoo.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -p -r1.15 -r1.16 --- yahoo.h 25 May 2004 22:43:29 -0000 1.15 +++ yahoo.h 2 Jun 2004 00:44:51 -0000 1.16 @@ -225,4 +225,7 @@ char *yahoo_string_encode(GaimConnection */ char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8); +/* yahoo_profile.c */ +void yahoo_get_info(GaimConnection *gc, const char *name); + #endif /* _YAHOO_H_ */ |