pidgin: 91c6ff12: Change MsnFileContext variables from "he...
qulogic at pidgin.im
qulogic at pidgin.im
Sun Jan 9 03:35:52 EST 2011
----------------------------------------------------------------------
Revision: 91c6ff1237b806ff4aef197edcf91a8a8ca39077
Parent: 73ccd00435b91c0dac1b62b404a50b7d650e88d6
Author: qulogic at pidgin.im
Date: 01/06/11 00:51:03
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/91c6ff1237b806ff4aef197edcf91a8a8ca39077
Changelog:
Change MsnFileContext variables from "header" to "context". This it
totally superfluous, but I don't like seeing that code if I'm looking
for header stuff.
Changes against parent 73ccd00435b91c0dac1b62b404a50b7d650e88d6
patched libpurple/protocols/msn/slp.c
patched libpurple/protocols/msn/slpcall.c
patched libpurple/protocols/msn/xfer.c
patched libpurple/protocols/msn/xfer.h
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slp.c 13ad54ab66239adc1cc5e958f3ee4d263b212fdc
+++ libpurple/protocols/msn/slp.c 70aadf51137bb3c88d4817bfb781a48198e1888a
@@ -293,7 +293,7 @@ gen_context(PurpleXfer *xfer, const char
gen_context(PurpleXfer *xfer, const char *file_name, const char *file_path)
{
gsize size = 0;
- MsnFileContext header;
+ MsnFileContext context;
gchar *u8 = NULL;
gchar *ret;
gunichar2 *uni = NULL;
@@ -323,28 +323,28 @@ gen_context(PurpleXfer *xfer, const char
preview = purple_xfer_get_thumbnail(xfer, &preview_len);
- header.length = MSN_FILE_CONTEXT_SIZE;
- header.version = 2; /* V.3 contains additional unnecessary data */
- header.file_size = size;
+ context.length = MSN_FILE_CONTEXT_SIZE;
+ context.version = 2; /* V.3 contains additional unnecessary data */
+ context.file_size = size;
if (preview)
- header.type = 0;
+ context.type = 0;
else
- header.type = 1;
+ context.type = 1;
len = MIN(len, MAX_FILE_NAME_LEN);
for (currentChar = 0; currentChar < len; currentChar++) {
- header.file_name[currentChar] = GUINT16_TO_LE(uni[currentChar]);
+ context.file_name[currentChar] = GUINT16_TO_LE(uni[currentChar]);
}
- memset(&header.file_name[currentChar], 0x00, (MAX_FILE_NAME_LEN - currentChar) * 2);
+ memset(&context.file_name[currentChar], 0x00, (MAX_FILE_NAME_LEN - currentChar) * 2);
- memset(&header.unknown1, 0, sizeof(header.unknown1));
- header.unknown2 = 0xffffffff;
+ memset(&context.unknown1, 0, sizeof(context.unknown1));
+ context.unknown2 = 0xffffffff;
/* Mind the cast, as in, don't free it after! */
- header.preview = (char *)preview;
- header.preview_len = preview_len;
+ context.preview = (char *)preview;
+ context.preview_len = preview_len;
- u8 = msn_file_context_to_wire(&header);
+ u8 = msn_file_context_to_wire(&context);
ret = purple_base64_encode((const guchar *)u8, MSN_FILE_CONTEXT_SIZE + preview_len);
g_free(uni);
============================================================
--- libpurple/protocols/msn/slpcall.c 15fc6612d80f0f9f664dc8525e7c885036fe05a9
+++ libpurple/protocols/msn/slpcall.c 5fbf6e85c7623971b75cd6b90b377c8eb2ae9630
@@ -511,7 +511,7 @@ got_sessionreq(MsnSlpCall *slpcall, cons
/* File Transfer */
PurpleAccount *account;
PurpleXfer *xfer;
- MsnFileContext *header;
+ MsnFileContext *file_context;
char *buf;
gsize bin_len;
guint32 file_size;
@@ -528,12 +528,12 @@ got_sessionreq(MsnSlpCall *slpcall, cons
slpcall->slplink->remote_user);
buf = (char *)purple_base64_decode(context, &bin_len);
- header = msn_file_context_from_wire(buf, bin_len);
+ file_context = msn_file_context_from_wire(buf, bin_len);
- if (header != NULL) {
- file_size = header->file_size;
+ if (file_context != NULL) {
+ file_size = file_context->file_size;
- file_name = g_convert((const gchar *)&header->file_name,
+ file_name = g_convert((const gchar *)&file_context->file_name,
MAX_FILE_NAME_LEN * 2,
"UTF-8", "UTF-16LE",
NULL, NULL, NULL);
@@ -554,16 +554,16 @@ got_sessionreq(MsnSlpCall *slpcall, cons
xfer->data = slpcall;
- if (header->preview) {
- purple_xfer_set_thumbnail(xfer, header->preview,
- header->preview_len,
+ if (file_context->preview) {
+ purple_xfer_set_thumbnail(xfer, file_context->preview,
+ file_context->preview_len,
"image/png");
- g_free(header->preview);
+ g_free(file_context->preview);
}
purple_xfer_request(xfer);
}
- g_free(header);
+ g_free(file_context);
g_free(buf);
accepted = TRUE;
============================================================
--- libpurple/protocols/msn/xfer.c d9d638d190006a728e951e8d179a054d5d7b2d0d
+++ libpurple/protocols/msn/xfer.c d8541455da494f7df015ae5d64a0f398af567d89
@@ -162,25 +162,25 @@ gchar *
}
gchar *
-msn_file_context_to_wire(MsnFileContext *header)
+msn_file_context_to_wire(MsnFileContext *context)
{
gchar *ret, *tmp;
- tmp = ret = g_new(gchar, MSN_FILE_CONTEXT_SIZE + header->preview_len + 1);
+ tmp = ret = g_new(gchar, MSN_FILE_CONTEXT_SIZE + context->preview_len + 1);
- msn_push32le(tmp, header->length);
- msn_push32le(tmp, header->version);
- msn_push64le(tmp, header->file_size);
- msn_push32le(tmp, header->type);
- memcpy(tmp, header->file_name, MAX_FILE_NAME_LEN * 2);
+ msn_push32le(tmp, context->length);
+ msn_push32le(tmp, context->version);
+ msn_push64le(tmp, context->file_size);
+ msn_push32le(tmp, context->type);
+ memcpy(tmp, context->file_name, MAX_FILE_NAME_LEN * 2);
tmp += MAX_FILE_NAME_LEN * 2;
- memcpy(tmp, header->unknown1, sizeof(header->unknown1));
- tmp += sizeof(header->unknown1);
- msn_push32le(tmp, header->unknown2);
- if (header->preview) {
- memcpy(tmp, header->preview, header->preview_len);
+ memcpy(tmp, context->unknown1, sizeof(context->unknown1));
+ tmp += sizeof(context->unknown1);
+ msn_push32le(tmp, context->unknown2);
+ if (context->preview) {
+ memcpy(tmp, context->preview, context->preview_len);
}
- tmp[header->preview_len] = '\0';
+ tmp[context->preview_len] = '\0';
return ret;
}
@@ -188,48 +188,48 @@ msn_file_context_from_wire(const char *b
MsnFileContext *
msn_file_context_from_wire(const char *buf, gsize len)
{
- MsnFileContext *header;
+ MsnFileContext *context;
if (!buf || len < MSN_FILE_CONTEXT_SIZE)
return NULL;
- header = g_new(MsnFileContext, 1);
+ context = g_new(MsnFileContext, 1);
- header->length = msn_pop32le(buf);
- header->version = msn_pop32le(buf);
- if (header->version == 2) {
+ context->length = msn_pop32le(buf);
+ context->version = msn_pop32le(buf);
+ if (context->version == 2) {
/* The length field is broken for this version. No check. */
- header->length = MSN_FILE_CONTEXT_SIZE;
- } else if (header->version == 3) {
- if (header->length != MSN_FILE_CONTEXT_SIZE + 63) {
- g_free(header);
+ context->length = MSN_FILE_CONTEXT_SIZE;
+ } else if (context->version == 3) {
+ if (context->length != MSN_FILE_CONTEXT_SIZE + 63) {
+ g_free(context);
return NULL;
} else if (len < MSN_FILE_CONTEXT_SIZE + 63) {
- g_free(header);
+ g_free(context);
return NULL;
}
} else {
- purple_debug_warning("msn", "Received MsnFileContext with unknown version: %d\n", header->version);
- g_free(header);
+ purple_debug_warning("msn", "Received MsnFileContext with unknown version: %d\n", context->version);
+ g_free(context);
return NULL;
}
- header->file_size = msn_pop64le(buf);
- header->type = msn_pop32le(buf);
- memcpy(header->file_name, buf, MAX_FILE_NAME_LEN * 2);
+ context->file_size = msn_pop64le(buf);
+ context->type = msn_pop32le(buf);
+ memcpy(context->file_name, buf, MAX_FILE_NAME_LEN * 2);
buf += MAX_FILE_NAME_LEN * 2;
- memcpy(header->unknown1, buf, sizeof(header->unknown1));
- buf += sizeof(header->unknown1);
- header->unknown2 = msn_pop32le(buf);
+ memcpy(context->unknown1, buf, sizeof(context->unknown1));
+ buf += sizeof(context->unknown1);
+ context->unknown2 = msn_pop32le(buf);
- if (header->type == 0 && len > header->length) {
- header->preview_len = len - header->length;
- header->preview = g_memdup(buf, header->preview_len);
+ if (context->type == 0 && len > context->length) {
+ context->preview_len = len - context->length;
+ context->preview = g_memdup(buf, context->preview_len);
} else {
- header->preview_len = 0;
- header->preview = NULL;
+ context->preview_len = 0;
+ context->preview = NULL;
}
- return header;
+ return context;
}
============================================================
--- libpurple/protocols/msn/xfer.h ee4a124178fed58e4b3357049ce1e3eb53e8e790
+++ libpurple/protocols/msn/xfer.h 3d478b478aaa4d370817cac83ae0cdd4b98ea82a
@@ -56,7 +56,7 @@ gchar *
void msn_xfer_end_cb(MsnSlpCall *slpcall, MsnSession *session);
gchar *
-msn_file_context_to_wire(MsnFileContext *header);
+msn_file_context_to_wire(MsnFileContext *context);
MsnFileContext *
msn_file_context_from_wire(const char *buf, gsize len);
More information about the Commits
mailing list