| 3012 |
3005 |
| 3013 static gboolean yahoo_unload_plugin(GaimPlugin *plugin) |
3006 static gboolean yahoo_unload_plugin(GaimPlugin *plugin) |
| 3014 { |
3007 { |
| 3015 yahoo_dest_colorht(); |
3008 yahoo_dest_colorht(); |
| 3016 return TRUE; |
3009 return TRUE; |
| 3017 } |
|
| 3018 |
|
| 3019 static void yahoo_got_info(void *data, const char *url_text, size_t len) |
|
| 3020 { |
|
| 3021 YahooGetInfoData *info_data = (YahooGetInfoData *)data; |
|
| 3022 char *stripped, *p; |
|
| 3023 char buf[1024]; |
|
| 3024 gboolean found = FALSE; |
|
| 3025 char *url_buffer; |
|
| 3026 GString *s; |
|
| 3027 int stripped_len; |
|
| 3028 |
|
| 3029 gaim_debug_info("yahoo", "In yahoo_got_info\n"); |
|
| 3030 |
|
| 3031 /* we failed to grab the profile URL */ |
|
| 3032 if (url_text == NULL || strcmp(url_text, "") == 0) { |
|
| 3033 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, |
|
| 3034 _("<html><body><b>Error retrieving profile</b></body></html>"), |
|
| 3035 NULL, NULL); |
|
| 3036 |
|
| 3037 g_free(info_data->name); |
|
| 3038 g_free(info_data); |
|
| 3039 return; |
|
| 3040 } |
|
| 3041 |
|
| 3042 /* we don't yet support the multiple link level of the warning page for |
|
| 3043 * 'adult' profiles, not to mention the fact that yahoo wants you to be |
|
| 3044 * logged in (on the website) to be able to view an 'adult' profile. for |
|
| 3045 * now, just tell them that we can't help them, and provide a link to the |
|
| 3046 * profile if they want to do the web browser thing. |
|
| 3047 */ |
|
| 3048 p = strstr(url_text, "Adult Profiles Warning Message"); |
|
| 3049 if (p) { |
|
| 3050 g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>", |
|
| 3051 _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n"), |
|
| 3052 _("If you wish to view this profile, you will need to visit this link in your web browser<br>"), |
|
| 3053 YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name); |
|
| 3054 |
|
| 3055 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, |
|
| 3056 buf, NULL, NULL); |
|
| 3057 |
|
| 3058 g_free(info_data->name); |
|
| 3059 g_free(info_data); |
|
| 3060 return; |
|
| 3061 } |
|
| 3062 |
|
| 3063 /* at the moment we don't support profile pages with languages other than |
|
| 3064 * english. the problem is, that every user may choose his/her own profile |
|
| 3065 * language. this language has nothing to do with the preferences of the |
|
| 3066 * user which looks at the profile |
|
| 3067 */ |
|
| 3068 p = strstr(url_text, "Last Updated:"); |
|
| 3069 if (!p) { |
|
| 3070 p = strstr(url_text, "Last Updated "); |
|
| 3071 } |
|
| 3072 if (!p) { |
|
| 3073 g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>", |
|
| 3074 _("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n"), |
|
| 3075 _("If you wish to view this profile, you will need to visit this link in your web browser<br>"), |
|
| 3076 YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name); |
|
| 3077 |
|
| 3078 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, |
|
| 3079 buf, NULL, NULL); |
|
| 3080 |
|
| 3081 g_free(info_data->name); |
|
| 3082 g_free(info_data); |
|
| 3083 return; |
|
| 3084 } |
|
| 3085 |
|
| 3086 url_buffer = g_strdup(url_text); |
|
| 3087 |
|
| 3088 /* |
|
| 3089 * gaim_markup_strip_html() doesn't strip out character entities like |
|
| 3090 * and · |
|
| 3091 */ |
|
| 3092 while ((p = strstr(url_buffer, " ")) != NULL) { |
|
| 3093 memmove(p, p + 6, strlen(p + 6)); |
|
| 3094 url_buffer[strlen(url_buffer) - 6] = '\0'; |
|
| 3095 } |
|
| 3096 while ((p = strstr(url_buffer, "·")) != NULL) { |
|
| 3097 memmove(p, p + 6, strlen(p + 6)); |
|
| 3098 url_buffer[strlen(url_buffer) - 6] = '\0'; |
|
| 3099 } |
|
| 3100 |
|
| 3101 /* nuke the nasty \r's */ |
|
| 3102 while ((p = strchr(url_buffer, '\r')) != NULL) { |
|
| 3103 memmove(p, p + 1, strlen(p + 1)); |
|
| 3104 url_buffer[strlen(url_buffer) - 1] = '\0'; |
|
| 3105 } |
|
| 3106 |
|
| 3107 /* nuke the html, it's easier than trying to parse the horrid stuff */ |
|
| 3108 stripped = gaim_markup_strip_html(url_buffer); |
|
| 3109 stripped_len = strlen(stripped); |
|
| 3110 |
|
| 3111 gaim_debug_misc("yahoo", "stripped = %p\n", stripped); |
|
| 3112 gaim_debug_misc("yahoo", "url_buffer = %p\n", url_buffer); |
|
| 3113 |
|
| 3114 /* gonna re-use the memory we've already got for url_buffer */ |
|
| 3115 /* no we're not */ |
|
| 3116 s = g_string_sized_new(strlen(url_buffer)); |
|
| 3117 g_string_append(s, "<html><body>\n"); |
|
| 3118 |
|
| 3119 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as |
|
| 3120 * true, since the Yahoo! ID will always be there */ |
|
| 3121 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Yahoo! ID:", 2, "\n", 0, |
|
| 3122 NULL, _("Yahoo! ID"), 0, NULL)) |
|
| 3123 g_string_append_printf(s, "<b>%s:</b> %s<br>", _("Yahoo! ID"), info_data->name); |
|
| 3124 |
|
| 3125 |
|
| 3126 /* extract their Email address and put it in */ |
|
| 3127 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "My Email", 5, "\n", 0, |
|
| 3128 "Private", _("Email"), 0, NULL); |
|
| 3129 |
|
| 3130 /* extract the Nickname if it exists */ |
|
| 3131 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Nickname:", 1, "\n", '\n', |
|
| 3132 NULL, _("Nickname"), 0, NULL); |
|
| 3133 |
|
| 3134 /* extract their RealName and put it in */ |
|
| 3135 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "RealName:", 1, "\n", '\n', |
|
| 3136 NULL, _("Realname"), 0, NULL); |
|
| 3137 |
|
| 3138 /* extract their Location and put it in */ |
|
| 3139 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Location:", 2, "\n", '\n', |
|
| 3140 NULL, _("Location"), 0, NULL); |
|
| 3141 |
|
| 3142 /* extract their Age and put it in */ |
|
| 3143 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Age:", 3, "\n", '\n', |
|
| 3144 NULL, _("Age"), 0, NULL); |
|
| 3145 |
|
| 3146 /* extract their MaritalStatus and put it in */ |
|
| 3147 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "MaritalStatus:", 3, "\n", '\n', |
|
| 3148 "No Answer", _("Marital Status"), 0, NULL); |
|
| 3149 |
|
| 3150 /* extract their Gender and put it in */ |
|
| 3151 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Gender:", 3, "\n", '\n', |
|
| 3152 "No Answer", _("Gender"), 0, NULL); |
|
| 3153 |
|
| 3154 /* extract their Occupation and put it in */ |
|
| 3155 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Occupation:", 2, "\n", '\n', |
|
| 3156 NULL, _("Occupation"), 0, NULL); |
|
| 3157 |
|
| 3158 /* Hobbies, Latest News, and Favorite Quote are a bit different, since the |
|
| 3159 * values can contain embedded newlines... but any or all of them can also |
|
| 3160 * not appear. The way we delimit them is to successively look for the next |
|
| 3161 * one that _could_ appear, and if all else fails, we end the section by |
|
| 3162 * looking for the 'Links' heading, which is the next thing to follow this |
|
| 3163 * bunch. |
|
| 3164 */ |
|
| 3165 |
|
| 3166 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Hobbies:", 1, "Latest News", |
|
| 3167 '\n', NULL, _("Hobbies"), 0, NULL)) |
|
| 3168 { |
|
| 3169 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Hobbies:", 1, "Favorite Quote", |
|
| 3170 '\n', NULL, _("Hobbies"), 0, NULL)) |
|
| 3171 { |
|
| 3172 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Hobbies:", 1, "Links", |
|
| 3173 '\n', NULL, _("Hobbies"), 0, NULL); |
|
| 3174 } |
|
| 3175 else |
|
| 3176 found = TRUE; |
|
| 3177 } |
|
| 3178 else |
|
| 3179 found = TRUE; |
|
| 3180 |
|
| 3181 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, "Latest News:", 1, "Favorite Quote", |
|
| 3182 '\n', NULL, _("Latest News"), 0, NULL)) |
|
| 3183 { |
|
| 3184 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Latest News:", 1, "Links", |
|
| 3185 '\n', NULL, _("Latest News"), 0, NULL); |
|
| 3186 } |
|
| 3187 else |
|
| 3188 found = TRUE; |
|
| 3189 |
|
| 3190 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Favorite Quote:", 0, "Links", |
|
| 3191 '\n', NULL, _("Favorite Quote"), 0, NULL); |
|
| 3192 |
|
| 3193 /* Home Page will either be "No home page specified", |
|
| 3194 * or "Home Page: " and a link. */ |
|
| 3195 p = strstr(stripped, "No home page specified"); |
|
| 3196 if(!p) |
|
| 3197 { |
|
| 3198 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Home Page:", 1, " ", 0, NULL, |
|
| 3199 _("Home Page"), 1, NULL); |
|
| 3200 } |
|
| 3201 |
|
| 3202 /* Cool Link {1,2,3} is also different. If "No cool link specified" exists, |
|
| 3203 * then we have none. If we have one however, we'll need to check and see if |
|
| 3204 * we have a second one. If we have a second one, we have to check to see if |
|
| 3205 * we have a third one. |
|
| 3206 */ |
|
| 3207 p = strstr(stripped,"No cool link specified"); |
|
| 3208 if (!p) |
|
| 3209 { |
|
| 3210 if (gaim_markup_extract_info_field(stripped, stripped_len, s, "Cool Link 1:", 1, " ", 0, NULL, |
|
| 3211 _("Cool Link 1"), 1, NULL)) |
|
| 3212 { |
|
| 3213 found = TRUE; |
|
| 3214 if (gaim_markup_extract_info_field(stripped, stripped_len, s, "Cool Link 2:", 1, " ", 0, NULL, |
|
| 3215 _("Cool Link 2"), 1, NULL)) |
|
| 3216 gaim_markup_extract_info_field(stripped, stripped_len, s, "Cool Link 3:", 1, " ", 0, NULL, |
|
| 3217 _("Cool Link 3"), 1, NULL); |
|
| 3218 } |
|
| 3219 } |
|
| 3220 |
|
| 3221 /* see if Member Since is there, and if so, extract it. */ |
|
| 3222 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Member Since:", 1, "Last Updated:", |
|
| 3223 '\n', NULL, _("Member Since"), 0, NULL); |
|
| 3224 |
|
| 3225 /* extract the Last Updated date and put it in */ |
|
| 3226 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Last Updated:", 1, "\n", '\n', NULL, |
|
| 3227 _("Last Updated"), 0, NULL); |
|
| 3228 |
|
| 3229 /* finish off the html */ |
|
| 3230 g_string_append(s, "</body></html>\n"); |
|
| 3231 g_free(stripped); |
|
| 3232 |
|
| 3233 if(found) |
|
| 3234 { |
|
| 3235 /* show it to the user */ |
|
| 3236 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, |
|
| 3237 s->str, NULL, NULL); |
|
| 3238 } |
|
| 3239 else |
|
| 3240 { |
|
| 3241 char *primary; |
|
| 3242 primary = g_strdup_printf(_("User information for %s unavailable"), info_data->name); |
|
| 3243 gaim_notify_error(info_data->gc, NULL, primary, |
|
| 3244 _("The user's profile is empty.")); |
|
| 3245 g_free(primary); |
|
| 3246 } |
|
| 3247 |
|
| 3248 g_free(url_buffer); |
|
| 3249 g_string_free(s, TRUE); |
|
| 3250 g_free(info_data->name); |
|
| 3251 g_free(info_data); |
|
| 3252 } |
|
| 3253 |
|
| 3254 static void yahoo_get_info(GaimConnection *gc, const char *name) |
|
| 3255 { |
|
| 3256 YahooGetInfoData *data; |
|
| 3257 char *url; |
|
| 3258 |
|
| 3259 data = g_new0(YahooGetInfoData, 1); |
|
| 3260 data->gc = gc; |
|
| 3261 data->name = g_strdup(name); |
|
| 3262 |
|
| 3263 url = g_strdup_printf("%s%s", YAHOO_PROFILE_URL, name); |
|
| 3264 |
|
| 3265 gaim_url_fetch(url, FALSE, NULL, FALSE, yahoo_got_info, data); |
|
| 3266 |
|
| 3267 g_free(url); |
|
| 3268 } |
3010 } |
| 3269 |
3011 |
| 3270 static void yahoo_change_buddys_group(GaimConnection *gc, const char *who, |
3012 static void yahoo_change_buddys_group(GaimConnection *gc, const char *who, |
| 3271 const char *old_group, const char *new_group) |
3013 const char *old_group, const char *new_group) |
| 3272 { |
3014 { |