2672
|
1 /*
|
4230
|
2 * Family 0x0013 - Server-Side/Stored Information.
|
2672
|
3 *
|
6871
|
4 * Relatively new facility that allows certain types of information, such as
|
|
5 * a user's buddy list, permit/deny list, and permit/deny preferences, to be
|
|
6 * stored on the server, so that they can be accessed from any client.
|
2672
|
7 *
|
4230
|
8 * We keep 2 copies of SSI data:
|
|
9 * 1) An exact copy of what is stored on the AIM servers.
|
|
10 * 2) A local copy that we make changes to, and then send diffs
|
|
11 * between this and the exact copy to keep them in sync.
|
|
12 *
|
|
13 * All the "aim_ssi_itemlist_bleh" functions near the top just modify the list
|
6871
|
14 * that is given to them (i.e. they don't send SNACs).
|
3210
|
15 *
|
|
16 * The SNAC sending and receiving functions are lower down in the file, and
|
|
17 * they're simpler. They are in the order of the subtypes they deal with,
|
|
18 * starting with the request rights function (subtype 0x0002), then parse
|
|
19 * rights (subtype 0x0003), then--well, you get the idea.
|
|
20 *
|
2672
|
21 * This is entirely too complicated.
|
2991
|
22 * You don't know the half of it.
|
|
23 *
|
2672
|
24 */
|
|
25
|
|
26 #define FAIM_INTERNAL
|
|
27 #include <aim.h>
|
|
28
|
3210
|
29 /**
|
4230
|
30 * Locally rebuild the 0x00c8 TLV in the additional data of the given group.
|
3210
|
31 *
|
|
32 * @param list A pointer to a pointer to the current list of items.
|
4230
|
33 * @param name A null terminated string containing the group name, or NULL
|
|
34 * if you want to modify the master group.
|
|
35 * @return Return a pointer to the modified item.
|
|
36 */
|
|
37 static struct aim_ssi_item *aim_ssi_itemlist_rebuildgroup(struct aim_ssi_item *list, const char *name)
|
|
38 {
|
|
39 int newlen;
|
|
40 struct aim_ssi_item *cur, *group;
|
|
41
|
|
42 if (!list)
|
|
43 return NULL;
|
|
44
|
|
45 /* Find the group */
|
|
46 if (!(group = aim_ssi_itemlist_finditem(list, name, NULL, AIM_SSI_TYPE_GROUP)))
|
|
47 return NULL;
|
|
48
|
|
49 /* Find the length for the new additional data */
|
|
50 newlen = 0;
|
|
51 if (group->gid == 0x0000) {
|
|
52 for (cur=list; cur; cur=cur->next)
|
|
53 if ((cur->type == AIM_SSI_TYPE_GROUP) && (cur->gid != 0x0000))
|
|
54 newlen += 2;
|
|
55 } else {
|
|
56 for (cur=list; cur; cur=cur->next)
|
|
57 if ((cur->gid == group->gid) && (cur->type == AIM_SSI_TYPE_BUDDY))
|
|
58 newlen += 2;
|
|
59 }
|
|
60
|
|
61 /* Build the new TLV list */
|
|
62 if (newlen > 0) {
|
|
63 fu8_t *newdata;
|
|
64
|
|
65 if (!(newdata = (fu8_t *)malloc((newlen)*sizeof(fu8_t))))
|
|
66 return NULL;
|
|
67 newlen = 0;
|
|
68 if (group->gid == 0x0000) {
|
|
69 for (cur=list; cur; cur=cur->next)
|
|
70 if ((cur->type == AIM_SSI_TYPE_GROUP) && (cur->gid != 0x0000))
|
|
71 newlen += aimutil_put16(newdata+newlen, cur->gid);
|
|
72 } else {
|
|
73 for (cur=list; cur; cur=cur->next)
|
|
74 if ((cur->gid == group->gid) && (cur->type == AIM_SSI_TYPE_BUDDY))
|
|
75 newlen += aimutil_put16(newdata+newlen, cur->bid);
|
|
76 }
|
7166
|
77 aim_tlvlist_replace_raw(&group->data, 0x00c8, newlen, newdata);
|
4230
|
78
|
|
79 free(newdata);
|
|
80 }
|
|
81
|
|
82 return group;
|
|
83 }
|
|
84
|
|
85 /**
|
|
86 * Locally add a new item to the given item list.
|
|
87 *
|
|
88 * @param list A pointer to a pointer to the current list of items.
|
3210
|
89 * @param name A null terminated string of the name of the new item, or NULL if the
|
|
90 * item should have no name.
|
4230
|
91 * @param gid The group ID# you want the new item to have, or 0xFFFF if we should pick something.
|
|
92 * @param bid The buddy ID# you want the new item to have, or 0xFFFF if we should pick something.
|
|
93 * @param type The type of the item, 0x0000 for a contact, 0x0001 for a group, etc.
|
|
94 * @param data The additional data for the new item.
|
|
95 * @return A pointer to the newly created item.
|
2991
|
96 */
|
4230
|
97 static struct aim_ssi_item *aim_ssi_itemlist_add(struct aim_ssi_item **list, const char *name, fu16_t gid, fu16_t bid, fu16_t type, aim_tlvlist_t *data)
|
2991
|
98 {
|
3210
|
99 int i;
|
4230
|
100 struct aim_ssi_item *cur, *new;
|
3210
|
101
|
4230
|
102 if (!list)
|
|
103 return NULL;
|
|
104
|
|
105 if (!(new = (struct aim_ssi_item *)malloc(sizeof(struct aim_ssi_item))))
|
3210
|
106 return NULL;
|
|
107
|
|
108 /* Set the name */
|
|
109 if (name) {
|
4230
|
110 new->name = (char *)malloc((strlen(name)+1)*sizeof(char));
|
|
111 strcpy(new->name, name);
|
3210
|
112 } else
|
4230
|
113 new->name = NULL;
|
3210
|
114
|
4230
|
115 /* Set the group ID# and buddy ID# */
|
|
116 new->gid = gid;
|
|
117 new->bid = bid;
|
3210
|
118 if (type == AIM_SSI_TYPE_GROUP) {
|
4230
|
119 if ((new->gid == 0xFFFF) && name) {
|
3210
|
120 do {
|
4230
|
121 new->gid += 0x0001;
|
3210
|
122 for (cur=*list, i=0; ((cur) && (!i)); cur=cur->next)
|
4230
|
123 if ((cur->type == AIM_SSI_TYPE_GROUP) && (cur->gid == new->gid))
|
|
124 i=1;
|
|
125 } while (i);
|
|
126 }
|
|
127 } else {
|
|
128 if (new->bid == 0xFFFF) {
|
|
129 do {
|
|
130 new->bid += 0x0001;
|
|
131 for (cur=*list, i=0; ((cur) && (!i)); cur=cur->next)
|
|
132 if ((cur->bid == new->bid) && (cur->gid == new->gid))
|
3210
|
133 i=1;
|
|
134 } while (i);
|
4230
|
135 }
|
3210
|
136 }
|
|
137
|
4230
|
138 /* Set the type */
|
|
139 new->type = type;
|
|
140
|
|
141 /* Set the TLV list */
|
4236
|
142 new->data = aim_tlvlist_copy(data);
|
3210
|
143
|
4230
|
144 /* Add the item to the list in the correct numerical position. Fancy, eh? */
|
|
145 if (*list) {
|
|
146 if ((new->gid < (*list)->gid) || ((new->gid == (*list)->gid) && (new->bid < (*list)->bid))) {
|
|
147 new->next = *list;
|
|
148 *list = new;
|
|
149 } else {
|
|
150 struct aim_ssi_item *prev;
|
4308
|
151 for ((prev=*list, cur=(*list)->next); (cur && ((new->gid > cur->gid) || ((new->gid == cur->gid) && (new->bid > cur->bid)))); prev=cur, cur=cur->next);
|
4230
|
152 new->next = prev->next;
|
|
153 prev->next = new;
|
|
154 }
|
|
155 } else {
|
|
156 new->next = *list;
|
|
157 *list = new;
|
|
158 }
|
|
159
|
|
160 return new;
|
3210
|
161 }
|
|
162
|
|
163 /**
|
4230
|
164 * Locally delete an item from the given item list.
|
3210
|
165 *
|
|
166 * @param list A pointer to a pointer to the current list of items.
|
4230
|
167 * @param del A pointer to the item you want to remove from the list.
|
3210
|
168 * @return Return 0 if no errors, otherwise return the error number.
|
|
169 */
|
4230
|
170 static int aim_ssi_itemlist_del(struct aim_ssi_item **list, struct aim_ssi_item *del)
|
3210
|
171 {
|
4230
|
172 if (!list || !(*list) || !del)
|
|
173 return -EINVAL;
|
3210
|
174
|
4230
|
175 /* Remove the item from the list */
|
|
176 if (*list == del) {
|
4308
|
177 *list = (*list)->next;
|
4230
|
178 } else {
|
|
179 struct aim_ssi_item *cur;
|
|
180 for (cur=*list; (cur->next && (cur->next!=del)); cur=cur->next);
|
|
181 if (cur->next)
|
7166
|
182 cur->next = del->next;
|
3210
|
183 }
|
|
184
|
7166
|
185 /* Free the removed item */
|
4230
|
186 free(del->name);
|
7167
|
187 aim_tlvlist_free(&del->data);
|
4230
|
188 free(del);
|
3210
|
189
|
2991
|
190 return 0;
|
|
191 }
|
|
192
|
3210
|
193 /**
|
4230
|
194 * Compare two items to see if they have the same data.
|
3210
|
195 *
|
4230
|
196 * @param cur1 A pointer to a pointer to the first item.
|
|
197 * @param cur2 A pointer to a pointer to the second item.
|
|
198 * @return Return 0 if no differences, or a number if there are differences.
|
3017
|
199 */
|
4230
|
200 static int aim_ssi_itemlist_cmp(struct aim_ssi_item *cur1, struct aim_ssi_item *cur2)
|
3017
|
201 {
|
4230
|
202 if (!cur1 || !cur2)
|
|
203 return 1;
|
|
204
|
|
205 if (cur1->data && !cur2->data)
|
|
206 return 2;
|
|
207
|
|
208 if (!cur1->data && cur2->data)
|
|
209 return 3;
|
|
210
|
6101
|
211 if ((cur1->data && cur2->data) && (aim_tlvlist_cmp(cur1->data, cur2->data)))
|
4230
|
212 return 4;
|
|
213
|
|
214 if (cur1->name && !cur2->name)
|
|
215 return 5;
|
|
216
|
|
217 if (!cur1->name && cur2->name)
|
|
218 return 6;
|
|
219
|
|
220 if (cur1->name && cur2->name && aim_sncmp(cur1->name, cur2->name))
|
|
221 return 7;
|
|
222
|
|
223 if (cur1->gid != cur2->gid)
|
|
224 return 8;
|
|
225
|
|
226 if (cur1->bid != cur2->bid)
|
|
227 return 9;
|
|
228
|
|
229 if (cur1->type != cur2->type)
|
|
230 return 10;
|
3210
|
231
|
3017
|
232 return 0;
|
|
233 }
|
|
234
|
4789
|
235 faim_export int aim_ssi_itemlist_valid(struct aim_ssi_item *list, struct aim_ssi_item *item)
|
|
236 {
|
|
237 struct aim_ssi_item *cur;
|
|
238 for (cur=list; cur; cur=cur->next)
|
|
239 if (cur == item)
|
|
240 return 1;
|
|
241 return 0;
|
|
242 }
|
|
243
|
3210
|
244 /**
|
|
245 * Locally find an item given a group ID# and a buddy ID#.
|
|
246 *
|
|
247 * @param list A pointer to the current list of items.
|
|
248 * @param gid The group ID# of the desired item.
|
|
249 * @param bid The buddy ID# of the desired item.
|
|
250 * @return Return a pointer to the item if found, else return NULL;
|
2991
|
251 */
|
3210
|
252 faim_export struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, fu16_t gid, fu16_t bid)
|
2991
|
253 {
|
|
254 struct aim_ssi_item *cur;
|
3210
|
255 for (cur=list; cur; cur=cur->next)
|
|
256 if ((cur->gid == gid) && (cur->bid == bid))
|
|
257 return cur;
|
2991
|
258 return NULL;
|
|
259 }
|
|
260
|
3210
|
261 /**
|
|
262 * Locally find an item given a group name, screen name, and type. If group name
|
|
263 * and screen name are null, then just return the first item of the given type.
|
|
264 *
|
|
265 * @param list A pointer to the current list of items.
|
|
266 * @param gn The group name of the desired item.
|
|
267 * @param bn The buddy name of the desired item.
|
|
268 * @param type The type of the desired item.
|
9285
|
269 * @return Return a pointer to the item if found, else return NULL.
|
3109
|
270 */
|
3466
|
271 faim_export struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, const char *gn, const char *sn, fu16_t type)
|
3109
|
272 {
|
3210
|
273 struct aim_ssi_item *cur;
|
|
274 if (!list)
|
|
275 return NULL;
|
|
276
|
|
277 if (gn && sn) { /* For finding buddies in groups */
|
|
278 for (cur=list; cur; cur=cur->next)
|
|
279 if ((cur->type == type) && (cur->name) && !(aim_sncmp(cur->name, sn))) {
|
|
280 struct aim_ssi_item *curg;
|
|
281 for (curg=list; curg; curg=curg->next)
|
|
282 if ((curg->type == AIM_SSI_TYPE_GROUP) && (curg->gid == cur->gid) && (curg->name) && !(aim_sncmp(curg->name, gn)))
|
|
283 return cur;
|
|
284 }
|
|
285
|
4230
|
286 } else if (gn) { /* For finding groups */
|
|
287 for (cur=list; cur; cur=cur->next) {
|
|
288 if ((cur->type == type) && (cur->bid == 0x0000) && (cur->name) && !(aim_sncmp(cur->name, gn))) {
|
3210
|
289 return cur;
|
4230
|
290 }
|
|
291 }
|
|
292
|
|
293 } else if (sn) { /* For finding permits, denies, and ignores */
|
|
294 for (cur=list; cur; cur=cur->next) {
|
4347
|
295 if ((cur->type == type) && (cur->name) && !(aim_sncmp(cur->name, sn))) {
|
4230
|
296 return cur;
|
|
297 }
|
|
298 }
|
3210
|
299
|
|
300 /* For stuff without names--permit deny setting, visibility mask, etc. */
|
|
301 } else for (cur=list; cur; cur=cur->next) {
|
4230
|
302 if ((cur->type == type) && (!cur->name))
|
3210
|
303 return cur;
|
|
304 }
|
|
305
|
|
306 return NULL;
|
|
307 }
|
|
308
|
|
309 /**
|
4230
|
310 * Check if the given buddy exists in any group in the buddy list.
|
|
311 *
|
|
312 * @param list A pointer to the current list of items.
|
|
313 * @param sn The group name of the desired item.
|
|
314 * @return Return a pointer to the name of the item if found, else return NULL;
|
|
315 */
|
|
316 faim_export struct aim_ssi_item *aim_ssi_itemlist_exists(struct aim_ssi_item *list, const char *sn)
|
|
317 {
|
|
318 struct aim_ssi_item *cur;
|
|
319 if (!list || !sn)
|
|
320 return NULL;
|
|
321 for (cur=list; cur; cur=cur->next)
|
|
322 if ((cur->type == AIM_SSI_TYPE_BUDDY) && (cur->name) && (!aim_sncmp(cur->name, sn)))
|
|
323 return cur;
|
|
324 return NULL;
|
|
325 }
|
|
326
|
|
327 /**
|
3210
|
328 * Locally find the parent item of the given buddy name.
|
|
329 *
|
|
330 * @param list A pointer to the current list of items.
|
|
331 * @param bn The buddy name of the desired item.
|
4230
|
332 * @return Return a pointer to the name of the item if found, else return NULL;
|
3210
|
333 */
|
4230
|
334 faim_export char *aim_ssi_itemlist_findparentname(struct aim_ssi_item *list, const char *sn)
|
3210
|
335 {
|
|
336 struct aim_ssi_item *cur, *curg;
|
|
337 if (!list || !sn)
|
|
338 return NULL;
|
4230
|
339 if (!(cur = aim_ssi_itemlist_exists(list, sn)))
|
3210
|
340 return NULL;
|
4230
|
341 if (!(curg = aim_ssi_itemlist_find(list, cur->gid, 0x0000)))
|
|
342 return NULL;
|
|
343 return curg->name;
|
3210
|
344 }
|
|
345
|
|
346 /**
|
|
347 * Locally find the permit/deny setting item, and return the setting.
|
|
348 *
|
|
349 * @param list A pointer to the current list of items.
|
|
350 * @return Return the current SSI permit deny setting, or 0 if no setting was found.
|
|
351 */
|
|
352 faim_export int aim_ssi_getpermdeny(struct aim_ssi_item *list)
|
|
353 {
|
|
354 struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, NULL, NULL, AIM_SSI_TYPE_PDINFO);
|
3109
|
355 if (cur) {
|
7167
|
356 aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x00ca, 1);
|
7166
|
357 if (tlv && tlv->value)
|
|
358 return aimutil_get8(tlv->value);
|
3109
|
359 }
|
|
360 return 0;
|
|
361 }
|
|
362
|
3210
|
363 /**
|
|
364 * Locally find the presence flag item, and return the setting. The returned setting is a
|
|
365 * bitmask of the user flags that you are visible to. See the AIM_FLAG_* #defines
|
|
366 * in aim.h
|
|
367 *
|
|
368 * @param list A pointer to the current list of items.
|
|
369 * @return Return the current visibility mask.
|
3109
|
370 */
|
3210
|
371 faim_export fu32_t aim_ssi_getpresence(struct aim_ssi_item *list)
|
3109
|
372 {
|
3210
|
373 struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, NULL, NULL, AIM_SSI_TYPE_PRESENCEPREFS);
|
3109
|
374 if (cur) {
|
7167
|
375 aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x00c9, 1);
|
7166
|
376 if (tlv && tlv->length)
|
|
377 return aimutil_get32(tlv->value);
|
3109
|
378 }
|
|
379 return 0xFFFFFFFF;
|
|
380 }
|
|
381
|
3210
|
382 /**
|
4230
|
383 * Locally find the alias of the given buddy.
|
|
384 *
|
|
385 * @param list A pointer to the current list of items.
|
4342
|
386 * @param gn The group of the buddy.
|
|
387 * @param sn The name of the buddy.
|
7172
|
388 * @return A pointer to a NULL terminated string that is the buddy's
|
4230
|
389 * alias, or NULL if the buddy has no alias. You should free
|
|
390 * this returned value!
|
|
391 */
|
4238
|
392 faim_export char *aim_ssi_getalias(struct aim_ssi_item *list, const char *gn, const char *sn)
|
4230
|
393 {
|
|
394 struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY);
|
|
395 if (cur) {
|
7167
|
396 aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x0131, 1);
|
7166
|
397 if (tlv && tlv->length) {
|
|
398 char *alias = (char *)malloc((tlv->length+1)*sizeof(char));
|
|
399 strncpy(alias, tlv->value, tlv->length);
|
|
400 alias[tlv->length] = 0;
|
|
401 return alias;
|
4230
|
402 }
|
|
403 }
|
|
404 return NULL;
|
|
405 }
|
|
406
|
|
407 /**
|
7172
|
408 * Locally find the comment of the given buddy.
|
|
409 *
|
|
410 * @param list A pointer to the current list of items.
|
|
411 * @param gn The group of the buddy.
|
|
412 * @param sn The name of the buddy.
|
|
413 * @return A pointer to a NULL terminated string that is the buddy's
|
|
414 * comment, or NULL if the buddy has no comment. You should free
|
|
415 * this returned value!
|
|
416 */
|
|
417 faim_export char *aim_ssi_getcomment(struct aim_ssi_item *list, const char *gn, const char *sn)
|
|
418 {
|
|
419 struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY);
|
|
420 if (cur) {
|
|
421 aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x013c, 1);
|
|
422 if (tlv && tlv->length) {
|
|
423 char *alias = (char *)malloc((tlv->length+1)*sizeof(char));
|
|
424 strncpy(alias, tlv->value, tlv->length);
|
|
425 alias[tlv->length] = 0;
|
|
426 return alias;
|
|
427 }
|
|
428 }
|
|
429 return NULL;
|
|
430 }
|
|
431
|
|
432 /**
|
4243
|
433 * Locally find if you are waiting for authorization for a buddy.
|
|
434 *
|
|
435 * @param list A pointer to the current list of items.
|
4342
|
436 * @param gn The group of the buddy.
|
|
437 * @param sn The name of the buddy.
|
4243
|
438 * @return A pointer to a NULL terminated string that is the buddies
|
|
439 * alias, or NULL if the buddy has no alias. You should free
|
|
440 * this returned value!
|
|
441 */
|
|
442 faim_export int aim_ssi_waitingforauth(struct aim_ssi_item *list, const char *gn, const char *sn)
|
|
443 {
|
|
444 struct aim_ssi_item *cur = aim_ssi_itemlist_finditem(list, gn, sn, AIM_SSI_TYPE_BUDDY);
|
|
445 if (cur) {
|
7167
|
446 if (aim_tlv_gettlv(cur->data, 0x0066, 1))
|
7166
|
447 return 1;
|
4243
|
448 }
|
|
449 return 0;
|
|
450 }
|
|
451
|
|
452 /**
|
4230
|
453 * If there are changes, then create temporary items and
|
|
454 * call addmoddel.
|
3210
|
455 *
|
|
456 * @param sess The oscar session.
|
|
457 * @return Return 0 if no errors, otherwise return the error number.
|
2991
|
458 */
|
4889
|
459 static int aim_ssi_sync(aim_session_t *sess)
|
2991
|
460 {
|
4230
|
461 struct aim_ssi_item *cur1, *cur2;
|
|
462 struct aim_ssi_tmp *cur, *new;
|
2991
|
463
|
4889
|
464 if (!sess)
|
2991
|
465 return -EINVAL;
|
|
466
|
4230
|
467 /* If we're waiting for an ack, we shouldn't do anything else */
|
|
468 if (sess->ssi.waiting_for_ack)
|
|
469 return 0;
|
|
470
|
|
471 /*
|
|
472 * Compare the 2 lists and create an aim_ssi_tmp for each difference.
|
|
473 * We should only send either additions, modifications, or deletions
|
|
474 * before waiting for an acknowledgement. So first do deletions, then
|
|
475 * additions, then modifications. Also, both the official and the local
|
|
476 * list should be in ascending numerical order for the group ID#s and the
|
|
477 * buddy ID#s, which makes things more efficient. I think.
|
|
478 */
|
|
479
|
4238
|
480 /* Additions */
|
4230
|
481 if (!sess->ssi.pending) {
|
4238
|
482 for (cur1=sess->ssi.local; cur1; cur1=cur1->next) {
|
|
483 if (!aim_ssi_itemlist_find(sess->ssi.official, cur1->gid, cur1->bid)) {
|
4230
|
484 new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp));
|
4238
|
485 new->action = AIM_CB_SSI_ADD;
|
4230
|
486 new->ack = 0xffff;
|
|
487 new->name = NULL;
|
|
488 new->item = cur1;
|
|
489 new->next = NULL;
|
|
490 if (sess->ssi.pending) {
|
|
491 for (cur=sess->ssi.pending; cur->next; cur=cur->next);
|
|
492 cur->next = new;
|
|
493 } else
|
|
494 sess->ssi.pending = new;
|
|
495 }
|
|
496 }
|
2991
|
497 }
|
|
498
|
4238
|
499 /* Deletions */
|
4230
|
500 if (!sess->ssi.pending) {
|
4238
|
501 for (cur1=sess->ssi.official; cur1; cur1=cur1->next) {
|
|
502 if (!aim_ssi_itemlist_find(sess->ssi.local, cur1->gid, cur1->bid)) {
|
4230
|
503 new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp));
|
4238
|
504 new->action = AIM_CB_SSI_DEL;
|
4230
|
505 new->ack = 0xffff;
|
|
506 new->name = NULL;
|
|
507 new->item = cur1;
|
|
508 new->next = NULL;
|
|
509 if (sess->ssi.pending) {
|
|
510 for (cur=sess->ssi.pending; cur->next; cur=cur->next);
|
|
511 cur->next = new;
|
|
512 } else
|
|
513 sess->ssi.pending = new;
|
|
514 }
|
|
515 }
|
|
516 }
|
|
517
|
|
518 /* Modifications */
|
|
519 if (!sess->ssi.pending) {
|
|
520 for (cur1=sess->ssi.local; cur1; cur1=cur1->next) {
|
|
521 cur2 = aim_ssi_itemlist_find(sess->ssi.official, cur1->gid, cur1->bid);
|
|
522 if (cur2 && (aim_ssi_itemlist_cmp(cur1, cur2))) {
|
|
523 new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp));
|
|
524 new->action = AIM_CB_SSI_MOD;
|
|
525 new->ack = 0xffff;
|
|
526 new->name = NULL;
|
|
527 new->item = cur1;
|
|
528 new->next = NULL;
|
|
529 if (sess->ssi.pending) {
|
|
530 for (cur=sess->ssi.pending; cur->next; cur=cur->next);
|
|
531 cur->next = new;
|
|
532 } else
|
|
533 sess->ssi.pending = new;
|
|
534 }
|
|
535 }
|
|
536 }
|
|
537
|
|
538 /* We're out of stuff to do, so tell the AIM servers we're done and exit */
|
|
539 if (!sess->ssi.pending) {
|
4889
|
540 aim_ssi_modend(sess);
|
4230
|
541 return 0;
|
|
542 }
|
|
543
|
|
544 /* Make sure we don't send anything else between now
|
|
545 * and when we receive the ack for the following operation */
|
|
546 sess->ssi.waiting_for_ack = 1;
|
|
547
|
|
548 /* Now go mail off our data and wait 4 to 6 weeks */
|
4889
|
549 aim_ssi_addmoddel(sess);
|
4230
|
550
|
2991
|
551 return 0;
|
|
552 }
|
|
553
|
3210
|
554 /**
|
4230
|
555 * Free all SSI data.
|
|
556 *
|
|
557 * This doesn't remove it from the server, that's different.
|
3210
|
558 *
|
|
559 * @param sess The oscar session.
|
|
560 * @return Return 0 if no errors, otherwise return the error number.
|
2991
|
561 */
|
4230
|
562 static int aim_ssi_freelist(aim_session_t *sess)
|
2991
|
563 {
|
4230
|
564 struct aim_ssi_item *cur, *del;
|
|
565 struct aim_ssi_tmp *curtmp, *deltmp;
|
2991
|
566
|
4230
|
567 cur = sess->ssi.official;
|
|
568 while (cur) {
|
|
569 del = cur;
|
|
570 cur = cur->next;
|
|
571 free(del->name);
|
7167
|
572 aim_tlvlist_free(&del->data);
|
4230
|
573 free(del);
|
|
574 }
|
2991
|
575
|
4230
|
576 cur = sess->ssi.local;
|
|
577 while (cur) {
|
|
578 del = cur;
|
|
579 cur = cur->next;
|
|
580 free(del->name);
|
7167
|
581 aim_tlvlist_free(&del->data);
|
4230
|
582 free(del);
|
2991
|
583 }
|
|
584
|
4230
|
585 curtmp = sess->ssi.pending;
|
|
586 while (curtmp) {
|
|
587 deltmp = curtmp;
|
|
588 curtmp = curtmp->next;
|
|
589 free(deltmp);
|
|
590 }
|
|
591
|
|
592 sess->ssi.numitems = 0;
|
|
593 sess->ssi.official = NULL;
|
|
594 sess->ssi.local = NULL;
|
|
595 sess->ssi.pending = NULL;
|
|
596 sess->ssi.timestamp = (time_t)0;
|
|
597
|
2991
|
598 return 0;
|
|
599 }
|
|
600
|
3210
|
601 /**
|
4230
|
602 * Delete all SSI data.
|
3210
|
603 *
|
|
604 * @param sess The oscar session.
|
|
605 * @return Return 0 if no errors, otherwise return the error number.
|
2991
|
606 */
|
4889
|
607 faim_export int aim_ssi_deletelist(aim_session_t *sess)
|
2991
|
608 {
|
4230
|
609 struct aim_ssi_item *cur, *del;
|
2991
|
610
|
4889
|
611 if (!sess)
|
|
612 return -EINVAL;
|
|
613
|
4230
|
614 /* Free the local list */
|
|
615 cur = sess->ssi.local;
|
|
616 while (cur) {
|
|
617 del = cur;
|
|
618 cur = cur->next;
|
|
619 free(del->name);
|
7167
|
620 aim_tlvlist_free(&del->data);
|
4230
|
621 free(del);
|
2991
|
622 }
|
4230
|
623 sess->ssi.local = NULL;
|
2991
|
624
|
4230
|
625 /* Sync our local list with the server list */
|
4889
|
626 aim_ssi_sync(sess);
|
2991
|
627
|
|
628 return 0;
|
|
629 }
|
|
630
|
3210
|
631 /**
|
4230
|
632 * This "cleans" the ssi list. It does the following:
|
4347
|
633 * 1) Makes sure all buddies, permits, and denies have names.
|
|
634 * 2) Makes sure that all buddies are in a group that exist.
|
|
635 * 3) Deletes any empty groups
|
3210
|
636 *
|
|
637 * @param sess The oscar session.
|
|
638 * @return Return 0 if no errors, otherwise return the error number.
|
2991
|
639 */
|
4889
|
640 faim_export int aim_ssi_cleanlist(aim_session_t *sess)
|
2991
|
641 {
|
4333
|
642 struct aim_ssi_item *cur, *next;
|
2991
|
643
|
4889
|
644 if (!sess)
|
|
645 return -EINVAL;
|
|
646
|
4346
|
647 /* Delete any buddies, permits, or denies with empty names. */
|
|
648 /* If there are any buddies directly in the master group, add them to a real group. */
|
|
649 /* DESTROY any buddies that are directly in the master group. */
|
|
650 /* Do the same for buddies that are in a non-existant group. */
|
|
651 /* This will kind of mess up if you hit the item limit, but this function isn't too critical */
|
4344
|
652 cur = sess->ssi.local;
|
|
653 while (cur) {
|
|
654 next = cur->next;
|
|
655 if (!cur->name) {
|
|
656 if (cur->type == AIM_SSI_TYPE_BUDDY)
|
4889
|
657 aim_ssi_delbuddy(sess, NULL, NULL);
|
4344
|
658 else if (cur->type == AIM_SSI_TYPE_PERMIT)
|
4889
|
659 aim_ssi_delpermit(sess, NULL);
|
4344
|
660 else if (cur->type == AIM_SSI_TYPE_DENY)
|
4889
|
661 aim_ssi_deldeny(sess, NULL);
|
4346
|
662 } else if ((cur->type == AIM_SSI_TYPE_BUDDY) && ((cur->gid == 0x0000) || (!aim_ssi_itemlist_find(sess->ssi.local, cur->gid, 0x0000)))) {
|
4889
|
663 aim_ssi_addbuddy(sess, cur->name, "orphans", NULL, NULL, NULL, 0);
|
|
664 aim_ssi_delbuddy(sess, cur->name, NULL);
|
4344
|
665 }
|
|
666 cur = next;
|
|
667 }
|
|
668
|
5504
|
669 /* Check if there are empty groups and delete them */
|
4333
|
670 cur = sess->ssi.local;
|
|
671 while (cur) {
|
|
672 next = cur->next;
|
5504
|
673 if (cur->type == AIM_SSI_TYPE_GROUP) {
|
7167
|
674 aim_tlv_t *tlv = aim_tlv_gettlv(cur->data, 0x00c8, 1);
|
5503
|
675 if (!tlv || !tlv->length)
|
4243
|
676 aim_ssi_itemlist_del(&sess->ssi.local, cur);
|
|
677 }
|
4333
|
678 cur = next;
|
|
679 }
|
4230
|
680
|
|
681 /* Check if the master group is empty */
|
|
682 if ((cur = aim_ssi_itemlist_find(sess->ssi.local, 0x0000, 0x0000)) && (!cur->data))
|
|
683 aim_ssi_itemlist_del(&sess->ssi.local, cur);
|
|
684
|
|
685 return 0;
|
|
686 }
|
2991
|
687
|
4230
|
688 /**
|
|
689 * Add a buddy to the list.
|
|
690 *
|
|
691 * @param sess The oscar session.
|
|
692 * @param name The name of the item.
|
|
693 * @param group The group of the item.
|
|
694 * @param alias The alias/nickname of the item, or NULL.
|
|
695 * @param comment The buddy comment for the item, or NULL.
|
|
696 * @param smsnum The locally assigned SMS number, or NULL.
|
|
697 * @return Return 0 if no errors, otherwise return the error number.
|
|
698 */
|
4889
|
699 faim_export int aim_ssi_addbuddy(aim_session_t *sess, const char *name, const char *group, const char *alias, const char *comment, const char *smsnum, int needauth)
|
4230
|
700 {
|
|
701 struct aim_ssi_item *parent;
|
|
702 aim_tlvlist_t *data = NULL;
|
2991
|
703
|
4889
|
704 if (!sess || !name || !group)
|
4230
|
705 return -EINVAL;
|
|
706
|
|
707 /* Find the parent */
|
|
708 if (!(parent = aim_ssi_itemlist_finditem(sess->ssi.local, group, NULL, AIM_SSI_TYPE_GROUP))) {
|
|
709 /* Find the parent's parent (the master group) */
|
|
710 if (!(parent = aim_ssi_itemlist_find(sess->ssi.local, 0x0000, 0x0000)))
|
|
711 if (!(parent = aim_ssi_itemlist_add(&sess->ssi.local, NULL, 0x0000, 0x0000, AIM_SSI_TYPE_GROUP, NULL)))
|
|
712 return -ENOMEM;
|
|
713 /* Add the parent */
|
|
714 if (!(parent = aim_ssi_itemlist_add(&sess->ssi.local, group, 0xFFFF, 0x0000, AIM_SSI_TYPE_GROUP, NULL)))
|
3210
|
715 return -ENOMEM;
|
|
716
|
4230
|
717 /* Modify the parent's parent (the master group) */
|
|
718 aim_ssi_itemlist_rebuildgroup(sess->ssi.local, NULL);
|
3210
|
719 }
|
|
720
|
4230
|
721 /* Create a TLV list for the new buddy */
|
|
722 if (needauth)
|
7167
|
723 aim_tlvlist_add_noval(&data, 0x0066);
|
4230
|
724 if (alias)
|
10986
|
725 aim_tlvlist_add_string(&data, 0x0131, alias);
|
4230
|
726 if (smsnum)
|
10986
|
727 aim_tlvlist_add_string(&data, 0x013a, smsnum);
|
4230
|
728 if (comment)
|
10986
|
729 aim_tlvlist_add_string(&data, 0x013c, comment);
|
4230
|
730
|
|
731 /* Add that bad boy */
|
|
732 aim_ssi_itemlist_add(&sess->ssi.local, name, parent->gid, 0xFFFF, AIM_SSI_TYPE_BUDDY, data);
|
7167
|
733 aim_tlvlist_free(&data);
|
4230
|
734
|
|
735 /* Modify the parent group */
|
|
736 aim_ssi_itemlist_rebuildgroup(sess->ssi.local, group);
|
|
737
|
|
738 /* Sync our local list with the server list */
|
4889
|
739 aim_ssi_sync(sess);
|
3210
|
740
|
4230
|
741 return 0;
|
|
742 }
|
3210
|
743
|
4230
|
744 /**
|
|
745 * Add a permit buddy to the list.
|
|
746 *
|
|
747 * @param sess The oscar session.
|
|
748 * @param name The name of the item..
|
|
749 * @return Return 0 if no errors, otherwise return the error number.
|
|
750 */
|
4889
|
751 faim_export int aim_ssi_addpermit(aim_session_t *sess, const char *name)
|
4230
|
752 {
|
4889
|
753
|
|
754 if (!sess || !name)
|
4230
|
755 return -EINVAL;
|
2991
|
756
|
4230
|
757 /* Add that bad boy */
|
|
758 aim_ssi_itemlist_add(&sess->ssi.local, name, 0x0000, 0xFFFF, AIM_SSI_TYPE_PERMIT, NULL);
|
|
759
|
|
760 /* Sync our local list with the server list */
|
4889
|
761 aim_ssi_sync(sess);
|
2991
|
762
|
|
763 return 0;
|
|
764 }
|
|
765
|
3210
|
766 /**
|
4230
|
767 * Add a deny buddy to the list.
|
2991
|
768 *
|
3210
|
769 * @param sess The oscar session.
|
4230
|
770 * @param name The name of the item..
|
3210
|
771 * @return Return 0 if no errors, otherwise return the error number.
|
2991
|
772 */
|
4889
|
773 faim_export int aim_ssi_adddeny(aim_session_t *sess, const char *name)
|
2991
|
774 {
|
4889
|
775
|
|
776 if (!sess || !name)
|
2991
|
777 return -EINVAL;
|
|
778
|
4230
|
779 /* Add that bad boy */
|
|
780 aim_ssi_itemlist_add(&sess->ssi.local, name, 0x0000, 0xFFFF, AIM_SSI_TYPE_DENY, NULL);
|
3017
|
781
|
4230
|
782 /* Sync our local list with the server list */
|
4889
|
783 aim_ssi_sync(sess);
|
2991
|
784
|
|
785 return 0;
|
|
786 }
|
|
787
|
3210
|
788 /**
|
4230
|
789 * Deletes a buddy from the list.
|
3210
|
790 *
|
|
791 * @param sess The oscar session.
|
4230
|
792 * @param name The name of the item, or NULL.
|
|
793 * @param group The group of the item, or NULL.
|
3210
|
794 * @return Return 0 if no errors, otherwise return the error number.
|
|
795 */
|
4889
|
796 faim_export int aim_ssi_delbuddy(aim_session_t *sess, const char *name, const char *group)
|
2991
|
797 {
|
4230
|
798 struct aim_ssi_item *del;
|
2991
|
799
|
4889
|
800 if (!sess)
|
4230
|
801 return -EINVAL;
|
|
802
|
|
803 /* Find the buddy */
|
|
804 if (!(del = aim_ssi_itemlist_finditem(sess->ssi.local, group, name, AIM_SSI_TYPE_BUDDY)))
|
2991
|
805 return -EINVAL;
|
|
806
|
4230
|
807 /* Remove the item from the list */
|
|
808 aim_ssi_itemlist_del(&sess->ssi.local, del);
|
|
809
|
|
810 /* Modify the parent group */
|
|
811 aim_ssi_itemlist_rebuildgroup(sess->ssi.local, group);
|
|
812
|
|
813 /* Check if we should delete the parent group */
|
|
814 if ((del = aim_ssi_itemlist_finditem(sess->ssi.local, group, NULL, AIM_SSI_TYPE_GROUP)) && (!del->data)) {
|
|
815 aim_ssi_itemlist_del(&sess->ssi.local, del);
|
|
816
|
|
817 /* Modify the parent group */
|
|
818 aim_ssi_itemlist_rebuildgroup(sess->ssi.local, NULL);
|
|
819
|
|
820 /* Check if we should delete the parent's parent (the master group) */
|
|
821 if ((del = aim_ssi_itemlist_find(sess->ssi.local, 0x0000, 0x0000)) && (!del->data)) {
|
|
822 aim_ssi_itemlist_del(&sess->ssi.local, del);
|
|
823 }
|
2991
|
824 }
|
|
825
|
4230
|
826 /* Sync our local list with the server list */
|
4889
|
827 aim_ssi_sync(sess);
|
2991
|
828
|
|
829 return 0;
|
|
830 }
|
|
831
|
3210
|
832 /**
|
4230
|
833 * Deletes a permit buddy from the list.
|
3210
|
834 *
|
|
835 * @param sess The oscar session.
|
4230
|
836 * @param name The name of the item, or NULL.
|
3210
|
837 * @return Return 0 if no errors, otherwise return the error number.
|
3017
|
838 */
|
4889
|
839 faim_export int aim_ssi_delpermit(aim_session_t *sess, const char *name)
|
2991
|
840 {
|
4230
|
841 struct aim_ssi_item *del;
|
2991
|
842
|
4889
|
843 if (!sess)
|
4230
|
844 return -EINVAL;
|
|
845
|
|
846 /* Find the item */
|
|
847 if (!(del = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, name, AIM_SSI_TYPE_PERMIT)))
|
2991
|
848 return -EINVAL;
|
|
849
|
4230
|
850 /* Remove the item from the list */
|
|
851 aim_ssi_itemlist_del(&sess->ssi.local, del);
|
2991
|
852
|
4230
|
853 /* Sync our local list with the server list */
|
4889
|
854 aim_ssi_sync(sess);
|
4230
|
855
|
|
856 return 0;
|
|
857 }
|
2991
|
858
|
4230
|
859 /**
|
|
860 * Deletes a deny buddy from the list.
|
|
861 *
|
|
862 * @param sess The oscar session.
|
|
863 * @param name The name of the item, or NULL.
|
|
864 * @return Return 0 if no errors, otherwise return the error number.
|
|
865 */
|
4889
|
866 faim_export int aim_ssi_deldeny(aim_session_t *sess, const char *name)
|
4230
|
867 {
|
|
868 struct aim_ssi_item *del;
|
2991
|
869
|
4889
|
870 if (!sess)
|
4230
|
871 return -EINVAL;
|
2991
|
872
|
4230
|
873 /* Find the item */
|
4248
|
874 if (!(del = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, name, AIM_SSI_TYPE_DENY)))
|
4230
|
875 return -EINVAL;
|
|
876
|
|
877 /* Remove the item from the list */
|
|
878 aim_ssi_itemlist_del(&sess->ssi.local, del);
|
|
879
|
|
880 /* Sync our local list with the server list */
|
4889
|
881 aim_ssi_sync(sess);
|
2991
|
882
|
|
883 return 0;
|
|
884 }
|
|
885
|
3210
|
886 /**
|
|
887 * Move a buddy from one group to another group. This basically just deletes the
|
|
888 * buddy and re-adds it.
|
|
889 *
|
|
890 * @param sess The oscar session.
|
|
891 * @param oldgn The group that the buddy is currently in.
|
|
892 * @param newgn The group that the buddy should be moved in to.
|
|
893 * @param sn The name of the buddy to be moved.
|
|
894 * @return Return 0 if no errors, otherwise return the error number.
|
|
895 */
|
4889
|
896 faim_export int aim_ssi_movebuddy(aim_session_t *sess, const char *oldgn, const char *newgn, const char *sn)
|
3140
|
897 {
|
4889
|
898 aim_ssi_addbuddy(sess, sn, newgn, aim_ssi_getalias(sess->ssi.local, oldgn, sn), NULL, NULL, aim_ssi_waitingforauth(sess->ssi.local, oldgn, sn));
|
|
899 aim_ssi_delbuddy(sess, sn, oldgn);
|
3140
|
900 return 0;
|
|
901 }
|
|
902
|
3210
|
903 /**
|
4269
|
904 * Change the alias stored on the server for a given buddy.
|
|
905 *
|
|
906 * @param sess The oscar session.
|
|
907 * @param gn The group that the buddy is currently in.
|
|
908 * @param sn The screen name of the buddy.
|
7166
|
909 * @param alias The new alias for the buddy, or NULL if you want to remove
|
7172
|
910 * a buddy's comment.
|
4269
|
911 * @return Return 0 if no errors, otherwise return the error number.
|
|
912 */
|
4889
|
913 faim_export int aim_ssi_aliasbuddy(aim_session_t *sess, const char *gn, const char *sn, const char *alias)
|
4269
|
914 {
|
|
915 struct aim_ssi_item *tmp;
|
|
916
|
4889
|
917 if (!sess || !gn || !sn)
|
4269
|
918 return -EINVAL;
|
|
919
|
|
920 if (!(tmp = aim_ssi_itemlist_finditem(sess->ssi.local, gn, sn, AIM_SSI_TYPE_BUDDY)))
|
|
921 return -EINVAL;
|
|
922
|
7166
|
923 /* Either add or remove the 0x0131 TLV from the TLV chain */
|
|
924 if ((alias != NULL) && (strlen(alias) > 0))
|
|
925 aim_tlvlist_replace_raw(&tmp->data, 0x0131, strlen(alias), alias);
|
|
926 else
|
|
927 aim_tlvlist_remove(&tmp->data, 0x0131);
|
4269
|
928
|
|
929 /* Sync our local list with the server list */
|
4889
|
930 aim_ssi_sync(sess);
|
4269
|
931
|
|
932 return 0;
|
|
933 }
|
|
934
|
|
935 /**
|
7172
|
936 * Change the comment stored on the server for a given buddy.
|
|
937 *
|
|
938 * @param sess The oscar session.
|
|
939 * @param gn The group that the buddy is currently in.
|
|
940 * @param sn The screen name of the buddy.
|
|
941 * @param alias The new comment for the buddy, or NULL if you want to remove
|
|
942 * a buddy's comment.
|
|
943 * @return Return 0 if no errors, otherwise return the error number.
|
|
944 */
|
|
945 faim_export int aim_ssi_editcomment(aim_session_t *sess, const char *gn, const char *sn, const char *comment)
|
|
946 {
|
|
947 struct aim_ssi_item *tmp;
|
|
948
|
|
949 if (!sess || !gn || !sn)
|
|
950 return -EINVAL;
|
|
951
|
|
952 if (!(tmp = aim_ssi_itemlist_finditem(sess->ssi.local, gn, sn, AIM_SSI_TYPE_BUDDY)))
|
|
953 return -EINVAL;
|
|
954
|
|
955 /* Either add or remove the 0x0131 TLV from the TLV chain */
|
|
956 if ((comment != NULL) && (strlen(comment) > 0))
|
|
957 aim_tlvlist_replace_raw(&tmp->data, 0x013c, strlen(comment), comment);
|
|
958 else
|
|
959 aim_tlvlist_remove(&tmp->data, 0x013c);
|
|
960
|
|
961 /* Sync our local list with the server list */
|
|
962 aim_ssi_sync(sess);
|
|
963
|
|
964 return 0;
|
|
965 }
|
|
966
|
|
967 /**
|
4230
|
968 * Rename a group.
|
3348
|
969 *
|
|
970 * @param sess The oscar session.
|
|
971 * @param oldgn The old group name.
|
|
972 * @param newgn The new group name.
|
|
973 * @return Return 0 if no errors, otherwise return the error number.
|
|
974 */
|
4889
|
975 faim_export int aim_ssi_rename_group(aim_session_t *sess, const char *oldgn, const char *newgn)
|
3348
|
976 {
|
|
977 struct aim_ssi_item *group;
|
|
978
|
4889
|
979 if (!sess || !oldgn || !newgn)
|
3348
|
980 return -EINVAL;
|
|
981
|
4230
|
982 if (!(group = aim_ssi_itemlist_finditem(sess->ssi.local, oldgn, NULL, AIM_SSI_TYPE_GROUP)))
|
3017
|
983 return -EINVAL;
|
|
984
|
4230
|
985 free(group->name);
|
|
986 group->name = (char *)malloc((strlen(newgn)+1)*sizeof(char));
|
|
987 strcpy(group->name, newgn);
|
2991
|
988
|
4230
|
989 /* Sync our local list with the server list */
|
4889
|
990 aim_ssi_sync(sess);
|
2991
|
991
|
|
992 return 0;
|
|
993 }
|
|
994
|
3210
|
995 /**
|
2991
|
996 * Stores your permit/deny setting on the server, and starts using it.
|
3210
|
997 *
|
|
998 * @param sess The oscar session.
|
|
999 * @param permdeny Your permit/deny setting. Can be one of the following:
|
|
1000 * 1 - Allow all users
|
|
1001 * 2 - Block all users
|
|
1002 * 3 - Allow only the users below
|
|
1003 * 4 - Block only the users below
|
|
1004 * 5 - Allow only users on my buddy list
|
|
1005 * @param vismask A bitmask of the class of users to whom you want to be
|
|
1006 * visible. See the AIM_FLAG_BLEH #defines in aim.h
|
|
1007 * @return Return 0 if no errors, otherwise return the error number.
|
2991
|
1008 */
|
4889
|
1009 faim_export int aim_ssi_setpermdeny(aim_session_t *sess, fu8_t permdeny, fu32_t vismask)
|
4230
|
1010 {
|
|
1011 struct aim_ssi_item *tmp;
|
2991
|
1012
|
4889
|
1013 if (!sess)
|
2991
|
1014 return -EINVAL;
|
|
1015
|
7166
|
1016 /* Find the PDINFO item, or add it if it does not exist */
|
|
1017 if (!(tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, NULL, AIM_SSI_TYPE_PDINFO)))
|
|
1018 tmp = aim_ssi_itemlist_add(&sess->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PDINFO, NULL);
|
2991
|
1019
|
7166
|
1020 /* Need to add the 0x00ca TLV to the TLV chain */
|
|
1021 aim_tlvlist_replace_8(&tmp->data, 0x00ca, permdeny);
|
|
1022
|
|
1023 /* Need to add the 0x00cb TLV to the TLV chain */
|
|
1024 aim_tlvlist_replace_32(&tmp->data, 0x00cb, vismask);
|
2991
|
1025
|
4230
|
1026 /* Sync our local list with the server list */
|
4889
|
1027 aim_ssi_sync(sess);
|
|
1028
|
|
1029 return 0;
|
|
1030 }
|
|
1031
|
|
1032 /**
|
|
1033 * Set buddy icon information
|
|
1034 *
|
|
1035 * @param sess The oscar session.
|
|
1036 * @param iconcsum The MD5 checksum of the icon you are using.
|
5842
|
1037 * @param iconcsumlen Length of the MD5 checksum given above. Should be 0x10 bytes.
|
4889
|
1038 * @return Return 0 if no errors, otherwise return the error number.
|
|
1039 */
|
|
1040 faim_export int aim_ssi_seticon(aim_session_t *sess, fu8_t *iconsum, fu16_t iconsumlen)
|
|
1041 {
|
|
1042 struct aim_ssi_item *tmp;
|
|
1043 fu8_t *csumdata;
|
|
1044
|
|
1045 if (!sess || !iconsum || !iconsumlen)
|
|
1046 return -EINVAL;
|
|
1047
|
7166
|
1048 /* Find the ICONINFO item, or add it if it does not exist */
|
|
1049 if (!(tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, "1", AIM_SSI_TYPE_ICONINFO))) {
|
|
1050 tmp = aim_ssi_itemlist_add(&sess->ssi.local, "1", 0x0000, 0x51F4, AIM_SSI_TYPE_ICONINFO, NULL);
|
|
1051 }
|
|
1052
|
|
1053 /* Need to add the 0x00d5 TLV to the TLV chain */
|
4889
|
1054 if (!(csumdata = (fu8_t *)malloc((iconsumlen+2)*sizeof(fu8_t))))
|
|
1055 return -ENOMEM;
|
|
1056 csumdata[0] = 0x00;
|
|
1057 csumdata[1] = 0x10;
|
|
1058 memcpy(&csumdata[2], iconsum, iconsumlen);
|
7166
|
1059 aim_tlvlist_replace_raw(&tmp->data, 0x00d5, (iconsumlen+2) * sizeof(fu8_t), csumdata);
|
|
1060 free(csumdata);
|
4889
|
1061
|
7166
|
1062 /* Need to add the 0x0131 TLV to the TLV chain, used to cache the icon */
|
|
1063 aim_tlvlist_replace_noval(&tmp->data, 0x0131);
|
4889
|
1064
|
|
1065 /* Sync our local list with the server list */
|
|
1066 aim_ssi_sync(sess);
|
2991
|
1067 return 0;
|
|
1068 }
|
|
1069
|
3210
|
1070 /**
|
7313
|
1071 * Remove a reference to a server stored buddy icon. This will make your
|
|
1072 * icon stop showing up to other people.
|
|
1073 *
|
|
1074 * @param sess The oscar session.
|
|
1075 * @return Return 0 if no errors, otherwise return the error number.
|
|
1076 */
|
|
1077 faim_export int aim_ssi_delicon(aim_session_t *sess)
|
|
1078 {
|
|
1079 struct aim_ssi_item *tmp;
|
|
1080
|
|
1081 if (!sess)
|
|
1082 return -EINVAL;
|
|
1083
|
|
1084 /* Find the ICONINFO item and delete it if it exists*/
|
|
1085 if ((tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, "1", AIM_SSI_TYPE_ICONINFO)))
|
|
1086 aim_ssi_itemlist_del(&sess->ssi.local, tmp);
|
|
1087
|
|
1088 /* Sync our local list with the server list */
|
|
1089 aim_ssi_sync(sess);
|
|
1090 return 0;
|
|
1091 }
|
|
1092
|
|
1093 /**
|
8233
|
1094 * Stores your setting for various SSI settings. Whether you
|
|
1095 * should show up as idle or not, etc.
|
3210
|
1096 *
|
|
1097 * @param sess The oscar session.
|
|
1098 * @param presence I think it's a bitmask, but I only know what one of the bits is:
|
7218
|
1099 * 0x00000002 - Hide wireless?
|
3210
|
1100 * 0x00000400 - Allow others to see your idle time
|
|
1101 * @return Return 0 if no errors, otherwise return the error number.
|
3109
|
1102 */
|
4889
|
1103 faim_export int aim_ssi_setpresence(aim_session_t *sess, fu32_t presence) {
|
4230
|
1104 struct aim_ssi_item *tmp;
|
3109
|
1105
|
4889
|
1106 if (!sess)
|
3109
|
1107 return -EINVAL;
|
|
1108
|
7166
|
1109 /* Find the PRESENCEPREFS item, or add it if it does not exist */
|
|
1110 if (!(tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, NULL, AIM_SSI_TYPE_PRESENCEPREFS)))
|
|
1111 tmp = aim_ssi_itemlist_add(&sess->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PRESENCEPREFS, NULL);
|
3109
|
1112
|
7166
|
1113 /* Need to add the x00c9 TLV to the TLV chain */
|
|
1114 aim_tlvlist_replace_32(&tmp->data, 0x00c9, presence);
|
3109
|
1115
|
4230
|
1116 /* Sync our local list with the server list */
|
4889
|
1117 aim_ssi_sync(sess);
|
3109
|
1118
|
|
1119 return 0;
|
|
1120 }
|
|
1121
|
|
1122 /*
|
4230
|
1123 * Subtype 0x0002 - Request SSI Rights.
|
2672
|
1124 */
|
4889
|
1125 faim_export int aim_ssi_reqrights(aim_session_t *sess)
|
2672
|
1126 {
|
4889
|
1127 aim_conn_t *conn;
|
|
1128
|
|
1129 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)))
|
|
1130 return -EINVAL;
|
|
1131
|
7282
|
1132 return aim_genericreq_n_snacid(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_REQRIGHTS);
|
2672
|
1133 }
|
|
1134
|
|
1135 /*
|
4230
|
1136 * Subtype 0x0003 - SSI Rights Information.
|
2672
|
1137 */
|
|
1138 static int parserights(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1139 {
|
4230
|
1140 int ret = 0, i;
|
2672
|
1141 aim_rxcallback_t userfunc;
|
4230
|
1142 aim_tlvlist_t *tlvlist;
|
|
1143 aim_tlv_t *tlv;
|
|
1144 aim_bstream_t bstream;
|
|
1145 fu16_t *maxitems;
|
|
1146
|
|
1147 /* This SNAC is made up of a bunch of TLVs */
|
7167
|
1148 tlvlist = aim_tlvlist_read(bs);
|
4230
|
1149
|
|
1150 /* TLV 0x0004 contains the maximum number of each item */
|
7167
|
1151 if (!(tlv = aim_tlv_gettlv(tlvlist, 0x0004, 1))) {
|
|
1152 aim_tlvlist_free(&tlvlist);
|
4230
|
1153 return 0;
|
|
1154 }
|
|
1155
|
|
1156 aim_bstream_init(&bstream, tlv->value, tlv->length);
|
|
1157
|
|
1158 if (!(maxitems = (fu16_t *)malloc((tlv->length/2)*sizeof(fu16_t)))) {
|
7167
|
1159 aim_tlvlist_free(&tlvlist);
|
4230
|
1160 return 0;
|
|
1161 }
|
|
1162
|
|
1163 for (i=0; i<(tlv->length/2); i++)
|
|
1164 maxitems[i] = aimbs_get16(&bstream);
|
2672
|
1165
|
|
1166 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
4230
|
1167 ret = userfunc(sess, rx, tlv->length/2, maxitems);
|
|
1168
|
7167
|
1169 aim_tlvlist_free(&tlvlist);
|
4230
|
1170 free(maxitems);
|
2672
|
1171
|
|
1172 return ret;
|
|
1173 }
|
|
1174
|
|
1175 /*
|
6350
|
1176 * Subtype 0x0004 - Request SSI Data when you don't have a timestamp and
|
|
1177 * revision number.
|
4230
|
1178 *
|
|
1179 */
|
6350
|
1180 faim_export int aim_ssi_reqdata(aim_session_t *sess)
|
|
1181 {
|
|
1182 aim_conn_t *conn;
|
4230
|
1183
|
6350
|
1184 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)))
|
|
1185 return -EINVAL;
|
|
1186
|
|
1187 /* Free any current data, just in case */
|
|
1188 aim_ssi_freelist(sess);
|
|
1189
|
|
1190 return aim_genericreq_n_snacid(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_REQDATA);
|
|
1191 }
|
4230
|
1192
|
|
1193 /*
|
6350
|
1194 * Subtype 0x0005 - Request SSI Data when you have a timestamp and revision
|
|
1195 * number.
|
2672
|
1196 *
|
|
1197 * The data will only be sent if it is newer than the posted local
|
|
1198 * timestamp and revision.
|
|
1199 *
|
|
1200 * Note that the client should never increment the revision, only the server.
|
|
1201 *
|
|
1202 */
|
6350
|
1203 faim_export int aim_ssi_reqifchanged(aim_session_t *sess, time_t timestamp, fu16_t numitems)
|
2672
|
1204 {
|
4889
|
1205 aim_conn_t *conn;
|
2672
|
1206 aim_frame_t *fr;
|
|
1207 aim_snacid_t snacid;
|
|
1208
|
4889
|
1209 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)))
|
2672
|
1210 return -EINVAL;
|
|
1211
|
|
1212 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+2)))
|
|
1213 return -ENOMEM;
|
|
1214
|
6350
|
1215 snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, AIM_CB_SSI_REQIFCHANGED, 0x0000, NULL, 0);
|
2672
|
1216
|
6350
|
1217 aim_putsnac(&fr->data, AIM_CB_FAM_SSI, AIM_CB_SSI_REQIFCHANGED, 0x0000, snacid);
|
4282
|
1218 aimbs_put32(&fr->data, timestamp);
|
|
1219 aimbs_put16(&fr->data, numitems);
|
2672
|
1220
|
|
1221 aim_tx_enqueue(sess, fr);
|
|
1222
|
4230
|
1223 /* Free any current data, just in case */
|
|
1224 aim_ssi_freelist(sess);
|
|
1225
|
2672
|
1226 return 0;
|
|
1227 }
|
|
1228
|
|
1229 /*
|
4230
|
1230 * Subtype 0x0006 - SSI Data.
|
2672
|
1231 */
|
|
1232 static int parsedata(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1233 {
|
|
1234 int ret = 0;
|
|
1235 aim_rxcallback_t userfunc;
|
|
1236 fu8_t fmtver; /* guess */
|
4282
|
1237 fu16_t namelen, gid, bid, type;
|
4236
|
1238 char *name;
|
|
1239 aim_tlvlist_t *data;
|
2672
|
1240
|
2991
|
1241 fmtver = aimbs_get8(bs); /* Version of ssi data. Should be 0x00 */
|
4282
|
1242 sess->ssi.numitems += aimbs_get16(bs); /* # of items in this SSI SNAC */
|
2672
|
1243
|
4230
|
1244 /* Read in the list */
|
|
1245 while (aim_bstream_empty(bs) > 4) { /* last four bytes are timestamp */
|
2672
|
1246 if ((namelen = aimbs_get16(bs)))
|
4236
|
1247 name = aimbs_getstr(bs, namelen);
|
4230
|
1248 else
|
4236
|
1249 name = NULL;
|
|
1250 gid = aimbs_get16(bs);
|
|
1251 bid = aimbs_get16(bs);
|
|
1252 type = aimbs_get16(bs);
|
7167
|
1253 data = aim_tlvlist_readlen(bs, aimbs_get16(bs));
|
4236
|
1254 aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, data);
|
|
1255 free(name);
|
7167
|
1256 aim_tlvlist_free(&data);
|
2672
|
1257 }
|
|
1258
|
4230
|
1259 /* Read in the timestamp */
|
4282
|
1260 sess->ssi.timestamp = aimbs_get32(bs);
|
2672
|
1261
|
4317
|
1262 if (!(snac->flags & 0x0001)) {
|
4230
|
1263 /* Make a copy of the list */
|
4236
|
1264 struct aim_ssi_item *cur;
|
|
1265 for (cur=sess->ssi.official; cur; cur=cur->next)
|
|
1266 aim_ssi_itemlist_add(&sess->ssi.local, cur->name, cur->gid, cur->bid, cur->type, cur->data);
|
4230
|
1267
|
|
1268 sess->ssi.received_data = 1;
|
|
1269
|
|
1270 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
1271 ret = userfunc(sess, rx, fmtver, sess->ssi.numitems, sess->ssi.official, sess->ssi.timestamp);
|
|
1272 }
|
2672
|
1273
|
|
1274 return ret;
|
|
1275 }
|
|
1276
|
|
1277 /*
|
4230
|
1278 * Subtype 0x0007 - SSI Activate Data.
|
2672
|
1279 *
|
|
1280 * Should be sent after receiving 13/6 or 13/f to tell the server you
|
|
1281 * are ready to begin using the list. It will promptly give you the
|
|
1282 * presence information for everyone in your list and put your permit/deny
|
|
1283 * settings into effect.
|
|
1284 *
|
|
1285 */
|
4642
|
1286 faim_export int aim_ssi_enable(aim_session_t *sess)
|
2672
|
1287 {
|
4642
|
1288 aim_conn_t *conn;
|
|
1289
|
|
1290 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)))
|
|
1291 return -EINVAL;
|
|
1292
|
3017
|
1293 return aim_genericreq_n(sess, conn, AIM_CB_FAM_SSI, 0x0007);
|
2672
|
1294 }
|
|
1295
|
|
1296 /*
|
4230
|
1297 * Subtype 0x0008/0x0009/0x000a - SSI Add/Mod/Del Item(s).
|
2991
|
1298 *
|
3017
|
1299 * Sends the SNAC to add, modify, or delete an item from the server-stored
|
|
1300 * information. These 3 SNACs all have an identical structure. The only
|
|
1301 * difference is the subtype that is set for the SNAC.
|
2991
|
1302 *
|
|
1303 */
|
4889
|
1304 faim_export int aim_ssi_addmoddel(aim_session_t *sess)
|
2991
|
1305 {
|
4889
|
1306 aim_conn_t *conn;
|
2991
|
1307 aim_frame_t *fr;
|
|
1308 aim_snacid_t snacid;
|
4230
|
1309 int snaclen;
|
|
1310 struct aim_ssi_tmp *cur;
|
2991
|
1311
|
4889
|
1312 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)) || !sess->ssi.pending || !sess->ssi.pending->item)
|
2991
|
1313 return -EINVAL;
|
|
1314
|
4230
|
1315 /* Calculate total SNAC size */
|
2991
|
1316 snaclen = 10; /* For family, subtype, flags, and SNAC ID */
|
4230
|
1317 for (cur=sess->ssi.pending; cur; cur=cur->next) {
|
2991
|
1318 snaclen += 10; /* For length, GID, BID, type, and length */
|
4230
|
1319 if (cur->item->name)
|
|
1320 snaclen += strlen(cur->item->name);
|
|
1321 if (cur->item->data)
|
7167
|
1322 snaclen += aim_tlvlist_size(&cur->item->data);
|
2991
|
1323 }
|
|
1324
|
|
1325 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, snaclen)))
|
|
1326 return -ENOMEM;
|
|
1327
|
4230
|
1328 snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, sess->ssi.pending->action, 0x0000, NULL, 0);
|
|
1329 aim_putsnac(&fr->data, AIM_CB_FAM_SSI, sess->ssi.pending->action, 0x0000, snacid);
|
2991
|
1330
|
4230
|
1331 for (cur=sess->ssi.pending; cur; cur=cur->next) {
|
|
1332 aimbs_put16(&fr->data, cur->item->name ? strlen(cur->item->name) : 0);
|
|
1333 if (cur->item->name)
|
|
1334 aimbs_putraw(&fr->data, cur->item->name, strlen(cur->item->name));
|
|
1335 aimbs_put16(&fr->data, cur->item->gid);
|
|
1336 aimbs_put16(&fr->data, cur->item->bid);
|
|
1337 aimbs_put16(&fr->data, cur->item->type);
|
7167
|
1338 aimbs_put16(&fr->data, cur->item->data ? aim_tlvlist_size(&cur->item->data) : 0);
|
4230
|
1339 if (cur->item->data)
|
7167
|
1340 aim_tlvlist_write(&fr->data, &cur->item->data);
|
2991
|
1341 }
|
|
1342
|
4230
|
1343 aim_tx_enqueue(sess, fr);
|
2991
|
1344
|
|
1345 return 0;
|
|
1346 }
|
|
1347
|
|
1348 /*
|
4230
|
1349 * Subtype 0x0008 - Incoming SSI add.
|
|
1350 *
|
8226
|
1351 * Sent by the server, for example, when someone is added to
|
|
1352 * your "Recent Buddies" group.
|
4230
|
1353 */
|
|
1354 static int parseadd(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1355 {
|
|
1356 int ret = 0;
|
|
1357 aim_rxcallback_t userfunc;
|
|
1358 char *name;
|
|
1359 fu16_t len, gid, bid, type;
|
|
1360 aim_tlvlist_t *data;
|
|
1361
|
|
1362 while (aim_bstream_empty(bs)) {
|
|
1363 if ((len = aimbs_get16(bs)))
|
|
1364 name = aimbs_getstr(bs, len);
|
|
1365 else
|
|
1366 name = NULL;
|
|
1367 gid = aimbs_get16(bs);
|
|
1368 bid = aimbs_get16(bs);
|
|
1369 type = aimbs_get16(bs);
|
|
1370 if ((len = aimbs_get16(bs)))
|
7167
|
1371 data = aim_tlvlist_readlen(bs, len);
|
4230
|
1372 else
|
|
1373 data = NULL;
|
|
1374
|
|
1375 aim_ssi_itemlist_add(&sess->ssi.local, name, gid, bid, type, data);
|
4236
|
1376 aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, data);
|
7167
|
1377 aim_tlvlist_free(&data);
|
4230
|
1378
|
|
1379 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
8227
|
1380 ret = userfunc(sess, rx, type, name);
|
|
1381
|
|
1382 free(name);
|
4230
|
1383 }
|
|
1384
|
|
1385 return ret;
|
|
1386 }
|
|
1387
|
|
1388 /*
|
|
1389 * Subtype 0x0009 - Incoming SSI mod.
|
|
1390 *
|
|
1391 * XXX - It would probably be good for the client to actually do something when it gets this.
|
|
1392 */
|
|
1393 static int parsemod(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1394 {
|
|
1395 int ret = 0;
|
|
1396 aim_rxcallback_t userfunc;
|
|
1397 char *name;
|
|
1398 fu16_t len, gid, bid, type;
|
|
1399 aim_tlvlist_t *data;
|
|
1400 struct aim_ssi_item *item;
|
|
1401
|
|
1402 while (aim_bstream_empty(bs)) {
|
|
1403 if ((len = aimbs_get16(bs)))
|
|
1404 name = aimbs_getstr(bs, len);
|
|
1405 else
|
|
1406 name = NULL;
|
|
1407 gid = aimbs_get16(bs);
|
|
1408 bid = aimbs_get16(bs);
|
|
1409 type = aimbs_get16(bs);
|
|
1410 if ((len = aimbs_get16(bs)))
|
7167
|
1411 data = aim_tlvlist_readlen(bs, len);
|
4230
|
1412 else
|
|
1413 data = NULL;
|
|
1414
|
|
1415 /* Replace the 2 local items with the given one */
|
|
1416 if ((item = aim_ssi_itemlist_find(sess->ssi.local, gid, bid))) {
|
|
1417 item->type = type;
|
|
1418 free(item->name);
|
|
1419 if (name) {
|
|
1420 item->name = (char *)malloc((strlen(name)+1)*sizeof(char));
|
|
1421 strcpy(item->name, name);
|
|
1422 } else
|
|
1423 item->name = NULL;
|
7167
|
1424 aim_tlvlist_free(&item->data);
|
4234
|
1425 item->data = aim_tlvlist_copy(data);
|
4230
|
1426 }
|
|
1427
|
|
1428 if ((item = aim_ssi_itemlist_find(sess->ssi.official, gid, bid))) {
|
|
1429 item->type = type;
|
|
1430 free(item->name);
|
|
1431 if (name) {
|
|
1432 item->name = (char *)malloc((strlen(name)+1)*sizeof(char));
|
|
1433 strcpy(item->name, name);
|
|
1434 } else
|
|
1435 item->name = NULL;
|
7167
|
1436 aim_tlvlist_free(&item->data);
|
4234
|
1437 item->data = aim_tlvlist_copy(data);
|
4230
|
1438 }
|
|
1439
|
|
1440 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
1441 ret = userfunc(sess, rx);
|
|
1442
|
4236
|
1443 free(name);
|
7167
|
1444 aim_tlvlist_free(&data);
|
4230
|
1445 }
|
|
1446
|
|
1447 return ret;
|
|
1448 }
|
|
1449
|
|
1450 /*
|
|
1451 * Subtype 0x000a - Incoming SSI del.
|
|
1452 *
|
|
1453 * XXX - It would probably be good for the client to actually do something when it gets this.
|
|
1454 */
|
|
1455 static int parsedel(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1456 {
|
|
1457 int ret = 0;
|
|
1458 aim_rxcallback_t userfunc;
|
|
1459 fu16_t gid, bid;
|
|
1460 struct aim_ssi_item *del;
|
|
1461
|
|
1462 while (aim_bstream_empty(bs)) {
|
|
1463 aim_bstream_advance(bs, aimbs_get16(bs));
|
|
1464 gid = aimbs_get16(bs);
|
|
1465 bid = aimbs_get16(bs);
|
|
1466 aimbs_get16(bs);
|
|
1467 aim_bstream_advance(bs, aimbs_get16(bs));
|
|
1468
|
4358
|
1469 if ((del = aim_ssi_itemlist_find(sess->ssi.local, gid, bid)))
|
|
1470 aim_ssi_itemlist_del(&sess->ssi.local, del);
|
|
1471 if ((del = aim_ssi_itemlist_find(sess->ssi.official, gid, bid)))
|
|
1472 aim_ssi_itemlist_del(&sess->ssi.official, del);
|
4230
|
1473
|
|
1474 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
1475 ret = userfunc(sess, rx);
|
|
1476 }
|
|
1477
|
|
1478 return ret;
|
|
1479 }
|
|
1480
|
|
1481 /*
|
|
1482 * Subtype 0x000e - SSI Add/Mod/Del Ack.
|
2991
|
1483 *
|
3017
|
1484 * Response to add, modify, or delete SNAC (sent with aim_ssi_addmoddel).
|
2991
|
1485 *
|
|
1486 */
|
|
1487 static int parseack(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1488 {
|
|
1489 int ret = 0;
|
|
1490 aim_rxcallback_t userfunc;
|
4230
|
1491 struct aim_ssi_tmp *cur, *del;
|
2991
|
1492
|
4230
|
1493 /* Read in the success/failure flags from the ack SNAC */
|
|
1494 cur = sess->ssi.pending;
|
|
1495 while (cur && (aim_bstream_empty(bs)>0)) {
|
|
1496 cur->ack = aimbs_get16(bs);
|
|
1497 cur = cur->next;
|
|
1498 }
|
|
1499
|
|
1500 /*
|
|
1501 * If outcome is 0, then add the item to the item list, or replace the other item,
|
|
1502 * or remove the old item. If outcome is non-zero, then remove the item from the
|
|
1503 * local list, or unmodify it, or add it.
|
|
1504 */
|
|
1505 for (cur=sess->ssi.pending; (cur && (cur->ack != 0xffff)); cur=cur->next) {
|
|
1506 if (cur->item) {
|
|
1507 if (cur->ack) {
|
|
1508 /* Our action was unsuccessful, so change the local list back to how it was */
|
|
1509 if (cur->action == AIM_CB_SSI_ADD) {
|
4791
|
1510 /* Remove the item from the local list */
|
|
1511 /* Make sure cur->item is still valid memory */
|
4789
|
1512 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) {
|
|
1513 if (cur->item->name) {
|
|
1514 cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
|
|
1515 strcpy(cur->name, cur->item->name);
|
|
1516 }
|
|
1517 aim_ssi_itemlist_del(&sess->ssi.local, cur->item);
|
4230
|
1518 }
|
|
1519 cur->item = NULL;
|
|
1520
|
|
1521 } else if (cur->action == AIM_CB_SSI_MOD) {
|
4292
|
1522 /* Replace the local item with the item from the official list */
|
4789
|
1523 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) {
|
|
1524 struct aim_ssi_item *cur1;
|
|
1525 if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) {
|
|
1526 free(cur->item->name);
|
|
1527 if (cur1->name) {
|
|
1528 cur->item->name = (char *)malloc((strlen(cur1->name)+1)*sizeof(char));
|
|
1529 strcpy(cur->item->name, cur1->name);
|
|
1530 } else
|
|
1531 cur->item->name = NULL;
|
7167
|
1532 aim_tlvlist_free(&cur->item->data);
|
4789
|
1533 cur->item->data = aim_tlvlist_copy(cur1->data);
|
|
1534 }
|
|
1535 } else
|
|
1536 cur->item = NULL;
|
4230
|
1537
|
|
1538 } else if (cur->action == AIM_CB_SSI_DEL) {
|
4236
|
1539 /* Add the item back into the local list */
|
4791
|
1540 if (aim_ssi_itemlist_valid(sess->ssi.official, cur->item)) {
|
4789
|
1541 aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
|
|
1542 } else
|
|
1543 cur->item = NULL;
|
4230
|
1544 }
|
|
1545
|
|
1546 } else {
|
|
1547 /* Do the exact opposite */
|
|
1548 if (cur->action == AIM_CB_SSI_ADD) {
|
4791
|
1549 /* Add the local item to the official list */
|
|
1550 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) {
|
|
1551 aim_ssi_itemlist_add(&sess->ssi.official, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
|
|
1552 } else
|
|
1553 cur->item = NULL;
|
4230
|
1554
|
|
1555 } else if (cur->action == AIM_CB_SSI_MOD) {
|
4292
|
1556 /* Replace the official item with the item from the local list */
|
4791
|
1557 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) {
|
|
1558 struct aim_ssi_item *cur1;
|
|
1559 if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) {
|
|
1560 free(cur1->name);
|
|
1561 if (cur->item->name) {
|
|
1562 cur1->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
|
|
1563 strcpy(cur1->name, cur->item->name);
|
|
1564 } else
|
|
1565 cur1->name = NULL;
|
7167
|
1566 aim_tlvlist_free(&cur1->data);
|
4791
|
1567 cur1->data = aim_tlvlist_copy(cur->item->data);
|
|
1568 }
|
|
1569 } else
|
|
1570 cur->item = NULL;
|
4230
|
1571
|
|
1572 } else if (cur->action == AIM_CB_SSI_DEL) {
|
4292
|
1573 /* Remove the item from the official list */
|
4791
|
1574 if (aim_ssi_itemlist_valid(sess->ssi.official, cur->item))
|
|
1575 aim_ssi_itemlist_del(&sess->ssi.official, cur->item);
|
4230
|
1576 cur->item = NULL;
|
|
1577 }
|
|
1578
|
|
1579 }
|
|
1580 } /* End if (cur->item) */
|
|
1581 } /* End for loop */
|
2991
|
1582
|
|
1583 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
4230
|
1584 ret = userfunc(sess, rx, sess->ssi.pending);
|
|
1585
|
|
1586 /* Free all aim_ssi_tmp's with an outcome */
|
|
1587 cur = sess->ssi.pending;
|
|
1588 while (cur && (cur->ack != 0xffff)) {
|
|
1589 del = cur;
|
|
1590 cur = cur->next;
|
|
1591 free(del->name);
|
|
1592 free(del);
|
|
1593 }
|
|
1594 sess->ssi.pending = cur;
|
|
1595
|
|
1596 /* If we're not waiting for any more acks, then send more SNACs */
|
|
1597 if (!sess->ssi.pending) {
|
|
1598 sess->ssi.pending = NULL;
|
|
1599 sess->ssi.waiting_for_ack = 0;
|
4889
|
1600 aim_ssi_sync(sess);
|
4230
|
1601 }
|
2991
|
1602
|
|
1603 return ret;
|
|
1604 }
|
|
1605
|
|
1606 /*
|
4230
|
1607 * Subtype 0x000f - SSI Data Unchanged.
|
2672
|
1608 *
|
6350
|
1609 * Response to aim_ssi_reqifchanged() if the server-side data is not newer than
|
2672
|
1610 * posted local stamp/revision.
|
|
1611 *
|
|
1612 */
|
|
1613 static int parsedataunchanged(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1614 {
|
|
1615 int ret = 0;
|
|
1616 aim_rxcallback_t userfunc;
|
|
1617
|
2991
|
1618 sess->ssi.received_data = 1;
|
|
1619
|
2672
|
1620 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
1621 ret = userfunc(sess, rx);
|
|
1622
|
|
1623 return ret;
|
|
1624 }
|
|
1625
|
4230
|
1626 /*
|
|
1627 * Subtype 0x0011 - SSI Begin Data Modification.
|
|
1628 *
|
|
1629 * Tells the server you're going to start modifying data.
|
|
1630 *
|
|
1631 */
|
4889
|
1632 faim_export int aim_ssi_modbegin(aim_session_t *sess)
|
4230
|
1633 {
|
4889
|
1634 aim_conn_t *conn;
|
|
1635
|
|
1636 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)))
|
|
1637 return -EINVAL;
|
|
1638
|
4230
|
1639 return aim_genericreq_n(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_EDITSTART);
|
|
1640 }
|
|
1641
|
|
1642 /*
|
|
1643 * Subtype 0x0012 - SSI End Data Modification.
|
|
1644 *
|
|
1645 * Tells the server you're finished modifying data.
|
|
1646 *
|
|
1647 */
|
4889
|
1648 faim_export int aim_ssi_modend(aim_session_t *sess)
|
4230
|
1649 {
|
4889
|
1650 aim_conn_t *conn;
|
|
1651
|
|
1652 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)))
|
|
1653 return -EINVAL;
|
|
1654
|
4230
|
1655 return aim_genericreq_n(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_EDITSTOP);
|
|
1656 }
|
|
1657
|
|
1658 /*
|
|
1659 * Subtype 0x0014 - Grant authorization
|
|
1660 *
|
|
1661 * Authorizes a contact so they can add you to their contact list.
|
|
1662 *
|
|
1663 */
|
4889
|
1664 faim_export int aim_ssi_sendauth(aim_session_t *sess, char *sn, char *msg)
|
4230
|
1665 {
|
4889
|
1666 aim_conn_t *conn;
|
4230
|
1667 aim_frame_t *fr;
|
|
1668 aim_snacid_t snacid;
|
|
1669
|
4889
|
1670 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)) || !sn)
|
4230
|
1671 return -EINVAL;
|
|
1672
|
|
1673 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+strlen(sn)+2+(msg ? strlen(msg)+1 : 0)+2)))
|
|
1674 return -ENOMEM;
|
|
1675
|
|
1676 snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTH, 0x0000, NULL, 0);
|
|
1677 aim_putsnac(&fr->data, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTH, 0x0000, snacid);
|
|
1678
|
|
1679 /* Screen name */
|
|
1680 aimbs_put8(&fr->data, strlen(sn));
|
|
1681 aimbs_putraw(&fr->data, sn, strlen(sn));
|
|
1682
|
|
1683 /* Message (null terminated) */
|
|
1684 aimbs_put16(&fr->data, msg ? strlen(msg) : 0);
|
|
1685 if (msg) {
|
|
1686 aimbs_putraw(&fr->data, msg, strlen(msg));
|
|
1687 aimbs_put8(&fr->data, 0x00);
|
|
1688 }
|
|
1689
|
|
1690 /* Unknown */
|
|
1691 aimbs_put16(&fr->data, 0x0000);
|
|
1692
|
|
1693 aim_tx_enqueue(sess, fr);
|
|
1694
|
|
1695 return 0;
|
|
1696 }
|
|
1697
|
|
1698 /*
|
|
1699 * Subtype 0x0015 - Receive an authorization grant
|
|
1700 */
|
|
1701 static int receiveauthgrant(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1702 {
|
|
1703 int ret = 0;
|
|
1704 aim_rxcallback_t userfunc;
|
|
1705 fu16_t tmp;
|
|
1706 char *sn, *msg;
|
|
1707
|
|
1708 /* Read screen name */
|
|
1709 if ((tmp = aimbs_get8(bs)))
|
|
1710 sn = aimbs_getstr(bs, tmp);
|
|
1711 else
|
|
1712 sn = NULL;
|
|
1713
|
|
1714 /* Read message (null terminated) */
|
|
1715 if ((tmp = aimbs_get16(bs)))
|
|
1716 msg = aimbs_getstr(bs, tmp);
|
|
1717 else
|
|
1718 msg = NULL;
|
|
1719
|
|
1720 /* Unknown */
|
|
1721 tmp = aimbs_get16(bs);
|
|
1722
|
|
1723 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
1724 ret = userfunc(sess, rx, sn, msg);
|
|
1725
|
|
1726 free(sn);
|
|
1727 free(msg);
|
|
1728
|
|
1729 return ret;
|
|
1730 }
|
|
1731
|
|
1732 /*
|
|
1733 * Subtype 0x0018 - Send authorization request
|
|
1734 *
|
|
1735 * Sends a request for authorization to the given contact. The request will either be
|
|
1736 * granted, denied, or dropped.
|
|
1737 *
|
|
1738 */
|
4889
|
1739 faim_export int aim_ssi_sendauthrequest(aim_session_t *sess, char *sn, char *msg)
|
4230
|
1740 {
|
4889
|
1741 aim_conn_t *conn;
|
4230
|
1742 aim_frame_t *fr;
|
|
1743 aim_snacid_t snacid;
|
|
1744
|
4889
|
1745 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)) || !sn)
|
4230
|
1746 return -EINVAL;
|
|
1747
|
|
1748 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+strlen(sn)+2+(msg ? strlen(msg)+1 : 0)+2)))
|
|
1749 return -ENOMEM;
|
|
1750
|
|
1751 snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREQ, 0x0000, NULL, 0);
|
|
1752 aim_putsnac(&fr->data, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREQ, 0x0000, snacid);
|
|
1753
|
|
1754 /* Screen name */
|
|
1755 aimbs_put8(&fr->data, strlen(sn));
|
|
1756 aimbs_putraw(&fr->data, sn, strlen(sn));
|
|
1757
|
|
1758 /* Message (null terminated) */
|
|
1759 aimbs_put16(&fr->data, msg ? strlen(msg) : 0);
|
|
1760 if (msg) {
|
|
1761 aimbs_putraw(&fr->data, msg, strlen(msg));
|
|
1762 aimbs_put8(&fr->data, 0x00);
|
|
1763 }
|
|
1764
|
|
1765 /* Unknown */
|
|
1766 aimbs_put16(&fr->data, 0x0000);
|
|
1767
|
|
1768 aim_tx_enqueue(sess, fr);
|
|
1769
|
|
1770 return 0;
|
|
1771 }
|
|
1772
|
|
1773 /*
|
|
1774 * Subtype 0x0019 - Receive an authorization request
|
|
1775 */
|
|
1776 static int receiveauthrequest(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1777 {
|
|
1778 int ret = 0;
|
|
1779 aim_rxcallback_t userfunc;
|
|
1780 fu16_t tmp;
|
|
1781 char *sn, *msg;
|
|
1782
|
|
1783 /* Read screen name */
|
|
1784 if ((tmp = aimbs_get8(bs)))
|
|
1785 sn = aimbs_getstr(bs, tmp);
|
|
1786 else
|
|
1787 sn = NULL;
|
|
1788
|
|
1789 /* Read message (null terminated) */
|
|
1790 if ((tmp = aimbs_get16(bs)))
|
|
1791 msg = aimbs_getstr(bs, tmp);
|
|
1792 else
|
|
1793 msg = NULL;
|
|
1794
|
|
1795 /* Unknown */
|
|
1796 tmp = aimbs_get16(bs);
|
|
1797
|
|
1798 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
1799 ret = userfunc(sess, rx, sn, msg);
|
|
1800
|
|
1801 free(sn);
|
|
1802 free(msg);
|
|
1803
|
|
1804 return ret;
|
|
1805 }
|
|
1806
|
|
1807 /*
|
|
1808 * Subtype 0x001a - Send authorization reply
|
|
1809 *
|
|
1810 * Sends a reply to a request for authorization. The reply can either
|
|
1811 * grant authorization or deny authorization.
|
|
1812 *
|
|
1813 * if reply=0x00 then deny
|
|
1814 * if reply=0x01 then grant
|
|
1815 *
|
|
1816 */
|
4889
|
1817 faim_export int aim_ssi_sendauthreply(aim_session_t *sess, char *sn, fu8_t reply, char *msg)
|
4230
|
1818 {
|
4889
|
1819 aim_conn_t *conn;
|
4230
|
1820 aim_frame_t *fr;
|
|
1821 aim_snacid_t snacid;
|
|
1822
|
4889
|
1823 if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI)) || !sn)
|
4230
|
1824 return -EINVAL;
|
|
1825
|
|
1826 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 1+strlen(sn) + 1 + 2+(msg ? strlen(msg)+1 : 0) + 2)))
|
|
1827 return -ENOMEM;
|
|
1828
|
|
1829 snacid = aim_cachesnac(sess, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREP, 0x0000, NULL, 0);
|
|
1830 aim_putsnac(&fr->data, AIM_CB_FAM_SSI, AIM_CB_SSI_SENDAUTHREP, 0x0000, snacid);
|
|
1831
|
|
1832 /* Screen name */
|
|
1833 aimbs_put8(&fr->data, strlen(sn));
|
|
1834 aimbs_putraw(&fr->data, sn, strlen(sn));
|
|
1835
|
|
1836 /* Grant or deny */
|
|
1837 aimbs_put8(&fr->data, reply);
|
|
1838
|
|
1839 /* Message (null terminated) */
|
|
1840 aimbs_put16(&fr->data, msg ? (strlen(msg)+1) : 0);
|
|
1841 if (msg) {
|
|
1842 aimbs_putraw(&fr->data, msg, strlen(msg));
|
|
1843 aimbs_put8(&fr->data, 0x00);
|
|
1844 }
|
|
1845
|
|
1846 /* Unknown */
|
|
1847 aimbs_put16(&fr->data, 0x0000);
|
|
1848
|
|
1849 aim_tx_enqueue(sess, fr);
|
|
1850
|
|
1851 return 0;
|
|
1852 }
|
|
1853
|
|
1854 /*
|
|
1855 * Subtype 0x001b - Receive an authorization reply
|
|
1856 * You get this bad boy when other people respond to the authorization
|
|
1857 * request that you have previously sent them.
|
|
1858 */
|
|
1859 static int receiveauthreply(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1860 {
|
|
1861 int ret = 0;
|
|
1862 aim_rxcallback_t userfunc;
|
|
1863 fu16_t tmp;
|
|
1864 fu8_t reply;
|
|
1865 char *sn, *msg;
|
|
1866
|
|
1867 /* Read screen name */
|
|
1868 if ((tmp = aimbs_get8(bs)))
|
|
1869 sn = aimbs_getstr(bs, tmp);
|
|
1870 else
|
|
1871 sn = NULL;
|
|
1872
|
|
1873 /* Read reply */
|
|
1874 reply = aimbs_get8(bs);
|
|
1875
|
|
1876 /* Read message (null terminated) */
|
|
1877 if ((tmp = aimbs_get16(bs)))
|
|
1878 msg = aimbs_getstr(bs, tmp);
|
|
1879 else
|
|
1880 msg = NULL;
|
|
1881
|
|
1882 /* Unknown */
|
|
1883 tmp = aimbs_get16(bs);
|
|
1884
|
|
1885 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
1886 ret = userfunc(sess, rx, sn, reply, msg);
|
|
1887
|
|
1888 free(sn);
|
|
1889 free(msg);
|
|
1890
|
|
1891 return ret;
|
|
1892 }
|
|
1893
|
|
1894 /*
|
|
1895 * Subtype 0x001c - Receive a message telling you someone added you to their list.
|
|
1896 */
|
|
1897 static int receiveadded(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1898 {
|
|
1899 int ret = 0;
|
|
1900 aim_rxcallback_t userfunc;
|
|
1901 fu16_t tmp;
|
|
1902 char *sn;
|
|
1903
|
|
1904 /* Read screen name */
|
|
1905 if ((tmp = aimbs_get8(bs)))
|
|
1906 sn = aimbs_getstr(bs, tmp);
|
|
1907 else
|
|
1908 sn = NULL;
|
|
1909
|
|
1910 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
|
1911 ret = userfunc(sess, rx, sn);
|
|
1912
|
|
1913 free(sn);
|
|
1914
|
|
1915 return ret;
|
|
1916 }
|
|
1917
|
2672
|
1918 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
1919 {
|
|
1920
|
3017
|
1921 if (snac->subtype == AIM_CB_SSI_RIGHTSINFO)
|
2672
|
1922 return parserights(sess, mod, rx, snac, bs);
|
3017
|
1923 else if (snac->subtype == AIM_CB_SSI_LIST)
|
2672
|
1924 return parsedata(sess, mod, rx, snac, bs);
|
4230
|
1925 else if (snac->subtype == AIM_CB_SSI_ADD)
|
|
1926 return parseadd(sess, mod, rx, snac, bs);
|
|
1927 else if (snac->subtype == AIM_CB_SSI_MOD)
|
|
1928 return parsemod(sess, mod, rx, snac, bs);
|
|
1929 else if (snac->subtype == AIM_CB_SSI_DEL)
|
|
1930 return parsedel(sess, mod, rx, snac, bs);
|
2991
|
1931 else if (snac->subtype == AIM_CB_SSI_SRVACK)
|
|
1932 return parseack(sess, mod, rx, snac, bs);
|
3017
|
1933 else if (snac->subtype == AIM_CB_SSI_NOLIST)
|
2672
|
1934 return parsedataunchanged(sess, mod, rx, snac, bs);
|
4230
|
1935 else if (snac->subtype == AIM_CB_SSI_RECVAUTH)
|
|
1936 return receiveauthgrant(sess, mod, rx, snac, bs);
|
|
1937 else if (snac->subtype == AIM_CB_SSI_RECVAUTHREQ)
|
|
1938 return receiveauthrequest(sess, mod, rx, snac, bs);
|
|
1939 else if (snac->subtype == AIM_CB_SSI_RECVAUTHREP)
|
|
1940 return receiveauthreply(sess, mod, rx, snac, bs);
|
|
1941 else if (snac->subtype == AIM_CB_SSI_ADDED)
|
|
1942 return receiveadded(sess, mod, rx, snac, bs);
|
2672
|
1943
|
|
1944 return 0;
|
|
1945 }
|
|
1946
|
2991
|
1947 static void ssi_shutdown(aim_session_t *sess, aim_module_t *mod)
|
|
1948 {
|
|
1949 aim_ssi_freelist(sess);
|
|
1950 }
|
|
1951
|
2672
|
1952 faim_internal int ssi_modfirst(aim_session_t *sess, aim_module_t *mod)
|
|
1953 {
|
|
1954
|
3017
|
1955 mod->family = AIM_CB_FAM_SSI;
|
4230
|
1956 mod->version = 0x0004;
|
2672
|
1957 mod->toolid = 0x0110;
|
4071
|
1958 mod->toolversion = 0x0629;
|
2672
|
1959 mod->flags = 0;
|
|
1960 strncpy(mod->name, "ssi", sizeof(mod->name));
|
|
1961 mod->snachandler = snachandler;
|
2991
|
1962 mod->shutdown = ssi_shutdown;
|
2672
|
1963
|
|
1964 return 0;
|
|
1965 }
|