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