cpw.malu.ft_thumbnails: 37f9288b: Add support for recieving and sending MS...
qulogic at pidgin.im
qulogic at pidgin.im
Sun Feb 28 00:52:39 EST 2010
-----------------------------------------------------------------
Revision: 37f9288bbb463836a3076a52b5fc9ac91c3f1aa7
Ancestor: 7b8a3bc163ccdd3be5be9a233d13cc69c2d1cfc0
Author: qulogic at pidgin.im
Date: 2010-02-28T04:14:15
Branch: im.pidgin.cpw.malu.ft_thumbnails
URL: http://d.pidgin.im/viewmtn/revision/info/37f9288bbb463836a3076a52b5fc9ac91c3f1aa7
Modified files:
libpurple/protocols/msn/slp.c
libpurple/protocols/msn/slplink.c
ChangeLog:
Add support for recieving and sending MSN file transfer previews.
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slp.c 8347895b2576ff2044f0fe63e29f0e464084bf83
+++ libpurple/protocols/msn/slp.c 8ff6f316d306aba37246e203e7fd3e1dc83a7093
@@ -422,6 +422,11 @@ got_sessionreq(MsnSlpCall *slpcall, cons
xfer->data = slpcall;
+ if (header->type == 0 && bin_len >= sizeof(MsnFileContext)) {
+ purple_xfer_set_thumbnail(xfer, &header->preview,
+ bin_len - sizeof(MsnFileContext));
+ }
+
purple_xfer_request(xfer);
}
g_free(header);
============================================================
--- libpurple/protocols/msn/slplink.c 42477d0a16d37a8c1e662dc4218afad270649fad
+++ libpurple/protocols/msn/slplink.c b547f9f7497a932b4ba53d2fa3e226747f1ee2ff
@@ -662,15 +662,19 @@ gen_context(PurpleXfer *xfer, const char
gen_context(PurpleXfer *xfer, const char *file_name, const char *file_path)
{
gsize size = 0;
- MsnFileContext header;
+ MsnFileContext *header;
gchar *u8 = NULL;
gchar *ret;
gunichar2 *uni = NULL;
glong currentChar = 0;
glong len = 0;
+ const char *preview;
+ gsize preview_len;
size = purple_xfer_get_size(xfer);
+ purple_xfer_prepare_thumbnail(xfer);
+
if (!file_name) {
gchar *basename = g_path_get_basename(file_path);
u8 = purple_utf8_try_convert(basename);
@@ -686,23 +690,37 @@ gen_context(PurpleXfer *xfer, const char
u8 = NULL;
}
- header.length = GUINT32_TO_LE(sizeof(MsnFileContext) - 1);
- header.version = GUINT32_TO_LE(2); /* V.3 contains additional unnecessary data */
- header.file_size = GUINT64_TO_LE(size);
- header.type = GUINT32_TO_LE(1); /* No file preview */
+ preview = purple_xfer_get_thumbnail_data(xfer);
+ if (preview)
+ preview_len = purple_xfer_get_thumbnail_size(xfer);
+ else
+ preview_len = 0;
+ header = g_malloc(sizeof(MsnFileContext) + preview_len);
+ header->length = GUINT32_TO_LE(sizeof(MsnFileContext) - 1);
+ header->version = GUINT32_TO_LE(2); /* V.3 contains additional unnecessary data */
+ header->file_size = GUINT64_TO_LE(size);
+ if (preview)
+ header->type = GUINT32_TO_LE(0);
+ else
+ header->type = GUINT32_TO_LE(1);
+
len = MIN(len, MAX_FILE_NAME_LEN);
for (currentChar = 0; currentChar < len; currentChar++) {
- header.file_name[currentChar] = GUINT16_TO_LE(uni[currentChar]);
+ header->file_name[currentChar] = GUINT16_TO_LE(uni[currentChar]);
}
- memset(&header.file_name[currentChar], 0x00, (MAX_FILE_NAME_LEN - currentChar) * 2);
+ memset(&header->file_name[currentChar], 0x00, (MAX_FILE_NAME_LEN - currentChar) * 2);
- memset(&header.unknown1, 0, sizeof(header.unknown1));
- header.unknown2 = GUINT32_TO_LE(0xffffffff);
- header.preview[0] = '\0';
+ memset(&header->unknown1, 0, sizeof(header->unknown1));
+ header->unknown2 = GUINT32_TO_LE(0xffffffff);
+ if (preview) {
+ memcpy(&header->preview, preview, preview_len);
+ }
+ header->preview[preview_len] = '\0';
g_free(uni);
- ret = purple_base64_encode((const guchar *)&header, sizeof(MsnFileContext));
+ ret = purple_base64_encode((const guchar *)header, sizeof(MsnFileContext) + preview_len);
+ g_free(header);
return ret;
}
More information about the Commits
mailing list