comparison libpurple/protocols/gg/lib/pubdir50.c @ 31410:93b08d43f684

matekm and kkszysiu collaborated on this patch to update our internal libgadu to version 1.10.1.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Thu, 24 Mar 2011 20:53:13 +0000
parents a8cc50c2279f
children 3a90a59ddea2
comparison
equal deleted inserted replaced
31409:5043fc53f957 31410:93b08d43f684
1 /* $Id: pubdir50.c 854 2009-10-12 21:06:28Z wojtekka $ */
2
3 /* 1 /*
4 * (C) Copyright 2003 Wojtek Kaniewski <wojtekka@irc.pl> 2 * (C) Copyright 2003 Wojtek Kaniewski <wojtekka@irc.pl>
5 * 3 *
6 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License Version 5 * it under the terms of the GNU Lesser General Public License Version
20 18
21 /** 19 /**
22 * \file pubdir50.c 20 * \file pubdir50.c
23 * 21 *
24 * \brief Obsługa katalogu publicznego od wersji Gadu-Gadu 5.x 22 * \brief Obsługa katalogu publicznego od wersji Gadu-Gadu 5.x
23 *
24 * \todo Zoptymalizować konwersję CP1250<->UTF8. Obecnie robiona jest
25 * testowa konwersja, żeby poznać długość tekstu wynikowego.
25 */ 26 */
26 27
27 #include <errno.h> 28 #include <errno.h>
28 #include <stdlib.h> 29 #include <stdlib.h>
29 #include <string.h> 30 #include <string.h>
30 #include <time.h> 31 #include <time.h>
31 32
32 #include "libgadu.h" 33 #include "libgadu.h"
33 #include "libgadu-internal.h" 34 #include "libgadu-internal.h"
35 #include "encoding.h"
34 36
35 /** 37 /**
36 * Tworzy nowe zapytanie katalogu publicznego. 38 * Tworzy nowe zapytanie katalogu publicznego.
37 * 39 *
38 * \param type Rodzaj zapytania 40 * \param type Rodzaj zapytania
222 size += strlen(req->entries[i].field) + 1; 224 size += strlen(req->entries[i].field) + 1;
223 size += strlen(req->entries[i].value) + 1; 225 size += strlen(req->entries[i].value) + 1;
224 } else { 226 } else {
225 char *tmp; 227 char *tmp;
226 228
227 tmp = gg_utf8_to_cp(req->entries[i].field); 229 // XXX \todo zoptymalizować
230 tmp = gg_encoding_convert(req->entries[i].field, sess->encoding, GG_ENCODING_CP1250, -1, -1);
228 231
229 if (tmp == NULL) 232 if (tmp == NULL)
230 return -1; 233 return -1;
231 234
232 size += strlen(tmp) + 1; 235 size += strlen(tmp) + 1;
233 236
234 free(tmp); 237 free(tmp);
235 238
236 tmp = gg_utf8_to_cp(req->entries[i].value); 239 // XXX \todo zoptymalizować
240 tmp = gg_encoding_convert(req->entries[i].value, sess->encoding, GG_ENCODING_CP1250, -1, -1);
237 241
238 if (tmp == NULL) 242 if (tmp == NULL)
239 return -1; 243 return -1;
240 244
241 size += strlen(tmp) + 1; 245 size += strlen(tmp) + 1;
269 strcpy(p, req->entries[i].value); 273 strcpy(p, req->entries[i].value);
270 p += strlen(p) + 1; 274 p += strlen(p) + 1;
271 } else { 275 } else {
272 char *tmp; 276 char *tmp;
273 277
274 tmp = gg_utf8_to_cp(req->entries[i].field); 278 // XXX \todo zoptymalizować
279 tmp = gg_encoding_convert(req->entries[i].field, sess->encoding, GG_ENCODING_CP1250, -1, -1);
275 280
276 if (tmp == NULL) { 281 if (tmp == NULL) {
277 free(buf); 282 free(buf);
278 return -1; 283 return -1;
279 } 284 }
280 285
281 strcpy(p, tmp); 286 strcpy(p, tmp);
282 p += strlen(tmp) + 1; 287 p += strlen(tmp) + 1;
283 free(tmp); 288 free(tmp);
284 289
285 tmp = gg_utf8_to_cp(req->entries[i].value); 290 // XXX \todo zoptymalizować
291 tmp = gg_encoding_convert(req->entries[i].value, sess->encoding, GG_ENCODING_CP1250, -1, -1);
292
286 293
287 if (tmp == NULL) { 294 if (tmp == NULL) {
288 free(buf); 295 free(buf);
289 return -1; 296 return -1;
290 } 297 }
414 if (gg_pubdir50_add_n(res, num, field, value) == -1) 421 if (gg_pubdir50_add_n(res, num, field, value) == -1)
415 goto failure; 422 goto failure;
416 } else { 423 } else {
417 char *tmp; 424 char *tmp;
418 425
419 tmp = gg_cp_to_utf8(value); 426 tmp = gg_encoding_convert(value, GG_ENCODING_CP1250, sess->encoding, -1, -1);
420 427
421 if (tmp == NULL) 428 if (tmp == NULL)
422 goto failure; 429 goto failure;
423 430
424 if (gg_pubdir50_add_n(res, num, field, tmp) == -1) { 431 if (gg_pubdir50_add_n(res, num, field, tmp) == -1) {