cpw.qulogic.msnp16: 73551b36: Shuffle some things around and add some ...
markdoliner at pidgin.im
markdoliner at pidgin.im
Mon Feb 8 03:21:43 EST 2010
-----------------------------------------------------------------
Revision: 73551b36d48cb0819a5648c155525b08a1db41f5
Ancestor: c7061cdd4aa014510ae344d29a088102c9d95eb7
Author: markdoliner at pidgin.im
Date: 2010-02-08T08:18:20
Branch: im.pidgin.cpw.qulogic.msnp16
URL: http://d.pidgin.im/viewmtn/revision/info/73551b36d48cb0819a5648c155525b08a1db41f5
Modified files:
libpurple/protocols/msn/cmdproc.c
ChangeLog:
Shuffle some things around and add some comments. Hopefully cleaner.
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/cmdproc.c 098ade4cde1b92dc4c6fa44b2eda7fb01d5e7b85
+++ libpurple/protocols/msn/cmdproc.c 96ba9eae5082f50237290155292346eaa68cf876
@@ -248,6 +248,8 @@ msn_cmdproc_process_msg(MsnCmdProc *cmdp
/* Multi-part messages */
message_id = msn_message_get_header_value(msg, "Message-ID");
if (message_id != NULL) {
+ /* This is the first in a series of chunks */
+
const char *chunk_text = msn_message_get_header_value(msg, "Chunks");
guint chunk;
if (chunk_text != NULL) {
@@ -269,31 +271,41 @@ msn_cmdproc_process_msg(MsnCmdProc *cmdp
} else {
chunk_text = msn_message_get_header_value(msg, "Chunk");
if (chunk_text != NULL) {
+ /* This is one chunk in a series of chunks */
+
MsnMessage *first = g_hash_table_lookup(cmdproc->multiparts, message_id);
chunk = strtol(chunk_text, NULL, 10);
if (first == NULL) {
purple_debug_error("msn",
"Unable to find first chunk of message_id '%s' to correspond with chunk %d.\n",
- message_id, chunk+1);
- } else if (first->received_chunks == chunk) {
- /* Chunk is from 1 to total-1 (doesn't count first one) */
- purple_debug_info("msn", "Received chunk %d of %d, message_id: '%s'\n",
- chunk+1, first->total_chunks, message_id);
- first->body = g_realloc(first->body, first->body_len + msg->body_len);
- memcpy(first->body + first->body_len, msg->body, msg->body_len);
- first->body_len += msg->body_len;
- first->received_chunks++;
- if (first->received_chunks != first->total_chunks)
- return;
- else
- /* We're done! Send it along... The caller takes care of
- freeing the old one. */
- msg = first;
- } else {
- /* TODO: Can you legitimately receive chunks out of order? */
+ message_id, chunk + 1);
+ } else if (first->received_chunks != chunk) {
+ /*
+ * We received an out of order chunk number (i.e. not the
+ * next one in the sequence). Not sure if this can happen
+ * legitimately, but we definitely don't handle it right
+ * now.
+ */
g_hash_table_remove(cmdproc->multiparts, message_id);
return;
}
+
+ /* Chunk is from 1 to total-1 (doesn't count first one) */
+ purple_debug_info("msn", "Received chunk %d of %d, message_id: '%s'\n",
+ chunk + 1, first->total_chunks, message_id);
+ first->body = g_realloc(first->body, first->body_len + msg->body_len);
+ memcpy(first->body + first->body_len, msg->body, msg->body_len);
+ first->body_len += msg->body_len;
+ first->received_chunks++;
+ if (first->received_chunks != first->total_chunks)
+ /* We're waiting for more chunks */
+ return;
+
+ /*
+ * We have all the chunks for this message, great! Send
+ * it along... The caller takes care of freeing the old one.
+ */
+ msg = first;
} else {
purple_debug_error("msn", "Received MessageId '%s' with no chunk number!\n", message_id);
}
More information about the Commits
mailing list