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