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