Mercurial > pidgin
comparison src/protocols/yahoo/yahoo.c @ 7095:c8bf2da398e3
[gaim-migrate @ 7660]
html.[ch] is gone. Everything inside was namespaced and put in util.[ch].
One less ugly part of gaim in the tree.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 01 Oct 2003 03:43:18 +0000 |
parents | 2343c3aa1dec |
children | 9220c7490cd1 |
comparison
equal
deleted
inserted
replaced
7094:2343c3aa1dec | 7095:c8bf2da398e3 |
---|---|
31 #include "prpl.h" | 31 #include "prpl.h" |
32 #include "proxy.h" | 32 #include "proxy.h" |
33 #include "request.h" | 33 #include "request.h" |
34 #include "server.h" | 34 #include "server.h" |
35 #include "util.h" | 35 #include "util.h" |
36 #include "html.h" | |
37 | 36 |
38 #include "sha.h" | 37 #include "sha.h" |
39 #include "yahoo.h" | 38 #include "yahoo.h" |
40 #include "yahoochat.h" | 39 #include "yahoochat.h" |
41 #include "md5.h" | 40 #include "md5.h" |
1917 return g_strdup(yahoo_get_status_string(f->status)); | 1916 return g_strdup(yahoo_get_status_string(f->status)); |
1918 return NULL; | 1917 return NULL; |
1919 case YAHOO_STATUS_CUSTOM: | 1918 case YAHOO_STATUS_CUSTOM: |
1920 if (!f->msg) | 1919 if (!f->msg) |
1921 return NULL; | 1920 return NULL; |
1922 stripped = strip_html(f->msg); | 1921 stripped = gaim_markup_strip_html(f->msg); |
1923 if (stripped) { | 1922 if (stripped) { |
1924 char *ret = g_markup_escape_text(stripped, strlen(stripped)); | 1923 char *ret = g_markup_escape_text(stripped, strlen(stripped)); |
1925 g_free(stripped); | 1924 g_free(stripped); |
1926 return ret; | 1925 return ret; |
1927 } | 1926 } |
1951 } | 1950 } |
1952 return NULL; | 1951 return NULL; |
1953 case YAHOO_STATUS_CUSTOM: | 1952 case YAHOO_STATUS_CUSTOM: |
1954 if (!f->msg) | 1953 if (!f->msg) |
1955 return NULL; | 1954 return NULL; |
1956 status = strip_html(f->msg); | 1955 status = gaim_markup_strip_html(f->msg); |
1957 break; | 1956 break; |
1958 default: | 1957 default: |
1959 status = g_strdup(yahoo_get_status_string(f->status)); | 1958 status = g_strdup(yahoo_get_status_string(f->status)); |
1960 break; | 1959 break; |
1961 } | 1960 } |
2409 * profile if they want to do the web browser thing. | 2408 * profile if they want to do the web browser thing. |
2410 */ | 2409 */ |
2411 p = strstr(url_text, "Adult Profiles Warning Message"); | 2410 p = strstr(url_text, "Adult Profiles Warning Message"); |
2412 if (p) { | 2411 if (p) { |
2413 strcpy(buf, _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n")); | 2412 strcpy(buf, _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n")); |
2414 info_extract_field(url_text, buf, ".idname=", 0, "%26", 0, NULL, | 2413 gaim_markup_extract_info_field(url_text, buf, ".idname=", 0, "%26", 0, NULL, |
2415 _("If you wish to view this profile, you will need to visit this link in your web browser"), | 2414 _("If you wish to view this profile, you will need to visit this link in your web browser"), |
2416 1, YAHOO_PROFILE_URL); | 2415 1, YAHOO_PROFILE_URL); |
2417 strcat(buf, "</body></html>\n"); | 2416 strcat(buf, "</body></html>\n"); |
2418 gaim_notify_formatted(data, NULL, _("Buddy Information"), NULL, | 2417 gaim_notify_formatted(data, NULL, _("Buddy Information"), NULL, |
2419 buf, NULL, NULL); | 2418 buf, NULL, NULL); |
2426 * user which looks at the profile | 2425 * user which looks at the profile |
2427 */ | 2426 */ |
2428 p = strstr(url_text, "Last Updated:"); | 2427 p = strstr(url_text, "Last Updated:"); |
2429 if (!p) { | 2428 if (!p) { |
2430 strcpy(buf, _("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n")); | 2429 strcpy(buf, _("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n")); |
2431 info_extract_field(url_text, buf, "<title>", 0, "'s Yahoo! Profile", 0, NULL, | 2430 gaim_markup_extract_info_field(url_text, buf, "<title>", 0, "'s Yahoo! Profile", 0, NULL, |
2432 _("If you wish to view this profile, you will need to visit this link in your web browser"), | 2431 _("If you wish to view this profile, you will need to visit this link in your web browser"), |
2433 1, YAHOO_PROFILE_URL); | 2432 1, YAHOO_PROFILE_URL); |
2434 strcat(buf, "</body></html>\n"); | 2433 strcat(buf, "</body></html>\n"); |
2435 gaim_notify_formatted(data, NULL, _("Buddy Information"), NULL, | 2434 gaim_notify_formatted(data, NULL, _("Buddy Information"), NULL, |
2436 buf, NULL, NULL); | 2435 buf, NULL, NULL); |
2437 return; | 2436 return; |
2438 } | 2437 } |
2439 | 2438 |
2440 url_buffer = g_strdup(url_text); | 2439 url_buffer = g_strdup(url_text); |
2441 | 2440 |
2442 /* strip_html() doesn't strip out character entities like and · | 2441 /* gaim_markup_strip_html() doesn't strip out character entities like and · |
2443 */ | 2442 */ |
2444 while ((p = strstr(url_buffer, " ")) != NULL) { | 2443 while ((p = strstr(url_buffer, " ")) != NULL) { |
2445 memmove(p, p + 6, strlen(p + 6)); | 2444 memmove(p, p + 6, strlen(p + 6)); |
2446 url_buffer[strlen(url_buffer) - 6] = '\0'; | 2445 url_buffer[strlen(url_buffer) - 6] = '\0'; |
2447 } | 2446 } |
2455 memmove(p, p + 1, strlen(p + 1)); | 2454 memmove(p, p + 1, strlen(p + 1)); |
2456 url_buffer[strlen(url_buffer) - 1] = '\0'; | 2455 url_buffer[strlen(url_buffer) - 1] = '\0'; |
2457 } | 2456 } |
2458 | 2457 |
2459 /* nuke the html, it's easier than trying to parse the horrid stuff */ | 2458 /* nuke the html, it's easier than trying to parse the horrid stuff */ |
2460 stripped = strip_html(url_buffer); | 2459 stripped = gaim_markup_strip_html(url_buffer); |
2461 | 2460 |
2462 /* gonna re-use the memory we've already got for url_buffer */ | 2461 /* gonna re-use the memory we've already got for url_buffer */ |
2463 strcpy(url_buffer, "<html><body>\n"); | 2462 strcpy(url_buffer, "<html><body>\n"); |
2464 | 2463 |
2465 /* extract their Yahoo! ID and put it in */ | 2464 /* extract their Yahoo! ID and put it in */ |
2466 info_extract_field(stripped, url_buffer, "Yahoo! ID:", 2, "\n", 0, | 2465 gaim_markup_extract_info_field(stripped, url_buffer, "Yahoo! ID:", 2, "\n", 0, |
2467 NULL, _("Yahoo! ID"), 0, NULL); | 2466 NULL, _("Yahoo! ID"), 0, NULL); |
2468 | 2467 |
2469 /* extract their Email address and put it in */ | 2468 /* extract their Email address and put it in */ |
2470 info_extract_field(stripped, url_buffer, "My Email", 5, "\n", 0, | 2469 gaim_markup_extract_info_field(stripped, url_buffer, "My Email", 5, "\n", 0, |
2471 "Private", _("Email"), 0, NULL); | 2470 "Private", _("Email"), 0, NULL); |
2472 | 2471 |
2473 /* extract the Nickname if it exists */ | 2472 /* extract the Nickname if it exists */ |
2474 info_extract_field(stripped, url_buffer, "Nickname:", 1, "\n", '\n', | 2473 gaim_markup_extract_info_field(stripped, url_buffer, "Nickname:", 1, "\n", '\n', |
2475 NULL, _("Nickname"), 0, NULL); | 2474 NULL, _("Nickname"), 0, NULL); |
2476 | 2475 |
2477 /* extract their RealName and put it in */ | 2476 /* extract their RealName and put it in */ |
2478 info_extract_field(stripped, url_buffer, "RealName:", 1, "\n", '\n', | 2477 gaim_markup_extract_info_field(stripped, url_buffer, "RealName:", 1, "\n", '\n', |
2479 NULL, _("Realname"), 0, NULL); | 2478 NULL, _("Realname"), 0, NULL); |
2480 | 2479 |
2481 /* extract their Location and put it in */ | 2480 /* extract their Location and put it in */ |
2482 info_extract_field(stripped, url_buffer, "Location:", 2, "\n", '\n', | 2481 gaim_markup_extract_info_field(stripped, url_buffer, "Location:", 2, "\n", '\n', |
2483 NULL, _("Location"), 0, NULL); | 2482 NULL, _("Location"), 0, NULL); |
2484 | 2483 |
2485 /* extract their Age and put it in */ | 2484 /* extract their Age and put it in */ |
2486 info_extract_field(stripped, url_buffer, "Age:", 3, "\n", '\n', | 2485 gaim_markup_extract_info_field(stripped, url_buffer, "Age:", 3, "\n", '\n', |
2487 NULL, _("Age"), 0, NULL); | 2486 NULL, _("Age"), 0, NULL); |
2488 | 2487 |
2489 /* extract their MaritalStatus and put it in */ | 2488 /* extract their MaritalStatus and put it in */ |
2490 info_extract_field(stripped, url_buffer, "MaritalStatus:", 3, "\n", '\n', | 2489 gaim_markup_extract_info_field(stripped, url_buffer, "MaritalStatus:", 3, "\n", '\n', |
2491 "No Answer", _("Marital Status"), 0, NULL); | 2490 "No Answer", _("Marital Status"), 0, NULL); |
2492 | 2491 |
2493 /* extract their Gender and put it in */ | 2492 /* extract their Gender and put it in */ |
2494 info_extract_field(stripped, url_buffer, "Gender:", 3, "\n", '\n', | 2493 gaim_markup_extract_info_field(stripped, url_buffer, "Gender:", 3, "\n", '\n', |
2495 "No Answer", _("Gender"), 0, NULL); | 2494 "No Answer", _("Gender"), 0, NULL); |
2496 | 2495 |
2497 /* extract their Occupation and put it in */ | 2496 /* extract their Occupation and put it in */ |
2498 info_extract_field(stripped, url_buffer, "Occupation:", 2, "\n", '\n', | 2497 gaim_markup_extract_info_field(stripped, url_buffer, "Occupation:", 2, "\n", '\n', |
2499 NULL, _("Occupation"), 0, NULL); | 2498 NULL, _("Occupation"), 0, NULL); |
2500 | 2499 |
2501 /* Hobbies, Latest News, and Favorite Quote are a bit different, since the | 2500 /* Hobbies, Latest News, and Favorite Quote are a bit different, since the |
2502 * values can contain embedded newlines... but any or all of them can also | 2501 * values can contain embedded newlines... but any or all of them can also |
2503 * not appear. The way we delimit them is to successively look for the next | 2502 * not appear. The way we delimit them is to successively look for the next |
2504 * one that _could_ appear, and if all else fails, we end the section by | 2503 * one that _could_ appear, and if all else fails, we end the section by |
2505 * looking for the 'Links' heading, which is the next thing to follow this | 2504 * looking for the 'Links' heading, which is the next thing to follow this |
2506 * bunch. | 2505 * bunch. |
2507 */ | 2506 */ |
2508 if (!info_extract_field(stripped, url_buffer, "Hobbies:", 1, "Latest News", | 2507 if (!gaim_markup_extract_info_field(stripped, url_buffer, "Hobbies:", 1, "Latest News", |
2509 '\n', NULL, _("Hobbies"), 0, NULL)) | 2508 '\n', NULL, _("Hobbies"), 0, NULL)) |
2510 if (!info_extract_field(stripped, url_buffer, "Hobbies:", 1, "Favorite Quote", | 2509 if (!gaim_markup_extract_info_field(stripped, url_buffer, "Hobbies:", 1, "Favorite Quote", |
2511 '\n', NULL, _("Hobbies"), 0, NULL)) | 2510 '\n', NULL, _("Hobbies"), 0, NULL)) |
2512 info_extract_field(stripped, url_buffer, "Hobbies:", 1, "Links", | 2511 gaim_markup_extract_info_field(stripped, url_buffer, "Hobbies:", 1, "Links", |
2513 '\n', NULL, _("Hobbies"), 0, NULL); | 2512 '\n', NULL, _("Hobbies"), 0, NULL); |
2514 if (!info_extract_field(stripped, url_buffer, "Latest News:", 1, "Favorite Quote", | 2513 if (!gaim_markup_extract_info_field(stripped, url_buffer, "Latest News:", 1, "Favorite Quote", |
2515 '\n', NULL, _("Latest News"), 0, NULL)) | 2514 '\n', NULL, _("Latest News"), 0, NULL)) |
2516 info_extract_field(stripped, url_buffer, "Latest News:", 1, "Links", | 2515 gaim_markup_extract_info_field(stripped, url_buffer, "Latest News:", 1, "Links", |
2517 '\n', NULL, _("Latest News"), 0, NULL); | 2516 '\n', NULL, _("Latest News"), 0, NULL); |
2518 info_extract_field(stripped, url_buffer, "Favorite Quote:", 0, "Links", | 2517 gaim_markup_extract_info_field(stripped, url_buffer, "Favorite Quote:", 0, "Links", |
2519 '\n', NULL, _("Favorite Quote"), 0, NULL); | 2518 '\n', NULL, _("Favorite Quote"), 0, NULL); |
2520 | 2519 |
2521 /* Home Page will either be "No home page specified", | 2520 /* Home Page will either be "No home page specified", |
2522 * or "Home Page: " and a link. */ | 2521 * or "Home Page: " and a link. */ |
2523 p = strstr(stripped, "No home page specified"); | 2522 p = strstr(stripped, "No home page specified"); |
2524 if (!p) | 2523 if (!p) |
2525 info_extract_field(stripped, url_buffer, "Home Page:", 1, " ", 0, NULL, | 2524 gaim_markup_extract_info_field(stripped, url_buffer, "Home Page:", 1, " ", 0, NULL, |
2526 _("Home Page"), 1, NULL); | 2525 _("Home Page"), 1, NULL); |
2527 | 2526 |
2528 /* Cool Link {1,2,3} is also different. If "No cool link specified" exists, | 2527 /* Cool Link {1,2,3} is also different. If "No cool link specified" exists, |
2529 * then we have none. If we have one however, we'll need to check and see if | 2528 * then we have none. If we have one however, we'll need to check and see if |
2530 * we have a second one. If we have a second one, we have to check to see if | 2529 * we have a second one. If we have a second one, we have to check to see if |
2531 * we have a third one. | 2530 * we have a third one. |
2532 */ | 2531 */ |
2533 p = strstr(stripped,"No cool link specified"); | 2532 p = strstr(stripped,"No cool link specified"); |
2534 if (!p) | 2533 if (!p) |
2535 if (info_extract_field(stripped, url_buffer, "Cool Link 1:", 1, " ", 0, NULL, | 2534 if (gaim_markup_extract_info_field(stripped, url_buffer, "Cool Link 1:", 1, " ", 0, NULL, |
2536 _("Cool Link 1"), 1, NULL)) | 2535 _("Cool Link 1"), 1, NULL)) |
2537 if (info_extract_field(stripped, url_buffer, "Cool Link 2:", 1, " ", 0, NULL, | 2536 if (gaim_markup_extract_info_field(stripped, url_buffer, "Cool Link 2:", 1, " ", 0, NULL, |
2538 _("Cool Link 2"), 1, NULL)) | 2537 _("Cool Link 2"), 1, NULL)) |
2539 info_extract_field(stripped, url_buffer, "Cool Link 3:", 1, " ", 0, NULL, | 2538 gaim_markup_extract_info_field(stripped, url_buffer, "Cool Link 3:", 1, " ", 0, NULL, |
2540 _("Cool Link 3"), 1, NULL); | 2539 _("Cool Link 3"), 1, NULL); |
2541 | 2540 |
2542 /* see if Member Since is there, and if so, extract it. */ | 2541 /* see if Member Since is there, and if so, extract it. */ |
2543 info_extract_field(stripped, url_buffer, "Member Since:", 1, "Last Updated:", | 2542 gaim_markup_extract_info_field(stripped, url_buffer, "Member Since:", 1, "Last Updated:", |
2544 '\n', NULL, _("Member Since"), 0, NULL); | 2543 '\n', NULL, _("Member Since"), 0, NULL); |
2545 | 2544 |
2546 /* extract the Last Updated date and put it in */ | 2545 /* extract the Last Updated date and put it in */ |
2547 info_extract_field(stripped, url_buffer, "Last Updated:", 1, "\n", '\n', NULL, | 2546 gaim_markup_extract_info_field(stripped, url_buffer, "Last Updated:", 1, "\n", '\n', NULL, |
2548 _("Last Updated"), 0, NULL); | 2547 _("Last Updated"), 0, NULL); |
2549 | 2548 |
2550 /* finish off the html */ | 2549 /* finish off the html */ |
2551 strcat(url_buffer, "</body></html>\n"); | 2550 strcat(url_buffer, "</body></html>\n"); |
2552 g_free(stripped); | 2551 g_free(stripped); |