13234
|
1 /*
|
|
2 * Gaim's oscar protocol plugin
|
|
3 * This file is the legal property of its developers.
|
|
4 * Please see the AUTHORS file distributed alongside this file.
|
|
5 *
|
|
6 * This library is free software; you can redistribute it and/or
|
|
7 * modify it under the terms of the GNU Lesser General Public
|
|
8 * License as published by the Free Software Foundation; either
|
|
9 * version 2 of the License, or (at your option) any later version.
|
|
10 *
|
|
11 * This library is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 * Lesser General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU Lesser General Public
|
|
17 * License along with this library; if not, write to the Free Software
|
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 */
|
|
20
|
|
21 /*
|
|
22 * Family 0x0015 - Encapsulated ICQ.
|
|
23 *
|
|
24 */
|
|
25
|
|
26 #include "oscar.h"
|
|
27
|
13592
|
28 int aim_icq_reqofflinemsgs(OscarData *od)
|
13234
|
29 {
|
13592
|
30 FlapConnection *conn;
|
|
31 FlapFrame *frame;
|
13234
|
32 aim_snacid_t snacid;
|
|
33 int bslen;
|
|
34
|
13592
|
35 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
|
13234
|
36 return -EINVAL;
|
|
37
|
|
38 bslen = 2 + 4 + 2 + 2;
|
|
39
|
13592
|
40 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
|
13234
|
41
|
13592
|
42 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
|
|
43 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
|
13234
|
44
|
|
45 /* For simplicity, don't bother using a tlvlist */
|
13592
|
46 byte_stream_put16(&frame->data, 0x0001);
|
|
47 byte_stream_put16(&frame->data, bslen);
|
13234
|
48
|
13592
|
49 byte_stream_putle16(&frame->data, bslen - 2);
|
|
50 byte_stream_putle32(&frame->data, atoi(od->sn));
|
|
51 byte_stream_putle16(&frame->data, 0x003c); /* I command thee. */
|
|
52 byte_stream_putle16(&frame->data, snacid); /* eh. */
|
13234
|
53
|
13592
|
54 flap_connection_send(conn, frame);
|
13234
|
55
|
|
56 return 0;
|
|
57 }
|
|
58
|
13592
|
59 int aim_icq_ackofflinemsgs(OscarData *od)
|
13234
|
60 {
|
13592
|
61 FlapConnection *conn;
|
|
62 FlapFrame *frame;
|
13234
|
63 aim_snacid_t snacid;
|
|
64 int bslen;
|
|
65
|
13592
|
66 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
|
13234
|
67 return -EINVAL;
|
|
68
|
|
69 bslen = 2 + 4 + 2 + 2;
|
|
70
|
13592
|
71 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
|
13234
|
72
|
13592
|
73 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
|
|
74 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
|
13234
|
75
|
|
76 /* For simplicity, don't bother using a tlvlist */
|
13592
|
77 byte_stream_put16(&frame->data, 0x0001);
|
|
78 byte_stream_put16(&frame->data, bslen);
|
13234
|
79
|
13592
|
80 byte_stream_putle16(&frame->data, bslen - 2);
|
|
81 byte_stream_putle32(&frame->data, atoi(od->sn));
|
|
82 byte_stream_putle16(&frame->data, 0x003e); /* I command thee. */
|
|
83 byte_stream_putle16(&frame->data, snacid); /* eh. */
|
13234
|
84
|
13592
|
85 flap_connection_send(conn, frame);
|
13234
|
86
|
|
87 return 0;
|
|
88 }
|
|
89
|
13592
|
90 int
|
|
91 aim_icq_setsecurity(OscarData *od, gboolean auth_required, gboolean webaware)
|
13234
|
92 {
|
13592
|
93 FlapConnection *conn;
|
|
94 FlapFrame *frame;
|
13234
|
95 aim_snacid_t snacid;
|
|
96 int bslen;
|
|
97
|
13592
|
98 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
|
13234
|
99 return -EINVAL;
|
|
100
|
|
101 bslen = 2+4+2+2+2+2+2+1+1+1+1+1+1;
|
|
102
|
13592
|
103 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
|
13234
|
104
|
13592
|
105 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
|
|
106 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
|
13234
|
107
|
|
108 /* For simplicity, don't bother using a tlvlist */
|
13592
|
109 byte_stream_put16(&frame->data, 0x0001);
|
|
110 byte_stream_put16(&frame->data, bslen);
|
13234
|
111
|
13592
|
112 byte_stream_putle16(&frame->data, bslen - 2);
|
|
113 byte_stream_putle32(&frame->data, atoi(od->sn));
|
|
114 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
|
|
115 byte_stream_putle16(&frame->data, snacid); /* eh. */
|
|
116 byte_stream_putle16(&frame->data, 0x0c3a); /* shrug. */
|
|
117 byte_stream_putle16(&frame->data, 0x030c);
|
|
118 byte_stream_putle16(&frame->data, 0x0001);
|
|
119 byte_stream_putle8(&frame->data, webaware);
|
|
120 byte_stream_putle8(&frame->data, 0xf8);
|
|
121 byte_stream_putle8(&frame->data, 0x02);
|
|
122 byte_stream_putle8(&frame->data, 0x01);
|
|
123 byte_stream_putle8(&frame->data, 0x00);
|
|
124 byte_stream_putle8(&frame->data, !auth_required);
|
13234
|
125
|
13592
|
126 flap_connection_send(conn, frame);
|
13234
|
127
|
|
128 return 0;
|
|
129 }
|
|
130
|
|
131 /**
|
|
132 * Change your ICQ password.
|
|
133 *
|
13592
|
134 * @param od The oscar session
|
13234
|
135 * @param passwd The new password. If this is longer than 8 characters it
|
|
136 * will be truncated.
|
|
137 * @return Return 0 if no errors, otherwise return the error number.
|
|
138 */
|
13592
|
139 int aim_icq_changepasswd(OscarData *od, const char *passwd)
|
13234
|
140 {
|
13592
|
141 FlapConnection *conn;
|
|
142 FlapFrame *frame;
|
13234
|
143 aim_snacid_t snacid;
|
|
144 int bslen, passwdlen;
|
|
145
|
|
146 if (!passwd)
|
|
147 return -EINVAL;
|
|
148
|
13592
|
149 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
|
13234
|
150 return -EINVAL;
|
|
151
|
|
152 passwdlen = strlen(passwd);
|
|
153 if (passwdlen > MAXICQPASSLEN)
|
|
154 passwdlen = MAXICQPASSLEN;
|
|
155 bslen = 2+4+2+2+2+2+passwdlen+1;
|
|
156
|
13592
|
157 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
|
13234
|
158
|
13592
|
159 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
|
|
160 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
|
13234
|
161
|
|
162 /* For simplicity, don't bother using a tlvlist */
|
13592
|
163 byte_stream_put16(&frame->data, 0x0001);
|
|
164 byte_stream_put16(&frame->data, bslen);
|
13234
|
165
|
13592
|
166 byte_stream_putle16(&frame->data, bslen - 2);
|
|
167 byte_stream_putle32(&frame->data, atoi(od->sn));
|
|
168 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
|
|
169 byte_stream_putle16(&frame->data, snacid); /* eh. */
|
|
170 byte_stream_putle16(&frame->data, 0x042e); /* shrug. */
|
|
171 byte_stream_putle16(&frame->data, passwdlen+1);
|
|
172 byte_stream_putstr(&frame->data, passwd);
|
|
173 byte_stream_putle8(&frame->data, '\0');
|
13234
|
174
|
13592
|
175 flap_connection_send(conn, frame);
|
13234
|
176
|
|
177 return 0;
|
|
178 }
|
|
179
|
13592
|
180 int aim_icq_getallinfo(OscarData *od, const char *uin)
|
13234
|
181 {
|
13592
|
182 FlapConnection *conn;
|
|
183 FlapFrame *frame;
|
13234
|
184 aim_snacid_t snacid;
|
|
185 int bslen;
|
|
186 struct aim_icq_info *info;
|
|
187
|
|
188 if (!uin || uin[0] < '0' || uin[0] > '9')
|
|
189 return -EINVAL;
|
|
190
|
13592
|
191 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
|
13234
|
192 return -EINVAL;
|
|
193
|
|
194 bslen = 2 + 4 + 2 + 2 + 2 + 4;
|
|
195
|
13592
|
196 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
|
13234
|
197
|
13592
|
198 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
|
|
199 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
|
13234
|
200
|
|
201 /* For simplicity, don't bother using a tlvlist */
|
13592
|
202 byte_stream_put16(&frame->data, 0x0001);
|
|
203 byte_stream_put16(&frame->data, bslen);
|
13234
|
204
|
13592
|
205 byte_stream_putle16(&frame->data, bslen - 2);
|
|
206 byte_stream_putle32(&frame->data, atoi(od->sn));
|
|
207 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
|
|
208 byte_stream_putle16(&frame->data, snacid); /* eh. */
|
|
209 byte_stream_putle16(&frame->data, 0x04b2); /* shrug. */
|
|
210 byte_stream_putle32(&frame->data, atoi(uin));
|
13234
|
211
|
13592
|
212 flap_connection_send(conn, frame);
|
13234
|
213
|
|
214 /* Keep track of this request and the ICQ number and request ID */
|
|
215 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info));
|
|
216 info->reqid = snacid;
|
|
217 info->uin = atoi(uin);
|
13592
|
218 info->next = od->icq_info;
|
|
219 od->icq_info = info;
|
13234
|
220
|
|
221 return 0;
|
|
222 }
|
|
223
|
13592
|
224 int aim_icq_getalias(OscarData *od, const char *uin)
|
13234
|
225 {
|
13592
|
226 FlapConnection *conn;
|
|
227 FlapFrame *frame;
|
13234
|
228 aim_snacid_t snacid;
|
|
229 int bslen;
|
|
230 struct aim_icq_info *info;
|
|
231
|
|
232 if (!uin || uin[0] < '0' || uin[0] > '9')
|
|
233 return -EINVAL;
|
|
234
|
13592
|
235 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
|
13234
|
236 return -EINVAL;
|
|
237
|
|
238 bslen = 2 + 4 + 2 + 2 + 2 + 4;
|
|
239
|
13592
|
240 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
|
13234
|
241
|
13592
|
242 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
|
|
243 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
|
13234
|
244
|
|
245 /* For simplicity, don't bother using a tlvlist */
|
13592
|
246 byte_stream_put16(&frame->data, 0x0001);
|
|
247 byte_stream_put16(&frame->data, bslen);
|
13234
|
248
|
13592
|
249 byte_stream_putle16(&frame->data, bslen - 2);
|
|
250 byte_stream_putle32(&frame->data, atoi(od->sn));
|
|
251 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
|
|
252 byte_stream_putle16(&frame->data, snacid); /* eh. */
|
|
253 byte_stream_putle16(&frame->data, 0x04ba); /* shrug. */
|
|
254 byte_stream_putle32(&frame->data, atoi(uin));
|
13234
|
255
|
13592
|
256 flap_connection_send(conn, frame);
|
13234
|
257
|
|
258 /* Keep track of this request and the ICQ number and request ID */
|
|
259 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info));
|
|
260 info->reqid = snacid;
|
|
261 info->uin = atoi(uin);
|
13592
|
262 info->next = od->icq_info;
|
|
263 od->icq_info = info;
|
13234
|
264
|
|
265 return 0;
|
|
266 }
|
|
267
|
13592
|
268 int aim_icq_getsimpleinfo(OscarData *od, const char *uin)
|
13234
|
269 {
|
13592
|
270 FlapConnection *conn;
|
|
271 FlapFrame *frame;
|
13234
|
272 aim_snacid_t snacid;
|
|
273 int bslen;
|
|
274
|
|
275 if (!uin || uin[0] < '0' || uin[0] > '9')
|
|
276 return -EINVAL;
|
|
277
|
13592
|
278 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
|
13234
|
279 return -EINVAL;
|
|
280
|
|
281 bslen = 2 + 4 + 2 + 2 + 2 + 4;
|
|
282
|
13592
|
283 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
|
13234
|
284
|
13592
|
285 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
|
|
286 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
|
13234
|
287
|
|
288 /* For simplicity, don't bother using a tlvlist */
|
13592
|
289 byte_stream_put16(&frame->data, 0x0001);
|
|
290 byte_stream_put16(&frame->data, bslen);
|
13234
|
291
|
13592
|
292 byte_stream_putle16(&frame->data, bslen - 2);
|
|
293 byte_stream_putle32(&frame->data, atoi(od->sn));
|
|
294 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
|
|
295 byte_stream_putle16(&frame->data, snacid); /* eh. */
|
|
296 byte_stream_putle16(&frame->data, 0x051f); /* shrug. */
|
|
297 byte_stream_putle32(&frame->data, atoi(uin));
|
13234
|
298
|
13592
|
299 flap_connection_send(conn, frame);
|
13234
|
300
|
|
301 return 0;
|
|
302 }
|
|
303
|
|
304 #if 0
|
13592
|
305 int aim_icq_sendxmlreq(OscarData *od, const char *xml)
|
13234
|
306 {
|
13592
|
307 FlapConnection *conn;
|
|
308 FlapFrame *frame;
|
13234
|
309 aim_snacid_t snacid;
|
|
310 int bslen;
|
|
311
|
|
312 if (!xml || !strlen(xml))
|
|
313 return -EINVAL;
|
|
314
|
13592
|
315 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
|
13234
|
316 return -EINVAL;
|
|
317
|
|
318 bslen = 2 + 10 + 2 + strlen(xml) + 1;
|
|
319
|
13592
|
320 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
|
13234
|
321
|
13592
|
322 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
|
|
323 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
|
13234
|
324
|
|
325 /* For simplicity, don't bother using a tlvlist */
|
13592
|
326 byte_stream_put16(&frame->data, 0x0001);
|
|
327 byte_stream_put16(&frame->data, bslen);
|
13234
|
328
|
13592
|
329 byte_stream_putle16(&frame->data, bslen - 2);
|
|
330 byte_stream_putle32(&frame->data, atoi(od->sn));
|
|
331 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
|
|
332 byte_stream_putle16(&frame->data, snacid); /* eh. */
|
|
333 byte_stream_putle16(&frame->data, 0x0998); /* shrug. */
|
|
334 byte_stream_putle16(&frame->data, strlen(xml) + 1);
|
|
335 byte_stream_putraw(&frame->data, (guint8 *)xml, strlen(xml) + 1);
|
13234
|
336
|
13592
|
337 flap_connection_send(conn, frame);
|
13234
|
338
|
|
339 return 0;
|
|
340 }
|
|
341 #endif
|
|
342
|
|
343 #if 0
|
|
344 /*
|
|
345 * Send an SMS message. This is the non-US way. The US-way is to IM
|
|
346 * their cell phone number (+19195551234).
|
|
347 *
|
|
348 * We basically construct and send an XML message. The format is:
|
|
349 * <icq_sms_message>
|
|
350 * <destination>full_phone_without_leading_+</destination>
|
|
351 * <text>message</text>
|
|
352 * <codepage>1252</codepage>
|
|
353 * <senders_UIN>self_uin</senders_UIN>
|
|
354 * <senders_name>self_name</senders_name>
|
|
355 * <delivery_receipt>Yes|No</delivery_receipt>
|
|
356 * <time>Wkd, DD Mmm YYYY HH:MM:SS TMZ</time>
|
|
357 * </icq_sms_message>
|
|
358 *
|
|
359 * Yeah hi Peter, whaaaat's happening. If there's any way to use
|
|
360 * a codepage other than 1252 that would be great. Thaaaanks.
|
|
361 */
|
13592
|
362 int aim_icq_sendsms(OscarData *od, const char *name, const char *msg, const char *alias)
|
13234
|
363 {
|
13592
|
364 FlapConnection *conn;
|
|
365 FlapFrame *frame;
|
13234
|
366 aim_snacid_t snacid;
|
|
367 int bslen, xmllen;
|
|
368 char *xml;
|
|
369 const char *timestr;
|
|
370 time_t t;
|
|
371 struct tm *tm;
|
|
372
|
13592
|
373 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
|
13234
|
374 return -EINVAL;
|
|
375
|
|
376 if (!name || !msg || !alias)
|
|
377 return -EINVAL;
|
|
378
|
|
379 time(&t);
|
|
380 tm = gmtime(&t);
|
|
381 timestr = gaim_utf8_strftime("%a, %d %b %Y %T %Z", tm);
|
|
382
|
|
383 /* The length of xml included the null terminating character */
|
13592
|
384 xmllen = 225 + strlen(name) + strlen(msg) + strlen(od->sn) + strlen(alias) + strlen(timestr) + 1;
|
13234
|
385
|
13592
|
386 xml = g_new(char, xmllen);
|
13234
|
387 snprintf(xml, xmllen, "<icq_sms_message>\n"
|
|
388 "\t<destination>%s</destination>\n"
|
|
389 "\t<text>%s</text>\n"
|
|
390 "\t<codepage>1252</codepage>\n"
|
|
391 "\t<senders_UIN>%s</senders_UIN>\n"
|
|
392 "\t<senders_name>%s</senders_name>\n"
|
|
393 "\t<delivery_receipt>Yes</delivery_receipt>\n"
|
|
394 "\t<time>%s</time>\n"
|
|
395 "</icq_sms_message>\n",
|
13592
|
396 name, msg, od->sn, alias, timestr);
|
13234
|
397
|
|
398 bslen = 37 + xmllen;
|
|
399
|
13592
|
400 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
|
13234
|
401
|
13592
|
402 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
|
|
403 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
|
13234
|
404
|
|
405 /* For simplicity, don't bother using a tlvlist */
|
13592
|
406 byte_stream_put16(&frame->data, 0x0001);
|
|
407 byte_stream_put16(&frame->data, bslen);
|
13234
|
408
|
13592
|
409 byte_stream_putle16(&frame->data, bslen - 2);
|
|
410 byte_stream_putle32(&frame->data, atoi(od->sn));
|
|
411 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
|
|
412 byte_stream_putle16(&frame->data, snacid); /* eh. */
|
13234
|
413
|
|
414 /* From libicq200-0.3.2/src/SNAC-SRV.cpp */
|
13592
|
415 byte_stream_putle16(&frame->data, 0x8214);
|
|
416 byte_stream_put16(&frame->data, 0x0001);
|
|
417 byte_stream_put16(&frame->data, 0x0016);
|
|
418 byte_stream_put32(&frame->data, 0x00000000);
|
|
419 byte_stream_put32(&frame->data, 0x00000000);
|
|
420 byte_stream_put32(&frame->data, 0x00000000);
|
|
421 byte_stream_put32(&frame->data, 0x00000000);
|
13234
|
422
|
13592
|
423 byte_stream_put16(&frame->data, 0x0000);
|
|
424 byte_stream_put16(&frame->data, xmllen);
|
|
425 byte_stream_putstr(&frame->data, xml);
|
13234
|
426
|
13592
|
427 flap_connection_send(conn, frame);
|
13234
|
428
|
|
429 free(xml);
|
|
430
|
|
431 return 0;
|
|
432 }
|
|
433 #endif
|
|
434
|
|
435 static void aim_icq_freeinfo(struct aim_icq_info *info) {
|
|
436 int i;
|
|
437
|
|
438 if (!info)
|
|
439 return;
|
|
440 free(info->nick);
|
|
441 free(info->first);
|
|
442 free(info->last);
|
|
443 free(info->email);
|
|
444 free(info->homecity);
|
|
445 free(info->homestate);
|
|
446 free(info->homephone);
|
|
447 free(info->homefax);
|
|
448 free(info->homeaddr);
|
|
449 free(info->mobile);
|
|
450 free(info->homezip);
|
|
451 free(info->personalwebpage);
|
|
452 if (info->email2)
|
|
453 for (i = 0; i < info->numaddresses; i++)
|
|
454 free(info->email2[i]);
|
|
455 free(info->email2);
|
|
456 free(info->workcity);
|
|
457 free(info->workstate);
|
|
458 free(info->workphone);
|
|
459 free(info->workfax);
|
|
460 free(info->workaddr);
|
|
461 free(info->workzip);
|
|
462 free(info->workcompany);
|
|
463 free(info->workdivision);
|
|
464 free(info->workposition);
|
|
465 free(info->workwebpage);
|
|
466 free(info->info);
|
|
467 free(info);
|
|
468 }
|
|
469
|
|
470 /**
|
|
471 * Subtype 0x0003 - Response to 0x0015/0x002, contains an ICQesque packet.
|
|
472 */
|
13592
|
473 static int
|
|
474 icqresponse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
475 {
|
|
476 int ret = 0;
|
|
477 aim_tlvlist_t *tl;
|
|
478 aim_tlv_t *datatlv;
|
13239
|
479 ByteStream qbs;
|
13234
|
480 guint32 ouruin;
|
|
481 guint16 cmdlen, cmd, reqid;
|
|
482
|
|
483 if (!(tl = aim_tlvlist_read(bs)) || !(datatlv = aim_tlv_gettlv(tl, 0x0001, 1))) {
|
|
484 aim_tlvlist_free(&tl);
|
|
485 gaim_debug_misc("oscar", "corrupt ICQ response\n");
|
|
486 return 0;
|
|
487 }
|
|
488
|
13592
|
489 byte_stream_init(&qbs, datatlv->value, datatlv->length);
|
13234
|
490
|
13592
|
491 cmdlen = byte_stream_getle16(&qbs);
|
|
492 ouruin = byte_stream_getle32(&qbs);
|
|
493 cmd = byte_stream_getle16(&qbs);
|
|
494 reqid = byte_stream_getle16(&qbs);
|
13234
|
495
|
|
496 gaim_debug_misc("oscar", "icq response: %d bytes, %ld, 0x%04x, 0x%04x\n", cmdlen, ouruin, cmd, reqid);
|
|
497
|
|
498 if (cmd == 0x0041) { /* offline message */
|
|
499 struct aim_icq_offlinemsg msg;
|
|
500 aim_rxcallback_t userfunc;
|
|
501
|
|
502 memset(&msg, 0, sizeof(msg));
|
|
503
|
13592
|
504 msg.sender = byte_stream_getle32(&qbs);
|
|
505 msg.year = byte_stream_getle16(&qbs);
|
|
506 msg.month = byte_stream_getle8(&qbs);
|
|
507 msg.day = byte_stream_getle8(&qbs);
|
|
508 msg.hour = byte_stream_getle8(&qbs);
|
|
509 msg.minute = byte_stream_getle8(&qbs);
|
|
510 msg.type = byte_stream_getle8(&qbs);
|
|
511 msg.flags = byte_stream_getle8(&qbs);
|
|
512 msg.msglen = byte_stream_getle16(&qbs);
|
|
513 msg.msg = byte_stream_getstr(&qbs, msg.msglen);
|
13234
|
514
|
13592
|
515 if ((userfunc = aim_callhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_OFFLINEMSG)))
|
|
516 ret = userfunc(od, conn, frame, &msg);
|
13234
|
517
|
|
518 free(msg.msg);
|
|
519
|
|
520 } else if (cmd == 0x0042) {
|
|
521 aim_rxcallback_t userfunc;
|
|
522
|
13592
|
523 if ((userfunc = aim_callhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_OFFLINEMSGCOMPLETE)))
|
|
524 ret = userfunc(od, conn, frame);
|
13234
|
525
|
|
526 } else if (cmd == 0x07da) { /* information */
|
|
527 guint16 subtype;
|
|
528 struct aim_icq_info *info;
|
|
529 aim_rxcallback_t userfunc;
|
|
530
|
13592
|
531 subtype = byte_stream_getle16(&qbs);
|
|
532 byte_stream_advance(&qbs, 1); /* 0x0a */
|
13234
|
533
|
|
534 /* find other data from the same request */
|
13592
|
535 for (info = od->icq_info; info && (info->reqid != reqid); info = info->next);
|
13234
|
536 if (!info) {
|
|
537 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info));
|
|
538 info->reqid = reqid;
|
13592
|
539 info->next = od->icq_info;
|
|
540 od->icq_info = info;
|
13234
|
541 }
|
|
542
|
|
543 switch (subtype) {
|
|
544 case 0x00a0: { /* hide ip status */
|
|
545 /* nothing */
|
|
546 } break;
|
|
547
|
|
548 case 0x00aa: { /* password change status */
|
|
549 /* nothing */
|
|
550 } break;
|
|
551
|
|
552 case 0x00c8: { /* general and "home" information */
|
13592
|
553 info->nick = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
554 info->first = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
555 info->last = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
556 info->email = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
557 info->homecity = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
558 info->homestate = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
559 info->homephone = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
560 info->homefax = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
561 info->homeaddr = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
562 info->mobile = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
563 info->homezip = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
564 info->homecountry = byte_stream_getle16(&qbs);
|
13234
|
565 /* 0x0a 00 02 00 */
|
|
566 /* 1 byte timezone? */
|
|
567 /* 1 byte hide email flag? */
|
|
568 } break;
|
|
569
|
|
570 case 0x00dc: { /* personal information */
|
13592
|
571 info->age = byte_stream_getle8(&qbs);
|
|
572 info->unknown = byte_stream_getle8(&qbs);
|
|
573 info->gender = byte_stream_getle8(&qbs); /* Not specified=0x00, Female=0x01, Male=0x02 */
|
|
574 info->personalwebpage = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
575 info->birthyear = byte_stream_getle16(&qbs);
|
|
576 info->birthmonth = byte_stream_getle8(&qbs);
|
|
577 info->birthday = byte_stream_getle8(&qbs);
|
|
578 info->language1 = byte_stream_getle8(&qbs);
|
|
579 info->language2 = byte_stream_getle8(&qbs);
|
|
580 info->language3 = byte_stream_getle8(&qbs);
|
13234
|
581 /* 0x00 00 01 00 00 01 00 00 00 00 00 */
|
|
582 } break;
|
|
583
|
|
584 case 0x00d2: { /* work information */
|
13592
|
585 info->workcity = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
586 info->workstate = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
587 info->workphone = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
588 info->workfax = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
589 info->workaddr = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
590 info->workzip = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
591 info->workcountry = byte_stream_getle16(&qbs);
|
|
592 info->workcompany = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
593 info->workdivision = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
594 info->workposition = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
595 byte_stream_advance(&qbs, 2); /* 0x01 00 */
|
|
596 info->workwebpage = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
13234
|
597 } break;
|
|
598
|
|
599 case 0x00e6: { /* additional personal information */
|
13592
|
600 info->info = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs)-1);
|
13234
|
601 } break;
|
|
602
|
|
603 case 0x00eb: { /* email address(es) */
|
|
604 int i;
|
13592
|
605 info->numaddresses = byte_stream_getle16(&qbs);
|
13234
|
606 info->email2 = (char **)calloc(info->numaddresses, sizeof(char *));
|
|
607 for (i = 0; i < info->numaddresses; i++) {
|
13592
|
608 info->email2[i] = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
13234
|
609 if (i+1 != info->numaddresses)
|
13592
|
610 byte_stream_advance(&qbs, 1); /* 0x00 */
|
13234
|
611 }
|
|
612 } break;
|
|
613
|
|
614 case 0x00f0: { /* personal interests */
|
|
615 } break;
|
|
616
|
|
617 case 0x00fa: { /* past background and current organizations */
|
|
618 } break;
|
|
619
|
|
620 case 0x0104: { /* alias info */
|
13592
|
621 info->nick = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
622 info->first = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
623 info->last = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
624 byte_stream_advance(&qbs, byte_stream_getle16(&qbs)); /* email address? */
|
13234
|
625 /* Then 0x00 02 00 */
|
|
626 } break;
|
|
627
|
|
628 case 0x010e: { /* unknown */
|
|
629 /* 0x00 00 */
|
|
630 } break;
|
|
631
|
|
632 case 0x019a: { /* simple info */
|
13592
|
633 byte_stream_advance(&qbs, 2);
|
|
634 info->uin = byte_stream_getle32(&qbs);
|
|
635 info->nick = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
636 info->first = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
637 info->last = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
|
638 info->email = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
|
13234
|
639 /* Then 0x00 02 00 00 00 00 00 */
|
|
640 } break;
|
|
641 } /* End switch statement */
|
|
642
|
|
643 if (!(snac->flags & 0x0001)) {
|
|
644 if (subtype != 0x0104)
|
13592
|
645 if ((userfunc = aim_callhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_INFO)))
|
|
646 ret = userfunc(od, conn, frame, info);
|
13234
|
647
|
|
648 if (info->uin && info->nick)
|
13592
|
649 if ((userfunc = aim_callhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_ALIAS)))
|
|
650 ret = userfunc(od, conn, frame, info);
|
13234
|
651
|
13592
|
652 if (od->icq_info == info) {
|
|
653 od->icq_info = info->next;
|
13234
|
654 } else {
|
|
655 struct aim_icq_info *cur;
|
13592
|
656 for (cur=od->icq_info; (cur->next && (cur->next!=info)); cur=cur->next);
|
13234
|
657 if (cur->next)
|
|
658 cur->next = cur->next->next;
|
|
659 }
|
|
660 aim_icq_freeinfo(info);
|
|
661 }
|
|
662 }
|
|
663
|
|
664 aim_tlvlist_free(&tl);
|
|
665
|
|
666 return ret;
|
|
667 }
|
|
668
|
13592
|
669 static int
|
|
670 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
671 {
|
|
672 if (snac->subtype == 0x0003)
|
13592
|
673 return icqresponse(od, conn, mod, frame, snac, bs);
|
13234
|
674
|
|
675 return 0;
|
|
676 }
|
|
677
|
13592
|
678 static void
|
|
679 icq_shutdown(OscarData *od, aim_module_t *mod)
|
13234
|
680 {
|
|
681 struct aim_icq_info *del;
|
|
682
|
13592
|
683 while (od->icq_info) {
|
|
684 del = od->icq_info;
|
|
685 od->icq_info = od->icq_info->next;
|
13234
|
686 aim_icq_freeinfo(del);
|
|
687 }
|
|
688
|
|
689 return;
|
|
690 }
|
|
691
|
13592
|
692 int
|
|
693 icq_modfirst(OscarData *od, aim_module_t *mod)
|
13234
|
694 {
|
|
695 mod->family = 0x0015;
|
|
696 mod->version = 0x0001;
|
|
697 mod->toolid = 0x0110;
|
|
698 mod->toolversion = 0x047c;
|
|
699 mod->flags = 0;
|
|
700 strncpy(mod->name, "icq", sizeof(mod->name));
|
|
701 mod->snachandler = snachandler;
|
|
702 mod->shutdown = icq_shutdown;
|
|
703
|
|
704 return 0;
|
|
705 }
|