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