Mercurial > pidgin.yaz
annotate src/protocols/oscar/im.c @ 9973:09ed9a574761
[gaim-migrate @ 10884]
Remove the old ICQ prpl
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 08 Sep 2004 03:11:41 +0000 |
parents | cee849d17167 |
children | 4e7fe18a36b7 |
rev | line source |
---|---|
2086 | 1 /* |
4617 | 2 * Family 0x0004 - Routines for sending/receiving Instant Messages. |
2086 | 3 * |
4617 | 4 * Note the term ICBM (Inter-Client Basic Message) which blankets |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8708
diff
changeset
|
5 * all types of generically routed through-server messages. Within |
4617 | 6 * the ICBM types (family 4), a channel is defined. Each channel |
7 * represents a different type of message. Channel 1 is used for | |
8 * what would commonly be called an "instant message". Channel 2 | |
9 * is used for negotiating "rendezvous". These transactions end in | |
10 * something more complex happening, such as a chat invitation, or | |
11 * a file transfer. Channel 3 is used for chat messages (not in | |
12 * the same family as these channels). Channel 4 is used for | |
13 * various ICQ messages. Examples are normal messages, URLs, and | |
14 * old-style authorization. | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
15 * |
4617 | 16 * In addition to the channel, every ICBM contains a cookie. For |
17 * standard IMs, these are only used for error messages. However, | |
18 * the more complex rendezvous messages make suitably more complex | |
19 * use of this field. | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
20 * |
4617 | 21 * TODO: Split this up into an im.c file an an icbm.c file. It |
22 * will be beautiful, you'll see. | |
23 * | |
24 * Need to rename all the mpmsg messages to aim_im_bleh. | |
25 * | |
26 * Make sure aim_conn_findbygroup is used by all functions. | |
2086 | 27 */ |
28 | |
29 #define FAIM_INTERNAL | |
30 #include <aim.h> | |
31 | |
3630 | 32 #ifdef _WIN32 |
33 #include "win32dep.h" | |
34 #endif | |
35 | |
4617 | 36 /** |
37 * Add a standard ICBM header to the given bstream with the given | |
38 * information. | |
39 * | |
40 * @param bs The bstream to write the ICBM header to. | |
41 * @param c c is for cookie, and cookie is for me. | |
42 * @param ch The ICBM channel (1 through 4). | |
43 * @param sn Null-terminated scrizeen nizame. | |
44 * @return The number of bytes written. It's really not useful. | |
45 */ | |
46 static int aim_im_puticbm(aim_bstream_t *bs, const fu8_t *c, fu16_t ch, const char *sn) | |
47 { | |
48 aimbs_putraw(bs, c, 8); | |
49 aimbs_put16(bs, ch); | |
50 aimbs_put8(bs, strlen(sn)); | |
51 aimbs_putraw(bs, sn, strlen(sn)); | |
52 return 8+2+1+strlen(sn); | |
53 } | |
54 | |
2086 | 55 /* |
56 * Takes a msghdr (and a length) and returns a client type | |
57 * code. Note that this is *only a guess* and has a low likelihood | |
58 * of actually being accurate. | |
59 * | |
60 * Its based on experimental data, with the help of Eric Warmenhoven | |
61 * who seems to have collected a wide variety of different AIM clients. | |
62 * | |
63 * | |
64 * Heres the current collection: | |
5971 | 65 * 0501 0003 0101 0101 01 AOL Mobile Communicator, WinAIM 1.0.414 |
66 * 0501 0003 0101 0201 01 WinAIM 2.0.847, 2.1.1187, 3.0.1464, | |
4102 | 67 * 4.3.2229, 4.4.2286 |
6304 | 68 * 0501 0004 0101 0102 0101 WinAIM 4.1.2010, libfaim (right here) |
5971 | 69 * 0501 0003 0101 02 WinAIM 5 |
6304 | 70 * 0501 0001 01 iChat x.x, mobile buddies |
5971 | 71 * 0501 0001 0101 01 AOL v6.0, CompuServe 2000 v6.0, any TOC client |
6304 | 72 * 0501 0002 0106 WinICQ 5.45.1.3777.85 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
73 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
74 * Note that in this function, only the feature bytes are tested, since |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
75 * the rest will always be the same. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
76 * |
2086 | 77 */ |
5556 | 78 faim_export fu16_t aim_im_fingerprint(const fu8_t *msghdr, int len) |
2086 | 79 { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
80 static const struct { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
81 fu16_t clientid; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
82 int len; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
83 fu8_t data[10]; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
84 } fingerprints[] = { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
85 /* AOL Mobile Communicator, WinAIM 1.0.414 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
86 { AIM_CLIENTTYPE_MC, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
87 3, {0x01, 0x01, 0x01}}, |
2086 | 88 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
89 /* WinAIM 2.0.847, 2.1.1187, 3.0.1464, 4.3.2229, 4.4.2286 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
90 { AIM_CLIENTTYPE_WINAIM, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
91 3, {0x01, 0x01, 0x02}}, |
2086 | 92 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
93 /* WinAIM 4.1.2010, libfaim */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
94 { AIM_CLIENTTYPE_WINAIM41, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
95 4, {0x01, 0x01, 0x01, 0x02}}, |
2086 | 96 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
97 /* AOL v6.0, CompuServe 2000 v6.0, any TOC client */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
98 { AIM_CLIENTTYPE_AOL_TOC, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
99 1, {0x01}}, |
2086 | 100 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
101 { 0, 0} |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
102 }; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
103 int i; |
2086 | 104 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
105 if (!msghdr || (len <= 0)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
106 return AIM_CLIENTTYPE_UNKNOWN; |
2086 | 107 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
108 for (i = 0; fingerprints[i].len; i++) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
109 if (fingerprints[i].len != len) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
110 continue; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
111 if (memcmp(fingerprints[i].data, msghdr, fingerprints[i].len) == 0) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
112 return fingerprints[i].clientid; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
113 } |
2086 | 114 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
115 return AIM_CLIENTTYPE_UNKNOWN; |
2086 | 116 } |
117 | |
4617 | 118 /** |
119 * Subtype 0x0002 - Set ICBM parameters. | |
3952 | 120 * |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8708
diff
changeset
|
121 * I definitely recommend sending this. If you don't, you'll be stuck |
4617 | 122 * with the rather unreasonable defaults. |
3952 | 123 * |
124 */ | |
4617 | 125 faim_export int aim_im_setparams(aim_session_t *sess, struct aim_icbmparameters *params) |
3952 | 126 { |
127 aim_conn_t *conn; | |
128 aim_frame_t *fr; | |
129 aim_snacid_t snacid; | |
130 | |
131 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) | |
132 return -EINVAL; | |
133 | |
134 if (!params) | |
135 return -EINVAL; | |
136 | |
137 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+16))) | |
138 return -ENOMEM; | |
139 | |
140 snacid = aim_cachesnac(sess, 0x0004, 0x0002, 0x0000, NULL, 0); | |
141 aim_putsnac(&fr->data, 0x0004, 0x0002, 0x0000, snacid); | |
142 | |
143 /* This is read-only (see Parameter Reply). Must be set to zero here. */ | |
144 aimbs_put16(&fr->data, 0x0000); | |
145 | |
146 /* These are all read-write */ | |
147 aimbs_put32(&fr->data, params->flags); | |
148 aimbs_put16(&fr->data, params->maxmsglen); | |
149 aimbs_put16(&fr->data, params->maxsenderwarn); | |
150 aimbs_put16(&fr->data, params->maxrecverwarn); | |
151 aimbs_put32(&fr->data, params->minmsginterval); | |
152 | |
153 aim_tx_enqueue(sess, fr); | |
154 | |
155 return 0; | |
156 } | |
157 | |
4617 | 158 /** |
159 * Subtype 0x0004 - Request ICBM parameter information. | |
160 * | |
161 */ | |
162 faim_export int aim_im_reqparams(aim_session_t *sess) | |
3952 | 163 { |
164 aim_conn_t *conn; | |
165 | |
166 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) | |
167 return -EINVAL; | |
168 | |
7282 | 169 return aim_genericreq_n_snacid(sess, conn, 0x0004, 0x0004); |
3952 | 170 } |
171 | |
4617 | 172 /** |
173 * Subtype 0x0005 - Receive parameter information. | |
174 * | |
175 */ | |
176 static int aim_im_paraminfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
3952 | 177 { |
4617 | 178 aim_rxcallback_t userfunc; |
3952 | 179 struct aim_icbmparameters params; |
180 | |
181 params.maxchan = aimbs_get16(bs); | |
182 params.flags = aimbs_get32(bs); | |
183 params.maxmsglen = aimbs_get16(bs); | |
184 params.maxsenderwarn = aimbs_get16(bs); | |
185 params.maxrecverwarn = aimbs_get16(bs); | |
186 params.minmsginterval = aimbs_get32(bs); | |
187 | |
188 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
189 return userfunc(sess, rx, ¶ms); | |
190 | |
191 return 0; | |
192 } | |
193 | |
4617 | 194 /** |
3952 | 195 * Subtype 0x0006 - Send an ICBM (instant message). |
2086 | 196 * |
197 * | |
198 * Possible flags: | |
199 * AIM_IMFLAGS_AWAY -- Marks the message as an autoresponse | |
200 * AIM_IMFLAGS_ACK -- Requests that the server send an ack | |
201 * when the message is received (of type 0x0004/0x000c) | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
202 * AIM_IMFLAGS_OFFLINE--If destination is offline, store it until they are |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
203 * online (probably ICQ only). |
2086 | 204 * |
205 * Generally, you should use the lowest encoding possible to send | |
206 * your message. If you only use basic punctuation and the generic | |
207 * Latin alphabet, use ASCII7 (no flags). If you happen to use non-ASCII7 | |
208 * characters, but they are all clearly defined in ISO-8859-1, then | |
209 * use that. Keep in mind that not all characters in the PC ASCII8 | |
210 * character set are defined in the ISO standard. For those cases (most | |
211 * notably when the (r) symbol is used), you must use the full UNICODE | |
212 * encoding for your message. In UNICODE mode, _all_ characters must | |
213 * occupy 16bits, including ones that are not special. (Remember that | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8708
diff
changeset
|
214 * the first 128 UNICODE symbols are equivalent to ASCII7, however they |
2086 | 215 * must be prefixed with a zero high order byte.) |
216 * | |
217 * I strongly discourage the use of UNICODE mode, mainly because none | |
218 * of the clients I use can parse those messages (and besides that, | |
219 * wchars are difficult and non-portable to handle in most UNIX environments). | |
220 * If you really need to include special characters, use the HTML UNICODE | |
221 * entities. These are of the form ߪ where 2026 is the hex | |
222 * representation of the UNICODE index (in this case, UNICODE | |
223 * "Horizontal Ellipsis", or 133 in in ASCII8). | |
224 * | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
225 * Implementation note: Since this is one of the most-used functions |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
226 * in all of libfaim, it is written with performance in mind. As such, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
227 * it is not as clear as it could be in respect to how this message is |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
228 * supposed to be layed out. Most obviously, tlvlists should be used |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
229 * instead of writing out the bytes manually. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
230 * |
4617 | 231 * XXX - more precise verification that we never send SNACs larger than 8192 |
232 * XXX - check SNAC size for multipart | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
233 * |
2086 | 234 */ |
4617 | 235 faim_export int aim_im_sendch1_ext(aim_session_t *sess, struct aim_sendimext_args *args) |
2086 | 236 { |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
237 aim_conn_t *conn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
238 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
239 aim_snacid_t snacid; |
4617 | 240 fu8_t ck[8]; |
241 int i, msgtlvlen; | |
242 static const fu8_t deffeatures[] = { 0x01, 0x01, 0x01, 0x02 }; | |
2086 | 243 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
244 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
245 return -EINVAL; |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
246 |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
247 if (!args) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
248 return -EINVAL; |
2086 | 249 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
250 if (args->flags & AIM_IMFLAGS_MULTIPART) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
251 if (args->mpmsg->numparts <= 0) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
252 return -EINVAL; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
253 } else { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
254 if (!args->msg || (args->msglen <= 0)) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
255 return -EINVAL; |
2086 | 256 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
257 if (args->msglen >= MAXMSGLEN) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
258 return -E2BIG; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
259 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
260 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
261 /* Painfully calculate the size of the message TLV */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
262 msgtlvlen = 1 + 1; /* 0501 */ |
2086 | 263 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
264 if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES) |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
265 msgtlvlen += 2 + args->featureslen; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
266 else |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
267 msgtlvlen += 2 + sizeof(deffeatures); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
268 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
269 if (args->flags & AIM_IMFLAGS_MULTIPART) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
270 aim_mpmsg_section_t *sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
271 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
272 for (sec = args->mpmsg->parts; sec; sec = sec->next) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
273 msgtlvlen += 2 /* 0101 */ + 2 /* block len */; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
274 msgtlvlen += 4 /* charset */ + sec->datalen; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
275 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
276 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
277 } else { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
278 msgtlvlen += 2 /* 0101 */ + 2 /* block len */; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
279 msgtlvlen += 4 /* charset */ + args->msglen; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
280 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
281 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
282 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, msgtlvlen+128))) |
2122 | 283 return -ENOMEM; |
2086 | 284 |
4617 | 285 /* XXX - should be optional */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
286 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, args->destsn, strlen(args->destsn)+1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
287 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
2086 | 288 |
2122 | 289 /* |
4617 | 290 * Generate a random message cookie |
2122 | 291 * |
292 * We could cache these like we do SNAC IDs. (In fact, it | |
293 * might be a good idea.) In the message error functions, | |
294 * the 8byte message cookie is returned as well as the | |
295 * SNAC ID. | |
296 * | |
297 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
298 for (i = 0; i < 8; i++) |
4617 | 299 ck[i] = (fu8_t)rand(); |
2086 | 300 |
4617 | 301 /* ICBM header */ |
302 aim_im_puticbm(&fr->data, ck, 0x0001, args->destsn); | |
2086 | 303 |
4617 | 304 /* Message TLV (type 0x0002) */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
305 aimbs_put16(&fr->data, 0x0002); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
306 aimbs_put16(&fr->data, msgtlvlen); |
2086 | 307 |
4617 | 308 /* Features TLV (type 0x0501) */ |
309 aimbs_put16(&fr->data, 0x0501); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
310 if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
311 aimbs_put16(&fr->data, args->featureslen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
312 aimbs_putraw(&fr->data, args->features, args->featureslen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
313 } else { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
314 aimbs_put16(&fr->data, sizeof(deffeatures)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
315 aimbs_putraw(&fr->data, deffeatures, sizeof(deffeatures)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
316 } |
2086 | 317 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
318 if (args->flags & AIM_IMFLAGS_MULTIPART) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
319 aim_mpmsg_section_t *sec; |
2086 | 320 |
4617 | 321 /* Insert each message part in a TLV (type 0x0101) */ |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
322 for (sec = args->mpmsg->parts; sec; sec = sec->next) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
323 aimbs_put16(&fr->data, 0x0101); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
324 aimbs_put16(&fr->data, sec->datalen + 4); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
325 aimbs_put16(&fr->data, sec->charset); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
326 aimbs_put16(&fr->data, sec->charsubset); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
327 aimbs_putraw(&fr->data, sec->data, sec->datalen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
328 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
329 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
330 } else { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
331 |
4617 | 332 /* Insert message text in a TLV (type 0x0101) */ |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
333 aimbs_put16(&fr->data, 0x0101); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
334 |
4617 | 335 /* Message block length */ |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
336 aimbs_put16(&fr->data, args->msglen + 0x04); |
2086 | 337 |
4617 | 338 /* Character set */ |
4662 | 339 aimbs_put16(&fr->data, args->charset); |
340 aimbs_put16(&fr->data, args->charsubset); | |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
341 |
4617 | 342 /* Message. Not terminated */ |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
343 aimbs_putraw(&fr->data, args->msg, args->msglen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
344 } |
2086 | 345 |
4617 | 346 /* Set the Autoresponse flag */ |
2122 | 347 if (args->flags & AIM_IMFLAGS_AWAY) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
348 aimbs_put16(&fr->data, 0x0004); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
349 aimbs_put16(&fr->data, 0x0000); |
4838 | 350 } else if (args->flags & AIM_IMFLAGS_ACK) { |
351 /* Set the Request Acknowledge flag */ | |
352 aimbs_put16(&fr->data, 0x0003); | |
353 aimbs_put16(&fr->data, 0x0000); | |
2122 | 354 } |
355 | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
356 if (args->flags & AIM_IMFLAGS_OFFLINE) { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
357 aimbs_put16(&fr->data, 0x0006); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
358 aimbs_put16(&fr->data, 0x0000); |
2122 | 359 } |
2086 | 360 |
2122 | 361 /* |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
362 * Set the I HAVE A REALLY PURTY ICON flag. |
3595 | 363 * XXX - This should really only be sent on initial |
364 * IMs and when you change your icon. | |
2122 | 365 */ |
366 if (args->flags & AIM_IMFLAGS_HASICON) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
367 aimbs_put16(&fr->data, 0x0008); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
368 aimbs_put16(&fr->data, 0x000c); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
369 aimbs_put32(&fr->data, args->iconlen); |
2626
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
370 aimbs_put16(&fr->data, 0x0001); |
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
371 aimbs_put16(&fr->data, args->iconsum); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
372 aimbs_put32(&fr->data, args->iconstamp); |
2122 | 373 } |
2086 | 374 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
375 /* |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
376 * Set the Buddy Icon Requested flag. |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8708
diff
changeset
|
377 * XXX - Every time? Surely not... |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
378 */ |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
379 if (args->flags & AIM_IMFLAGS_BUDDYREQ) { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
380 aimbs_put16(&fr->data, 0x0009); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
381 aimbs_put16(&fr->data, 0x0000); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
382 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
383 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
384 aim_tx_enqueue(sess, fr); |
2086 | 385 |
7283 | 386 /* clean out SNACs over 60sec old */ |
387 aim_cleansnacs(sess, 60); | |
2086 | 388 |
2122 | 389 return 0; |
2086 | 390 } |
391 | |
392 /* | |
4617 | 393 * Simple wrapper for aim_im_sendch1_ext() |
2086 | 394 * |
395 * You cannot use aim_send_im if you need the HASICON flag. You must | |
4617 | 396 * use aim_im_sendch1_ext directly for that. |
2086 | 397 * |
398 * aim_send_im also cannot be used if you require UNICODE messages, because | |
4617 | 399 * that requires an explicit message length. Use aim_im_sendch1_ext(). |
2086 | 400 * |
401 */ | |
4617 | 402 faim_export int aim_im_sendch1(aim_session_t *sess, const char *sn, fu16_t flags, const char *msg) |
2086 | 403 { |
2122 | 404 struct aim_sendimext_args args; |
2086 | 405 |
4617 | 406 args.destsn = sn; |
2122 | 407 args.flags = flags; |
408 args.msg = msg; | |
409 args.msglen = strlen(msg); | |
4662 | 410 args.charset = 0x0000; |
411 args.charsubset = 0x0000; | |
2086 | 412 |
4617 | 413 /* Make these don't get set by accident -- they need aim_im_sendch1_ext */ |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
414 args.flags &= ~(AIM_IMFLAGS_CUSTOMFEATURES | AIM_IMFLAGS_HASICON | AIM_IMFLAGS_MULTIPART); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
415 |
4617 | 416 return aim_im_sendch1_ext(sess, &args); |
2086 | 417 } |
418 | |
8225 | 419 /* |
420 * Subtype 0x0006 - Send a chat invitation. | |
421 */ | |
422 faim_export int aim_im_sendch2_chatinvite(aim_session_t *sess, const char *sn, const char *msg, fu16_t exchange, const char *roomname, fu16_t instance) | |
423 { | |
424 aim_conn_t *conn; | |
425 aim_frame_t *fr; | |
426 aim_snacid_t snacid; | |
427 int i; | |
428 aim_msgcookie_t *cookie; | |
429 struct aim_invite_priv *priv; | |
430 fu8_t ck[8]; | |
431 aim_tlvlist_t *otl = NULL, *itl = NULL; | |
432 fu8_t *hdr; | |
433 int hdrlen; | |
434 aim_bstream_t hdrbs; | |
435 | |
436 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) | |
437 return -EINVAL; | |
438 | |
439 if (!sn || !msg || !roomname) | |
440 return -EINVAL; | |
441 | |
442 for (i = 0; i < 8; i++) | |
443 ck[i] = (fu8_t)rand(); | |
444 | |
445 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152+strlen(sn)+strlen(roomname)+strlen(msg)))) | |
446 return -ENOMEM; | |
447 | |
448 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, sn, strlen(sn)+1); | |
449 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); | |
450 | |
451 /* XXX should be uncached by an unwritten 'invite accept' handler */ | |
452 if ((priv = malloc(sizeof(struct aim_invite_priv)))) { | |
453 priv->sn = strdup(sn); | |
454 priv->roomname = strdup(roomname); | |
455 priv->exchange = exchange; | |
456 priv->instance = instance; | |
457 } | |
458 | |
459 if ((cookie = aim_mkcookie(ck, AIM_COOKIETYPE_INVITE, priv))) | |
460 aim_cachecookie(sess, cookie); | |
461 else | |
462 free(priv); | |
463 | |
464 /* ICBM Header */ | |
465 aimbs_putraw(&fr->data, ck, 8); /* Cookie */ | |
466 aimbs_put16(&fr->data, 0x0002); /* Channel */ | |
467 aimbs_put8(&fr->data, strlen(sn)); /* Screename length */ | |
468 aimbs_putraw(&fr->data, sn, strlen(sn)); /* Screenname */ | |
469 | |
470 /* | |
471 * TLV t(0005) | |
472 * | |
473 * Everything else is inside this TLV. | |
474 * | |
475 * Sigh. AOL was rather inconsistent right here. So we have | |
476 * to play some minor tricks. Right inside the type 5 is some | |
477 * raw data, followed by a series of TLVs. | |
478 * | |
479 */ | |
480 hdrlen = 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2; | |
481 hdr = malloc(hdrlen); | |
482 aim_bstream_init(&hdrbs, hdr, hdrlen); | |
8978 | 483 |
8225 | 484 aimbs_put16(&hdrbs, 0x0000); /* Unknown! */ |
485 aimbs_putraw(&hdrbs, ck, sizeof(ck)); /* I think... */ | |
486 aim_putcap(&hdrbs, AIM_CAPS_CHAT); | |
487 | |
488 aim_tlvlist_add_16(&itl, 0x000a, 0x0001); | |
489 aim_tlvlist_add_noval(&itl, 0x000f); | |
490 aim_tlvlist_add_raw(&itl, 0x000c, strlen(msg), msg); | |
491 aim_tlvlist_add_chatroom(&itl, 0x2711, exchange, roomname, instance); | |
492 aim_tlvlist_write(&hdrbs, &itl); | |
493 | |
494 aim_tlvlist_add_raw(&otl, 0x0005, aim_bstream_curpos(&hdrbs), hdr); | |
495 | |
496 aim_tlvlist_write(&fr->data, &otl); | |
497 | |
498 free(hdr); | |
499 aim_tlvlist_free(&itl); | |
500 aim_tlvlist_free(&otl); | |
501 | |
502 aim_tx_enqueue(sess, fr); | |
503 | |
504 return 0; | |
505 } | |
506 | |
4617 | 507 /** |
508 * Subtype 0x0006 - Send your icon to a given user. | |
3952 | 509 * |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
510 * This is also performance sensitive. (If you can believe it...) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
511 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
512 */ |
4617 | 513 faim_export int aim_im_sendch2_icon(aim_session_t *sess, const char *sn, const fu8_t *icon, int iconlen, time_t stamp, fu16_t iconsum) |
2086 | 514 { |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
515 aim_conn_t *conn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
516 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
517 aim_snacid_t snacid; |
4617 | 518 fu8_t ck[8]; |
519 int i; | |
2086 | 520 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
521 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
522 return -EINVAL; |
2086 | 523 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
524 if (!sn || !icon || (iconlen <= 0) || (iconlen >= MAXICONLEN)) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
525 return -EINVAL; |
2086 | 526 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
527 for (i = 0; i < 8; i++) |
4617 | 528 ck[i] = (fu8_t)rand(); |
2086 | 529 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
530 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sn)+2+2+2+8+16+2+2+2+2+2+2+2+4+4+4+iconlen+strlen(AIM_ICONIDENT)+2+2))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
531 return -ENOMEM; |
2086 | 532 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
533 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
534 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
2086 | 535 |
4617 | 536 /* ICBM header */ |
537 aim_im_puticbm(&fr->data, ck, 0x0002, sn); | |
2086 | 538 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
539 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
540 * TLV t(0005) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
541 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
542 * Encompasses everything below. |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
543 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
544 aimbs_put16(&fr->data, 0x0005); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
545 aimbs_put16(&fr->data, 2+8+16+6+4+4+iconlen+4+4+4+strlen(AIM_ICONIDENT)); |
2086 | 546 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
547 aimbs_put16(&fr->data, 0x0000); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
548 aimbs_putraw(&fr->data, ck, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
549 aim_putcap(&fr->data, AIM_CAPS_BUDDYICON); |
2086 | 550 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
551 /* TLV t(000a) */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
552 aimbs_put16(&fr->data, 0x000a); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
553 aimbs_put16(&fr->data, 0x0002); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
554 aimbs_put16(&fr->data, 0x0001); |
2086 | 555 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
556 /* TLV t(000f) */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
557 aimbs_put16(&fr->data, 0x000f); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
558 aimbs_put16(&fr->data, 0x0000); |
2086 | 559 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
560 /* TLV t(2711) */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
561 aimbs_put16(&fr->data, 0x2711); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
562 aimbs_put16(&fr->data, 4+4+4+iconlen+strlen(AIM_ICONIDENT)); |
2626
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
563 aimbs_put16(&fr->data, 0x0000); |
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
564 aimbs_put16(&fr->data, iconsum); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
565 aimbs_put32(&fr->data, iconlen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
566 aimbs_put32(&fr->data, stamp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
567 aimbs_putraw(&fr->data, icon, iconlen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
568 aimbs_putraw(&fr->data, AIM_ICONIDENT, strlen(AIM_ICONIDENT)); |
2086 | 569 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
570 /* TLV t(0003) */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
571 aimbs_put16(&fr->data, 0x0003); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
572 aimbs_put16(&fr->data, 0x0000); |
2086 | 573 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
574 aim_tx_enqueue(sess, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
575 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
576 return 0; |
2086 | 577 } |
578 | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
579 /* |
4617 | 580 * Subtype 0x0006 - Send a rich text message. |
3952 | 581 * |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
582 * This only works for ICQ 2001b (thats 2001 not 2000). Better, only |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
583 * send it to clients advertising the RTF capability. In fact, if you send |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
584 * it to a client that doesn't support that capability, the server will gladly |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
585 * bounce it back to you. |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
586 * |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
587 * You'd think this would be in icq.c, but, well, I'm trying to stick with |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
588 * the one-group-per-file scheme as much as possible. This could easily |
8978 | 589 * be an exception, since Rendezvous IMs are external of the Oscar core, |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
590 * and therefore are undefined. Really I just need to think of a good way to |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
591 * make an interface similar to what AOL actually uses. But I'm not using COM. |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
592 * |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
593 */ |
4617 | 594 faim_export int aim_im_sendch2_rtfmsg(aim_session_t *sess, struct aim_sendrtfmsg_args *args) |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
595 { |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
596 aim_conn_t *conn; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
597 aim_frame_t *fr; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
598 aim_snacid_t snacid; |
4617 | 599 fu8_t ck[8]; |
600 const char rtfcap[] = {"{97B12751-243C-4334-AD22-D6ABF73F1492}"}; /* AIM_CAPS_ICQRTF capability in string form */ | |
601 int i, servdatalen; | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
602 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
603 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
604 return -EINVAL; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
605 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
606 if (!args || !args->destsn || !args->rtfmsg) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
607 return -EINVAL; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
608 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
609 servdatalen = 2+2+16+2+4+1+2 + 2+2+4+4+4 + 2+4+2+strlen(args->rtfmsg)+1 + 4+4+4+strlen(rtfcap)+1; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
610 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
611 for (i = 0; i < 8; i++) |
4617 | 612 ck[i] = (fu8_t)rand(); |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
613 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
614 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+128+servdatalen))) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
615 return -ENOMEM; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
616 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
617 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
618 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
619 |
4617 | 620 /* ICBM header */ |
621 aim_im_puticbm(&fr->data, ck, 0x0002, args->destsn); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
622 |
4617 | 623 /* TLV t(0005) - Encompasses everything below. */ |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
624 aimbs_put16(&fr->data, 0x0005); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
625 aimbs_put16(&fr->data, 2+8+16 + 2+2+2 + 2+2 + 2+2+servdatalen); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
626 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
627 aimbs_put16(&fr->data, 0x0000); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
628 aimbs_putraw(&fr->data, ck, 8); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
629 aim_putcap(&fr->data, AIM_CAPS_ICQSERVERRELAY); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
630 |
4617 | 631 /* t(000a) l(0002) v(0001) */ |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
632 aimbs_put16(&fr->data, 0x000a); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
633 aimbs_put16(&fr->data, 0x0002); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
634 aimbs_put16(&fr->data, 0x0001); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
635 |
4617 | 636 /* t(000f) l(0000) v() */ |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
637 aimbs_put16(&fr->data, 0x000f); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
638 aimbs_put16(&fr->data, 0x0000); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
639 |
4617 | 640 /* Service Data TLV */ |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
641 aimbs_put16(&fr->data, 0x2711); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
642 aimbs_put16(&fr->data, servdatalen); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
643 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
644 aimbs_putle16(&fr->data, 11 + 16 /* 11 + (sizeof CLSID) */); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
645 aimbs_putle16(&fr->data, 9); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
646 aim_putcap(&fr->data, AIM_CAPS_EMPTY); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
647 aimbs_putle16(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
648 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
649 aimbs_putle8(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
650 aimbs_putle16(&fr->data, 0x03ea); /* trid1 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
651 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
652 aimbs_putle16(&fr->data, 14); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
653 aimbs_putle16(&fr->data, 0x03eb); /* trid2 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
654 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
655 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
656 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
657 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
658 aimbs_putle16(&fr->data, 0x0001); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
659 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
660 aimbs_putle16(&fr->data, strlen(args->rtfmsg)+1); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
661 aimbs_putraw(&fr->data, args->rtfmsg, strlen(args->rtfmsg)+1); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
662 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
663 aimbs_putle32(&fr->data, args->fgcolor); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
664 aimbs_putle32(&fr->data, args->bgcolor); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
665 aimbs_putle32(&fr->data, strlen(rtfcap)+1); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
666 aimbs_putraw(&fr->data, rtfcap, strlen(rtfcap)+1); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
667 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
668 aim_tx_enqueue(sess, fr); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
669 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
670 return 0; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
671 } |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
672 |
4617 | 673 /** |
674 * Subtype 0x0006 - Send an "I want to directly connect to you" message | |
675 * | |
676 */ | |
8982 | 677 faim_export int aim_im_sendch2_odcrequest(aim_session_t *sess, fu8_t *cookie, bool usecookie, const char *sn, const fu8_t *ip, fu16_t port) |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
678 { |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
679 aim_conn_t *conn; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
680 aim_frame_t *fr; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
681 aim_snacid_t snacid; |
4617 | 682 fu8_t ck[8]; |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
683 aim_tlvlist_t *tl = NULL, *itl = NULL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
684 int hdrlen, i; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
685 fu8_t *hdr; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
686 aim_bstream_t hdrbs; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
687 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
688 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
689 return -EINVAL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
690 |
4617 | 691 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 256+strlen(sn)))) |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
692 return -ENOMEM; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
693 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
694 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
695 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
696 |
8978 | 697 /* |
698 * Generate a random message cookie | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
699 * |
8978 | 700 * This cookie needs to be alphanumeric and NULL-terminated to be |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
701 * TOC-compatible. |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
702 * |
4617 | 703 * XXX - have I mentioned these should be generated in msgcookie.c? |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
704 * |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
705 */ |
8982 | 706 |
707 if (cookie && usecookie) /* allow user-specified cookie */ | |
708 memcpy(ck, cookie, 8); | |
709 else | |
710 for (i = 0; i < 7; i++) | |
711 ck[i] = 0x30 + ((fu8_t) rand() % 10); | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
712 ck[7] = '\0'; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
713 |
8982 | 714 if (cookie && !usecookie) |
4617 | 715 memcpy(cookie, ck, 8); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
716 |
4617 | 717 /* ICBM header */ |
718 aim_im_puticbm(&fr->data, ck, 0x0002, sn); | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
719 |
7167 | 720 aim_tlvlist_add_noval(&tl, 0x0003); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
721 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
722 hdrlen = 2+8+16+6+8+6+4; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
723 hdr = malloc(hdrlen); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
724 aim_bstream_init(&hdrbs, hdr, hdrlen); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
725 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
726 aimbs_put16(&hdrbs, 0x0000); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
727 aimbs_putraw(&hdrbs, ck, 8); |
6871 | 728 aim_putcap(&hdrbs, AIM_CAPS_DIRECTIM); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
729 |
7167 | 730 aim_tlvlist_add_16(&itl, 0x000a, 0x0001); |
731 aim_tlvlist_add_raw(&itl, 0x0003, 4, ip); | |
732 aim_tlvlist_add_16(&itl, 0x0005, port); | |
733 aim_tlvlist_add_noval(&itl, 0x000f); | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
734 |
7167 | 735 aim_tlvlist_write(&hdrbs, &itl); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
736 |
7167 | 737 aim_tlvlist_add_raw(&tl, 0x0005, aim_bstream_curpos(&hdrbs), hdr); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
738 |
7167 | 739 aim_tlvlist_write(&fr->data, &tl); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
740 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
741 free(hdr); |
7167 | 742 aim_tlvlist_free(&itl); |
743 aim_tlvlist_free(&tl); | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
744 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
745 aim_tx_enqueue(sess, fr); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
746 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
747 return 0; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
748 } |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
749 |
4617 | 750 /** |
751 * Subtype 0x0006 - Send an "I want to send you this file" message | |
752 * | |
753 */ | |
5146 | 754 faim_export int aim_im_sendch2_sendfile_ask(aim_session_t *sess, struct aim_oft_info *oft_info) |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
755 { |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
756 aim_conn_t *conn; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
757 aim_frame_t *fr; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
758 aim_snacid_t snacid; |
4617 | 759 aim_tlvlist_t *tl=NULL, *subtl=NULL; |
760 int i; | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
761 |
5146 | 762 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)) || !oft_info) |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
763 return -EINVAL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
764 |
4617 | 765 /* XXX - Should be like "21CBF95" and null terminated */ |
766 for (i = 0; i < 7; i++) | |
5146 | 767 oft_info->cookie[i] = 0x30 + ((fu8_t)rand() % 10); |
768 oft_info->cookie[7] = '\0'; | |
4617 | 769 |
770 { /* Create the subTLV chain */ | |
771 fu8_t *buf; | |
772 int buflen; | |
773 aim_bstream_t bs; | |
774 | |
7167 | 775 aim_tlvlist_add_16(&subtl, 0x000a, 0x0001); |
776 aim_tlvlist_add_noval(&subtl, 0x000f); | |
777 /* aim_tlvlist_add_raw(&subtl, 0x000e, 2, "en"); | |
778 aim_tlvlist_add_raw(&subtl, 0x000d, 8, "us-ascii"); | |
779 aim_tlvlist_add_raw(&subtl, 0x000c, 24, "Please accept this file."); */ | |
8838 | 780 /* XXX - Change oft_info->clientip to an array of 4 bytes */ |
5146 | 781 if (oft_info->clientip) { |
782 fu8_t ip[4]; | |
783 char *nexttoken; | |
784 int i = 0; | |
785 nexttoken = strtok(oft_info->clientip, "."); | |
786 while (nexttoken && i<4) { | |
787 ip[i] = atoi(nexttoken); | |
788 nexttoken = strtok(NULL, "."); | |
789 i++; | |
790 } | |
7167 | 791 aim_tlvlist_add_raw(&subtl, 0x0003, 4, ip); |
5146 | 792 } |
7167 | 793 aim_tlvlist_add_16(&subtl, 0x0005, oft_info->port); |
4617 | 794 |
795 /* TLV t(2711) */ | |
5146 | 796 buflen = 2+2+4+strlen(oft_info->fh.name)+1; |
4617 | 797 buf = malloc(buflen); |
798 aim_bstream_init(&bs, buf, buflen); | |
5146 | 799 aimbs_put16(&bs, (oft_info->fh.totfiles > 1) ? 0x0002 : 0x0001); |
800 aimbs_put16(&bs, oft_info->fh.totfiles); | |
801 aimbs_put32(&bs, oft_info->fh.totsize); | |
4617 | 802 |
5146 | 803 /* Filename - NULL terminated, for some odd reason */ |
804 aimbs_putraw(&bs, oft_info->fh.name, strlen(oft_info->fh.name)); | |
805 aimbs_put8(&bs, 0x00); | |
4617 | 806 |
7167 | 807 aim_tlvlist_add_raw(&subtl, 0x2711, bs.len, bs.data); |
4617 | 808 free(buf); |
809 } | |
810 | |
811 { /* Create the main TLV chain */ | |
812 fu8_t *buf; | |
813 int buflen; | |
814 aim_bstream_t bs; | |
815 | |
816 /* TLV t(0005) - Encompasses everything from above. Gee. */ | |
7167 | 817 buflen = 2+8+16+aim_tlvlist_size(&subtl); |
4617 | 818 buf = malloc(buflen); |
819 aim_bstream_init(&bs, buf, buflen); | |
820 aimbs_put16(&bs, AIM_RENDEZVOUS_PROPOSE); | |
5146 | 821 aimbs_putraw(&bs, oft_info->cookie, 8); |
4617 | 822 aim_putcap(&bs, AIM_CAPS_SENDFILE); |
7167 | 823 aim_tlvlist_write(&bs, &subtl); |
824 aim_tlvlist_free(&subtl); | |
825 aim_tlvlist_add_raw(&tl, 0x0005, bs.len, bs.data); | |
4617 | 826 free(buf); |
827 | |
828 /* TLV t(0003) - Request an ack */ | |
7167 | 829 aim_tlvlist_add_noval(&tl, 0x0003); |
4617 | 830 } |
831 | |
7167 | 832 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(oft_info->sn) + aim_tlvlist_size(&tl)))) |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
833 return -ENOMEM; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
834 |
5146 | 835 snacid = aim_cachesnac(sess, 0x0004, 0x0006, AIM_SNACFLAGS_DESTRUCTOR, oft_info->cookie, sizeof(oft_info->cookie)); |
3752 | 836 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
837 | |
4617 | 838 /* ICBM header */ |
5146 | 839 aim_im_puticbm(&fr->data, oft_info->cookie, 0x0002, oft_info->sn); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
840 |
4617 | 841 /* All that crap from above (the 0x0005 TLV and the 0x0003 TLV) */ |
7167 | 842 aim_tlvlist_write(&fr->data, &tl); |
843 aim_tlvlist_free(&tl); | |
4617 | 844 |
845 aim_tx_enqueue(sess, fr); | |
846 | |
847 return 0; | |
848 } | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
849 |
4617 | 850 /** |
851 * Subtype 0x0006 - Send an "I will accept this file" message? | |
852 * | |
853 * @param rendid Capability type (AIM_CAPS_GETFILE or AIM_CAPS_SENDFILE) | |
854 */ | |
5146 | 855 faim_export int aim_im_sendch2_sendfile_accept(aim_session_t *sess, struct aim_oft_info *oft_info) |
4617 | 856 { |
857 aim_conn_t *conn; | |
858 aim_frame_t *fr; | |
859 aim_snacid_t snacid; | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
860 |
5146 | 861 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)) || !oft_info) |
4617 | 862 return -EINVAL; |
863 | |
5146 | 864 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(oft_info->sn) + 4+2+8+16))) |
4617 | 865 return -ENOMEM; |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
866 |
4617 | 867 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); |
868 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); | |
869 | |
870 /* ICBM header */ | |
5146 | 871 aim_im_puticbm(&fr->data, oft_info->cookie, 0x0002, oft_info->sn); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
872 |
4617 | 873 aimbs_put16(&fr->data, 0x0005); |
874 aimbs_put16(&fr->data, 0x001a); | |
875 aimbs_put16(&fr->data, AIM_RENDEZVOUS_ACCEPT); | |
5146 | 876 aimbs_putraw(&fr->data, oft_info->cookie, 8); |
877 aim_putcap(&fr->data, AIM_CAPS_SENDFILE); | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
878 |
4617 | 879 aim_tx_enqueue(sess, fr); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
880 |
4617 | 881 return 0; |
882 } | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
883 |
4617 | 884 /** |
885 * Subtype 0x0006 - Send a "cancel this file transfer" message? | |
886 * | |
887 */ | |
5146 | 888 faim_export int aim_im_sendch2_sendfile_cancel(aim_session_t *sess, struct aim_oft_info *oft_info) |
4617 | 889 { |
890 aim_conn_t *conn; | |
891 aim_frame_t *fr; | |
892 aim_snacid_t snacid; | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
893 |
5146 | 894 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)) || !oft_info) |
4617 | 895 return -EINVAL; |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
896 |
5146 | 897 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 11+strlen(oft_info->sn) + 4+2+8+16))) |
4617 | 898 return -ENOMEM; |
899 | |
900 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); | |
901 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
902 |
4617 | 903 /* ICBM header */ |
5146 | 904 aim_im_puticbm(&fr->data, oft_info->cookie, 0x0002, oft_info->sn); |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
905 |
4617 | 906 aimbs_put16(&fr->data, 0x0005); |
907 aimbs_put16(&fr->data, 0x001a); | |
908 aimbs_put16(&fr->data, AIM_RENDEZVOUS_CANCEL); | |
5146 | 909 aimbs_putraw(&fr->data, oft_info->cookie, 8); |
910 aim_putcap(&fr->data, AIM_CAPS_SENDFILE); | |
3630 | 911 |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
912 aim_tx_enqueue(sess, fr); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
913 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
914 return 0; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
915 } |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
916 |
3212 | 917 /** |
3952 | 918 * Subtype 0x0006 - Request the status message of the given ICQ user. |
3212 | 919 * |
920 * @param sess The oscar session. | |
921 * @param sn The UIN of the user of whom you wish to request info. | |
922 * @param type The type of info you wish to request. This should be the current | |
923 * state of the user, as one of the AIM_ICQ_STATE_* defines. | |
924 * @return Return 0 if no errors, otherwise return the error number. | |
925 */ | |
4617 | 926 faim_export int aim_im_sendch2_geticqaway(aim_session_t *sess, const char *sn, int type) |
3212 | 927 { |
928 aim_conn_t *conn; | |
4617 | 929 aim_frame_t *fr; |
930 aim_snacid_t snacid; | |
3212 | 931 int i; |
932 fu8_t ck[8]; | |
933 | |
934 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004)) || !sn) | |
935 return -EINVAL; | |
936 | |
937 for (i = 0; i < 8; i++) | |
4617 | 938 ck[i] = (fu8_t)rand(); |
3212 | 939 |
940 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sn) + 4+0x5e + 4))) | |
941 return -ENOMEM; | |
942 | |
943 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); | |
944 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); | |
945 | |
4617 | 946 /* ICBM header */ |
947 aim_im_puticbm(&fr->data, ck, 0x0002, sn); | |
3212 | 948 |
949 /* TLV t(0005) - Encompasses almost everything below. */ | |
950 aimbs_put16(&fr->data, 0x0005); /* T */ | |
951 aimbs_put16(&fr->data, 0x005e); /* L */ | |
952 { /* V */ | |
953 aimbs_put16(&fr->data, 0x0000); | |
954 | |
955 /* Cookie */ | |
956 aimbs_putraw(&fr->data, ck, 8); | |
957 | |
958 /* Put the 16 byte server relay capability */ | |
959 aim_putcap(&fr->data, AIM_CAPS_ICQSERVERRELAY); | |
960 | |
961 /* TLV t(000a) */ | |
962 aimbs_put16(&fr->data, 0x000a); | |
963 aimbs_put16(&fr->data, 0x0002); | |
964 aimbs_put16(&fr->data, 0x0001); | |
965 | |
966 /* TLV t(000f) */ | |
967 aimbs_put16(&fr->data, 0x000f); | |
968 aimbs_put16(&fr->data, 0x0000); | |
969 | |
970 /* TLV t(2711) */ | |
971 aimbs_put16(&fr->data, 0x2711); | |
972 aimbs_put16(&fr->data, 0x0036); | |
973 { /* V */ | |
974 aimbs_putle16(&fr->data, 0x001b); /* L */ | |
3952 | 975 aimbs_putle16(&fr->data, 0x0008); /* XXX - Protocol version */ |
4154 | 976 aim_putcap(&fr->data, AIM_CAPS_EMPTY); |
3212 | 977 aimbs_putle16(&fr->data, 0x0000); /* Unknown */ |
978 aimbs_putle16(&fr->data, 0x0003); /* Client features? */ | |
979 aimbs_putle16(&fr->data, 0x0000); /* Unknown */ | |
980 aimbs_putle8(&fr->data, 0x00); /* Unkizown */ | |
981 aimbs_putle16(&fr->data, 0xffff); /* Sequence number? XXX - This should decrement by 1 with each request */ | |
982 | |
983 aimbs_putle16(&fr->data, 0x000e); /* L */ | |
984 aimbs_putle16(&fr->data, 0xffff); /* Sequence number? XXX - This should decrement by 1 with each request */ | |
985 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */ | |
986 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */ | |
987 aimbs_putle32(&fr->data, 0x00000000); /* Unknown */ | |
988 | |
989 /* The type of status message being requested */ | |
990 if (type & AIM_ICQ_STATE_CHAT) | |
991 aimbs_putle16(&fr->data, 0x03ec); | |
992 else if(type & AIM_ICQ_STATE_DND) | |
993 aimbs_putle16(&fr->data, 0x03eb); | |
994 else if(type & AIM_ICQ_STATE_OUT) | |
995 aimbs_putle16(&fr->data, 0x03ea); | |
996 else if(type & AIM_ICQ_STATE_BUSY) | |
997 aimbs_putle16(&fr->data, 0x03e9); | |
998 else if(type & AIM_ICQ_STATE_AWAY) | |
999 aimbs_putle16(&fr->data, 0x03e8); | |
1000 | |
1001 aimbs_putle16(&fr->data, 0x0000); /* Status? */ | |
1002 aimbs_putle16(&fr->data, 0x0001); /* Priority of this message? */ | |
4154 | 1003 aimbs_putle16(&fr->data, 0x0001); /* L */ |
1004 aimbs_putle8(&fr->data, 0x00); /* String of length L */ | |
3212 | 1005 } /* End TLV t(2711) */ |
1006 } /* End TLV t(0005) */ | |
1007 | |
1008 /* TLV t(0003) */ | |
1009 aimbs_put16(&fr->data, 0x0003); | |
1010 aimbs_put16(&fr->data, 0x0000); | |
1011 | |
1012 aim_tx_enqueue(sess, fr); | |
1013 | |
1014 return 0; | |
1015 } | |
1016 | |
1017 /** | |
4617 | 1018 * Subtype 0x0006 - Send an ICQ-esque ICBM. |
3952 | 1019 * |
3141 | 1020 * This can be used to send an ICQ authorization reply (deny or grant). It is the "old way." |
1021 * The new way is to use SSI. I like the new way a lot better. This seems like such a hack, | |
1022 * mostly because it's in network byte order. Figuring this stuff out sometimes takes a while, | |
1023 * but thats ok, because it gives me time to try to figure out what kind of drugs the AOL people | |
1024 * were taking when they merged the two protocols. | |
1025 * | |
3212 | 1026 * @param sn The destination screen name. |
1027 * @param type The type of message. 0x0007 for authorization denied. 0x0008 for authorization granted. | |
1028 * @param message The message you want to send, it should be null terminated. | |
1029 * @return Return 0 if no errors, otherwise return the error number. | |
3141 | 1030 */ |
4617 | 1031 faim_export int aim_im_sendch4(aim_session_t *sess, char *sn, fu16_t type, fu8_t *message) |
3141 | 1032 { |
1033 aim_conn_t *conn; | |
1034 aim_frame_t *fr; | |
1035 aim_snacid_t snacid; | |
1036 int i; | |
4617 | 1037 char ck[8]; |
3141 | 1038 |
1039 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0002))) | |
1040 return -EINVAL; | |
1041 | |
1042 if (!sn || !type || !message) | |
1043 return -EINVAL; | |
1044 | |
1045 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+3+strlen(sn)+12+strlen(message)+1+4))) | |
1046 return -ENOMEM; | |
1047 | |
1048 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); | |
1049 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); | |
1050 | |
4617 | 1051 /* Cookie */ |
3141 | 1052 for (i=0; i<8; i++) |
4617 | 1053 ck[i] = (fu8_t)rand(); |
3141 | 1054 |
4617 | 1055 /* ICBM header */ |
1056 aim_im_puticbm(&fr->data, ck, 0x0004, sn); | |
3141 | 1057 |
1058 /* | |
1059 * TLV t(0005) | |
1060 * | |
1061 * ICQ data (the UIN and the message). | |
1062 */ | |
1063 aimbs_put16(&fr->data, 0x0005); | |
1064 aimbs_put16(&fr->data, 4 + 2+2+strlen(message)+1); | |
1065 | |
1066 /* | |
1067 * Your UIN | |
1068 */ | |
1069 aimbs_putle32(&fr->data, atoi(sess->sn)); | |
1070 | |
1071 /* | |
1072 * TLV t(type) l(strlen(message)+1) v(message+NULL) | |
1073 */ | |
1074 aimbs_putle16(&fr->data, type); | |
1075 aimbs_putle16(&fr->data, strlen(message)+1); | |
1076 aimbs_putraw(&fr->data, message, strlen(message)+1); | |
1077 | |
1078 /* | |
1079 * TLV t(0006) l(0000) v() | |
1080 */ | |
1081 aimbs_put16(&fr->data, 0x0006); | |
1082 aimbs_put16(&fr->data, 0x0000); | |
1083 | |
1084 aim_tx_enqueue(sess, fr); | |
1085 | |
1086 return 0; | |
1087 } | |
1088 | |
4617 | 1089 /* |
1090 * XXX - I don't see when this would ever get called... | |
1091 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1092 static int outgoingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 1093 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1094 int i, ret = 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1095 aim_rxcallback_t userfunc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1096 fu8_t cookie[8]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1097 fu16_t channel; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1098 aim_tlvlist_t *tlvlist; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1099 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1100 int snlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1101 fu16_t icbmflags = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1102 fu8_t flag1 = 0, flag2 = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1103 fu8_t *msg = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1104 aim_tlv_t *msgblock; |
2086 | 1105 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1106 /* ICBM Cookie. */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1107 for (i = 0; i < 8; i++) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1108 cookie[i] = aimbs_get8(bs); |
2086 | 1109 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1110 /* Channel ID */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1111 channel = aimbs_get16(bs); |
2086 | 1112 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1113 if (channel != 0x01) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1114 faimdprintf(sess, 0, "icbm: ICBM recieved on unsupported channel. Ignoring. (chan = %04x)\n", channel); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1115 return 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1116 } |
2086 | 1117 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1118 snlen = aimbs_get8(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1119 sn = aimbs_getstr(bs, snlen); |
2086 | 1120 |
7167 | 1121 tlvlist = aim_tlvlist_read(bs); |
2086 | 1122 |
7167 | 1123 if (aim_tlv_gettlv(tlvlist, 0x0003, 1)) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1124 icbmflags |= AIM_IMFLAGS_ACK; |
7167 | 1125 if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1126 icbmflags |= AIM_IMFLAGS_AWAY; |
2086 | 1127 |
7167 | 1128 if ((msgblock = aim_tlv_gettlv(tlvlist, 0x0002, 1))) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1129 aim_bstream_t mbs; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1130 int featurelen, msglen; |
2086 | 1131 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1132 aim_bstream_init(&mbs, msgblock->value, msgblock->length); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1133 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1134 aimbs_get8(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1135 aimbs_get8(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1136 for (featurelen = aimbs_get16(&mbs); featurelen; featurelen--) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1137 aimbs_get8(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1138 aimbs_get8(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1139 aimbs_get8(&mbs); |
2086 | 1140 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1141 msglen = aimbs_get16(&mbs) - 4; /* final block length */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1142 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1143 flag1 = aimbs_get16(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1144 flag2 = aimbs_get16(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1145 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1146 msg = aimbs_getstr(&mbs, msglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1147 } |
2086 | 1148 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1149 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1150 ret = userfunc(sess, rx, channel, sn, msg, icbmflags, flag1, flag2); |
2086 | 1151 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1152 free(sn); |
7167 | 1153 aim_tlvlist_free(&tlvlist); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1154 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1155 return ret; |
2086 | 1156 } |
1157 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1158 /* |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1159 * Ahh, the joys of nearly ridiculous over-engineering. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1160 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1161 * Not only do AIM ICBM's support multiple channels. Not only do they |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1162 * support multiple character sets. But they support multiple character |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1163 * sets / encodings within the same ICBM. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1164 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1165 * These multipart messages allow for complex space savings techniques, which |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1166 * seem utterly unnecessary by today's standards. In fact, there is only |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1167 * one client still in popular use that still uses this method: AOL for the |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1168 * Macintosh, Version 5.0. Obscure, yes, I know. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1169 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1170 * In modern (non-"legacy") clients, if the user tries to send a character |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1171 * that is not ISO-8859-1 or ASCII, the client will send the entire message |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1172 * as UNICODE, meaning that every character in the message will occupy the |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1173 * full 16 bit UNICODE field, even if the high order byte would be zero. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1174 * Multipart messages prevent this wasted space by allowing the client to |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1175 * only send the characters in UNICODE that need to be sent that way, and |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1176 * the rest of the message can be sent in whatever the native character |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1177 * set is (probably ASCII). |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1178 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1179 * An important note is that sections will be displayed in the order that |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1180 * they appear in the ICBM. There is no facility for merging or rearranging |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1181 * sections at run time. So if you have, say, ASCII then UNICODE then ASCII, |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1182 * you must supply two ASCII sections with a UNICODE in the middle, and incur |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1183 * the associated overhead. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1184 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1185 * Normally I would have laughed and given a firm 'no' to supporting this |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1186 * seldom-used feature, but something is attracting me to it. In the future, |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1187 * it may be possible to abuse this to send mixed-media messages to other |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1188 * open source clients (like encryption or something) -- see faimtest for |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1189 * examples of how to do this. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1190 * |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8708
diff
changeset
|
1191 * I would definitely recommend avoiding this feature unless you really |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1192 * know what you are doing, and/or you have something neat to do with it. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1193 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1194 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1195 faim_export int aim_mpmsg_init(aim_session_t *sess, aim_mpmsg_t *mpm) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1196 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1197 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1198 memset(mpm, 0, sizeof(aim_mpmsg_t)); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1199 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1200 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1201 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1202 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1203 static int mpmsg_addsection(aim_session_t *sess, aim_mpmsg_t *mpm, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1204 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1205 aim_mpmsg_section_t *sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1206 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1207 if (!(sec = malloc(sizeof(aim_mpmsg_section_t)))) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1208 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1209 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1210 sec->charset = charset; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1211 sec->charsubset = charsubset; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1212 sec->data = data; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1213 sec->datalen = datalen; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1214 sec->next = NULL; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1215 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1216 if (!mpm->parts) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1217 mpm->parts = sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1218 else { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1219 aim_mpmsg_section_t *cur; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1220 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1221 for (cur = mpm->parts; cur->next; cur = cur->next) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1222 ; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1223 cur->next = sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1224 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1225 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1226 mpm->numparts++; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1227 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1228 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1229 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1230 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1231 faim_export int aim_mpmsg_addraw(aim_session_t *sess, aim_mpmsg_t *mpm, fu16_t charset, fu16_t charsubset, const fu8_t *data, fu16_t datalen) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1232 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1233 fu8_t *dup; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1234 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1235 if (!(dup = malloc(datalen))) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1236 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1237 memcpy(dup, data, datalen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1238 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1239 if (mpmsg_addsection(sess, mpm, charset, charsubset, dup, datalen) == -1) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1240 free(dup); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1241 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1242 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1243 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1244 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1245 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1246 |
4617 | 1247 /* XXX - should provide a way of saying ISO-8859-1 specifically */ |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1248 faim_export int aim_mpmsg_addascii(aim_session_t *sess, aim_mpmsg_t *mpm, const char *ascii) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1249 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1250 fu8_t *dup; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1251 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1252 if (!(dup = strdup(ascii))) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1253 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1254 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1255 if (mpmsg_addsection(sess, mpm, 0x0000, 0x0000, dup, strlen(ascii)) == -1) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1256 free(dup); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1257 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1258 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1259 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1260 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1261 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1262 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1263 faim_export int aim_mpmsg_addunicode(aim_session_t *sess, aim_mpmsg_t *mpm, const fu16_t *unicode, fu16_t unicodelen) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1264 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1265 fu8_t *buf; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1266 aim_bstream_t bs; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1267 int i; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1268 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1269 if (!(buf = malloc(unicodelen * 2))) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1270 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1271 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1272 aim_bstream_init(&bs, buf, unicodelen * 2); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1273 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1274 /* We assume unicode is in /host/ byte order -- convert to network */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1275 for (i = 0; i < unicodelen; i++) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1276 aimbs_put16(&bs, unicode[i]); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1277 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1278 if (mpmsg_addsection(sess, mpm, 0x0002, 0x0000, buf, aim_bstream_curpos(&bs)) == -1) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1279 free(buf); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1280 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1281 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1282 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1283 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1284 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1285 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1286 faim_export void aim_mpmsg_free(aim_session_t *sess, aim_mpmsg_t *mpm) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1287 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1288 aim_mpmsg_section_t *cur; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1289 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1290 for (cur = mpm->parts; cur; ) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1291 aim_mpmsg_section_t *tmp; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1292 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1293 tmp = cur->next; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1294 free(cur->data); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1295 free(cur); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1296 cur = tmp; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1297 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1298 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1299 mpm->numparts = 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1300 mpm->parts = NULL; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1301 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1302 return; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1303 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1304 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1305 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1306 * Start by building the multipart structures, then pick the first |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1307 * human-readable section and stuff it into args->msg so no one gets |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1308 * suspicious. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1309 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1310 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1311 static int incomingim_ch1_parsemsgs(aim_session_t *sess, fu8_t *data, int len, struct aim_incomingim_ch1_args *args) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1312 { |
9806 | 1313 /* Should this be ASCII -> UNICODE -> Custom */ |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1314 static const fu16_t charsetpri[] = { |
9826 | 1315 AIM_CHARSET_ASCII, /* ASCII first */ |
1316 AIM_CHARSET_CUSTOM, /* then ISO-8859-1 */ | |
1317 AIM_CHARSET_UNICODE, /* UNICODE as last resort */ | |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1318 }; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1319 static const int charsetpricount = 3; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1320 int i; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1321 aim_bstream_t mbs; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1322 aim_mpmsg_section_t *sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1323 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1324 aim_bstream_init(&mbs, data, len); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1325 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1326 while (aim_bstream_empty(&mbs)) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1327 fu16_t msglen, flag1, flag2; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1328 fu8_t *msgbuf; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1329 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1330 aimbs_get8(&mbs); /* 01 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1331 aimbs_get8(&mbs); /* 01 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1332 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1333 /* Message string length, including character set info. */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1334 msglen = aimbs_get16(&mbs); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1335 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1336 /* Character set info */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1337 flag1 = aimbs_get16(&mbs); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1338 flag2 = aimbs_get16(&mbs); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1339 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1340 /* Message. */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1341 msglen -= 4; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1342 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1343 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1344 * For now, we don't care what the encoding is. Just copy |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1345 * it into a multipart struct and deal with it later. However, |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1346 * always pad the ending with a NULL. This makes it easier |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1347 * to treat ASCII sections as strings. It won't matter for |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1348 * UNICODE or binary data, as you should never read past |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1349 * the specified data length, which will not include the pad. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1350 * |
4617 | 1351 * XXX - There's an API bug here. For sending, the UNICODE is |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1352 * given in host byte order (aim_mpmsg_addunicode), but here |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1353 * the received messages are given in network byte order. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1354 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1355 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1356 msgbuf = aimbs_getstr(&mbs, msglen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1357 mpmsg_addsection(sess, &args->mpmsg, flag1, flag2, msgbuf, msglen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1358 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1359 } /* while */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1360 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1361 args->icbmflags |= AIM_IMFLAGS_MULTIPART; /* always set */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1362 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1363 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1364 * Clients that support multiparts should never use args->msg, as it |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1365 * will point to an arbitrary section. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1366 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1367 * Here, we attempt to provide clients that do not support multipart |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1368 * messages with something to look at -- hopefully a human-readable |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1369 * string. But, failing that, a UNICODE message, or nothing at all. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1370 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1371 * Which means that even if args->msg is NULL, it does not mean the |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1372 * message was blank. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1373 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1374 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1375 for (i = 0; i < charsetpricount; i++) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1376 for (sec = args->mpmsg.parts; sec; sec = sec->next) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1377 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1378 if (sec->charset != charsetpri[i]) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1379 continue; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1380 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1381 /* Great. We found one. Fill it in. */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1382 args->charset = sec->charset; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1383 args->charsubset = sec->charsubset; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1384 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1385 /* Set up the simple flags */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1386 if (args->charsubset == 0x0000) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1387 ; /* standard subencoding? */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1388 else if (args->charsubset == 0x000b) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1389 args->icbmflags |= AIM_IMFLAGS_SUBENC_MACINTOSH; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1390 else if (args->charsubset == 0xffff) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1391 ; /* no subencoding */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1392 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1393 args->msg = sec->data; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1394 args->msglen = sec->datalen; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1395 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1396 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1397 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1398 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1399 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1400 /* No human-readable sections found. Oh well. */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1401 args->charset = args->charsubset = 0xffff; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1402 args->msg = NULL; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1403 args->msglen = 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1404 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1405 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1406 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1407 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2341
diff
changeset
|
1408 static int incomingim_ch1(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, fu16_t channel, aim_userinfo_t *userinfo, aim_bstream_t *bs, fu8_t *cookie) |
2086 | 1409 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1410 fu16_t type, length; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1411 aim_rxcallback_t userfunc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1412 int ret = 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1413 struct aim_incomingim_ch1_args args; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1414 int endpos; |
2086 | 1415 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1416 memset(&args, 0, sizeof(args)); |
2086 | 1417 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1418 aim_mpmsg_init(sess, &args.mpmsg); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1419 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1420 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1421 * This used to be done using tlvchains. For performance reasons, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1422 * I've changed it to process the TLVs in-place. This avoids lots |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1423 * of per-IM memory allocations. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1424 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1425 while (aim_bstream_empty(bs)) { |
2086 | 1426 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1427 type = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1428 length = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1429 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1430 endpos = aim_bstream_curpos(bs) + length; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1431 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1432 if (type == 0x0002) { /* Message Block */ |
2086 | 1433 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1434 /* |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1435 * This TLV consists of the following: |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1436 * - 0501 -- Unknown |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1437 * - Features: Don't know how to interpret these |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1438 * - 0101 -- Unknown |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1439 * - Message |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1440 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1441 */ |
2086 | 1442 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1443 aimbs_get8(bs); /* 05 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1444 aimbs_get8(bs); /* 01 */ |
2086 | 1445 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1446 args.featureslen = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1447 /* XXX XXX this is all evil! */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1448 args.features = bs->data + bs->offset; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1449 aim_bstream_advance(bs, args.featureslen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1450 args.icbmflags |= AIM_IMFLAGS_CUSTOMFEATURES; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1451 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1452 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1453 * The rest of the TLV contains one or more message |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1454 * blocks... |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1455 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1456 incomingim_ch1_parsemsgs(sess, bs->data + bs->offset /* XXX evil!!! */, length - 2 - 2 - args.featureslen, &args); |
2086 | 1457 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1458 } else if (type == 0x0003) { /* Server Ack Requested */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1459 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1460 args.icbmflags |= AIM_IMFLAGS_ACK; |
2086 | 1461 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1462 } else if (type == 0x0004) { /* Message is Auto Response */ |
2086 | 1463 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1464 args.icbmflags |= AIM_IMFLAGS_AWAY; |
2086 | 1465 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
1466 } else if (type == 0x0006) { /* Message was received offline. */ |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
1467 |
4617 | 1468 /* XXX - not sure if this actually gets sent. */ |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
1469 args.icbmflags |= AIM_IMFLAGS_OFFLINE; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
1470 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1471 } else if (type == 0x0008) { /* I-HAVE-A-REALLY-PURTY-ICON Flag */ |
2086 | 1472 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1473 args.iconlen = aimbs_get32(bs); |
2626
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
1474 aimbs_get16(bs); /* 0x0001 */ |
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
1475 args.iconsum = aimbs_get16(bs); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1476 args.iconstamp = aimbs_get32(bs); |
2869 | 1477 |
1478 /* | |
1479 * This looks to be a client bug. MacAIM 4.3 will | |
1480 * send this tag, but with all zero values, in the | |
1481 * first message of a conversation. This makes no | |
1482 * sense whatsoever, so I'm going to say its a bug. | |
1483 * | |
1484 * You really shouldn't advertise a zero-length icon | |
1485 * anyway. | |
1486 * | |
1487 */ | |
1488 if (args.iconlen) | |
1489 args.icbmflags |= AIM_IMFLAGS_HASICON; | |
2086 | 1490 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1491 } else if (type == 0x0009) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1492 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1493 args.icbmflags |= AIM_IMFLAGS_BUDDYREQ; |
2086 | 1494 |
3595 | 1495 } else if (type == 0x000b) { /* Non-direct connect typing notification */ |
1496 | |
1497 args.icbmflags |= AIM_IMFLAGS_TYPINGNOT; | |
1498 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1499 } else if (type == 0x0017) { |
2086 | 1500 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1501 args.extdatalen = length; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1502 args.extdata = aimbs_getraw(bs, args.extdatalen); |
2086 | 1503 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1504 } else { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1505 faimdprintf(sess, 0, "incomingim_ch1: unknown TLV 0x%04x (len %d)\n", type, length); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1506 } |
2086 | 1507 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1508 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1509 * This is here to protect ourselves from ourselves. That |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8708
diff
changeset
|
1510 * is, if something above doesn't completely parse its value |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1511 * section, or, worse, overparses it, this will set the |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1512 * stream where it needs to be in order to land on the next |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1513 * TLV when the loop continues. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1514 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1515 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1516 aim_bstream_setpos(bs, endpos); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1517 } |
2086 | 1518 |
1519 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1520 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1521 ret = userfunc(sess, rx, channel, userinfo, &args); |
2086 | 1522 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1523 aim_mpmsg_free(sess, &args.mpmsg); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1524 free(args.extdata); |
2086 | 1525 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1526 return ret; |
2086 | 1527 } |
1528 | |
2869 | 1529 static void incomingim_ch2_buddylist(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1530 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1531 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1532 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1533 * This goes like this... |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1534 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1535 * group name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1536 * group name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1537 * num of buddies in group |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1538 * buddy name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1539 * buddy name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1540 * buddy name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1541 * buddy name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1542 * ... |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1543 * group name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1544 * group name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1545 * num of buddies in group |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1546 * buddy name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1547 * buddy name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1548 * ... |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1549 * ... |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1550 */ |
2869 | 1551 while (servdata && aim_bstream_empty(servdata)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1552 fu16_t gnlen, numb; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1553 int i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1554 char *gn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1555 |
2869 | 1556 gnlen = aimbs_get16(servdata); |
1557 gn = aimbs_getstr(servdata, gnlen); | |
1558 numb = aimbs_get16(servdata); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1559 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1560 for (i = 0; i < numb; i++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1561 fu16_t bnlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1562 char *bn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1563 |
2869 | 1564 bnlen = aimbs_get16(servdata); |
1565 bn = aimbs_getstr(servdata, bnlen); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1566 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1567 faimdprintf(sess, 0, "got a buddy list from %s: group %s, buddy %s\n", userinfo->sn, gn, bn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1568 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1569 free(bn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1570 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1571 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1572 free(gn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1573 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1574 |
2869 | 1575 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1576 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1577 |
2869 | 1578 static void incomingim_ch2_buddyicon_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) |
2086 | 1579 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1580 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1581 free(args->info.icon.icon); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1582 |
2869 | 1583 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1584 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1585 |
2869 | 1586 static void incomingim_ch2_buddyicon(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1587 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1588 |
2869 | 1589 if (servdata) { |
1590 args->info.icon.checksum = aimbs_get32(servdata); | |
1591 args->info.icon.length = aimbs_get32(servdata); | |
1592 args->info.icon.timestamp = aimbs_get32(servdata); | |
1593 args->info.icon.icon = aimbs_getraw(servdata, args->info.icon.length); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1594 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1595 |
2869 | 1596 args->destructor = (void *)incomingim_ch2_buddyicon_free; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1597 |
2869 | 1598 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1599 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1600 |
2869 | 1601 static void incomingim_ch2_chat_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1602 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1603 |
4617 | 1604 /* XXX - aim_chat_roominfo_free() */ |
2869 | 1605 free(args->info.chat.roominfo.name); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1606 |
2869 | 1607 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1608 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1609 |
2869 | 1610 static void incomingim_ch2_chat(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1611 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1612 |
2869 | 1613 /* |
1614 * Chat room info. | |
1615 */ | |
1616 if (servdata) | |
1617 aim_chat_readroominfo(servdata, &args->info.chat.roominfo); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1618 |
2869 | 1619 args->destructor = (void *)incomingim_ch2_chat_free; |
1620 | |
1621 return; | |
1622 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1623 |
2869 | 1624 static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) |
1625 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1626 |
2869 | 1627 free((char *)args->info.rtfmsg.rtfmsg); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1628 |
2869 | 1629 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1630 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1631 |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1632 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1633 * The relationship between AIM_CAPS_ICQSERVERRELAY and AIM_CAPS_ICQRTF is |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1634 * kind of odd. This sends the client ICQRTF since that is all that I've seen |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1635 * SERVERRELAY used for. |
2869 | 1636 * |
1637 * Note that this is all little-endian. Cringe. | |
1638 * | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1639 */ |
2869 | 1640 static void incomingim_ch2_icqserverrelay(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata) |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1641 { |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1642 fu16_t hdrlen, anslen, msglen; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1643 |
2869 | 1644 hdrlen = aimbs_getle16(servdata); |
1645 aim_bstream_advance(servdata, hdrlen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1646 |
2869 | 1647 hdrlen = aimbs_getle16(servdata); |
1648 aim_bstream_advance(servdata, hdrlen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1649 |
8708 | 1650 args->info.rtfmsg.msgtype = aimbs_getle16(servdata); |
1651 | |
2869 | 1652 anslen = aimbs_getle32(servdata); |
1653 aim_bstream_advance(servdata, anslen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1654 |
2869 | 1655 msglen = aimbs_getle16(servdata); |
1656 args->info.rtfmsg.rtfmsg = aimbs_getstr(servdata, msglen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1657 |
2869 | 1658 args->info.rtfmsg.fgcolor = aimbs_getle32(servdata); |
1659 args->info.rtfmsg.bgcolor = aimbs_getle32(servdata); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1660 |
2869 | 1661 hdrlen = aimbs_getle32(servdata); |
1662 aim_bstream_advance(servdata, hdrlen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1663 |
2869 | 1664 args->destructor = (void *)incomingim_ch2_icqserverrelay_free; |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1665 |
2869 | 1666 return; |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1667 } |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1668 |
3630 | 1669 static void incomingim_ch2_sendfile_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) |
1670 { | |
1671 free(args->info.sendfile.filename); | |
1672 } | |
1673 | |
1674 static void incomingim_ch2_sendfile(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args, aim_bstream_t *servdata) | |
1675 { | |
1676 | |
1677 args->destructor = (void *)incomingim_ch2_sendfile_free; | |
1678 | |
4617 | 1679 /* Maybe there is a better way to tell what kind of sendfile |
1680 * this is? Maybe TLV t(000a)? */ | |
1681 if (servdata) { /* Someone is sending us a file */ | |
3952 | 1682 int flen; |
1683 | |
3771 | 1684 /* subtype is one of AIM_OFT_SUBTYPE_* */ |
1685 args->info.sendfile.subtype = aimbs_get16(servdata); | |
3630 | 1686 args->info.sendfile.totfiles = aimbs_get16(servdata); |
1687 args->info.sendfile.totsize = aimbs_get32(servdata); | |
3952 | 1688 |
4617 | 1689 /* |
1690 * I hope to God I'm right when I guess that there is a | |
1691 * 32 char max filename length for single files. I think | |
1692 * OFT tends to do that. Gotta love inconsistency. I saw | |
1693 * a 26 byte filename? | |
1694 */ | |
1695 /* AAA - create an aimbs_getnullstr function (don't anymore)(maybe) */ | |
3952 | 1696 /* Use an inelegant way of getting the null-terminated filename, |
1697 * since there's no easy bstream routine. */ | |
1698 for (flen = 0; aimbs_get8(servdata); flen++); | |
1699 aim_bstream_advance(servdata, -flen -1); | |
1700 args->info.sendfile.filename = aimbs_getstr(servdata, flen); | |
1701 | |
1702 /* There is sometimes more after the null-terminated filename, | |
1703 * but I'm unsure of its format. */ | |
4617 | 1704 /* I don't believe him. */ |
3630 | 1705 } |
1706 | |
1707 return; | |
1708 } | |
1709 | |
2869 | 1710 typedef void (*ch2_args_destructor_t)(aim_session_t *sess, struct aim_incomingim_ch2_args *args); |
1711 | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2341
diff
changeset
|
1712 static int incomingim_ch2(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, fu16_t channel, aim_userinfo_t *userinfo, aim_tlvlist_t *tlvlist, fu8_t *cookie) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1713 { |
2869 | 1714 aim_rxcallback_t userfunc; |
1715 aim_tlv_t *block1, *servdatatlv; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1716 aim_tlvlist_t *list2; |
2869 | 1717 struct aim_incomingim_ch2_args args; |
1718 aim_bstream_t bbs, sdbs, *sdbsptr = NULL; | |
1719 fu8_t *cookie2; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1720 int ret = 0; |
2869 | 1721 |
4898 | 1722 char proxyip[30] = {""}; |
1723 char clientip[30] = {""}; | |
2869 | 1724 char verifiedip[30] = {""}; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1725 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1726 memset(&args, 0, sizeof(args)); |
2086 | 1727 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1728 /* |
8978 | 1729 * There's another block of TLVs embedded in the type 5 here. |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1730 */ |
7167 | 1731 block1 = aim_tlv_gettlv(tlvlist, 0x0005, 1); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1732 aim_bstream_init(&bbs, block1->value, block1->length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1733 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1734 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1735 * First two bytes represent the status of the connection. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1736 * |
3771 | 1737 * 0 is a request, 1 is a cancel, 2 is an accept |
8978 | 1738 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1739 args.status = aimbs_get16(&bbs); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1740 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1741 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1742 * Next comes the cookie. Should match the ICBM cookie. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1743 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1744 cookie2 = aimbs_getraw(&bbs, 8); |
8978 | 1745 if (memcmp(cookie, cookie2, 8) != 0) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1746 faimdprintf(sess, 0, "rend: warning cookies don't match!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1747 memcpy(args.cookie, cookie2, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1748 free(cookie2); |
2086 | 1749 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1750 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1751 * The next 16bytes are a capability block so we can |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1752 * identify what type of rendezvous this is. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1753 */ |
7334 | 1754 args.reqclass = aim_locate_getcaps(sess, &bbs, 0x10); |
2086 | 1755 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1756 /* |
2196
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1757 * What follows may be TLVs or nothing, depending on the |
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1758 * purpose of the message. |
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1759 * |
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1760 * Ack packets for instance have nothing more to them. |
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1761 */ |
7167 | 1762 list2 = aim_tlvlist_read(&bbs); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1763 |
2869 | 1764 /* |
4898 | 1765 * IP address to proxy the file transfer through. |
4617 | 1766 * |
1767 * XXX - I don't like this. Maybe just read in an int? Or inet_ntoa... | |
2869 | 1768 */ |
7167 | 1769 if (aim_tlv_gettlv(list2, 0x0002, 1)) { |
2869 | 1770 aim_tlv_t *iptlv; |
1771 | |
7167 | 1772 iptlv = aim_tlv_gettlv(list2, 0x0002, 1); |
4901 | 1773 if (iptlv->length == 4) |
7495 | 1774 snprintf(proxyip, sizeof(proxyip), "%hhu.%hhu.%hhu.%hhu", |
4901 | 1775 iptlv->value[0], iptlv->value[1], |
1776 iptlv->value[2], iptlv->value[3]); | |
2869 | 1777 } |
1778 | |
1779 /* | |
4898 | 1780 * IP address from the perspective of the client. |
2869 | 1781 */ |
7167 | 1782 if (aim_tlv_gettlv(list2, 0x0003, 1)) { |
2869 | 1783 aim_tlv_t *iptlv; |
1784 | |
7167 | 1785 iptlv = aim_tlv_gettlv(list2, 0x0003, 1); |
4901 | 1786 if (iptlv->length == 4) |
7495 | 1787 snprintf(clientip, sizeof(clientip), "%hhu.%hhu.%hhu.%hhu", |
4901 | 1788 iptlv->value[0], iptlv->value[1], |
1789 iptlv->value[2], iptlv->value[3]); | |
2869 | 1790 } |
2086 | 1791 |
2869 | 1792 /* |
1793 * Verified IP address (from the perspective of Oscar). | |
1794 * | |
1795 * This is added by the server. | |
1796 */ | |
7167 | 1797 if (aim_tlv_gettlv(list2, 0x0004, 1)) { |
2869 | 1798 aim_tlv_t *iptlv; |
2086 | 1799 |
7167 | 1800 iptlv = aim_tlv_gettlv(list2, 0x0004, 1); |
4901 | 1801 if (iptlv->length == 4) |
7495 | 1802 snprintf(verifiedip, sizeof(verifiedip), "%hhu.%hhu.%hhu.%hhu", |
4901 | 1803 iptlv->value[0], iptlv->value[1], |
1804 iptlv->value[2], iptlv->value[3]); | |
2869 | 1805 } |
2086 | 1806 |
2869 | 1807 /* |
1808 * Port number for something. | |
1809 */ | |
7167 | 1810 if (aim_tlv_gettlv(list2, 0x0005, 1)) |
1811 args.port = aim_tlv_get16(list2, 0x0005, 1); | |
2086 | 1812 |
2869 | 1813 /* |
8708 | 1814 * Something to do with ft? -- two bytes |
4617 | 1815 * 0x0001 - "I want to send you this file" |
1816 * 0x0002 - "I will accept this file from you" | |
8708 | 1817 * 0x0002 - Also used in ICQ Lite Beta 4.0 URLs |
4617 | 1818 */ |
7167 | 1819 if (aim_tlv_gettlv(list2, 0x000a, 1)) |
4617 | 1820 ; |
1821 | |
1822 /* | |
2869 | 1823 * Error code. |
1824 */ | |
7167 | 1825 if (aim_tlv_gettlv(list2, 0x000b, 1)) |
1826 args.errorcode = aim_tlv_get16(list2, 0x000b, 1); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1827 |
2869 | 1828 /* |
1829 * Invitation message / chat description. | |
1830 */ | |
9933 | 1831 if (aim_tlv_gettlv(list2, 0x000c, 1)) { |
7167 | 1832 args.msg = aim_tlv_getstr(list2, 0x000c, 1); |
9933 | 1833 args.msglen = aim_tlv_getlength(list2, 0x000c, 1); |
1834 } | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1835 |
2869 | 1836 /* |
1837 * Character set. | |
1838 */ | |
7167 | 1839 if (aim_tlv_gettlv(list2, 0x000d, 1)) |
1840 args.encoding = aim_tlv_getstr(list2, 0x000d, 1); | |
2869 | 1841 |
1842 /* | |
1843 * Language. | |
1844 */ | |
7167 | 1845 if (aim_tlv_gettlv(list2, 0x000e, 1)) |
1846 args.language = aim_tlv_getstr(list2, 0x000e, 1); | |
2869 | 1847 |
4898 | 1848 /* |
1849 * Unknown -- no value | |
5146 | 1850 * |
1851 * Maybe means we should connect directly to transfer the file? | |
8708 | 1852 * Also used in ICQ Lite Beta 4.0 URLs. Also empty. |
4898 | 1853 */ |
7167 | 1854 if (aim_tlv_gettlv(list2, 0x000f, 1)) |
2869 | 1855 ; |
1856 | |
4898 | 1857 /* |
1858 * Unknown -- no value | |
1859 * | |
1860 * Maybe means we should proxy the file transfer through an AIM server? | |
1861 */ | |
7167 | 1862 if (aim_tlv_gettlv(list2, 0x0010, 1)) |
4898 | 1863 ; |
1864 | |
1865 if (strlen(proxyip)) | |
1866 args.proxyip = (char *)proxyip; | |
1867 if (strlen(clientip)) | |
1868 args.clientip = (char *)clientip; | |
2869 | 1869 if (strlen(verifiedip)) |
1870 args.verifiedip = (char *)verifiedip; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1871 |
2869 | 1872 /* |
4617 | 1873 * This must be present in PROPOSALs, but will probably not |
8708 | 1874 * exist in CANCELs and ACCEPTs. Also exists in ICQ Lite |
1875 * Beta 4.0 URLs (AIM_CAPS_ICQSERVERRELAY). | |
2869 | 1876 * |
1877 * Service Data blocks are module-specific in format. | |
1878 */ | |
7167 | 1879 if ((servdatatlv = aim_tlv_gettlv(list2, 0x2711 /* 10001 */, 1))) { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1880 |
2869 | 1881 aim_bstream_init(&sdbs, servdatatlv->value, servdatatlv->length); |
1882 sdbsptr = &sdbs; | |
2086 | 1883 } |
1884 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1885 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1886 * The rest of the handling depends on what type it is. |
2869 | 1887 * |
1888 * Not all of them have special handling (yet). | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1889 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1890 if (args.reqclass & AIM_CAPS_BUDDYICON) |
2869 | 1891 incomingim_ch2_buddyicon(sess, mod, rx, snac, userinfo, &args, sdbsptr); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1892 else if (args.reqclass & AIM_CAPS_SENDBUDDYLIST) |
2869 | 1893 incomingim_ch2_buddylist(sess, mod, rx, snac, userinfo, &args, sdbsptr); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1894 else if (args.reqclass & AIM_CAPS_CHAT) |
2869 | 1895 incomingim_ch2_chat(sess, mod, rx, snac, userinfo, &args, sdbsptr); |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1896 else if (args.reqclass & AIM_CAPS_ICQSERVERRELAY) |
2869 | 1897 incomingim_ch2_icqserverrelay(sess, mod, rx, snac, userinfo, &args, sdbsptr); |
3630 | 1898 else if (args.reqclass & AIM_CAPS_SENDFILE) |
1899 incomingim_ch2_sendfile(sess, mod, rx, snac, userinfo, &args, sdbsptr); | |
2869 | 1900 |
1901 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
1902 ret = userfunc(sess, rx, channel, userinfo, &args); | |
1903 | |
1904 | |
1905 if (args.destructor) | |
1906 ((ch2_args_destructor_t)args.destructor)(sess, &args); | |
1907 | |
1908 free((char *)args.msg); | |
1909 free((char *)args.encoding); | |
1910 free((char *)args.language); | |
2086 | 1911 |
7167 | 1912 aim_tlvlist_free(&list2); |
2086 | 1913 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1914 return ret; |
2086 | 1915 } |
1916 | |
3141 | 1917 static int incomingim_ch4(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, fu16_t channel, aim_userinfo_t *userinfo, aim_tlvlist_t *tlvlist, fu8_t *cookie) |
1918 { | |
1919 aim_bstream_t meat; | |
1920 aim_rxcallback_t userfunc; | |
1921 aim_tlv_t *block; | |
1922 struct aim_incomingim_ch4_args args; | |
3159 | 1923 int ret = 0; |
3141 | 1924 |
1925 /* | |
1926 * Make a bstream for the meaty part. Yum. Meat. | |
1927 */ | |
7167 | 1928 if (!(block = aim_tlv_gettlv(tlvlist, 0x0005, 1))) |
3141 | 1929 return -1; |
1930 aim_bstream_init(&meat, block->value, block->length); | |
1931 | |
1932 args.uin = aimbs_getle32(&meat); | |
4173 | 1933 args.type = aimbs_getle8(&meat); |
1934 args.flags = aimbs_getle8(&meat); | |
4076 | 1935 args.msglen = aimbs_getle16(&meat); |
1936 args.msg = aimbs_getraw(&meat, args.msglen); | |
3141 | 1937 |
1938 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
1939 ret = userfunc(sess, rx, channel, userinfo, &args); | |
1940 | |
1941 free(args.msg); | |
1942 | |
1943 return ret; | |
1944 } | |
1945 | |
2086 | 1946 /* |
3952 | 1947 * Subtype 0x0007 |
1948 * | |
2086 | 1949 * It can easily be said that parsing ICBMs is THE single |
1950 * most difficult thing to do in the in AIM protocol. In | |
1951 * fact, I think I just did say that. | |
1952 * | |
1953 * Below is the best damned solution I've come up with | |
1954 * over the past sixteen months of battling with it. This | |
1955 * can parse both away and normal messages from every client | |
1956 * I have access to. Its not fast, its not clean. But it works. | |
1957 * | |
1958 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1959 static int incomingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 1960 { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1961 int i, ret = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1962 fu8_t cookie[8]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1963 fu16_t channel; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2341
diff
changeset
|
1964 aim_userinfo_t userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1965 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2341
diff
changeset
|
1966 memset(&userinfo, 0x00, sizeof(aim_userinfo_t)); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1967 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1968 /* |
8225 | 1969 * Read ICBM Cookie. |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1970 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1971 for (i = 0; i < 8; i++) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1972 cookie[i] = aimbs_get8(bs); |
2086 | 1973 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1974 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1975 * Channel ID. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1976 * |
4617 | 1977 * Channel 0x0001 is the message channel. It is |
1978 * used to send basic ICBMs. | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1979 * |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8708
diff
changeset
|
1980 * Channel 0x0002 is the Rendezvous channel, which |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1981 * is where Chat Invitiations and various client-client |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1982 * connection negotiations come from. |
3141 | 1983 * |
4617 | 1984 * Channel 0x0003 is used for chat messages. |
1985 * | |
3141 | 1986 * Channel 0x0004 is used for ICQ authorization, or |
1987 * possibly any system notice. | |
1988 * | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1989 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1990 channel = aimbs_get16(bs); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1991 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1992 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1993 * Extract the standard user info block. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1994 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1995 * Note that although this contains TLVs that appear contiguous |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1996 * with the TLVs read below, they are two different pieces. The |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1997 * userinfo block contains the number of TLVs that contain user |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8708
diff
changeset
|
1998 * information, the rest are not even though there is no separation. |
5836 | 1999 * You can start reading the message TLVs after aim_info_extract() |
2000 * parses out the standard userinfo block. | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2001 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2002 * That also means that TLV types can be duplicated between the |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2003 * userinfo block and the rest of the message, however there should |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2004 * never be two TLVs of the same type in one block. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2005 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2006 */ |
5836 | 2007 aim_info_extract(sess, bs, &userinfo); |
2086 | 2008 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2009 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2010 * From here on, its depends on what channel we're on. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2011 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2012 * Technically all channels have a TLV list have this, however, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2013 * for the common channel 1 case, in-place parsing is used for |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2014 * performance reasons (less memory allocation). |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2015 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2016 if (channel == 1) { |
2086 | 2017 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2018 ret = incomingim_ch1(sess, mod, rx, snac, channel, &userinfo, bs, cookie); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2019 |
2869 | 2020 } else if (channel == 2) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2021 aim_tlvlist_t *tlvlist; |
2086 | 2022 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2023 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2024 * Read block of TLVs (not including the userinfo data). All |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2025 * further data is derived from what is parsed here. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2026 */ |
7167 | 2027 tlvlist = aim_tlvlist_read(bs); |
2086 | 2028 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2029 ret = incomingim_ch2(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie); |
2086 | 2030 |
7167 | 2031 aim_tlvlist_free(&tlvlist); |
2869 | 2032 |
3141 | 2033 } else if (channel == 4) { |
2034 aim_tlvlist_t *tlvlist; | |
2035 | |
7167 | 2036 tlvlist = aim_tlvlist_read(bs); |
3141 | 2037 ret = incomingim_ch4(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie); |
7167 | 2038 aim_tlvlist_free(&tlvlist); |
3141 | 2039 |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
2040 } else { |
5836 | 2041 faimdprintf(sess, 0, "icbm: ICBM received on an unsupported channel. Ignoring. (chan = %04x)\n", channel); |
2042 } | |
2869 | 2043 |
5836 | 2044 aim_info_free(&userinfo); |
2086 | 2045 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2046 return ret; |
2086 | 2047 } |
2048 | |
2049 /* | |
4617 | 2050 * Subtype 0x0008 - Send a warning to sn. |
3952 | 2051 * |
2052 * Flags: | |
2053 * AIM_WARN_ANON Send as an anonymous (doesn't count as much) | |
2054 * | |
2055 * returns -1 on error (couldn't alloc packet), 0 on success. | |
2056 * | |
2057 */ | |
4617 | 2058 faim_export int aim_im_warn(aim_session_t *sess, aim_conn_t *conn, const char *sn, fu32_t flags) |
3952 | 2059 { |
2060 aim_frame_t *fr; | |
2061 aim_snacid_t snacid; | |
2062 | |
4617 | 2063 if (!sess || !conn || !sn) |
2064 return -EINVAL; | |
2065 | |
2066 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, strlen(sn)+13))) | |
3952 | 2067 return -ENOMEM; |
2068 | |
4617 | 2069 snacid = aim_cachesnac(sess, 0x0004, 0x0008, 0x0000, sn, strlen(sn)+1); |
3952 | 2070 aim_putsnac(&fr->data, 0x0004, 0x0008, 0x0000, snacid); |
2071 | |
4617 | 2072 aimbs_put16(&fr->data, (flags & AIM_WARN_ANON) ? 0x0001 : 0x0000); |
2073 aimbs_put8(&fr->data, strlen(sn)); | |
2074 aimbs_putraw(&fr->data, sn, strlen(sn)); | |
3952 | 2075 |
2076 aim_tx_enqueue(sess, fr); | |
2077 | |
2078 return 0; | |
2079 } | |
2080 | |
2081 /* Subtype 0x000a */ | |
2082 static int missedcall(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
2083 { | |
2084 int ret = 0; | |
2085 aim_rxcallback_t userfunc; | |
2086 fu16_t channel, nummissed, reason; | |
2087 aim_userinfo_t userinfo; | |
2088 | |
2089 while (aim_bstream_empty(bs)) { | |
2090 | |
2091 channel = aimbs_get16(bs); | |
5836 | 2092 aim_info_extract(sess, bs, &userinfo); |
3952 | 2093 nummissed = aimbs_get16(bs); |
2094 reason = aimbs_get16(bs); | |
2095 | |
2096 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
2097 ret = userfunc(sess, rx, channel, &userinfo, nummissed, reason); | |
5836 | 2098 |
2099 aim_info_free(&userinfo); | |
3952 | 2100 } |
2101 | |
2102 return ret; | |
2103 } | |
2104 | |
2105 /* | |
2106 * Subtype 0x000b | |
2107 * | |
2086 | 2108 * Possible codes: |
2109 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support" | |
2110 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer" | |
2111 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers" | |
2112 * | |
2113 */ | |
4617 | 2114 faim_export int aim_im_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, fu16_t code) |
2086 | 2115 { |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
2116 aim_conn_t *conn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2117 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2118 aim_snacid_t snacid; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2119 aim_tlvlist_t *tl = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2120 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
2121 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
2122 return -EINVAL; |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
2123 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2124 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sender)+6))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2125 return -ENOMEM; |
2086 | 2126 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2127 snacid = aim_cachesnac(sess, 0x0004, 0x000b, 0x0000, NULL, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2128 aim_putsnac(&fr->data, 0x0004, 0x000b, 0x0000, snacid); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2129 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2130 aimbs_putraw(&fr->data, cookie, 8); |
2086 | 2131 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2132 aimbs_put16(&fr->data, 0x0002); /* channel */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2133 aimbs_put8(&fr->data, strlen(sender)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2134 aimbs_putraw(&fr->data, sender, strlen(sender)); |
2086 | 2135 |
7167 | 2136 aim_tlvlist_add_16(&tl, 0x0003, code); |
2137 aim_tlvlist_write(&fr->data, &tl); | |
2138 aim_tlvlist_free(&tl); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2139 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2140 aim_tx_enqueue(sess, fr); |
2086 | 2141 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2142 return 0; |
2086 | 2143 } |
2144 | |
2145 /* | |
3952 | 2146 * Subtype 0x000b - Receive the response from an ICQ status message request. |
2086 | 2147 * |
3952 | 2148 * This contains the ICQ status message. Go figure. |
2149 * | |
3212 | 2150 */ |
2151 static int clientautoresp(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2152 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2153 int ret = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2154 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2155 fu16_t channel, reason; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2156 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2157 fu8_t *ck, snlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2158 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2159 ck = aimbs_getraw(bs, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2160 channel = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2161 snlen = aimbs_get8(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2162 sn = aimbs_getstr(bs, snlen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2163 reason = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2164 |
3952 | 2165 if (channel == 0x0002) { /* File transfer declined */ |
4617 | 2166 aimbs_get16(bs); /* Unknown */ |
2167 aimbs_get16(bs); /* Unknown */ | |
3630 | 2168 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
2169 ret = userfunc(sess, rx, channel, sn, reason, ck); | |
3952 | 2170 } else if (channel == 0x0004) { /* ICQ message */ |
2171 switch (reason) { | |
2172 case 0x0003: { /* ICQ status message. Maybe other stuff too, you never know with these people. */ | |
2173 fu8_t statusmsgtype, *msg; | |
2174 fu16_t len; | |
2175 fu32_t state; | |
2176 | |
2177 len = aimbs_getle16(bs); /* Should be 0x001b */ | |
2178 aim_bstream_advance(bs, len); /* Unknown */ | |
2179 | |
2180 len = aimbs_getle16(bs); /* Should be 0x000e */ | |
2181 aim_bstream_advance(bs, len); /* Unknown */ | |
2182 | |
2183 statusmsgtype = aimbs_getle8(bs); | |
2184 switch (statusmsgtype) { | |
2185 case 0xe8: | |
2186 state = AIM_ICQ_STATE_AWAY; | |
2187 break; | |
2188 case 0xe9: | |
2189 state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY; | |
2190 break; | |
2191 case 0xea: | |
2192 state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_OUT; | |
2193 break; | |
2194 case 0xeb: | |
2195 state = AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY; | |
2196 break; | |
2197 case 0xec: | |
2198 state = AIM_ICQ_STATE_CHAT; | |
2199 break; | |
2200 default: | |
2201 state = 0; | |
2202 break; | |
2203 } | |
2204 | |
2205 aimbs_getle8(bs); /* Unknown - 0x03 Maybe this means this is an auto-reply */ | |
2206 aimbs_getle16(bs); /* Unknown - 0x0000 */ | |
2207 aimbs_getle16(bs); /* Unknown - 0x0000 */ | |
2208 | |
2209 len = aimbs_getle16(bs); | |
2210 msg = aimbs_getraw(bs, len); | |
2211 | |
2212 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
2213 ret = userfunc(sess, rx, channel, sn, reason, state, msg); | |
2214 | |
2215 free(msg); | |
2216 } break; | |
2217 | |
2218 default: { | |
2219 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
2220 ret = userfunc(sess, rx, channel, sn, reason); | |
2221 } break; | |
2222 } /* end switch */ | |
3630 | 2223 } |
2224 | |
2341
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2225 free(ck); |
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2226 free(sn); |
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2227 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2228 return ret; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2229 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2230 |
4617 | 2231 /* |
2232 * Subtype 0x000c - Receive an ack after sending an ICBM. | |
2233 * | |
2234 * You have to have send the message with the AIM_IMFLAGS_ACK flag set | |
2235 * (TLV t(0003)). The ack contains the ICBM header of the message you | |
2236 * sent. | |
2237 * | |
2238 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2239 static int msgack(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 2240 { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2241 aim_rxcallback_t userfunc; |
4617 | 2242 fu16_t ch; |
2243 fu8_t *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2244 char *sn; |
2341
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2245 int ret = 0; |
2086 | 2246 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2247 ck = aimbs_getraw(bs, 8); |
4617 | 2248 ch = aimbs_get16(bs); |
2249 sn = aimbs_getstr(bs, aimbs_get8(bs)); | |
2086 | 2250 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2251 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
4617 | 2252 ret = userfunc(sess, rx, ch, sn); |
2086 | 2253 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2254 free(sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2255 free(ck); |
2086 | 2256 |
2341
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2257 return ret; |
2086 | 2258 } |
2259 | |
3595 | 2260 /* |
3952 | 2261 * Subtype 0x0014 - Send a mini typing notification (mtn) packet. |
2262 * | |
2263 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer, | |
2264 * and Gaim 0.60 and newer. | |
2265 * | |
3595 | 2266 */ |
6059 | 2267 faim_export int aim_im_sendmtn(aim_session_t *sess, fu16_t type1, const char *sn, fu16_t type2) |
3595 | 2268 { |
2269 aim_conn_t *conn; | |
2270 aim_frame_t *fr; | |
2271 aim_snacid_t snacid; | |
2272 | |
2273 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0002))) | |
2274 return -EINVAL; | |
2275 | |
2276 if (!sn) | |
2277 return -EINVAL; | |
2278 | |
2279 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+11+strlen(sn)+2))) | |
2280 return -ENOMEM; | |
2281 | |
2282 snacid = aim_cachesnac(sess, 0x0004, 0x0014, 0x0000, NULL, 0); | |
2283 aim_putsnac(&fr->data, 0x0004, 0x0014, 0x0000, snacid); | |
2284 | |
2285 /* | |
2286 * 8 days of light | |
2287 * Er, that is to say, 8 bytes of 0's | |
2288 */ | |
2289 aimbs_put16(&fr->data, 0x0000); | |
2290 aimbs_put16(&fr->data, 0x0000); | |
2291 aimbs_put16(&fr->data, 0x0000); | |
2292 aimbs_put16(&fr->data, 0x0000); | |
2293 | |
2294 /* | |
2295 * Type 1 (should be 0x0001 for mtn) | |
2296 */ | |
2297 aimbs_put16(&fr->data, type1); | |
2298 | |
2299 /* | |
2300 * Dest sn | |
2301 */ | |
2302 aimbs_put8(&fr->data, strlen(sn)); | |
2303 aimbs_putraw(&fr->data, sn, strlen(sn)); | |
2304 | |
2305 /* | |
2306 * Type 2 (should be 0x0000, 0x0001, or 0x0002 for mtn) | |
2307 */ | |
2308 aimbs_put16(&fr->data, type2); | |
2309 | |
2310 aim_tx_enqueue(sess, fr); | |
2311 | |
2312 return 0; | |
2313 } | |
2314 | |
2315 /* | |
3952 | 2316 * Subtype 0x0014 - Receive a mini typing notification (mtn) packet. |
2317 * | |
2318 * This is supported by winaim5 and newer, MacAIM bleh and newer, iChat bleh and newer, | |
2319 * and Gaim 0.60 and newer. | |
2320 * | |
3595 | 2321 */ |
2322 static int mtn_receive(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
2323 { | |
2324 int ret = 0; | |
2325 aim_rxcallback_t userfunc; | |
2326 char *sn; | |
2327 fu8_t snlen; | |
2328 fu16_t type1, type2; | |
2329 | |
2330 aim_bstream_advance(bs, 8); /* Unknown - All 0's */ | |
2331 type1 = aimbs_get16(bs); | |
2332 snlen = aimbs_get8(bs); | |
2333 sn = aimbs_getstr(bs, snlen); | |
2334 type2 = aimbs_get16(bs); | |
2335 | |
2336 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
2337 ret = userfunc(sess, rx, type1, sn, type2); | |
2338 | |
2339 free(sn); | |
2340 | |
2341 return ret; | |
2342 } | |
2343 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2344 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2345 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2346 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2347 if (snac->subtype == 0x0005) |
4617 | 2348 return aim_im_paraminfo(sess, mod, rx, snac, bs); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2349 else if (snac->subtype == 0x0006) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2350 return outgoingim(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2351 else if (snac->subtype == 0x0007) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2352 return incomingim(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2353 else if (snac->subtype == 0x000a) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2354 return missedcall(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2355 else if (snac->subtype == 0x000b) |
3212 | 2356 return clientautoresp(sess, mod, rx, snac, bs); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2357 else if (snac->subtype == 0x000c) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2358 return msgack(sess, mod, rx, snac, bs); |
3595 | 2359 else if (snac->subtype == 0x0014) |
2360 return mtn_receive(sess, mod, rx, snac, bs); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2361 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2362 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2363 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2364 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
2365 faim_internal int msg_modfirst(aim_session_t *sess, aim_module_t *mod) |
2086 | 2366 { |
2367 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2368 mod->family = 0x0004; |
2672 | 2369 mod->version = 0x0001; |
2370 mod->toolid = 0x0110; | |
4071 | 2371 mod->toolversion = 0x0629; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2372 mod->flags = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2373 strncpy(mod->name, "messaging", sizeof(mod->name)); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2374 mod->snachandler = snachandler; |
2086 | 2375 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
2376 return 0; |
2086 | 2377 } |