Mercurial > pidgin
comparison libpurple/protocols/msn/slp.c @ 27755:6c9c6123b942
Using g_convert instead of g_utf16_to_utf8 means we don't need to go
through the whole buffer converting it first.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 31 Jul 2009 03:53:00 +0000 |
parents | 35b6fd563056 |
children | 6c4e816873f7 |
comparison
equal
deleted
inserted
replaced
27752:46a6465491ac | 27755:6c9c6123b942 |
---|---|
322 PurpleXfer *xfer; | 322 PurpleXfer *xfer; |
323 char *bin; | 323 char *bin; |
324 gsize bin_len; | 324 gsize bin_len; |
325 guint32 file_size; | 325 guint32 file_size; |
326 char *file_name; | 326 char *file_name; |
327 gunichar2 *uni_name; | |
328 | 327 |
329 account = slpcall->slplink->session->account; | 328 account = slpcall->slplink->session->account; |
330 | 329 |
331 slpcall->cb = msn_xfer_completed_cb; | 330 slpcall->cb = msn_xfer_completed_cb; |
332 slpcall->end_cb = msn_xfer_end_cb; | 331 slpcall->end_cb = msn_xfer_end_cb; |
340 if (xfer) | 339 if (xfer) |
341 { | 340 { |
342 bin = (char *)purple_base64_decode(context, &bin_len); | 341 bin = (char *)purple_base64_decode(context, &bin_len); |
343 file_size = GUINT32_FROM_LE(*(gsize *)(bin + 8)); | 342 file_size = GUINT32_FROM_LE(*(gsize *)(bin + 8)); |
344 | 343 |
345 uni_name = (gunichar2 *)(bin + 20); | 344 file_name = g_convert(bin + 20, -1, "UTF-16LE", "UTF-8", |
346 while(*uni_name != 0 && ((char *)uni_name - (bin + 20)) < MAX_FILE_NAME_LEN) { | 345 NULL, NULL, NULL); |
347 *uni_name = GUINT16_FROM_LE(*uni_name); | |
348 uni_name++; | |
349 } | |
350 | |
351 file_name = g_utf16_to_utf8((const gunichar2 *)(bin + 20), -1, | |
352 NULL, NULL, NULL); | |
353 | 346 |
354 g_free(bin); | 347 g_free(bin); |
355 | 348 |
356 purple_xfer_set_filename(xfer, file_name); | 349 purple_xfer_set_filename(xfer, file_name); |
357 g_free(file_name); | 350 g_free(file_name); |