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