Mercurial > pidgin.yaz
comparison src/protocols/yahoo/yahoo_profile.c @ 9162:82aa3bc494de
[gaim-migrate @ 9947]
I reckon I should add the new file. I even went and updated the win32
Makefile. As a side note, wing's patch stuck it all in yahoo.c, so he
should make sure I didn't mess anything up moving it to its own file.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Wed, 02 Jun 2004 01:11:23 +0000 |
parents | |
children | 76125b842b23 |
comparison
equal
deleted
inserted
replaced
9161:c3fa2ad099a2 | 9162:82aa3bc494de |
---|---|
1 /* | |
2 * gaim | |
3 * | |
4 * Gaim 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 | |
6 * source distribution. | |
7 * | |
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 | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
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 | |
21 * | |
22 */ | |
23 | |
24 #include "internal.h" | |
25 #include "debug.h" | |
26 #include "notify.h" | |
27 #include "util.h" | |
28 | |
29 #include "yahoo.h" | |
30 | |
31 typedef struct { | |
32 GaimConnection *gc; | |
33 char *name; | |
34 } YahooGetInfoData; | |
35 | |
36 | |
37 typedef enum profile_lang_id { | |
38 XX, DA, DE, EL, | |
39 EN, EN_GB, | |
40 ES_AR, ES_ES, ES_MX, ES_US, | |
41 FR_CA, FR_FR, | |
42 IT, JA, KO, NO, PT, SV, | |
43 ZH_CN, ZH_HK, ZH_TW, ZH_US | |
44 } profile_lang_id_t; | |
45 | |
46 typedef struct profile_lang_node { | |
47 profile_lang_id_t lang; | |
48 char *last_updated_string; | |
49 char *det; | |
50 } profile_lang_node_t; | |
51 | |
52 typedef struct profile_strings_node { | |
53 profile_lang_id_t lang; | |
54 char *lang_string; /* Only to make debugging output saner */ | |
55 char *charset; | |
56 char *yahoo_id_string; | |
57 char *private_string; | |
58 char *no_answer_string; | |
59 char *my_email_string; | |
60 char *realname_string; | |
61 char *location_string; | |
62 char *age_string; | |
63 char *maritalstatus_string; | |
64 char *gender_string; | |
65 char *occupation_string; | |
66 char *hobbies_string; | |
67 char *latest_news_string; | |
68 char *favorite_quote_string; | |
69 char *links_string; | |
70 char *no_home_page_specified_string; | |
71 char *home_page_string; | |
72 char *no_cool_link_specified_string; | |
73 char *cool_link_1_string; | |
74 char *cool_link_2_string; | |
75 char *cool_link_3_string; | |
76 char *dummy; | |
77 } profile_strings_node_t; | |
78 | |
79 /* Strings to determine the profile "language" (more accurately "locale"). | |
80 * 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 | |
82 * distinguish 2 locales with this (e.g., ES_ES from ES_US, or FR_CA from | |
83 * FR_FR, or EL from EN_GB), in which case a second string is added and | |
84 * such special cases must be placed before the more general case. | |
85 */ | |
86 static const profile_lang_node_t profile_langs[] = { | |
87 { DA, "Opdateret sidste gang ", NULL }, | |
88 { DE, "Letzter Update ", NULL }, | |
89 { EL, "Last Updated:", "http://gr.profiles.yahoo.com" }, | |
90 { EN_GB, "Last Updated ", "Favourite Quote" }, | |
91 { EN, "Last Updated:", NULL }, | |
92 { EN, "Last Updated ", NULL }, | |
93 { ES_AR, "\332ltima actualizaci\363n ", NULL }, | |
94 { ES_ES, "Actualizada el ", "http://es.profiles.yahoo.com" }, | |
95 { ES_MX, "Actualizada el ", "http://mx.profiles.yahoo.com" }, | |
96 { ES_US, "Actualizada el ", NULL }, | |
97 { FR_CA, "Derni\xe8re mise \xe0 jour", "http://cf.profiles.yahoo.com" }, | |
98 { FR_FR, "Derni\xe8re mise \xe0 jour", NULL }, | |
99 { IT, "Ultimo aggiornamento ", NULL }, | |
100 { JA, "\xba\xc7\xbd\xaa\xb9\xb9\xbf\xb7\xc6\xfc\xa1\xa7", NULL }, | |
101 { KO, "\xb0\xbb\xbd\xc5\x20\xb3\xaf\xc2\xa5 ", NULL }, | |
102 { NO, "Sist oppdatert ", NULL }, | |
103 { PT, "\332ltima atualiza\347\343o ", NULL }, | |
104 { SV, "Senast uppdaterad ", NULL }, | |
105 { ZH_CN, "\xd7\xee\xba\xf3\xd0\xde\xb8\xc4\xc8\xd5\xc6\xda", NULL }, | |
106 { ZH_HK, "\xb3\xcc\xaa\xf1\xa7\xf3\xb7\x73\xae\xc9\xb6\xa1", NULL }, | |
107 { ZH_US, "\xb3\xcc\xab\xe1\xad\xd7\xa7\xef\xa4\xe9\xb4\xc1", "http://chinese.profiles.yahoo.com" }, | |
108 { ZH_TW, "\xb3\xcc\xab\xe1\xad\xd7\xa7\xef\xa4\xe9\xb4\xc1", NULL }, | |
109 { XX, NULL, NULL } | |
110 }; | |
111 | |
112 /* Strings in this list must be in UTF-8; 's should be specified as spaces. */ | |
113 static const profile_strings_node_t profile_strings[] = { | |
114 { DA, "da", "ISO-8859-1", | |
115 "Yahoo! ID:", | |
116 "Privat", | |
117 "Intet svar", | |
118 "Min Email", | |
119 "Rigtige navn:", | |
120 "Opholdssted:", | |
121 "Alder:", | |
122 "Ægteskabelig status:", | |
123 "Køn:", | |
124 "Erhverv:", | |
125 "Hobbyer:", | |
126 "Sidste nyt:", | |
127 "Favoritcitat", | |
128 "Links", | |
129 "Ingen hjemmeside specificeret", | |
130 "Forside:", | |
131 "Intet cool link specificeret", | |
132 "Cool link 1:", | |
133 "Cool link 2:", | |
134 "Cool link 3:", | |
135 NULL | |
136 }, | |
137 { DE, "de", "ISO-8859-1", | |
138 "Yahoo!-ID:", | |
139 "Privat", | |
140 "Keine Antwort", | |
141 "Meine E-Mail", | |
142 "Realer Name:", | |
143 "Ort:", | |
144 "Alter:", | |
145 "Familienstand:", | |
146 "Geschlecht:", | |
147 "Beruf:", | |
148 "Hobbys:", | |
149 "Neuste Nachrichten:", | |
150 "Mein Lieblingsspruch", | |
151 "Links", | |
152 "Keine Homepage angegeben", | |
153 "Homepage:", | |
154 "Keinen coolen Link angegeben", | |
155 "Cooler Link 1:", | |
156 "Cooler Link 2:", | |
157 "Cooler Link 3:", | |
158 NULL | |
159 }, | |
160 { EL, "el", "ISO-8859-7", /* EL is identical to EN, except no_answer_string */ | |
161 "Yahoo! ID:", | |
162 "Private", | |
163 "Καμία απάντηση", | |
164 "My Email", | |
165 "Real Name:", | |
166 "Location:", | |
167 "Age:", | |
168 "Marital Status:", | |
169 "Gender:", | |
170 "Occupation:", | |
171 "Hobbies:", | |
172 "Latest News", | |
173 "Favorite Quote", | |
174 "Links", | |
175 "No home page specified", | |
176 "Home Page:", | |
177 "No cool link specified", | |
178 "Cool Link 1:", | |
179 "Cool Link 2:", | |
180 "Cool Link 3:", | |
181 NULL | |
182 }, | |
183 { EN, "en", "ISO-8859-1", | |
184 "Yahoo! ID:", | |
185 "Private", | |
186 "No Answer", | |
187 "My Email", | |
188 "Real Name:", | |
189 "Location:", | |
190 "Age:", | |
191 "Marital Status:", | |
192 "Gender:", | |
193 "Occupation:", | |
194 "Hobbies:", | |
195 "Latest News", | |
196 "Favorite Quote", | |
197 "Links", | |
198 "No home page specified", | |
199 "Home Page:", | |
200 "No cool link specified", | |
201 "Cool Link 1:", | |
202 "Cool Link 2:", | |
203 "Cool Link 3:", | |
204 NULL | |
205 }, | |
206 { EN_GB, "en_GB", "ISO-8859-1", /* Same as EN except spelling of "Favourite" */ | |
207 "Yahoo! ID:", | |
208 "Private", | |
209 "No Answer", | |
210 "My Email", | |
211 "Real Name:", | |
212 "Location:", | |
213 "Age:", | |
214 "Marital Status:", | |
215 "Gender:", | |
216 "Occupation:", | |
217 "Hobbies:", | |
218 "Latest News", | |
219 "Favourite Quote", | |
220 "Links", | |
221 "No home page specified", | |
222 "Home Page:", | |
223 "No cool link specified", | |
224 "Cool Link 1:", | |
225 "Cool Link 2:", | |
226 "Cool Link 3:", | |
227 NULL | |
228 }, | |
229 { ES_AR, "es_AR", "ISO-8859-1", | |
230 "Usuario de Yahoo!:", | |
231 "Privado", | |
232 "No introdujiste una respuesta", | |
233 "Mi dirección de correo electrónico", | |
234 "Nombre real:", | |
235 "Ubicación:", | |
236 "Edad:", | |
237 "Estado civil:", | |
238 "Sexo:", | |
239 "Ocupación:", | |
240 "Pasatiempos:", | |
241 "Últimas noticias:", | |
242 "Tu cita favorita", | |
243 "Enlaces", | |
244 "Ninguna página de inicio especificada", | |
245 "Página de inicio:", | |
246 "Ningún enlace preferido", | |
247 "Enlace genial 1:", | |
248 "Enlace genial 2:", | |
249 "Enlace genial 3:", | |
250 NULL | |
251 }, | |
252 { ES_ES, "es_ES", "ISO-8859-1", | |
253 "ID de Yahoo!:", | |
254 "Privado", | |
255 "Sin respuesta", | |
256 "Mi correo-e", | |
257 "Nombre verdadero:", | |
258 "Lugar:", | |
259 "Edad:", | |
260 "Estado civil:", | |
261 "Sexo:", | |
262 "Ocupación:", | |
263 "Aficiones:", | |
264 "Ultimas Noticias:", | |
265 "Tu cita Favorita", | |
266 "Enlace", | |
267 "Ninguna página personal especificada", | |
268 "Página de Inicio:", | |
269 "Ningún enlace preferido", | |
270 "Enlaces Preferidos 1:", | |
271 "Enlaces Preferidos 2:", | |
272 "Enlaces Preferidos 3:", | |
273 NULL | |
274 }, | |
275 { ES_MX, "es_MX", "ISO-8859-1", | |
276 "ID de Yahoo!:", | |
277 "Privado", | |
278 "Sin responder", | |
279 "Mi Dirección de correo-e", | |
280 "Nombre real:", | |
281 "Ubicación:", | |
282 "Edad:", | |
283 "Estado civil:", | |
284 "Sexo:", | |
285 "Ocupación:", | |
286 "Pasatiempos:", | |
287 "Ultimas Noticias:", | |
288 "Su cita favorita", | |
289 "Enlaces", | |
290 "Ninguna Página predefinida", | |
291 "Página web:", | |
292 "Ningún Enlace preferido", | |
293 "Enlaces Preferidos 1:", | |
294 "Enlaces Preferidos 2:", | |
295 "Enlaces Preferidos 3:", | |
296 NULL | |
297 }, | |
298 { ES_US, "es_US", "ISO-8859-1", | |
299 "ID de Yahoo!:", | |
300 "Privado", | |
301 "No introdujo una respuesta", | |
302 "Mi Dirección de correo-e", | |
303 "Nombre real:", | |
304 "Localidad:", | |
305 "Edad:", | |
306 "Estado civil:", | |
307 "Sexo:", | |
308 "Ocupación:", | |
309 "Pasatiempos:", | |
310 "Ultimas Noticias:", | |
311 "Su cita Favorita", | |
312 "Enlaces", | |
313 "Ninguna Página de inicio predefinida", | |
314 "Página de inicio:", | |
315 "Ningún Enlace preferido", | |
316 "Enlaces Preferidos 1:", | |
317 "Enlaces Preferidos 2:", | |
318 "Enlaces Preferidos 3:", | |
319 NULL | |
320 }, | |
321 { FR_CA, "fr_CA", "ISO-8859-1", | |
322 "Compte Yahoo!:", | |
323 "Privé", | |
324 "Sans réponse", | |
325 "Mon courriel", | |
326 "Nom réel:", | |
327 "Lieu:", | |
328 "Âge:", | |
329 "État civil:", | |
330 "Sexe:", | |
331 "Profession:", | |
332 "Passe-temps:", | |
333 "Actualités:", | |
334 "Citation préférée", | |
335 "Liens", | |
336 "Pas de mention d'une page personnelle", | |
337 "Page personnelle:", | |
338 "Pas de mention d'un lien favori", | |
339 "Lien préféré 1:", | |
340 "Lien préféré 2:", | |
341 "Lien préféré 3:", | |
342 NULL | |
343 }, | |
344 { FR_FR, "fr_FR", "ISO-8859-1", | |
345 "Compte Yahoo!:", | |
346 "Privé", | |
347 "Sans réponse", | |
348 "Mon E-mail", | |
349 "Nom réel:", | |
350 "Lieu:", | |
351 "Âge:", | |
352 "Situation de famille:", | |
353 "Sexe:", | |
354 "Profession:", | |
355 "Centres d'intérêts:", | |
356 "Actualités:", | |
357 "Citation préférée", | |
358 "Liens", | |
359 "Pas de mention d'une page perso", | |
360 "Page perso:", | |
361 "Pas de mention d'un lien favori", | |
362 "Lien préféré 1:", | |
363 "Lien préféré 2:", | |
364 "Lien préféré 3:", | |
365 NULL | |
366 }, | |
367 { IT, "it", "ISO-8859-1", | |
368 "ID Yahoo!:", | |
369 "Non pubblica", | |
370 "Nessuna risposta", | |
371 "La mia e-mail", | |
372 "Nome vero:", | |
373 "Località:", | |
374 "Eta':", | |
375 "Stato civile:", | |
376 "Sesso:", | |
377 "Occupazione:", | |
378 "Hobby:", | |
379 "Ultime notizie:", | |
380 "Citazione preferita", | |
381 "Link", | |
382 "Nessuna home page specificata", | |
383 "Inizio:", | |
384 "Nessun link specificato", | |
385 "Link Preferiti 1:", | |
386 "Link Preferiti 2:", | |
387 "Link Preferiti 3:", | |
388 NULL | |
389 }, | |
390 { JA, "ja", "EUC-JP", | |
391 "Yahoo! JAPAN ID:", | |
392 "非公開", | |
393 "無回答", | |
394 "メール:", | |
395 "名前:", | |
396 "住所:", | |
397 "年齢:", | |
398 "未婚/既婚:", | |
399 "性別:", | |
400 "職業:", | |
401 "趣味:", | |
402 "最近の出来事:", | |
403 NULL, | |
404 #if 0 | |
405 "おすすめサイト", | |
406 #else | |
407 "自己PR", /* "Self description" comes before "Links" for yahoo.co.jp */ | |
408 #endif | |
409 NULL, | |
410 NULL, | |
411 NULL, | |
412 "おすすめサイト1:", | |
413 "おすすめサイト2:", | |
414 "おすすめサイト3:", | |
415 NULL | |
416 }, | |
417 { KO, "ko", "EUC-KR", | |
418 "야후! ID:", | |
419 "비공개", | |
420 "비공개", | |
421 "My Email", | |
422 "실명:", | |
423 "거주지:", | |
424 "나이:", | |
425 "결혼 여부:", | |
426 "성별:", | |
427 "직업:", | |
428 "취미:", | |
429 "자기 소개:", | |
430 "좋아하는 명언", | |
431 "링크", | |
432 "홈페이지를 지정하지 않았습니다.", | |
433 "홈페이지:", | |
434 "추천 사이트가 없습니다.", | |
435 "추천 사이트 1:", | |
436 "추천 사이트 2:", | |
437 "추천 사이트 3:", | |
438 NULL | |
439 }, | |
440 { NO, "no", "ISO-8859-1", | |
441 "Yahoo! ID:", | |
442 "Privat", | |
443 "Ikke noe svar", | |
444 "Min e-post", | |
445 "Virkelig navn:", | |
446 "Sted:", | |
447 "Alder:", | |
448 "Sivilstatus:", | |
449 "Kjønn:", | |
450 "Yrke:", | |
451 "Hobbyer:", | |
452 "Siste nytt:", | |
453 "Yndlingssitat", | |
454 "Lenker", | |
455 "Ingen hjemmeside angitt", | |
456 "Hjemmeside:", | |
457 "No cool link specified", | |
458 "Bra lenke 1:", | |
459 "Bra lenke 2:", | |
460 "Bra lenke 3:", | |
461 NULL | |
462 }, | |
463 { PT, "pt", "ISO-8859-1", | |
464 "ID Yahoo!:", | |
465 "Particular", | |
466 "Sem resposta", | |
467 "Meu e-mail", | |
468 "Nome verdadeiro:", | |
469 "Local:", | |
470 "Idade:", | |
471 "Estado civil:", | |
472 "Sexo:", | |
473 "Ocupação:", | |
474 "Hobbies:", | |
475 "Últimas notícias:", | |
476 "Frase favorita", | |
477 "Links", | |
478 "Nenhuma página pessoal especificada", | |
479 "Página pessoal:", | |
480 "Nenhum site legal especificado", | |
481 "Site legal 1:", | |
482 "Site legal 2:", | |
483 "Site legal 3:", | |
484 NULL | |
485 }, | |
486 { SV, "sv", "ISO-8859-1", | |
487 "Yahoo!-ID:", | |
488 "Privat", | |
489 "Inget svar", | |
490 "Min mail", | |
491 "Riktigt namn:", | |
492 "Plats:", | |
493 "Ålder:", | |
494 "Civilstånd:", | |
495 "Kön:", | |
496 "Yrke:", | |
497 "Hobby:", | |
498 "Senaste nytt:", | |
499 "Favoritcitat", | |
500 "Länkar", | |
501 "Ingen hemsida specificerad", | |
502 "Hemsida:", | |
503 "Ingen cool länk specificerad", | |
504 "Coola länkar 1:", | |
505 "Coola länkar 2:", | |
506 "Coola länkar 3:", | |
507 NULL | |
508 }, | |
509 { ZH_CN, "zh_CN", "GB2312", | |
510 "Yahoo! ID:", | |
511 "没有提供", | |
512 "没有回答", | |
513 "个人电邮地址", | |
514 "真实姓名:", | |
515 "所在地点:", | |
516 "年龄:", | |
517 "婚姻状况:", | |
518 "性别:", | |
519 "职业:", | |
520 "业余爱好:", | |
521 "个人近况:", | |
522 "喜欢的引言", | |
523 "链接", | |
524 "没有个人主页", | |
525 "个人主页:", | |
526 "没有推荐网站链接", | |
527 "推荐网站链接 1:", | |
528 "推荐网站链接 2:", | |
529 "推荐网站链接 3:", | |
530 NULL | |
531 }, | |
532 { ZH_HK, "zh_HK", "Big5", | |
533 "Yahoo! ID:", | |
534 "私人的", | |
535 "沒有回答", | |
536 "電子信箱", | |
537 "真實姓名:", | |
538 "地點:", | |
539 "年齡:", | |
540 "婚姻狀況:", | |
541 "性別:", | |
542 "職業:", | |
543 "嗜好:", | |
544 "最新消息:", | |
545 "最喜愛的股票叫價", /* [sic] Yahoo!'s translators don't check context */ | |
546 "連結", | |
547 "沒有注明個人網頁", /* [sic] */ | |
548 "個人網頁:", | |
549 "沒有注明 Cool 連結", /* [sic] */ | |
550 "Cool 連結 1:", /* TODO */ | |
551 "Cool 連結 2:", /* TODO */ | |
552 "Cool 連結 3:", /* TODO */ | |
553 NULL | |
554 }, | |
555 { ZH_TW, "zh_TW", "Big5", | |
556 "帳 號:", | |
557 "沒有提供", | |
558 "沒有回應", | |
559 "電子信箱", | |
560 "姓名:", | |
561 "地點:", | |
562 "年齡:", | |
563 "婚姻狀態:", | |
564 "性別:", | |
565 "職業:", | |
566 "興趣:", | |
567 "個人近況:", | |
568 "喜歡的名句", | |
569 "連結", | |
570 "沒有個人網頁", | |
571 "個人網頁:", | |
572 "沒有推薦網站連結", | |
573 "推薦網站連結 1:", | |
574 "推薦網站連結 2:", | |
575 "推薦網站連結 3:", | |
576 NULL | |
577 }, | |
578 { ZH_US, "zh_US", "Big5", /* ZH_US is like ZH_TW, but also a bit like ZH_HK */ | |
579 "Yahoo! ID:", | |
580 "沒有提供", | |
581 "沒有回答", | |
582 "個人Email地址", | |
583 "真實姓名:", | |
584 "地點:", | |
585 "年齡:", | |
586 "婚姻狀態:", | |
587 "性別:", | |
588 "職業:", | |
589 "嗜好:", | |
590 "個人近況:", | |
591 "喜歡的名句", | |
592 "連結", | |
593 "沒有個人網頁", | |
594 "個人網頁:", | |
595 "沒有推薦網站連結", | |
596 "推薦網站連結 1:", /* TODO */ | |
597 "推薦網站連結 2:", /* TODO */ | |
598 "推薦網站連結 3:", /* TODO */ | |
599 NULL | |
600 }, | |
601 { XX, NULL, NULL, NULL, NULL, NULL, NULL }, | |
602 }; | |
603 | |
604 static char *yahoo_remove_nonbreaking_spaces(char *str) | |
605 { | |
606 char *p; | |
607 while ((p = strstr(str, " ")) != NULL) { | |
608 *p = ' '; /* Turn 's into ordinary blanks */ | |
609 p += 1; | |
610 memmove(p, p + 5, strlen(p + 5)); | |
611 str[strlen(str) - 5] = '\0'; | |
612 } | |
613 return str; | |
614 } | |
615 | |
616 static void yahoo_got_info(void *data, const char *url_text, size_t len) | |
617 { | |
618 YahooGetInfoData *info_data = (YahooGetInfoData *)data; | |
619 char *stripped, *p; | |
620 char buf[1024]; | |
621 gboolean found = FALSE; | |
622 char *url_buffer; | |
623 GString *s; | |
624 int stripped_len; | |
625 const char *last_updated_string = NULL; | |
626 char *last_updated_utf8_string; | |
627 int lang, strid; | |
628 | |
629 gaim_debug_info("yahoo", "In yahoo_got_info\n"); | |
630 | |
631 /* we failed to grab the profile URL */ | |
632 if (url_text == NULL || strcmp(url_text, "") == 0) { | |
633 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, | |
634 _("<html><body><b>Error retrieving profile</b></body></html>"), | |
635 NULL, NULL); | |
636 | |
637 g_free(info_data->name); | |
638 g_free(info_data); | |
639 return; | |
640 } | |
641 | |
642 /* we don't yet support the multiple link level of the warning page for | |
643 * 'adult' profiles, not to mention the fact that yahoo wants you to be | |
644 * logged in (on the website) to be able to view an 'adult' profile. for | |
645 * now, just tell them that we can't help them, and provide a link to the | |
646 * profile if they want to do the web browser thing. | |
647 */ | |
648 p = strstr(url_text, "Adult Profiles Warning Message"); | |
649 if (p) { | |
650 g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>", | |
651 _("<b>Sorry, profiles marked as containing adult content are not supported at this time.</b><br><br>\n"), | |
652 _("If you wish to view this profile, you will need to visit this link in your web browser<br>"), | |
653 YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name); | |
654 | |
655 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, | |
656 buf, NULL, NULL); | |
657 | |
658 g_free(info_data->name); | |
659 g_free(info_data); | |
660 return; | |
661 } | |
662 | |
663 /* Check whether the profile is written in a supported language */ | |
664 for (lang = 0;; lang += 1) { | |
665 last_updated_string = profile_langs[lang].last_updated_string; | |
666 if (!last_updated_string) break; | |
667 p = strstr(url_text, last_updated_string); | |
668 if (p && profile_langs[lang].det && !strstr(url_text, profile_langs[lang].det)) { | |
669 p = NULL; | |
670 } | |
671 if (p) break; | |
672 } | |
673 if (p) { | |
674 for (strid = 0; profile_strings[strid].lang != XX; strid += 1) { | |
675 if (profile_strings[strid].lang == profile_langs[lang].lang) break; | |
676 } | |
677 gaim_debug_info("yahoo", "detected profile lang = %s (%d)\n", profile_strings[strid].lang_string, lang); | |
678 } | |
679 | |
680 /* At the moment we don't support profile pages with languages other than | |
681 * English. The problem is, that every user may choose his/her own profile | |
682 * language. This language has nothing to do with the preferences of the | |
683 * user which looks at the profile | |
684 */ | |
685 if (!p || profile_strings[strid].lang == XX) { | |
686 if (strstr(url_text, "was not found on this server.") == NULL && strstr(url_text, "Yahoo! Member Directory - User not found") == NULL) { | |
687 g_snprintf(buf, 1024, "<html><body>%s%s<a href=\"%s%s\">%s%s</a></body></html>", | |
688 _("<b>Sorry, non-English profiles are not supported at this time.</b><br><br>\n"), | |
689 _("If you wish to view this profile, you will need to visit this link in your web browser<br>"), | |
690 YAHOO_PROFILE_URL, info_data->name, YAHOO_PROFILE_URL, info_data->name); | |
691 } else { | |
692 g_snprintf(buf, 1024, "<html><body><b>Error retrieving profile</b></body></html>"); | |
693 } | |
694 | |
695 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, | |
696 buf, NULL, NULL); | |
697 | |
698 g_free(info_data->name); | |
699 g_free(info_data); | |
700 return; | |
701 } | |
702 | |
703 url_buffer = g_strdup(url_text); | |
704 | |
705 /* | |
706 * gaim_markup_strip_html() doesn't strip out character entities like | |
707 * and · | |
708 */ | |
709 yahoo_remove_nonbreaking_spaces(url_buffer); | |
710 #if 1 | |
711 while ((p = strstr(url_buffer, "·")) != NULL) { | |
712 memmove(p, p + 6, strlen(p + 6)); | |
713 url_buffer[strlen(url_buffer) - 6] = '\0'; | |
714 } | |
715 #endif | |
716 | |
717 /* nuke the nasty \r's */ | |
718 while ((p = strchr(url_buffer, '\r')) != NULL) { | |
719 memmove(p, p + 1, strlen(p + 1)); | |
720 url_buffer[strlen(url_buffer) - 1] = '\0'; | |
721 } | |
722 | |
723 /* nuke the html, it's easier than trying to parse the horrid stuff */ | |
724 stripped = gaim_markup_strip_html(url_buffer); | |
725 stripped_len = strlen(stripped); | |
726 | |
727 gaim_debug_misc("yahoo", "stripped = %p\n", stripped); | |
728 gaim_debug_misc("yahoo", "url_buffer = %p\n", url_buffer); | |
729 | |
730 /* convert to utf8 */ | |
731 p = g_convert(stripped, -1, "utf-8", profile_strings[strid].charset, NULL, NULL, NULL); | |
732 if (!p) { | |
733 p = g_locale_to_utf8(stripped, -1, NULL, NULL, NULL); | |
734 if (!p) { | |
735 p = g_convert(stripped, -1, "utf-8", "windows-1252", NULL, NULL, NULL); | |
736 } | |
737 } | |
738 if (p) { | |
739 g_free(stripped); | |
740 stripped = gaim_utf8_ncr_decode(p); | |
741 stripped_len = strlen(stripped); | |
742 g_free(p); | |
743 p = stripped; | |
744 } | |
745 /* FIXME need error dialog here */ | |
746 | |
747 /* "Last updated" should also be converted to utf8 and with killed */ | |
748 last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8", profile_strings[strid].charset, NULL, NULL, NULL); | |
749 yahoo_remove_nonbreaking_spaces(last_updated_utf8_string); | |
750 | |
751 gaim_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); | |
752 | |
753 /* gonna re-use the memory we've already got for url_buffer */ | |
754 /* no we're not */ | |
755 s = g_string_sized_new(strlen(url_buffer)); | |
756 g_string_append(s, "<html><body>\n"); | |
757 | |
758 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as | |
759 * true, since the Yahoo! ID will always be there */ | |
760 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].yahoo_id_string, 2, "\n", 0, | |
761 NULL, _("Yahoo! ID"), 0, NULL)) | |
762 g_string_append_printf(s, "<b>%s:</b> %s<br>", _("Yahoo! ID"), info_data->name); | |
763 | |
764 | |
765 /* extract their Email address and put it in */ | |
766 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].my_email_string, 5, "\n", 0, | |
767 profile_strings[strid].private_string, _("Email"), 0, NULL); | |
768 | |
769 /* extract the Nickname if it exists */ | |
770 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Nickname:", 1, "\n", '\n', | |
771 NULL, _("Nickname"), 0, NULL); | |
772 | |
773 /* extract their RealName and put it in */ | |
774 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].realname_string, 1, "\n", '\n', | |
775 NULL, _("Realname"), 0, NULL); | |
776 | |
777 /* extract their Location and put it in */ | |
778 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].location_string, 2, "\n", '\n', | |
779 NULL, _("Location"), 0, NULL); | |
780 | |
781 /* extract their Age and put it in */ | |
782 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].age_string, 3, "\n", '\n', | |
783 NULL, _("Age"), 0, NULL); | |
784 | |
785 /* extract their MaritalStatus and put it in */ | |
786 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].maritalstatus_string, 3, "\n", '\n', | |
787 profile_strings[strid].no_answer_string, _("Marital Status"), 0, NULL); | |
788 | |
789 /* extract their Gender and put it in */ | |
790 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].gender_string, 3, "\n", '\n', | |
791 profile_strings[strid].no_answer_string, _("Gender"), 0, NULL); | |
792 | |
793 /* extract their Occupation and put it in */ | |
794 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].occupation_string, 2, "\n", '\n', | |
795 NULL, _("Occupation"), 0, NULL); | |
796 | |
797 /* Hobbies, Latest News, and Favorite Quote are a bit different, since the | |
798 * values can contain embedded newlines... but any or all of them can also | |
799 * not appear. The way we delimit them is to successively look for the next | |
800 * one that _could_ appear, and if all else fails, we end the section by | |
801 * looking for the 'Links' heading, which is the next thing to follow this | |
802 * bunch. | |
803 */ | |
804 | |
805 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].hobbies_string, 1, profile_strings[strid].latest_news_string, | |
806 '\n', NULL, _("Hobbies"), 0, NULL)) | |
807 { | |
808 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].hobbies_string, 1, profile_strings[strid].favorite_quote_string, | |
809 '\n', NULL, _("Hobbies"), 0, NULL)) | |
810 { | |
811 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].hobbies_string, 1, profile_strings[strid].links_string, | |
812 '\n', NULL, _("Hobbies"), 0, NULL); | |
813 } | |
814 else | |
815 found = TRUE; | |
816 } | |
817 else | |
818 found = TRUE; | |
819 | |
820 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].latest_news_string, 1, profile_strings[strid].favorite_quote_string, | |
821 '\n', NULL, _("Latest News"), 0, NULL)) | |
822 { | |
823 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].latest_news_string, 1, profile_strings[strid].links_string, | |
824 '\n', NULL, _("Latest News"), 0, NULL); | |
825 } | |
826 else | |
827 found = TRUE; | |
828 | |
829 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].favorite_quote_string, 1, profile_strings[strid].links_string, | |
830 '\n', NULL, _("Favorite Quote"), 0, NULL); | |
831 | |
832 /* Home Page will either be "No home page specified", | |
833 * or "Home Page: " and a link. | |
834 * For non-English profiles, there might be no "Home Page:" string at all, | |
835 * in which case we probably can do nothing about it. | |
836 */ | |
837 if (profile_strings[strid].home_page_string) { | |
838 p = !profile_strings[strid].no_home_page_specified_string? NULL: | |
839 strstr(stripped, profile_strings[strid].no_home_page_specified_string); | |
840 if(!p) | |
841 { | |
842 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].home_page_string, 1, "\n", 0, NULL, | |
843 _("Home Page"), 1, NULL); | |
844 } | |
845 } | |
846 | |
847 /* Cool Link {1,2,3} is also different. If "No cool link specified" exists, | |
848 * then we have none. If we have one however, we'll need to check and see if | |
849 * we have a second one. If we have a second one, we have to check to see if | |
850 * we have a third one. | |
851 */ | |
852 p = !profile_strings[strid].no_cool_link_specified_string? NULL: | |
853 strstr(stripped,profile_strings[strid].no_cool_link_specified_string); | |
854 if (!p) | |
855 { | |
856 if (gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].cool_link_1_string, 1, "\n", 0, NULL, | |
857 _("Cool Link 1"), 1, NULL)) | |
858 { | |
859 found = TRUE; | |
860 if (gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].cool_link_2_string, 1, "\n", 0, NULL, | |
861 _("Cool Link 2"), 1, NULL)) | |
862 gaim_markup_extract_info_field(stripped, stripped_len, s, profile_strings[strid].cool_link_3_string, 1, "\n", 0, NULL, | |
863 _("Cool Link 3"), 1, NULL); | |
864 } | |
865 } | |
866 | |
867 /* see if Member Since is there, and if so, extract it. */ | |
868 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, "Member Since:", 1, last_updated_utf8_string, | |
869 '\n', NULL, _("Member Since"), 0, NULL); | |
870 | |
871 /* extract the Last Updated date and put it in */ | |
872 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, last_updated_utf8_string, 0, "\n", '\n', NULL, | |
873 _("Last Updated"), 0, NULL); | |
874 | |
875 /* finish off the html */ | |
876 g_string_append(s, "</body></html>\n"); | |
877 g_free(stripped); | |
878 | |
879 if(found) | |
880 { | |
881 /* show it to the user */ | |
882 gaim_notify_formatted(info_data->gc, NULL, _("Buddy Information"), NULL, | |
883 s->str, NULL, NULL); | |
884 } | |
885 else | |
886 { | |
887 char *primary; | |
888 primary = g_strdup_printf(_("User information for %s unavailable"), info_data->name); | |
889 gaim_notify_error(info_data->gc, NULL, primary, | |
890 _("The user's profile is empty.")); | |
891 g_free(primary); | |
892 } | |
893 | |
894 g_free(last_updated_utf8_string); | |
895 g_free(url_buffer); | |
896 g_string_free(s, TRUE); | |
897 g_free(info_data->name); | |
898 g_free(info_data); | |
899 } | |
900 | |
901 void yahoo_get_info(GaimConnection *gc, const char *name) | |
902 { | |
903 YahooGetInfoData *data; | |
904 char *url; | |
905 | |
906 data = g_new0(YahooGetInfoData, 1); | |
907 data->gc = gc; | |
908 data->name = g_strdup(name); | |
909 | |
910 if (strstr(gaim_account_get_string(gaim_connection_get_account(gc), "server", YAHOO_PAGER_HOST), "yahoo.co.jp")) { | |
911 url = g_strdup_printf("%s%s", "http://profiles.yahoo.co.jp/", name); | |
912 } else { | |
913 url = g_strdup_printf("%s%s", YAHOO_PROFILE_URL, name); | |
914 } | |
915 | |
916 gaim_url_fetch(url, FALSE, NULL, FALSE, yahoo_got_info, data); | |
917 | |
918 g_free(url); | |
919 } |