comparison src/protocols/yahoo/yahoo_profile.c @ 9242:fb517adf4972

[gaim-migrate @ 10041] wing improved yahoo profile support some more, and now even profile images show up in the get info dialog. Good work wing! committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Wed, 09 Jun 2004 01:40:56 +0000
parents 8054855f2bb9
children adde46ad65e9
comparison
equal deleted inserted replaced
9241:5e9018c81bd9 9242:fb517adf4972
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * 21 *
22 */ 22 */
23 23
24 #define PHOTO_SUPPORT 1
25
24 #include "internal.h" 26 #include "internal.h"
25 #include "debug.h" 27 #include "debug.h"
26 #include "notify.h" 28 #include "notify.h"
27 #include "util.h" 29 #include "util.h"
30 #if PHOTO_SUPPORT
31 #include "imgstore.h"
32 #endif
28 33
29 #include "yahoo.h" 34 #include "yahoo.h"
30 35
31 typedef struct { 36 typedef struct {
32 GaimConnection *gc; 37 GaimConnection *gc;
73 char *cool_link_1_string; 78 char *cool_link_1_string;
74 char *cool_link_2_string; 79 char *cool_link_2_string;
75 char *cool_link_3_string; 80 char *cool_link_3_string;
76 char *dummy; 81 char *dummy;
77 } profile_strings_node_t; 82 } profile_strings_node_t;
83
84
85 typedef struct {
86 YahooGetInfoData *info_data;
87 char *url_buffer;
88 GString *s;
89 char *photo_url_text;
90 char *profile_url_text;
91 char *tooltip_text;
92 const profile_strings_node_t *strings;
93 const char *last_updated_string;
94 } YahooGetInfoStepTwoData;
95
78 96
79 /* Strings to determine the profile "language" (more accurately "locale"). 97 /* Strings to determine the profile "language" (more accurately "locale").
80 * Strings in this list must be in the original charset in the profile. 98 * Strings in this list must be in the original charset in the profile.
81 * The "Last Updated" string is used, but sometimes is not sufficient to 99 * The "Last Updated" string is used, but sometimes is not sufficient to
82 * distinguish 2 locales with this (e.g., ES_ES from ES_US, or FR_CA from 100 * distinguish 2 locales with this (e.g., ES_ES from ES_US, or FR_CA from
611 str[strlen(str) - 5] = '\0'; 629 str[strlen(str) - 5] = '\0';
612 } 630 }
613 return str; 631 return str;
614 } 632 }
615 633
634 static char *yahoo_tooltip_info_text(YahooGetInfoData *info_data) {
635 GString *s = g_string_sized_new(80); /* wild guess */
636 GaimBuddy *b;
637
638 g_string_printf(s, _("<b>%s:</b> %s<br>"), _("Yahoo! ID"), info_data->name);
639 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc),
640 info_data->name);
641
642 if (b) {
643 char *statustext = yahoo_tooltip_text(b);
644 if(b->alias && b->alias[0]) {
645 char *aliastext = g_markup_escape_text(b->alias, -1);
646 g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext);
647 g_free(aliastext);
648 }
649 if (b->idle > 0) {
650 char *idletime = gaim_str_seconds_to_string(time(NULL) - b->idle);
651 g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Idle"),
652 idletime);
653 g_free(idletime);
654 }
655 if (statustext) {
656 g_string_append_printf(s, "%s<br>", statustext);
657 g_free(statustext);
658 }
659 }
660
661 return g_string_free(s, FALSE);
662 }
663
664 #if PHOTO_SUPPORT
665
666 static char *yahoo_get_photo_url(const char *url_text, const char *name) {
667 GString *s = g_string_sized_new(strlen(name) + 8);
668 char *p;
669 char *it = NULL;
670
671 g_string_printf(s, " alt=\"%s\">", name);
672 p = strstr(url_text, s->str);
673
674 if (p) {
675 /* Search backwards for "http://". This is stupid, but it works. */
676 for (; !it && p > url_text; p -= 1) {
677 if (strncmp(p, "\"http://", 8) == 0) {
678 char *q;
679 p += 1; /* skip only the " */
680 q = strchr(p, '"');
681 if (q) {
682 it = g_strndup(p, q - p);
683 }
684 }
685 }
686 }
687
688 g_string_free(s, TRUE);
689 return it;
690 }
691
692 static void yahoo_got_photo(void *data, const char *url_text, size_t len);
693
694 #endif /* PHOTO_SUPPORT */
695
616 static void yahoo_got_info(void *data, const char *url_text, size_t len) 696 static void yahoo_got_info(void *data, const char *url_text, size_t len)
617 { 697 {
618 YahooGetInfoData *info_data = (YahooGetInfoData *)data; 698 YahooGetInfoData *info_data = (YahooGetInfoData *)data;
619 char *stripped, *p; 699 char *p;
620 char buf[1024]; 700 char buf[1024];
701 #if PHOTO_SUPPORT
702 YahooGetInfoStepTwoData *info2_data;
703 char *photo_url_text = NULL;
704 #else
621 gboolean found = FALSE; 705 gboolean found = FALSE;
706 char *stripped;
707 int stripped_len;
708 char *last_updated_utf8_string = NULL;
709 #endif
710 const char *last_updated_string = NULL;
622 char *url_buffer; 711 char *url_buffer;
623 GString *s; 712 GString *s;
624 int stripped_len; 713 char *tooltip_text = NULL;
625 const char *last_updated_string = NULL; 714 char *profile_url_text = NULL;
626 char *last_updated_utf8_string;
627 int lang, strid; 715 int lang, strid;
628 GaimBuddy *b;
629 struct yahoo_data *yd; 716 struct yahoo_data *yd;
717 const profile_strings_node_t *strings = NULL;
630 718
631 if (!GAIM_CONNECTION_IS_VALID(info_data->gc)) { 719 if (!GAIM_CONNECTION_IS_VALID(info_data->gc)) {
632 g_free(info_data->name); 720 g_free(info_data->name);
633 g_free(info_data); 721 g_free(info_data);
634 return; 722 return;
635 } 723 }
636 724
637 gaim_debug_info("yahoo", "In yahoo_got_info\n"); 725 gaim_debug_info("yahoo", "In yahoo_got_info\n");
638 726
639 yd = info_data->gc->proto_data; 727 yd = info_data->gc->proto_data;
728
729 /* Get the tooltip info string */
730 tooltip_text = yahoo_tooltip_info_text(info_data);
640 731
641 /* we failed to grab the profile URL. this should never happen */ 732 /* We failed to grab the profile URL. This is not expected to actually
733 * happen except under unusual error conditions, as Yahoo is observed
734 * to send back HTML, with a 200 status code.
735 */
642 if (url_text == NULL || strcmp(url_text, "") == 0) { 736 if (url_text == NULL || strcmp(url_text, "") == 0) {
737 g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>",
738 tooltip_text, _("Error retrieving profile"));
739
643 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, 740 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
644 _("<html><body><b>Error retrieving profile</b></body></html>"), 741 buf, NULL, NULL);
645 NULL, NULL); 742
646 743 g_free(profile_url_text);
744 g_free(tooltip_text);
647 g_free(info_data->name); 745 g_free(info_data->name);
648 g_free(info_data); 746 g_free(info_data);
649 return; 747 return;
650 } 748 }
651 749
652 /* we don't yet support the multiple link level of the warning page for 750 /* Construct the correct profile URL */
751 s = g_string_sized_new(80); /* wild guess */
752 g_string_printf(s, "%s%s", (yd->jp? YAHOOJP_PROFILE_URL: YAHOO_PROFILE_URL),
753 info_data->name);
754 profile_url_text = g_string_free(s, FALSE);
755 s = NULL;
756
757 /* We don't yet support the multiple link level of the warning page for
653 * 'adult' profiles, not to mention the fact that yahoo wants you to be 758 * 'adult' profiles, not to mention the fact that yahoo wants you to be
654 * logged in (on the website) to be able to view an 'adult' profile. for 759 * logged in (on the website) to be able to view an 'adult' profile. For
655 * now, just tell them that we can't help them, and provide a link to the 760 * now, just tell them that we can't help them, and provide a link to the
656 * profile if they want to do the web browser thing. 761 * profile if they want to do the web browser thing.
657 */ 762 */
658 p = strstr(url_text, "Adult Profiles Warning Message"); 763 p = strstr(url_text, "Adult Profiles Warning Message");
764 if (!p) {
765 p = strstr(url_text, "Adult Content Warning"); /* TITLE element */
766 }
659 if (p) { 767 if (p) {
660 g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>", 768 g_snprintf(buf, 1024, "<html><body>%s<b>%s</b><br><br>\n"
661 _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n"), 769 "%s<br><a href=\"%s\">%s</a></body></html>",
662 _("If you wish to view this profile, you will need to visit this link in your web browser<br>"), 770 tooltip_text,
663 YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name); 771 _("Sorry, profiles marked as containing adult content "
772 "are not supported at this time."),
773 _("If you wish to view this profile, "
774 "you will need to visit this link in your web browser"),
775 profile_url_text, profile_url_text);
664 776
665 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, 777 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
666 buf, NULL, NULL); 778 buf, NULL, NULL);
667 779
780 g_free(profile_url_text);
781 g_free(tooltip_text);
668 g_free(info_data->name); 782 g_free(info_data->name);
669 g_free(info_data); 783 g_free(info_data);
670 return; 784 return;
671 } 785 }
672 786
682 } 796 }
683 if (p) { 797 if (p) {
684 for (strid = 0; profile_strings[strid].lang != XX; strid += 1) { 798 for (strid = 0; profile_strings[strid].lang != XX; strid += 1) {
685 if (profile_strings[strid].lang == profile_langs[lang].lang) break; 799 if (profile_strings[strid].lang == profile_langs[lang].lang) break;
686 } 800 }
801 strings = profile_strings + strid;
687 gaim_debug_info("yahoo", "detected profile lang = %s (%d)\n", profile_strings[strid].lang_string, lang); 802 gaim_debug_info("yahoo", "detected profile lang = %s (%d)\n", profile_strings[strid].lang_string, lang);
688 } 803 }
689 804
690 /* Every user may choose his/her own profile language, and this language 805 /* Every user may choose his/her own profile language, and this language
691 * has nothing to do with the preferences of the user which looks at the 806 * has nothing to do with the preferences of the user which looks at the
692 * profile. We try to support all languages, but nothing is guaranteed. 807 * profile. We try to support all languages, but nothing is guaranteed.
808 * If we cannot determine the language, it means either (1) the profile
809 * is written in an unsupported language, (2) our language support is
810 * out of date, or (3) the user is not found.
693 */ 811 */
694 if (!p || profile_strings[strid].lang == XX) { 812 if (!p || strings->lang == XX) {
695 if (strstr(url_text, "was not found on this server.") == NULL && strstr(url_text, "Yahoo! Member Directory - User not found") == NULL) { 813 if (!strstr(url_text, "Yahoo! Member Directory - User not found")
696 g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>", 814 && !strstr(url_text, "was not found on this server.")
697 _("<b>Sorry, this profile seems to be in a language " 815 && !strstr(url_text, "\xb8\xf8\xb3\xab\xa5\xd7\xa5\xed\xa5\xd5\xa5\xa3\xa1\xbc\xa5\xeb\xa4\xac\xb8\xab\xa4\xc4\xa4\xab\xa4\xea\xa4\xde\xa4\xbb\xa4\xf3")) {
698 "that is not supported at this time.</b><br><br>\n"), 816 g_snprintf(buf, 1024, "<html><body>%s<b>%s</b><br><br>\n"
699 _("If you wish to view this profile, you will need to visit this link in your web browser<br>"), 817 "%s<br><a href=\"%s\">%s</a></body></html>",
700 YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name); 818 tooltip_text,
819 _("Sorry, this profile seems to be in a language "
820 "that is not supported at this time."),
821 _("If you wish to view this profile, "
822 "you will need to visit this link in your web browser"),
823 profile_url_text, profile_url_text);
701 } else { 824 } else {
702 g_snprintf(buf, 1024, "<html><body><b>Error retrieving profile</b></body></html>"); 825 g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>",
826 tooltip_text, _("Error retrieving profile"));
703 } 827 }
704 828
705 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, 829 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL,
706 buf, NULL, NULL); 830 buf, NULL, NULL);
707 831
832 g_free(profile_url_text);
833 g_free(tooltip_text);
708 g_free(info_data->name); 834 g_free(info_data->name);
709 g_free(info_data); 835 g_free(info_data);
710 return; 836 return;
711 } 837 }
838
839 #if PHOTO_SUPPORT
840 photo_url_text = yahoo_get_photo_url(url_text, info_data->name);
841 #endif
712 842
713 url_buffer = g_strdup(url_text); 843 url_buffer = g_strdup(url_text);
714 844
715 /* 845 /*
716 * gaim_markup_strip_html() doesn't strip out character entities like &nbsp; 846 * gaim_markup_strip_html() doesn't strip out character entities like &nbsp;
723 url_buffer[strlen(url_buffer) - 6] = '\0'; 853 url_buffer[strlen(url_buffer) - 6] = '\0';
724 } 854 }
725 #endif 855 #endif
726 856
727 /* nuke the nasty \r's */ 857 /* nuke the nasty \r's */
728 while ((p = strchr(url_buffer, '\r')) != NULL) { 858 gaim_str_strip_cr(url_buffer);
729 memmove(p, p + 1, strlen(p + 1)); 859
730 url_buffer[strlen(url_buffer) - 1] = '\0'; 860 #if PHOTO_SUPPORT
731 } 861
862 /* Marshall the existing state */
863 info2_data = g_malloc(sizeof(YahooGetInfoStepTwoData));
864 info2_data->info_data = info_data;
865 info2_data->url_buffer = url_buffer;
866 info2_data->s = s;
867 info2_data->photo_url_text = photo_url_text;
868 info2_data->profile_url_text = profile_url_text;
869 info2_data->tooltip_text = tooltip_text;
870 info2_data->strings = strings;
871 info2_data->last_updated_string = last_updated_string;
872
873 /* Try to put the photo in there too, if there's one */
874 if (photo_url_text) {
875 /* User-uploaded photos use a different server that requires the Host
876 * header, but Yahoo Japan will use the "chunked" content encoding if
877 * we specify HTTP 1.1. So we have to specify 1.0 & fix gaim_url_fetch
878 */
879 gaim_url_fetch(photo_url_text, FALSE, NULL, FALSE, yahoo_got_photo,
880 info2_data);
881 } else {
882 /* Emulate a callback */
883 yahoo_got_photo(info2_data, NULL, 0);
884 }
885 }
886
887 static void yahoo_got_photo(void *data, const char *url_text, size_t len)
888 {
889 YahooGetInfoStepTwoData *info2_data = (YahooGetInfoStepTwoData *)data;
890 gboolean found = FALSE;
891 int id = -1;
892
893 /* Temporary variables */
894 char *p = NULL;
895 char *stripped;
896 int stripped_len;
897 char *last_updated_utf8_string = NULL;
898
899 /* Unmarshall the saved state */
900 YahooGetInfoData *info_data = info2_data->info_data;
901 char *url_buffer = info2_data->url_buffer;
902 GString *s = info2_data->s;
903 char *photo_url_text = info2_data->photo_url_text;
904 char *profile_url_text = info2_data->profile_url_text;
905 char *tooltip_text = info2_data->tooltip_text;
906 const profile_strings_node_t *strings = info2_data->strings;
907 const char *last_updated_string = info2_data->last_updated_string;
908
909 /* We continue here from yahoo_got_info, as if nothing has happened */
910 #endif /* PHOTO_SUPPORT */
732 911
733 /* nuke the html, it's easier than trying to parse the horrid stuff */ 912 /* nuke the html, it's easier than trying to parse the horrid stuff */
734 stripped = gaim_markup_strip_html(url_buffer); 913 stripped = gaim_markup_strip_html(url_buffer);
735 stripped_len = strlen(stripped); 914 stripped_len = strlen(stripped);
736 915
737 gaim_debug_misc("yahoo", "stripped = %p\n", stripped); 916 gaim_debug_misc("yahoo", "stripped = %p\n", stripped);
738 gaim_debug_misc("yahoo", "url_buffer = %p\n", url_buffer); 917 gaim_debug_misc("yahoo", "url_buffer = %p\n", url_buffer);
739 918
740 /* convert to utf8 */ 919 /* convert to utf8 */
741 p = g_convert(stripped, -1, "utf-8", profile_strings[strid].charset, NULL, NULL, NULL); 920 p = g_convert(stripped, -1, "utf-8", strings->charset, NULL, NULL, NULL);
742 if (!p) { 921 if (!p) {
743 p = g_locale_to_utf8(stripped, -1, NULL, NULL, NULL); 922 p = g_locale_to_utf8(stripped, -1, NULL, NULL, NULL);
744 if (!p) { 923 if (!p) {
745 p = g_convert(stripped, -1, "utf-8", "windows-1252", NULL, NULL, NULL); 924 p = g_convert(stripped, -1, "utf-8", "windows-1252", NULL, NULL, NULL);
746 } 925 }
753 p = stripped; 932 p = stripped;
754 } 933 }
755 /* FIXME need error dialog here */ 934 /* FIXME need error dialog here */
756 935
757 /* "Last updated" should also be converted to utf8 and with &nbsp; killed */ 936 /* "Last updated" should also be converted to utf8 and with &nbsp; killed */
758 last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8", profile_strings[strid].charset, NULL, NULL, NULL); 937 last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8",
938 strings->charset, NULL, NULL, NULL);
759 yahoo_remove_nonbreaking_spaces(last_updated_utf8_string); 939 yahoo_remove_nonbreaking_spaces(last_updated_utf8_string);
760 940
761 gaim_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); 941 gaim_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped);
762 942
763 /* gonna re-use the memory we've already got for url_buffer */ 943 /* gonna re-use the memory we've already got for url_buffer */
764 /* no we're not */ 944 /* no we're not */
765 s = g_string_sized_new(strlen(url_buffer)); 945 s = g_string_sized_new(strlen(url_buffer));
766 g_string_append(s, "<html><body>\n"); 946 g_string_append(s, "<html><body>\n");
767 947
948 #if 0
768 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as 949 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as
769 * true, since the Yahoo! ID will always be there */ 950 * true, since the Yahoo! ID will always be there */
770 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].yahoo_id_string, 2, "\n", 0, 951 if (!gaim_markup_extract_info_field(stripped, stripped_len, s,
952 strings->yahoo_id_string, 2, "\n", 0,
771 NULL, _("Yahoo! ID"), 0, NULL)) 953 NULL, _("Yahoo! ID"), 0, NULL))
772 g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Yahoo! ID"), info_data->name); 954 ;
773 955 #endif
774 /* Display the alias, idle time, and status message below the Yahoo! ID */ 956
775 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), info_data->name); 957 /* Put the Yahoo! ID, nickname, idle time, and status message in */
776 if (b) { 958 g_string_append(s, tooltip_text);
777 char *statustext = yahoo_tooltip_text(b); 959
778 if(b->alias && b->alias[0]) { 960 #if PHOTO_SUPPORT
779 char *aliastext = g_markup_escape_text(b->alias, -1); 961
780 g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext); 962 /* Try to put the photo in there too, if there's one and is readable */
781 g_free(aliastext); 963 if (data && url_text && len != 0) {
964 if (strstr(url_text, "400 Bad Request")
965 || strstr(url_text, "403 Forbidden")
966 || strstr(url_text, "404 Not Found")) {
967
968 gaim_debug_info("yahoo", "Error getting %s: %s\n",
969 photo_url_text, url_text);
970 } else {
971 gaim_debug_info("yahoo", "%s is %d bytes\n", photo_url_text, len);
972 id = gaim_imgstore_add(url_text, len, NULL);
973 g_string_append_printf(s, "<img id=\"%d\"><br>", id);
782 } 974 }
783 if (b->idle > 0) { 975 }
784 char *idletime = gaim_str_seconds_to_string(time(NULL) - b->idle); 976
785 g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Idle"), idletime); 977 #endif /* PHOTO_SUPPORT */
786 g_free(idletime);
787 }
788 if (statustext) {
789 g_string_append_printf(s, "%s<br>", statustext);
790 g_free(statustext);
791 }
792 }
793 978
794 /* extract their Email address and put it in */ 979 /* extract their Email address and put it in */
795 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].my_email_string, 5, "\n", 0, 980 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
796 profile_strings[strid].private_string, _("Email"), 0, NULL); 981 strings->my_email_string, 5, "\n", 0,
982 strings->private_string, _("Email"), 0, NULL);
797 983
798 /* extract the Nickname if it exists */ 984 /* extract the Nickname if it exists */
799 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Nickname:", 1, "\n", '\n', 985 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
986 "Nickname:", 1, "\n", '\n',
800 NULL, _("Nickname"), 0, NULL); 987 NULL, _("Nickname"), 0, NULL);
801 988
802 /* extract their RealName and put it in */ 989 /* extract their RealName and put it in */
803 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].realname_string, 1, "\n", '\n', 990 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
991 strings->realname_string, 1, "\n", '\n',
804 NULL, _("Realname"), 0, NULL); 992 NULL, _("Realname"), 0, NULL);
805 993
806 /* extract their Location and put it in */ 994 /* extract their Location and put it in */
807 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].location_string, 2, "\n", '\n', 995 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
996 strings->location_string, 2, "\n", '\n',
808 NULL, _("Location"), 0, NULL); 997 NULL, _("Location"), 0, NULL);
809 998
810 /* extract their Age and put it in */ 999 /* extract their Age and put it in */
811 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].age_string, 3, "\n", '\n', 1000 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
1001 strings->age_string, 3, "\n", '\n',
812 NULL, _("Age"), 0, NULL); 1002 NULL, _("Age"), 0, NULL);
813 1003
814 /* extract their MaritalStatus and put it in */ 1004 /* extract their MaritalStatus and put it in */
815 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].maritalstatus_string, 3, "\n", '\n', 1005 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
816 profile_strings[strid].no_answer_string, _("Marital Status"), 0, NULL); 1006 strings->maritalstatus_string, 3, "\n", '\n',
1007 strings->no_answer_string, _("Marital Status"), 0, NULL);
817 1008
818 /* extract their Gender and put it in */ 1009 /* extract their Gender and put it in */
819 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].gender_string, 3, "\n", '\n', 1010 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
820 profile_strings[strid].no_answer_string, _("Gender"), 0, NULL); 1011 strings->gender_string, 3, "\n", '\n',
1012 strings->no_answer_string, _("Gender"), 0, NULL);
821 1013
822 /* extract their Occupation and put it in */ 1014 /* extract their Occupation and put it in */
823 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].occupation_string, 2, "\n", '\n', 1015 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
1016 strings->occupation_string, 2, "\n", '\n',
824 NULL, _("Occupation"), 0, NULL); 1017 NULL, _("Occupation"), 0, NULL);
825 1018
826 /* Hobbies, Latest News, and Favorite Quote are a bit different, since the 1019 /* Hobbies, Latest News, and Favorite Quote are a bit different, since
827 * values can contain embedded newlines... but any or all of them can also 1020 * the values can contain embedded newlines... but any or all of them
828 * not appear. The way we delimit them is to successively look for the next 1021 * can also not appear. The way we delimit them is to successively
829 * one that _could_ appear, and if all else fails, we end the section by 1022 * look for the next one that _could_ appear, and if all else fails,
830 * looking for the 'Links' heading, which is the next thing to follow this 1023 * we end the section by looking for the 'Links' heading, which is the
831 * bunch. 1024 * next thing to follow this bunch. (For Yahoo Japan, we check for
1025 * the "Description" ("Self PR") heading instead of "Links".)
832 */ 1026 */
833 1027
834 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].hobbies_string, 1, profile_strings[strid].latest_news_string, 1028 if (!gaim_markup_extract_info_field(stripped, stripped_len, s,
1029 strings->hobbies_string, 1, strings->latest_news_string,
835 '\n', NULL, _("Hobbies"), 0, NULL)) 1030 '\n', NULL, _("Hobbies"), 0, NULL))
836 { 1031 {
837 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].hobbies_string, 1, profile_strings[strid].favorite_quote_string, 1032 if (!gaim_markup_extract_info_field(stripped, stripped_len, s,
1033 strings->hobbies_string, 1, strings->favorite_quote_string,
838 '\n', NULL, _("Hobbies"), 0, NULL)) 1034 '\n', NULL, _("Hobbies"), 0, NULL))
839 { 1035 {
840 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].hobbies_string, 1, profile_strings[strid].links_string, 1036 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
1037 strings->hobbies_string, 1, strings->links_string,
841 '\n', NULL, _("Hobbies"), 0, NULL); 1038 '\n', NULL, _("Hobbies"), 0, NULL);
842 } 1039 }
843 else 1040 else
844 found = TRUE; 1041 found = TRUE;
845 } 1042 }
846 else 1043 else
847 found = TRUE; 1044 found = TRUE;
848 1045
849 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].latest_news_string, 1, profile_strings[strid].favorite_quote_string, 1046 if (!gaim_markup_extract_info_field(stripped, stripped_len, s,
1047 strings->latest_news_string, 1, strings->favorite_quote_string,
850 '\n', NULL, _("Latest News"), 0, NULL)) 1048 '\n', NULL, _("Latest News"), 0, NULL))
851 { 1049 {
852 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].latest_news_string, 1, profile_strings[strid].links_string, 1050 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
1051 strings->latest_news_string, 1, strings->links_string,
853 '\n', NULL, _("Latest News"), 0, NULL); 1052 '\n', NULL, _("Latest News"), 0, NULL);
854 } 1053 }
855 else 1054 else
856 found = TRUE; 1055 found = TRUE;
857 1056
858 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].favorite_quote_string, 1, profile_strings[strid].links_string, 1057 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
1058 strings->favorite_quote_string, 1, strings->links_string,
859 '\n', NULL, _("Favorite Quote"), 0, NULL); 1059 '\n', NULL, _("Favorite Quote"), 0, NULL);
860 1060
861 /* Home Page will either be "No home page specified", 1061 /* Home Page will either be "No home page specified",
862 * or "Home Page: " and a link. 1062 * or "Home Page: " and a link.
863 * For non-English profiles, there might be no "Home Page:" string at all, 1063 * For Yahoo! Japan, if there is no home page specified,
864 * in which case we probably can do nothing about it. 1064 * neither "No home page specified" nor "Home Page:" is shown.
865 */ 1065 */
866 if (profile_strings[strid].home_page_string) { 1066 if (strings->home_page_string) {
867 p = !profile_strings[strid].no_home_page_specified_string? NULL: 1067 p = !strings->no_home_page_specified_string? NULL:
868 strstr(stripped, profile_strings[strid].no_home_page_specified_string); 1068 strstr(stripped, strings->no_home_page_specified_string);
869 if(!p) 1069 if(!p)
870 { 1070 {
871 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].home_page_string, 1, "\n", 0, NULL, 1071 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
1072 strings->home_page_string, 1, "\n", 0, NULL,
872 _("Home Page"), 1, NULL); 1073 _("Home Page"), 1, NULL);
873 } 1074 }
874 } 1075 }
875 1076
876 /* Cool Link {1,2,3} is also different. If "No cool link specified" exists, 1077 /* Cool Link {1,2,3} is also different. If "No cool link specified"
877 * then we have none. If we have one however, we'll need to check and see 1078 * exists, then we have none. If we have one however, we'll need to
878 * if we have a second one. If we have a second one, we have to check to 1079 * check and see if we have a second one. If we have a second one,
879 * see if we have a third one. 1080 * we have to check to see if we have a third one.
880 */ 1081 */
881 p = !profile_strings[strid].no_cool_link_specified_string? NULL: 1082 p = !strings->no_cool_link_specified_string? NULL:
882 strstr(stripped,profile_strings[strid].no_cool_link_specified_string); 1083 strstr(stripped,strings->no_cool_link_specified_string);
883 if (!p) 1084 if (!p)
884 { 1085 {
885 if (gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].cool_link_1_string, 1, "\n", 0, NULL, 1086 if (gaim_markup_extract_info_field(stripped, stripped_len, s,
1087 strings->cool_link_1_string, 1, "\n", 0, NULL,
886 _("Cool Link 1"), 1, NULL)) 1088 _("Cool Link 1"), 1, NULL))
887 { 1089 {
888 found = TRUE; 1090 found = TRUE;
889 if (gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].cool_link_2_string, 1, "\n", 0, NULL, 1091 if (gaim_markup_extract_info_field(stripped, stripped_len, s,
1092 strings->cool_link_2_string, 1, "\n", 0, NULL,
890 _("Cool Link 2"), 1, NULL)) 1093 _("Cool Link 2"), 1, NULL))
891 gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].cool_link_3_string, 1, "\n", 0, NULL, 1094 {
1095 gaim_markup_extract_info_field(stripped, stripped_len, s,
1096 strings->cool_link_3_string, 1, "\n", 0, NULL,
892 _("Cool Link 3"), 1, NULL); 1097 _("Cool Link 3"), 1, NULL);
1098 }
893 } 1099 }
894 } 1100 }
895 1101
896 /* see if Member Since is there, and if so, extract it. */ 1102 /* see if Member Since is there, and if so, extract it. */
897 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Member Since:", 1, last_updated_utf8_string, 1103 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
1104 "Member Since:", 1, last_updated_utf8_string,
898 '\n', NULL, _("Member Since"), 0, NULL); 1105 '\n', NULL, _("Member Since"), 0, NULL);
899 1106
900 /* extract the Last Updated date and put it in */ 1107 /* extract the Last Updated date and put it in */
901 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, last_updated_utf8_string, 0, "\n", '\n', NULL, 1108 found |= gaim_markup_extract_info_field(stripped, stripped_len, s,
1109 last_updated_utf8_string, 0, "\n", '\n', NULL,
902 _("Last Updated"), 0, NULL); 1110 _("Last Updated"), 0, NULL);
903 1111
904 /* put a link to the actual profile URL */ 1112 /* put a link to the actual profile URL */
905 g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL")); 1113 g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL"));
906 g_string_append_printf(s, "<a href=\"%s%s\">%s%s</a><br>", 1114 g_string_append_printf(s, "<br><a href=\"%s\">%s</a><br>",
907 (yd->jp? YAHOOJP_PROFILE_URL: YAHOO_PROFILE_URL), info_data->name, 1115 profile_url_text, profile_url_text);
908 (yd->jp? YAHOOJP_PROFILE_URL: YAHOO_PROFILE_URL), info_data->name);
909 1116
910 /* finish off the html */ 1117 /* finish off the html */
911 g_string_append(s, "</body></html>\n"); 1118 g_string_append(s, "</body></html>\n");
912 g_free(stripped); 1119 g_free(stripped);
913 1120
927 } 1134 }
928 1135
929 g_free(last_updated_utf8_string); 1136 g_free(last_updated_utf8_string);
930 g_free(url_buffer); 1137 g_free(url_buffer);
931 g_string_free(s, TRUE); 1138 g_string_free(s, TRUE);
1139 g_free(profile_url_text);
1140 g_free(tooltip_text);
932 g_free(info_data->name); 1141 g_free(info_data->name);
933 g_free(info_data); 1142 g_free(info_data);
1143
1144 #if PHOTO_SUPPORT
1145 g_free(photo_url_text);
1146 g_free(info2_data);
1147 if (id != -1)
1148 gaim_imgstore_unref(id);
1149 #endif
934 } 1150 }
935 1151
936 void yahoo_get_info(GaimConnection *gc, const char *name) 1152 void yahoo_get_info(GaimConnection *gc, const char *name)
937 { 1153 {
938 struct yahoo_data *yd = gc->proto_data; 1154 struct yahoo_data *yd = gc->proto_data;