Mercurial > pidgin
annotate libfaim/aim_im.c @ 1030:38452403563b
[gaim-migrate @ 1040]
updating the buddy list to work better with multiple connections. there are still a bunch of things fucked up with this but i wanted more people to start working on it than just me, especially since i won't be here this weekend.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 27 Oct 2000 07:53:32 +0000 |
parents | fa681641643d |
children | 920c86b753d7 |
rev | line source |
---|---|
2 | 1 /* |
2 * aim_im.c | |
3 * | |
4 * The routines for sending/receiving Instant Messages. | |
5 * | |
6 */ | |
7 | |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
8 #include <faim/aim.h> |
2 | 9 |
10 /* | |
11 * Send an ICBM (instant message). | |
12 * | |
13 * | |
14 * Possible flags: | |
15 * AIM_IMFLAGS_AWAY -- Marks the message as an autoresponse | |
16 * AIM_IMFLAGS_ACK -- Requests that the server send an ack | |
17 * when the message is received (of type 0x0004/0x000c) | |
18 * | |
19 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
20 faim_export unsigned long aim_send_im(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
21 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
22 char *destsn, u_int flags, char *msg) |
2 | 23 { |
24 | |
237 | 25 int curbyte,i; |
26 struct command_tx_struct *newpacket; | |
2 | 27 |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
28 if (strlen(msg) >= MAXMSGLEN) |
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
29 return -1; |
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
30 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
31 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, strlen(msg)+256))) |
237 | 32 return -1; |
2 | 33 |
237 | 34 newpacket->lock = 1; /* lock struct */ |
2 | 35 |
36 curbyte = 0; | |
237 | 37 curbyte += aim_putsnac(newpacket->data+curbyte, |
38 0x0004, 0x0006, 0x0000, sess->snac_nextid); | |
39 | |
40 /* | |
41 * Generate a random message cookie | |
42 * | |
43 * We could cache these like we do SNAC IDs. (In fact, it | |
44 * might be a good idea.) In the message error functions, | |
45 * the 8byte message cookie is returned as well as the | |
46 * SNAC ID. | |
47 * | |
48 */ | |
49 for (i=0;i<8;i++) | |
889
e1da6a6ec42b
[gaim-migrate @ 899]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
840
diff
changeset
|
50 curbyte += aimutil_put8(newpacket->data+curbyte, (u_char) rand()); |
2 | 51 |
237 | 52 /* |
53 * Channel ID | |
54 */ | |
55 curbyte += aimutil_put16(newpacket->data+curbyte,0x0001); | |
56 | |
57 /* | |
58 * Destination SN (prepended with byte length) | |
59 */ | |
60 curbyte += aimutil_put8(newpacket->data+curbyte,strlen(destsn)); | |
61 curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn)); | |
62 | |
63 /* | |
64 * metaTLV start. | |
65 */ | |
66 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
67 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x10); |
2 | 68 |
237 | 69 /* |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
70 * Flag data / ICBM Parameters? |
237 | 71 */ |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
72 curbyte += aimutil_put8(newpacket->data+curbyte, 0x05); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
73 curbyte += aimutil_put8(newpacket->data+curbyte, 0x01); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
74 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
75 /* number of bytes to follow */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
76 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0004); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
77 curbyte += aimutil_put8(newpacket->data+curbyte, 0x01); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
78 curbyte += aimutil_put8(newpacket->data+curbyte, 0x01); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
79 curbyte += aimutil_put8(newpacket->data+curbyte, 0x01); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
80 curbyte += aimutil_put8(newpacket->data+curbyte, 0x02); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
81 |
237 | 82 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0101); |
83 | |
84 /* | |
85 * Message block length. | |
86 */ | |
87 curbyte += aimutil_put16(newpacket->data+curbyte, strlen(msg) + 0x04); | |
88 | |
89 /* | |
90 * Character set data? | |
91 */ | |
92 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
93 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
2 | 94 |
237 | 95 /* |
96 * Message. Not terminated. | |
97 */ | |
98 curbyte += aimutil_putstr(newpacket->data+curbyte,msg, strlen(msg)); | |
2 | 99 |
237 | 100 /* |
101 * Set the Request Acknowledge flag. | |
102 */ | |
103 if (flags & AIM_IMFLAGS_ACK) { | |
104 curbyte += aimutil_put16(newpacket->data+curbyte,0x0003); | |
105 curbyte += aimutil_put16(newpacket->data+curbyte,0x0000); | |
106 } | |
107 | |
108 /* | |
109 * Set the Autoresponse flag. | |
110 */ | |
111 if (flags & AIM_IMFLAGS_AWAY) { | |
112 curbyte += aimutil_put16(newpacket->data+curbyte,0x0004); | |
113 curbyte += aimutil_put16(newpacket->data+curbyte,0x0000); | |
114 } | |
115 | |
116 newpacket->commandlen = curbyte; | |
117 newpacket->lock = 0; | |
118 | |
119 aim_tx_enqueue(sess, newpacket); | |
2 | 120 |
121 #ifdef USE_SNAC_FOR_IMS | |
122 { | |
123 struct aim_snac_t snac; | |
124 | |
237 | 125 snac.id = sess->snac_nextid; |
2 | 126 snac.family = 0x0004; |
127 snac.type = 0x0006; | |
128 snac.flags = 0x0000; | |
129 | |
130 snac.data = malloc(strlen(destsn)+1); | |
131 memcpy(snac.data, destsn, strlen(destsn)+1); | |
132 | |
237 | 133 aim_newsnac(sess, &snac); |
2 | 134 } |
135 | |
237 | 136 aim_cleansnacs(sess, 60); /* clean out all SNACs over 60sec old */ |
2 | 137 #endif |
138 | |
237 | 139 return (sess->snac_nextid++); |
2 | 140 } |
141 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
142 faim_internal int aim_parse_outgoing_im_middle(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
143 struct command_rx_struct *command) |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
144 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
145 unsigned int i = 0, z; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
146 rxcallback_t userfunc = NULL; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
147 unsigned char cookie[8]; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
148 int channel; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
149 struct aim_tlvlist_t *tlvlist; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
150 char sn[MAXSNLEN]; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
151 unsigned short icbmflags = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
152 unsigned char flag1 = 0, flag2 = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
153 unsigned char *msgblock = NULL, *msg = NULL; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
154 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
155 i = 10; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
156 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
157 /* ICBM Cookie. */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
158 for (z=0; z<8; z++,i++) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
159 cookie[z] = command->data[i]; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
160 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
161 /* Channel ID */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
162 channel = aimutil_get16(command->data+i); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
163 i += 2; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
164 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
165 if (channel != 0x01) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
166 printf("faim: icbm: ICBM recieved on unsupported channel. Ignoring. (chan = %04x)\n", channel); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
167 return 1; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
168 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
169 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
170 strncpy(sn, (char *) command->data+i+1, (int) *(command->data+i)); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
171 i += 1 + (int) *(command->data+i); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
172 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
173 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
174 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
175 if (aim_gettlv(tlvlist, 0x0003, 1)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
176 icbmflags |= AIM_IMFLAGS_ACK; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
177 if (aim_gettlv(tlvlist, 0x0004, 1)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
178 icbmflags |= AIM_IMFLAGS_AWAY; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
179 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
180 if (aim_gettlv(tlvlist, 0x0002, 1)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
181 int j = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
182 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
183 msgblock = (unsigned char *)aim_gettlv_str(tlvlist, 0x0002, 1); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
184 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
185 /* no, this really is correct. I'm not high or anything either. */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
186 j += 2; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
187 j += 2 + aimutil_get16(msgblock+j); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
188 j += 2; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
189 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
190 j += 2; /* final block length */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
191 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
192 flag1 = aimutil_get16(msgblock); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
193 j += 2; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
194 flag2 = aimutil_get16(msgblock); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
195 j += 2; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
196 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
197 msg = msgblock+j; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
198 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
199 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
200 if ((userfunc = aim_callhandler(command->conn, 0x0004, 0x0006)) || (i = 0)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
201 i = userfunc(sess, command, channel, sn, msg, icbmflags, flag1, flag2); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
202 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
203 if (msgblock) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
204 free(msgblock); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
205 aim_freetlvchain(&tlvlist); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
206 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
207 return 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
208 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
209 |
237 | 210 /* |
211 * It can easily be said that parsing ICBMs is THE single | |
212 * most difficult thing to do in the in AIM protocol. In | |
213 * fact, I think I just did say that. | |
214 * | |
215 * Below is the best damned solution I've come up with | |
216 * over the past sixteen months of battling with it. This | |
217 * can parse both away and normal messages from every client | |
218 * I have access to. Its not fast, its not clean. But it works. | |
219 * | |
220 * We should also support at least minimal parsing of | |
221 * Channel 2, so that we can at least know the name of the | |
222 * room we're invited to, but obviously can't attend... | |
223 * | |
224 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
225 faim_internal int aim_parse_incoming_im_middle(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
226 struct command_rx_struct *command) |
2 | 227 { |
237 | 228 u_int i = 0,z; |
229 rxcallback_t userfunc = NULL; | |
230 u_char cookie[8]; | |
231 int channel; | |
232 struct aim_tlvlist_t *tlvlist; | |
233 struct aim_userinfo_s userinfo; | |
234 u_short wastebits; | |
235 | |
236 memset(&userinfo, 0x00, sizeof(struct aim_userinfo_s)); | |
237 | |
238 i = 10; /* Skip SNAC header */ | |
2 | 239 |
237 | 240 /* |
241 * Read ICBM Cookie. And throw away. | |
242 */ | |
243 for (z=0; z<8; z++,i++) | |
244 cookie[z] = command->data[i]; | |
2 | 245 |
237 | 246 /* |
247 * Channel ID. | |
248 * | |
249 * Channel 0x0001 is the message channel. There are | |
250 * other channels for things called "rendevous" | |
251 * which represent chat and some of the other new | |
252 * features of AIM2/3/3.5. | |
253 * | |
254 * Channel 0x0002 is the Rendevous channel, which | |
255 * is where Chat Invitiations and various client-client | |
256 * connection negotiations come from. | |
257 * | |
258 */ | |
259 channel = aimutil_get16(command->data+i); | |
260 i += 2; | |
2 | 261 |
237 | 262 /* |
263 * | |
264 */ | |
265 if ((channel != 0x01) && (channel != 0x02)) | |
266 { | |
267 printf("faim: icbm: ICBM received on an unsupported channel. Ignoring.\n (chan = %04x)", channel); | |
268 return 1; | |
269 } | |
270 | |
271 /* | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
272 * Extract the standard user info block. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
273 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
274 * Note that although this contains TLVs that appear contiguous |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
275 * with the TLVs read below, they are two different pieces. The |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
276 * userinfo block contains the number of TLVs that contain user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
277 * information, the rest are not even though there is no seperation. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
278 * aim_extractuserinfo() returns the number of bytes used by the |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
279 * userinfo tlvs, so you can start reading the rest of them right |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
280 * afterward. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
281 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
282 * That also means that TLV types can be duplicated between the |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
283 * userinfo block and the rest of the message, however there should |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
284 * never be two TLVs of the same type in one block. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
285 * |
237 | 286 */ |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
287 i += aim_extractuserinfo(command->data+i, &userinfo); |
2 | 288 |
237 | 289 /* |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
290 * Read block of TLVs (not including the userinfo data). All |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
291 * further data is derived from what is parsed here. |
237 | 292 */ |
293 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i); | |
2 | 294 |
237 | 295 /* |
296 * From here on, its depends on what channel we're on. | |
297 */ | |
298 if (channel == 1) | |
299 { | |
300 u_int j = 0, y = 0, z = 0; | |
301 char *msg = NULL; | |
302 u_int icbmflags = 0; | |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
303 struct aim_tlv_t *msgblocktlv; |
237 | 304 u_char *msgblock; |
305 u_short flag1,flag2; | |
306 | |
307 /* | |
308 * Check Autoresponse status. If it is an autoresponse, | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
309 * it will contain a type 0x0004 TLV, with zero length. |
237 | 310 */ |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
311 if (aim_gettlv(tlvlist, 0x0004, 1)) |
237 | 312 icbmflags |= AIM_IMFLAGS_AWAY; |
313 | |
314 /* | |
315 * Check Ack Request status. | |
316 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
317 if (aim_gettlv(tlvlist, 0x0003, 1)) |
237 | 318 icbmflags |= AIM_IMFLAGS_ACK; |
319 | |
320 /* | |
321 * Message block. | |
322 */ | |
323 msgblocktlv = aim_gettlv(tlvlist, 0x0002, 1); | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
324 if (!msgblocktlv || !msgblocktlv->value) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
325 printf("faim: icbm: major error! no message block TLV found!\n"); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
326 aim_freetlvchain(&tlvlist); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
327 return 1; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
328 } |
237 | 329 |
330 /* | |
331 * Extracting the message from the unknown cruft. | |
332 * | |
333 * This is a bit messy, and I'm not really qualified, | |
334 * even as the author, to comment on it. At least | |
335 * its not as bad as a while loop shooting into infinity. | |
336 * | |
337 * "Do you believe in magic?" | |
338 * | |
339 */ | |
340 msgblock = msgblocktlv->value; | |
341 j = 0; | |
342 | |
343 wastebits = aimutil_get8(msgblock+j++); | |
344 wastebits = aimutil_get8(msgblock+j++); | |
345 | |
346 y = aimutil_get16(msgblock+j); | |
347 j += 2; | |
348 for (z = 0; z < y; z++) | |
349 wastebits = aimutil_get8(msgblock+j++); | |
350 wastebits = aimutil_get8(msgblock+j++); | |
351 wastebits = aimutil_get8(msgblock+j++); | |
352 | |
353 /* | |
354 * Message string length, including flag words. | |
355 */ | |
356 i = aimutil_get16(msgblock+j); | |
357 j += 2; | |
358 | |
359 /* | |
360 * Flag words. | |
361 * | |
362 * Its rumored that these can kick in some funky | |
363 * 16bit-wide char stuff that used to really kill | |
364 * libfaim. Hopefully the latter is no longer true. | |
365 * | |
366 * Though someone should investiagte the former. | |
367 * | |
368 */ | |
369 flag1 = aimutil_get16(msgblock+j); | |
370 j += 2; | |
371 flag2 = aimutil_get16(msgblock+j); | |
372 j += 2; | |
373 | |
374 if (flag1 || flag2) | |
375 printf("faim: icbm: **warning: encoding flags are being used! {%04x, %04x}\n", flag1, flag2); | |
376 | |
377 /* | |
378 * Message string. | |
379 */ | |
380 i -= 4; | |
381 msg = (char *)malloc(i+1); | |
382 memcpy(msg, msgblock+j, i); | |
383 msg[i] = '\0'; | |
384 | |
385 /* | |
386 * Call client. | |
387 */ | |
388 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); | |
389 if (userfunc) | |
390 i = userfunc(sess, command, channel, &userinfo, msg, icbmflags, flag1, flag2); | |
391 else | |
392 i = 0; | |
393 | |
394 free(msg); | |
395 } | |
396 else if (channel == 0x0002) | |
397 { | |
398 struct aim_tlv_t *block1; | |
399 struct aim_tlvlist_t *list2; | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
400 unsigned short reqclass = 0; |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
401 unsigned short status = 0; |
237 | 402 |
403 /* | |
404 * There's another block of TLVs embedded in the type 5 here. | |
405 */ | |
406 block1 = aim_gettlv(tlvlist, 0x0005, 1); | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
407 if (!block1) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
408 printf("faim: no tlv 0x0005 in rendezvous transaction!\n"); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
409 aim_freetlvchain(&tlvlist); |
237 | 410 return 1; /* major problem */ |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
411 } |
237 | 412 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
413 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
414 * First two bytes represent the status of the connection. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
415 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
416 * 0 is a request, 2 is an accept |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
417 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
418 status = aimutil_get16(block1->value+0); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
419 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
420 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
421 * Next comes the cookie. Should match the ICBM cookie. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
422 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
423 if (memcmp(block1->value+2, cookie, 8) != 0) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
424 printf("faim: rend: warning cookies don't match!\n"); |
237 | 425 |
426 /* | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
427 * The next 16bytes are a capability block so we can |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
428 * identify what type of rendezvous this is. |
237 | 429 * |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
430 * Thanks to Eric Warmenhoven <warmenhoven@linux.com> (of GAIM) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
431 * for pointing some of this out to me. In fact, a lot of |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
432 * the client-to-client info comes from the work of the GAIM |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
433 * developers. Thanks! |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
434 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
435 * Read off one capability string and we should have it ID'd. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
436 * |
237 | 437 */ |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
438 reqclass = aim_getcap(block1->value+2+8, 0x10); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
439 if (reqclass == 0x0000) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
440 printf("faim: rend: no ID block\n"); |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
441 aim_freetlvchain(&tlvlist); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
442 return 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
443 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
444 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
445 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
446 * What follows may be TLVs or nothing, depending on the |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
447 * purpose of the message. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
448 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
449 * Ack packets for instance have nothing more to them. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
450 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
451 list2 = aim_readtlvchain(block1->value+2+8+16, block1->length-2-8-16); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
452 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
453 if (!list2 || ((reqclass != AIM_CAPS_IMIMAGE) && !(aim_gettlv(list2, 0x2711, 1)))) { |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
454 struct aim_msgcookie_t *cook; |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
455 int type; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
456 |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
457 type = aim_msgcookie_gettype(reqclass); /* XXX: fix this shitty code */ |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
458 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
459 if ((cook = aim_uncachecookie(sess, cookie, type)) == NULL) { |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
460 printf("faim: non-data rendezvous thats not in cache!\n"); |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
461 aim_freetlvchain(&list2); |
237 | 462 aim_freetlvchain(&tlvlist); |
463 return 1; | |
464 } | |
465 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
466 if (cook->type == AIM_CAPS_SENDFILE) { |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
467 struct aim_filetransfer_priv *ft; |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
468 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
469 if (cook->data) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
470 struct aim_tlv_t *errortlv; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
471 int errorcode = -1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
472 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
473 ft = (struct aim_filetransfer_priv *)cook->data; |
237 | 474 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
475 if ((errortlv = aim_gettlv(list2, 0x000b, 1))) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
476 errorcode = aimutil_get16(errortlv->value); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
477 } |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
478 if (errorcode) { |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
479 printf("faim: transfer from %s (%s) for %s cancelled (error code %d)\n", ft->sn, ft->ip, ft->fh.name, errorcode); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
480 } else if (status == 0x0002) { /* connection accepted */ |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
481 printf("faim: transfer from %s (%s) for %s accepted\n", ft->sn, ft->ip, ft->fh.name); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
482 } |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
483 free(cook->data); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
484 } else { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
485 printf("faim: not data attached to file transfer\n"); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
486 } |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
487 } else if (cook->type == AIM_CAPS_VOICE) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
488 printf("faim: voice request cancelled\n"); |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
489 } else { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
490 printf("faim: unknown cookie cache type %d\n", cook->type); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
491 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
492 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
493 free(cook); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
494 if (list2) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
495 aim_freetlvchain(&list2); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
496 aim_freetlvchain(&tlvlist); |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
497 return 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
498 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
499 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
500 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
501 * The rest of the handling depends on what type it is. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
502 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
503 if (reqclass & AIM_CAPS_BUDDYICON) { |
2 | 504 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
505 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
506 * Call client. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
507 */ |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
508 #if 0 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
509 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
510 if (userfunc || (i = 0)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
511 i = userfunc(sess, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
512 command, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
513 channel, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
514 reqclass, |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
515 &userinfo, |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
516 ip, |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
517 cookie); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
518 #endif |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
519 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
520 } else if (reqclass & AIM_CAPS_VOICE) { |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
521 struct aim_msgcookie_t *cachedcook; |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
522 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
523 printf("faim: rend: voice!\n"); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
524 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
525 if(!(cachedcook = (struct aim_msgcookie_t*)calloc(1, sizeof(struct aim_msgcookie_t)))) |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
526 return 1; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
527 |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
528 memcpy(cachedcook->cookie, cookie, 8); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
529 cachedcook->type = AIM_COOKIETYPE_OFTVOICE; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
530 cachedcook->data = NULL; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
531 |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
532 if (aim_cachecookie(sess, cachedcook) != 0) |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
533 printf("faim: ERROR caching message cookie\n"); |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
534 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
535 /* XXX: implement all this */ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
536 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
537 /* |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
538 * Call client. |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
539 */ |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
540 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
541 if (userfunc || (i = 0)) { |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
542 i = userfunc(sess, command, channel, reqclass, &userinfo); |
237 | 543 } |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
544 } else if ((reqclass & AIM_CAPS_IMIMAGE) || (reqclass & AIM_CAPS_BUDDYICON)) { |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
545 char ip[30]; |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
546 struct aim_directim_priv *priv; |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
547 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
548 memset(ip, 0, 30); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
549 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
550 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0005, 1)) { |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
551 struct aim_tlv_t *iptlv, *porttlv; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
552 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
553 iptlv = aim_gettlv(list2, 0x0003, 1); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
554 porttlv = aim_gettlv(list2, 0x0005, 1); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
555 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
556 snprintf(ip, 30, "%d.%d.%d.%d:%d", |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
557 aimutil_get8(iptlv->value+0), |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
558 aimutil_get8(iptlv->value+1), |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
559 aimutil_get8(iptlv->value+2), |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
560 aimutil_get8(iptlv->value+3), |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
561 4443 /*aimutil_get16(porttlv->value)*/); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
562 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
563 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
564 printf("faim: rend: directIM request from %s (%s)\n", |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
565 userinfo.sn, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
566 ip); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
567 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
568 /* XXX: there are a couple of different request packets for |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
569 * different things */ |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
570 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
571 priv = (struct aim_directim_priv *)calloc(1, sizeof(struct aim_directim_priv)); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
572 memcpy(priv->ip, ip, sizeof(priv->ip)); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
573 memcpy(priv->sn, userinfo.sn, sizeof(priv->sn)); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
574 memcpy(priv->cookie, cookie, sizeof(priv->cookie)); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
575 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
576 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
577 * Call client. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
578 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
579 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
580 if (userfunc || (i = 0)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
581 i = userfunc(sess, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
582 command, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
583 channel, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
584 reqclass, |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
585 &userinfo, priv); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
586 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
587 } else if (reqclass & AIM_CAPS_CHAT) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
588 struct aim_tlv_t *miscinfo; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
589 struct aim_chat_roominfo roominfo; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
590 char *msg=NULL,*encoding=NULL,*lang=NULL; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
591 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
592 miscinfo = aim_gettlv(list2, 0x2711, 1); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
593 aim_chat_readroominfo(miscinfo->value, &roominfo); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
594 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
595 if (aim_gettlv(list2, 0x000c, 1)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
596 msg = aim_gettlv_str(list2, 0x000c, 1); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
597 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
598 if (aim_gettlv(list2, 0x000d, 1)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
599 encoding = aim_gettlv_str(list2, 0x000d, 1); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
600 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
601 if (aim_gettlv(list2, 0x000e, 1)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
602 lang = aim_gettlv_str(list2, 0x000e, 1); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
603 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
604 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
605 * Call client. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
606 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
607 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
608 if (userfunc || (i = 0)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
609 i = userfunc(sess, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
610 command, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
611 channel, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
612 reqclass, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
613 &userinfo, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
614 &roominfo, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
615 msg, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
616 encoding?encoding+1:NULL, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
617 lang?lang+1:NULL); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
618 free(roominfo.name); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
619 free(msg); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
620 free(encoding); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
621 free(lang); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
622 } else if (reqclass & AIM_CAPS_GETFILE) { |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
623 char ip[30]; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
624 struct aim_msgcookie_t *cachedcook; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
625 struct aim_tlv_t *miscinfo; |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
626 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
627 if (!(cachedcook = calloc(1, sizeof(struct aim_msgcookie_t)))) |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
628 return 0; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
629 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
630 memset(ip, 0, 30); |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
631 |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
632 if (!(miscinfo = aim_gettlv(list2, 0x2711, 1))) { |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
633 free(cachedcook); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
634 return 0; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
635 } |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
636 |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
637 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0005, 1)) { |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
638 struct aim_tlv_t *iptlv, *porttlv; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
639 |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
640 if (!(iptlv = aim_gettlv(list2, 0x0003, 1)) || !(porttlv = aim_gettlv(list2, 0x0005, 1))) { |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
641 free(cachedcook); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
642 return 0; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
643 } |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
644 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
645 snprintf(ip, 30, "%d.%d.%d.%d:%d", |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
646 aimutil_get8(iptlv->value+0), |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
647 aimutil_get8(iptlv->value+1), |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
648 aimutil_get8(iptlv->value+2), |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
649 aimutil_get8(iptlv->value+3), |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
650 aimutil_get16(porttlv->value)); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
651 } |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
652 |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
653 printf("faim: rend: file get request from %s (%s)\n", userinfo.sn, ip); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
654 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
655 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
656 * Call client. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
657 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
658 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
659 if (userfunc || (i = 0)) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
660 i = userfunc(sess, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
661 command, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
662 channel, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
663 reqclass, |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
664 &userinfo, |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
665 ip, |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
666 cookie); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
667 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
668 } else if (reqclass & AIM_CAPS_SENDFILE) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
669 #if 0 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
670 char ip[30]; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
671 char *desc = NULL; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
672 struct aim_msgcookie_t *cachedcook; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
673 struct aim_filetransfer_priv *ft; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
674 struct aim_tlv_t *miscinfo; |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
675 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
676 memset(ip, 0, sizeof(ip)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
677 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
678 if (!(miscinfo = aim_gettlv(list2, 0x2711, 1))) |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
679 return 0; |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
680 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
681 if (aim_gettlv(list2, 0x0003, 1) && aim_gettlv(list2, 0x0003, 1)) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
682 struct aim_tlv_t *iptlv, *porttlv; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
683 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
684 iptlv = aim_gettlv(list2, 0x0003, 1); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
685 porttlv = aim_gettlv(list2, 0x0005, 1); |
237 | 686 |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
687 snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d:%d", |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
688 aimutil_get8(iptlv->value+0), |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
689 aimutil_get8(iptlv->value+1), |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
690 aimutil_get8(iptlv->value+2), |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
691 aimutil_get8(iptlv->value+3), |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
692 aimutil_get16(porttlv->value)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
693 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
694 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
695 if (aim_gettlv(list2, 0x000c, 1)) { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
696 desc = aim_gettlv_str(list2, 0x000c, 1); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
697 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
698 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
699 printf("faim: rend: file transfer request from %s for %s: %s (%s)\n", |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
700 userinfo.sn, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
701 miscinfo->value+8, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
702 desc, |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
703 ip); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
704 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
705 memcpy(cachedcook->cookie, cookie, 8); |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
706 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
707 ft = malloc(sizeof(struct aim_filetransfer_priv)); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
708 strncpy(ft->sn, userinfo.sn, sizeof(ft->sn)); |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
709 strncpy(ft->ip, ip, sizeof(ft->ip)); |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
710 strncpy(ft->fh.name, miscinfo->value+8, sizeof(ft->fh.name)); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
711 cachedcook->type = AIM_COOKIETYPE_OFTSEND; |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
712 cachedcook->data = ft; |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
713 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
714 if (aim_cachecookie(sess, cachedcook) != 0) |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
715 printf("faim: ERROR caching message cookie\n"); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
716 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
717 |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
718 aim_accepttransfer(sess, command->conn, ft->sn, cookie, AIM_CAPS_SENDFILE); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
719 |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
720 if (desc) |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
721 free(desc); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
722 #endif |
503
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
723 /* |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
724 * Call client. |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
725 */ |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
726 userfunc = aim_callhandler(command->conn, 0x0004, 0x0007); |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
727 if (userfunc || (i = 0)) |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
728 i = userfunc(sess, |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
729 command, |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
730 channel, |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
731 reqclass, |
6e318907bcce
[gaim-migrate @ 513]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
732 &userinfo); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
733 } else { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
734 printf("faim: rend: unknown rendezvous 0x%04x\n", reqclass); |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
735 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
736 |
237 | 737 aim_freetlvchain(&list2); |
2 | 738 } |
739 | |
237 | 740 /* |
741 * Free up the TLV chain. | |
742 */ | |
743 aim_freetlvchain(&tlvlist); | |
2 | 744 |
745 | |
746 return i; | |
747 } | |
237 | 748 |
749 /* | |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
750 * Possible codes: |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
751 * AIM_TRANSFER_DENY_NOTSUPPORTED -- "client does not support" |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
752 * AIM_TRANSFER_DENY_DECLINE -- "client has declined transfer" |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
753 * AIM_TRANSFER_DENY_NOTACCEPTING -- "client is not accepting transfers" |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
754 * |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
755 */ |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
756 faim_export unsigned long aim_denytransfer(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
757 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
758 char *sender, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
759 char *cookie, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
760 unsigned short code) |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
761 { |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
762 struct command_tx_struct *newpacket; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
763 int curbyte, i; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
764 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
765 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+8+2+1+strlen(sender)+6))) |
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
766 return -1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
767 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
768 newpacket->lock = 1; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
769 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
770 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x000b, 0x0000, sess->snac_nextid); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
771 for (i = 0; i < 8; i++) |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
772 curbyte += aimutil_put8(newpacket->data+curbyte, cookie[i]); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
773 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
774 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(sender)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
775 curbyte += aimutil_putstr(newpacket->data+curbyte, sender, strlen(sender)); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
776 curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0003, code); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
777 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
778 newpacket->lock = 0; |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
779 aim_tx_enqueue(sess, newpacket); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
780 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
781 return (sess->snac_nextid++); |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
782 } |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
783 |
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
284
diff
changeset
|
784 /* |
237 | 785 * Not real sure what this does, nor does anyone I've talk to. |
786 * | |
787 * Didn't use to send it. But now I think it might be a good | |
788 * idea. | |
789 * | |
790 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
791 faim_export unsigned long aim_seticbmparam(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
792 struct aim_conn_t *conn) |
237 | 793 { |
794 struct command_tx_struct *newpacket; | |
795 int curbyte; | |
796 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
797 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+16))) |
237 | 798 return -1; |
799 | |
800 newpacket->lock = 1; | |
801 | |
802 curbyte = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid); | |
803 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
804 curbyte += aimutil_put32(newpacket->data+curbyte, 0x00000003); | |
805 curbyte += aimutil_put8(newpacket->data+curbyte, 0x1f); | |
806 curbyte += aimutil_put8(newpacket->data+curbyte, 0x40); | |
807 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03); | |
808 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7); | |
809 curbyte += aimutil_put8(newpacket->data+curbyte, 0x03); | |
810 curbyte += aimutil_put8(newpacket->data+curbyte, 0xe7); | |
811 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
812 curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); | |
813 | |
814 newpacket->lock = 0; | |
815 aim_tx_enqueue(sess, newpacket); | |
816 | |
817 return (sess->snac_nextid++); | |
818 } | |
819 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
820 faim_internal int aim_parse_msgerror_middle(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
821 struct command_rx_struct *command) |
237 | 822 { |
823 u_long snacid = 0x000000000; | |
824 struct aim_snac_t *snac = NULL; | |
825 int ret = 0; | |
826 rxcallback_t userfunc = NULL; | |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
827 char *dest; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
828 unsigned short reason = 0; |
237 | 829 |
830 /* | |
831 * Get SNAC from packet and look it up | |
832 * the list of unrepliedto/outstanding | |
833 * SNACs. | |
834 * | |
835 * After its looked up, the SN that the | |
836 * message should've gone to will be | |
837 * in the ->data element of the snac struct. | |
838 * | |
839 */ | |
840 snacid = aimutil_get32(command->data+6); | |
841 snac = aim_remsnac(sess, snacid); | |
842 | |
284
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
843 if (!snac) { |
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
844 printf("faim: msgerr: got an ICBM-failed error on an unknown SNAC ID! (%08lx)\n", snacid); |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
845 dest = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
846 } else |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
847 dest = snac->data; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
848 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
849 reason = aimutil_get16(command->data+10); |
237 | 850 |
851 /* | |
852 * Call client. | |
853 */ | |
854 userfunc = aim_callhandler(command->conn, 0x0004, 0x0001); | |
855 if (userfunc) | |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
856 ret = userfunc(sess, command, dest, reason); |
237 | 857 else |
858 ret = 0; | |
859 | |
284
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
860 if (snac) { |
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
861 free(snac->data); |
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
862 free(snac); |
bafaf1b68f9a
[gaim-migrate @ 294]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
863 } |
237 | 864 |
865 return ret; | |
866 } | |
867 | |
868 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
869 faim_internal int aim_parse_missedcall(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
870 struct command_rx_struct *command) |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
871 { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
872 int i, ret = 1; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
873 rxcallback_t userfunc = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
874 unsigned short channel, nummissed, reason; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
875 struct aim_userinfo_s userinfo; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
876 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
877 i = 10; /* Skip SNAC header */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
878 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
879 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
880 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
881 * XXX: supposedly, this entire packet can repeat as many times |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
882 * as necessary. Should implement that. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
883 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
884 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
885 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
886 * Channel ID. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
887 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
888 channel = aimutil_get16(command->data+i); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
889 i += 2; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
890 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
891 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
892 * Extract the standard user info block. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
893 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
894 i += aim_extractuserinfo(command->data+i, &userinfo); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
895 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
896 nummissed = aimutil_get16(command->data+i); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
897 i += 2; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
898 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
899 reason = aimutil_get16(command->data+i); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
900 i += 2; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
901 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
902 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
903 * Call client. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
904 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
905 userfunc = aim_callhandler(command->conn, 0x0004, 0x000a); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
906 if (userfunc) |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
907 ret = userfunc(sess, command, channel, &userinfo, nummissed, reason); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
908 else |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
909 ret = 0; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
910 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
911 return ret; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
503
diff
changeset
|
912 } |