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