Mercurial > pidgin
annotate src/protocols/oscar/im.c @ 3064:f0aaea918717
[gaim-migrate @ 3078]
Poor, poor msn_embarrassed.xpm. Thanks for rescuing him, Vinay Sahni. Also, truncating oscar passwords to 8 characters.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 16 Mar 2002 22:18:38 +0000 |
parents | 9b029055cfba |
children | bcdbffc2c3e6 |
rev | line source |
---|---|
2086 | 1 /* |
2 * aim_im.c | |
3 * | |
4 * The routines for sending/receiving Instant Messages. | |
5 * | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
6 * Note the term ICBM (Inter-Client Basic Message) which blankets |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
7 * all types of genericly routed through-server messages. Within |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
8 * the ICBM types (family 4), a channel is defined. Each channel |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
9 * represents a different type of message. Channel 1 is used for |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
10 * what would commonly be called an "instant message". Channel 2 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
11 * is used for negotiating "rendezvous". These transactions end in |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
12 * something more complex happening, such as a chat invitation, or |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
13 * a file transfer. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
14 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
15 * In addition to the channel, every ICBM contains a cookie. For |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
16 * standard IMs, these are only used for error messages. However, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
17 * the more complex rendezvous messages make suitably more complex |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
18 * use of this field. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
19 * |
2086 | 20 */ |
21 | |
22 #define FAIM_INTERNAL | |
23 #include <aim.h> | |
24 | |
25 /* | |
26 * Takes a msghdr (and a length) and returns a client type | |
27 * code. Note that this is *only a guess* and has a low likelihood | |
28 * of actually being accurate. | |
29 * | |
30 * Its based on experimental data, with the help of Eric Warmenhoven | |
31 * who seems to have collected a wide variety of different AIM clients. | |
32 * | |
33 * | |
34 * Heres the current collection: | |
35 * 0501 0003 0101 0101 01 AOL Mobile Communicator, WinAIM 1.0.414 | |
36 * 0501 0003 0101 0201 01 WinAIM 2.0.847, 2.1.1187, 3.0.1464, | |
37 * 4.3.2229, 4.4.2286 | |
38 * 0501 0004 0101 0102 0101 WinAIM 4.1.2010, libfaim (right here) | |
39 * 0501 0001 0101 01 AOL v6.0, CompuServe 2000 v6.0, any | |
40 * TOC client | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
41 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
42 * 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
|
43 * the rest will always be the same. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
44 * |
2086 | 45 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
46 faim_export fu16_t aim_fingerprintclient(fu8_t *msghdr, int len) |
2086 | 47 { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
48 static const struct { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
49 fu16_t clientid; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
50 int len; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
51 fu8_t data[10]; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
52 } fingerprints[] = { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
53 /* AOL Mobile Communicator, WinAIM 1.0.414 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
54 { AIM_CLIENTTYPE_MC, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
55 3, {0x01, 0x01, 0x01}}, |
2086 | 56 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
57 /* WinAIM 2.0.847, 2.1.1187, 3.0.1464, 4.3.2229, 4.4.2286 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
58 { AIM_CLIENTTYPE_WINAIM, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
59 3, {0x01, 0x01, 0x02}}, |
2086 | 60 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
61 /* WinAIM 4.1.2010, libfaim */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
62 { AIM_CLIENTTYPE_WINAIM41, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
63 4, {0x01, 0x01, 0x01, 0x02}}, |
2086 | 64 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
65 /* AOL v6.0, CompuServe 2000 v6.0, any TOC client */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
66 { AIM_CLIENTTYPE_AOL_TOC, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
67 1, {0x01}}, |
2086 | 68 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
69 { 0, 0} |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
70 }; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
71 int i; |
2086 | 72 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
73 if (!msghdr || (len <= 0)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
74 return AIM_CLIENTTYPE_UNKNOWN; |
2086 | 75 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
76 for (i = 0; fingerprints[i].len; i++) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
77 if (fingerprints[i].len != len) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
78 continue; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
79 if (memcmp(fingerprints[i].data, msghdr, fingerprints[i].len) == 0) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
80 return fingerprints[i].clientid; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
81 } |
2086 | 82 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
83 return AIM_CLIENTTYPE_UNKNOWN; |
2086 | 84 } |
85 | |
86 /* This should be endian-safe now... but who knows... */ | |
2626
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
87 faim_export fu16_t aim_iconsum(const fu8_t *buf, int buflen) |
2086 | 88 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
89 fu32_t sum; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
90 int i; |
2086 | 91 |
2639
4d6a767133e1
[gaim-migrate @ 2652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2626
diff
changeset
|
92 for (i = 0, sum = 0; i + 1 < buflen; i += 2) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
93 sum += (buf[i+1] << 8) + buf[i]; |
2639
4d6a767133e1
[gaim-migrate @ 2652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2626
diff
changeset
|
94 if (i < buflen) |
4d6a767133e1
[gaim-migrate @ 2652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2626
diff
changeset
|
95 sum += buf[i]; |
2086 | 96 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
97 sum = ((sum & 0xffff0000) >> 16) + (sum & 0x0000ffff); |
2086 | 98 |
2626
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
99 return (fu16_t)sum; |
2086 | 100 } |
101 | |
102 /* | |
103 * Send an ICBM (instant message). | |
104 * | |
105 * | |
106 * Possible flags: | |
107 * AIM_IMFLAGS_AWAY -- Marks the message as an autoresponse | |
108 * AIM_IMFLAGS_ACK -- Requests that the server send an ack | |
109 * when the message is received (of type 0x0004/0x000c) | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
110 * 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
|
111 * online (probably ICQ only). |
2086 | 112 * AIM_IMFLAGS_UNICODE--Instead of ASCII7, the passed message is |
113 * made up of UNICODE duples. If you set | |
114 * this, you'd better be damn sure you know | |
115 * what you're doing. | |
116 * AIM_IMFLAGS_ISO_8859_1 -- The message contains the ASCII8 subset | |
117 * known as ISO-8859-1. | |
118 * | |
119 * Generally, you should use the lowest encoding possible to send | |
120 * your message. If you only use basic punctuation and the generic | |
121 * Latin alphabet, use ASCII7 (no flags). If you happen to use non-ASCII7 | |
122 * characters, but they are all clearly defined in ISO-8859-1, then | |
123 * use that. Keep in mind that not all characters in the PC ASCII8 | |
124 * character set are defined in the ISO standard. For those cases (most | |
125 * notably when the (r) symbol is used), you must use the full UNICODE | |
126 * encoding for your message. In UNICODE mode, _all_ characters must | |
127 * occupy 16bits, including ones that are not special. (Remember that | |
128 * the first 128 UNICODE symbols are equivelent to ASCII7, however they | |
129 * must be prefixed with a zero high order byte.) | |
130 * | |
131 * I strongly discourage the use of UNICODE mode, mainly because none | |
132 * of the clients I use can parse those messages (and besides that, | |
133 * wchars are difficult and non-portable to handle in most UNIX environments). | |
134 * If you really need to include special characters, use the HTML UNICODE | |
135 * entities. These are of the form ߪ where 2026 is the hex | |
136 * representation of the UNICODE index (in this case, UNICODE | |
137 * "Horizontal Ellipsis", or 133 in in ASCII8). | |
138 * | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
139 * Implementation note: Since this is one of the most-used functions |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
140 * 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
|
141 * it is not as clear as it could be in respect to how this message is |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
142 * supposed to be layed out. Most obviously, tlvlists should be used |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
143 * instead of writing out the bytes manually. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
144 * |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
145 * XXX more precise verification that we never send SNACs larger than 8192 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
146 * XXX check SNAC size for multipart |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
147 * |
2086 | 148 */ |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
149 faim_export int aim_send_im_ext(aim_session_t *sess, struct aim_sendimext_args *args) |
2086 | 150 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
151 static const fu8_t deffeatures[] = { |
2315
7ec21662ffc2
[gaim-migrate @ 2325]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2270
diff
changeset
|
152 0x01, 0x01, 0x01, 0x02 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
153 }; |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
154 aim_conn_t *conn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
155 int i, msgtlvlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
156 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
157 aim_snacid_t snacid; |
2086 | 158 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
159 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
160 return -EINVAL; |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
161 |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
162 if (!args) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
163 return -EINVAL; |
2086 | 164 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
165 if (args->flags & AIM_IMFLAGS_MULTIPART) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
166 if (args->mpmsg->numparts <= 0) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
167 return -EINVAL; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
168 } else { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
169 if (!args->msg || (args->msglen <= 0)) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
170 return -EINVAL; |
2086 | 171 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
172 if (args->msglen >= MAXMSGLEN) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
173 return -E2BIG; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
174 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
175 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
176 /* Painfully calculate the size of the message TLV */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
177 msgtlvlen = 1 + 1; /* 0501 */ |
2086 | 178 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
179 if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES) |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
180 msgtlvlen += 2 + args->featureslen; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
181 else |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
182 msgtlvlen += 2 + sizeof(deffeatures); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
183 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
184 if (args->flags & AIM_IMFLAGS_MULTIPART) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
185 aim_mpmsg_section_t *sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
186 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
187 for (sec = args->mpmsg->parts; sec; sec = sec->next) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
188 msgtlvlen += 2 /* 0101 */ + 2 /* block len */; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
189 msgtlvlen += 4 /* charset */ + sec->datalen; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
190 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
191 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
192 } else { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
193 msgtlvlen += 2 /* 0101 */ + 2 /* block len */; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
194 msgtlvlen += 4 /* charset */ + args->msglen; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
195 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
196 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
197 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
198 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, msgtlvlen+128))) |
2122 | 199 return -ENOMEM; |
2086 | 200 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
201 /* XXX should be optional */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
202 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
|
203 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
2086 | 204 |
2122 | 205 /* |
206 * Generate a random message cookie | |
207 * | |
208 * We could cache these like we do SNAC IDs. (In fact, it | |
209 * might be a good idea.) In the message error functions, | |
210 * the 8byte message cookie is returned as well as the | |
211 * SNAC ID. | |
212 * | |
213 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
214 for (i = 0; i < 8; i++) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
215 aimbs_put8(&fr->data, (fu8_t) rand()); |
2086 | 216 |
2122 | 217 /* |
218 * Channel ID | |
219 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
220 aimbs_put16(&fr->data, 0x0001); |
2086 | 221 |
2122 | 222 /* |
223 * Destination SN (prepended with byte length) | |
224 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
225 aimbs_put8(&fr->data, strlen(args->destsn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
226 aimbs_putraw(&fr->data, args->destsn, strlen(args->destsn)); |
2086 | 227 |
2122 | 228 /* |
2751
b715593f0d21
[gaim-migrate @ 2764]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2717
diff
changeset
|
229 * Message TLV (type 2). |
2122 | 230 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
231 aimbs_put16(&fr->data, 0x0002); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
232 aimbs_put16(&fr->data, msgtlvlen); |
2086 | 233 |
2122 | 234 /* |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
235 * Features |
2122 | 236 * |
237 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
238 aimbs_put8(&fr->data, 0x05); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
239 aimbs_put8(&fr->data, 0x01); |
2086 | 240 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
241 if (args->flags & AIM_IMFLAGS_CUSTOMFEATURES) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
242 aimbs_put16(&fr->data, args->featureslen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
243 aimbs_putraw(&fr->data, args->features, args->featureslen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
244 } else { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
245 aimbs_put16(&fr->data, sizeof(deffeatures)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
246 aimbs_putraw(&fr->data, deffeatures, sizeof(deffeatures)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
247 } |
2086 | 248 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
249 if (args->flags & AIM_IMFLAGS_MULTIPART) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
250 aim_mpmsg_section_t *sec; |
2086 | 251 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
252 for (sec = args->mpmsg->parts; sec; sec = sec->next) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
253 aimbs_put16(&fr->data, 0x0101); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
254 aimbs_put16(&fr->data, sec->datalen + 4); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
255 aimbs_put16(&fr->data, sec->charset); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
256 aimbs_put16(&fr->data, sec->charsubset); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
257 aimbs_putraw(&fr->data, sec->data, sec->datalen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
258 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
259 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
260 } else { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
261 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
262 aimbs_put16(&fr->data, 0x0101); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
263 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
264 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
265 * Message block length. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
266 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
267 aimbs_put16(&fr->data, args->msglen + 0x04); |
2086 | 268 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
269 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
270 * Character set. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
271 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
272 if (args->flags & AIM_IMFLAGS_CUSTOMCHARSET) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
273 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
274 aimbs_put16(&fr->data, args->charset); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
275 aimbs_put16(&fr->data, args->charsubset); |
2086 | 276 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
277 } else { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
278 if (args->flags & AIM_IMFLAGS_UNICODE) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
279 aimbs_put16(&fr->data, 0x0002); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
280 else if (args->flags & AIM_IMFLAGS_ISO_8859_1) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
281 aimbs_put16(&fr->data, 0x0003); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
282 else |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
283 aimbs_put16(&fr->data, 0x0000); |
2086 | 284 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
285 aimbs_put16(&fr->data, 0x0000); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
286 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
287 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
288 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
289 * Message. Not terminated. |
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 aimbs_putraw(&fr->data, args->msg, args->msglen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
292 } |
2086 | 293 |
2122 | 294 /* |
295 * Set the Request Acknowledge flag. | |
296 */ | |
297 if (args->flags & AIM_IMFLAGS_ACK) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
298 aimbs_put16(&fr->data, 0x0003); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
299 aimbs_put16(&fr->data, 0x0000); |
2122 | 300 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
301 |
2122 | 302 /* |
303 * Set the Autoresponse flag. | |
304 */ | |
305 if (args->flags & AIM_IMFLAGS_AWAY) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
306 aimbs_put16(&fr->data, 0x0004); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
307 aimbs_put16(&fr->data, 0x0000); |
2122 | 308 } |
309 | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
310 if (args->flags & AIM_IMFLAGS_OFFLINE) { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
311 aimbs_put16(&fr->data, 0x0006); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
312 aimbs_put16(&fr->data, 0x0000); |
2122 | 313 } |
2086 | 314 |
2122 | 315 /* |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
316 * Set the I HAVE A REALLY PURTY ICON flag. |
2122 | 317 */ |
318 if (args->flags & AIM_IMFLAGS_HASICON) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
319 aimbs_put16(&fr->data, 0x0008); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
320 aimbs_put16(&fr->data, 0x000c); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
321 aimbs_put32(&fr->data, args->iconlen); |
2626
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
322 aimbs_put16(&fr->data, 0x0001); |
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
323 aimbs_put16(&fr->data, args->iconsum); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
324 aimbs_put32(&fr->data, args->iconstamp); |
2122 | 325 } |
2086 | 326 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
327 /* |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
328 * Set the Buddy Icon Requested flag. |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
329 */ |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
330 if (args->flags & AIM_IMFLAGS_BUDDYREQ) { |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
331 aimbs_put16(&fr->data, 0x0009); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
332 aimbs_put16(&fr->data, 0x0000); |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
333 } |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
334 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
335 aim_tx_enqueue(sess, fr); |
2086 | 336 |
2751
b715593f0d21
[gaim-migrate @ 2764]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2717
diff
changeset
|
337 if (!(sess->flags & AIM_SESS_FLAGS_DONTTIMEOUTONICBM)) |
b715593f0d21
[gaim-migrate @ 2764]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2717
diff
changeset
|
338 aim_cleansnacs(sess, 60); /* clean out SNACs over 60sec old */ |
2086 | 339 |
2122 | 340 return 0; |
2086 | 341 } |
342 | |
343 /* | |
344 * Simple wrapper for aim_send_im_ext() | |
345 * | |
346 * You cannot use aim_send_im if you need the HASICON flag. You must | |
347 * use aim_send_im_ext directly for that. | |
348 * | |
349 * aim_send_im also cannot be used if you require UNICODE messages, because | |
350 * that requires an explicit message length. Use aim_send_im_ext(). | |
351 * | |
352 */ | |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
353 faim_export int aim_send_im(aim_session_t *sess, const char *destsn, fu16_t flags, const char *msg) |
2086 | 354 { |
2122 | 355 struct aim_sendimext_args args; |
2086 | 356 |
2122 | 357 args.destsn = destsn; |
358 args.flags = flags; | |
359 args.msg = msg; | |
360 args.msglen = strlen(msg); | |
2086 | 361 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
362 /* Make these don't get set by accident -- they need aim_send_im_ext */ |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
363 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
|
364 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
365 return aim_send_im_ext(sess, &args); |
2086 | 366 } |
367 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
368 /* |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
369 * This is also performance sensitive. (If you can believe it...) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
370 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
371 */ |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
372 faim_export int aim_send_icon(aim_session_t *sess, const char *sn, const fu8_t *icon, int iconlen, time_t stamp, fu16_t iconsum) |
2086 | 373 { |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
374 aim_conn_t *conn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
375 int i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
376 fu8_t ck[8]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
377 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
378 aim_snacid_t snacid; |
2086 | 379 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
380 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
381 return -EINVAL; |
2086 | 382 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
383 if (!sn || !icon || (iconlen <= 0) || (iconlen >= MAXICONLEN)) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
384 return -EINVAL; |
2086 | 385 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
386 for (i = 0; i < 8; i++) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
387 aimutil_put8(ck+i, (fu8_t) rand()); |
2086 | 388 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
389 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
|
390 return -ENOMEM; |
2086 | 391 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
392 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
393 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
2086 | 394 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
395 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
396 * Cookie |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
397 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
398 aimbs_putraw(&fr->data, ck, 8); |
2086 | 399 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
400 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
401 * Channel (2) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
402 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
403 aimbs_put16(&fr->data, 0x0002); |
2086 | 404 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
405 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
406 * Dest sn |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
407 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
408 aimbs_put8(&fr->data, strlen(sn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
409 aimbs_putraw(&fr->data, sn, strlen(sn)); |
2086 | 410 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
411 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
412 * TLV t(0005) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
413 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
414 * Encompasses everything below. |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
415 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
416 aimbs_put16(&fr->data, 0x0005); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
417 aimbs_put16(&fr->data, 2+8+16+6+4+4+iconlen+4+4+4+strlen(AIM_ICONIDENT)); |
2086 | 418 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
419 aimbs_put16(&fr->data, 0x0000); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
420 aimbs_putraw(&fr->data, ck, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
421 aim_putcap(&fr->data, AIM_CAPS_BUDDYICON); |
2086 | 422 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
423 /* TLV t(000a) */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
424 aimbs_put16(&fr->data, 0x000a); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
425 aimbs_put16(&fr->data, 0x0002); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
426 aimbs_put16(&fr->data, 0x0001); |
2086 | 427 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
428 /* TLV t(000f) */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
429 aimbs_put16(&fr->data, 0x000f); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
430 aimbs_put16(&fr->data, 0x0000); |
2086 | 431 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
432 /* TLV t(2711) */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
433 aimbs_put16(&fr->data, 0x2711); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
434 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
|
435 aimbs_put16(&fr->data, 0x0000); |
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
436 aimbs_put16(&fr->data, iconsum); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
437 aimbs_put32(&fr->data, iconlen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
438 aimbs_put32(&fr->data, stamp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
439 aimbs_putraw(&fr->data, icon, iconlen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
440 aimbs_putraw(&fr->data, AIM_ICONIDENT, strlen(AIM_ICONIDENT)); |
2086 | 441 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
442 /* TLV t(0003) */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
443 aimbs_put16(&fr->data, 0x0003); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
444 aimbs_put16(&fr->data, 0x0000); |
2086 | 445 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
446 aim_tx_enqueue(sess, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
447 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
448 return 0; |
2086 | 449 } |
450 | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
451 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
452 * 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
|
453 * 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
|
454 * 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
|
455 * bounce it back to you. |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
456 * |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
457 * 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
|
458 * the one-group-per-file scheme as much as possible. This could easily |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
459 * be an exception, since Rendezvous IMs are external of the Oscar core, |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
460 * 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
|
461 * 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
|
462 * |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
463 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
464 faim_export int aim_send_rtfmsg(aim_session_t *sess, struct aim_sendrtfmsg_args *args) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
465 { |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
466 const char rtfcap[] = {"{97B12751-243C-4334-AD22-D6ABF73F1492}"}; /* AIM_CAPS_ICQRTF capability in string form */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
467 aim_conn_t *conn; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
468 int i; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
469 fu8_t ck[8]; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
470 aim_frame_t *fr; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
471 aim_snacid_t snacid; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
472 int servdatalen; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
473 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
474 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
475 return -EINVAL; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
476 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
477 if (!args || !args->destsn || !args->rtfmsg) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
478 return -EINVAL; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
479 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
480 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
|
481 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
482 for (i = 0; i < 8; i++) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
483 aimutil_put8(ck+i, (fu8_t) rand()); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
484 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
485 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
|
486 return -ENOMEM; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
487 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
488 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
489 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
490 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
491 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
492 * Cookie |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
493 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
494 aimbs_putraw(&fr->data, ck, 8); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
495 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
496 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
497 * Channel (2) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
498 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
499 aimbs_put16(&fr->data, 0x0002); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
500 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
501 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
502 * Dest sn |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
503 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
504 aimbs_put8(&fr->data, strlen(args->destsn)); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
505 aimbs_putraw(&fr->data, args->destsn, strlen(args->destsn)); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
506 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
507 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
508 * TLV t(0005) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
509 * |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
510 * Encompasses everything below. |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
511 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
512 aimbs_put16(&fr->data, 0x0005); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
513 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
|
514 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
515 aimbs_put16(&fr->data, 0x0000); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
516 aimbs_putraw(&fr->data, ck, 8); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
517 aim_putcap(&fr->data, AIM_CAPS_ICQSERVERRELAY); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
518 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
519 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
520 * t(000a) l(0002) v(0001) |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
521 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
522 aimbs_put16(&fr->data, 0x000a); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
523 aimbs_put16(&fr->data, 0x0002); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
524 aimbs_put16(&fr->data, 0x0001); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
525 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
526 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
527 * t(000f) l(0000) v() |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
528 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
529 aimbs_put16(&fr->data, 0x000f); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
530 aimbs_put16(&fr->data, 0x0000); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
531 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
532 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
533 * Service Data TLV |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
534 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
535 aimbs_put16(&fr->data, 0x2711); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
536 aimbs_put16(&fr->data, servdatalen); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
537 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
538 aimbs_putle16(&fr->data, 11 + 16 /* 11 + (sizeof CLSID) */); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
539 aimbs_putle16(&fr->data, 9); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
540 aim_putcap(&fr->data, AIM_CAPS_EMPTY); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
541 aimbs_putle16(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
542 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
543 aimbs_putle8(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
544 aimbs_putle16(&fr->data, 0x03ea); /* trid1 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
545 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
546 aimbs_putle16(&fr->data, 14); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
547 aimbs_putle16(&fr->data, 0x03eb); /* trid2 */ |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
548 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
549 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
550 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
551 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
552 aimbs_putle16(&fr->data, 0x0001); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
553 aimbs_putle32(&fr->data, 0); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
554 aimbs_putle16(&fr->data, strlen(args->rtfmsg)+1); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
555 aimbs_putraw(&fr->data, args->rtfmsg, strlen(args->rtfmsg)+1); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
556 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
557 aimbs_putle32(&fr->data, args->fgcolor); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
558 aimbs_putle32(&fr->data, args->bgcolor); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
559 aimbs_putle32(&fr->data, strlen(rtfcap)+1); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
560 aimbs_putraw(&fr->data, rtfcap, strlen(rtfcap)+1); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
561 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
562 aim_tx_enqueue(sess, fr); |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
563 |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
564 return 0; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
565 } |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
566 |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
567 faim_internal int aim_request_directim(aim_session_t *sess, const char *destsn, fu8_t *ip, fu16_t port, fu8_t *ckret) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
568 { |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
569 aim_conn_t *conn; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
570 fu8_t ck[8]; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
571 aim_frame_t *fr; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
572 aim_snacid_t snacid; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
573 aim_tlvlist_t *tl = NULL, *itl = NULL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
574 int hdrlen, i; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
575 fu8_t *hdr; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
576 aim_bstream_t hdrbs; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
577 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
578 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
579 return -EINVAL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
580 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
581 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 256+strlen(destsn)))) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
582 return -ENOMEM; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
583 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
584 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
585 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
586 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
587 /* |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
588 * Generate a random message cookie |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
589 * |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
590 * This cookie needs to be alphanumeric and NULL-terminated to be |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
591 * TOC-compatible. |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
592 * |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
593 * XXX have I mentioned these should be generated in msgcookie.c? |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
594 * |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
595 */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
596 for (i = 0; i < 7; i++) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
597 ck[i] = 0x30 + ((fu8_t) rand() % 10); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
598 ck[7] = '\0'; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
599 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
600 if (ckret) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
601 memcpy(ckret, ck, 8); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
602 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
603 /* Cookie */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
604 aimbs_putraw(&fr->data, ck, 8); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
605 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
606 /* Channel */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
607 aimbs_put16(&fr->data, 0x0002); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
608 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
609 /* Destination SN */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
610 aimbs_put8(&fr->data, strlen(destsn)); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
611 aimbs_putraw(&fr->data, destsn, strlen(destsn)); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
612 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
613 aim_addtlvtochain_noval(&tl, 0x0003); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
614 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
615 hdrlen = 2+8+16+6+8+6+4; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
616 hdr = malloc(hdrlen); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
617 aim_bstream_init(&hdrbs, hdr, hdrlen); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
618 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
619 aimbs_put16(&hdrbs, 0x0000); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
620 aimbs_putraw(&hdrbs, ck, 8); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
621 aim_putcap(&hdrbs, AIM_CAPS_IMIMAGE); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
622 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
623 aim_addtlvtochain16(&itl, 0x000a, 0x0001); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
624 aim_addtlvtochain_raw(&itl, 0x0003, 4, ip); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
625 aim_addtlvtochain16(&itl, 0x0005, port); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
626 aim_addtlvtochain_noval(&itl, 0x000f); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
627 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
628 aim_writetlvchain(&hdrbs, &itl); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
629 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
630 aim_addtlvtochain_raw(&tl, 0x0005, aim_bstream_curpos(&hdrbs), hdr); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
631 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
632 aim_writetlvchain(&fr->data, &tl); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
633 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
634 free(hdr); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
635 aim_freetlvchain(&itl); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
636 aim_freetlvchain(&tl); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
637 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
638 aim_tx_enqueue(sess, fr); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
639 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
640 return 0; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
641 } |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
642 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
643 faim_internal int aim_request_sendfile(aim_session_t *sess, const char *sn, const char *filename, fu16_t numfiles, fu32_t totsize, fu8_t *ip, fu16_t port, fu8_t *ckret) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
644 { |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
645 aim_conn_t *conn; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
646 int i; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
647 fu8_t ck[8]; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
648 aim_frame_t *fr; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
649 aim_snacid_t snacid; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
650 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
651 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
652 return -EINVAL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
653 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
654 if (!sn || !filename) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
655 return -EINVAL; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
656 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
657 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+8+2+1+strlen(sn)+2+2+2+8+16+6+8+6+4+2+2+2+2+4+strlen(filename)+4))) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
658 return -ENOMEM; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
659 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
660 snacid = aim_cachesnac(sess, 0x0004, 0x0006, 0x0000, NULL, 0); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
661 aim_putsnac(&fr->data, 0x0004, 0x0006, 0x0000, snacid); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
662 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
663 for (i = 0; i < 7; i++) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
664 aimutil_put8(ck+i, 0x30 + ((fu8_t) rand() % 10)); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
665 ck[7] = '\0'; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
666 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
667 if (ckret) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
668 memcpy(ckret, ck, 8); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
669 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
670 /* |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
671 * Cookie |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
672 */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
673 aimbs_putraw(&fr->data, ck, 8); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
674 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
675 /* |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
676 * Channel (2) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
677 */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
678 aimbs_put16(&fr->data, 0x0002); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
679 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
680 /* |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
681 * Dest sn |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
682 */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
683 aimbs_put8(&fr->data, strlen(sn)); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
684 aimbs_putraw(&fr->data, sn, strlen(sn)); |
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 /* |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
687 * TLV t(0005) |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
688 * |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
689 * Encompasses everything below. Gee. |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
690 */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
691 aimbs_put16(&fr->data, 0x0005); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
692 aimbs_put16(&fr->data, 2+8+16+6+8+6+4+2+2+2+2+4+strlen(filename)+4); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
693 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
694 aimbs_put16(&fr->data, 0x0000); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
695 aimbs_putraw(&fr->data, ck, 8); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
696 aim_putcap(&fr->data, AIM_CAPS_SENDFILE); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
697 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
698 /* TLV t(000a) */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
699 aimbs_put16(&fr->data, 0x000a); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
700 aimbs_put16(&fr->data, 0x0002); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
701 aimbs_put16(&fr->data, 0x0001); |
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 /* TLV t(0003) (IP) */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
704 aimbs_put16(&fr->data, 0x0003); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
705 aimbs_put16(&fr->data, 0x0004); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
706 aimbs_putraw(&fr->data, ip, 4); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
707 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
708 /* TLV t(0005) (port) */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
709 aimbs_put16(&fr->data, 0x0005); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
710 aimbs_put16(&fr->data, 0x0002); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
711 aimbs_put16(&fr->data, port); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
712 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
713 /* TLV t(000f) */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
714 aimbs_put16(&fr->data, 0x000f); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
715 aimbs_put16(&fr->data, 0x0000); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
716 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
717 /* TLV t(2711) */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
718 aimbs_put16(&fr->data, 0x2711); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
719 aimbs_put16(&fr->data, 2+2+4+strlen(filename)+4); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
720 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
721 /* ? */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
722 aimbs_put16(&fr->data, 0x0001); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
723 aimbs_put16(&fr->data, numfiles); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
724 aimbs_put32(&fr->data, totsize); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
725 aimbs_putraw(&fr->data, filename, strlen(filename)); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
726 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
727 /* ? */ |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
728 aimbs_put32(&fr->data, 0x00000000); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
729 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
730 aim_tx_enqueue(sess, fr); |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
731 |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
732 return 0; |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
733 } |
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
734 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
735 static int outgoingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 736 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
737 int i, ret = 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
738 aim_rxcallback_t userfunc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
739 fu8_t cookie[8]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
740 fu16_t channel; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
741 aim_tlvlist_t *tlvlist; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
742 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
743 int snlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
744 fu16_t icbmflags = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
745 fu8_t flag1 = 0, flag2 = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
746 fu8_t *msg = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
747 aim_tlv_t *msgblock; |
2086 | 748 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
749 /* ICBM Cookie. */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
750 for (i = 0; i < 8; i++) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
751 cookie[i] = aimbs_get8(bs); |
2086 | 752 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
753 /* Channel ID */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
754 channel = aimbs_get16(bs); |
2086 | 755 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
756 if (channel != 0x01) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
757 faimdprintf(sess, 0, "icbm: ICBM recieved on unsupported channel. Ignoring. (chan = %04x)\n", channel); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
758 return 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
759 } |
2086 | 760 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
761 snlen = aimbs_get8(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
762 sn = aimbs_getstr(bs, snlen); |
2086 | 763 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
764 tlvlist = aim_readtlvchain(bs); |
2086 | 765 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
766 if (aim_gettlv(tlvlist, 0x0003, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
767 icbmflags |= AIM_IMFLAGS_ACK; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
768 if (aim_gettlv(tlvlist, 0x0004, 1)) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
769 icbmflags |= AIM_IMFLAGS_AWAY; |
2086 | 770 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
771 if ((msgblock = aim_gettlv(tlvlist, 0x0002, 1))) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
772 aim_bstream_t mbs; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
773 int featurelen, msglen; |
2086 | 774 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
775 aim_bstream_init(&mbs, msgblock->value, msgblock->length); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
776 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
777 aimbs_get8(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
778 aimbs_get8(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
779 for (featurelen = aimbs_get16(&mbs); featurelen; featurelen--) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
780 aimbs_get8(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
781 aimbs_get8(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
782 aimbs_get8(&mbs); |
2086 | 783 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
784 msglen = aimbs_get16(&mbs) - 4; /* final block length */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
785 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
786 flag1 = aimbs_get16(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
787 flag2 = aimbs_get16(&mbs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
788 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
789 msg = aimbs_getstr(&mbs, msglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
790 } |
2086 | 791 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
792 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
793 ret = userfunc(sess, rx, channel, sn, msg, icbmflags, flag1, flag2); |
2086 | 794 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
795 free(sn); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
796 aim_freetlvchain(&tlvlist); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
797 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
798 return ret; |
2086 | 799 } |
800 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
801 /* |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
802 * Ahh, the joys of nearly ridiculous over-engineering. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
803 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
804 * 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
|
805 * support multiple character sets. But they support multiple character |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
806 * sets / encodings within the same ICBM. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
807 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
808 * These multipart messages allow for complex space savings techniques, which |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
809 * 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
|
810 * 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
|
811 * Macintosh, Version 5.0. Obscure, yes, I know. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
812 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
813 * 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
|
814 * 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
|
815 * 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
|
816 * 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
|
817 * Multipart messages prevent this wasted space by allowing the client to |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
818 * 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
|
819 * 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
|
820 * set is (probably ASCII). |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
821 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
822 * 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
|
823 * 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
|
824 * 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
|
825 * 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
|
826 * the associated overhead. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
827 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
828 * 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
|
829 * 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
|
830 * 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
|
831 * open source clients (like encryption or something) -- see faimtest for |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
832 * examples of how to do this. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
833 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
834 * I would definitly recommend avoiding this feature unless you really |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
835 * 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
|
836 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
837 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
838 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
|
839 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
840 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
841 memset(mpm, 0, sizeof(aim_mpmsg_t)); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
842 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
843 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
844 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
845 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
846 static int mpmsg_addsection(aim_session_t *sess, aim_mpmsg_t *mpm, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
847 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
848 aim_mpmsg_section_t *sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
849 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
850 if (!(sec = malloc(sizeof(aim_mpmsg_section_t)))) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
851 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
852 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
853 sec->charset = charset; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
854 sec->charsubset = charsubset; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
855 sec->data = data; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
856 sec->datalen = datalen; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
857 sec->next = NULL; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
858 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
859 if (!mpm->parts) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
860 mpm->parts = sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
861 else { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
862 aim_mpmsg_section_t *cur; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
863 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
864 for (cur = mpm->parts; cur->next; cur = cur->next) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
865 ; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
866 cur->next = sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
867 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
868 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
869 mpm->numparts++; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
870 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
871 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
872 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
873 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
874 faim_export int aim_mpmsg_addraw(aim_session_t *sess, aim_mpmsg_t *mpm, fu16_t charset, fu16_t charsubset, const fu8_t *data, fu16_t datalen) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
875 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
876 fu8_t *dup; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
877 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
878 if (!(dup = malloc(datalen))) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
879 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
880 memcpy(dup, data, datalen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
881 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
882 if (mpmsg_addsection(sess, mpm, charset, charsubset, dup, datalen) == -1) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
883 free(dup); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
884 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
885 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
886 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
887 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
888 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
889 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
890 /* XXX should provide a way of saying ISO-8859-1 specifically */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
891 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
|
892 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
893 fu8_t *dup; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
894 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
895 if (!(dup = strdup(ascii))) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
896 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
897 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
898 if (mpmsg_addsection(sess, mpm, 0x0000, 0x0000, dup, strlen(ascii)) == -1) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
899 free(dup); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
900 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
901 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
902 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
903 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
904 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
905 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
906 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
|
907 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
908 fu8_t *buf; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
909 aim_bstream_t bs; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
910 int i; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
911 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
912 if (!(buf = malloc(unicodelen * 2))) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
913 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
914 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
915 aim_bstream_init(&bs, buf, unicodelen * 2); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
916 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
917 /* We assume unicode is in /host/ byte order -- convert to network */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
918 for (i = 0; i < unicodelen; i++) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
919 aimbs_put16(&bs, unicode[i]); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
920 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
921 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
|
922 free(buf); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
923 return -1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
924 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
925 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
926 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
927 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
928 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
929 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
|
930 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
931 aim_mpmsg_section_t *cur; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
932 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
933 for (cur = mpm->parts; cur; ) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
934 aim_mpmsg_section_t *tmp; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
935 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
936 tmp = cur->next; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
937 free(cur->data); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
938 free(cur); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
939 cur = tmp; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
940 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
941 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
942 mpm->numparts = 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
943 mpm->parts = NULL; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
944 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
945 return; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
946 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
947 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
948 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
949 * Start by building the multipart structures, then pick the first |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
950 * 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
|
951 * suspicious. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
952 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
953 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
954 static int incomingim_ch1_parsemsgs(aim_session_t *sess, fu8_t *data, int len, struct aim_incomingim_ch1_args *args) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
955 { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
956 static const fu16_t charsetpri[] = { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
957 0x0000, /* ASCII first */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
958 0x0003, /* then ISO-8859-1 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
959 0x0002, /* UNICODE as last resort */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
960 }; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
961 static const int charsetpricount = 3; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
962 int i; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
963 aim_bstream_t mbs; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
964 aim_mpmsg_section_t *sec; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
965 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
966 aim_bstream_init(&mbs, data, len); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
967 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
968 while (aim_bstream_empty(&mbs)) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
969 fu16_t msglen, flag1, flag2; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
970 fu8_t *msgbuf; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
971 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
972 aimbs_get8(&mbs); /* 01 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
973 aimbs_get8(&mbs); /* 01 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
974 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
975 /* Message string length, including character set info. */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
976 msglen = aimbs_get16(&mbs); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
977 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
978 /* Character set info */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
979 flag1 = aimbs_get16(&mbs); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
980 flag2 = aimbs_get16(&mbs); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
981 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
982 /* Message. */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
983 msglen -= 4; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
984 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
985 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
986 * 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
|
987 * it into a multipart struct and deal with it later. However, |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
988 * always pad the ending with a NULL. This makes it easier |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
989 * to treat ASCII sections as strings. It won't matter for |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
990 * UNICODE or binary data, as you should never read past |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
991 * the specified data length, which will not include the pad. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
992 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
993 * XXX There's an API bug here. For sending, the UNICODE is |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
994 * given in host byte order (aim_mpmsg_addunicode), but here |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
995 * the received messages are given in network byte order. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
996 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
997 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
998 msgbuf = aimbs_getstr(&mbs, msglen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
999 mpmsg_addsection(sess, &args->mpmsg, flag1, flag2, msgbuf, msglen); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1000 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1001 } /* while */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1002 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1003 args->icbmflags |= AIM_IMFLAGS_MULTIPART; /* always set */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1004 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1005 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1006 * Clients that support multiparts should never use args->msg, as it |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1007 * will point to an arbitrary section. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1008 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1009 * Here, we attempt to provide clients that do not support multipart |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1010 * messages with something to look at -- hopefully a human-readable |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1011 * string. But, failing that, a UNICODE message, or nothing at all. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1012 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1013 * 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
|
1014 * message was blank. |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1015 * |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1016 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1017 for (i = 0; i < charsetpricount; i++) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1018 for (sec = args->mpmsg.parts; sec; sec = sec->next) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1019 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1020 if (sec->charset != charsetpri[i]) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1021 continue; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1022 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1023 /* Great. We found one. Fill it in. */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1024 args->charset = sec->charset; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1025 args->charsubset = sec->charsubset; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1026 args->icbmflags |= AIM_IMFLAGS_CUSTOMCHARSET; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1027 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1028 /* Set up the simple flags */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1029 if (args->charset == 0x0000) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1030 ; /* ASCII */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1031 else if (args->charset == 0x0002) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1032 args->icbmflags |= AIM_IMFLAGS_UNICODE; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1033 else if (args->charset == 0x0003) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1034 args->icbmflags |= AIM_IMFLAGS_ISO_8859_1; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1035 else if (args->charset == 0xffff) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1036 ; /* no encoding (yeep!) */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1037 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1038 if (args->charsubset == 0x0000) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1039 ; /* standard subencoding? */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1040 else if (args->charsubset == 0x000b) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1041 args->icbmflags |= AIM_IMFLAGS_SUBENC_MACINTOSH; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1042 else if (args->charsubset == 0xffff) |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1043 ; /* no subencoding */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1044 #if 0 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1045 /* XXX this isn't really necesary... */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1046 if ( ((args.flag1 != 0x0000) && |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1047 (args.flag1 != 0x0002) && |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1048 (args.flag1 != 0x0003) && |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1049 (args.flag1 != 0xffff)) || |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1050 ((args.flag2 != 0x0000) && |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1051 (args.flag2 != 0x000b) && |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1052 (args.flag2 != 0xffff))) { |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1053 faimdprintf(sess, 0, "icbm: **warning: encoding flags are being used! {%04x, %04x}\n", args.flag1, args.flag2); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1054 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1055 #endif |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1056 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1057 args->msg = sec->data; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1058 args->msglen = sec->datalen; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1059 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1060 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1061 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1062 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1063 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1064 /* No human-readable sections found. Oh well. */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1065 args->charset = args->charsubset = 0xffff; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1066 args->msg = NULL; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1067 args->msglen = 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1068 |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1069 return 0; |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1070 } |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1071 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2341
diff
changeset
|
1072 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 | 1073 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1074 fu16_t type, length; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1075 aim_rxcallback_t userfunc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1076 int ret = 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1077 struct aim_incomingim_ch1_args args; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1078 int endpos; |
2086 | 1079 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1080 memset(&args, 0, sizeof(args)); |
2086 | 1081 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1082 aim_mpmsg_init(sess, &args.mpmsg); |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1083 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1084 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1085 * This used to be done using tlvchains. For performance reasons, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1086 * 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
|
1087 * of per-IM memory allocations. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1088 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1089 while (aim_bstream_empty(bs)) { |
2086 | 1090 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1091 type = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1092 length = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1093 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1094 endpos = aim_bstream_curpos(bs) + length; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1095 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1096 if (type == 0x0002) { /* Message Block */ |
2086 | 1097 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1098 /* |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1099 * This TLV consists of the following: |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1100 * - 0501 -- Unknown |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1101 * - Features: Don't know how to interpret these |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1102 * - 0101 -- Unknown |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1103 * - Message |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1104 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1105 */ |
2086 | 1106 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1107 aimbs_get8(bs); /* 05 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1108 aimbs_get8(bs); /* 01 */ |
2086 | 1109 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1110 args.featureslen = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1111 /* XXX XXX this is all evil! */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1112 args.features = bs->data + bs->offset; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1113 aim_bstream_advance(bs, args.featureslen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1114 args.icbmflags |= AIM_IMFLAGS_CUSTOMFEATURES; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1115 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1116 /* |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1117 * The rest of the TLV contains one or more message |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1118 * blocks... |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1119 */ |
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1120 incomingim_ch1_parsemsgs(sess, bs->data + bs->offset /* XXX evil!!! */, length - 2 - 2 - args.featureslen, &args); |
2086 | 1121 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1122 } else if (type == 0x0003) { /* Server Ack Requested */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1123 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1124 args.icbmflags |= AIM_IMFLAGS_ACK; |
2086 | 1125 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1126 } else if (type == 0x0004) { /* Message is Auto Response */ |
2086 | 1127 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1128 args.icbmflags |= AIM_IMFLAGS_AWAY; |
2086 | 1129 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
1130 } else if (type == 0x0006) { /* Message was received offline. */ |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
1131 |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
1132 /* XXX not sure if this actually gets sent. */ |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
1133 args.icbmflags |= AIM_IMFLAGS_OFFLINE; |
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2673
diff
changeset
|
1134 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1135 } else if (type == 0x0008) { /* I-HAVE-A-REALLY-PURTY-ICON Flag */ |
2086 | 1136 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1137 args.iconlen = aimbs_get32(bs); |
2626
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
1138 aimbs_get16(bs); /* 0x0001 */ |
93f9bbd62630
[gaim-migrate @ 2639]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
1139 args.iconsum = aimbs_get16(bs); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1140 args.iconstamp = aimbs_get32(bs); |
2869 | 1141 |
1142 /* | |
1143 * This looks to be a client bug. MacAIM 4.3 will | |
1144 * send this tag, but with all zero values, in the | |
1145 * first message of a conversation. This makes no | |
1146 * sense whatsoever, so I'm going to say its a bug. | |
1147 * | |
1148 * You really shouldn't advertise a zero-length icon | |
1149 * anyway. | |
1150 * | |
1151 */ | |
1152 if (args.iconlen) | |
1153 args.icbmflags |= AIM_IMFLAGS_HASICON; | |
2086 | 1154 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1155 } else if (type == 0x0009) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1156 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1157 args.icbmflags |= AIM_IMFLAGS_BUDDYREQ; |
2086 | 1158 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1159 } else if (type == 0x0017) { |
2086 | 1160 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1161 args.extdatalen = length; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1162 args.extdata = aimbs_getraw(bs, args.extdatalen); |
2086 | 1163 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1164 } else { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1165 faimdprintf(sess, 0, "incomingim_ch1: unknown TLV 0x%04x (len %d)\n", type, length); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1166 } |
2086 | 1167 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1168 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1169 * This is here to protect ourselves from ourselves. That |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1170 * is, if something above doesn't completly parse its value |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1171 * section, or, worse, overparses it, this will set the |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1172 * 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
|
1173 * TLV when the loop continues. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1174 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1175 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1176 aim_bstream_setpos(bs, endpos); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1177 } |
2086 | 1178 |
1179 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1180 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1181 ret = userfunc(sess, rx, channel, userinfo, &args); |
2086 | 1182 |
2270
d82efea341ef
[gaim-migrate @ 2280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1183 aim_mpmsg_free(sess, &args.mpmsg); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1184 free(args.extdata); |
2086 | 1185 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1186 return ret; |
2086 | 1187 } |
1188 | |
2869 | 1189 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
|
1190 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1191 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1192 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1193 * This goes like this... |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1194 * |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1195 * group name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1196 * group name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1197 * num of buddies in group |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1198 * buddy name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1199 * buddy name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1200 * buddy name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1201 * buddy name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1202 * ... |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1203 * group name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1204 * group name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1205 * num of buddies in group |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1206 * buddy name length |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1207 * buddy name |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1208 * ... |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1209 * ... |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1210 */ |
2869 | 1211 while (servdata && aim_bstream_empty(servdata)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1212 fu16_t gnlen, numb; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1213 int i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1214 char *gn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1215 |
2869 | 1216 gnlen = aimbs_get16(servdata); |
1217 gn = aimbs_getstr(servdata, gnlen); | |
1218 numb = aimbs_get16(servdata); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1219 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1220 for (i = 0; i < numb; i++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1221 fu16_t bnlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1222 char *bn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1223 |
2869 | 1224 bnlen = aimbs_get16(servdata); |
1225 bn = aimbs_getstr(servdata, bnlen); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1226 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1227 faimdprintf(sess, 0, "got a buddy list from %s: group %s, buddy %s\n", userinfo->sn, gn, bn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1228 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1229 free(bn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1230 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1231 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1232 free(gn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1233 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1234 |
2869 | 1235 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1236 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1237 |
2869 | 1238 static void incomingim_ch2_buddyicon_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) |
2086 | 1239 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1240 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1241 free(args->info.icon.icon); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1242 |
2869 | 1243 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1244 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1245 |
2869 | 1246 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
|
1247 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1248 |
2869 | 1249 if (servdata) { |
1250 args->info.icon.checksum = aimbs_get32(servdata); | |
1251 args->info.icon.length = aimbs_get32(servdata); | |
1252 args->info.icon.timestamp = aimbs_get32(servdata); | |
1253 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
|
1254 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1255 |
2869 | 1256 args->destructor = (void *)incomingim_ch2_buddyicon_free; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1257 |
2869 | 1258 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1259 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1260 |
2869 | 1261 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
|
1262 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1263 |
2869 | 1264 /* XXX aim_chat_roominfo_free() */ |
1265 free(args->info.chat.roominfo.name); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1266 |
2869 | 1267 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1268 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1269 |
2869 | 1270 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
|
1271 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1272 |
2869 | 1273 /* |
1274 * Chat room info. | |
1275 */ | |
1276 if (servdata) | |
1277 aim_chat_readroominfo(servdata, &args->info.chat.roominfo); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1278 |
2869 | 1279 args->destructor = (void *)incomingim_ch2_chat_free; |
1280 | |
1281 return; | |
1282 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1283 |
2869 | 1284 static void incomingim_ch2_icqserverrelay_free(aim_session_t *sess, struct aim_incomingim_ch2_args *args) |
1285 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1286 |
2869 | 1287 free((char *)args->info.rtfmsg.rtfmsg); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1288 |
2869 | 1289 return; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1290 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1291 |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1292 /* |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1293 * The relationship between AIM_CAPS_ICQSERVERRELAY and AIM_CAPS_ICQRTF is |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1294 * 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
|
1295 * SERVERRELAY used for. |
2869 | 1296 * |
1297 * Note that this is all little-endian. Cringe. | |
1298 * | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1299 */ |
2869 | 1300 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
|
1301 { |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1302 fu16_t hdrlen, anslen, msglen; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1303 fu16_t msgtype; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1304 |
2869 | 1305 hdrlen = aimbs_getle16(servdata); |
1306 aim_bstream_advance(servdata, hdrlen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1307 |
2869 | 1308 hdrlen = aimbs_getle16(servdata); |
1309 aim_bstream_advance(servdata, hdrlen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1310 |
2869 | 1311 msgtype = aimbs_getle16(servdata); |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1312 |
2869 | 1313 anslen = aimbs_getle32(servdata); |
1314 aim_bstream_advance(servdata, anslen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1315 |
2869 | 1316 msglen = aimbs_getle16(servdata); |
1317 args->info.rtfmsg.rtfmsg = aimbs_getstr(servdata, msglen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1318 |
2869 | 1319 args->info.rtfmsg.fgcolor = aimbs_getle32(servdata); |
1320 args->info.rtfmsg.bgcolor = aimbs_getle32(servdata); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1321 |
2869 | 1322 hdrlen = aimbs_getle32(servdata); |
1323 aim_bstream_advance(servdata, hdrlen); | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1324 |
2869 | 1325 /* XXX This is such a hack. */ |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1326 args->reqclass = AIM_CAPS_ICQRTF; |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1327 |
2869 | 1328 args->destructor = (void *)incomingim_ch2_icqserverrelay_free; |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1329 |
2869 | 1330 return; |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1331 } |
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1332 |
2869 | 1333 typedef void (*ch2_args_destructor_t)(aim_session_t *sess, struct aim_incomingim_ch2_args *args); |
1334 | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2341
diff
changeset
|
1335 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
|
1336 { |
2869 | 1337 aim_rxcallback_t userfunc; |
1338 aim_tlv_t *block1, *servdatatlv; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1339 aim_tlvlist_t *list2; |
2869 | 1340 struct aim_incomingim_ch2_args args; |
1341 aim_bstream_t bbs, sdbs, *sdbsptr = NULL; | |
1342 fu8_t *cookie2; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1343 int ret = 0; |
2869 | 1344 |
1345 char clientip1[30] = {""}; | |
1346 char clientip2[30] = {""}; | |
1347 char verifiedip[30] = {""}; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1348 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1349 memset(&args, 0, sizeof(args)); |
2086 | 1350 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1351 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1352 * There's another block of TLVs embedded in the type 5 here. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1353 */ |
2869 | 1354 block1 = aim_gettlv(tlvlist, 0x0005, 1); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1355 aim_bstream_init(&bbs, block1->value, block1->length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1356 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1357 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1358 * First two bytes represent the status of the connection. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1359 * |
2869 | 1360 * 0 is a request, 1 is a deny (?), 2 is an accept |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1361 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1362 args.status = aimbs_get16(&bbs); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1363 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1364 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1365 * Next comes the cookie. Should match the ICBM cookie. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1366 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1367 cookie2 = aimbs_getraw(&bbs, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1368 if (memcmp(cookie, cookie2, 8) != 0) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1369 faimdprintf(sess, 0, "rend: warning cookies don't match!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1370 memcpy(args.cookie, cookie2, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1371 free(cookie2); |
2086 | 1372 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1373 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1374 * The next 16bytes are a capability block so we can |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1375 * identify what type of rendezvous this is. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1376 */ |
2869 | 1377 args.reqclass = aim_getcap(sess, &bbs, 0x10); |
2086 | 1378 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1379 /* |
2196
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1380 * What follows may be TLVs or nothing, depending on the |
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1381 * purpose of the message. |
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1382 * |
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1383 * Ack packets for instance have nothing more to them. |
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1384 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1385 list2 = aim_readtlvchain(&bbs); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1386 |
2869 | 1387 /* |
1388 * IP address from the perspective of the client. | |
1389 */ | |
1390 if (aim_gettlv(list2, 0x0002, 1)) { | |
1391 aim_tlv_t *iptlv; | |
1392 | |
1393 iptlv = aim_gettlv(list2, 0x0002, 1); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1394 |
2869 | 1395 snprintf(clientip1, sizeof(clientip1), "%d.%d.%d.%d", |
1396 aimutil_get8(iptlv->value+0), | |
1397 aimutil_get8(iptlv->value+1), | |
1398 aimutil_get8(iptlv->value+2), | |
1399 aimutil_get8(iptlv->value+3)); | |
1400 } | |
1401 | |
1402 /* | |
1403 * Secondary IP address from the perspective of the client. | |
1404 */ | |
1405 if (aim_gettlv(list2, 0x0003, 1)) { | |
1406 aim_tlv_t *iptlv; | |
1407 | |
1408 iptlv = aim_gettlv(list2, 0x0003, 1); | |
2086 | 1409 |
2869 | 1410 snprintf(clientip2, sizeof(clientip2), "%d.%d.%d.%d", |
1411 aimutil_get8(iptlv->value+0), | |
1412 aimutil_get8(iptlv->value+1), | |
1413 aimutil_get8(iptlv->value+2), | |
1414 aimutil_get8(iptlv->value+3)); | |
1415 } | |
2086 | 1416 |
2869 | 1417 /* |
1418 * Verified IP address (from the perspective of Oscar). | |
1419 * | |
1420 * This is added by the server. | |
1421 */ | |
1422 if (aim_gettlv(list2, 0x0004, 1)) { | |
1423 aim_tlv_t *iptlv; | |
2086 | 1424 |
2869 | 1425 iptlv = aim_gettlv(list2, 0x0004, 1); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1426 |
2869 | 1427 snprintf(verifiedip, sizeof(verifiedip), "%d.%d.%d.%d", |
1428 aimutil_get8(iptlv->value+0), | |
1429 aimutil_get8(iptlv->value+1), | |
1430 aimutil_get8(iptlv->value+2), | |
1431 aimutil_get8(iptlv->value+3)); | |
1432 } | |
2086 | 1433 |
2869 | 1434 /* |
1435 * Port number for something. | |
1436 */ | |
1437 if (aim_gettlv(list2, 0x0005, 1)) | |
1438 args.port = aim_gettlv16(list2, 0x0005, 1); | |
2086 | 1439 |
2869 | 1440 /* |
1441 * Error code. | |
1442 */ | |
1443 if (aim_gettlv(list2, 0x000b, 1)) | |
1444 args.errorcode = aim_gettlv16(list2, 0x000b, 1); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1445 |
2869 | 1446 /* |
1447 * Invitation message / chat description. | |
1448 */ | |
1449 if (aim_gettlv(list2, 0x000c, 1)) | |
1450 args.msg = aim_gettlv_str(list2, 0x000c, 1); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1451 |
2869 | 1452 /* |
1453 * Character set. | |
1454 */ | |
1455 if (aim_gettlv(list2, 0x000d, 1)) | |
1456 args.encoding = aim_gettlv_str(list2, 0x000d, 1); | |
1457 | |
1458 /* | |
1459 * Language. | |
1460 */ | |
1461 if (aim_gettlv(list2, 0x000e, 1)) | |
1462 args.language = aim_gettlv_str(list2, 0x000e, 1); | |
1463 | |
1464 /* Unknown -- two bytes = 0x0001 */ | |
1465 if (aim_gettlv(list2, 0x000a, 1)) | |
1466 ; | |
2086 | 1467 |
2869 | 1468 /* Unknown -- no value */ |
1469 if (aim_gettlv(list2, 0x000f, 1)) | |
1470 ; | |
1471 | |
1472 if (strlen(clientip1)) | |
1473 args.clientip = (char *)clientip1; | |
1474 if (strlen(clientip2)) | |
1475 args.clientip2 = (char *)clientip2; | |
1476 if (strlen(verifiedip)) | |
1477 args.verifiedip = (char *)verifiedip; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1478 |
2869 | 1479 /* |
1480 * This is must be present in PROPOSALs, but will probably not | |
1481 * exist in CANCELs and ACCEPTs. | |
1482 * | |
1483 * Service Data blocks are module-specific in format. | |
1484 */ | |
1485 if ((servdatatlv = aim_gettlv(list2, 0x2711 /* 10001 */, 1))) { | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1486 |
2869 | 1487 aim_bstream_init(&sdbs, servdatatlv->value, servdatatlv->length); |
1488 sdbsptr = &sdbs; | |
2086 | 1489 } |
1490 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1491 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1492 * The rest of the handling depends on what type it is. |
2869 | 1493 * |
1494 * Not all of them have special handling (yet). | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1495 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1496 if (args.reqclass & AIM_CAPS_BUDDYICON) |
2869 | 1497 incomingim_ch2_buddyicon(sess, mod, rx, snac, userinfo, &args, sdbsptr); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1498 else if (args.reqclass & AIM_CAPS_SENDBUDDYLIST) |
2869 | 1499 incomingim_ch2_buddylist(sess, mod, rx, snac, userinfo, &args, sdbsptr); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1500 else if (args.reqclass & AIM_CAPS_CHAT) |
2869 | 1501 incomingim_ch2_chat(sess, mod, rx, snac, userinfo, &args, sdbsptr); |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2808
diff
changeset
|
1502 else if (args.reqclass & AIM_CAPS_ICQSERVERRELAY) |
2869 | 1503 incomingim_ch2_icqserverrelay(sess, mod, rx, snac, userinfo, &args, sdbsptr); |
1504 | |
1505 | |
1506 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | |
1507 ret = userfunc(sess, rx, channel, userinfo, &args); | |
1508 | |
1509 | |
1510 if (args.destructor) | |
1511 ((ch2_args_destructor_t)args.destructor)(sess, &args); | |
1512 | |
1513 free((char *)args.msg); | |
1514 free((char *)args.encoding); | |
1515 free((char *)args.language); | |
2086 | 1516 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1517 aim_freetlvchain(&list2); |
2086 | 1518 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1519 return ret; |
2086 | 1520 } |
1521 | |
1522 /* | |
1523 * It can easily be said that parsing ICBMs is THE single | |
1524 * most difficult thing to do in the in AIM protocol. In | |
1525 * fact, I think I just did say that. | |
1526 * | |
1527 * Below is the best damned solution I've come up with | |
1528 * over the past sixteen months of battling with it. This | |
1529 * can parse both away and normal messages from every client | |
1530 * I have access to. Its not fast, its not clean. But it works. | |
1531 * | |
1532 */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1533 static int incomingim(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 1534 { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1535 int i, ret = 0; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1536 fu8_t cookie[8]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1537 fu16_t channel; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2341
diff
changeset
|
1538 aim_userinfo_t userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1539 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2341
diff
changeset
|
1540 memset(&userinfo, 0x00, sizeof(aim_userinfo_t)); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1541 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1542 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1543 * Read ICBM Cookie. And throw away. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1544 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1545 for (i = 0; i < 8; i++) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1546 cookie[i] = aimbs_get8(bs); |
2086 | 1547 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1548 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1549 * Channel ID. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1550 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1551 * Channel 0x0001 is the message channel. There are |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1552 * other channels for things called "rendevous" |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1553 * which represent chat and some of the other new |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1554 * features of AIM2/3/3.5. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1555 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1556 * Channel 0x0002 is the Rendevous channel, which |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1557 * is where Chat Invitiations and various client-client |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1558 * connection negotiations come from. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1559 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1560 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1561 channel = aimbs_get16(bs); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1562 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1563 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1564 * Extract the standard user info block. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1565 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1566 * Note that although this contains TLVs that appear contiguous |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1567 * with the TLVs read below, they are two different pieces. The |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1568 * userinfo block contains the number of TLVs that contain user |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1569 * information, the rest are not even though there is no seperation. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1570 * aim_extractuserinfo() returns the number of bytes used by the |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1571 * userinfo tlvs, so you can start reading the rest of them right |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1572 * afterward. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1573 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1574 * That also means that TLV types can be duplicated between the |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1575 * userinfo block and the rest of the message, however there should |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1576 * never be two TLVs of the same type in one block. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1577 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1578 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1579 aim_extractuserinfo(sess, bs, &userinfo); |
2086 | 1580 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1581 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1582 * From here on, its depends on what channel we're on. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1583 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1584 * Technically all channels have a TLV list have this, however, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1585 * 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
|
1586 * performance reasons (less memory allocation). |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1587 */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1588 if (channel == 1) { |
2086 | 1589 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1590 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
|
1591 |
2869 | 1592 } else if (channel == 2) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1593 aim_tlvlist_t *tlvlist; |
2086 | 1594 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1595 /* |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1596 * Read block of TLVs (not including the userinfo data). All |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1597 * further data is derived from what is parsed here. |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1598 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1599 tlvlist = aim_readtlvchain(bs); |
2086 | 1600 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1601 ret = incomingim_ch2(sess, mod, rx, snac, channel, &userinfo, tlvlist, cookie); |
2086 | 1602 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1603 aim_freetlvchain(&tlvlist); |
2869 | 1604 |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
1605 } else { |
2869 | 1606 |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
1607 faimdprintf(sess, 0, "icbm: ICBM received on an unsupported channel. Ignoring.\n (chan = %04x)", channel); |
2869 | 1608 |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
1609 return 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1610 } |
2086 | 1611 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1612 return ret; |
2086 | 1613 } |
1614 | |
1615 /* | |
1616 * Possible codes: | |
1617 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support" | |
1618 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer" | |
1619 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers" | |
1620 * | |
1621 */ | |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1622 faim_export int aim_denytransfer(aim_session_t *sess, const char *sender, const char *cookie, fu16_t code) |
2086 | 1623 { |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1624 aim_conn_t *conn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1625 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1626 aim_snacid_t snacid; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1627 aim_tlvlist_t *tl = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1628 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1629 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1630 return -EINVAL; |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1631 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1632 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
|
1633 return -ENOMEM; |
2086 | 1634 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1635 snacid = aim_cachesnac(sess, 0x0004, 0x000b, 0x0000, NULL, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1636 aim_putsnac(&fr->data, 0x0004, 0x000b, 0x0000, snacid); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1637 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1638 aimbs_putraw(&fr->data, cookie, 8); |
2086 | 1639 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1640 aimbs_put16(&fr->data, 0x0002); /* channel */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1641 aimbs_put8(&fr->data, strlen(sender)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1642 aimbs_putraw(&fr->data, sender, strlen(sender)); |
2086 | 1643 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1644 aim_addtlvtochain16(&tl, 0x0003, code); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1645 aim_writetlvchain(&fr->data, &tl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1646 aim_freetlvchain(&tl); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1647 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1648 aim_tx_enqueue(sess, fr); |
2086 | 1649 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1650 return 0; |
2086 | 1651 } |
1652 | |
1653 /* | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1654 * aim_reqicbmparaminfo() |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1655 * |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1656 * Request ICBM parameter information. |
2086 | 1657 * |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1658 */ |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1659 faim_export int aim_reqicbmparams(aim_session_t *sess) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1660 { |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1661 aim_conn_t *conn; |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1662 |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1663 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1664 return -EINVAL; |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1665 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1666 return aim_genericreq_n(sess, conn, 0x0004, 0x0004); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1667 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1668 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1669 /* |
2086 | 1670 * |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1671 * I definitly recommend sending this. If you don't, you'll be stuck |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1672 * with the rather unreasonable defaults. You don't want those. Send this. |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1673 * |
2086 | 1674 */ |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1675 faim_export int aim_seticbmparam(aim_session_t *sess, struct aim_icbmparameters *params) |
2086 | 1676 { |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1677 aim_conn_t *conn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1678 aim_frame_t *fr; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1679 aim_snacid_t snacid; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1680 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1681 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1682 return -EINVAL; |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1683 |
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1684 if (!params) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1685 return -EINVAL; |
2086 | 1686 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1687 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+16))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1688 return -ENOMEM; |
2086 | 1689 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1690 snacid = aim_cachesnac(sess, 0x0004, 0x0002, 0x0000, NULL, 0); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1691 aim_putsnac(&fr->data, 0x0004, 0x0002, 0x0000, snacid); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1692 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1693 /* This is read-only (see Parameter Reply). Must be set to zero here. */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1694 aimbs_put16(&fr->data, 0x0000); |
2086 | 1695 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1696 /* These are all read-write */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1697 aimbs_put32(&fr->data, params->flags); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1698 aimbs_put16(&fr->data, params->maxmsglen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1699 aimbs_put16(&fr->data, params->maxsenderwarn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1700 aimbs_put16(&fr->data, params->maxrecverwarn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1701 aimbs_put32(&fr->data, params->minmsginterval); |
2086 | 1702 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1703 aim_tx_enqueue(sess, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1704 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1705 return 0; |
2086 | 1706 } |
1707 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1708 static int paraminfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 1709 { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1710 struct aim_icbmparameters params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1711 aim_rxcallback_t userfunc; |
2086 | 1712 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1713 params.maxchan = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1714 params.flags = aimbs_get32(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1715 params.maxmsglen = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1716 params.maxsenderwarn = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1717 params.maxrecverwarn = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1718 params.minmsginterval = aimbs_get32(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1719 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1720 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1721 return userfunc(sess, rx, ¶ms); |
2086 | 1722 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1723 return 0; |
2086 | 1724 } |
1725 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1726 static int missedcall(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 1727 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1728 int ret = 0; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1729 aim_rxcallback_t userfunc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1730 fu16_t channel, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2341
diff
changeset
|
1731 aim_userinfo_t userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1732 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1733 while (aim_bstream_empty(bs)) { |
2086 | 1734 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1735 channel = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1736 aim_extractuserinfo(sess, bs, &userinfo); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1737 nummissed = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1738 reason = aimbs_get16(bs); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1739 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1740 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1741 ret = userfunc(sess, rx, channel, &userinfo, nummissed, reason); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1742 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1743 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1744 return ret; |
2086 | 1745 } |
1746 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1747 static int clienterr(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
|
1748 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1749 int ret = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1750 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1751 fu16_t channel, reason; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1752 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1753 fu8_t *ck, snlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1754 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1755 ck = aimbs_getraw(bs, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1756 channel = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1757 snlen = aimbs_get8(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1758 sn = aimbs_getstr(bs, snlen); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1759 reason = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1760 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1761 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1762 ret = userfunc(sess, rx, channel, sn, reason); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1763 |
2341
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1764 free(ck); |
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1765 free(sn); |
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1766 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1767 return ret; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1768 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1769 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1770 static int msgack(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 1771 { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1772 aim_rxcallback_t userfunc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1773 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1774 fu8_t snlen, *ck; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1775 char *sn; |
2341
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1776 int ret = 0; |
2086 | 1777 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1778 ck = aimbs_getraw(bs, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1779 type = aimbs_get16(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1780 snlen = aimbs_get8(bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1781 sn = aimbs_getstr(bs, snlen); |
2086 | 1782 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1783 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
2341
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1784 ret = userfunc(sess, rx, type, sn); |
2086 | 1785 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1786 free(sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1787 free(ck); |
2086 | 1788 |
2341
5486d558ecee
[gaim-migrate @ 2354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1789 return ret; |
2086 | 1790 } |
1791 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1792 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
|
1793 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1794 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1795 if (snac->subtype == 0x0005) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1796 return paraminfo(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1797 else if (snac->subtype == 0x0006) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1798 return outgoingim(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1799 else if (snac->subtype == 0x0007) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1800 return incomingim(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1801 else if (snac->subtype == 0x000a) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1802 return missedcall(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1803 else if (snac->subtype == 0x000b) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1804 return clienterr(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1805 else if (snac->subtype == 0x000c) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1806 return msgack(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1807 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1808 return 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1809 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1810 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2196
diff
changeset
|
1811 faim_internal int msg_modfirst(aim_session_t *sess, aim_module_t *mod) |
2086 | 1812 { |
1813 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1814 mod->family = 0x0004; |
2672 | 1815 mod->version = 0x0001; |
1816 mod->toolid = 0x0110; | |
1817 mod->toolversion = 0x047b; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1818 mod->flags = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1819 strncpy(mod->name, "messaging", sizeof(mod->name)); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1820 mod->snachandler = snachandler; |
2086 | 1821 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2122
diff
changeset
|
1822 return 0; |
2086 | 1823 } |