Mercurial > pidgin
annotate libpurple/protocols/mxit/chunk.c @ 28555:3f1d39bac4cd
Make the default themes' names consistent with the default smiley theme.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Wed, 11 Nov 2009 19:48:59 +0000 |
parents | 69aa4660401a |
children | 06fabb28bc69 |
rev | line source |
---|---|
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1 /* |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2 * MXit Protocol libPurple Plugin |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
3 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
4 * -- handle chunked data (multimedia messages) -- |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
5 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
6 * Pieter Loubser <libpurple@mxit.com> |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
7 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
8 * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
9 * <http://www.mxitlifestyle.com> |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
10 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
11 * This program is free software; you can redistribute it and/or modify |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
12 * it under the terms of the GNU General Public License as published by |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
13 * the Free Software Foundation; either version 2 of the License, or |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
14 * (at your option) any later version. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
15 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
16 * This program is distributed in the hope that it will be useful, |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
19 * GNU General Public License for more details. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
20 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
21 * You should have received a copy of the GNU General Public License |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
22 * along with this program; if not, write to the Free Software |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
24 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
25 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
26 #include <stdio.h> |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
27 #include <unistd.h> |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
28 #include <string.h> |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
29 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
30 #include "purple.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
31 #include "protocol.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
32 #include "mxit.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
33 #include "chunk.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
34 #include "filexfer.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
35 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
36 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
37 /*======================================================================================================================== |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
38 * Data-Type encoding |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
39 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
40 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
41 #if 0 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
42 #include <byteswap.h> |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
43 #if (__BYTE_ORDER == __BIG_ENDIAN) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
44 #define SWAP_64(x) (x) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
45 #else |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
46 #define SWAP_64(x) bswap_64(x) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
47 #endif |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
48 #endif |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
49 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
50 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
51 * Encode a single byte in the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
52 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
53 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
54 * @param value The byte |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
55 * @return The number of bytes added. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
56 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
57 static int add_int8( char* chunkdata, char value ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
58 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
59 *chunkdata = value; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
60 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
61 return sizeof( char ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
62 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
63 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
64 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
65 * Encode a 16-bit value in the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
66 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
67 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
68 * @param value The 16-bit value |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
69 * @return The number of bytes added. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
70 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
71 static int add_int16( char* chunkdata, short value ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
72 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
73 value = htons( value ); /* network byte-order */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
74 memcpy( chunkdata, &value, sizeof( short ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
75 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
76 return sizeof( short ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
77 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
78 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
79 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
80 * Encode a 32-bit value in the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
81 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
82 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
83 * @param value The 32-bit value |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
84 * @return The number of bytes added. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
85 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
86 static int add_int32( char* chunkdata, int value ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
87 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
88 value = htonl( value ); /* network byte-order */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
89 memcpy( chunkdata, &value, sizeof( int ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
90 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
91 return sizeof( int ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
93 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
94 #if 0 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
95 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
96 * Encode a 64-bit value in the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
97 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
98 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
99 * @param value The 64-bit value |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
100 * @return The number of bytes added. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
101 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
102 static int add_int64( char* chunkdata, int64_t value ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
103 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
104 value = SWAP_64( value ); /* network byte-order */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
105 memcpy( chunkdata, &value, sizeof( int64_t ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
106 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
107 return sizeof( int64_t ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
108 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
109 #endif |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
110 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
111 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
112 * Encode a block of data in the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
113 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
114 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
115 * @param data The data to add |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
116 * @param datalen The length of the data to add |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
117 * @return The number of bytes added. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
118 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
119 static int add_data( char* chunkdata, const char* data, int datalen ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
120 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
121 memcpy( chunkdata, data, datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
122 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
123 return datalen; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
124 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
125 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
126 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
127 * Encode a string as UTF-8 in the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
128 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
129 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
130 * @param str The string to encode |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
131 * @return The number of bytes in the string |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
132 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
133 static int add_utf8_string( char* chunkdata, const char* str ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
134 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
135 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
136 size_t len = strlen( str ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
137 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
138 /* utf8 string length [2 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
139 pos += add_int16( &chunkdata[pos], len ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
140 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
141 /* utf8 string */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
142 pos += add_data( &chunkdata[pos], str, len ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
143 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
144 return pos; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
145 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
146 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
147 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
148 /*======================================================================================================================== |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
149 * Data-Type decoding |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
150 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
151 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
152 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
153 * Extract a single byte from the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
154 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
155 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
156 * @param value The byte |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
157 * @return The number of bytes extracted. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
158 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
159 static int get_int8( const char* chunkdata, char* value ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
160 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
161 *value = *chunkdata; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
162 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
163 return sizeof( char ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
164 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
165 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
166 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
167 * Extract a 16-bit value from the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
168 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
169 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
170 * @param value The 16-bit value |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
171 * @return The number of bytes extracted |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
172 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
173 static int get_int16( const char* chunkdata, short* value ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
174 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
175 *value = ntohs( *( (const short*) chunkdata ) ); /* host byte-order */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
176 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
177 return sizeof( short ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
178 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
179 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
180 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
181 * Extract a 32-bit value from the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
182 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
183 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
184 * @param value The 32-bit value |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
185 * @return The number of bytes extracted |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
186 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
187 static int get_int32( const char* chunkdata, int* value ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
188 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
189 *value = ntohl( *( (const int*) chunkdata ) ); /* host byte-order */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
190 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
191 return sizeof( int ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
192 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
193 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
194 #if 0 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
195 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
196 * Extract a 64-bit value from the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
197 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
198 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
199 * @param value The 64-bit value |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
200 * @return The number of bytes extracted |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
201 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
202 static int get_int64( const char* chunkdata, int64_t* value ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
203 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
204 *value = SWAP_64( *( (const int64_t*) chunkdata ) ); /* host byte-order */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
205 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
206 return sizeof( int64_t ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
207 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
208 #endif |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
209 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
210 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
211 * Copy a block of data from the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
212 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
213 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
214 * @param dest Where to store the extract data |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
215 * @param datalen The length of the data to extract |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
216 * @return The number of bytes extracted |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
217 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
218 static int get_data( const char* chunkdata, char* dest, int datalen ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
219 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
220 memcpy( dest, chunkdata, datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
221 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
222 return datalen; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
223 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
224 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
225 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
226 * Extract a UTF-8 encoded string from the chunked data. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
227 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
228 * @param chunkdata The chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
229 * @param str A pointer to extracted string. Must be g_free()'d. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
230 * @return The number of bytes consumed |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
231 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
232 static int get_utf8_string( const char* chunkdata, char* str, int maxstrlen ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
233 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
234 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
235 short len; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
236 int skip = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
237 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
238 /* string length [2 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
239 pos += get_int16( &chunkdata[pos], &len ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
240 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
241 if ( len > maxstrlen ) { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
242 /* possible buffer overflow */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
243 purple_debug_error( MXIT_PLUGIN_ID, "Buffer overflow detected (get_utf8_string)\n" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
244 skip = len - maxstrlen; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
245 len = maxstrlen; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
246 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
247 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
248 /* string data */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
249 pos += get_data( &chunkdata[pos], str, len ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
250 str[len] = '\0'; /* terminate string */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
251 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
252 return pos + skip; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
253 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
254 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
255 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
256 /*======================================================================================================================== |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
257 * Chunked Data encoding |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
258 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
259 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
260 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
261 * Encode a "reject file" chunk. (Chunk type 7) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
262 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
263 * @param chunkdata Chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
264 * @param fileid A unique ID that identifies this file |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
265 * @return The number of bytes encoded in the buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
266 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
267 int mxit_chunk_create_reject( char* chunkdata, const char* fileid ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
268 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
269 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
270 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
271 /* file id [8 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
272 pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
273 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
274 /* rejection reason [1 byte] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
275 pos += add_int8( &chunkdata[pos], REJECT_BY_USER ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
276 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
277 /* rejection description [UTF-8 (optional)] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
278 pos += add_utf8_string( &chunkdata[pos], "" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
279 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
280 return pos; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
281 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
282 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
283 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
284 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
285 * Encode a "get file" request chunk. (Chunk type 8) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
286 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
287 * @param chunkdata Chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
288 * @param fileid A unique ID that identifies this file |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
289 * @param filesize The number of bytes to retrieve |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
290 * @param offset The start offset in the file |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
291 * @return The number of bytes encoded in the buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
292 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
293 int mxit_chunk_create_get( char* chunkdata, const char* fileid, int filesize, int offset ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
294 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
295 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
296 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
297 /* file id [8 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
298 pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
299 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
300 /* offset [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
301 pos += add_int32( &chunkdata[pos], offset ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
302 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
303 /* length [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
304 pos += add_int32( &chunkdata[pos], filesize ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
305 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
306 return pos; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
307 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
308 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
309 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
310 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
311 * Encode a "received file" chunk. (Chunk type 9) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
312 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
313 * @param chunkdata Chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
314 * @param fileid A unique ID that identifies this file |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
315 * @param status The status of the file transfer (see chunk.h) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
316 * @return The number of bytes encoded in the buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
317 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
318 int mxit_chunk_create_received( char* chunkdata, const char* fileid, unsigned char status ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
319 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
320 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
321 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
322 /* file id [8 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
323 pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
324 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
325 /* status [1 byte] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
326 pos += add_int8( &chunkdata[pos], status ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
327 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
328 return pos; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
329 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
330 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
331 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
332 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
333 * Encode a "send file direct" chunk. (Chunk type 10) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
334 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
335 * @param chunkdata Chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
336 * @param username The username of the recipient |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
337 * @param filename The name of the file being sent |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
338 * @param data The file contents |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
339 * @param datalen The size of the file contents |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
340 * @return The number of bytes encoded in the buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
341 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
342 int mxit_chunk_create_senddirect( char* chunkdata, const char* username, const char* filename, const unsigned char* data, int datalen ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
343 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
344 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
345 const char* mime = NULL; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
346 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
347 /* data length [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
348 pos += add_int32( &chunkdata[pos], datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
349 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
350 /* number of username(s) [2 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
351 pos += add_int16( &chunkdata[pos], 1 ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
352 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
353 /* username(s) [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
354 pos += add_utf8_string( &chunkdata[pos], username ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
355 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
356 /* filename [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
357 pos += add_utf8_string( &chunkdata[pos], filename ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
358 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
359 /* file mime type [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
360 mime = file_mime_type( filename, (const char*) data, datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
361 pos += add_utf8_string( &chunkdata[pos], mime ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
362 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
363 /* human readable description [UTF-8 (optional)] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
364 pos += add_utf8_string( &chunkdata[pos], "" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
365 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
366 /* crc [4 bytes] (0 = optional) */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
367 pos += add_int32( &chunkdata[pos], 0 ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
368 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
369 /* the actual file data */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
370 pos += add_data( &chunkdata[pos], (const char *) data, datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
371 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
372 return pos; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
373 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
374 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
375 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
376 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
377 * Encode a "set avatar" chunk. (Chunk type 13) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
378 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
379 * @param chunkdata Chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
380 * @param data The avatar data |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
381 * @param datalen The size of the avatar data |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
382 * @return The number of bytes encoded in the buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
383 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
384 int mxit_chunk_create_set_avatar( char* chunkdata, const unsigned char* data, int datalen ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
385 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
386 const char fileid[MXIT_CHUNK_FILEID_LEN]; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
387 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
388 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
389 /* id [8 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
390 memset( &fileid, 0, sizeof( fileid ) ); /* set to 0 for file upload */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
391 pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
392 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
393 /* size [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
394 pos += add_int32( &chunkdata[pos], datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
395 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
396 /* crc [4 bytes] (0 = optional) */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
397 pos += add_int32( &chunkdata[pos], 0 ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
398 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
399 /* the actual file data */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
400 pos += add_data( &chunkdata[pos], (const char *) data, datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
401 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
402 return pos; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
403 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
404 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
405 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
406 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
407 * Encode a "get avatar" chunk. (Chunk type 14) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
408 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
409 * @param chunkdata Chunked-data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
410 * @param mxitId The username who's avatar to download |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
411 * @param avatarId The Id of the avatar image (as string) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
412 * @param imgsize The resolution of the avatar image |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
413 * @return The number of bytes encoded in the buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
414 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
415 int mxit_chunk_create_get_avatar( char* chunkdata, const char* mxitId, const char* avatarId, unsigned int imgsize ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
416 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
417 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
418 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
419 /* number of avatars [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
420 pos += add_int32( &chunkdata[pos], 1 ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
421 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
422 /* username [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
423 pos += add_utf8_string( &chunkdata[pos], mxitId ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
424 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
425 /* avatar id [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
426 pos += add_utf8_string( &chunkdata[pos], avatarId ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
427 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
428 /* avatar format [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
429 pos += add_utf8_string( &chunkdata[pos], MXIT_AVATAR_TYPE ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
430 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
431 /* avatar bit depth [1 byte] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
432 pos += add_int8( &chunkdata[pos], MXIT_AVATAR_BITDEPT ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
433 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
434 /* number of sizes [2 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
435 pos += add_int16( &chunkdata[pos], 1 ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
436 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
437 /* image size [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
438 pos += add_int32( &chunkdata[pos], imgsize ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
439 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
440 return pos; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
441 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
442 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
443 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
444 /*======================================================================================================================== |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
445 * Chunked Data decoding |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
446 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
447 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
448 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
449 * Parse a received "offer file" chunk. (Chunk 6) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
450 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
451 * @param chunkdata Chunked data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
452 * @param datalen The length of the chunked data |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
453 * @param offer Decoded offerfile information |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
454 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
455 void mxit_chunk_parse_offer( char* chunkdata, int datalen, struct offerfile_chunk* offer ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
456 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
457 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
458 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
459 purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_offer (%i bytes)\n", datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
460 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
461 /* id [8 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
462 pos += get_data( &chunkdata[pos], offer->fileid, 8); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
463 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
464 /* from username [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
465 pos += get_utf8_string( &chunkdata[pos], offer->username, sizeof( offer->username ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
466 mxit_strip_domain( offer->username ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
467 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
468 /* file size [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
469 pos += get_int32( &chunkdata[pos], &(offer->filesize) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
470 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
471 /* filename [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
472 pos += get_utf8_string( &chunkdata[pos], offer->filename, sizeof( offer->filename) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
473 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
474 /* mime type [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
475 /* not used by libPurple */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
476 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
477 /* timestamp [8 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
478 /* not used by libPurple */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
479 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
480 /* file description [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
481 /* not used by libPurple */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
482 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
483 /* file alternative [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
484 /* not used by libPurple */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
485 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
486 /* flags [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
487 /* not used by libPurple */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
488 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
489 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
490 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
491 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
492 * Parse a received "get file" response chunk. (Chunk 8) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
493 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
494 * @param chunkdata Chunked data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
495 * @param datalen The length of the chunked data |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
496 * @param offer Decoded getfile information |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
497 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
498 void mxit_chunk_parse_get( char* chunkdata, int datalen, struct getfile_chunk* getfile ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
499 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
500 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
501 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
502 purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_file (%i bytes)\n", datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
503 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
504 /* id [8 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
505 pos += get_data( &chunkdata[pos], getfile->fileid, 8 ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
506 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
507 /* offset [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
508 pos += get_int32( &chunkdata[pos], &(getfile->offset) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
509 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
510 /* file length [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
511 pos += get_int32( &chunkdata[pos], &(getfile->length) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
512 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
513 /* crc [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
514 pos += get_int32( &chunkdata[pos], &(getfile->crc) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
515 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
516 /* file data */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
517 getfile->data = &chunkdata[pos]; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
518 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
519 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
520 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
521 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
522 * Parse a received splash screen chunk. (Chunk 2) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
523 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
524 * @param chunkdata Chunked data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
525 * @param datalen The length of the chunked data |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
526 * @param splash Decoded splash image information |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
527 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
528 static void mxit_chunk_parse_splash( char* chunkdata, int datalen, struct splash_chunk* splash ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
529 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
530 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
531 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
532 purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_splash (%i bytes)\n", datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
533 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
534 /* anchor [1 byte] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
535 pos += get_int8( &chunkdata[pos], &(splash->anchor) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
536 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
537 /* time to show [1 byte] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
538 pos += get_int8( &chunkdata[pos], &(splash->showtime) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
539 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
540 /* background color [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
541 pos += get_int32( &chunkdata[pos], &(splash->bgcolor) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
542 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
543 /* file data */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
544 splash->data = &chunkdata[pos]; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
545 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
546 /* data length */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
547 splash->datalen = datalen - pos; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
548 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
549 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
550 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
551 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
552 * Parse a received "custom resource" chunk. (Chunk 1) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
553 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
554 * @param chunkdata Chunked data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
555 * @param datalen The length of the chunked data |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
556 * @param offer Decoded custom resource |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
557 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
558 void mxit_chunk_parse_cr( char* chunkdata, int datalen, struct cr_chunk* cr ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
559 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
560 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
561 int chunklen = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
562 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
563 purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_cr (%i bytes)\n", datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
564 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
565 /* id [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
566 pos += get_utf8_string( &chunkdata[pos], cr->id, sizeof( cr->id ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
567 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
568 /* handle [UTF-8] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
569 pos += get_utf8_string( &chunkdata[pos], cr->handle, sizeof( cr->handle ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
570 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
571 /* operation [1 byte] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
572 pos += get_int8( &chunkdata[pos], &(cr->operation) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
573 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
574 /* chunk size [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
575 pos += get_int32( &chunkdata[pos], &chunklen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
576 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
577 /* parse the resource chunks */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
578 while ( chunklen > 0 ) { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
579 struct raw_chunk* chunkhdr = ( struct raw_chunk * ) &chunkdata[pos]; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
580 chunkhdr->length = ntohl( chunkhdr->length ); /* host byte-order */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
581 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
582 /* start of chunk data */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
583 pos += sizeof( struct raw_chunk ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
584 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
585 switch ( chunkhdr->type ) { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
586 case CP_CHUNK_SPLASH : /* splash image */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
587 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
588 struct splash_chunk* splash = g_new0( struct splash_chunk, 1 ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
589 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
590 mxit_chunk_parse_splash( &chunkdata[pos], chunkhdr->length, splash ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
591 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
592 cr->resources = g_list_append( cr->resources, splash ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
593 break; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
594 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
595 case CP_CHUNK_CLICK : /* splash click */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
596 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
597 struct splash_click_chunk* click = g_new0( struct splash_click_chunk, 1 ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
598 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
599 cr->resources = g_list_append( cr->resources, click ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
600 break; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
601 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
602 default: |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
603 purple_debug_info( MXIT_PLUGIN_ID, "Unsupported custom resource chunk received (%i)\n", chunkhdr->type ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
604 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
605 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
606 /* skip over data to next resource chunk */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
607 pos += chunkhdr->length; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
608 chunklen -= ( sizeof( struct raw_chunk ) + chunkhdr->length ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
609 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
610 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
611 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
612 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
613 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
614 * Parse a received "get avatar" response chunk. (Chunk 14) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
615 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
616 * @param chunkdata Chunked data buffer |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
617 * @param datalen The length of the chunked data |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
618 * @param avatar Decoded avatar information |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
619 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
620 void mxit_chunk_parse_get_avatar( char* chunkdata, int datalen, struct getavatar_chunk* avatar ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
621 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
622 int pos = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
623 int numfiles = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
624 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
625 purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_get_avatar (%i bytes)\n", datalen ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
626 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
627 /* number of files [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
628 pos += get_int32( &chunkdata[pos], &numfiles ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
629 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
630 if ( numfiles < 1 ) /* no data */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
631 return; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
632 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
633 /* mxitId [UTF-8 string] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
634 pos += get_utf8_string( &chunkdata[pos], avatar->mxitid, sizeof( avatar->mxitid ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
635 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
636 /* avatar id [UTF-8 string] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
637 pos += get_utf8_string( &chunkdata[pos], avatar->avatarid, sizeof( avatar->avatarid ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
638 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
639 /* format [UTF-8 string] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
640 pos += get_utf8_string( &chunkdata[pos], avatar->format, sizeof( avatar->format ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
641 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
642 /* bit depth [1 byte] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
643 pos += get_int8( &chunkdata[pos], &(avatar->bitdepth) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
644 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
645 /* crc [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
646 pos += get_int32( &chunkdata[pos], &(avatar->crc) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
647 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
648 /* width [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
649 pos += get_int32( &chunkdata[pos], &(avatar->width) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
650 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
651 /* height [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
652 pos += get_int32( &chunkdata[pos], &(avatar->height) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
653 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
654 /* file length [4 bytes] */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
655 pos += get_int32( &chunkdata[pos], &(avatar->length) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
656 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
657 /* file data */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
658 avatar->data = &chunkdata[pos]; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
659 } |