| 1 | Index: trunk/src/nateon.c |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- trunk/src/nateon.c (revision 143) |
|---|
| 4 | +++ trunk/src/nateon.c (working copy) |
|---|
| 5 | @@ -59,25 +59,24 @@ |
|---|
| 6 | |
|---|
| 7 | } NateonSendData; |
|---|
| 8 | |
|---|
| 9 | -//typedef struct |
|---|
| 10 | -//{ |
|---|
| 11 | -// PurpleConnection *gc; |
|---|
| 12 | -// char *name; |
|---|
| 13 | -// |
|---|
| 14 | -//} NateonGetInfoData; |
|---|
| 15 | -// |
|---|
| 16 | -//typedef struct |
|---|
| 17 | -//{ |
|---|
| 18 | -// NateonGetInfoData *info_data; |
|---|
| 19 | -// char *stripped; |
|---|
| 20 | -// char *url_buffer; |
|---|
| 21 | -// GString *s; |
|---|
| 22 | -// char *photo_url_text; |
|---|
| 23 | -// char *tooltip_text; |
|---|
| 24 | -// const char *title; |
|---|
| 25 | -// |
|---|
| 26 | -//} NateonGetInfoStepTwoData; |
|---|
| 27 | +typedef struct |
|---|
| 28 | +{ |
|---|
| 29 | + PurpleConnection *gc; |
|---|
| 30 | + char *name; |
|---|
| 31 | + const char *ID; |
|---|
| 32 | +} NateonGetInfoData; |
|---|
| 33 | |
|---|
| 34 | +typedef struct |
|---|
| 35 | +{ |
|---|
| 36 | + NateonGetInfoData *info_data; |
|---|
| 37 | + char *stripped; |
|---|
| 38 | + char *url_buffer; |
|---|
| 39 | + PurpleNotifyUserInfo *user_info; |
|---|
| 40 | + char *photo_url_text; |
|---|
| 41 | + char *photo_frame_url_text; |
|---|
| 42 | + |
|---|
| 43 | +} NateonGetInfoStepTwoData; |
|---|
| 44 | + |
|---|
| 45 | static const char *nateon_normalize(const PurpleAccount *account, const char *str) |
|---|
| 46 | { |
|---|
| 47 | static char buf[BUF_LEN]; |
|---|
| 48 | @@ -1594,591 +1593,393 @@ |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | -//static char * |
|---|
| 53 | -//nateon_tooltip_info_text(NateonGetInfoData *info_data) |
|---|
| 54 | -//{ |
|---|
| 55 | -// GString *s; |
|---|
| 56 | -// PurpleBuddy *b; |
|---|
| 57 | -// |
|---|
| 58 | -// s = g_string_sized_new(80); /* wild guess */ |
|---|
| 59 | -// |
|---|
| 60 | -// b = purple_find_buddy(purple_connection_get_account(info_data->gc), |
|---|
| 61 | -// info_data->name); |
|---|
| 62 | -// |
|---|
| 63 | -// if (b) |
|---|
| 64 | -// { |
|---|
| 65 | -// PurplePresence *presence; |
|---|
| 66 | -// GString *str = g_string_new(""); |
|---|
| 67 | -// char *tmp; |
|---|
| 68 | -// |
|---|
| 69 | -// presence = purple_buddy_get_presence(b); |
|---|
| 70 | -// |
|---|
| 71 | -// if (b->alias && b->alias[0]) |
|---|
| 72 | -// { |
|---|
| 73 | -// char *aliastext = g_markup_escape_text(b->alias, -1); |
|---|
| 74 | -// g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext); |
|---|
| 75 | -// g_free(aliastext); |
|---|
| 76 | -// } |
|---|
| 77 | -// |
|---|
| 78 | -// if (b->server_alias) |
|---|
| 79 | -// { |
|---|
| 80 | -// char *nicktext = g_markup_escape_text(b->server_alias, -1); |
|---|
| 81 | -// g_string_append_printf(s, _("<b>%s:</b> "), _("Nickname")); |
|---|
| 82 | -// g_string_append_printf(s, "<font sml=\"nateon\">%s</font><br>", |
|---|
| 83 | -// nicktext); |
|---|
| 84 | -// g_free(nicktext); |
|---|
| 85 | -// } |
|---|
| 86 | -// |
|---|
| 87 | -// nateon_tooltip_text(b, str, TRUE); |
|---|
| 88 | -// tmp = purple_strreplace((*str->str == '\n' ? str->str + 1 : str->str), |
|---|
| 89 | -// "\n", "<br>"); |
|---|
| 90 | -// g_string_free(str, TRUE); |
|---|
| 91 | -// g_string_append_printf(s, "%s<br>", tmp); |
|---|
| 92 | -// g_free(tmp); |
|---|
| 93 | -// } |
|---|
| 94 | -// |
|---|
| 95 | -// return g_string_free(s, FALSE); |
|---|
| 96 | -//} |
|---|
| 97 | -// |
|---|
| 98 | -//#if PHOTO_SUPPORT |
|---|
| 99 | -// |
|---|
| 100 | -//static char * |
|---|
| 101 | -//nateon_get_photo_url(const char *url_text) |
|---|
| 102 | -//{ |
|---|
| 103 | -// char *p, *q; |
|---|
| 104 | -// |
|---|
| 105 | -// if ((p = strstr(url_text, " contactparams:photopreauthurl=\"")) != NULL) |
|---|
| 106 | -// { |
|---|
| 107 | -// p += strlen(" contactparams:photopreauthurl=\""); |
|---|
| 108 | -// } |
|---|
| 109 | -// |
|---|
| 110 | -// if (p && (strncmp(p, "http://", 8) == 0) && ((q = strchr(p, '"')) != NULL)) |
|---|
| 111 | -// return g_strndup(p, q - p); |
|---|
| 112 | -// |
|---|
| 113 | -// return NULL; |
|---|
| 114 | -//} |
|---|
| 115 | -// |
|---|
| 116 | -//static void nateon_got_photo(void *data, const char *url_text, size_t len); |
|---|
| 117 | -// |
|---|
| 118 | -//#endif |
|---|
| 119 | -// |
|---|
| 120 | -//#if 0 |
|---|
| 121 | -//static char *nateon_info_date_reformat(const char *field, size_t len) |
|---|
| 122 | -//{ |
|---|
| 123 | -// char *tmp = g_strndup(field, len); |
|---|
| 124 | -// time_t t = purple_str_to_time(tmp, FALSE, NULL, NULL, NULL); |
|---|
| 125 | -// |
|---|
| 126 | -// g_free(tmp); |
|---|
| 127 | -// return g_strdup(purple_date_format_short(localtime(&t))); |
|---|
| 128 | -//} |
|---|
| 129 | -//#endif |
|---|
| 130 | -/* |
|---|
| 131 | -#define NATEON_GOT_INFO_GET_FIELD(a, b) \ |
|---|
| 132 | -found = purple_markup_extract_info_field(stripped, stripped_len, s, \ |
|---|
| 133 | -"\n" a "\t", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \ |
|---|
| 134 | -if (found) \ |
|---|
| 135 | -sect_info = TRUE; |
|---|
| 136 | -*/ |
|---|
| 137 | -//static void |
|---|
| 138 | -//nateon_got_info(void *data, const char *url_text, size_t len) |
|---|
| 139 | -//{ |
|---|
| 140 | -// NateonGetInfoData *info_data = (NateonGetInfoData *)data; |
|---|
| 141 | -// char *stripped, *p, *q; |
|---|
| 142 | -// char buf[1024]; |
|---|
| 143 | -// char *tooltip_text; |
|---|
| 144 | -// char *user_url = NULL; |
|---|
| 145 | -// gboolean found; |
|---|
| 146 | -// gboolean has_info = FALSE; |
|---|
| 147 | -// gboolean sect_info = FALSE; |
|---|
| 148 | -// const char* title = NULL; |
|---|
| 149 | -// char *url_buffer; |
|---|
| 150 | -// char *personal = NULL; |
|---|
| 151 | -// char *business = NULL; |
|---|
| 152 | -// GString *s, *s2; |
|---|
| 153 | -// int stripped_len; |
|---|
| 154 | -//#if PHOTO_SUPPORT |
|---|
| 155 | -// char *photo_url_text = NULL; |
|---|
| 156 | -// NateonGetInfoStepTwoData *info2_data = NULL; |
|---|
| 157 | -//#endif |
|---|
| 158 | -// |
|---|
| 159 | -// purple_debug_info("nateon", "In nateon_got_info\n"); |
|---|
| 160 | -// |
|---|
| 161 | -// /* Make sure the connection is still valid */ |
|---|
| 162 | -// if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL) |
|---|
| 163 | -// { |
|---|
| 164 | -// purple_debug_warning("nateon", "invalid connection. ignoring buddy info.\n"); |
|---|
| 165 | -// g_free(info_data->name); |
|---|
| 166 | -// g_free(info_data); |
|---|
| 167 | -// return; |
|---|
| 168 | -// } |
|---|
| 169 | -// |
|---|
| 170 | -// tooltip_text = nateon_tooltip_info_text(info_data); |
|---|
| 171 | -// title = _("NATEON Profile"); |
|---|
| 172 | -// |
|---|
| 173 | -// if (url_text == NULL || strcmp(url_text, "") == 0) |
|---|
| 174 | -// { |
|---|
| 175 | -// g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>", |
|---|
| 176 | -// tooltip_text, _("Error retrieving profile")); |
|---|
| 177 | -// |
|---|
| 178 | -// purple_notify_userinfo(info_data->gc, info_data->name, buf, NULL, NULL); |
|---|
| 179 | -// |
|---|
| 180 | -// g_free(tooltip_text); |
|---|
| 181 | -// return; |
|---|
| 182 | -// } |
|---|
| 183 | -// |
|---|
| 184 | -// url_buffer = g_strdup(url_text); |
|---|
| 185 | -// |
|---|
| 186 | -// /* If they have a homepage link, NATEON masks it such that we need to |
|---|
| 187 | -// * fetch the url out before purple_markup_strip_html() nukes it */ |
|---|
| 188 | -// /* I don't think this works with the new spaces profiles - Stu 3/2/06 */ |
|---|
| 189 | -// if ((p = strstr(url_text, |
|---|
| 190 | -// "Take a look at my </font><A class=viewDesc title=\"")) != NULL) |
|---|
| 191 | -// { |
|---|
| 192 | -// p += 50; |
|---|
| 193 | -// |
|---|
| 194 | -// if ((q = strchr(p, '"')) != NULL) |
|---|
| 195 | -// user_url = g_strndup(p, q - p); |
|---|
| 196 | -// } |
|---|
| 197 | -// |
|---|
| 198 | -// /* |
|---|
| 199 | -// * purple_markup_strip_html() doesn't strip out character entities like |
|---|
| 200 | -// * and · |
|---|
| 201 | -// */ |
|---|
| 202 | -// while ((p = strstr(url_buffer, " ")) != NULL) |
|---|
| 203 | -// { |
|---|
| 204 | -// *p = ' '; /* Turn 's into ordinary blanks */ |
|---|
| 205 | -// p += 1; |
|---|
| 206 | -// memmove(p, p + 5, strlen(p + 5)); |
|---|
| 207 | -// url_buffer[strlen(url_buffer) - 5] = '\0'; |
|---|
| 208 | -// } |
|---|
| 209 | -// |
|---|
| 210 | -// while ((p = strstr(url_buffer, "·")) != NULL) |
|---|
| 211 | -// { |
|---|
| 212 | -// memmove(p, p + 6, strlen(p + 6)); |
|---|
| 213 | -// url_buffer[strlen(url_buffer) - 6] = '\0'; |
|---|
| 214 | -// } |
|---|
| 215 | -// |
|---|
| 216 | -// /* Nuke the nasty \r's that just get in the way */ |
|---|
| 217 | -// purple_str_strip_char(url_buffer, '\r'); |
|---|
| 218 | -// |
|---|
| 219 | -// /* NATEON always puts in ' for apostrophes...replace them */ |
|---|
| 220 | -// while ((p = strstr(url_buffer, "'")) != NULL) |
|---|
| 221 | -// { |
|---|
| 222 | -// *p = '\''; |
|---|
| 223 | -// memmove(p + 1, p + 5, strlen(p + 5)); |
|---|
| 224 | -// url_buffer[strlen(url_buffer) - 4] = '\0'; |
|---|
| 225 | -// } |
|---|
| 226 | -// |
|---|
| 227 | -// /* Nuke the html, it's easier than trying to parse the horrid stuff */ |
|---|
| 228 | -// stripped = purple_markup_strip_html(url_buffer); |
|---|
| 229 | -// stripped_len = strlen(stripped); |
|---|
| 230 | -// |
|---|
| 231 | -// purple_debug_misc("nateon", "stripped = %p\n", stripped); |
|---|
| 232 | -// purple_debug_misc("nateon", "url_buffer = %p\n", url_buffer); |
|---|
| 233 | -// |
|---|
| 234 | -// /* Gonna re-use the memory we've already got for url_buffer */ |
|---|
| 235 | -// /* No we're not. */ |
|---|
| 236 | -// s = g_string_sized_new(strlen(url_buffer)); |
|---|
| 237 | -// s2 = g_string_sized_new(strlen(url_buffer)); |
|---|
| 238 | -// |
|---|
| 239 | -// /* Extract their Name and put it in */ |
|---|
| 240 | -// NATEON_GOT_INFO_GET_FIELD("Name", _("Name")) |
|---|
| 241 | -// |
|---|
| 242 | -// /* General */ |
|---|
| 243 | -// NATEON_GOT_INFO_GET_FIELD("Nickname", _("Nickname")); |
|---|
| 244 | -// NATEON_GOT_INFO_GET_FIELD("Age", _("Age")); |
|---|
| 245 | -// NATEON_GOT_INFO_GET_FIELD("Gender", _("Gender")); |
|---|
| 246 | -// NATEON_GOT_INFO_GET_FIELD("Occupation", _("Occupation")); |
|---|
| 247 | -// NATEON_GOT_INFO_GET_FIELD("Location", _("Location")); |
|---|
| 248 | -// |
|---|
| 249 | -// /* Extract their Interests and put it in */ |
|---|
| 250 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 251 | -// "\nInterests\t", 0, " (/default.aspx?page=searchresults", 0, |
|---|
| 252 | -// "Undisclosed", _("Hobbies and Interests") /* _("Interests") */, |
|---|
| 253 | -// 0, NULL, NULL); |
|---|
| 254 | -// |
|---|
| 255 | -// if (found) |
|---|
| 256 | -// sect_info = TRUE; |
|---|
| 257 | -// |
|---|
| 258 | -// NATEON_GOT_INFO_GET_FIELD("More about me", _("A Little About Me")); |
|---|
| 259 | -// |
|---|
| 260 | -// if (sect_info) |
|---|
| 261 | -// { |
|---|
| 262 | -// /* trim off the trailing "<br>\n" */ |
|---|
| 263 | -// g_string_truncate(s, strlen(s->str) - 5); |
|---|
| 264 | -// g_string_append_printf(s2, _("%s<b>General</b><br>%s"), |
|---|
| 265 | -// (*tooltip_text) ? "<hr>" : "", s->str); |
|---|
| 266 | -// s = g_string_truncate(s, 0); |
|---|
| 267 | -// has_info = TRUE; |
|---|
| 268 | -// sect_info = FALSE; |
|---|
| 269 | -// } |
|---|
| 270 | -// |
|---|
| 271 | -// |
|---|
| 272 | -// /* Social */ |
|---|
| 273 | -// NATEON_GOT_INFO_GET_FIELD("Marital status", _("Marital Status")); |
|---|
| 274 | -// NATEON_GOT_INFO_GET_FIELD("Interested in", _("Interests")); |
|---|
| 275 | -// NATEON_GOT_INFO_GET_FIELD("Pets", _("Pets")); |
|---|
| 276 | -// NATEON_GOT_INFO_GET_FIELD("Hometown", _("Hometown")); |
|---|
| 277 | -// NATEON_GOT_INFO_GET_FIELD("Places lived", _("Places Lived")); |
|---|
| 278 | -// NATEON_GOT_INFO_GET_FIELD("Fashion", _("Fashion")); |
|---|
| 279 | -// NATEON_GOT_INFO_GET_FIELD("Humor", _("Humor")); |
|---|
| 280 | -// NATEON_GOT_INFO_GET_FIELD("Music", _("Music")); |
|---|
| 281 | -// NATEON_GOT_INFO_GET_FIELD("Favorite quote", _("Favorite Quote")); |
|---|
| 282 | -// |
|---|
| 283 | -// if (sect_info) |
|---|
| 284 | -// { |
|---|
| 285 | -// g_string_append_printf(s2, _("%s<b>Social</b><br>%s"), has_info ? "<br><hr>" : "", s->str); |
|---|
| 286 | -// s = g_string_truncate(s, 0); |
|---|
| 287 | -// has_info = TRUE; |
|---|
| 288 | -// sect_info = FALSE; |
|---|
| 289 | -// } |
|---|
| 290 | -// |
|---|
| 291 | -// /* Contact Info */ |
|---|
| 292 | -// /* Personal */ |
|---|
| 293 | -// NATEON_GOT_INFO_GET_FIELD("Name", _("Name")); |
|---|
| 294 | -// NATEON_GOT_INFO_GET_FIELD("Significant other", _("Significant Other")); |
|---|
| 295 | -// NATEON_GOT_INFO_GET_FIELD("Home phone", _("Home Phone")); |
|---|
| 296 | -// NATEON_GOT_INFO_GET_FIELD("Home phone 2", _("Home Phone 2")); |
|---|
| 297 | -// NATEON_GOT_INFO_GET_FIELD("Home address", _("Home Address")); |
|---|
| 298 | -// NATEON_GOT_INFO_GET_FIELD("Personal Mobile", _("Personal Mobile")); |
|---|
| 299 | -// NATEON_GOT_INFO_GET_FIELD("Home fax", _("Home Fax")); |
|---|
| 300 | -// NATEON_GOT_INFO_GET_FIELD("Personal e-mail", _("Personal E-Mail")); |
|---|
| 301 | -// NATEON_GOT_INFO_GET_FIELD("Personal IM", _("Personal IM")); |
|---|
| 302 | -// NATEON_GOT_INFO_GET_FIELD("Birthday", _("Birthday")); |
|---|
| 303 | -// NATEON_GOT_INFO_GET_FIELD("Anniversary", _("Anniversary")); |
|---|
| 304 | -// NATEON_GOT_INFO_GET_FIELD("Notes", _("Notes")); |
|---|
| 305 | -// |
|---|
| 306 | -// if (sect_info) |
|---|
| 307 | -// { |
|---|
| 308 | -// personal = g_strdup_printf(_("<br><b>Personal</b><br>%s"), s->str); |
|---|
| 309 | -// s = g_string_truncate(s, 0); |
|---|
| 310 | -// sect_info = FALSE; |
|---|
| 311 | -// } |
|---|
| 312 | -// |
|---|
| 313 | -// /* Business */ |
|---|
| 314 | -// NATEON_GOT_INFO_GET_FIELD("Name", _("Name")); |
|---|
| 315 | -// NATEON_GOT_INFO_GET_FIELD("Job title", _("Job Title")); |
|---|
| 316 | -// NATEON_GOT_INFO_GET_FIELD("Company", _("Company")); |
|---|
| 317 | -// NATEON_GOT_INFO_GET_FIELD("Department", _("Department")); |
|---|
| 318 | -// NATEON_GOT_INFO_GET_FIELD("Profession", _("Profession")); |
|---|
| 319 | -// NATEON_GOT_INFO_GET_FIELD("Work phone 1", _("Work Phone")); |
|---|
| 320 | -// NATEON_GOT_INFO_GET_FIELD("Work phone 2", _("Work Phone 2")); |
|---|
| 321 | -// NATEON_GOT_INFO_GET_FIELD("Work address", _("Work Address")); |
|---|
| 322 | -// NATEON_GOT_INFO_GET_FIELD("Work mobile", _("Work Mobile")); |
|---|
| 323 | -// NATEON_GOT_INFO_GET_FIELD("Work pager", _("Work Pager")); |
|---|
| 324 | -// NATEON_GOT_INFO_GET_FIELD("Work fax", _("Work Fax")); |
|---|
| 325 | -// NATEON_GOT_INFO_GET_FIELD("Work e-mail", _("Work E-Mail")); |
|---|
| 326 | -// NATEON_GOT_INFO_GET_FIELD("Work IM", _("Work IM")); |
|---|
| 327 | -// NATEON_GOT_INFO_GET_FIELD("Start date", _("Start Date")); |
|---|
| 328 | -// NATEON_GOT_INFO_GET_FIELD("Notes", _("Notes")); |
|---|
| 329 | -// |
|---|
| 330 | -// if (sect_info) |
|---|
| 331 | -// { |
|---|
| 332 | -// business = g_strdup_printf(_("<br><b>Business</b><br>%s"), s->str); |
|---|
| 333 | -// s = g_string_truncate(s, 0); |
|---|
| 334 | -// sect_info = FALSE; |
|---|
| 335 | -// } |
|---|
| 336 | -// |
|---|
| 337 | -// if ((personal != NULL) || (business != NULL)) |
|---|
| 338 | -// { |
|---|
| 339 | -// /* trim off the trailing "<br>\n" */ |
|---|
| 340 | -// g_string_truncate(s, strlen(s->str) - 5); |
|---|
| 341 | -// |
|---|
| 342 | -// has_info = TRUE; |
|---|
| 343 | -// g_string_append_printf(s2, _("<hr><b>Contact Info</b>%s%s"), |
|---|
| 344 | -// personal ? personal : "", |
|---|
| 345 | -// business ? business : ""); |
|---|
| 346 | -// } |
|---|
| 347 | -// |
|---|
| 348 | -// g_free(personal); |
|---|
| 349 | -// g_free(business); |
|---|
| 350 | -// g_string_free(s, TRUE); |
|---|
| 351 | -// s = s2; |
|---|
| 352 | -// |
|---|
| 353 | -//#if 0 /* these probably don't show up any more */ |
|---|
| 354 | -// /* |
|---|
| 355 | -// * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies |
|---|
| 356 | -// * and Interests', 'Favorite Quote', and 'My Homepage' may or may |
|---|
| 357 | -// * not appear, in any combination. However, they do appear in |
|---|
| 358 | -// * certain order, so we can successively search to pin down the |
|---|
| 359 | -// * distinct values. |
|---|
| 360 | -// */ |
|---|
| 361 | -// |
|---|
| 362 | -// /* Check if they have A Little About Me */ |
|---|
| 363 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 364 | -// " A Little About Me \n\n", 0, "Favorite Things", '\n', NULL, |
|---|
| 365 | -// _("A Little About Me"), 0, NULL, NULL); |
|---|
| 366 | -// |
|---|
| 367 | -// if (!found) |
|---|
| 368 | -// { |
|---|
| 369 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 370 | -// " A Little About Me \n\n", 0, "Hobbies and Interests", '\n', |
|---|
| 371 | -// NULL, _("A Little About Me"), 0, NULL, NULL); |
|---|
| 372 | -// } |
|---|
| 373 | -// |
|---|
| 374 | -// if (!found) |
|---|
| 375 | -// { |
|---|
| 376 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 377 | -// " A Little About Me \n\n", 0, "Favorite Quote", '\n', NULL, |
|---|
| 378 | -// _("A Little About Me"), 0, NULL, NULL); |
|---|
| 379 | -// } |
|---|
| 380 | -// |
|---|
| 381 | -// if (!found) |
|---|
| 382 | -// { |
|---|
| 383 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 384 | -// " A Little About Me \n\n", 0, "My Homepage \n\nTake a look", |
|---|
| 385 | -// '\n', |
|---|
| 386 | -// NULL, _("A Little About Me"), 0, NULL, NULL); |
|---|
| 387 | -// } |
|---|
| 388 | -// |
|---|
| 389 | -// if (!found) |
|---|
| 390 | -// { |
|---|
| 391 | -// purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 392 | -// " A Little About Me \n\n", 0, "last updated", '\n', NULL, |
|---|
| 393 | -// _("A Little About Me"), 0, NULL, NULL); |
|---|
| 394 | -// } |
|---|
| 395 | -// |
|---|
| 396 | -// if (found) |
|---|
| 397 | -// has_info = TRUE; |
|---|
| 398 | -// |
|---|
| 399 | -// /* Check if they have Favorite Things */ |
|---|
| 400 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 401 | -// " Favorite Things \n\n", 0, "Hobbies and Interests", '\n', NULL, |
|---|
| 402 | -// _("Favorite Things"), 0, NULL, NULL); |
|---|
| 403 | -// |
|---|
| 404 | -// if (!found) |
|---|
| 405 | -// { |
|---|
| 406 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 407 | -// " Favorite Things \n\n", 0, "Favorite Quote", '\n', NULL, |
|---|
| 408 | -// _("Favorite Things"), 0, NULL, NULL); |
|---|
| 409 | -// } |
|---|
| 410 | -// |
|---|
| 411 | -// if (!found) |
|---|
| 412 | -// { |
|---|
| 413 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 414 | -// " Favorite Things \n\n", 0, "My Homepage \n\nTake a look", '\n', |
|---|
| 415 | -// NULL, _("Favorite Things"), 0, NULL, NULL); |
|---|
| 416 | -// } |
|---|
| 417 | -// |
|---|
| 418 | -// if (!found) |
|---|
| 419 | -// { |
|---|
| 420 | -// purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 421 | -// " Favorite Things \n\n", 0, "last updated", '\n', NULL, |
|---|
| 422 | -// _("Favorite Things"), 0, NULL, NULL); |
|---|
| 423 | -// } |
|---|
| 424 | -// |
|---|
| 425 | -// if (found) |
|---|
| 426 | -// has_info = TRUE; |
|---|
| 427 | -// |
|---|
| 428 | -// /* Check if they have Hobbies and Interests */ |
|---|
| 429 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 430 | -// " Hobbies and Interests \n\n", 0, "Favorite Quote", '\n', NULL, |
|---|
| 431 | -// _("Hobbies and Interests"), 0, NULL, NULL); |
|---|
| 432 | -// |
|---|
| 433 | -// if (!found) |
|---|
| 434 | -// { |
|---|
| 435 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 436 | -// " Hobbies and Interests \n\n", 0, "My Homepage \n\nTake a look", |
|---|
| 437 | -// '\n', NULL, _("Hobbies and Interests"), 0, NULL, NULL); |
|---|
| 438 | -// } |
|---|
| 439 | -// |
|---|
| 440 | -// if (!found) |
|---|
| 441 | -// { |
|---|
| 442 | -// purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 443 | -// " Hobbies and Interests \n\n", 0, "last updated", '\n', NULL, |
|---|
| 444 | -// _("Hobbies and Interests"), 0, NULL, NULL); |
|---|
| 445 | -// } |
|---|
| 446 | -// |
|---|
| 447 | -// if (found) |
|---|
| 448 | -// has_info = TRUE; |
|---|
| 449 | -// |
|---|
| 450 | -// /* Check if they have Favorite Quote */ |
|---|
| 451 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 452 | -// "Favorite Quote \n\n", 0, "My Homepage \n\nTake a look", '\n', NULL, |
|---|
| 453 | -// _("Favorite Quote"), 0, NULL, NULL); |
|---|
| 454 | -// |
|---|
| 455 | -// if (!found) |
|---|
| 456 | -// { |
|---|
| 457 | -// purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 458 | -// "Favorite Quote \n\n", 0, "last updated", '\n', NULL, |
|---|
| 459 | -// _("Favorite Quote"), 0, NULL, NULL); |
|---|
| 460 | -// } |
|---|
| 461 | -// |
|---|
| 462 | -// if (found) |
|---|
| 463 | -// has_info = TRUE; |
|---|
| 464 | -// |
|---|
| 465 | -// /* Extract the last updated date and put it in */ |
|---|
| 466 | -// found = purple_markup_extract_info_field(stripped, stripped_len, s, |
|---|
| 467 | -// " last updated:", 1, "\n", 0, NULL, _("Last Updated"), 0, |
|---|
| 468 | -// NULL, nateon_info_date_reformat); |
|---|
| 469 | -// |
|---|
| 470 | -// if (found) |
|---|
| 471 | -// has_info = TRUE; |
|---|
| 472 | -//#endif |
|---|
| 473 | -// |
|---|
| 474 | -// /* If we were able to fetch a homepage url earlier, stick it in there */ |
|---|
| 475 | -// if (user_url != NULL) |
|---|
| 476 | -// { |
|---|
| 477 | -// g_snprintf(buf, sizeof(buf), |
|---|
| 478 | -// "<b>%s:</b><br><a href=\"%s\">%s</a><br>\n", |
|---|
| 479 | -// _("Homepage"), user_url, user_url); |
|---|
| 480 | -// |
|---|
| 481 | -// g_string_append(s, buf); |
|---|
| 482 | -// |
|---|
| 483 | -// g_free(user_url); |
|---|
| 484 | -// |
|---|
| 485 | -// has_info = TRUE; |
|---|
| 486 | -// } |
|---|
| 487 | -// |
|---|
| 488 | -// if (!has_info) |
|---|
| 489 | -// { |
|---|
| 490 | -// /* NATEON doesn't actually distinguish between "unknown member" and |
|---|
| 491 | -// * a known member with an empty profile. Try to explain this fact. |
|---|
| 492 | -// * Note that if we have a nonempty tooltip_text, we know the user |
|---|
| 493 | -// * exists. |
|---|
| 494 | -// */ |
|---|
| 495 | -// /* This doesn't work with the new spaces profiles - Stu 3/2/06 |
|---|
| 496 | -// char *p = strstr(url_buffer, "Unknown Member </TITLE>"); |
|---|
| 497 | -// * This might not work for long either ... */ |
|---|
| 498 | -// char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\""); |
|---|
| 499 | -// PurpleBuddy *b = purple_find_buddy |
|---|
| 500 | -// (purple_connection_get_account(info_data->gc), info_data->name); |
|---|
| 501 | -// g_string_append_printf(s, "<br><b>%s</b><br>%s<br><br>", |
|---|
| 502 | -// _("Error retrieving profile"), |
|---|
| 503 | -// ((p && b)? |
|---|
| 504 | -// _("The user has not created a public profile."): |
|---|
| 505 | -// p? _("NATEON reported not being able to find the user's profile. " |
|---|
| 506 | -// "This either means that the user does not exist, " |
|---|
| 507 | -// "or that the user exists " |
|---|
| 508 | -// "but has not created a public profile."): |
|---|
| 509 | -// _("Purple could not find " /* This should never happen */ |
|---|
| 510 | -// "any information in the user's profile. " |
|---|
| 511 | -// "The user most likely does not exist."))); |
|---|
| 512 | -// } |
|---|
| 513 | -// /* put a link to the actual profile URL */ |
|---|
| 514 | -// g_string_append_printf(s, _("<hr><b>%s:</b> "), _("Profile URL")); |
|---|
| 515 | -// g_string_append_printf(s, "<br><a href=\"%s%s\">%s%s</a><br>", |
|---|
| 516 | -// PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); |
|---|
| 517 | -// |
|---|
| 518 | -// /* Finish it off, and show it to them */ |
|---|
| 519 | -// g_string_append(s, "</body></html>\n"); |
|---|
| 520 | -// |
|---|
| 521 | -//#if PHOTO_SUPPORT |
|---|
| 522 | -// /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ |
|---|
| 523 | -// photo_url_text = nateon_get_photo_url(url_text); |
|---|
| 524 | -// |
|---|
| 525 | -// /* Marshall the existing state */ |
|---|
| 526 | -// info2_data = g_malloc0(sizeof(NateonGetInfoStepTwoData)); |
|---|
| 527 | -// info2_data->info_data = info_data; |
|---|
| 528 | -// info2_data->stripped = stripped; |
|---|
| 529 | -// info2_data->url_buffer = url_buffer; |
|---|
| 530 | -// info2_data->s = s; |
|---|
| 531 | -// info2_data->photo_url_text = photo_url_text; |
|---|
| 532 | -// info2_data->tooltip_text = tooltip_text; |
|---|
| 533 | -// info2_data->title = title; |
|---|
| 534 | -// |
|---|
| 535 | -// /* Try to put the photo in there too, if there's one */ |
|---|
| 536 | -// if (photo_url_text) |
|---|
| 537 | -// { |
|---|
| 538 | -// purple_url_fetch(photo_url_text, FALSE, NULL, FALSE, nateon_got_photo, |
|---|
| 539 | -// info2_data); |
|---|
| 540 | -// } |
|---|
| 541 | -// else |
|---|
| 542 | -// { |
|---|
| 543 | -// /* Emulate a callback */ |
|---|
| 544 | -// nateon_got_photo(info2_data, NULL, 0); |
|---|
| 545 | -// } |
|---|
| 546 | -//} |
|---|
| 547 | -// |
|---|
| 548 | -//static void |
|---|
| 549 | -//nateon_got_photo(void *data, const char *url_text, size_t len) |
|---|
| 550 | -//{ |
|---|
| 551 | -// NateonGetInfoStepTwoData *info2_data = (NateonGetInfoStepTwoData *)data; |
|---|
| 552 | -// int id = -1; |
|---|
| 553 | -// |
|---|
| 554 | -// /* Unmarshall the saved state */ |
|---|
| 555 | -// NateonGetInfoData *info_data = info2_data->info_data; |
|---|
| 556 | -// char *stripped = info2_data->stripped; |
|---|
| 557 | -// char *url_buffer = info2_data->url_buffer; |
|---|
| 558 | -// GString *s = info2_data->s; |
|---|
| 559 | -// char *photo_url_text = info2_data->photo_url_text; |
|---|
| 560 | -// char *tooltip_text = info2_data->tooltip_text; |
|---|
| 561 | -// |
|---|
| 562 | -// /* Make sure the connection is still valid if we got here by fetching a photo url */ |
|---|
| 563 | -// if (url_text && |
|---|
| 564 | -// g_list_find(purple_connections_get_all(), info_data->gc) == NULL) |
|---|
| 565 | -// { |
|---|
| 566 | -// purple_debug_warning("nateon", "invalid connection. ignoring buddy photo info.\n"); |
|---|
| 567 | -// g_free(stripped); |
|---|
| 568 | -// g_free(url_buffer); |
|---|
| 569 | -// g_string_free(s, TRUE); |
|---|
| 570 | -// g_free(tooltip_text); |
|---|
| 571 | -// g_free(info_data->name); |
|---|
| 572 | -// g_free(info_data); |
|---|
| 573 | -// g_free(photo_url_text); |
|---|
| 574 | -// g_free(info2_data); |
|---|
| 575 | -// |
|---|
| 576 | -// return; |
|---|
| 577 | -// } |
|---|
| 578 | -// |
|---|
| 579 | -// /* Try to put the photo in there too, if there's one and is readable */ |
|---|
| 580 | -// if (data && url_text && len != 0) |
|---|
| 581 | -// { |
|---|
| 582 | -// if (strstr(url_text, "400 Bad Request") |
|---|
| 583 | -// || strstr(url_text, "403 Forbidden") |
|---|
| 584 | -// || strstr(url_text, "404 Not Found")) |
|---|
| 585 | -// { |
|---|
| 586 | -// |
|---|
| 587 | -// purple_debug_info("nateon", "Error getting %s: %s\n", |
|---|
| 588 | -// photo_url_text, url_text); |
|---|
| 589 | -// } |
|---|
| 590 | -// else |
|---|
| 591 | -// { |
|---|
| 592 | -// char buf[1024]; |
|---|
| 593 | -// purple_debug_info("nateon", "%s is %d bytes\n", photo_url_text, len); |
|---|
| 594 | -// id = purple_imgstore_add(url_text, len, NULL); |
|---|
| 595 | -// g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); |
|---|
| 596 | -// g_string_prepend(s, buf); |
|---|
| 597 | -// } |
|---|
| 598 | -// } |
|---|
| 599 | -// |
|---|
| 600 | -// /* We continue here from nateon_got_info, as if nothing has happened */ |
|---|
| 601 | -//#endif |
|---|
| 602 | -// |
|---|
| 603 | -// g_string_prepend(s, tooltip_text); |
|---|
| 604 | -// purple_notify_userinfo(info_data->gc, info_data->name, s->str, NULL, NULL); |
|---|
| 605 | -// |
|---|
| 606 | -// g_free(stripped); |
|---|
| 607 | -// g_free(url_buffer); |
|---|
| 608 | -// g_string_free(s, TRUE); |
|---|
| 609 | -// g_free(tooltip_text); |
|---|
| 610 | -// g_free(info_data->name); |
|---|
| 611 | -// g_free(info_data); |
|---|
| 612 | -//#if PHOTO_SUPPORT |
|---|
| 613 | -// g_free(photo_url_text); |
|---|
| 614 | -// g_free(info2_data); |
|---|
| 615 | -// if (id != -1) |
|---|
| 616 | -// purple_imgstore_unref(id); |
|---|
| 617 | -//#endif |
|---|
| 618 | -//} |
|---|
| 619 | +/** |
|---|
| 620 | + * Extract info text from info_data and add it to user_info |
|---|
| 621 | + */ |
|---|
| 622 | +static gboolean |
|---|
| 623 | +nateon_tooltip_extract_info_text(PurpleNotifyUserInfo *user_info, NateonGetInfoData *info_data) |
|---|
| 624 | +{ |
|---|
| 625 | + PurpleBuddy *b; |
|---|
| 626 | |
|---|
| 627 | - static void |
|---|
| 628 | + b = purple_find_buddy(purple_connection_get_account(info_data->gc), |
|---|
| 629 | + info_data->name); |
|---|
| 630 | + |
|---|
| 631 | + if (b) |
|---|
| 632 | + { |
|---|
| 633 | + char *tmp; |
|---|
| 634 | + |
|---|
| 635 | + if (b->alias && b->alias[0]) |
|---|
| 636 | + { |
|---|
| 637 | + char *aliastext = g_markup_escape_text(b->alias, -1); |
|---|
| 638 | + purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); |
|---|
| 639 | + g_free(aliastext); |
|---|
| 640 | + } |
|---|
| 641 | + |
|---|
| 642 | + if (b->server_alias) |
|---|
| 643 | + { |
|---|
| 644 | + char *nicktext = g_markup_escape_text(b->server_alias, -1); |
|---|
| 645 | + tmp = g_strdup_printf("<font sml=\"nateon\">%s</font><br>", nicktext); |
|---|
| 646 | + purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); |
|---|
| 647 | + g_free(tmp); |
|---|
| 648 | + g_free(nicktext); |
|---|
| 649 | + } |
|---|
| 650 | + |
|---|
| 651 | + /* Add the tooltip information */ |
|---|
| 652 | + nateon_tooltip_text(b, user_info, TRUE); |
|---|
| 653 | + |
|---|
| 654 | + return TRUE; |
|---|
| 655 | + } |
|---|
| 656 | + |
|---|
| 657 | + return FALSE; |
|---|
| 658 | +} |
|---|
| 659 | + |
|---|
| 660 | +#if PHOTO_SUPPORT |
|---|
| 661 | + |
|---|
| 662 | +static void nateon_got_photo(PurpleUtilFetchUrlData *url_data, gpointer data, |
|---|
| 663 | + const gchar *url_text, size_t len, const gchar *error_message); |
|---|
| 664 | +static void nateon_got_photo_frame(PurpleUtilFetchUrlData *url_data, gpointer data, |
|---|
| 665 | + const gchar *url_text, size_t len, const gchar *error_message); |
|---|
| 666 | + |
|---|
| 667 | +#endif |
|---|
| 668 | + |
|---|
| 669 | + |
|---|
| 670 | +static void |
|---|
| 671 | +nateon_got_info(PurpleUtilFetchUrlData *url_data, gpointer data, |
|---|
| 672 | + const gchar *url_text, size_t len, const gchar *error_message) |
|---|
| 673 | +{ |
|---|
| 674 | + NateonGetInfoData *info_data = (NateonGetInfoData *)data; |
|---|
| 675 | + PurpleNotifyUserInfo *user_info; |
|---|
| 676 | + char *stripped, *p, *tmp; |
|---|
| 677 | + gboolean has_tooltip_text = FALSE; |
|---|
| 678 | + gboolean has_info = FALSE; |
|---|
| 679 | + char *url_buffer; |
|---|
| 680 | + int stripped_len; |
|---|
| 681 | +#if PHOTO_SUPPORT |
|---|
| 682 | + //char *photo_url_text = NULL; |
|---|
| 683 | + char *photo_frame_url_text = NULL; |
|---|
| 684 | + NateonGetInfoStepTwoData *info2_data = NULL; |
|---|
| 685 | +#endif |
|---|
| 686 | + |
|---|
| 687 | + purple_debug_info("nateon", "In nateon_got_info\n"); |
|---|
| 688 | + |
|---|
| 689 | + /* Make sure the connection is still valid */ |
|---|
| 690 | + if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL) |
|---|
| 691 | + { |
|---|
| 692 | + purple_debug_warning("nateon", "invalid connection. ignoring buddy info.\n"); |
|---|
| 693 | + g_free(info_data->name); |
|---|
| 694 | + g_free(info_data); |
|---|
| 695 | + return; |
|---|
| 696 | + } |
|---|
| 697 | + |
|---|
| 698 | + user_info = purple_notify_user_info_new(); |
|---|
| 699 | + has_tooltip_text = nateon_tooltip_extract_info_text(user_info, info_data); |
|---|
| 700 | + |
|---|
| 701 | + |
|---|
| 702 | + |
|---|
| 703 | + //purple_notify_user_info_add_section_break(user_info); |
|---|
| 704 | + |
|---|
| 705 | + if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) |
|---|
| 706 | + { |
|---|
| 707 | + tmp = g_strdup_printf("<b>%s</b>", _("Error retrieving profile")); |
|---|
| 708 | + purple_notify_user_info_add_pair(user_info, NULL, tmp); |
|---|
| 709 | + g_free(tmp); |
|---|
| 710 | + |
|---|
| 711 | + purple_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); |
|---|
| 712 | + purple_notify_user_info_destroy(user_info); |
|---|
| 713 | + |
|---|
| 714 | + g_free(info_data->name); |
|---|
| 715 | + g_free(info_data); |
|---|
| 716 | + return; |
|---|
| 717 | + } |
|---|
| 718 | + |
|---|
| 719 | + url_buffer = g_strdup(url_text); |
|---|
| 720 | + |
|---|
| 721 | + if ((p = strstr(url_text, |
|---|
| 722 | + "\xec\xa1\xb4\xec\x9e\xac\xed\x95\x98" |
|---|
| 723 | + "\xec\xa7\x80 \xec\x95\x8a\xeb\x8a\x94 " |
|---|
| 724 | + "\xec\x82\xac\xec\x9a\xa9\xec\x9e\x90" |
|---|
| 725 | + "\xec\x9e\x85\xeb\x8b\x88\xeb\x8b\xa4.")) == NULL) |
|---|
| 726 | + { |
|---|
| 727 | + has_info = TRUE; |
|---|
| 728 | + } |
|---|
| 729 | + |
|---|
| 730 | + /* Nuke the html, it's easier than trying to parse the horrid stuff */ |
|---|
| 731 | + stripped = purple_markup_strip_html(url_buffer); |
|---|
| 732 | + stripped_len = strlen(stripped); |
|---|
| 733 | + |
|---|
| 734 | + purple_debug_misc("nateon", "stripped = %p\n", stripped); |
|---|
| 735 | + purple_debug_misc("nateon", "url_buffer = %p\n", url_buffer); |
|---|
| 736 | + |
|---|
| 737 | + /* General section header */ |
|---|
| 738 | + if (has_tooltip_text) |
|---|
| 739 | + purple_notify_user_info_add_section_break(user_info); |
|---|
| 740 | + |
|---|
| 741 | + /* Personal */ |
|---|
| 742 | + purple_notify_user_info_add_section_header(user_info, _("Personal Information")); |
|---|
| 743 | + |
|---|
| 744 | + /* Extract their Name, minihp and put it in */ |
|---|
| 745 | + purple_markup_extract_info_field(stripped, stripped_len, user_info, |
|---|
| 746 | + " \xec\x9d\xb4\xeb\xa6\x84\t", 0, " ", 0, "Undisclosed", _("Name"), 0, NULL, NULL); |
|---|
| 747 | + purple_notify_user_info_remove_last_item(user_info); |
|---|
| 748 | + |
|---|
| 749 | + //purple_debug_info("nateon", "example string to search, end of memo: %s\n", _("\xeb\xa9\x94\xeb\xaa\xa8")); |
|---|
| 750 | + |
|---|
| 751 | + |
|---|
| 752 | + // all the '\xec\x9d\xb4\' bits are to create the hangeul that that the extract_info is looking for in the page. UTF-8 |
|---|
| 753 | + // the extract_info_field is using integers to skip the spaces, it's ugly, but works. Matt |
|---|
| 754 | + purple_markup_extract_info_field(stripped, stripped_len, user_info, "\xec\x9d\xb4\xeb\xa9\x94\xec\x9d\xbc", 49, "(", 0, "Undisclosed", "Email", 0, NULL, NULL); |
|---|
| 755 | + purple_markup_extract_info_field(stripped, stripped_len, user_info, "\xec\x83\x9d\xec\x9d\xbc", 52, "\xec\x9d\xb4\xeb\xa9\x94\xec\x9d\xbc", 0, "Undisclosed", "Birthday", 0, NULL, NULL); |
|---|
| 756 | + purple_markup_extract_info_field(stripped, stripped_len, user_info, "\xed\x9c\xb4\xeb\x8c\x80\xed\x8f\xb0", 99, "(", 0, "Undisclosed", "Mobile Phone", 0, NULL, NULL); |
|---|
| 757 | + purple_markup_extract_info_field(stripped, stripped_len, user_info, "\xec\x9e\x90\xea\xb8\xb0\xec\x86\x8c\xea\xb0\x9c", 0, "\xeb\xa9\x94\xeb\xaa\xa8", 0, "Undisclosed", "A Little About Me", 0, NULL, NULL); |
|---|
| 758 | + |
|---|
| 759 | + |
|---|
| 760 | +// purple_debug_info("nateon", "Tried to ge the email, birthday etc\n"); |
|---|
| 761 | + |
|---|
| 762 | + //Some profiles use openWindow_Home for the Mini Hompy, I don't know why, but let's just "or" it together. Matt |
|---|
| 763 | + if (strstr(stripped, "openWindow_minihompy") != NULL || strstr(stripped, "openWindow_Home") != NULL) |
|---|
| 764 | + { |
|---|
| 765 | + tmp = g_strdup_printf("<a href=\"http://%s%s\">Mini Hompy</a>", NATEON_MINIHP_URL, info_data->ID); |
|---|
| 766 | + purple_notify_user_info_add_pair(user_info, _("Homepage"), tmp); |
|---|
| 767 | + g_free(tmp); |
|---|
| 768 | + } |
|---|
| 769 | + |
|---|
| 770 | + |
|---|
| 771 | + if (!has_info) |
|---|
| 772 | + { |
|---|
| 773 | + PurpleBuddy *b = purple_find_buddy |
|---|
| 774 | + (purple_connection_get_account(info_data->gc), info_data->name); |
|---|
| 775 | + purple_notify_user_info_add_pair(user_info, _("Error retrieving profile"), |
|---|
| 776 | + ((p && b) ? _("The user has not created a public profile.") : |
|---|
| 777 | + (p ? _("NATEON reported not being able to find the user's profile. " |
|---|
| 778 | + "This either means that the user does not exist, " |
|---|
| 779 | + "or that the user exists " |
|---|
| 780 | + "but has not created a public profile.") : |
|---|
| 781 | + _("Could not find " /* This should never happen */ |
|---|
| 782 | + "any information in the user's profile. " |
|---|
| 783 | + "The user most likely does not exist.")))); |
|---|
| 784 | + } |
|---|
| 785 | + |
|---|
| 786 | + /* put a link to the actual profile URL */ |
|---|
| 787 | + tmp = g_strdup_printf("<a href=\"http://%s%s?CMN=%s\">Profile</a>", |
|---|
| 788 | + NATEON_PROFILE_BASE, NATEON_PROFILE_PAGE, info_data->ID); |
|---|
| 789 | + purple_notify_user_info_add_pair(user_info, _("Profile"), tmp); |
|---|
| 790 | + g_free(tmp); |
|---|
| 791 | + |
|---|
| 792 | + //purple_notify_user_info_add_pair(user_info, _("Stripped HTML"), stripped); |
|---|
| 793 | + |
|---|
| 794 | + |
|---|
| 795 | +#if PHOTO_SUPPORT |
|---|
| 796 | + |
|---|
| 797 | + /* Marshall the existing state */ |
|---|
| 798 | + info2_data = g_malloc0(sizeof(NateonGetInfoStepTwoData)); |
|---|
| 799 | + info2_data->info_data = info_data; |
|---|
| 800 | + info2_data->stripped = stripped; |
|---|
| 801 | + info2_data->url_buffer = url_buffer; |
|---|
| 802 | + info2_data->user_info = user_info; |
|---|
| 803 | + |
|---|
| 804 | + /* Try to put the photo in there too, if there's one */ |
|---|
| 805 | + if (strstr(url_text, "openProfileImage") != NULL) |
|---|
| 806 | + { |
|---|
| 807 | + photo_frame_url_text = g_strdup_printf(NATEON_PHOTO_URL, info_data->ID); |
|---|
| 808 | + info2_data->photo_frame_url_text = photo_frame_url_text; |
|---|
| 809 | + purple_util_fetch_url(photo_frame_url_text, FALSE, NULL, FALSE, nateon_got_photo_frame, |
|---|
| 810 | + info2_data); |
|---|
| 811 | + } |
|---|
| 812 | + else |
|---|
| 813 | + { |
|---|
| 814 | + /* Emulate a callback */ |
|---|
| 815 | + /* TODO: Huh? */ |
|---|
| 816 | + nateon_got_photo(NULL, info2_data, NULL, 0, NULL); |
|---|
| 817 | + } |
|---|
| 818 | + |
|---|
| 819 | +} |
|---|
| 820 | + |
|---|
| 821 | +static void |
|---|
| 822 | +nateon_got_photo_frame(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|---|
| 823 | + const gchar *url_text, size_t len, const gchar *error_message) |
|---|
| 824 | +{ |
|---|
| 825 | + NateonGetInfoStepTwoData *info2_data = (NateonGetInfoStepTwoData *)user_data; |
|---|
| 826 | + char *p, *q, *tmp, *photo_url_text; |
|---|
| 827 | + |
|---|
| 828 | + if ( (p=strstr(url_text, "/profileimage")) != NULL && (q=strstr(p, "\"")) != NULL) |
|---|
| 829 | + { |
|---|
| 830 | + tmp = g_strndup(p, q - p); |
|---|
| 831 | + photo_url_text = g_strdup_printf("%s%s", NATEON_PROFILE_BASE, tmp); |
|---|
| 832 | + info2_data->photo_url_text = photo_url_text; |
|---|
| 833 | + purple_util_fetch_url(photo_url_text, FALSE, NULL, FALSE, nateon_got_photo, |
|---|
| 834 | + info2_data); |
|---|
| 835 | + g_free(tmp); |
|---|
| 836 | + } |
|---|
| 837 | + else |
|---|
| 838 | + { |
|---|
| 839 | + /* Emulate a callback */ |
|---|
| 840 | + /* TODO: Huh? */ |
|---|
| 841 | + nateon_got_photo(NULL, info2_data, NULL, 0, NULL); |
|---|
| 842 | + } |
|---|
| 843 | +} |
|---|
| 844 | + |
|---|
| 845 | +static void |
|---|
| 846 | +nateon_got_photo(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|---|
| 847 | + const gchar *url_text, size_t len, const gchar *error_message) |
|---|
| 848 | +{ |
|---|
| 849 | + NateonGetInfoStepTwoData *info2_data = (NateonGetInfoStepTwoData *)user_data; |
|---|
| 850 | + int id = -1; |
|---|
| 851 | + |
|---|
| 852 | + /* Unmarshall the saved state */ |
|---|
| 853 | + NateonGetInfoData *info_data = info2_data->info_data; |
|---|
| 854 | + char *stripped = info2_data->stripped; |
|---|
| 855 | + char *url_buffer = info2_data->url_buffer; |
|---|
| 856 | + PurpleNotifyUserInfo *user_info = info2_data->user_info; |
|---|
| 857 | + char *photo_url_text = info2_data->photo_url_text; |
|---|
| 858 | + char *photo_frame_url_text = info2_data->photo_frame_url_text; |
|---|
| 859 | + |
|---|
| 860 | + /* Make sure the connection is still valid if we got here by fetching a photo url */ |
|---|
| 861 | + if (url_text && (error_message != NULL || |
|---|
| 862 | + g_list_find(purple_connections_get_all(), info_data->gc) == NULL)) |
|---|
| 863 | + { |
|---|
| 864 | + purple_debug_warning("nateon", "invalid connection. ignoring buddy photo info.\n"); |
|---|
| 865 | + g_free(stripped); |
|---|
| 866 | + g_free(url_buffer); |
|---|
| 867 | + g_free(user_info); |
|---|
| 868 | + g_free(info_data->name); |
|---|
| 869 | + g_free(info_data); |
|---|
| 870 | + g_free(photo_url_text); |
|---|
| 871 | + g_free(photo_frame_url_text); |
|---|
| 872 | + g_free(info2_data); |
|---|
| 873 | + |
|---|
| 874 | + return; |
|---|
| 875 | + } |
|---|
| 876 | + |
|---|
| 877 | + /* Try to put the photo in there too, if there's one and is readable */ |
|---|
| 878 | + if (user_data && url_text && len != 0) |
|---|
| 879 | + { |
|---|
| 880 | + if (strstr(url_text, "400 Bad Request") |
|---|
| 881 | + || strstr(url_text, "403 Forbidden") |
|---|
| 882 | + || strstr(url_text, "404 Not Found")) |
|---|
| 883 | + { |
|---|
| 884 | + |
|---|
| 885 | + purple_debug_info("nateon", "Error getting %s: %s\n", |
|---|
| 886 | + photo_url_text, url_text); |
|---|
| 887 | + } |
|---|
| 888 | + else |
|---|
| 889 | + { |
|---|
| 890 | + char buf[1024]; |
|---|
| 891 | + purple_debug_info("nateon", "%s is %d bytes\n", photo_url_text, len); |
|---|
| 892 | + id = purple_imgstore_add_with_id(g_memdup(url_text, len), len, NULL); |
|---|
| 893 | + g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); |
|---|
| 894 | + purple_notify_user_info_prepend_pair(user_info, NULL, buf); |
|---|
| 895 | + } |
|---|
| 896 | + } |
|---|
| 897 | + |
|---|
| 898 | + /* We continue here from nateon_got_info, as if nothing has happened */ |
|---|
| 899 | +#endif |
|---|
| 900 | + purple_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); |
|---|
| 901 | + |
|---|
| 902 | + g_free(stripped); |
|---|
| 903 | + g_free(url_buffer); |
|---|
| 904 | + purple_notify_user_info_destroy(user_info); |
|---|
| 905 | + g_free(info_data->name); |
|---|
| 906 | + g_free(info_data); |
|---|
| 907 | +#if PHOTO_SUPPORT |
|---|
| 908 | + g_free(photo_url_text); |
|---|
| 909 | + g_free(photo_frame_url_text); |
|---|
| 910 | + g_free(info2_data); |
|---|
| 911 | + if (id != -1) |
|---|
| 912 | + purple_imgstore_unref_by_id(id); |
|---|
| 913 | +#endif |
|---|
| 914 | +} |
|---|
| 915 | + |
|---|
| 916 | +static void nateon_get_info2(PurpleUtilFetchUrlData *url_data, gpointer data, const gchar *url_text, size_t len, const gchar *error_message) |
|---|
| 917 | +{ |
|---|
| 918 | + //This function collects the cookies from url_text and creates a request for the profile from the server |
|---|
| 919 | + NateonGetInfoData *sd = (NateonGetInfoData *)data; |
|---|
| 920 | + char *p, *q, *content, *request; |
|---|
| 921 | + gchar *cookie = NULL; |
|---|
| 922 | + purple_debug_info("nateon", "[%s]\n", __FUNCTION__); |
|---|
| 923 | + |
|---|
| 924 | + content = g_strdup_printf("CMN=%s", sd->ID); |
|---|
| 925 | + |
|---|
| 926 | + //purple_debug_info("nateon", "url_text[%s]\n", url_text); |
|---|
| 927 | + //the CNF cookie is the most important one. All the other cookies are optional, but CFN allows us to get the prfile detials |
|---|
| 928 | + if ((p = strstr(url_text, "CFN=")) != NULL) |
|---|
| 929 | + { |
|---|
| 930 | + if ((q = strchr(p, ';')) != NULL) |
|---|
| 931 | + { |
|---|
| 932 | + cookie = g_strndup(p, q - p); |
|---|
| 933 | + //purple_debug_info("nateon", "cookie[%s]\n", cookie); |
|---|
| 934 | + } |
|---|
| 935 | + } |
|---|
| 936 | + |
|---|
| 937 | + request = g_strdup_printf("POST %s HTTP/1.1\r\n" |
|---|
| 938 | + "Accept: */*\r\n" |
|---|
| 939 | + "Content-Type: application/x-www-form-urlencoded\r\n" |
|---|
| 940 | + "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" |
|---|
| 941 | + "Host: %s\r\n" |
|---|
| 942 | + "Content-Length:%d\r\n" |
|---|
| 943 | + "Connection: Keep-Alive\r\n" |
|---|
| 944 | + "Cookie: %s;\r\n" |
|---|
| 945 | + "\r\n%s", NATEON_PROFILE_PAGE, NATEON_PROFILE_BASE, strlen(content), cookie, content); |
|---|
| 946 | + |
|---|
| 947 | + //purple_debug_info("nateon", "Request[%s]\n", request); |
|---|
| 948 | + |
|---|
| 949 | + purple_util_fetch_url_request(NATEON_PROFILE_BASE, TRUE, |
|---|
| 950 | + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", |
|---|
| 951 | + TRUE, request, TRUE, nateon_got_info, data); |
|---|
| 952 | + |
|---|
| 953 | + g_free(cookie); |
|---|
| 954 | + g_free(request); |
|---|
| 955 | + g_free(content); |
|---|
| 956 | +} |
|---|
| 957 | + |
|---|
| 958 | +static void |
|---|
| 959 | nateon_get_info(PurpleConnection *gc, const char *name) |
|---|
| 960 | { |
|---|
| 961 | - // NateonGetInfoData *data; |
|---|
| 962 | - // char *url; |
|---|
| 963 | - // |
|---|
| 964 | - // data = g_new0(NateonGetInfoData, 1); |
|---|
| 965 | - // data->gc = gc; |
|---|
| 966 | - // data->name = g_strdup(name); |
|---|
| 967 | - // |
|---|
| 968 | - // url = g_strdup_printf("%s%s", PROFILE_URL, name); |
|---|
| 969 | - // |
|---|
| 970 | - // purple_url_fetch(url, FALSE, |
|---|
| 971 | - // "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", |
|---|
| 972 | - // TRUE, nateon_got_info, data); |
|---|
| 973 | - // |
|---|
| 974 | - // g_free(url); |
|---|
| 975 | + //This function makes a login request to the server and gets the cookies returned for use in nateon_get_info2 |
|---|
| 976 | + NateonGetInfoData *data; |
|---|
| 977 | + NateonSession *session; |
|---|
| 978 | + const char *username; |
|---|
| 979 | + char *request; |
|---|
| 980 | + char *content; |
|---|
| 981 | + char *profileurl; |
|---|
| 982 | + char *redirecturl, *id; |
|---|
| 983 | + |
|---|
| 984 | + username = purple_account_get_username(purple_connection_get_account(gc)); |
|---|
| 985 | + session = gc->proto_data; |
|---|
| 986 | + |
|---|
| 987 | + id = nateon_userlist_find_user_with_name(session->userlist, name)->id; |
|---|
| 988 | + |
|---|
| 989 | + data = g_new0(NateonGetInfoData, 1); |
|---|
| 990 | + data->gc = gc; |
|---|
| 991 | + data->name = g_strdup(name); |
|---|
| 992 | + data->ID = g_strdup(id); |
|---|
| 993 | + |
|---|
| 994 | + //purple_debug_info("nateon", "profile url1:{%s}\n", profileurl); |
|---|
| 995 | + profileurl = g_strdup_printf(NATEON_PROFILE_BASE NATEON_PROFILE_PAGE "?CNM=%s", id); |
|---|
| 996 | + //purple_debug_info("nateon", "profile url2:{%s}\n", profileurl); |
|---|
| 997 | + redirecturl = g_strdup_printf("%s%s%s", NATEON_LOGIN_BASE, NATEON_LOGIN_REDIR, purple_url_encode(profileurl)); |
|---|
| 998 | + purple_debug_info("nateon", "redirect url:{%s}\n", redirecturl); |
|---|
| 999 | + |
|---|
| 1000 | + content = g_strdup_printf(NATEON_LOGIN_PAGE_PARAMETERS, session->ticket, purple_url_encode(redirecturl)); |
|---|
| 1001 | + |
|---|
| 1002 | + request = g_strdup_printf("POST %s HTTP/1.1\r\n" |
|---|
| 1003 | + "Accept: */*\r\n" |
|---|
| 1004 | + "Content-Type: application/x-www-form-urlencoded\r\n" |
|---|
| 1005 | + "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n" |
|---|
| 1006 | + "Host: %s\r\n" |
|---|
| 1007 | + "Content-Length:%d\r\n" |
|---|
| 1008 | + "Connection: Keep-Alive\r\n" |
|---|
| 1009 | + "\r\n%s", NATEON_LOGIN_PAGE, NATEON_LOGIN_BASE, strlen(content), content); |
|---|
| 1010 | + |
|---|
| 1011 | + purple_debug_info("nateon", "1st request{%s}\n", request); |
|---|
| 1012 | + |
|---|
| 1013 | + purple_util_fetch_url_request(NATEON_LOGIN_BASE, TRUE, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", |
|---|
| 1014 | + TRUE, request, TRUE, nateon_get_info2, data); |
|---|
| 1015 | + |
|---|
| 1016 | + g_free(request); |
|---|
| 1017 | + g_free(content); |
|---|
| 1018 | + g_free(profileurl); |
|---|
| 1019 | + g_free(redirecturl); |
|---|
| 1020 | } |
|---|
| 1021 | |
|---|
| 1022 | static gboolean nateon_load(PurplePlugin *plugin) |
|---|
| 1023 | Index: trunk/src/nateon.h |
|---|
| 1024 | =================================================================== |
|---|
| 1025 | --- trunk/src/nateon.h (revision 143) |
|---|
| 1026 | +++ trunk/src/nateon.h (working copy) |
|---|
| 1027 | @@ -66,12 +66,16 @@ |
|---|
| 1028 | #define NATEON_TYPING_RECV_TIMEOUT 6 |
|---|
| 1029 | #define NATEON_TYPING_SEND_TIMEOUT 4 |
|---|
| 1030 | |
|---|
| 1031 | -//#define HOTMAIL_URL "http://www.hotmail.com/cgi-bin/folders" |
|---|
| 1032 | -//#define PASSPORT_URL "http://lc1.law13.hotmail.passport.com/cgi-bin/dologin?login=" |
|---|
| 1033 | -//#define PROFILE_URL "http://spaces.msn.com/profile.aspx?mem=" |
|---|
| 1034 | -// |
|---|
| 1035 | -//#define USEROPT_HOTMAIL 0 |
|---|
| 1036 | +#define NATEON_PROFILE_BASE "nateonweb.nate.com" |
|---|
| 1037 | +#define NATEON_PROFILE_PAGE "/client/profile4.0/view.php" |
|---|
| 1038 | +#define NATEON_PHOTO_URL NATEON_PROFILE_BASE "/client/profile4.0/getProfileImage.php?CMN=%s" |
|---|
| 1039 | +#define NATEON_MINIHP_URL NATEON_PROFILE_BASE "/client/profile4.0/minihompi_send.php?menu=Home&TargetCMN=" |
|---|
| 1040 | |
|---|
| 1041 | +#define NATEON_LOGIN_BASE "cyxso.cyworld.com" |
|---|
| 1042 | +#define NATEON_LOGIN_REDIR "/application/cfn_bridge.jsp?r_url=" |
|---|
| 1043 | +#define NATEON_LOGIN_PAGE "/application/ctlogin.jsp" |
|---|
| 1044 | +#define NATEON_LOGIN_PAGE_PARAMETERS "t=%s&r_url=%s&r_flag=y&map_flag=&h_flag=&r_param=" |
|---|
| 1045 | + |
|---|
| 1046 | #define BUDDY_ALIAS_MAXLEN 387 |
|---|
| 1047 | |
|---|
| 1048 | /* |
|---|