Mercurial > pidgin
annotate src/protocols/yahoo/yahoo_profile.c @ 12662:eb4841fa697c
[gaim-migrate @ 15005]
sf bug #1385691, Text field visible even when status set to "online"
Don't allow available messages for ICQ. The server doesn't support them.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Mon, 26 Dec 2005 07:43:41 +0000 |
| parents | b4d2bba86f65 |
| children | 2c3ee0eff94b |
| rev | line source |
|---|---|
| 9162 | 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 | |
| 9242 | 24 #define PHOTO_SUPPORT 1 |
| 25 | |
| 9162 | 26 #include "internal.h" |
| 27 #include "debug.h" | |
| 28 #include "notify.h" | |
| 29 #include "util.h" | |
| 9242 | 30 #if PHOTO_SUPPORT |
| 31 #include "imgstore.h" | |
| 32 #endif | |
| 9162 | 33 |
| 34 #include "yahoo.h" | |
| 9281 | 35 #include "yahoo_friend.h" |
| 9162 | 36 |
| 37 typedef struct { | |
| 38 GaimConnection *gc; | |
| 39 char *name; | |
| 40 } YahooGetInfoData; | |
| 41 | |
| 42 typedef enum profile_lang_id { | |
| 43 XX, DA, DE, EL, | |
| 44 EN, EN_GB, | |
| 45 ES_AR, ES_ES, ES_MX, ES_US, | |
| 46 FR_CA, FR_FR, | |
| 47 IT, JA, KO, NO, PT, SV, | |
| 48 ZH_CN, ZH_HK, ZH_TW, ZH_US | |
| 49 } profile_lang_id_t; | |
| 50 | |
| 51 typedef struct profile_lang_node { | |
| 52 profile_lang_id_t lang; | |
| 53 char *last_updated_string; | |
| 54 char *det; | |
| 55 } profile_lang_node_t; | |
| 56 | |
| 57 typedef struct profile_strings_node { | |
| 58 profile_lang_id_t lang; | |
| 59 char *lang_string; /* Only to make debugging output saner */ | |
| 60 char *charset; | |
| 61 char *yahoo_id_string; | |
| 62 char *private_string; | |
| 63 char *no_answer_string; | |
| 64 char *my_email_string; | |
| 65 char *realname_string; | |
| 66 char *location_string; | |
| 67 char *age_string; | |
| 68 char *maritalstatus_string; | |
| 69 char *gender_string; | |
| 70 char *occupation_string; | |
| 71 char *hobbies_string; | |
| 72 char *latest_news_string; | |
| 73 char *favorite_quote_string; | |
| 74 char *links_string; | |
| 75 char *no_home_page_specified_string; | |
| 76 char *home_page_string; | |
| 77 char *no_cool_link_specified_string; | |
| 78 char *cool_link_1_string; | |
| 79 char *cool_link_2_string; | |
| 80 char *cool_link_3_string; | |
| 81 char *dummy; | |
| 82 } profile_strings_node_t; | |
| 83 | |
| 9510 | 84 typedef enum profile_state { |
| 85 PROFILE_STATE_DEFAULT, | |
| 86 PROFILE_STATE_NOT_FOUND, | |
| 87 PROFILE_STATE_UNKNOWN_LANGUAGE | |
| 88 } profile_state_t; | |
| 89 | |
| 9242 | 90 typedef struct { |
| 91 YahooGetInfoData *info_data; | |
| 92 char *url_buffer; | |
| 93 GString *s; | |
| 94 char *photo_url_text; | |
| 95 char *profile_url_text; | |
| 96 char *tooltip_text; | |
| 97 const profile_strings_node_t *strings; | |
| 98 const char *last_updated_string; | |
| 9510 | 99 const char *title; |
| 100 profile_state_t profile_state; | |
| 9242 | 101 } YahooGetInfoStepTwoData; |
| 102 | |
| 9162 | 103 /* Strings to determine the profile "language" (more accurately "locale"). |
| 104 * Strings in this list must be in the original charset in the profile. | |
| 105 * The "Last Updated" string is used, but sometimes is not sufficient to | |
| 106 * distinguish 2 locales with this (e.g., ES_ES from ES_US, or FR_CA from | |
| 107 * FR_FR, or EL from EN_GB), in which case a second string is added and | |
| 108 * such special cases must be placed before the more general case. | |
| 109 */ | |
| 110 static const profile_lang_node_t profile_langs[] = { | |
| 111 { DA, "Opdateret sidste gang ", NULL }, | |
| 112 { DE, "Letzter Update ", NULL }, | |
| 113 { EL, "Last Updated:", "http://gr.profiles.yahoo.com" }, | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
114 { EN_GB, "Last Update ", "Favourite Quote" }, |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
115 { EN, "Last Update:", NULL }, |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
116 { EN, "Last Update ", NULL }, |
| 9162 | 117 { ES_AR, "\332ltima actualizaci\363n ", NULL }, |
| 118 { ES_ES, "Actualizada el ", "http://es.profiles.yahoo.com" }, | |
| 119 { ES_MX, "Actualizada el ", "http://mx.profiles.yahoo.com" }, | |
| 120 { ES_US, "Actualizada el ", NULL }, | |
| 121 { FR_CA, "Derni\xe8re mise \xe0 jour", "http://cf.profiles.yahoo.com" }, | |
| 122 { FR_FR, "Derni\xe8re mise \xe0 jour", NULL }, | |
| 11626 | 123 { IT, "Ultimo aggiornamento:", NULL }, |
| 9162 | 124 { JA, "\xba\xc7\xbd\xaa\xb9\xb9\xbf\xb7\xc6\xfc\xa1\xa7", NULL }, |
| 125 { KO, "\xb0\xbb\xbd\xc5\x20\xb3\xaf\xc2\xa5 ", NULL }, | |
| 126 { NO, "Sist oppdatert ", NULL }, | |
| 127 { PT, "\332ltima atualiza\347\343o ", NULL }, | |
| 128 { SV, "Senast uppdaterad ", NULL }, | |
| 129 { ZH_CN, "\xd7\xee\xba\xf3\xd0\xde\xb8\xc4\xc8\xd5\xc6\xda", NULL }, | |
| 130 { ZH_HK, "\xb3\xcc\xaa\xf1\xa7\xf3\xb7\x73\xae\xc9\xb6\xa1", NULL }, | |
| 131 { ZH_US, "\xb3\xcc\xab\xe1\xad\xd7\xa7\xef\xa4\xe9\xb4\xc1", "http://chinese.profiles.yahoo.com" }, | |
| 132 { ZH_TW, "\xb3\xcc\xab\xe1\xad\xd7\xa7\xef\xa4\xe9\xb4\xc1", NULL }, | |
| 133 { XX, NULL, NULL } | |
| 134 }; | |
| 135 | |
| 136 /* Strings in this list must be in UTF-8; 's should be specified as spaces. */ | |
| 137 static const profile_strings_node_t profile_strings[] = { | |
| 138 { DA, "da", "ISO-8859-1", | |
| 139 "Yahoo! ID:", | |
| 140 "Privat", | |
| 141 "Intet svar", | |
| 142 "Min Email", | |
| 143 "Rigtige navn:", | |
| 144 "Opholdssted:", | |
| 145 "Alder:", | |
| 146 "Ægteskabelig status:", | |
| 147 "Køn:", | |
| 148 "Erhverv:", | |
| 149 "Hobbyer:", | |
| 150 "Sidste nyt:", | |
| 151 "Favoritcitat", | |
| 152 "Links", | |
| 153 "Ingen hjemmeside specificeret", | |
| 154 "Forside:", | |
| 155 "Intet cool link specificeret", | |
| 156 "Cool link 1:", | |
| 157 "Cool link 2:", | |
| 158 "Cool link 3:", | |
| 159 NULL | |
| 160 }, | |
| 161 { DE, "de", "ISO-8859-1", | |
| 162 "Yahoo!-ID:", | |
| 163 "Privat", | |
| 164 "Keine Antwort", | |
| 165 "Meine E-Mail", | |
| 166 "Realer Name:", | |
| 167 "Ort:", | |
| 168 "Alter:", | |
| 169 "Familienstand:", | |
| 170 "Geschlecht:", | |
| 171 "Beruf:", | |
| 172 "Hobbys:", | |
| 173 "Neuste Nachrichten:", | |
| 174 "Mein Lieblingsspruch", | |
| 175 "Links", | |
| 176 "Keine Homepage angegeben", | |
| 177 "Homepage:", | |
| 178 "Keinen coolen Link angegeben", | |
| 179 "Cooler Link 1:", | |
| 180 "Cooler Link 2:", | |
| 181 "Cooler Link 3:", | |
| 182 NULL | |
| 183 }, | |
| 184 { EL, "el", "ISO-8859-7", /* EL is identical to EN, except no_answer_string */ | |
| 185 "Yahoo! ID:", | |
| 186 "Private", | |
| 187 "Καμία απάντηση", | |
| 188 "My Email", | |
| 189 "Real Name:", | |
| 190 "Location:", | |
| 191 "Age:", | |
| 192 "Marital Status:", | |
| 193 "Gender:", | |
| 194 "Occupation:", | |
| 195 "Hobbies:", | |
| 196 "Latest News", | |
| 197 "Favorite Quote", | |
| 198 "Links", | |
| 199 "No home page specified", | |
| 200 "Home Page:", | |
| 201 "No cool link specified", | |
| 202 "Cool Link 1:", | |
| 203 "Cool Link 2:", | |
| 204 "Cool Link 3:", | |
| 205 NULL | |
| 206 }, | |
| 207 { EN, "en", "ISO-8859-1", | |
| 208 "Yahoo! ID:", | |
| 209 "Private", | |
| 210 "No Answer", | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
211 "My Email:", |
| 9162 | 212 "Real Name:", |
| 213 "Location:", | |
| 214 "Age:", | |
| 215 "Marital Status:", | |
|
12578
6609528f7099
[gaim-migrate @ 14900]
Luke Schierer <lschiere@pidgin.im>
parents:
12367
diff
changeset
|
216 "Sex:", |
| 9162 | 217 "Occupation:", |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
218 "Hobbies", |
| 9162 | 219 "Latest News", |
| 220 "Favorite Quote", | |
| 221 "Links", | |
| 222 "No home page specified", | |
| 223 "Home Page:", | |
| 224 "No cool link specified", | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
225 "Cool Link 1", |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
226 "Cool Link 2", |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
227 "Cool Link 3", |
| 9162 | 228 NULL |
| 229 }, | |
| 230 { EN_GB, "en_GB", "ISO-8859-1", /* Same as EN except spelling of "Favourite" */ | |
| 231 "Yahoo! ID:", | |
| 232 "Private", | |
| 233 "No Answer", | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
234 "My Email:", |
| 9162 | 235 "Real Name:", |
| 236 "Location:", | |
| 237 "Age:", | |
| 238 "Marital Status:", | |
|
12578
6609528f7099
[gaim-migrate @ 14900]
Luke Schierer <lschiere@pidgin.im>
parents:
12367
diff
changeset
|
239 "Sex:", |
| 9162 | 240 "Occupation:", |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
241 "Hobbies", |
| 9162 | 242 "Latest News", |
| 243 "Favourite Quote", | |
| 244 "Links", | |
| 245 "No home page specified", | |
| 246 "Home Page:", | |
| 247 "No cool link specified", | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
248 "Cool Link 1", |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
249 "Cool Link 2", |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
250 "Cool Link 3", |
| 9162 | 251 NULL |
| 252 }, | |
| 253 { ES_AR, "es_AR", "ISO-8859-1", | |
| 254 "Usuario de Yahoo!:", | |
| 255 "Privado", | |
| 256 "No introdujiste una respuesta", | |
| 257 "Mi dirección de correo electrónico", | |
| 258 "Nombre real:", | |
| 259 "Ubicación:", | |
| 260 "Edad:", | |
| 261 "Estado civil:", | |
| 262 "Sexo:", | |
| 263 "Ocupación:", | |
| 264 "Pasatiempos:", | |
| 265 "Últimas noticias:", | |
| 266 "Tu cita favorita", | |
| 267 "Enlaces", | |
| 268 "Ninguna página de inicio especificada", | |
| 269 "Página de inicio:", | |
| 270 "Ningún enlace preferido", | |
| 271 "Enlace genial 1:", | |
| 272 "Enlace genial 2:", | |
| 273 "Enlace genial 3:", | |
| 274 NULL | |
| 275 }, | |
| 276 { ES_ES, "es_ES", "ISO-8859-1", | |
| 277 "ID de Yahoo!:", | |
| 278 "Privado", | |
| 279 "Sin respuesta", | |
| 280 "Mi correo-e", | |
| 281 "Nombre verdadero:", | |
| 282 "Lugar:", | |
| 283 "Edad:", | |
| 284 "Estado civil:", | |
| 285 "Sexo:", | |
| 286 "Ocupación:", | |
| 287 "Aficiones:", | |
| 288 "Ultimas Noticias:", | |
| 289 "Tu cita Favorita", | |
| 290 "Enlace", | |
| 291 "Ninguna página personal especificada", | |
| 292 "Página de Inicio:", | |
| 293 "Ningún enlace preferido", | |
| 294 "Enlaces Preferidos 1:", | |
| 295 "Enlaces Preferidos 2:", | |
| 296 "Enlaces Preferidos 3:", | |
| 297 NULL | |
| 298 }, | |
| 299 { ES_MX, "es_MX", "ISO-8859-1", | |
| 300 "ID de Yahoo!:", | |
| 301 "Privado", | |
| 302 "Sin responder", | |
| 303 "Mi Dirección de correo-e", | |
| 304 "Nombre real:", | |
| 305 "Ubicación:", | |
| 306 "Edad:", | |
| 307 "Estado civil:", | |
| 308 "Sexo:", | |
| 309 "Ocupación:", | |
| 310 "Pasatiempos:", | |
| 311 "Ultimas Noticias:", | |
| 312 "Su cita favorita", | |
| 313 "Enlaces", | |
| 314 "Ninguna Página predefinida", | |
| 315 "Página web:", | |
| 316 "Ningún Enlace preferido", | |
| 317 "Enlaces Preferidos 1:", | |
| 318 "Enlaces Preferidos 2:", | |
| 319 "Enlaces Preferidos 3:", | |
| 320 NULL | |
| 321 }, | |
| 322 { ES_US, "es_US", "ISO-8859-1", | |
| 323 "ID de Yahoo!:", | |
| 324 "Privado", | |
| 325 "No introdujo una respuesta", | |
| 326 "Mi Dirección de correo-e", | |
| 327 "Nombre real:", | |
| 328 "Localidad:", | |
| 329 "Edad:", | |
| 330 "Estado civil:", | |
| 331 "Sexo:", | |
| 332 "Ocupación:", | |
| 333 "Pasatiempos:", | |
| 334 "Ultimas Noticias:", | |
| 335 "Su cita Favorita", | |
| 336 "Enlaces", | |
| 337 "Ninguna Página de inicio predefinida", | |
| 338 "Página de inicio:", | |
| 339 "Ningún Enlace preferido", | |
| 340 "Enlaces Preferidos 1:", | |
| 341 "Enlaces Preferidos 2:", | |
| 342 "Enlaces Preferidos 3:", | |
| 343 NULL | |
| 344 }, | |
| 345 { FR_CA, "fr_CA", "ISO-8859-1", | |
| 346 "Compte Yahoo!:", | |
| 347 "Privé", | |
| 348 "Sans réponse", | |
| 349 "Mon courriel", | |
| 350 "Nom réel:", | |
| 351 "Lieu:", | |
| 352 "Âge:", | |
| 353 "État civil:", | |
| 354 "Sexe:", | |
| 355 "Profession:", | |
| 356 "Passe-temps:", | |
| 357 "Actualités:", | |
| 358 "Citation préférée", | |
| 359 "Liens", | |
| 360 "Pas de mention d'une page personnelle", | |
| 361 "Page personnelle:", | |
| 362 "Pas de mention d'un lien favori", | |
| 363 "Lien préféré 1:", | |
| 364 "Lien préféré 2:", | |
| 365 "Lien préféré 3:", | |
| 366 NULL | |
| 367 }, | |
| 368 { FR_FR, "fr_FR", "ISO-8859-1", | |
| 369 "Compte Yahoo!:", | |
| 370 "Privé", | |
| 371 "Sans réponse", | |
| 372 "Mon E-mail", | |
| 373 "Nom réel:", | |
| 374 "Lieu:", | |
| 375 "Âge:", | |
| 376 "Situation de famille:", | |
| 377 "Sexe:", | |
| 378 "Profession:", | |
| 379 "Centres d'intérêts:", | |
| 380 "Actualités:", | |
| 381 "Citation préférée", | |
| 382 "Liens", | |
| 383 "Pas de mention d'une page perso", | |
| 384 "Page perso:", | |
| 385 "Pas de mention d'un lien favori", | |
| 386 "Lien préféré 1:", | |
| 387 "Lien préféré 2:", | |
| 388 "Lien préféré 3:", | |
| 389 NULL | |
| 390 }, | |
| 391 { IT, "it", "ISO-8859-1", | |
| 11626 | 392 "Yahoo! ID:", |
| 9162 | 393 "Non pubblica", |
| 394 "Nessuna risposta", | |
| 11626 | 395 "La mia e-mail:", |
| 9162 | 396 "Nome vero:", |
| 397 "Località:", | |
| 11626 | 398 "Età:", |
| 9162 | 399 "Stato civile:", |
| 400 "Sesso:", | |
| 401 "Occupazione:", | |
| 11626 | 402 "Hobby", |
| 403 "Ultime notizie", | |
| 9162 | 404 "Citazione preferita", |
| 405 "Link", | |
| 406 "Nessuna home page specificata", | |
| 407 "Inizio:", | |
| 408 "Nessun link specificato", | |
| 11626 | 409 "Cool Link 1", |
| 410 "Cool Link 2", | |
| 411 "Cool Link 3", | |
| 9162 | 412 NULL |
| 413 }, | |
| 414 { JA, "ja", "EUC-JP", | |
| 415 "Yahoo! JAPAN ID:", | |
| 416 "非公開", | |
| 417 "無回答", | |
| 418 "メール:", | |
| 419 "名前:", | |
| 420 "住所:", | |
| 421 "年齢:", | |
| 422 "未婚/既婚:", | |
| 423 "性別:", | |
| 424 "職業:", | |
| 425 "趣味:", | |
| 426 "最近の出来事:", | |
| 427 NULL, | |
| 428 #if 0 | |
| 429 "おすすめサイト", | |
| 430 #else | |
| 431 "自己PR", /* "Self description" comes before "Links" for yahoo.co.jp */ | |
| 432 #endif | |
| 433 NULL, | |
| 434 NULL, | |
| 435 NULL, | |
| 436 "おすすめサイト1:", | |
| 437 "おすすめサイト2:", | |
| 438 "おすすめサイト3:", | |
| 439 NULL | |
| 440 }, | |
| 441 { KO, "ko", "EUC-KR", | |
| 442 "야후! ID:", | |
| 443 "비공개", | |
| 444 "비공개", | |
| 445 "My Email", | |
| 446 "실명:", | |
| 447 "거주지:", | |
| 448 "나이:", | |
| 449 "결혼 여부:", | |
| 450 "성별:", | |
| 451 "직업:", | |
| 452 "취미:", | |
| 453 "자기 소개:", | |
| 454 "좋아하는 명언", | |
| 455 "링크", | |
| 456 "홈페이지를 지정하지 않았습니다.", | |
| 457 "홈페이지:", | |
| 458 "추천 사이트가 없습니다.", | |
| 459 "추천 사이트 1:", | |
| 460 "추천 사이트 2:", | |
| 461 "추천 사이트 3:", | |
| 462 NULL | |
| 463 }, | |
| 464 { NO, "no", "ISO-8859-1", | |
| 465 "Yahoo! ID:", | |
| 466 "Privat", | |
| 467 "Ikke noe svar", | |
| 468 "Min e-post", | |
| 469 "Virkelig navn:", | |
| 470 "Sted:", | |
| 471 "Alder:", | |
| 472 "Sivilstatus:", | |
| 473 "Kjønn:", | |
| 474 "Yrke:", | |
| 475 "Hobbyer:", | |
| 476 "Siste nytt:", | |
| 477 "Yndlingssitat", | |
| 478 "Lenker", | |
| 479 "Ingen hjemmeside angitt", | |
| 480 "Hjemmeside:", | |
| 481 "No cool link specified", | |
| 482 "Bra lenke 1:", | |
| 483 "Bra lenke 2:", | |
| 484 "Bra lenke 3:", | |
| 485 NULL | |
| 486 }, | |
| 487 { PT, "pt", "ISO-8859-1", | |
| 488 "ID Yahoo!:", | |
| 489 "Particular", | |
| 490 "Sem resposta", | |
| 491 "Meu e-mail", | |
| 492 "Nome verdadeiro:", | |
| 493 "Local:", | |
| 494 "Idade:", | |
| 495 "Estado civil:", | |
| 496 "Sexo:", | |
| 497 "Ocupação:", | |
| 498 "Hobbies:", | |
| 499 "Últimas notícias:", | |
| 500 "Frase favorita", | |
| 501 "Links", | |
| 502 "Nenhuma página pessoal especificada", | |
| 503 "Página pessoal:", | |
| 504 "Nenhum site legal especificado", | |
| 505 "Site legal 1:", | |
| 506 "Site legal 2:", | |
| 507 "Site legal 3:", | |
| 508 NULL | |
| 509 }, | |
| 510 { SV, "sv", "ISO-8859-1", | |
| 511 "Yahoo!-ID:", | |
| 512 "Privat", | |
| 513 "Inget svar", | |
| 514 "Min mail", | |
| 515 "Riktigt namn:", | |
| 516 "Plats:", | |
| 517 "Ålder:", | |
| 518 "Civilstånd:", | |
| 519 "Kön:", | |
| 520 "Yrke:", | |
| 521 "Hobby:", | |
| 522 "Senaste nytt:", | |
| 523 "Favoritcitat", | |
| 524 "Länkar", | |
| 525 "Ingen hemsida specificerad", | |
| 526 "Hemsida:", | |
| 527 "Ingen cool länk specificerad", | |
| 528 "Coola länkar 1:", | |
| 529 "Coola länkar 2:", | |
| 530 "Coola länkar 3:", | |
| 531 NULL | |
| 532 }, | |
| 533 { ZH_CN, "zh_CN", "GB2312", | |
| 534 "Yahoo! ID:", | |
| 535 "没有提供", | |
| 536 "没有回答", | |
| 537 "个人电邮地址", | |
| 538 "真实姓名:", | |
| 539 "所在地点:", | |
| 540 "年龄:", | |
| 541 "婚姻状况:", | |
| 542 "性别:", | |
| 543 "职业:", | |
| 544 "业余爱好:", | |
| 545 "个人近况:", | |
| 546 "喜欢的引言", | |
| 547 "链接", | |
| 548 "没有个人主页", | |
| 549 "个人主页:", | |
| 550 "没有推荐网站链接", | |
| 551 "推荐网站链接 1:", | |
| 552 "推荐网站链接 2:", | |
| 553 "推荐网站链接 3:", | |
| 554 NULL | |
| 555 }, | |
| 556 { ZH_HK, "zh_HK", "Big5", | |
| 557 "Yahoo! ID:", | |
| 558 "私人的", | |
| 559 "沒有回答", | |
| 560 "電子信箱", | |
| 561 "真實姓名:", | |
| 562 "地點:", | |
| 563 "年齡:", | |
| 564 "婚姻狀況:", | |
| 565 "性別:", | |
| 566 "職業:", | |
| 567 "嗜好:", | |
| 568 "最新消息:", | |
| 569 "最喜愛的股票叫價", /* [sic] Yahoo!'s translators don't check context */ | |
| 570 "連結", | |
| 571 "沒有注明個人網頁", /* [sic] */ | |
| 572 "個人網頁:", | |
| 573 "沒有注明 Cool 連結", /* [sic] */ | |
| 574 "Cool 連結 1:", /* TODO */ | |
| 575 "Cool 連結 2:", /* TODO */ | |
| 576 "Cool 連結 3:", /* TODO */ | |
| 577 NULL | |
| 578 }, | |
| 579 { ZH_TW, "zh_TW", "Big5", | |
| 580 "帳 號:", | |
| 581 "沒有提供", | |
| 582 "沒有回應", | |
| 583 "電子信箱", | |
| 584 "姓名:", | |
| 585 "地點:", | |
| 586 "年齡:", | |
| 587 "婚姻狀態:", | |
| 588 "性別:", | |
| 589 "職業:", | |
| 590 "興趣:", | |
| 591 "個人近況:", | |
| 592 "喜歡的名句", | |
| 593 "連結", | |
| 594 "沒有個人網頁", | |
| 595 "個人網頁:", | |
| 596 "沒有推薦網站連結", | |
| 597 "推薦網站連結 1:", | |
| 598 "推薦網站連結 2:", | |
| 599 "推薦網站連結 3:", | |
| 600 NULL | |
| 601 }, | |
| 602 { ZH_US, "zh_US", "Big5", /* ZH_US is like ZH_TW, but also a bit like ZH_HK */ | |
| 603 "Yahoo! ID:", | |
| 604 "沒有提供", | |
| 605 "沒有回答", | |
| 606 "個人Email地址", | |
| 607 "真實姓名:", | |
| 608 "地點:", | |
| 609 "年齡:", | |
| 610 "婚姻狀態:", | |
| 611 "性別:", | |
| 612 "職業:", | |
| 613 "嗜好:", | |
| 614 "個人近況:", | |
| 615 "喜歡的名句", | |
| 616 "連結", | |
| 617 "沒有個人網頁", | |
| 618 "個人網頁:", | |
| 619 "沒有推薦網站連結", | |
| 620 "推薦網站連結 1:", /* TODO */ | |
| 621 "推薦網站連結 2:", /* TODO */ | |
| 622 "推薦網站連結 3:", /* TODO */ | |
| 623 NULL | |
| 624 }, | |
|
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
625 { XX, NULL, NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
626 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
627 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
628 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
629 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
630 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
631 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
632 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
633 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
634 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
635 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
636 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
637 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
638 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
639 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
640 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
641 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
642 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
643 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
644 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
645 NULL, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
646 NULL |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12578
diff
changeset
|
647 }, |
| 9162 | 648 }; |
| 649 | |
| 650 static char *yahoo_remove_nonbreaking_spaces(char *str) | |
| 651 { | |
| 652 char *p; | |
| 653 while ((p = strstr(str, " ")) != NULL) { | |
| 654 *p = ' '; /* Turn 's into ordinary blanks */ | |
| 655 p += 1; | |
| 656 memmove(p, p + 5, strlen(p + 5)); | |
| 657 str[strlen(str) - 5] = '\0'; | |
| 658 } | |
| 659 return str; | |
| 660 } | |
| 661 | |
| 9242 | 662 static char *yahoo_tooltip_info_text(YahooGetInfoData *info_data) { |
| 663 GString *s = g_string_sized_new(80); /* wild guess */ | |
| 664 GaimBuddy *b; | |
| 9281 | 665 YahooFriend *f; |
| 9242 | 666 |
| 667 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), | |
| 668 info_data->name); | |
| 669 | |
| 670 if (b) { | |
| 671 char *statustext = yahoo_tooltip_text(b); | |
| 672 if(b->alias && b->alias[0]) { | |
| 673 char *aliastext = g_markup_escape_text(b->alias, -1); | |
| 674 g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext); | |
| 675 g_free(aliastext); | |
| 676 } | |
| 9984 | 677 #if 0 |
| 9242 | 678 if (b->idle > 0) { |
| 679 char *idletime = gaim_str_seconds_to_string(time(NULL) - b->idle); | |
| 680 g_string_append_printf(s, _("<b>%s:</b> %s<br>"), _("Idle"), | |
| 681 idletime); | |
| 682 g_free(idletime); | |
| 683 } | |
| 9984 | 684 #endif |
| 9242 | 685 if (statustext) { |
|
12267
df93ed932b3a
[gaim-migrate @ 14569]
Richard Laager <rlaager@wiktel.com>
parents:
11920
diff
changeset
|
686 char *tmp; |
|
df93ed932b3a
[gaim-migrate @ 14569]
Richard Laager <rlaager@wiktel.com>
parents:
11920
diff
changeset
|
687 g_strstrip(statustext); |
|
df93ed932b3a
[gaim-migrate @ 14569]
Richard Laager <rlaager@wiktel.com>
parents:
11920
diff
changeset
|
688 tmp = gaim_strreplace(statustext, "\n", "<br>"); |
| 9242 | 689 g_free(statustext); |
|
12267
df93ed932b3a
[gaim-migrate @ 14569]
Richard Laager <rlaager@wiktel.com>
parents:
11920
diff
changeset
|
690 g_string_append_printf(s, "%s<br>", tmp); |
|
df93ed932b3a
[gaim-migrate @ 14569]
Richard Laager <rlaager@wiktel.com>
parents:
11920
diff
changeset
|
691 g_free(tmp); |
| 9242 | 692 } |
| 9281 | 693 if ((f = yahoo_friend_find(info_data->gc, b->name))) { |
| 694 const char *ip; | |
| 695 if ((ip = yahoo_friend_get_ip(f))) | |
| 696 g_string_append_printf(s, _("<b>IP Address:</b> %s<br>"), ip); | |
| 697 } | |
| 9242 | 698 } |
| 699 return g_string_free(s, FALSE); | |
| 700 } | |
| 701 | |
| 702 #if PHOTO_SUPPORT | |
| 703 | |
| 704 static char *yahoo_get_photo_url(const char *url_text, const char *name) { | |
| 705 GString *s = g_string_sized_new(strlen(name) + 8); | |
| 706 char *p; | |
| 707 char *it = NULL; | |
| 708 | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
709 /*g_string_printf(s, " alt=\"%s\">", name);*/ |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
710 /* Y! newformat */ |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
711 g_string_printf(s, " alt=%s>", name); |
| 9242 | 712 p = strstr(url_text, s->str); |
| 713 | |
| 714 if (p) { | |
| 715 /* Search backwards for "http://". This is stupid, but it works. */ | |
| 716 for (; !it && p > url_text; p -= 1) { | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
717 /*if (strncmp(p, "\"http://", 8) == 0) {*/ |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
718 /* Y! newformat*/ |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
719 if (strncmp(p, "=http://", 8) == 0) { |
| 9242 | 720 char *q; |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
721 p += 1; /* skip only the ' ' */ |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
722 q = strchr(p, ' '); |
| 9242 | 723 if (q) { |
| 724 it = g_strndup(p, q - p); | |
| 725 } | |
| 726 } | |
| 727 } | |
| 728 } | |
| 729 | |
| 730 g_string_free(s, TRUE); | |
| 731 return it; | |
| 732 } | |
| 733 | |
| 734 static void yahoo_got_photo(void *data, const char *url_text, size_t len); | |
| 735 | |
| 736 #endif /* PHOTO_SUPPORT */ | |
| 737 | |
| 9162 | 738 static void yahoo_got_info(void *data, const char *url_text, size_t len) |
| 739 { | |
| 740 YahooGetInfoData *info_data = (YahooGetInfoData *)data; | |
| 9242 | 741 char *p; |
| 9162 | 742 char buf[1024]; |
| 9242 | 743 #if PHOTO_SUPPORT |
| 744 YahooGetInfoStepTwoData *info2_data; | |
| 745 char *photo_url_text = NULL; | |
| 746 #else | |
| 9162 | 747 gboolean found = FALSE; |
| 9242 | 748 char *stripped; |
| 749 int stripped_len; | |
| 750 char *last_updated_utf8_string = NULL; | |
| 751 #endif | |
| 752 const char *last_updated_string = NULL; | |
| 9162 | 753 char *url_buffer; |
| 754 GString *s; | |
| 9242 | 755 char *tooltip_text = NULL; |
| 756 char *profile_url_text = NULL; | |
| 9162 | 757 int lang, strid; |
| 9221 | 758 struct yahoo_data *yd; |
| 9242 | 759 const profile_strings_node_t *strings = NULL; |
| 9510 | 760 const char *title; |
| 761 profile_state_t profile_state = PROFILE_STATE_DEFAULT; | |
| 9221 | 762 |
| 763 if (!GAIM_CONNECTION_IS_VALID(info_data->gc)) { | |
| 764 g_free(info_data->name); | |
| 765 g_free(info_data); | |
| 766 return; | |
| 767 } | |
| 9162 | 768 |
| 769 gaim_debug_info("yahoo", "In yahoo_got_info\n"); | |
| 770 | |
| 9221 | 771 yd = info_data->gc->proto_data; |
| 9510 | 772 title = (yd->jp? _("Yahoo! Japan Profile") : |
| 773 _("Yahoo! Profile")); | |
| 9242 | 774 |
| 775 /* Get the tooltip info string */ | |
| 776 tooltip_text = yahoo_tooltip_info_text(info_data); | |
| 9221 | 777 |
| 9242 | 778 /* We failed to grab the profile URL. This is not expected to actually |
| 779 * happen except under unusual error conditions, as Yahoo is observed | |
| 780 * to send back HTML, with a 200 status code. | |
| 781 */ | |
| 9162 | 782 if (url_text == NULL || strcmp(url_text, "") == 0) { |
| 9242 | 783 g_snprintf(buf, 1024, "<html><body>%s<b>%s</b></body></html>", |
| 784 tooltip_text, _("Error retrieving profile")); | |
| 785 | |
|
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
786 gaim_notify_userinfo(info_data->gc, info_data->name, |
|
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
787 buf, NULL, NULL); |
| 9162 | 788 |
| 9242 | 789 g_free(profile_url_text); |
| 790 g_free(tooltip_text); | |
| 9162 | 791 g_free(info_data->name); |
| 792 g_free(info_data); | |
| 793 return; | |
| 794 } | |
| 795 | |
| 9242 | 796 /* Construct the correct profile URL */ |
| 797 s = g_string_sized_new(80); /* wild guess */ | |
| 798 g_string_printf(s, "%s%s", (yd->jp? YAHOOJP_PROFILE_URL: YAHOO_PROFILE_URL), | |
| 799 info_data->name); | |
| 800 profile_url_text = g_string_free(s, FALSE); | |
| 801 s = NULL; | |
| 802 | |
| 803 /* We don't yet support the multiple link level of the warning page for | |
| 9162 | 804 * 'adult' profiles, not to mention the fact that yahoo wants you to be |
| 9242 | 805 * logged in (on the website) to be able to view an 'adult' profile. For |
| 9162 | 806 * now, just tell them that we can't help them, and provide a link to the |
| 807 * profile if they want to do the web browser thing. | |
| 808 */ | |
| 809 p = strstr(url_text, "Adult Profiles Warning Message"); | |
| 9242 | 810 if (!p) { |
| 811 p = strstr(url_text, "Adult Content Warning"); /* TITLE element */ | |
| 812 } | |
| 9162 | 813 if (p) { |
| 9242 | 814 g_snprintf(buf, 1024, "<html><body>%s<b>%s</b><br><br>\n" |
| 815 "%s<br><a href=\"%s\">%s</a></body></html>", | |
| 816 tooltip_text, | |
| 817 _("Sorry, profiles marked as containing adult content " | |
| 818 "are not supported at this time."), | |
| 819 _("If you wish to view this profile, " | |
| 820 "you will need to visit this link in your web browser"), | |
| 821 profile_url_text, profile_url_text); | |
| 9162 | 822 |
|
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
823 gaim_notify_userinfo(info_data->gc, info_data->name, |
|
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
824 buf, NULL, NULL); |
| 9162 | 825 |
| 9242 | 826 g_free(profile_url_text); |
| 827 g_free(tooltip_text); | |
| 9162 | 828 g_free(info_data->name); |
| 829 g_free(info_data); | |
| 830 return; | |
| 831 } | |
| 832 | |
| 833 /* Check whether the profile is written in a supported language */ | |
| 834 for (lang = 0;; lang += 1) { | |
| 835 last_updated_string = profile_langs[lang].last_updated_string; | |
| 836 if (!last_updated_string) break; | |
| 837 p = strstr(url_text, last_updated_string); | |
| 838 if (p && profile_langs[lang].det && !strstr(url_text, profile_langs[lang].det)) { | |
| 839 p = NULL; | |
| 840 } | |
| 841 if (p) break; | |
| 842 } | |
| 843 if (p) { | |
| 844 for (strid = 0; profile_strings[strid].lang != XX; strid += 1) { | |
| 9221 | 845 if (profile_strings[strid].lang == profile_langs[lang].lang) break; |
| 9162 | 846 } |
| 9242 | 847 strings = profile_strings + strid; |
| 9162 | 848 gaim_debug_info("yahoo", "detected profile lang = %s (%d)\n", profile_strings[strid].lang_string, lang); |
| 849 } | |
| 850 | |
| 9220 | 851 /* Every user may choose his/her own profile language, and this language |
| 852 * has nothing to do with the preferences of the user which looks at the | |
| 853 * profile. We try to support all languages, but nothing is guaranteed. | |
| 9242 | 854 * If we cannot determine the language, it means either (1) the profile |
| 855 * is written in an unsupported language, (2) our language support is | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
856 * out of date, or (3) the user is not found, or (4) Y! have changed their |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
857 * webpage layout |
| 9162 | 858 */ |
| 9242 | 859 if (!p || strings->lang == XX) { |
| 860 if (!strstr(url_text, "Yahoo! Member Directory - User not found") | |
| 861 && !strstr(url_text, "was not found on this server.") | |
| 862 && !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")) { | |
| 9510 | 863 profile_state = PROFILE_STATE_UNKNOWN_LANGUAGE; |
| 9162 | 864 } else { |
| 9510 | 865 profile_state = PROFILE_STATE_NOT_FOUND; |
| 9162 | 866 } |
| 867 } | |
| 868 | |
| 9242 | 869 #if PHOTO_SUPPORT |
| 870 photo_url_text = yahoo_get_photo_url(url_text, info_data->name); | |
| 871 #endif | |
| 872 | |
| 9162 | 873 url_buffer = g_strdup(url_text); |
| 874 | |
| 875 /* | |
| 876 * gaim_markup_strip_html() doesn't strip out character entities like | |
| 877 * and · | |
| 878 */ | |
| 879 yahoo_remove_nonbreaking_spaces(url_buffer); | |
| 880 #if 1 | |
| 881 while ((p = strstr(url_buffer, "·")) != NULL) { | |
| 882 memmove(p, p + 6, strlen(p + 6)); | |
| 883 url_buffer[strlen(url_buffer) - 6] = '\0'; | |
| 884 } | |
| 885 #endif | |
| 886 | |
| 887 /* nuke the nasty \r's */ | |
| 11920 | 888 gaim_str_strip_char(url_buffer, '\r'); |
| 9242 | 889 |
| 890 #if PHOTO_SUPPORT | |
| 891 /* Marshall the existing state */ | |
| 892 info2_data = g_malloc(sizeof(YahooGetInfoStepTwoData)); | |
| 893 info2_data->info_data = info_data; | |
| 894 info2_data->url_buffer = url_buffer; | |
| 895 info2_data->s = s; | |
| 896 info2_data->photo_url_text = photo_url_text; | |
| 897 info2_data->profile_url_text = profile_url_text; | |
| 898 info2_data->tooltip_text = tooltip_text; | |
| 899 info2_data->strings = strings; | |
| 900 info2_data->last_updated_string = last_updated_string; | |
| 9510 | 901 info2_data->title = title; |
| 902 info2_data->profile_state = profile_state; | |
| 9242 | 903 |
| 904 /* Try to put the photo in there too, if there's one */ | |
| 905 if (photo_url_text) { | |
| 906 /* User-uploaded photos use a different server that requires the Host | |
| 907 * header, but Yahoo Japan will use the "chunked" content encoding if | |
| 908 * we specify HTTP 1.1. So we have to specify 1.0 & fix gaim_url_fetch | |
| 909 */ | |
| 910 gaim_url_fetch(photo_url_text, FALSE, NULL, FALSE, yahoo_got_photo, | |
| 911 info2_data); | |
| 912 } else { | |
| 913 /* Emulate a callback */ | |
| 914 yahoo_got_photo(info2_data, NULL, 0); | |
| 9162 | 915 } |
| 9242 | 916 } |
| 917 | |
| 918 static void yahoo_got_photo(void *data, const char *url_text, size_t len) | |
| 919 { | |
| 920 YahooGetInfoStepTwoData *info2_data = (YahooGetInfoStepTwoData *)data; | |
| 921 gboolean found = FALSE; | |
| 922 int id = -1; | |
| 923 | |
| 924 /* Temporary variables */ | |
| 925 char *p = NULL; | |
| 926 char *stripped; | |
| 927 int stripped_len; | |
| 928 char *last_updated_utf8_string = NULL; | |
| 929 | |
| 930 /* Unmarshall the saved state */ | |
| 931 YahooGetInfoData *info_data = info2_data->info_data; | |
| 932 char *url_buffer = info2_data->url_buffer; | |
| 933 GString *s = info2_data->s; | |
| 934 char *photo_url_text = info2_data->photo_url_text; | |
| 935 char *profile_url_text = info2_data->profile_url_text; | |
| 936 char *tooltip_text = info2_data->tooltip_text; | |
| 937 const profile_strings_node_t *strings = info2_data->strings; | |
| 938 const char *last_updated_string = info2_data->last_updated_string; | |
| 9510 | 939 profile_state_t profile_state = info2_data->profile_state; |
| 9242 | 940 |
| 941 /* We continue here from yahoo_got_info, as if nothing has happened */ | |
| 942 #endif /* PHOTO_SUPPORT */ | |
| 9162 | 943 |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
944 /* Jun 29 05 Bleeter: Y! changed their profile pages. Terminators now seem to be */ |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
945 /* </dd> and not \n. The prpl's need to be audited before it can be moved */ |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
946 /* in to gaim_markup_strip_html*/ |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
947 char *fudged_buffer; |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
948 fudged_buffer = gaim_strcasereplace(url_buffer, "</dd>", "</dd><br>"); |
| 9162 | 949 /* nuke the html, it's easier than trying to parse the horrid stuff */ |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
950 stripped = gaim_markup_strip_html(fudged_buffer); |
| 9162 | 951 stripped_len = strlen(stripped); |
| 952 | |
| 953 gaim_debug_misc("yahoo", "stripped = %p\n", stripped); | |
| 954 gaim_debug_misc("yahoo", "url_buffer = %p\n", url_buffer); | |
| 955 | |
| 956 /* convert to utf8 */ | |
| 9510 | 957 if (strings && strings->charset != XX) { |
| 958 p = g_convert(stripped, -1, "utf-8", strings->charset, | |
| 959 NULL, NULL, NULL); | |
| 9162 | 960 if (!p) { |
| 9510 | 961 p = g_locale_to_utf8(stripped, -1, NULL, NULL, NULL); |
| 962 if (!p) { | |
| 963 p = g_convert(stripped, -1, "utf-8", "windows-1252", | |
| 964 NULL, NULL, NULL); | |
| 965 } | |
| 966 } | |
| 967 if (p) { | |
| 968 g_free(stripped); | |
| 969 stripped = gaim_utf8_ncr_decode(p); | |
| 970 stripped_len = strlen(stripped); | |
| 971 g_free(p); | |
| 9162 | 972 } |
| 973 } | |
| 9510 | 974 p = NULL; |
| 9162 | 975 |
| 976 /* "Last updated" should also be converted to utf8 and with killed */ | |
| 9510 | 977 if (strings && strings->charset != XX) { |
| 978 last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8", | |
| 979 strings->charset, NULL, NULL, NULL); | |
| 980 yahoo_remove_nonbreaking_spaces(last_updated_utf8_string); | |
| 9162 | 981 |
| 9510 | 982 gaim_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); |
| 983 } | |
| 9162 | 984 |
| 985 /* gonna re-use the memory we've already got for url_buffer */ | |
| 986 /* no we're not */ | |
| 987 s = g_string_sized_new(strlen(url_buffer)); | |
| 9510 | 988 |
| 989 if (profile_state == PROFILE_STATE_DEFAULT) { | |
| 9242 | 990 #if 0 |
| 9162 | 991 /* extract their Yahoo! ID and put it in. Don't bother marking has_info as |
| 992 * true, since the Yahoo! ID will always be there */ | |
| 9242 | 993 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
994 strings->yahoo_id_string, 10, "\n", 0, |
| 9162 | 995 NULL, _("Yahoo! ID"), 0, NULL)) |
| 9242 | 996 ; |
| 997 #endif | |
| 998 | |
| 999 #if PHOTO_SUPPORT | |
| 1000 /* Try to put the photo in there too, if there's one and is readable */ | |
| 1001 if (data && url_text && len != 0) { | |
| 1002 if (strstr(url_text, "400 Bad Request") | |
| 1003 || strstr(url_text, "403 Forbidden") | |
| 1004 || strstr(url_text, "404 Not Found")) { | |
| 1005 | |
| 1006 gaim_debug_info("yahoo", "Error getting %s: %s\n", | |
| 1007 photo_url_text, url_text); | |
| 1008 } else { | |
| 1009 gaim_debug_info("yahoo", "%s is %d bytes\n", photo_url_text, len); | |
| 1010 id = gaim_imgstore_add(url_text, len, NULL); | |
| 1011 g_string_append_printf(s, "<img id=\"%d\"><br>", id); | |
| 9220 | 1012 } |
| 1013 } | |
| 9242 | 1014 #endif /* PHOTO_SUPPORT */ |
| 1015 | |
| 9162 | 1016 /* extract their Email address and put it in */ |
| 9242 | 1017 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1018 strings->my_email_string, 1, " ", 0, |
| 9242 | 1019 strings->private_string, _("Email"), 0, NULL); |
| 9162 | 1020 |
| 1021 /* extract the Nickname if it exists */ | |
| 9242 | 1022 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1023 "Nickname:", 1, "\n", '\n', | |
| 9162 | 1024 NULL, _("Nickname"), 0, NULL); |
| 1025 | |
| 1026 /* extract their RealName and put it in */ | |
| 9242 | 1027 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1028 strings->realname_string, 1, "\n", '\n', | |
| 9162 | 1029 NULL, _("Realname"), 0, NULL); |
| 1030 | |
| 1031 /* extract their Location and put it in */ | |
| 9242 | 1032 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1033 strings->location_string, 2, "\n", '\n', | |
| 9162 | 1034 NULL, _("Location"), 0, NULL); |
| 1035 | |
| 1036 /* extract their Age and put it in */ | |
| 9242 | 1037 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1038 strings->age_string, 3, "\n", '\n', | |
| 9162 | 1039 NULL, _("Age"), 0, NULL); |
| 1040 | |
| 1041 /* extract their MaritalStatus and put it in */ | |
| 9242 | 1042 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1043 strings->maritalstatus_string, 3, "\n", '\n', | |
| 1044 strings->no_answer_string, _("Marital Status"), 0, NULL); | |
| 9162 | 1045 |
| 1046 /* extract their Gender and put it in */ | |
| 9242 | 1047 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1048 strings->gender_string, 3, "\n", '\n', | |
| 1049 strings->no_answer_string, _("Gender"), 0, NULL); | |
| 9162 | 1050 |
| 1051 /* extract their Occupation and put it in */ | |
| 9242 | 1052 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1053 strings->occupation_string, 2, "\n", '\n', | |
| 9162 | 1054 NULL, _("Occupation"), 0, NULL); |
| 1055 | |
| 9242 | 1056 /* Hobbies, Latest News, and Favorite Quote are a bit different, since |
| 1057 * the values can contain embedded newlines... but any or all of them | |
| 1058 * can also not appear. The way we delimit them is to successively | |
| 1059 * look for the next one that _could_ appear, and if all else fails, | |
| 1060 * we end the section by looking for the 'Links' heading, which is the | |
| 1061 * next thing to follow this bunch. (For Yahoo Japan, we check for | |
| 1062 * the "Description" ("Self PR") heading instead of "Links".) | |
| 9162 | 1063 */ |
| 1064 | |
| 9242 | 1065 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1066 strings->hobbies_string, 1, strings->latest_news_string, | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1067 '\n', "\n", _("Hobbies"), 0, NULL)) |
| 9162 | 1068 { |
| 9242 | 1069 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1070 strings->hobbies_string, 1, strings->favorite_quote_string, | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1071 '\n', "\n", _("Hobbies"), 0, NULL)) |
| 9162 | 1072 { |
| 9242 | 1073 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1074 strings->hobbies_string, 1, strings->links_string, | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1075 '\n', "\n", _("Hobbies"), 0, NULL); |
| 9162 | 1076 } |
| 1077 else | |
| 1078 found = TRUE; | |
| 1079 } | |
| 1080 else | |
| 1081 found = TRUE; | |
| 1082 | |
| 9242 | 1083 if (!gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1084 strings->latest_news_string, 1, strings->favorite_quote_string, | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1085 '\n', "\n", _("Latest News"), 0, NULL)) |
| 9162 | 1086 { |
| 9242 | 1087 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1088 strings->latest_news_string, 1, strings->links_string, | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1089 '\n', "\n", _("Latest News"), 0, NULL); |
| 9162 | 1090 } |
| 1091 else | |
| 1092 found = TRUE; | |
| 1093 | |
| 9242 | 1094 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1095 strings->favorite_quote_string, 1, strings->links_string, | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1096 '\n', "\n", _("Favorite Quote"), 0, NULL); |
| 9162 | 1097 |
| 1098 /* Home Page will either be "No home page specified", | |
| 1099 * or "Home Page: " and a link. | |
| 9242 | 1100 * For Yahoo! Japan, if there is no home page specified, |
| 1101 * neither "No home page specified" nor "Home Page:" is shown. | |
| 9162 | 1102 */ |
| 9242 | 1103 if (strings->home_page_string) { |
| 1104 p = !strings->no_home_page_specified_string? NULL: | |
| 1105 strstr(stripped, strings->no_home_page_specified_string); | |
| 9162 | 1106 if(!p) |
| 1107 { | |
| 9242 | 1108 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1109 strings->home_page_string, 1, "\n", 0, NULL, | |
| 9162 | 1110 _("Home Page"), 1, NULL); |
| 1111 } | |
| 1112 } | |
| 1113 | |
| 9242 | 1114 /* Cool Link {1,2,3} is also different. If "No cool link specified" |
| 1115 * exists, then we have none. If we have one however, we'll need to | |
| 1116 * check and see if we have a second one. If we have a second one, | |
| 1117 * we have to check to see if we have a third one. | |
| 9162 | 1118 */ |
| 9242 | 1119 p = !strings->no_cool_link_specified_string? NULL: |
| 1120 strstr(stripped,strings->no_cool_link_specified_string); | |
| 9162 | 1121 if (!p) |
| 1122 { | |
| 9242 | 1123 if (gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1124 strings->cool_link_1_string, 1, "\n", 0, NULL, | |
| 9162 | 1125 _("Cool Link 1"), 1, NULL)) |
| 1126 { | |
| 1127 found = TRUE; | |
| 9242 | 1128 if (gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1129 strings->cool_link_2_string, 1, "\n", 0, NULL, | |
| 9162 | 1130 _("Cool Link 2"), 1, NULL)) |
| 9242 | 1131 { |
| 1132 gaim_markup_extract_info_field(stripped, stripped_len, s, | |
| 1133 strings->cool_link_3_string, 1, "\n", 0, NULL, | |
| 9162 | 1134 _("Cool Link 3"), 1, NULL); |
| 9242 | 1135 } |
| 9162 | 1136 } |
| 1137 } | |
| 1138 | |
| 1139 /* see if Member Since is there, and if so, extract it. */ | |
| 9242 | 1140 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
| 1141 "Member Since:", 1, last_updated_utf8_string, | |
| 9162 | 1142 '\n', NULL, _("Member Since"), 0, NULL); |
| 1143 | |
| 1144 /* extract the Last Updated date and put it in */ | |
| 9242 | 1145 found |= gaim_markup_extract_info_field(stripped, stripped_len, s, |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1146 last_updated_utf8_string, 1, " ", '\n', NULL, |
|
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1147 _("Last Update"), 0, NULL); |
| 9510 | 1148 } /* if (profile_state == PROFILE_STATE_DEFAULT) */ |
| 1149 | |
| 1150 if(!found) | |
| 1151 { | |
| 1152 g_string_append_printf(s, "<br><b>"); | |
| 1153 g_string_append_printf(s, _("User information for %s unavailable"), | |
| 1154 info_data->name); | |
| 1155 g_string_append_printf(s, "</b><br>"); | |
| 1156 | |
| 1157 if (profile_state == PROFILE_STATE_UNKNOWN_LANGUAGE) { | |
| 1158 g_string_append_printf(s, "%s<br><br>", | |
| 1159 _("Sorry, this profile seems to be in a language " | |
| 12367 | 1160 "or format that is not supported at this time.")); |
| 9510 | 1161 |
| 1162 } else if (profile_state == PROFILE_STATE_NOT_FOUND) { | |
| 1163 GaimBuddy *b = gaim_find_buddy | |
| 1164 (gaim_connection_get_account(info_data->gc), | |
| 1165 info_data->name); | |
| 1166 YahooFriend *f = NULL; | |
| 1167 if (b) { | |
| 1168 /* Someone on the buddy list can be "not on server list", | |
| 1169 * in which case the user may or may not actually exist. | |
| 1170 * Hence this extra step. | |
| 1171 */ | |
| 1172 f = yahoo_friend_find(b->account->gc, b->name); | |
| 1173 } | |
| 1174 g_string_append_printf(s, "%s<br><br>", | |
| 1175 f? _("Could not retrieve the user's profile. " | |
| 1176 "This most likely is a temporary server-side problem. " | |
| 1177 "Please try again later."): | |
| 1178 _("Could not retrieve the user's profile. " | |
| 1179 "This most likely means that the user does not exist; " | |
| 1180 "however, Yahoo! sometimes does fail to find a user's " | |
| 1181 "profile. If you know that the user exists, " | |
| 1182 "please try again later.")); | |
| 1183 | |
| 1184 } else { | |
| 1185 g_string_append_printf(s, "%s<br><br>", | |
| 1186 _("The user's profile is empty.")); | |
| 1187 } | |
| 1188 } | |
| 1189 | |
| 9220 | 1190 /* put a link to the actual profile URL */ |
| 1191 g_string_append_printf(s, _("<b>%s:</b> "), _("Profile URL")); | |
| 9242 | 1192 g_string_append_printf(s, "<br><a href=\"%s\">%s</a><br>", |
| 1193 profile_url_text, profile_url_text); | |
| 9220 | 1194 |
| 9510 | 1195 /* finish off the html at the end */ |
| 9162 | 1196 g_string_append(s, "</body></html>\n"); |
| 1197 g_free(stripped); | |
| 1198 | |
| 9510 | 1199 /* Put the Yahoo! ID, nickname, idle time, and status message in */ |
| 1200 g_string_prepend(s, tooltip_text); | |
| 1201 | |
| 1202 /* finish off the html at the beginning */ | |
| 1203 g_string_prepend(s, "<html><body>\n"); | |
| 1204 | |
| 1205 /* show it to the user */ | |
|
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
1206 gaim_notify_userinfo(info_data->gc, info_data->name, |
|
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
1207 s->str, NULL, NULL); |
| 9162 | 1208 |
| 1209 g_free(last_updated_utf8_string); | |
| 1210 g_free(url_buffer); | |
|
11045
d456fdaf6c73
[gaim-migrate @ 12961]
Richard Laager <rlaager@wiktel.com>
parents:
10604
diff
changeset
|
1211 g_free(fudged_buffer); |
| 9162 | 1212 g_string_free(s, TRUE); |
| 9242 | 1213 g_free(profile_url_text); |
| 1214 g_free(tooltip_text); | |
| 9162 | 1215 g_free(info_data->name); |
| 1216 g_free(info_data); | |
| 9242 | 1217 |
| 1218 #if PHOTO_SUPPORT | |
| 1219 g_free(photo_url_text); | |
| 1220 g_free(info2_data); | |
| 1221 if (id != -1) | |
| 1222 gaim_imgstore_unref(id); | |
| 1223 #endif | |
| 9162 | 1224 } |
| 1225 | |
| 1226 void yahoo_get_info(GaimConnection *gc, const char *name) | |
| 1227 { | |
| 9164 | 1228 struct yahoo_data *yd = gc->proto_data; |
| 9162 | 1229 YahooGetInfoData *data; |
| 1230 char *url; | |
| 1231 | |
| 1232 data = g_new0(YahooGetInfoData, 1); | |
| 1233 data->gc = gc; | |
| 1234 data->name = g_strdup(name); | |
| 1235 | |
| 9221 | 1236 url = g_strdup_printf("%s%s", |
| 1237 (yd->jp? YAHOOJP_PROFILE_URL: YAHOO_PROFILE_URL), name); | |
| 9162 | 1238 |
| 10604 | 1239 gaim_url_fetch(url, TRUE, NULL, FALSE, yahoo_got_info, data); |
| 9162 | 1240 |
| 1241 g_free(url); | |
| 1242 } |
