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