7011
|
1 /*
|
|
2 * Family 0x0002 - Locate.
|
|
3 *
|
|
4 * The functions here are responsible for requesting and parsing information-
|
|
5 * gathering SNACs. Or something like that. This family contains the SNACs
|
|
6 * for getting and setting info, away messages, directory profile thingy, etc.
|
|
7 */
|
|
8
|
|
9 #define FAIM_INTERNAL
|
|
10 #include <aim.h>
|
|
11 #ifdef _WIN32
|
|
12 #include "win32dep.h"
|
|
13 #endif
|
|
14
|
|
15 struct node {
|
|
16 char *sn;
|
|
17 struct node *next;
|
|
18 };
|
|
19
|
|
20 /**
|
|
21 * Keep an aim_userinfo_t for each user we are aware of.
|
|
22 */
|
|
23 static aim_userinfo_t *infos = NULL;
|
|
24 static struct node *request_queue = NULL;
|
|
25 static int waiting_for_response = FALSE;
|
|
26
|
|
27 /*
|
|
28 * Capability blocks.
|
|
29 *
|
|
30 * These are CLSIDs. They should actually be of the form:
|
|
31 *
|
|
32 * {0x0946134b, 0x4c7f, 0x11d1,
|
|
33 * {0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}},
|
|
34 *
|
|
35 * But, eh.
|
|
36 */
|
|
37 static const struct {
|
|
38 fu32_t flag;
|
|
39 fu8_t data[16];
|
|
40 } aim_caps[] = {
|
|
41
|
|
42 /*
|
|
43 * These are in ascending numerical order.
|
|
44 */
|
|
45 {AIM_CAPS_ICHAT,
|
|
46 {0x09, 0x46, 0x00, 0x00, 0x4c, 0x7f, 0x11, 0xd1,
|
|
47 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
48
|
|
49 {AIM_CAPS_SECUREIM,
|
|
50 {0x09, 0x46, 0x00, 0x01, 0x4c, 0x7f, 0x11, 0xd1,
|
|
51 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
52
|
7025
|
53 /*
|
|
54 * Not really sure about this one. In an email from
|
|
55 * 26 Sep 2003, Matthew Sachs suggested that, "this
|
|
56 * is probably the capability for the SMS features."
|
|
57 */
|
|
58 {AIM_CAPS_SMS,
|
|
59 {0x09, 0x46, 0x01, 0xff, 0x4c, 0x7f, 0x11, 0xd1,
|
|
60 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
61
|
|
62 {AIM_CAPS_APPLESOMETHIN1,
|
|
63 {0x09, 0x46, 0xf0, 0x03, 0x4c, 0x7f, 0x11, 0xd1,
|
|
64 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
65
|
|
66 {AIM_CAPS_APPLESOMETHIN2,
|
|
67 {0x09, 0x46, 0xf0, 0x04, 0x4c, 0x7f, 0x11, 0xd1,
|
|
68 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
69
|
|
70 {AIM_CAPS_APPLESOMETHIN3,
|
|
71 {0x09, 0x46, 0xf0, 0x05, 0x4c, 0x7f, 0x11, 0xd1,
|
|
72 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
73
|
7011
|
74 {AIM_CAPS_HIPTOP,
|
|
75 {0x09, 0x46, 0x13, 0x23, 0x4c, 0x7f, 0x11, 0xd1,
|
|
76 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
77
|
|
78 {AIM_CAPS_VOICE,
|
|
79 {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1,
|
|
80 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
81
|
|
82 {AIM_CAPS_SENDFILE,
|
|
83 {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1,
|
|
84 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
85
|
|
86 /*
|
|
87 * Advertised by the EveryBuddy client.
|
|
88 */
|
|
89 {AIM_CAPS_ICQ,
|
|
90 {0x09, 0x46, 0x13, 0x44, 0x4c, 0x7f, 0x11, 0xd1,
|
|
91 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
92
|
|
93 {AIM_CAPS_DIRECTIM,
|
|
94 {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1,
|
|
95 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
96
|
|
97 {AIM_CAPS_BUDDYICON,
|
|
98 {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1,
|
|
99 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
100
|
|
101 /*
|
|
102 * Windows AIM calls this "Add-ins," which is probably more accurate
|
|
103 */
|
|
104 {AIM_CAPS_SAVESTOCKS,
|
|
105 {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1,
|
|
106 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
107
|
|
108 {AIM_CAPS_GETFILE,
|
|
109 {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1,
|
|
110 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
111
|
|
112 {AIM_CAPS_ICQSERVERRELAY,
|
|
113 {0x09, 0x46, 0x13, 0x49, 0x4c, 0x7f, 0x11, 0xd1,
|
|
114 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
115
|
|
116 /*
|
|
117 * Indeed, there are two of these. The former appears to be correct,
|
|
118 * but in some versions of winaim, the second one is set. Either they
|
|
119 * forgot to fix endianness, or they made a typo. It really doesn't
|
|
120 * matter which.
|
|
121 */
|
|
122 {AIM_CAPS_GAMES,
|
|
123 {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
|
|
124 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
125 {AIM_CAPS_GAMES2,
|
|
126 {0x09, 0x46, 0x13, 0x4a, 0x4c, 0x7f, 0x11, 0xd1,
|
|
127 0x22, 0x82, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
128
|
|
129 {AIM_CAPS_SENDBUDDYLIST,
|
|
130 {0x09, 0x46, 0x13, 0x4b, 0x4c, 0x7f, 0x11, 0xd1,
|
|
131 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
132
|
|
133 /*
|
|
134 * Setting this lets AIM users receive messages from ICQ users, and ICQ
|
|
135 * users receive messages from AIM users. It also lets ICQ users show
|
|
136 * up in buddy lists for AIM users, and AIM users show up in buddy lists
|
|
137 * for ICQ users. And ICQ privacy/invisibility acts like AIM privacy,
|
|
138 * in that if you add a user to your deny list, you will not be able to
|
|
139 * see them as online (previous you could still see them, but they
|
|
140 * couldn't see you.
|
|
141 */
|
|
142 {AIM_CAPS_INTEROPERATE,
|
|
143 {0x09, 0x46, 0x13, 0x4d, 0x4c, 0x7f, 0x11, 0xd1,
|
|
144 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
145
|
|
146 {AIM_CAPS_ICQUTF8,
|
|
147 {0x09, 0x46, 0x13, 0x4e, 0x4c, 0x7f, 0x11, 0xd1,
|
|
148 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
149
|
|
150 {AIM_CAPS_ICQUTF8OLD,
|
|
151 {0x2e, 0x7a, 0x64, 0x75, 0xfa, 0xdf, 0x4d, 0xc8,
|
|
152 0x88, 0x6f, 0xea, 0x35, 0x95, 0xfd, 0xb6, 0xdf}},
|
|
153
|
|
154 /*
|
|
155 * Chat is oddball.
|
|
156 */
|
|
157 {AIM_CAPS_CHAT,
|
|
158 {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1,
|
|
159 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}},
|
|
160
|
|
161 /*
|
|
162 {AIM_CAPS_ICQ2GO,
|
|
163 {0x56, 0x3f, 0xc8, 0x09, 0x0b, 0x6f, 0x41, 0xbd,
|
|
164 0x9f, 0x79, 0x42, 0x26, 0x09, 0xdf, 0xa2, 0xf3}},
|
|
165 */
|
|
166
|
|
167 {AIM_CAPS_ICQRTF,
|
|
168 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
|
|
169 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x92}},
|
|
170
|
|
171 /* supposed to be ICQRTF?
|
|
172 {AIM_CAPS_TRILLUNKNOWN,
|
|
173 {0x97, 0xb1, 0x27, 0x51, 0x24, 0x3c, 0x43, 0x34,
|
|
174 0xad, 0x22, 0xd6, 0xab, 0xf7, 0x3f, 0x14, 0x09}}, */
|
|
175
|
|
176 {AIM_CAPS_APINFO,
|
|
177 {0xaa, 0x4a, 0x32, 0xb5, 0xf8, 0x84, 0x48, 0xc6,
|
|
178 0xa3, 0xd7, 0x8c, 0x50, 0x97, 0x19, 0xfd, 0x5b}},
|
|
179
|
|
180 {AIM_CAPS_TRILLIANCRYPT,
|
|
181 {0xf2, 0xe7, 0xc7, 0xf4, 0xfe, 0xad, 0x4d, 0xfb,
|
|
182 0xb2, 0x35, 0x36, 0x79, 0x8b, 0xdf, 0x00, 0x00}},
|
|
183
|
|
184 {AIM_CAPS_EMPTY,
|
|
185 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
|
|
187
|
|
188 {AIM_CAPS_LAST}
|
|
189 };
|
|
190
|
|
191 /*
|
|
192 * Add the userinfo to our linked list. If we already have userinfo
|
|
193 * for this buddy, then just overwrite parts of the old data.
|
|
194 * @param userinfo Contains the new information for the buddy.
|
|
195 */
|
|
196 static void aim_locate_adduserinfo(aim_userinfo_t *userinfo) {
|
|
197 aim_userinfo_t *cur;
|
|
198
|
|
199 cur = aim_locate_finduserinfo(userinfo->sn);
|
|
200
|
|
201 if (cur == NULL) {
|
|
202 cur = (aim_userinfo_t *)calloc(1, sizeof(aim_userinfo_t));
|
|
203 cur->sn = strdup(userinfo->sn);
|
|
204 cur->next = infos;
|
|
205 infos = cur;
|
|
206 }
|
|
207
|
|
208 cur->warnlevel = userinfo->warnlevel;
|
|
209 cur->idletime = userinfo->idletime;
|
|
210 if (userinfo->flags != 0)
|
|
211 cur->flags = userinfo->flags;
|
|
212 if (userinfo->createtime != 0)
|
|
213 cur->createtime = userinfo->createtime;
|
|
214 if (userinfo->membersince != 0)
|
|
215 cur->membersince = userinfo->membersince;
|
|
216 if (userinfo->onlinesince != 0)
|
|
217 cur->onlinesince = userinfo->onlinesince;
|
|
218 if (userinfo->sessionlen != 0)
|
|
219 cur->sessionlen = userinfo->sessionlen;
|
|
220 if (userinfo->capabilities != 0)
|
|
221 cur->capabilities = userinfo->capabilities;
|
|
222 cur->present |= userinfo->present;
|
|
223
|
|
224 if ((userinfo->away != NULL) && (userinfo->away_len > 0)) {
|
|
225 free(cur->away);
|
|
226 free(cur->away_encoding);
|
|
227 cur->away = (char *)malloc(userinfo->away_len);
|
|
228 memcpy(cur->away, userinfo->away, userinfo->away_len);
|
|
229 cur->away_encoding = strdup(userinfo->away_encoding); /* XXX - This seems to leak occasionally */
|
|
230 cur->away_len = userinfo->away_len;
|
|
231 }
|
|
232
|
|
233 if ((userinfo->info != NULL) && (userinfo->info_len > 0)) {
|
|
234 free(cur->info);
|
|
235 free(cur->info_encoding);
|
|
236 cur->info = (char *)malloc(userinfo->info_len);
|
|
237 memcpy(cur->info, userinfo->info, userinfo->info_len);
|
|
238 cur->info_encoding = strdup(userinfo->info_encoding); /* XXX - This seems to leak occasionally */
|
|
239 cur->info_len = userinfo->info_len;
|
|
240 }
|
|
241 }
|
|
242
|
|
243 static void aim_locate_dorequest(aim_session_t *sess) {
|
|
244 struct node *cur = request_queue;
|
|
245
|
|
246 if (cur == NULL)
|
|
247 return;
|
|
248
|
|
249 if (waiting_for_response == TRUE)
|
|
250 return;
|
|
251
|
|
252 waiting_for_response = TRUE;
|
|
253 aim_locate_getinfoshort(sess, cur->sn, 0x00000007);
|
|
254 }
|
|
255
|
|
256 faim_internal void aim_locate_requestuserinfo(aim_session_t *sess, const char *sn) {
|
|
257 struct node *cur;
|
|
258
|
|
259 cur = (struct node *)malloc(sizeof(struct node));
|
|
260 cur->sn = strdup(sn);
|
|
261 cur->next = request_queue;
|
|
262 request_queue = cur;
|
|
263
|
|
264 aim_locate_dorequest(sess);
|
|
265 }
|
|
266
|
|
267 faim_export aim_userinfo_t *aim_locate_finduserinfo(const char *sn) {
|
|
268 aim_userinfo_t *cur = infos;
|
|
269
|
|
270 while (cur != NULL) {
|
|
271 if (aim_sncmp(cur->sn, sn) == 0)
|
|
272 return cur;
|
|
273 cur = cur->next;
|
|
274 }
|
|
275
|
|
276 return NULL;
|
|
277 }
|
|
278
|
|
279 /*
|
|
280 * This still takes a length parameter even with a bstream because capabilities
|
|
281 * are not naturally bounded.
|
|
282 */
|
|
283 faim_internal fu32_t aim_getcap(aim_session_t *sess, aim_bstream_t *bs, int len)
|
|
284 {
|
|
285 fu32_t flags = 0;
|
|
286 int offset;
|
|
287
|
|
288 for (offset = 0; aim_bstream_empty(bs) && (offset < len); offset += 0x10) {
|
|
289 fu8_t *cap;
|
|
290 int i, identified;
|
|
291
|
|
292 cap = aimbs_getraw(bs, 0x10);
|
|
293
|
|
294 for (i = 0, identified = 0; !(aim_caps[i].flag & AIM_CAPS_LAST); i++) {
|
|
295
|
|
296 if (memcmp(&aim_caps[i].data, cap, 0x10) == 0) {
|
|
297 flags |= aim_caps[i].flag;
|
|
298 identified++;
|
|
299 break; /* should only match once... */
|
|
300
|
|
301 }
|
|
302 }
|
|
303
|
|
304 if (!identified) {
|
|
305 faimdprintf(sess, 0, "unknown capability: {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
|
|
306 cap[0], cap[1], cap[2], cap[3],
|
|
307 cap[4], cap[5],
|
|
308 cap[6], cap[7],
|
|
309 cap[8], cap[9],
|
|
310 cap[10], cap[11], cap[12], cap[13],
|
|
311 cap[14], cap[15]);
|
|
312 }
|
|
313
|
|
314 free(cap);
|
|
315 }
|
|
316
|
|
317 return flags;
|
|
318 }
|
|
319
|
|
320 faim_internal int aim_putcap(aim_bstream_t *bs, fu32_t caps)
|
|
321 {
|
|
322 int i;
|
|
323
|
|
324 if (!bs)
|
|
325 return -EINVAL;
|
|
326
|
|
327 for (i = 0; aim_bstream_empty(bs); i++) {
|
|
328
|
|
329 if (aim_caps[i].flag == AIM_CAPS_LAST)
|
|
330 break;
|
|
331
|
|
332 if (caps & aim_caps[i].flag)
|
|
333 aimbs_putraw(bs, aim_caps[i].data, 0x10);
|
|
334
|
|
335 }
|
|
336
|
|
337 return 0;
|
|
338 }
|
|
339
|
|
340 static void dumptlv(aim_session_t *sess, fu16_t type, aim_bstream_t *bs, fu8_t len)
|
|
341 {
|
|
342 int i;
|
|
343
|
|
344 if (!sess || !bs || !len)
|
|
345 return;
|
|
346
|
|
347 faimdprintf(sess, 0, "userinfo: type =0x%04x\n", type);
|
|
348 faimdprintf(sess, 0, "userinfo: length=0x%04x\n", len);
|
|
349 faimdprintf(sess, 0, "userinfo: value:\n");
|
|
350
|
|
351 for (i = 0; i < len; i++) {
|
|
352 if ((i % 8) == 0)
|
|
353 faimdprintf(sess, 0, "\nuserinfo: ");
|
|
354 faimdprintf(sess, 0, "0x%2x ", aimbs_get8(bs));
|
|
355 }
|
|
356
|
|
357 faimdprintf(sess, 0, "\n");
|
|
358
|
|
359 return;
|
|
360 }
|
|
361
|
|
362 faim_internal void aim_info_free(aim_userinfo_t *info)
|
|
363 {
|
|
364 free(info->sn);
|
|
365 free(info->iconcsum);
|
|
366 free(info->info);
|
|
367 free(info->info_encoding);
|
|
368 free(info->avail);
|
|
369 free(info->avail_encoding);
|
|
370 free(info->away);
|
|
371 free(info->away_encoding);
|
|
372 }
|
|
373
|
|
374 /*
|
|
375 * AIM is fairly regular about providing user info. This is a generic
|
|
376 * routine to extract it in its standard form.
|
|
377 */
|
|
378 faim_internal int aim_info_extract(aim_session_t *sess, aim_bstream_t *bs, aim_userinfo_t *outinfo)
|
|
379 {
|
|
380 int curtlv, tlvcnt;
|
|
381 fu8_t snlen;
|
|
382
|
|
383 if (!bs || !outinfo)
|
|
384 return -EINVAL;
|
|
385
|
|
386 /* Clear out old data first */
|
|
387 memset(outinfo, 0x00, sizeof(aim_userinfo_t));
|
|
388
|
|
389 /*
|
|
390 * Screen name. Stored as an unterminated string prepended with a
|
|
391 * byte containing its length.
|
|
392 */
|
|
393 snlen = aimbs_get8(bs);
|
|
394 outinfo->sn = aimbs_getstr(bs, snlen);
|
|
395
|
|
396 /*
|
|
397 * Warning Level. Stored as an unsigned short.
|
|
398 */
|
|
399 outinfo->warnlevel = aimbs_get16(bs);
|
|
400
|
|
401 /*
|
|
402 * TLV Count. Unsigned short representing the number of
|
|
403 * Type-Length-Value triples that follow.
|
|
404 */
|
|
405 tlvcnt = aimbs_get16(bs);
|
|
406
|
|
407 /*
|
|
408 * Parse out the Type-Length-Value triples as they're found.
|
|
409 */
|
|
410 for (curtlv = 0; curtlv < tlvcnt; curtlv++) {
|
|
411 int endpos;
|
|
412 fu16_t type, length;
|
|
413
|
|
414 type = aimbs_get16(bs);
|
|
415 length = aimbs_get16(bs);
|
|
416
|
|
417 endpos = aim_bstream_curpos(bs) + length;
|
|
418
|
|
419 if (type == 0x0001) {
|
|
420 /*
|
|
421 * Type = 0x0001: User flags
|
|
422 *
|
|
423 * Specified as any of the following ORed together:
|
|
424 * 0x0001 Trial (user less than 60days)
|
|
425 * 0x0002 Unknown bit 2
|
|
426 * 0x0004 AOL Main Service user
|
|
427 * 0x0008 Unknown bit 4
|
|
428 * 0x0010 Free (AIM) user
|
|
429 * 0x0020 Away
|
|
430 * 0x0400 ActiveBuddy
|
|
431 *
|
|
432 */
|
|
433 outinfo->flags = aimbs_get16(bs);
|
|
434 outinfo->present |= AIM_USERINFO_PRESENT_FLAGS;
|
|
435
|
|
436 } else if (type == 0x0002) {
|
|
437 /*
|
|
438 * Type = 0x0002: Account creation time.
|
|
439 *
|
|
440 * The time/date that the user originally registered for
|
|
441 * the service, stored in time_t format.
|
|
442 *
|
|
443 * I'm not sure how this differs from type 5 ("member
|
|
444 * since").
|
|
445 *
|
|
446 * Note: This is the field formerly known as "member
|
|
447 * since". All these years and I finally found out
|
|
448 * that I got the name wrong.
|
|
449 */
|
|
450 outinfo->createtime = aimbs_get32(bs);
|
|
451 outinfo->present |= AIM_USERINFO_PRESENT_CREATETIME;
|
|
452
|
|
453 } else if (type == 0x0003) {
|
|
454 /*
|
|
455 * Type = 0x0003: On-Since date.
|
|
456 *
|
|
457 * The time/date that the user started their current
|
|
458 * session, stored in time_t format.
|
|
459 */
|
|
460 outinfo->onlinesince = aimbs_get32(bs);
|
|
461 outinfo->present |= AIM_USERINFO_PRESENT_ONLINESINCE;
|
|
462
|
|
463 } else if (type == 0x0004) {
|
|
464 /*
|
|
465 * Type = 0x0004: Idle time.
|
|
466 *
|
|
467 * Number of minutes since the user actively used the
|
|
468 * service.
|
|
469 *
|
|
470 * Note that the client tells the server when to start
|
|
471 * counting idle times, so this may or may not be
|
|
472 * related to reality.
|
|
473 */
|
|
474 outinfo->idletime = aimbs_get16(bs);
|
|
475 outinfo->present |= AIM_USERINFO_PRESENT_IDLE;
|
|
476
|
|
477 } else if (type == 0x0005) {
|
|
478 /*
|
|
479 * Type = 0x0005: Member since date.
|
|
480 *
|
|
481 * The time/date that the user originally registered for
|
|
482 * the service, stored in time_t format.
|
|
483 *
|
|
484 * This is sometimes sent instead of type 2 ("account
|
|
485 * creation time"), particularly in the self-info.
|
|
486 * And particularly for ICQ?
|
|
487 */
|
|
488 outinfo->membersince = aimbs_get32(bs);
|
|
489 outinfo->present |= AIM_USERINFO_PRESENT_MEMBERSINCE;
|
|
490
|
|
491 } else if (type == 0x0006) {
|
|
492 /*
|
|
493 * Type = 0x0006: ICQ Online Status
|
|
494 *
|
|
495 * ICQ's Away/DND/etc "enriched" status. Some decoding
|
|
496 * of values done by Scott <darkagl@pcnet.com>
|
|
497 */
|
|
498 aimbs_get16(bs);
|
|
499 outinfo->icqinfo.status = aimbs_get16(bs);
|
|
500 outinfo->present |= AIM_USERINFO_PRESENT_ICQEXTSTATUS;
|
|
501
|
|
502 } else if (type == 0x000a) {
|
|
503 /*
|
|
504 * Type = 0x000a
|
|
505 *
|
|
506 * ICQ User IP Address.
|
|
507 * Ahh, the joy of ICQ security.
|
|
508 */
|
|
509 outinfo->icqinfo.ipaddr = aimbs_get32(bs);
|
|
510 outinfo->present |= AIM_USERINFO_PRESENT_ICQIPADDR;
|
|
511
|
|
512 } else if (type == 0x000c) {
|
|
513 /*
|
|
514 * Type = 0x000c
|
|
515 *
|
|
516 * random crap containing the IP address,
|
|
517 * apparently a port number, and some Other Stuff.
|
|
518 *
|
|
519 * Format is:
|
|
520 * 4 bytes - Our IP address, 0xc0 a8 01 2b for 192.168.1.43
|
|
521 *
|
|
522 *
|
|
523 */
|
|
524 aimbs_getrawbuf(bs, outinfo->icqinfo.crap, 0x25);
|
|
525 outinfo->present |= AIM_USERINFO_PRESENT_ICQDATA;
|
|
526
|
|
527 } else if (type == 0x000d) {
|
|
528 /*
|
|
529 * Type = 0x000d
|
|
530 *
|
|
531 * Capability information.
|
|
532 *
|
|
533 */
|
|
534 outinfo->capabilities = aim_getcap(sess, bs, length);
|
|
535 outinfo->present |= AIM_USERINFO_PRESENT_CAPABILITIES;
|
|
536
|
|
537 } else if (type == 0x000e) {
|
|
538 /*
|
|
539 * Type = 0x000e
|
|
540 *
|
|
541 * Unknown. Always of zero length, and always only
|
|
542 * on AOL users.
|
|
543 *
|
|
544 * Ignore.
|
|
545 *
|
|
546 */
|
|
547
|
|
548 } else if ((type == 0x000f) || (type == 0x0010)) {
|
|
549 /*
|
|
550 * Type = 0x000f: Session Length. (AIM)
|
|
551 * Type = 0x0010: Session Length. (AOL)
|
|
552 *
|
|
553 * The duration, in seconds, of the user's current
|
|
554 * session.
|
|
555 *
|
|
556 * Which TLV type this comes in depends on the
|
|
557 * service the user is using (AIM or AOL).
|
|
558 *
|
|
559 */
|
|
560 outinfo->sessionlen = aimbs_get32(bs);
|
|
561 outinfo->present |= AIM_USERINFO_PRESENT_SESSIONLEN;
|
|
562
|
|
563 } else if (type == 0x0019) {
|
|
564 /* faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV type 0x0019: from %s\n", outinfo->sn); */
|
|
565
|
|
566 } else if (type == 0x001b) {
|
|
567 /* faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV type 0x001b: from %s\n", outinfo->sn); */
|
|
568
|
|
569 } else if (type == 0x001d) {
|
|
570 /*
|
|
571 * Type = 0x001d
|
|
572 *
|
|
573 * Buddy icon information and available messages.
|
|
574 *
|
|
575 * This almost seems like the AIM protocol guys gave
|
|
576 * the iChat guys a Type, and the iChat guys tried to
|
|
577 * cram as much cool shit into it as possible. Then
|
|
578 * the Windows AIM guys were like, "hey, that's
|
|
579 * pretty neat, let's copy those prawns."
|
|
580 *
|
|
581 * In that spirit, this can contain a custom message,
|
|
582 * kind of like an away message, but you're not away
|
|
583 * (it's called an "available" message). Or it can
|
|
584 * contain information about the buddy icon the user
|
|
585 * has stored on the server.
|
|
586 */
|
|
587 int type2, number, length2;
|
|
588
|
|
589 while (aim_bstream_curpos(bs) < endpos) {
|
|
590 type2 = aimbs_get16(bs);
|
|
591 number = aimbs_get8(bs);
|
|
592 length2 = aimbs_get8(bs);
|
|
593
|
|
594 switch (type2) {
|
|
595 case 0x0000: { /* This is an official buddy icon? */
|
|
596 /* This is always 5 bytes of "0x02 01 d2 04 72"? */
|
|
597 aim_bstream_advance(bs, length2);
|
|
598 } break;
|
|
599
|
|
600 case 0x0001: { /* A buddy icon checksum */
|
|
601 if ((length2 > 0) && (number == 0x01)) {
|
|
602 free(outinfo->iconcsum);
|
|
603 outinfo->iconcsum = aimbs_getraw(bs, length2);
|
|
604 outinfo->iconcsumlen = length2;
|
|
605 } else
|
|
606 aim_bstream_advance(bs, length2);
|
|
607 } break;
|
|
608
|
|
609 case 0x0002: { /* An available message */
|
|
610 if (length2 > 4) {
|
|
611 free(outinfo->avail);
|
|
612 outinfo->avail_len = aimbs_get16(bs);
|
|
613 outinfo->avail = aimbs_getstr(bs, outinfo->avail_len);
|
|
614 if (aimbs_get16(bs) == 0x0001) { /* We have an encoding */
|
|
615 aimbs_get16(bs);
|
|
616 outinfo->avail_encoding = aimbs_getstr(bs, aimbs_get16(bs));
|
|
617 } else {
|
|
618 /* No explicit encoding, client should use UTF-8 */
|
|
619 outinfo->avail_encoding = NULL;
|
|
620 }
|
|
621 } else
|
|
622 aim_bstream_advance(bs, length2);
|
|
623 } break;
|
|
624
|
|
625 default: {
|
|
626 aim_bstream_advance(bs, length2);
|
|
627 } break;
|
|
628 }
|
|
629 }
|
|
630
|
|
631 } else if (type == 0x001e) {
|
|
632 /*
|
|
633 * Type 30: Unknown.
|
|
634 *
|
|
635 * Always four bytes, but it doesn't look like an int.
|
|
636 */
|
7025
|
637
|
|
638 } else if (type == 0x001f) {
|
|
639 /*
|
|
640 * Type 31: Unknown.
|
|
641 *
|
|
642 * Seen on a buddy using DeadAIM. Data was 4 bytes:
|
|
643 * 0x00 00 00 10
|
|
644 */
|
|
645
|
7011
|
646 } else {
|
|
647
|
|
648 /*
|
|
649 * Reaching here indicates that either AOL has
|
|
650 * added yet another TLV for us to deal with,
|
|
651 * or the parsing has gone Terribly Wrong.
|
|
652 *
|
|
653 * Either way, inform the owner and attempt
|
|
654 * recovery.
|
|
655 *
|
|
656 */
|
|
657 faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV:\n");
|
|
658 faimdprintf(sess, 0, "userinfo: sn =%s\n", outinfo->sn);
|
|
659 dumptlv(sess, type, bs, length);
|
|
660 }
|
|
661
|
|
662 /* Save ourselves. */
|
|
663 aim_bstream_setpos(bs, endpos);
|
|
664 }
|
|
665
|
|
666 aim_locate_adduserinfo(outinfo);
|
|
667
|
|
668 return 0;
|
|
669 }
|
|
670
|
|
671 /*
|
|
672 * Inverse of aim_info_extract()
|
|
673 */
|
|
674 faim_internal int aim_putuserinfo(aim_bstream_t *bs, aim_userinfo_t *info)
|
|
675 {
|
|
676 aim_tlvlist_t *tlvlist = NULL;
|
|
677
|
|
678 if (!bs || !info)
|
|
679 return -EINVAL;
|
|
680
|
|
681 aimbs_put8(bs, strlen(info->sn));
|
|
682 aimbs_putraw(bs, info->sn, strlen(info->sn));
|
|
683
|
|
684 aimbs_put16(bs, info->warnlevel);
|
|
685
|
|
686 if (info->present & AIM_USERINFO_PRESENT_FLAGS)
|
|
687 aim_addtlvtochain16(&tlvlist, 0x0001, info->flags);
|
|
688 if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE)
|
|
689 aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince);
|
|
690 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE)
|
|
691 aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince);
|
|
692 if (info->present & AIM_USERINFO_PRESENT_IDLE)
|
|
693 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime);
|
|
694
|
|
695 /* XXX - So, ICQ_OSCAR_SUPPORT is never defined anywhere... */
|
|
696 #if ICQ_OSCAR_SUPPORT
|
|
697 if (atoi(info->sn) != 0) {
|
|
698 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS)
|
|
699 aim_addtlvtochain16(&tlvlist, 0x0006, info->icqinfo.status);
|
|
700 if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR)
|
|
701 aim_addtlvtochain32(&tlvlist, 0x000a, info->icqinfo.ipaddr);
|
|
702 }
|
|
703 #endif
|
|
704
|
|
705 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES)
|
|
706 aim_addtlvtochain_caps(&tlvlist, 0x000d, info->capabilities);
|
|
707
|
|
708 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN)
|
|
709 aim_addtlvtochain32(&tlvlist, (fu16_t)((info->flags & AIM_FLAG_AOL) ? 0x0010 : 0x000f), info->sessionlen);
|
|
710
|
|
711 aimbs_put16(bs, aim_counttlvchain(&tlvlist));
|
|
712 aim_writetlvchain(bs, &tlvlist);
|
|
713 aim_freetlvchain(&tlvlist);
|
|
714
|
|
715 return 0;
|
|
716 }
|
|
717
|
|
718 /*
|
|
719 * Subtype 0x0002
|
|
720 *
|
|
721 * Request Location services rights.
|
|
722 *
|
|
723 */
|
|
724 faim_export int aim_locate_reqrights(aim_session_t *sess)
|
|
725 {
|
|
726 aim_conn_t *conn;
|
|
727
|
|
728 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_LOC)))
|
|
729 return -EINVAL;
|
|
730
|
|
731 return aim_genericreq_n(sess, conn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQRIGHTS);
|
|
732 }
|
|
733
|
|
734 /*
|
|
735 * Subtype 0x0003
|
|
736 *
|
|
737 * Normally contains:
|
|
738 * t(0001) - short containing max profile length (value = 1024)
|
|
739 * t(0002) - short - unknown (value = 16) [max MIME type length?]
|
|
740 * t(0003) - short - unknown (value = 10)
|
|
741 * t(0004) - short - unknown (value = 2048) [ICQ only?]
|
|
742 */
|
|
743 static int rights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
744 {
|
|
745 aim_tlvlist_t *tlvlist;
|
|
746 aim_rxcallback_t userfunc;
|
|
747 int ret = 0;
|
|
748 fu16_t maxsiglen = 0;
|
|
749
|
|
750 tlvlist = aim_readtlvchain(bs);
|
|
751
|
|
752 if (aim_gettlv(tlvlist, 0x0001, 1))
|
|
753 maxsiglen = aim_gettlv16(tlvlist, 0x0001, 1);
|
|
754
|
|
755 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
756 ret = userfunc(sess, rx, maxsiglen);
|
|
757
|
|
758 aim_freetlvchain(&tlvlist);
|
|
759
|
|
760 return ret;
|
|
761 }
|
|
762
|
|
763 /*
|
|
764 * Subtype 0x0004
|
|
765 *
|
|
766 * Gives BOS your profile.
|
|
767 *
|
|
768 * profile_encoding and awaymsg_encoding MUST be set if profile or
|
|
769 * away are set, respectively, and their value may or may not be
|
|
770 * restricted to a few choices. I am currently aware of:
|
|
771 *
|
|
772 * us-ascii Just that
|
|
773 * unicode-2-0 UCS2-BE
|
|
774 *
|
|
775 * profile_len and awaymsg_len MUST be set similarly, and they MUST
|
|
776 * be the length of their respective strings in bytes.
|
|
777 *
|
|
778 * To get the previous behavior of awaymsg == "" un-setting the away
|
|
779 * message, set awaymsg non-NULL and awaymsg_len to 0 (this is the
|
|
780 * obvious equivalent).
|
|
781 *
|
|
782 */
|
|
783 faim_export int aim_locate_setprofile(aim_session_t *sess,
|
|
784 const char *profile_encoding, const char *profile, const int profile_len,
|
|
785 const char *awaymsg_encoding, const char *awaymsg, const int awaymsg_len,
|
|
786 fu32_t caps)
|
|
787 {
|
|
788 aim_conn_t *conn;
|
|
789 aim_frame_t *fr;
|
|
790 aim_snacid_t snacid;
|
|
791 aim_tlvlist_t *tl = NULL;
|
|
792 char *encoding;
|
|
793 static const char defencoding[] = {"text/aolrtf; charset=\"%s\""};
|
|
794
|
|
795 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_LOC)))
|
|
796 return -EINVAL;
|
|
797
|
|
798 if ((profile && profile_encoding == NULL) || (awaymsg && awaymsg_len && awaymsg_encoding == NULL)) {
|
|
799 return -EINVAL;
|
|
800 }
|
|
801
|
|
802 /* Build the packet first to get real length */
|
|
803 if (profile) {
|
|
804 /* no + 1 here because of %s */
|
|
805 encoding = malloc(strlen(defencoding) + strlen(profile_encoding));
|
|
806 if (encoding == NULL) {
|
|
807 return -ENOMEM;
|
|
808 }
|
|
809 snprintf(encoding, strlen(defencoding) + strlen(profile_encoding), defencoding, profile_encoding);
|
|
810 aim_addtlvtochain_raw(&tl, 0x0001, strlen(encoding), encoding);
|
|
811 aim_addtlvtochain_raw(&tl, 0x0002, profile_len, profile);
|
|
812 free(encoding);
|
|
813 }
|
|
814
|
|
815 /*
|
|
816 * So here's how this works:
|
|
817 * - You are away when you have a non-zero-length type 4 TLV stored.
|
|
818 * - You become unaway when you clear the TLV with a zero-length
|
|
819 * type 4 TLV.
|
|
820 * - If you do not send the type 4 TLV, your status does not change
|
|
821 * (that is, if you were away, you'll remain away).
|
|
822 */
|
|
823 if (awaymsg) {
|
|
824 if (awaymsg_len) {
|
|
825 encoding = malloc(strlen(defencoding) + strlen(awaymsg_encoding));
|
|
826 if (encoding == NULL) {
|
|
827 return -ENOMEM;
|
|
828 }
|
|
829 snprintf(encoding, strlen(defencoding) + strlen(awaymsg_encoding), defencoding, awaymsg_encoding);
|
|
830 aim_addtlvtochain_raw(&tl, 0x0003, strlen(encoding), encoding);
|
|
831 aim_addtlvtochain_raw(&tl, 0x0004, awaymsg_len, awaymsg);
|
|
832 free(encoding);
|
|
833 } else
|
|
834 aim_addtlvtochain_noval(&tl, 0x0004);
|
|
835 }
|
|
836
|
|
837 aim_addtlvtochain_caps(&tl, 0x0005, caps);
|
|
838
|
|
839 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + aim_sizetlvchain(&tl))))
|
|
840 return -ENOMEM;
|
|
841
|
|
842 snacid = aim_cachesnac(sess, 0x0002, 0x0004, 0x0000, NULL, 0);
|
|
843 aim_putsnac(&fr->data, 0x0002, 0x004, 0x0000, snacid);
|
|
844
|
|
845 aim_writetlvchain(&fr->data, &tl);
|
|
846 aim_freetlvchain(&tl);
|
|
847
|
|
848 aim_tx_enqueue(sess, fr);
|
|
849
|
|
850 return 0;
|
|
851 }
|
|
852
|
|
853 /*
|
|
854 * Subtype 0x0005 - Request info of another AIM user.
|
|
855 *
|
|
856 * @param sn The screenname whose info you wish to request.
|
|
857 * @param infotype The type of info you wish to request.
|
|
858 * 0x0001 - Info/profile
|
|
859 * 0x0003 - Away message
|
|
860 * 0x0004 - Capabilities
|
|
861 */
|
|
862 faim_export int aim_locate_getinfo(aim_session_t *sess, const char *sn, fu16_t infotype)
|
|
863 {
|
|
864 aim_conn_t *conn;
|
|
865 aim_frame_t *fr;
|
|
866 aim_snacid_t snacid;
|
|
867
|
|
868 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_LOC)) || !sn)
|
|
869 return -EINVAL;
|
|
870
|
|
871 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 12+1+strlen(sn))))
|
|
872 return -ENOMEM;
|
|
873
|
|
874 snacid = aim_cachesnac(sess, 0x0002, 0x0005, 0x0000, NULL, 0);
|
|
875
|
|
876 aim_putsnac(&fr->data, 0x0002, 0x0005, 0x0000, snacid);
|
|
877 aimbs_put16(&fr->data, infotype);
|
|
878 aimbs_put8(&fr->data, strlen(sn));
|
|
879 aimbs_putraw(&fr->data, sn, strlen(sn));
|
|
880
|
|
881 aim_tx_enqueue(sess, fr);
|
|
882
|
|
883 return 0;
|
|
884 }
|
|
885
|
|
886 /* Subtype 0x0006 */
|
|
887 static int userinfo(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
888 {
|
|
889 int ret = 0;
|
|
890 aim_rxcallback_t userfunc;
|
|
891 aim_userinfo_t *userinfo, *userinfo2;
|
|
892 aim_tlvlist_t *tlvlist;
|
|
893 aim_tlv_t *tlv = NULL;
|
|
894 int was_explicit;
|
|
895 struct node *cur, *del;
|
|
896
|
|
897 userinfo = (aim_userinfo_t *)malloc(sizeof(aim_userinfo_t));
|
|
898 aim_info_extract(sess, bs, userinfo);
|
|
899 tlvlist = aim_readtlvchain(bs);
|
|
900
|
|
901 /* Profile will be 1 and 2 */
|
|
902 userinfo->info_encoding = aim_gettlv_str(tlvlist, 0x0001, 1);
|
|
903 if ((tlv = aim_gettlv(tlvlist, 0x0002, 1))) {
|
|
904 userinfo->info = (char *)malloc(tlv->length);
|
|
905 memcpy(userinfo->info, tlv->value, tlv->length);
|
|
906 userinfo->info_len = tlv->length;
|
|
907 }
|
|
908
|
|
909 /* Away message will be 3 and 4 */
|
|
910 userinfo->away_encoding = aim_gettlv_str(tlvlist, 0x0003, 1);
|
|
911 if ((tlv = aim_gettlv(tlvlist, 0x0004, 1))) {
|
|
912 userinfo->away = (char *)malloc(tlv->length);
|
|
913 memcpy(userinfo->away, tlv->value, tlv->length);
|
|
914 userinfo->away_len = tlv->length;
|
|
915 }
|
|
916
|
|
917 /* Caps will be 5 */
|
|
918 if ((tlv = aim_gettlv(tlvlist, 0x0005, 1))) {
|
|
919 aim_bstream_t cbs;
|
|
920 aim_bstream_init(&cbs, tlv->value, tlv->length);
|
|
921 userinfo->capabilities = aim_getcap(sess, &cbs, tlv->length);
|
|
922 userinfo->present = AIM_USERINFO_PRESENT_CAPABILITIES;
|
|
923 }
|
|
924 aim_freetlvchain(&tlvlist);
|
|
925
|
|
926 aim_locate_adduserinfo(userinfo);
|
|
927 userinfo2 = aim_locate_finduserinfo(userinfo->sn);
|
|
928 aim_info_free(userinfo);
|
|
929 free(userinfo);
|
|
930
|
|
931 /*
|
|
932 * Remove this screen name from our queue. If the client requested
|
|
933 * this buddy's info explicitly, then notify them that we have info
|
|
934 * for this buddy.
|
|
935 */
|
|
936 was_explicit = TRUE;
|
|
937 while ((request_queue != NULL) && (aim_sncmp(userinfo2->sn, request_queue->sn) == 0)) {
|
|
938 del = request_queue;
|
|
939 request_queue = del->next;
|
|
940 was_explicit = FALSE;
|
|
941 free(del->sn);
|
|
942 free(del);
|
|
943 }
|
|
944 cur = request_queue;
|
|
945 while ((cur != NULL) && (cur->next != NULL)) {
|
|
946 if (aim_sncmp(userinfo2->sn, cur->next->sn) == 0) {
|
|
947 del = cur->next;
|
|
948 cur->next = del->next;
|
|
949 was_explicit = FALSE;
|
|
950 free(del->sn);
|
|
951 free(del);
|
|
952 } else
|
|
953 cur = cur->next;
|
|
954 }
|
|
955
|
|
956 if (was_explicit == TRUE) {
|
|
957 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
958 ret = userfunc(sess, rx, userinfo2);
|
|
959 } else {
|
|
960 waiting_for_response = FALSE;
|
|
961 aim_locate_dorequest(sess);
|
|
962 }
|
|
963
|
|
964 return ret;
|
|
965 }
|
|
966
|
|
967 /*
|
|
968 * Subtype 0x0009 - Set directory profile data.
|
|
969 *
|
|
970 * This is not the same as aim_location_setprofile!
|
|
971 * privacy: 1 to allow searching, 0 to disallow.
|
|
972 *
|
|
973 */
|
|
974 faim_export int aim_locate_setdirinfo(aim_session_t *sess, const char *first, const char *middle, const char *last, const char *maiden, const char *nickname, const char *street, const char *city, const char *state, const char *zip, int country, fu16_t privacy)
|
|
975 {
|
|
976 aim_conn_t *conn;
|
|
977 aim_frame_t *fr;
|
|
978 aim_snacid_t snacid;
|
|
979 aim_tlvlist_t *tl = NULL;
|
|
980
|
|
981 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_LOC)))
|
|
982 return -EINVAL;
|
|
983
|
|
984 aim_addtlvtochain16(&tl, 0x000a, privacy);
|
|
985
|
|
986 if (first)
|
|
987 aim_addtlvtochain_raw(&tl, 0x0001, strlen(first), first);
|
|
988 if (last)
|
|
989 aim_addtlvtochain_raw(&tl, 0x0002, strlen(last), last);
|
|
990 if (middle)
|
|
991 aim_addtlvtochain_raw(&tl, 0x0003, strlen(middle), middle);
|
|
992 if (maiden)
|
|
993 aim_addtlvtochain_raw(&tl, 0x0004, strlen(maiden), maiden);
|
|
994
|
|
995 if (state)
|
|
996 aim_addtlvtochain_raw(&tl, 0x0007, strlen(state), state);
|
|
997 if (city)
|
|
998 aim_addtlvtochain_raw(&tl, 0x0008, strlen(city), city);
|
|
999
|
|
1000 if (nickname)
|
|
1001 aim_addtlvtochain_raw(&tl, 0x000c, strlen(nickname), nickname);
|
|
1002 if (zip)
|
|
1003 aim_addtlvtochain_raw(&tl, 0x000d, strlen(zip), zip);
|
|
1004
|
|
1005 if (street)
|
|
1006 aim_addtlvtochain_raw(&tl, 0x0021, strlen(street), street);
|
|
1007
|
|
1008 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl))))
|
|
1009 return -ENOMEM;
|
|
1010
|
|
1011 snacid = aim_cachesnac(sess, 0x0002, 0x0009, 0x0000, NULL, 0);
|
|
1012
|
|
1013 aim_putsnac(&fr->data, 0x0002, 0x0009, 0x0000, snacid);
|
|
1014 aim_writetlvchain(&fr->data, &tl);
|
|
1015 aim_freetlvchain(&tl);
|
|
1016
|
|
1017 aim_tx_enqueue(sess, fr);
|
|
1018
|
|
1019 return 0;
|
|
1020 }
|
|
1021
|
|
1022 /*
|
|
1023 * Subtype 0x000b - Huh? What is this?
|
|
1024 */
|
|
1025 faim_export int aim_locate_000b(aim_session_t *sess, const char *sn)
|
|
1026 {
|
|
1027 aim_conn_t *conn;
|
|
1028 aim_frame_t *fr;
|
|
1029 aim_snacid_t snacid;
|
|
1030
|
|
1031 return -EINVAL;
|
|
1032
|
|
1033 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_LOC)) || !sn)
|
|
1034 return -EINVAL;
|
|
1035
|
|
1036 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+strlen(sn))))
|
|
1037 return -ENOMEM;
|
|
1038
|
|
1039 snacid = aim_cachesnac(sess, 0x0002, 0x000b, 0x0000, NULL, 0);
|
|
1040
|
|
1041 aim_putsnac(&fr->data, 0x0002, 0x000b, 0x0000, snacid);
|
|
1042 aimbs_put8(&fr->data, strlen(sn));
|
|
1043 aimbs_putraw(&fr->data, sn, strlen(sn));
|
|
1044
|
|
1045 aim_tx_enqueue(sess, fr);
|
|
1046
|
|
1047 return 0;
|
|
1048 }
|
|
1049
|
|
1050 /*
|
|
1051 * Subtype 0x000f
|
|
1052 *
|
|
1053 * XXX pass these in better
|
|
1054 *
|
|
1055 */
|
|
1056 faim_export int aim_locate_setinterests(aim_session_t *sess, const char *interest1, const char *interest2, const char *interest3, const char *interest4, const char *interest5, fu16_t privacy)
|
|
1057 {
|
|
1058 aim_conn_t *conn;
|
|
1059 aim_frame_t *fr;
|
|
1060 aim_snacid_t snacid;
|
|
1061 aim_tlvlist_t *tl = NULL;
|
|
1062
|
|
1063 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_LOC)))
|
|
1064 return -EINVAL;
|
|
1065
|
|
1066 /* ?? privacy ?? */
|
|
1067 aim_addtlvtochain16(&tl, 0x000a, privacy);
|
|
1068
|
|
1069 if (interest1)
|
|
1070 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest1), interest1);
|
|
1071 if (interest2)
|
|
1072 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest2), interest2);
|
|
1073 if (interest3)
|
|
1074 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest3), interest3);
|
|
1075 if (interest4)
|
|
1076 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest4), interest4);
|
|
1077 if (interest5)
|
|
1078 aim_addtlvtochain_raw(&tl, 0x0000b, strlen(interest5), interest5);
|
|
1079
|
|
1080 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl))))
|
|
1081 return -ENOMEM;
|
|
1082
|
|
1083 snacid = aim_cachesnac(sess, 0x0002, 0x000f, 0x0000, NULL, 0);
|
|
1084
|
|
1085 aim_putsnac(&fr->data, 0x0002, 0x000f, 0x0000, 0);
|
|
1086 aim_writetlvchain(&fr->data, &tl);
|
|
1087 aim_freetlvchain(&tl);
|
|
1088
|
|
1089 aim_tx_enqueue(sess, fr);
|
|
1090
|
|
1091 return 0;
|
|
1092 }
|
|
1093
|
|
1094 /*
|
|
1095 * Subtype 0x0015 - Request the info a user using the short method. This is
|
|
1096 * what iChat uses. It normally is VERY leniently rate limited.
|
|
1097 *
|
|
1098 * @param sn The screen name whose info you wish to request.
|
|
1099 * @param flags The bitmask which specifies the type of info you wish to request.
|
|
1100 * 0x00000001 - Info/profile.
|
|
1101 * 0x00000002 - Away message.
|
|
1102 * 0x00000004 - Capabilities.
|
|
1103 * 0x00000008 - Certification.
|
|
1104 * @return Return 0 if no errors, otherwise return the error number.
|
|
1105 */
|
|
1106 faim_export int aim_locate_getinfoshort(aim_session_t *sess, const char *sn, fu32_t flags)
|
|
1107 {
|
|
1108 aim_conn_t *conn;
|
|
1109 aim_frame_t *fr;
|
|
1110 aim_snacid_t snacid;
|
|
1111
|
|
1112 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_LOC)) || !sn)
|
|
1113 return -EINVAL;
|
|
1114
|
|
1115 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+1+strlen(sn))))
|
|
1116 return -ENOMEM;
|
|
1117
|
|
1118 snacid = aim_cachesnac(sess, 0x0002, 0x0015, 0x0000, NULL, 0);
|
|
1119
|
|
1120 aim_putsnac(&fr->data, 0x0002, 0x0015, 0x0000, 0);
|
|
1121 aimbs_put32(&fr->data, flags);
|
|
1122 aimbs_put8(&fr->data, strlen(sn));
|
|
1123 aimbs_putraw(&fr->data, sn, strlen(sn));
|
|
1124
|
|
1125 aim_tx_enqueue(sess, fr);
|
|
1126
|
|
1127 return 0;
|
|
1128 }
|
|
1129
|
|
1130 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1131 {
|
|
1132
|
|
1133 if (snac->subtype == 0x0003)
|
|
1134 return rights(sess, mod, rx, snac, bs);
|
|
1135 else if (snac->subtype == 0x0006)
|
|
1136 return userinfo(sess, mod, rx, snac, bs);
|
|
1137
|
|
1138 return 0;
|
|
1139 }
|
|
1140
|
|
1141 static void locate_shutdown(aim_session_t *sess, aim_module_t *mod)
|
|
1142 {
|
|
1143 aim_userinfo_t *del;
|
|
1144
|
|
1145 while (infos) {
|
|
1146 del = infos;
|
|
1147 infos = infos->next;
|
|
1148 free(del->sn);
|
|
1149 free(del->info);
|
|
1150 free(del->avail);
|
|
1151 free(del->away);
|
|
1152 free(del);
|
|
1153 }
|
|
1154 }
|
|
1155
|
|
1156 faim_internal int locate_modfirst(aim_session_t *sess, aim_module_t *mod)
|
|
1157 {
|
|
1158
|
|
1159 mod->family = AIM_CB_FAM_LOC;
|
|
1160 mod->version = 0x0001;
|
|
1161 mod->toolid = 0x0110;
|
|
1162 mod->toolversion = 0x0629;
|
|
1163 mod->flags = 0;
|
|
1164 strncpy(mod->name, "locate", sizeof(mod->name));
|
|
1165 mod->snachandler = snachandler;
|
|
1166 mod->shutdown = locate_shutdown;
|
|
1167
|
|
1168 return 0;
|
|
1169 }
|