Mercurial > pidgin.yaz
comparison libpurple/protocols/yahoo/yahoo_profile.c @ 27767:76ff0ad87964
propagate from branch 'im.pidgin.pidgin' (head 9de3934cd71a8b08f0f6da39df8f0102d36fbd2b)
to branch 'im.pidgin.pidgin.yaz' (head d439d42fe8d0ee4a40486b4de12acb4116bc2e58)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 25 Feb 2008 05:45:57 +0000 |
parents | b0ed2ce8514d 26f55eb6ab59 |
children | 0f3a131d23da |
comparison
equal
deleted
inserted
replaced
22325:9d02eb04f406 | 27767:76ff0ad87964 |
---|---|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #define PHOTO_SUPPORT 1 | 24 #define PHOTO_SUPPORT 1 |
25 //original is 1 --yaz | |
25 | 26 |
26 #include "internal.h" | 27 #include "internal.h" |
27 #include "debug.h" | 28 #include "debug.h" |
28 #include "notify.h" | 29 #include "notify.h" |
29 #include "util.h" | 30 #include "util.h" |
759 yahoo_got_photo(PurpleUtilFetchUrlData *url_data, gpointer data, | 760 yahoo_got_photo(PurpleUtilFetchUrlData *url_data, gpointer data, |
760 const gchar *url_text, size_t len, const gchar *error_message); | 761 const gchar *url_text, size_t len, const gchar *error_message); |
761 | 762 |
762 #endif /* PHOTO_SUPPORT */ | 763 #endif /* PHOTO_SUPPORT */ |
763 | 764 |
765 #define PROF_LEN (1024 * 10) | |
764 static void yahoo_got_info(PurpleUtilFetchUrlData *url_data, gpointer user_data, | 766 static void yahoo_got_info(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
765 const gchar *url_text, size_t len, const gchar *error_message) | 767 const gchar *url_text, size_t len, const gchar *error_message) |
766 { | 768 { |
767 YahooGetInfoData *info_data = (YahooGetInfoData *)user_data; | 769 YahooGetInfoData *info_data = (YahooGetInfoData *)user_data; |
768 PurpleNotifyUserInfo *user_info; | 770 PurpleNotifyUserInfo *user_info; |
1015 } | 1017 } |
1016 if (p) { | 1018 if (p) { |
1017 g_free(stripped); | 1019 g_free(stripped); |
1018 stripped = purple_utf8_ncr_decode(p); | 1020 stripped = purple_utf8_ncr_decode(p); |
1019 stripped_len = strlen(stripped); | 1021 stripped_len = strlen(stripped); |
1022 | |
1023 purple_debug_misc("yahoo", "after utf8 conversion: stripped@1 = (%s)\n", | |
1024 stripped); //payload --yaz | |
1020 g_free(p); | 1025 g_free(p); |
1021 } | 1026 } |
1022 } | 1027 } |
1023 p = NULL; | 1028 p = NULL; |
1024 | 1029 |
1026 if (strings && strings->charset != XX) { | 1031 if (strings && strings->charset != XX) { |
1027 last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8", | 1032 last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8", |
1028 strings->charset, NULL, NULL, NULL); | 1033 strings->charset, NULL, NULL, NULL); |
1029 yahoo_remove_nonbreaking_spaces(last_updated_utf8_string); | 1034 yahoo_remove_nonbreaking_spaces(last_updated_utf8_string); |
1030 | 1035 |
1031 purple_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); | 1036 purple_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); //payload --yaz |
1032 } | 1037 } |
1033 | 1038 |
1034 if (profile_state == PROFILE_STATE_DEFAULT) { | 1039 if (profile_state == PROFILE_STATE_DEFAULT) { |
1035 #if 0 | 1040 #if 0 |
1036 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as | 1041 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as |
1058 purple_notify_user_info_add_pair(user_info, NULL, tmp); | 1063 purple_notify_user_info_add_pair(user_info, NULL, tmp); |
1059 g_free(tmp); | 1064 g_free(tmp); |
1060 } | 1065 } |
1061 } | 1066 } |
1062 #endif /* PHOTO_SUPPORT */ | 1067 #endif /* PHOTO_SUPPORT */ |
1068 purple_debug_info("yahoo", "email = %s\n", strings->my_email_string); | |
1063 | 1069 |
1064 /* extract their Email address and put it in */ | 1070 /* extract their Email address and put it in */ |
1065 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1071 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1066 strings->my_email_string, (yd->jp ? 4 : 1), " ", 0, | 1072 strings->my_email_string, (yd->jp ? 4 : 1), " ", 0, |
1067 strings->private_string, _("E-Mail"), 0, NULL, NULL); | 1073 strings->private_string, _("E-Mail"), 0, NULL, NULL); |
1068 | 1074 #if 0 |
1069 /* extract the Nickname if it exists */ | 1075 /* extract the Nickname if it exists */ |
1070 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1076 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1071 "Nickname:", 1, "\n", '\n', | 1077 "Nickname:", 1, "\n", '\n', |
1072 NULL, _("Nickname"), 0, NULL, NULL); | 1078 NULL, _("Nickname"), 0, NULL, NULL); |
1073 | 1079 |
1074 /* extract their RealName and put it in */ | 1080 /* extract their RealName and put it in */ |
1075 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1081 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1076 strings->realname_string, (yd->jp ? 3 : 1), "\n", '\n', | 1082 strings->realname_string, (yd->jp ? 3 : 1), "\n", '\n', |
1077 NULL, _("Real Name"), 0, NULL, NULL); | 1083 NULL, _("Real Name"), 0, NULL, NULL); |
1078 | 1084 |
1079 /* extract their Location and put it in */ | 1085 /* extract their Location and put it in */ |
1080 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1086 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1081 strings->location_string, (yd->jp ? 4 : 2), "\n", '\n', | 1087 strings->location_string, (yd->jp ? 4 : 2), "\n", '\n', |
1082 NULL, _("Location"), 0, NULL, NULL); | 1088 NULL, _("Location"), 0, NULL, NULL); |
1083 | 1089 |
1084 /* extract their Age and put it in */ | 1090 /* extract their Age and put it in */ |
1085 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1091 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1086 strings->age_string, (yd->jp ? 2 : 3), "\n", '\n', | 1092 strings->age_string, (yd->jp ? 2 : 3), "\n", '\n', |
1087 NULL, _("Age"), 0, NULL, NULL); | 1093 NULL, _("Age"), 0, NULL, NULL); |
1088 | 1094 |
1089 /* extract their MaritalStatus and put it in */ | 1095 /* extract their MaritalStatus and put it in */ |
1090 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1096 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1091 strings->maritalstatus_string, (yd->jp ? 2 : 3), "\n", '\n', | 1097 strings->maritalstatus_string, (yd->jp ? 2 : 3), "\n", '\n', |
1092 strings->no_answer_string, _("Marital Status"), 0, NULL, NULL); | 1098 strings->no_answer_string, _("Marital Status"), 0, NULL, NULL); |
1093 | 1099 |
1094 /* extract their Gender and put it in */ | 1100 /* extract their Gender and put it in */ |
1095 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1101 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1096 strings->gender_string, (yd->jp ? 2 : 3), "\n", '\n', | 1102 strings->gender_string, (yd->jp ? 2 : 3), "\n", '\n', |
1097 strings->no_answer_string, _("Gender"), 0, NULL, NULL); | 1103 strings->no_answer_string, _("Gender"), 0, NULL, NULL); |
1098 | 1104 |
1099 /* extract their Occupation and put it in */ | 1105 /* extract their Occupation and put it in */ |
1100 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1106 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1101 strings->occupation_string, 2, "\n", '\n', | 1107 strings->occupation_string, 2, "\n", '\n', |
1102 NULL, _("Occupation"), 0, NULL, NULL); | 1108 NULL, _("Occupation"), 0, NULL, NULL); |
1103 | 1109 #endif |
1104 /* Hobbies, Latest News, and Favorite Quote are a bit different, since | 1110 /* Hobbies, Latest News, and Favorite Quote are a bit different, since |
1105 * the values can contain embedded newlines... but any or all of them | 1111 * the values can contain embedded newlines... but any or all of them |
1106 * can also not appear. The way we delimit them is to successively | 1112 * can also not appear. The way we delimit them is to successively |
1107 * look for the next one that _could_ appear, and if all else fails, | 1113 * look for the next one that _could_ appear, and if all else fails, |
1108 * we end the section by looking for the 'Links' heading, which is the | 1114 * we end the section by looking for the 'Links' heading, which is the |
1109 * next thing to follow this bunch. (For Yahoo Japan, we check for | 1115 * next thing to follow this bunch. (For Yahoo Japan, we check for |
1110 * the "Description" ("Self PR") heading instead of "Links".) | 1116 * the "Description" ("Self PR") heading instead of "Links".) |
1111 */ | 1117 */ |
1112 | 1118 #if 0 |
1113 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1119 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1114 strings->hobbies_string, (yd->jp ? 3 : 1), strings->latest_news_string, | 1120 strings->hobbies_string, (yd->jp ? 3 : 1), strings->latest_news_string, |
1115 '\n', "\n", _("Hobbies"), 0, NULL, NULL)) | 1121 '\n', "\n", _("Hobbies"), 0, NULL, NULL)) |
1116 { | 1122 { |
1117 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1123 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1118 strings->hobbies_string, 1, strings->favorite_quote_string, | 1124 strings->hobbies_string, 1, strings->favorite_quote_string, |
1119 '\n', "\n", _("Hobbies"), 0, NULL, NULL)) | 1125 '\n', "\n", _("Hobbies"), 0, NULL, NULL)) |
1120 { | 1126 { |
1121 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1127 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1122 strings->hobbies_string, 1, strings->links_string, | 1128 strings->hobbies_string, 1, strings->links_string, |
1123 '\n', "\n", _("Hobbies"), 0, NULL, NULL); | 1129 '\n', "\n", _("Hobbies"), 0, NULL, NULL); |
1124 } | 1130 } |
1125 else | 1131 else |
1126 found = TRUE; | 1132 found = TRUE; |
1127 } | 1133 } |
1128 else | 1134 else |
1129 found = TRUE; | 1135 found = TRUE; |
1130 | 1136 |
1131 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1137 if (!purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1132 strings->latest_news_string, 1, strings->favorite_quote_string, | 1138 strings->latest_news_string, 1, strings->favorite_quote_string, |
1133 '\n', "\n", _("Latest News"), 0, NULL, NULL)) | 1139 '\n', "\n", _("Latest News"), 0, NULL, NULL)) |
1134 { | 1140 { |
1135 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1141 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1136 strings->latest_news_string, (yd->jp ? 2 : 1), strings->links_string, | 1142 strings->latest_news_string, (yd->jp ? 2 : 1), strings->links_string, |
1137 '\n', "\n", _("Latest News"), 0, NULL, NULL); | 1143 '\n', "\n", _("Latest News"), 0, NULL, NULL); |
1138 } | 1144 } |
1139 else | 1145 else |
1140 found = TRUE; | 1146 found = TRUE; |
1141 | 1147 |
1142 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1148 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1143 strings->favorite_quote_string, 1, strings->links_string, | 1149 strings->favorite_quote_string, 1, strings->links_string, |
1144 '\n', "\n", _("Favorite Quote"), 0, NULL, NULL); | 1150 '\n', "\n", _("Favorite Quote"), 0, NULL, NULL); |
1145 | 1151 |
1146 /* Home Page will either be "No home page specified", | 1152 /* Home Page will either be "No home page specified", |
1147 * or "Home Page: " and a link. | 1153 * or "Home Page: " and a link. |
1148 * For Yahoo! Japan, if there is no home page specified, | 1154 * For Yahoo! Japan, if there is no home page specified, |
1149 * neither "No home page specified" nor "Home Page:" is shown. | 1155 * neither "No home page specified" nor "Home Page:" is shown. |
1153 strstr(stripped, strings->no_home_page_specified_string); | 1159 strstr(stripped, strings->no_home_page_specified_string); |
1154 if(!p) | 1160 if(!p) |
1155 { | 1161 { |
1156 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1162 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1157 strings->home_page_string, 1, "\n", 0, NULL, | 1163 strings->home_page_string, 1, "\n", 0, NULL, |
1158 _("Home Page"), 1, NULL, NULL); | 1164 _("Home Page"), 1, NULL, NULL); |
1159 } | 1165 } |
1160 } | 1166 } |
1161 | 1167 |
1162 /* Cool Link {1,2,3} is also different. If "No cool link specified" | 1168 /* Cool Link {1,2,3} is also different. If "No cool link specified" |
1163 * exists, then we have none. If we have one however, we'll need to | 1169 * exists, then we have none. If we have one however, we'll need to |
1168 strstr(stripped,strings->no_cool_link_specified_string); | 1174 strstr(stripped,strings->no_cool_link_specified_string); |
1169 if (!p) | 1175 if (!p) |
1170 { | 1176 { |
1171 if (purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1177 if (purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1172 strings->cool_link_1_string, 1, "\n", 0, NULL, | 1178 strings->cool_link_1_string, 1, "\n", 0, NULL, |
1173 _("Cool Link 1"), 1, NULL, NULL)) | 1179 _("Cool Link 1"), 1, NULL, NULL)) |
1174 { | 1180 { |
1175 found = TRUE; | 1181 found = TRUE; |
1176 if (purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1182 if (purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1177 strings->cool_link_2_string, 1, "\n", 0, NULL, | 1183 strings->cool_link_2_string, 1, "\n", 0, NULL, |
1178 _("Cool Link 2"), 1, NULL, NULL)) | 1184 _("Cool Link 2"), 1, NULL, NULL)) |
1186 | 1192 |
1187 if (last_updated_utf8_string != NULL) { | 1193 if (last_updated_utf8_string != NULL) { |
1188 /* see if Member Since is there, and if so, extract it. */ | 1194 /* see if Member Since is there, and if so, extract it. */ |
1189 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1195 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1190 "Member Since:", 1, last_updated_utf8_string, | 1196 "Member Since:", 1, last_updated_utf8_string, |
1191 '\n', NULL, _("Member Since"), 0, NULL, yahoo_info_date_reformat); | 1197 '\n', NULL, _("Member Since"), 0, NULL, yahoo_info_date_reformat); |
1192 | 1198 |
1193 /* extract the Last Updated date and put it in */ | 1199 /* extract the Last Updated date and put it in */ |
1194 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, | 1200 found |= purple_markup_extract_info_field(stripped, stripped_len, user_info, |
1195 last_updated_utf8_string, (yd->jp ? 2 : 1), (yd->jp ? "\n" : " "), (yd->jp ? 0 : '\n'), NULL, | 1201 last_updated_utf8_string, (yd->jp ? 2 : 1), (yd->jp ? "\n" : " "), (yd->jp ? 0 : '\n'), NULL, |
1196 _("Last Update"), 0, NULL, (yd->jp ? NULL : yahoo_info_date_reformat)); | 1202 _("Last Update"), 0, NULL, (yd->jp ? NULL : yahoo_info_date_reformat)); |
1197 } | 1203 } |
1204 #endif | |
1198 } /* if (profile_state == PROFILE_STATE_DEFAULT) */ | 1205 } /* if (profile_state == PROFILE_STATE_DEFAULT) */ |
1199 | 1206 |
1200 if(!found) | 1207 if(!found) |
1201 { | 1208 { |
1202 GString *str = g_string_new(""); | 1209 GString *str = g_string_new(""); |