Mercurial > pidgin
comparison libpurple/protocols/yahoo/yahoo_profile.c @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 2c33e35a5084 |
children | 391a79778f89 |
comparison
equal
deleted
inserted
replaced
15821:84b0f9b23ede | 15822:32c366eeeb99 |
---|---|
1 /* | 1 /* |
2 * gaim | 2 * purple |
3 * | 3 * |
4 * Gaim is the legal property of its developers, whose names are too numerous | 4 * Purple is the legal property of its developers, whose names are too numerous |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | 5 * to list here. Please refer to the COPYRIGHT file distributed with this |
6 * source distribution. | 6 * source distribution. |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | 9 * it under the terms of the GNU General Public License as published by |
33 | 33 |
34 #include "yahoo.h" | 34 #include "yahoo.h" |
35 #include "yahoo_friend.h" | 35 #include "yahoo_friend.h" |
36 | 36 |
37 typedef struct { | 37 typedef struct { |
38 GaimConnection *gc; | 38 PurpleConnection *gc; |
39 char *name; | 39 char *name; |
40 } YahooGetInfoData; | 40 } YahooGetInfoData; |
41 | 41 |
42 typedef enum profile_lang_id { | 42 typedef enum profile_lang_id { |
43 XX, DA, DE, EL, | 43 XX, DA, DE, EL, |
87 PROFILE_STATE_UNKNOWN_LANGUAGE | 87 PROFILE_STATE_UNKNOWN_LANGUAGE |
88 } profile_state_t; | 88 } profile_state_t; |
89 | 89 |
90 typedef struct { | 90 typedef struct { |
91 YahooGetInfoData *info_data; | 91 YahooGetInfoData *info_data; |
92 GaimNotifyUserInfo *user_info; | 92 PurpleNotifyUserInfo *user_info; |
93 char *url_buffer; | 93 char *url_buffer; |
94 char *photo_url_text; | 94 char *photo_url_text; |
95 char *profile_url_text; | 95 char *profile_url_text; |
96 const profile_strings_node_t *strings; | 96 const profile_strings_node_t *strings; |
97 const char *last_updated_string; | 97 const char *last_updated_string; |
647 }; | 647 }; |
648 | 648 |
649 static char *yahoo_info_date_reformat(const char *field, size_t len) | 649 static char *yahoo_info_date_reformat(const char *field, size_t len) |
650 { | 650 { |
651 char *tmp = g_strndup(field, len); | 651 char *tmp = g_strndup(field, len); |
652 time_t t = gaim_str_to_time(tmp, FALSE, NULL, NULL, NULL); | 652 time_t t = purple_str_to_time(tmp, FALSE, NULL, NULL, NULL); |
653 | 653 |
654 g_free(tmp); | 654 g_free(tmp); |
655 return g_strdup(gaim_date_format_short(localtime(&t))); | 655 return g_strdup(purple_date_format_short(localtime(&t))); |
656 } | 656 } |
657 | 657 |
658 static char *yahoo_remove_nonbreaking_spaces(char *str) | 658 static char *yahoo_remove_nonbreaking_spaces(char *str) |
659 { | 659 { |
660 char *p; | 660 char *p; |
665 str[strlen(str) - 5] = '\0'; | 665 str[strlen(str) - 5] = '\0'; |
666 } | 666 } |
667 return str; | 667 return str; |
668 } | 668 } |
669 | 669 |
670 static void yahoo_extract_user_info_text(GaimNotifyUserInfo *user_info, YahooGetInfoData *info_data) { | 670 static void yahoo_extract_user_info_text(PurpleNotifyUserInfo *user_info, YahooGetInfoData *info_data) { |
671 GaimBuddy *b; | 671 PurpleBuddy *b; |
672 YahooFriend *f; | 672 YahooFriend *f; |
673 | 673 |
674 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), | 674 b = purple_find_buddy(purple_connection_get_account(info_data->gc), |
675 info_data->name); | 675 info_data->name); |
676 | 676 |
677 if (b) { | 677 if (b) { |
678 if(b->alias && b->alias[0]) { | 678 if(b->alias && b->alias[0]) { |
679 char *aliastext = g_markup_escape_text(b->alias, -1); | 679 char *aliastext = g_markup_escape_text(b->alias, -1); |
680 gaim_notify_user_info_add_pair(user_info, _("Alias"), aliastext); | 680 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); |
681 g_free(aliastext); | 681 g_free(aliastext); |
682 } | 682 } |
683 #if 0 | 683 #if 0 |
684 if (b->idle > 0) { | 684 if (b->idle > 0) { |
685 char *idletime = gaim_str_seconds_to_string(time(NULL) - b->idle); | 685 char *idletime = purple_str_seconds_to_string(time(NULL) - b->idle); |
686 gaim_notify_user_info_add_pair(user_info, _("Idle"), idletime); | 686 purple_notify_user_info_add_pair(user_info, _("Idle"), idletime); |
687 g_free(idletime); | 687 g_free(idletime); |
688 } | 688 } |
689 #endif | 689 #endif |
690 | 690 |
691 /* Add the normal tooltip pairs */ | 691 /* Add the normal tooltip pairs */ |
692 yahoo_tooltip_text(b, user_info, TRUE); | 692 yahoo_tooltip_text(b, user_info, TRUE); |
693 | 693 |
694 if ((f = yahoo_friend_find(info_data->gc, b->name))) { | 694 if ((f = yahoo_friend_find(info_data->gc, b->name))) { |
695 const char *ip; | 695 const char *ip; |
696 if ((ip = yahoo_friend_get_ip(f))) | 696 if ((ip = yahoo_friend_get_ip(f))) |
697 gaim_notify_user_info_add_pair(user_info, _("IP Address"), ip); | 697 purple_notify_user_info_add_pair(user_info, _("IP Address"), ip); |
698 } | 698 } |
699 } | 699 } |
700 } | 700 } |
701 | 701 |
702 #if PHOTO_SUPPORT | 702 #if PHOTO_SUPPORT |
730 g_string_free(s, TRUE); | 730 g_string_free(s, TRUE); |
731 return it; | 731 return it; |
732 } | 732 } |
733 | 733 |
734 static void | 734 static void |
735 yahoo_got_photo(GaimUtilFetchUrlData *url_data, gpointer data, | 735 yahoo_got_photo(PurpleUtilFetchUrlData *url_data, gpointer data, |
736 const gchar *url_text, size_t len, const gchar *error_message); | 736 const gchar *url_text, size_t len, const gchar *error_message); |
737 | 737 |
738 #endif /* PHOTO_SUPPORT */ | 738 #endif /* PHOTO_SUPPORT */ |
739 | 739 |
740 static void yahoo_got_info(GaimUtilFetchUrlData *url_data, gpointer user_data, | 740 static void yahoo_got_info(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
741 const gchar *url_text, size_t len, const gchar *error_message) | 741 const gchar *url_text, size_t len, const gchar *error_message) |
742 { | 742 { |
743 YahooGetInfoData *info_data = (YahooGetInfoData *)user_data; | 743 YahooGetInfoData *info_data = (YahooGetInfoData *)user_data; |
744 GaimNotifyUserInfo *user_info; | 744 PurpleNotifyUserInfo *user_info; |
745 char *p; | 745 char *p; |
746 #if PHOTO_SUPPORT | 746 #if PHOTO_SUPPORT |
747 YahooGetInfoStepTwoData *info2_data; | 747 YahooGetInfoStepTwoData *info2_data; |
748 char *photo_url_text = NULL; | 748 char *photo_url_text = NULL; |
749 #else | 749 #else |
761 struct yahoo_data *yd; | 761 struct yahoo_data *yd; |
762 const profile_strings_node_t *strings = NULL; | 762 const profile_strings_node_t *strings = NULL; |
763 const char *title; | 763 const char *title; |
764 profile_state_t profile_state = PROFILE_STATE_DEFAULT; | 764 profile_state_t profile_state = PROFILE_STATE_DEFAULT; |
765 | 765 |
766 gaim_debug_info("yahoo", "In yahoo_got_info\n"); | 766 purple_debug_info("yahoo", "In yahoo_got_info\n"); |
767 | 767 |
768 yd = info_data->gc->proto_data; | 768 yd = info_data->gc->proto_data; |
769 yd->url_datas = g_slist_remove(yd->url_datas, url_data); | 769 yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
770 | 770 |
771 user_info = gaim_notify_user_info_new(); | 771 user_info = purple_notify_user_info_new(); |
772 | 772 |
773 title = yd->jp ? _("Yahoo! Japan Profile") : | 773 title = yd->jp ? _("Yahoo! Japan Profile") : |
774 _("Yahoo! Profile"); | 774 _("Yahoo! Profile"); |
775 | 775 |
776 /* Get the tooltip info string */ | 776 /* Get the tooltip info string */ |
779 /* We failed to grab the profile URL. This is not expected to actually | 779 /* We failed to grab the profile URL. This is not expected to actually |
780 * happen except under unusual error conditions, as Yahoo is observed | 780 * happen except under unusual error conditions, as Yahoo is observed |
781 * to send back HTML, with a 200 status code. | 781 * to send back HTML, with a 200 status code. |
782 */ | 782 */ |
783 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) { | 783 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) { |
784 gaim_notify_user_info_add_pair(user_info, _("Error retrieving profile"), NULL); | 784 purple_notify_user_info_add_pair(user_info, _("Error retrieving profile"), NULL); |
785 gaim_notify_userinfo(info_data->gc, info_data->name, | 785 purple_notify_userinfo(info_data->gc, info_data->name, |
786 user_info, NULL, NULL); | 786 user_info, NULL, NULL); |
787 gaim_notify_user_info_destroy(user_info); | 787 purple_notify_user_info_destroy(user_info); |
788 g_free(profile_url_text); | 788 g_free(profile_url_text); |
789 g_free(info_data->name); | 789 g_free(info_data->name); |
790 g_free(info_data); | 790 g_free(info_data); |
791 return; | 791 return; |
792 } | 792 } |
814 _("Sorry, profiles marked as containing adult content " | 814 _("Sorry, profiles marked as containing adult content " |
815 "are not supported at this time."), | 815 "are not supported at this time."), |
816 _("If you wish to view this profile, " | 816 _("If you wish to view this profile, " |
817 "you will need to visit this link in your web browser:"), | 817 "you will need to visit this link in your web browser:"), |
818 profile_url_text, profile_url_text); | 818 profile_url_text, profile_url_text); |
819 gaim_notify_user_info_add_pair(user_info, NULL, tmp); | 819 purple_notify_user_info_add_pair(user_info, NULL, tmp); |
820 g_free(tmp); | 820 g_free(tmp); |
821 | 821 |
822 gaim_notify_userinfo(info_data->gc, info_data->name, | 822 purple_notify_userinfo(info_data->gc, info_data->name, |
823 user_info, NULL, NULL); | 823 user_info, NULL, NULL); |
824 | 824 |
825 g_free(profile_url_text); | 825 g_free(profile_url_text); |
826 gaim_notify_user_info_destroy(user_info); | 826 purple_notify_user_info_destroy(user_info); |
827 g_free(info_data->name); | 827 g_free(info_data->name); |
828 g_free(info_data); | 828 g_free(info_data); |
829 return; | 829 return; |
830 } | 830 } |
831 | 831 |
848 if (p) { | 848 if (p) { |
849 for (strid = 0; profile_strings[strid].lang != XX; strid += 1) { | 849 for (strid = 0; profile_strings[strid].lang != XX; strid += 1) { |
850 if (profile_strings[strid].lang == profile_langs[lang].lang) break; | 850 if (profile_strings[strid].lang == profile_langs[lang].lang) break; |
851 } | 851 } |
852 strings = profile_strings + strid; | 852 strings = profile_strings + strid; |
853 gaim_debug_info("yahoo", "detected profile lang = %s (%d)\n", profile_strings[strid].lang_string, lang); | 853 purple_debug_info("yahoo", "detected profile lang = %s (%d)\n", profile_strings[strid].lang_string, lang); |
854 } | 854 } |
855 | 855 |
856 /* Every user may choose his/her own profile language, and this language | 856 /* Every user may choose his/her own profile language, and this language |
857 * has nothing to do with the preferences of the user which looks at the | 857 * has nothing to do with the preferences of the user which looks at the |
858 * profile. We try to support all languages, but nothing is guaranteed. | 858 * profile. We try to support all languages, but nothing is guaranteed. |
876 #endif | 876 #endif |
877 | 877 |
878 url_buffer = g_strdup(url_text); | 878 url_buffer = g_strdup(url_text); |
879 | 879 |
880 /* | 880 /* |
881 * gaim_markup_strip_html() doesn't strip out character entities like | 881 * purple_markup_strip_html() doesn't strip out character entities like |
882 * and · | 882 * and · |
883 */ | 883 */ |
884 yahoo_remove_nonbreaking_spaces(url_buffer); | 884 yahoo_remove_nonbreaking_spaces(url_buffer); |
885 #if 1 | 885 #if 1 |
886 while ((p = strstr(url_buffer, "·")) != NULL) { | 886 while ((p = strstr(url_buffer, "·")) != NULL) { |
888 url_buffer[strlen(url_buffer) - 6] = '\0'; | 888 url_buffer[strlen(url_buffer) - 6] = '\0'; |
889 } | 889 } |
890 #endif | 890 #endif |
891 | 891 |
892 /* nuke the nasty \r's */ | 892 /* nuke the nasty \r's */ |
893 gaim_str_strip_char(url_buffer, '\r'); | 893 purple_str_strip_char(url_buffer, '\r'); |
894 | 894 |
895 #if PHOTO_SUPPORT | 895 #if PHOTO_SUPPORT |
896 /* Marshall the existing state */ | 896 /* Marshall the existing state */ |
897 info2_data = g_malloc(sizeof(YahooGetInfoStepTwoData)); | 897 info2_data = g_malloc(sizeof(YahooGetInfoStepTwoData)); |
898 info2_data->info_data = info_data; | 898 info2_data->info_data = info_data; |
905 info2_data->profile_state = profile_state; | 905 info2_data->profile_state = profile_state; |
906 info2_data->user_info = user_info; | 906 info2_data->user_info = user_info; |
907 | 907 |
908 /* Try to put the photo in there too, if there's one */ | 908 /* Try to put the photo in there too, if there's one */ |
909 if (photo_url_text) { | 909 if (photo_url_text) { |
910 GaimUtilFetchUrlData *url_data; | 910 PurpleUtilFetchUrlData *url_data; |
911 /* User-uploaded photos use a different server that requires the Host | 911 /* User-uploaded photos use a different server that requires the Host |
912 * header, but Yahoo Japan will use the "chunked" content encoding if | 912 * header, but Yahoo Japan will use the "chunked" content encoding if |
913 * we specify HTTP 1.1. So we have to specify 1.0 & fix gaim_util_fetch_url | 913 * we specify HTTP 1.1. So we have to specify 1.0 & fix purple_util_fetch_url |
914 */ | 914 */ |
915 url_data = gaim_util_fetch_url(photo_url_text, FALSE, NULL, | 915 url_data = purple_util_fetch_url(photo_url_text, FALSE, NULL, |
916 FALSE, yahoo_got_photo, info2_data); | 916 FALSE, yahoo_got_photo, info2_data); |
917 if (url_data != NULL) | 917 if (url_data != NULL) |
918 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); | 918 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
919 else { | 919 else { |
920 g_free(info2_data->info_data->name); | 920 g_free(info2_data->info_data->name); |
926 yahoo_got_photo(NULL, info2_data, NULL, 0, NULL); | 926 yahoo_got_photo(NULL, info2_data, NULL, 0, NULL); |
927 } | 927 } |
928 } | 928 } |
929 | 929 |
930 static void | 930 static void |
931 yahoo_got_photo(GaimUtilFetchUrlData *url_data, gpointer data, | 931 yahoo_got_photo(PurpleUtilFetchUrlData *url_data, gpointer data, |
932 const gchar *url_text, size_t len, const gchar *error_message) | 932 const gchar *url_text, size_t len, const gchar *error_message) |
933 { | 933 { |
934 YahooGetInfoStepTwoData *info2_data = (YahooGetInfoStepTwoData *)data; | 934 YahooGetInfoStepTwoData *info2_data = (YahooGetInfoStepTwoData *)data; |
935 struct yahoo_data *yd; | 935 struct yahoo_data *yd; |
936 gboolean found = FALSE; | 936 gboolean found = FALSE; |
944 char *tmp; | 944 char *tmp; |
945 | 945 |
946 /* Unmarshall the saved state */ | 946 /* Unmarshall the saved state */ |
947 YahooGetInfoData *info_data = info2_data->info_data; | 947 YahooGetInfoData *info_data = info2_data->info_data; |
948 char *url_buffer = info2_data->url_buffer; | 948 char *url_buffer = info2_data->url_buffer; |
949 GaimNotifyUserInfo *user_info = info2_data->user_info; | 949 PurpleNotifyUserInfo *user_info = info2_data->user_info; |
950 char *photo_url_text = info2_data->photo_url_text; | 950 char *photo_url_text = info2_data->photo_url_text; |
951 char *profile_url_text = info2_data->profile_url_text; | 951 char *profile_url_text = info2_data->profile_url_text; |
952 const profile_strings_node_t *strings = info2_data->strings; | 952 const profile_strings_node_t *strings = info2_data->strings; |
953 const char *last_updated_string = info2_data->last_updated_string; | 953 const char *last_updated_string = info2_data->last_updated_string; |
954 profile_state_t profile_state = info2_data->profile_state; | 954 profile_state_t profile_state = info2_data->profile_state; |
956 /* We continue here from yahoo_got_info, as if nothing has happened */ | 956 /* We continue here from yahoo_got_info, as if nothing has happened */ |
957 #endif /* PHOTO_SUPPORT */ | 957 #endif /* PHOTO_SUPPORT */ |
958 | 958 |
959 /* Jun 29 05 Bleeter: Y! changed their profile pages. Terminators now seem to be */ | 959 /* Jun 29 05 Bleeter: Y! changed their profile pages. Terminators now seem to be */ |
960 /* </dd> and not \n. The prpl's need to be audited before it can be moved */ | 960 /* </dd> and not \n. The prpl's need to be audited before it can be moved */ |
961 /* in to gaim_markup_strip_html*/ | 961 /* in to purple_markup_strip_html*/ |
962 char *fudged_buffer; | 962 char *fudged_buffer; |
963 | 963 |
964 yd = info_data->gc->proto_data; | 964 yd = info_data->gc->proto_data; |
965 yd->url_datas = g_slist_remove(yd->url_datas, url_data); | 965 yd->url_datas = g_slist_remove(yd->url_datas, url_data); |
966 | 966 |
967 fudged_buffer = gaim_strcasereplace(url_buffer, "</dd>", "</dd><br>"); | 967 fudged_buffer = purple_strcasereplace(url_buffer, "</dd>", "</dd><br>"); |
968 /* nuke the html, it's easier than trying to parse the horrid stuff */ | 968 /* nuke the html, it's easier than trying to parse the horrid stuff */ |
969 stripped = gaim_markup_strip_html(fudged_buffer); | 969 stripped = purple_markup_strip_html(fudged_buffer); |
970 stripped_len = strlen(stripped); | 970 stripped_len = strlen(stripped); |
971 | 971 |
972 gaim_debug_misc("yahoo", "stripped = %p\n", stripped); | 972 purple_debug_misc("yahoo", "stripped = %p\n", stripped); |
973 gaim_debug_misc("yahoo", "url_buffer = %p\n", url_buffer); | 973 purple_debug_misc("yahoo", "url_buffer = %p\n", url_buffer); |
974 | 974 |
975 /* convert to utf8 */ | 975 /* convert to utf8 */ |
976 if (strings && strings->charset != XX) { | 976 if (strings && strings->charset != XX) { |
977 p = g_convert(stripped, -1, "utf-8", strings->charset, | 977 p = g_convert(stripped, -1, "utf-8", strings->charset, |
978 NULL, NULL, NULL); | 978 NULL, NULL, NULL); |
983 NULL, NULL, NULL); | 983 NULL, NULL, NULL); |
984 } | 984 } |
985 } | 985 } |
986 if (p) { | 986 if (p) { |
987 g_free(stripped); | 987 g_free(stripped); |
988 stripped = gaim_utf8_ncr_decode(p); | 988 stripped = purple_utf8_ncr_decode(p); |
989 stripped_len = strlen(stripped); | 989 stripped_len = strlen(stripped); |
990 g_free(p); | 990 g_free(p); |
991 } | 991 } |
992 } | 992 } |
993 p = NULL; | 993 p = NULL; |
996 if (strings && strings->charset != XX) { | 996 if (strings && strings->charset != XX) { |
997 last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8", | 997 last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8", |
998 strings->charset, NULL, NULL, NULL); | 998 strings->charset, NULL, NULL, NULL); |
999 yahoo_remove_nonbreaking_spaces(last_updated_utf8_string); | 999 yahoo_remove_nonbreaking_spaces(last_updated_utf8_string); |
1000 | 1000 |
1001 gaim_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); | 1001 purple_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); |
1002 } | 1002 } |
1003 | 1003 |
1004 if (profile_state == PROFILE_STATE_DEFAULT) { | 1004 if (profile_state == PROFILE_STATE_DEFAULT) { |
1005 #if 0 | 1005 #if 0 |
1006 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as | 1006 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as |
1007 * true, since the Yahoo! ID will always be there */ | 1007 * true, since the Yahoo! ID will always be there */ |
1008 if (!gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1008 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1009 strings->yahoo_id_string, (yd->jp ? 2 : 10), "\n", 0, | 1009 strings->yahoo_id_string, (yd->jp ? 2 : 10), "\n", 0, |
1010 NULL, _("Yahoo! ID"), 0, NULL, NULL)) | 1010 NULL, _("Yahoo! ID"), 0, NULL, NULL)) |
1011 ; | 1011 ; |
1012 #endif | 1012 #endif |
1013 | 1013 |
1016 if (data && url_text && len != 0) { | 1016 if (data && url_text && len != 0) { |
1017 if (strstr(url_text, "400 Bad Request") | 1017 if (strstr(url_text, "400 Bad Request") |
1018 || strstr(url_text, "403 Forbidden") | 1018 || strstr(url_text, "403 Forbidden") |
1019 || strstr(url_text, "404 Not Found")) { | 1019 || strstr(url_text, "404 Not Found")) { |
1020 | 1020 |
1021 gaim_debug_info("yahoo", "Error getting %s: %s\n", | 1021 purple_debug_info("yahoo", "Error getting %s: %s\n", |
1022 photo_url_text, url_text); | 1022 photo_url_text, url_text); |
1023 } else { | 1023 } else { |
1024 gaim_debug_info("yahoo", "%s is %d bytes\n", photo_url_text, len); | 1024 purple_debug_info("yahoo", "%s is %d bytes\n", photo_url_text, len); |
1025 id = gaim_imgstore_add(url_text, len, NULL); | 1025 id = purple_imgstore_add(url_text, len, NULL); |
1026 | 1026 |
1027 tmp = g_strdup_printf("<img id=\"%d\"><br>", id); | 1027 tmp = g_strdup_printf("<img id=\"%d\"><br>", id); |
1028 gaim_notify_user_info_add_pair(user_info, NULL, tmp); | 1028 purple_notify_user_info_add_pair(user_info, NULL, tmp); |
1029 g_free(tmp); | 1029 g_free(tmp); |
1030 } | 1030 } |
1031 } | 1031 } |
1032 #endif /* PHOTO_SUPPORT */ | 1032 #endif /* PHOTO_SUPPORT */ |
1033 | 1033 |
1034 /* extract their Email address and put it in */ | 1034 /* extract their Email address and put it in */ |
1035 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1035 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1036 strings->my_email_string, (yd->jp ? 4 : 1), " ", 0, | 1036 strings->my_email_string, (yd->jp ? 4 : 1), " ", 0, |
1037 strings->private_string, _("E-Mail"), 0, NULL, NULL); | 1037 strings->private_string, _("E-Mail"), 0, NULL, NULL); |
1038 | 1038 |
1039 /* extract the Nickname if it exists */ | 1039 /* extract the Nickname if it exists */ |
1040 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1040 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1041 "Nickname:", 1, "\n", '\n', | 1041 "Nickname:", 1, "\n", '\n', |
1042 NULL, _("Nickname"), 0, NULL, NULL); | 1042 NULL, _("Nickname"), 0, NULL, NULL); |
1043 | 1043 |
1044 /* extract their RealName and put it in */ | 1044 /* extract their RealName and put it in */ |
1045 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1045 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1046 strings->realname_string, (yd->jp ? 3 : 1), "\n", '\n', | 1046 strings->realname_string, (yd->jp ? 3 : 1), "\n", '\n', |
1047 NULL, _("Real Name"), 0, NULL, NULL); | 1047 NULL, _("Real Name"), 0, NULL, NULL); |
1048 | 1048 |
1049 /* extract their Location and put it in */ | 1049 /* extract their Location and put it in */ |
1050 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1050 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1051 strings->location_string, (yd->jp ? 4 : 2), "\n", '\n', | 1051 strings->location_string, (yd->jp ? 4 : 2), "\n", '\n', |
1052 NULL, _("Location"), 0, NULL, NULL); | 1052 NULL, _("Location"), 0, NULL, NULL); |
1053 | 1053 |
1054 /* extract their Age and put it in */ | 1054 /* extract their Age and put it in */ |
1055 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1055 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1056 strings->age_string, (yd->jp ? 2 : 3), "\n", '\n', | 1056 strings->age_string, (yd->jp ? 2 : 3), "\n", '\n', |
1057 NULL, _("Age"), 0, NULL, NULL); | 1057 NULL, _("Age"), 0, NULL, NULL); |
1058 | 1058 |
1059 /* extract their MaritalStatus and put it in */ | 1059 /* extract their MaritalStatus and put it in */ |
1060 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1060 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1061 strings->maritalstatus_string, (yd->jp ? 2 : 3), "\n", '\n', | 1061 strings->maritalstatus_string, (yd->jp ? 2 : 3), "\n", '\n', |
1062 strings->no_answer_string, _("Marital Status"), 0, NULL, NULL); | 1062 strings->no_answer_string, _("Marital Status"), 0, NULL, NULL); |
1063 | 1063 |
1064 /* extract their Gender and put it in */ | 1064 /* extract their Gender and put it in */ |
1065 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1065 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1066 strings->gender_string, (yd->jp ? 2 : 3), "\n", '\n', | 1066 strings->gender_string, (yd->jp ? 2 : 3), "\n", '\n', |
1067 strings->no_answer_string, _("Gender"), 0, NULL, NULL); | 1067 strings->no_answer_string, _("Gender"), 0, NULL, NULL); |
1068 | 1068 |
1069 /* extract their Occupation and put it in */ | 1069 /* extract their Occupation and put it in */ |
1070 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1070 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1071 strings->occupation_string, 2, "\n", '\n', | 1071 strings->occupation_string, 2, "\n", '\n', |
1072 NULL, _("Occupation"), 0, NULL, NULL); | 1072 NULL, _("Occupation"), 0, NULL, NULL); |
1073 | 1073 |
1074 /* Hobbies, Latest News, and Favorite Quote are a bit different, since | 1074 /* Hobbies, Latest News, and Favorite Quote are a bit different, since |
1075 * the values can contain embedded newlines... but any or all of them | 1075 * the values can contain embedded newlines... but any or all of them |
1078 * we end the section by looking for the 'Links' heading, which is the | 1078 * we end the section by looking for the 'Links' heading, which is the |
1079 * next thing to follow this bunch. (For Yahoo Japan, we check for | 1079 * next thing to follow this bunch. (For Yahoo Japan, we check for |
1080 * the "Description" ("Self PR") heading instead of "Links".) | 1080 * the "Description" ("Self PR") heading instead of "Links".) |
1081 */ | 1081 */ |
1082 | 1082 |
1083 if (!gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1083 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1084 strings->hobbies_string, (yd->jp ? 3 : 1), strings->latest_news_string, | 1084 strings->hobbies_string, (yd->jp ? 3 : 1), strings->latest_news_string, |
1085 '\n', "\n", _("Hobbies"), 0, NULL, NULL)) | 1085 '\n', "\n", _("Hobbies"), 0, NULL, NULL)) |
1086 { | 1086 { |
1087 if (!gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1087 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1088 strings->hobbies_string, 1, strings->favorite_quote_string, | 1088 strings->hobbies_string, 1, strings->favorite_quote_string, |
1089 '\n', "\n", _("Hobbies"), 0, NULL, NULL)) | 1089 '\n', "\n", _("Hobbies"), 0, NULL, NULL)) |
1090 { | 1090 { |
1091 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1091 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1092 strings->hobbies_string, 1, strings->links_string, | 1092 strings->hobbies_string, 1, strings->links_string, |
1093 '\n', "\n", _("Hobbies"), 0, NULL, NULL); | 1093 '\n', "\n", _("Hobbies"), 0, NULL, NULL); |
1094 } | 1094 } |
1095 else | 1095 else |
1096 found = TRUE; | 1096 found = TRUE; |
1097 } | 1097 } |
1098 else | 1098 else |
1099 found = TRUE; | 1099 found = TRUE; |
1100 | 1100 |
1101 if (!gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1101 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1102 strings->latest_news_string, 1, strings->favorite_quote_string, | 1102 strings->latest_news_string, 1, strings->favorite_quote_string, |
1103 '\n', "\n", _("Latest News"), 0, NULL, NULL)) | 1103 '\n', "\n", _("Latest News"), 0, NULL, NULL)) |
1104 { | 1104 { |
1105 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1105 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1106 strings->latest_news_string, (yd->jp ? 2 : 1), strings->links_string, | 1106 strings->latest_news_string, (yd->jp ? 2 : 1), strings->links_string, |
1107 '\n', "\n", _("Latest News"), 0, NULL, NULL); | 1107 '\n', "\n", _("Latest News"), 0, NULL, NULL); |
1108 } | 1108 } |
1109 else | 1109 else |
1110 found = TRUE; | 1110 found = TRUE; |
1111 | 1111 |
1112 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1112 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1113 strings->favorite_quote_string, 1, strings->links_string, | 1113 strings->favorite_quote_string, 1, strings->links_string, |
1114 '\n', "\n", _("Favorite Quote"), 0, NULL, NULL); | 1114 '\n', "\n", _("Favorite Quote"), 0, NULL, NULL); |
1115 | 1115 |
1116 /* Home Page will either be "No home page specified", | 1116 /* Home Page will either be "No home page specified", |
1117 * or "Home Page: " and a link. | 1117 * or "Home Page: " and a link. |
1121 if (strings->home_page_string) { | 1121 if (strings->home_page_string) { |
1122 p = !strings->no_home_page_specified_string? NULL: | 1122 p = !strings->no_home_page_specified_string? NULL: |
1123 strstr(stripped, strings->no_home_page_specified_string); | 1123 strstr(stripped, strings->no_home_page_specified_string); |
1124 if(!p) | 1124 if(!p) |
1125 { | 1125 { |
1126 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1126 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1127 strings->home_page_string, 1, "\n", 0, NULL, | 1127 strings->home_page_string, 1, "\n", 0, NULL, |
1128 _("Home Page"), 1, NULL, NULL); | 1128 _("Home Page"), 1, NULL, NULL); |
1129 } | 1129 } |
1130 } | 1130 } |
1131 | 1131 |
1136 */ | 1136 */ |
1137 p = !strings->no_cool_link_specified_string? NULL: | 1137 p = !strings->no_cool_link_specified_string? NULL: |
1138 strstr(stripped,strings->no_cool_link_specified_string); | 1138 strstr(stripped,strings->no_cool_link_specified_string); |
1139 if (!p) | 1139 if (!p) |
1140 { | 1140 { |
1141 if (gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1141 if (purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1142 strings->cool_link_1_string, 1, "\n", 0, NULL, | 1142 strings->cool_link_1_string, 1, "\n", 0, NULL, |
1143 _("Cool Link 1"), 1, NULL, NULL)) | 1143 _("Cool Link 1"), 1, NULL, NULL)) |
1144 { | 1144 { |
1145 found = TRUE; | 1145 found = TRUE; |
1146 if (gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1146 if (purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1147 strings->cool_link_2_string, 1, "\n", 0, NULL, | 1147 strings->cool_link_2_string, 1, "\n", 0, NULL, |
1148 _("Cool Link 2"), 1, NULL, NULL)) | 1148 _("Cool Link 2"), 1, NULL, NULL)) |
1149 { | 1149 { |
1150 gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1150 purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1151 strings->cool_link_3_string, 1, "\n", 0, NULL, | 1151 strings->cool_link_3_string, 1, "\n", 0, NULL, |
1152 _("Cool Link 3"), 1, NULL, NULL); | 1152 _("Cool Link 3"), 1, NULL, NULL); |
1153 } | 1153 } |
1154 } | 1154 } |
1155 } | 1155 } |
1156 | 1156 |
1157 if (last_updated_utf8_string != NULL) { | 1157 if (last_updated_utf8_string != NULL) { |
1158 /* see if Member Since is there, and if so, extract it. */ | 1158 /* see if Member Since is there, and if so, extract it. */ |
1159 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1159 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1160 "Member Since:", 1, last_updated_utf8_string, | 1160 "Member Since:", 1, last_updated_utf8_string, |
1161 '\n', NULL, _("Member Since"), 0, NULL, yahoo_info_date_reformat); | 1161 '\n', NULL, _("Member Since"), 0, NULL, yahoo_info_date_reformat); |
1162 | 1162 |
1163 /* extract the Last Updated date and put it in */ | 1163 /* extract the Last Updated date and put it in */ |
1164 found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info, | 1164 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1165 last_updated_utf8_string, (yd->jp ? 2 : 1), (yd->jp ? "\n" : " "), (yd->jp ? 0 : '\n'), NULL, | 1165 last_updated_utf8_string, (yd->jp ? 2 : 1), (yd->jp ? "\n" : " "), (yd->jp ? 0 : '\n'), NULL, |
1166 _("Last Update"), 0, NULL, (yd->jp ? NULL : yahoo_info_date_reformat)); | 1166 _("Last Update"), 0, NULL, (yd->jp ? NULL : yahoo_info_date_reformat)); |
1167 } | 1167 } |
1168 } /* if (profile_state == PROFILE_STATE_DEFAULT) */ | 1168 } /* if (profile_state == PROFILE_STATE_DEFAULT) */ |
1169 | 1169 |
1180 g_string_append_printf(str, "%s<br><br>", | 1180 g_string_append_printf(str, "%s<br><br>", |
1181 _("Sorry, this profile seems to be in a language " | 1181 _("Sorry, this profile seems to be in a language " |
1182 "or format that is not supported at this time.")); | 1182 "or format that is not supported at this time.")); |
1183 | 1183 |
1184 } else if (profile_state == PROFILE_STATE_NOT_FOUND) { | 1184 } else if (profile_state == PROFILE_STATE_NOT_FOUND) { |
1185 GaimBuddy *b = gaim_find_buddy | 1185 PurpleBuddy *b = purple_find_buddy |
1186 (gaim_connection_get_account(info_data->gc), | 1186 (purple_connection_get_account(info_data->gc), |
1187 info_data->name); | 1187 info_data->name); |
1188 YahooFriend *f = NULL; | 1188 YahooFriend *f = NULL; |
1189 if (b) { | 1189 if (b) { |
1190 /* Someone on the buddy list can be "not on server list", | 1190 /* Someone on the buddy list can be "not on server list", |
1191 * in which case the user may or may not actually exist. | 1191 * in which case the user may or may not actually exist. |
1205 } else { | 1205 } else { |
1206 g_string_append_printf(str, "%s<br><br>", | 1206 g_string_append_printf(str, "%s<br><br>", |
1207 _("The user's profile is empty.")); | 1207 _("The user's profile is empty.")); |
1208 } | 1208 } |
1209 | 1209 |
1210 gaim_notify_user_info_add_pair(user_info, NULL, str->str); | 1210 purple_notify_user_info_add_pair(user_info, NULL, str->str); |
1211 g_string_free(str, TRUE); | 1211 g_string_free(str, TRUE); |
1212 } | 1212 } |
1213 | 1213 |
1214 /* put a link to the actual profile URL */ | 1214 /* put a link to the actual profile URL */ |
1215 tmp = g_strdup_printf("<a href=\"%s\">%s</a>", profile_url_text, profile_url_text); | 1215 tmp = g_strdup_printf("<a href=\"%s\">%s</a>", profile_url_text, profile_url_text); |
1216 gaim_notify_user_info_add_pair(user_info, _("Profile URL"), tmp); | 1216 purple_notify_user_info_add_pair(user_info, _("Profile URL"), tmp); |
1217 g_free(tmp); | 1217 g_free(tmp); |
1218 | 1218 |
1219 g_free(stripped); | 1219 g_free(stripped); |
1220 | 1220 |
1221 /* show it to the user */ | 1221 /* show it to the user */ |
1222 gaim_notify_userinfo(info_data->gc, info_data->name, | 1222 purple_notify_userinfo(info_data->gc, info_data->name, |
1223 user_info, NULL, NULL); | 1223 user_info, NULL, NULL); |
1224 gaim_notify_user_info_destroy(user_info); | 1224 purple_notify_user_info_destroy(user_info); |
1225 | 1225 |
1226 g_free(last_updated_utf8_string); | 1226 g_free(last_updated_utf8_string); |
1227 g_free(url_buffer); | 1227 g_free(url_buffer); |
1228 g_free(fudged_buffer); | 1228 g_free(fudged_buffer); |
1229 g_free(profile_url_text); | 1229 g_free(profile_url_text); |
1232 | 1232 |
1233 #if PHOTO_SUPPORT | 1233 #if PHOTO_SUPPORT |
1234 g_free(photo_url_text); | 1234 g_free(photo_url_text); |
1235 g_free(info2_data); | 1235 g_free(info2_data); |
1236 if (id != -1) | 1236 if (id != -1) |
1237 gaim_imgstore_unref(id); | 1237 purple_imgstore_unref(id); |
1238 #endif | 1238 #endif |
1239 } | 1239 } |
1240 | 1240 |
1241 void yahoo_get_info(GaimConnection *gc, const char *name) | 1241 void yahoo_get_info(PurpleConnection *gc, const char *name) |
1242 { | 1242 { |
1243 struct yahoo_data *yd = gc->proto_data; | 1243 struct yahoo_data *yd = gc->proto_data; |
1244 YahooGetInfoData *data; | 1244 YahooGetInfoData *data; |
1245 char *url; | 1245 char *url; |
1246 GaimUtilFetchUrlData *url_data; | 1246 PurpleUtilFetchUrlData *url_data; |
1247 | 1247 |
1248 data = g_new0(YahooGetInfoData, 1); | 1248 data = g_new0(YahooGetInfoData, 1); |
1249 data->gc = gc; | 1249 data->gc = gc; |
1250 data->name = g_strdup(name); | 1250 data->name = g_strdup(name); |
1251 | 1251 |
1252 url = g_strdup_printf("%s%s", | 1252 url = g_strdup_printf("%s%s", |
1253 (yd->jp ? YAHOOJP_PROFILE_URL : YAHOO_PROFILE_URL), name); | 1253 (yd->jp ? YAHOOJP_PROFILE_URL : YAHOO_PROFILE_URL), name); |
1254 | 1254 |
1255 url_data = gaim_util_fetch_url(url, TRUE, NULL, FALSE, yahoo_got_info, data); | 1255 url_data = purple_util_fetch_url(url, TRUE, NULL, FALSE, yahoo_got_info, data); |
1256 if (url_data != NULL) | 1256 if (url_data != NULL) |
1257 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); | 1257 yd->url_datas = g_slist_prepend(yd->url_datas, url_data); |
1258 else { | 1258 else { |
1259 g_free(data->name); | 1259 g_free(data->name); |
1260 g_free(data); | 1260 g_free(data); |