Mercurial > pidgin.yaz
changeset 10047:9b82412d3e52
[gaim-migrate @ 11008]
Make MSN FT work on BE machines?
See http://sourceforge.net/tracker/index.php?func=detail&aid=976472&group_id=235&atid=300235
Thanks to Jean-Francois Roy and Evan Schoenberg
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 19 Sep 2004 19:00:16 +0000 |
parents | dcdda2857ca8 |
children | e2890a4585c0 |
files | src/protocols/msn/slp.c src/protocols/msn/slplink.c |
diffstat | 2 files changed, 39 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/msn/slp.c Sun Sep 19 18:41:45 2004 +0000 +++ b/src/protocols/msn/slp.c Sun Sep 19 19:00:16 2004 +0000 @@ -235,6 +235,8 @@ msn_slplink_queue_slpmsg(slplink, slpmsg); } +#define MAX_FILE_NAME_LEN 0x226 + static void got_sessionreq(MsnSlpCall *slpcall, const char *branch, const char *euf_guid, const char *context) @@ -318,6 +320,7 @@ gsize bin_len; guint32 file_size; char *file_name; + gunichar2 *uni_name; account = slpcall->slplink->session->account; @@ -331,6 +334,13 @@ gaim_base64_decode(context, &bin, &bin_len); file_size = GUINT32_FROM_LE(*((gsize *)bin + 2)); + + uni_name = (gunichar2 *)(bin + 20); + while(*uni_name != 0 && ((char *)uni_name - (bin + 20)) < MAX_FILE_NAME_LEN) { + *uni_name = GUINT16_FROM_LE(*uni_name); + uni_name++; + } + file_name = g_utf16_to_utf8((const gunichar2 *)(bin + 20), -1, NULL, NULL, NULL);
--- a/src/protocols/msn/slplink.c Sun Sep 19 18:41:45 2004 +0000 +++ b/src/protocols/msn/slplink.c Sun Sep 19 19:00:16 2004 +0000 @@ -571,23 +571,33 @@ #define MAX_FILE_NAME_LEN 0x226 static char * -gen_context(const char *file_name) +gen_context(const char *file_name, const char *file_path) { struct stat st; gsize size = 0; MsnContextHeader header; - gchar *u8; + gchar *u8 = NULL; gchar *base, *n; - gunichar2 *uni; - glong uni_len; + gunichar2 *uni = NULL; + glong currentChar = 0; + glong uni_len = 0; gsize len; if (stat(file_name, &st) == 0) size = st.st_size; - u8 = gaim_utf8_try_convert(g_basename(file_name)); - uni = g_utf8_to_utf16(u8, -1, NULL, &uni_len, NULL); - g_free(u8); + if(!file_name) { + u8 = gaim_utf8_try_convert(g_basename(file_path)); + file_name = u8; + } + + uni = g_utf8_to_utf16(file_name, -1, NULL, &uni_len, NULL); + + if(u8) { + g_free(u8); + file_name = NULL; + u8 = NULL; + } len = sizeof(MsnContextHeader) + MAX_FILE_NAME_LEN + 4; @@ -596,21 +606,23 @@ header.file_size = GUINT32_TO_LE(size); header.unk2 = GUINT32_TO_LE(0); header.unk3 = GUINT32_TO_LE(0); - - base = n = g_malloc(len + 1); + + base = g_malloc(len + 1); + n = base; memcpy(n, &header, sizeof(MsnContextHeader)); n += sizeof(MsnContextHeader); memset(n, 0x00, MAX_FILE_NAME_LEN); - memcpy(n, uni, uni_len * 2); + for(currentChar = 0; currentChar < uni_len; currentChar++) { + *((gunichar2 *)n + currentChar) = GUINT16_TO_LE(uni[currentChar]); + } n += MAX_FILE_NAME_LEN; memset(n, 0xFF, 4); n += 4; - + g_free(uni); - return gaim_base64_encode(base, len); } @@ -620,11 +632,13 @@ MsnSlpCall *slpcall; char *context; const char *fn; + const char *fp; - fn = gaim_xfer_get_local_filename(xfer); + fn = gaim_xfer_get_filename(xfer); + fp = gaim_xfer_get_local_filename(xfer); g_return_if_fail(slplink != NULL); - g_return_if_fail(fn != NULL); + g_return_if_fail(fp != NULL); slpcall = msn_slp_call_new(slplink); msn_slp_call_init(slpcall, MSN_SLPCALL_DC); @@ -639,7 +653,7 @@ xfer->data = slpcall; - context = gen_context(fn); + context = gen_context(fn, fp); msn_slp_call_invite(slpcall, "5D3E02AB-6190-11D3-BBBB-00C04F795683", 2, context);