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