pidgin.mxit: 52a36abc: * Handle response to SendFile chunk pack...
andrew.victor at mxit.com
andrew.victor at mxit.com
Tue Apr 12 17:35:53 EDT 2011
----------------------------------------------------------------------
Revision: 52a36abca7dc83c1504e51c42db80a60887c0bdc
Parent: c31852494732b575fbed52e6b86b9a5af1087313
Author: andrew.victor at mxit.com
Date: 04/12/11 17:25:51
Branch: im.pidgin.pidgin.mxit
URL: http://d.pidgin.im/viewmtn/revision/info/52a36abca7dc83c1504e51c42db80a60887c0bdc
Changelog:
* Handle response to SendFile chunk packet, and display the error message
if the file transfer failed.
* Enable protocol version 6.3.
Changes against parent c31852494732b575fbed52e6b86b9a5af1087313
patched libpurple/protocols/mxit/chunk.c
patched libpurple/protocols/mxit/chunk.h
patched libpurple/protocols/mxit/protocol.c
patched libpurple/protocols/mxit/protocol.h
-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/chunk.c 8858aa0d2b5f8b502297ae68c75786ce9f6a0d7a
+++ libpurple/protocols/mxit/chunk.c f8e523b8870c28146448cbaa11a39160d5e2a474
@@ -224,6 +224,7 @@ static int get_data( const char* chunkda
*
* @param chunkdata The chunked-data buffer
* @param str A pointer to extracted string. Must be g_free()'d.
+ * @param maxstrlen Maximum size of destination buffer.
* @return The number of bytes consumed
*/
static int get_utf8_string( const char* chunkdata, char* str, int maxstrlen )
@@ -465,10 +466,10 @@ void mxit_chunk_parse_offer( char* chunk
pos += get_int32( &chunkdata[pos], &(offer->filesize) );
/* filename [UTF-8] */
- pos += get_utf8_string( &chunkdata[pos], offer->filename, sizeof( offer->filename) );
+ pos += get_utf8_string( &chunkdata[pos], offer->filename, sizeof( offer->filename ) );
/* mime type [UTF-8] */
- /* not used by libPurple */
+ pos += get_utf8_string( &chunkdata[pos], offer->mimetype, sizeof( offer->mimetype ) );
/* timestamp [8 bytes] */
/* not used by libPurple */
@@ -606,6 +607,37 @@ void mxit_chunk_parse_cr( char* chunkdat
/*------------------------------------------------------------------------
+ * Parse a received "send file direct" response chunk. (Chunk 10)
+ *
+ * @param chunkdata Chunked data buffer
+ * @param datalen The length of the chunked data
+ * @param sendfile Decoded sendfile information
+ */
+void mxit_chunk_parse_sendfile( char* chunkdata, int datalen, struct sendfile_chunk* sendfile )
+{
+ int pos = 0;
+ short entries = 0;
+
+ purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_sendfile (%i bytes)\n", datalen );
+
+ /* number of entries [2 bytes] */
+ pos += get_int16( &chunkdata[pos], &entries );
+
+ if ( entries < 1 ) /* no data */
+ return;
+
+ /* contactAddress [UTF-8 string] */
+ pos += get_utf8_string( &chunkdata[pos], sendfile->username, sizeof( sendfile->username ) );
+
+ /* status [4 bytes] */
+ pos += get_int32( &chunkdata[pos], &(sendfile->status) );
+
+ /* status message [UTF-8 string] */
+ pos += get_utf8_string( &chunkdata[pos], sendfile->statusmsg, sizeof( sendfile->statusmsg ) );
+}
+
+
+/*------------------------------------------------------------------------
* Parse a received "get avatar" response chunk. (Chunk 14)
*
* @param chunkdata Chunked data buffer
============================================================
--- libpurple/protocols/mxit/chunk.h 89235508caccc62f6ad885e1c23830a8e27db485
+++ libpurple/protocols/mxit/chunk.h 609188a9ef0a8fa7b3906ec038d6c7975f6dd81e
@@ -99,14 +99,20 @@ static inline gchar* chunk_data( gchar*
return &chunkheader[MXIT_CHUNK_HEADER_SIZE];
}
-
+/*
+ * Offer File chunk (6).
+ */
struct offerfile_chunk {
char fileid[MXIT_CHUNK_FILEID_LEN];
char username[MXIT_CP_MAX_JID_LEN + 1];
int filesize;
char filename[FILENAME_MAX];
+ char mimetype[64];
};
+/*
+ * Get File chunk (8) response.
+ */
struct getfile_chunk {
char fileid[MXIT_CHUNK_FILEID_LEN];
int offset;
@@ -115,6 +121,9 @@ struct getfile_chunk {
char* data;
};
+/*
+ * Custom Resource chunk (1).
+ */
struct cr_chunk {
char id[64];
char handle[64];
@@ -122,6 +131,9 @@ struct cr_chunk {
GList* resources;
};
+/*
+ * Splash Image chunk (2)
+ */
struct splash_chunk {
char anchor;
char showtime;
@@ -130,10 +142,16 @@ struct splash_chunk {
int datalen;
};
+/*
+ * Splash Click Through chunk (3)
+ */
struct splash_click_chunk {
char reserved[1];
};
+/*
+ * Get Avatar chunk (14) response.
+ */
struct getavatar_chunk {
char mxitid[50];
char avatarid[64];
@@ -146,6 +164,15 @@ struct getavatar_chunk {
char* data;
};
+/*
+ * Send File Direct chunk (10) response.
+ */
+struct sendfile_chunk {
+ char username[MXIT_CP_MAX_JID_LEN + 1];
+ int status;
+ char statusmsg[1024];
+};
+
/* Encode chunk */
int mxit_chunk_create_senddirect( char* chunkdata, const char* username, const char* filename, const unsigned char* data, int datalen );
int mxit_chunk_create_reject( char* chunkdata, const char* fileid );
@@ -158,6 +185,7 @@ void mxit_chunk_parse_cr( char* chunkdat
void mxit_chunk_parse_offer( char* chunkdata, int datalen, struct offerfile_chunk* offer );
void mxit_chunk_parse_get( char* chunkdata, int datalen, struct getfile_chunk* getfile );
void mxit_chunk_parse_cr( char* chunkdata, int datalen, struct cr_chunk* cr );
+void mxit_chunk_parse_sendfile( char* chunkdata, int datalen, struct sendfile_chunk* sendfile );
void mxit_chunk_parse_get_avatar( char* chunkdata, int datalen, struct getavatar_chunk* avatar );
#endif /* _MXIT_CHUNK_H_ */
============================================================
--- libpurple/protocols/mxit/protocol.c 09f584d136ff1c767eec1a70c2bc7e8b84556483
+++ libpurple/protocols/mxit/protocol.c 347af3cd9a06f1cf0397e595d7a31b21701559fb
@@ -2088,7 +2088,7 @@ static void mxit_parse_cmd_media( struct
struct contact* contact = NULL;
/* decode the chunked data */
- memset( &chunk, 0, sizeof ( struct getavatar_chunk ) );
+ memset( &chunk, 0, sizeof( struct getavatar_chunk ) );
mxit_chunk_parse_get_avatar( &records[0]->fields[0]->data[sizeof( char ) + sizeof( int )], records[0]->fields[0]->len, &chunk );
/* update avatar image */
@@ -2114,7 +2114,18 @@ static void mxit_parse_cmd_media( struct
break;
case CP_CHUNK_DIRECT_SND :
- /* this is a ack for a file send. no action is required */
+ /* this is a ack for a file send. */
+ {
+ struct sendfile_chunk chunk;
+
+ memset( &chunk, 0, sizeof( struct sendfile_chunk ) );
+ mxit_chunk_parse_sendfile( &records[0]->fields[0]->data[sizeof( char ) + sizeof( int )], records[0]->fields[0]->len, &chunk );
+
+ purple_debug_info( MXIT_PLUGIN_ID, "file-send send to '%s' [status=%i message='%s']\n", chunk.username, chunk.status, chunk.statusmsg );
+
+ if ( chunk.status != 0 ) /* not success */
+ mxit_popup( PURPLE_NOTIFY_MSG_ERROR, _( "File Send Failed" ), chunk.statusmsg );
+ }
break;
case CP_CHUNK_RECEIVED :
@@ -2285,6 +2296,7 @@ static int process_success_response( str
/* HTTP poll reply */
case CP_CMD_EXTPROFILE_SET :
/* profile update */
+ // TODO: Protocol 6.2 indicates status for each attribute, and current value.
case CP_CMD_SPLASHCLICK :
/* splash-screen clickthrough */
case CP_CMD_MSGEVENT :
============================================================
--- libpurple/protocols/mxit/protocol.h 2858d6d6e89f531b88d14e7b43cdcc06455853d9
+++ libpurple/protocols/mxit/protocol.h cd86cea741fc786d0fd9969fb8a49b69ac44a52d
@@ -91,7 +91,7 @@
#define MXIT_CP_ARCH "Y" /* client architecture series (Y not for Yoda but for PC-client) */
#define MXIT_CLIENT_ID "LP" /* client ID as specified by MXit */
#define MXIT_CP_PLATFORM "PURPLE" /* client platform */
-#define MXIT_CP_PROTO_VESION 60 /* client protocol version */
+#define MXIT_CP_PROTO_VESION 63 /* client protocol version */
/* set operating system name */
#if defined( __APPLE__ )
More information about the Commits
mailing list