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 */
|
13890
|
1092 int aim_ssi_seticon(OscarData *od, const 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))) {
|
13890
|
1102 tmp = aim_ssi_itemlist_add(&od->ssi.local, "1", 0x0000, 0xFFFF, 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));
|
13890
|
1107 aimutil_put16(&csumdata[0], iconsumlen);
|
13234
|
1108 memcpy(&csumdata[2], iconsum, iconsumlen);
|
|
1109 aim_tlvlist_replace_raw(&tmp->data, 0x00d5, (iconsumlen+2) * sizeof(guint8), csumdata);
|
|
1110 free(csumdata);
|
|
1111
|
|
1112 /* Need to add the 0x0131 TLV to the TLV chain, used to cache the icon */
|
|
1113 aim_tlvlist_replace_noval(&tmp->data, 0x0131);
|
|
1114
|
|
1115 /* Sync our local list with the server list */
|
13592
|
1116 aim_ssi_sync(od);
|
13234
|
1117 return 0;
|
|
1118 }
|
|
1119
|
|
1120 /**
|
13592
|
1121 * Remove a reference to a server stored buddy icon. This will make your
|
13234
|
1122 * icon stop showing up to other people.
|
|
1123 *
|
13890
|
1124 * Really this function just sets the icon to a dummy value. It's weird...
|
|
1125 * but I think the dummy value basically means "I don't have an icon!"
|
|
1126 *
|
|
1127 * @param od The oscar session.
|
13234
|
1128 * @return Return 0 if no errors, otherwise return the error number.
|
|
1129 */
|
13592
|
1130 int aim_ssi_delicon(OscarData *od)
|
13234
|
1131 {
|
13890
|
1132 const guint8 csumdata[] = {0x02, 0x01, 0xd2, 0x04, 0x72};
|
13234
|
1133
|
13890
|
1134 return aim_ssi_seticon(od, csumdata, 5);
|
13234
|
1135 }
|
|
1136
|
|
1137 /**
|
|
1138 * Stores your setting for various SSI settings. Whether you
|
|
1139 * should show up as idle or not, etc.
|
|
1140 *
|
13592
|
1141 * @param od The oscar odion.
|
13234
|
1142 * @param presence I think it's a bitmask, but I only know what one of the bits is:
|
|
1143 * 0x00000002 - Hide wireless?
|
|
1144 * 0x00000400 - Allow others to see your idle time
|
|
1145 * @return Return 0 if no errors, otherwise return the error number.
|
|
1146 */
|
13592
|
1147 int aim_ssi_setpresence(OscarData *od, guint32 presence) {
|
13234
|
1148 struct aim_ssi_item *tmp;
|
|
1149
|
13592
|
1150 if (!od)
|
13234
|
1151 return -EINVAL;
|
|
1152
|
|
1153 /* Find the PRESENCEPREFS item, or add it if it does not exist */
|
13592
|
1154 if (!(tmp = aim_ssi_itemlist_finditem(od->ssi.local, NULL, NULL, AIM_SSI_TYPE_PRESENCEPREFS)))
|
|
1155 tmp = aim_ssi_itemlist_add(&od->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PRESENCEPREFS, NULL);
|
13234
|
1156
|
|
1157 /* Need to add the x00c9 TLV to the TLV chain */
|
|
1158 aim_tlvlist_replace_32(&tmp->data, 0x00c9, presence);
|
|
1159
|
|
1160 /* Sync our local list with the server list */
|
13592
|
1161 aim_ssi_sync(od);
|
13234
|
1162
|
|
1163 return 0;
|
|
1164 }
|
|
1165
|
|
1166 /*
|
|
1167 * Subtype 0x0002 - Request SSI Rights.
|
|
1168 */
|
13592
|
1169 int aim_ssi_reqrights(OscarData *od)
|
13234
|
1170 {
|
13592
|
1171 FlapConnection *conn;
|
13234
|
1172
|
13592
|
1173 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)))
|
13234
|
1174 return -EINVAL;
|
|
1175
|
13609
|
1176 aim_genericreq_n_snacid(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_REQRIGHTS);
|
|
1177
|
|
1178 return 0;
|
13234
|
1179 }
|
|
1180
|
|
1181 /*
|
|
1182 * Subtype 0x0003 - SSI Rights Information.
|
|
1183 */
|
13592
|
1184 static int parserights(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1185 {
|
|
1186 int ret = 0, i;
|
|
1187 aim_rxcallback_t userfunc;
|
|
1188 aim_tlvlist_t *tlvlist;
|
|
1189 aim_tlv_t *tlv;
|
13239
|
1190 ByteStream bstream;
|
13234
|
1191 guint16 *maxitems;
|
|
1192
|
|
1193 /* This SNAC is made up of a bunch of TLVs */
|
|
1194 tlvlist = aim_tlvlist_read(bs);
|
|
1195
|
|
1196 /* TLV 0x0004 contains the maximum number of each item */
|
|
1197 if (!(tlv = aim_tlv_gettlv(tlvlist, 0x0004, 1))) {
|
|
1198 aim_tlvlist_free(&tlvlist);
|
|
1199 return 0;
|
|
1200 }
|
|
1201
|
13592
|
1202 byte_stream_init(&bstream, tlv->value, tlv->length);
|
13234
|
1203
|
13592
|
1204 maxitems = (guint16 *)malloc((tlv->length/2)*sizeof(guint16));
|
13234
|
1205
|
|
1206 for (i=0; i<(tlv->length/2); i++)
|
13592
|
1207 maxitems[i] = byte_stream_get16(&bstream);
|
13234
|
1208
|
13592
|
1209 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1210 ret = userfunc(od, conn, frame, tlv->length/2, maxitems);
|
13234
|
1211
|
|
1212 aim_tlvlist_free(&tlvlist);
|
|
1213 free(maxitems);
|
|
1214
|
|
1215 return ret;
|
|
1216 }
|
|
1217
|
|
1218 /*
|
13592
|
1219 * Subtype 0x0004 - Request SSI Data when you don't have a timestamp and
|
13234
|
1220 * revision number.
|
13592
|
1221 *
|
13234
|
1222 */
|
13592
|
1223 int aim_ssi_reqdata(OscarData *od)
|
13234
|
1224 {
|
13592
|
1225 FlapConnection *conn;
|
13234
|
1226
|
13592
|
1227 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)))
|
13234
|
1228 return -EINVAL;
|
|
1229
|
|
1230 /* Free any current data, just in case */
|
13592
|
1231 aim_ssi_freelist(od);
|
13234
|
1232
|
13609
|
1233 aim_genericreq_n_snacid(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_REQDATA);
|
|
1234
|
|
1235 return 0;
|
13234
|
1236 }
|
|
1237
|
|
1238 /*
|
13592
|
1239 * Subtype 0x0005 - Request SSI Data when you have a timestamp and revision
|
13234
|
1240 * number.
|
|
1241 *
|
|
1242 * The data will only be sent if it is newer than the posted local
|
|
1243 * timestamp and revision.
|
13592
|
1244 *
|
13234
|
1245 * Note that the client should never increment the revision, only the server.
|
13592
|
1246 *
|
13234
|
1247 */
|
13592
|
1248 int aim_ssi_reqifchanged(OscarData *od, time_t timestamp, guint16 numitems)
|
13234
|
1249 {
|
13592
|
1250 FlapConnection *conn;
|
|
1251 FlapFrame *frame;
|
13234
|
1252 aim_snacid_t snacid;
|
|
1253
|
13592
|
1254 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)))
|
13234
|
1255 return -EINVAL;
|
|
1256
|
13592
|
1257 frame = flap_frame_new(od, 0x02, 10+4+2);
|
13234
|
1258
|
13592
|
1259 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_REQIFCHANGED, 0x0000, NULL, 0);
|
13234
|
1260
|
13592
|
1261 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_REQIFCHANGED, 0x0000, snacid);
|
|
1262 byte_stream_put32(&frame->data, timestamp);
|
|
1263 byte_stream_put16(&frame->data, numitems);
|
13234
|
1264
|
13592
|
1265 flap_connection_send(conn, frame);
|
13234
|
1266
|
|
1267 /* Free any current data, just in case */
|
13592
|
1268 aim_ssi_freelist(od);
|
13234
|
1269
|
|
1270 return 0;
|
|
1271 }
|
|
1272
|
|
1273 /*
|
|
1274 * Subtype 0x0006 - SSI Data.
|
|
1275 */
|
13592
|
1276 static int parsedata(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1277 {
|
|
1278 int ret = 0;
|
|
1279 aim_rxcallback_t userfunc;
|
|
1280 guint8 fmtver; /* guess */
|
|
1281 guint16 namelen, gid, bid, type;
|
|
1282 char *name;
|
|
1283 aim_tlvlist_t *data;
|
|
1284
|
13592
|
1285 fmtver = byte_stream_get8(bs); /* Version of ssi data. Should be 0x00 */
|
|
1286 od->ssi.numitems += byte_stream_get16(bs); /* # of items in this SSI SNAC */
|
13234
|
1287
|
|
1288 /* Read in the list */
|
13592
|
1289 while (byte_stream_empty(bs) > 4) { /* last four bytes are timestamp */
|
|
1290 if ((namelen = byte_stream_get16(bs)))
|
|
1291 name = byte_stream_getstr(bs, namelen);
|
13234
|
1292 else
|
|
1293 name = NULL;
|
13592
|
1294 gid = byte_stream_get16(bs);
|
|
1295 bid = byte_stream_get16(bs);
|
|
1296 type = byte_stream_get16(bs);
|
|
1297 data = aim_tlvlist_readlen(bs, byte_stream_get16(bs));
|
|
1298 aim_ssi_itemlist_add(&od->ssi.official, name, gid, bid, type, data);
|
13234
|
1299 free(name);
|
|
1300 aim_tlvlist_free(&data);
|
|
1301 }
|
|
1302
|
|
1303 /* Read in the timestamp */
|
13592
|
1304 od->ssi.timestamp = byte_stream_get32(bs);
|
13234
|
1305
|
|
1306 if (!(snac->flags & 0x0001)) {
|
|
1307 /* Make a copy of the list */
|
|
1308 struct aim_ssi_item *cur;
|
13592
|
1309 for (cur=od->ssi.official; cur; cur=cur->next)
|
|
1310 aim_ssi_itemlist_add(&od->ssi.local, cur->name, cur->gid, cur->bid, cur->type, cur->data);
|
13234
|
1311
|
13592
|
1312 od->ssi.received_data = 1;
|
13234
|
1313
|
13592
|
1314 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
13662
|
1315 ret = userfunc(od, conn, frame, fmtver, od->ssi.numitems, od->ssi.timestamp);
|
13234
|
1316 }
|
|
1317
|
|
1318 return ret;
|
|
1319 }
|
|
1320
|
|
1321 /*
|
|
1322 * Subtype 0x0007 - SSI Activate Data.
|
|
1323 *
|
|
1324 * Should be sent after receiving 13/6 or 13/f to tell the server you
|
|
1325 * are ready to begin using the list. It will promptly give you the
|
|
1326 * presence information for everyone in your list and put your permit/deny
|
|
1327 * settings into effect.
|
13743
|
1328 *
|
13234
|
1329 */
|
13592
|
1330 int aim_ssi_enable(OscarData *od)
|
13234
|
1331 {
|
13592
|
1332 FlapConnection *conn;
|
13234
|
1333
|
13592
|
1334 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)))
|
13234
|
1335 return -EINVAL;
|
|
1336
|
13592
|
1337 return aim_genericreq_n(od, conn, SNAC_FAMILY_FEEDBAG, 0x0007);
|
13234
|
1338 }
|
|
1339
|
|
1340 /*
|
|
1341 * Subtype 0x0008/0x0009/0x000a - SSI Add/Mod/Del Item(s).
|
|
1342 *
|
13743
|
1343 * Sends the SNAC to add, modify, or delete items from the server-stored
|
13234
|
1344 * information. These 3 SNACs all have an identical structure. The only
|
|
1345 * difference is the subtype that is set for the SNAC.
|
13743
|
1346 *
|
13234
|
1347 */
|
13743
|
1348 static int aim_ssi_addmoddel(OscarData *od)
|
13234
|
1349 {
|
13592
|
1350 FlapConnection *conn;
|
|
1351 FlapFrame *frame;
|
13234
|
1352 aim_snacid_t snacid;
|
|
1353 int snaclen;
|
|
1354 struct aim_ssi_tmp *cur;
|
|
1355
|
13592
|
1356 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !od->ssi.pending || !od->ssi.pending->item)
|
13234
|
1357 return -EINVAL;
|
|
1358
|
|
1359 /* Calculate total SNAC size */
|
|
1360 snaclen = 10; /* For family, subtype, flags, and SNAC ID */
|
13592
|
1361 for (cur=od->ssi.pending; cur; cur=cur->next) {
|
13234
|
1362 snaclen += 10; /* For length, GID, BID, type, and length */
|
|
1363 if (cur->item->name)
|
|
1364 snaclen += strlen(cur->item->name);
|
|
1365 if (cur->item->data)
|
|
1366 snaclen += aim_tlvlist_size(&cur->item->data);
|
|
1367 }
|
|
1368
|
13592
|
1369 frame = flap_frame_new(od, 0x02, snaclen);
|
13234
|
1370
|
13592
|
1371 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, od->ssi.pending->action, 0x0000, NULL, 0);
|
|
1372 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, od->ssi.pending->action, 0x0000, snacid);
|
13234
|
1373
|
13592
|
1374 for (cur=od->ssi.pending; cur; cur=cur->next) {
|
|
1375 byte_stream_put16(&frame->data, cur->item->name ? strlen(cur->item->name) : 0);
|
13234
|
1376 if (cur->item->name)
|
13592
|
1377 byte_stream_putstr(&frame->data, cur->item->name);
|
|
1378 byte_stream_put16(&frame->data, cur->item->gid);
|
|
1379 byte_stream_put16(&frame->data, cur->item->bid);
|
|
1380 byte_stream_put16(&frame->data, cur->item->type);
|
|
1381 byte_stream_put16(&frame->data, cur->item->data ? aim_tlvlist_size(&cur->item->data) : 0);
|
13234
|
1382 if (cur->item->data)
|
13592
|
1383 aim_tlvlist_write(&frame->data, &cur->item->data);
|
13234
|
1384 }
|
|
1385
|
13592
|
1386 flap_connection_send(conn, frame);
|
13234
|
1387
|
|
1388 return 0;
|
|
1389 }
|
|
1390
|
|
1391 /*
|
|
1392 * Subtype 0x0008 - Incoming SSI add.
|
|
1393 *
|
13743
|
1394 * Sent by the server, for example, when someone is added to
|
13234
|
1395 * your "Recent Buddies" group.
|
|
1396 */
|
13592
|
1397 static int parseadd(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1398 {
|
|
1399 int ret = 0;
|
|
1400 aim_rxcallback_t userfunc;
|
|
1401 char *name;
|
|
1402 guint16 len, gid, bid, type;
|
|
1403 aim_tlvlist_t *data;
|
|
1404
|
13592
|
1405 while (byte_stream_empty(bs)) {
|
|
1406 if ((len = byte_stream_get16(bs)))
|
|
1407 name = byte_stream_getstr(bs, len);
|
13234
|
1408 else
|
|
1409 name = NULL;
|
13592
|
1410 gid = byte_stream_get16(bs);
|
|
1411 bid = byte_stream_get16(bs);
|
|
1412 type = byte_stream_get16(bs);
|
|
1413 if ((len = byte_stream_get16(bs)))
|
13234
|
1414 data = aim_tlvlist_readlen(bs, len);
|
|
1415 else
|
|
1416 data = NULL;
|
|
1417
|
13592
|
1418 aim_ssi_itemlist_add(&od->ssi.local, name, gid, bid, type, data);
|
|
1419 aim_ssi_itemlist_add(&od->ssi.official, name, gid, bid, type, data);
|
13234
|
1420 aim_tlvlist_free(&data);
|
|
1421
|
13592
|
1422 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1423 ret = userfunc(od, conn, frame, type, name);
|
13234
|
1424
|
|
1425 free(name);
|
|
1426 }
|
|
1427
|
|
1428 return ret;
|
|
1429 }
|
|
1430
|
|
1431 /*
|
|
1432 * Subtype 0x0009 - Incoming SSI mod.
|
|
1433 *
|
|
1434 * XXX - It would probably be good for the client to actually do something when it gets this.
|
|
1435 */
|
13592
|
1436 static int parsemod(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1437 {
|
|
1438 int ret = 0;
|
|
1439 aim_rxcallback_t userfunc;
|
|
1440 char *name;
|
|
1441 guint16 len, gid, bid, type;
|
|
1442 aim_tlvlist_t *data;
|
|
1443 struct aim_ssi_item *item;
|
|
1444
|
13592
|
1445 while (byte_stream_empty(bs)) {
|
|
1446 if ((len = byte_stream_get16(bs)))
|
|
1447 name = byte_stream_getstr(bs, len);
|
13234
|
1448 else
|
|
1449 name = NULL;
|
13592
|
1450 gid = byte_stream_get16(bs);
|
|
1451 bid = byte_stream_get16(bs);
|
|
1452 type = byte_stream_get16(bs);
|
|
1453 if ((len = byte_stream_get16(bs)))
|
13234
|
1454 data = aim_tlvlist_readlen(bs, len);
|
|
1455 else
|
|
1456 data = NULL;
|
|
1457
|
|
1458 /* Replace the 2 local items with the given one */
|
13592
|
1459 if ((item = aim_ssi_itemlist_find(od->ssi.local, gid, bid))) {
|
13234
|
1460 item->type = type;
|
|
1461 free(item->name);
|
|
1462 if (name) {
|
|
1463 item->name = (char *)malloc((strlen(name)+1)*sizeof(char));
|
|
1464 strcpy(item->name, name);
|
|
1465 } else
|
|
1466 item->name = NULL;
|
|
1467 aim_tlvlist_free(&item->data);
|
|
1468 item->data = aim_tlvlist_copy(data);
|
|
1469 }
|
|
1470
|
13592
|
1471 if ((item = aim_ssi_itemlist_find(od->ssi.official, gid, bid))) {
|
13234
|
1472 item->type = type;
|
|
1473 free(item->name);
|
|
1474 if (name) {
|
|
1475 item->name = (char *)malloc((strlen(name)+1)*sizeof(char));
|
|
1476 strcpy(item->name, name);
|
|
1477 } else
|
|
1478 item->name = NULL;
|
|
1479 aim_tlvlist_free(&item->data);
|
|
1480 item->data = aim_tlvlist_copy(data);
|
|
1481 }
|
|
1482
|
13592
|
1483 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1484 ret = userfunc(od, conn, frame);
|
13234
|
1485
|
|
1486 free(name);
|
|
1487 aim_tlvlist_free(&data);
|
|
1488 }
|
|
1489
|
|
1490 return ret;
|
|
1491 }
|
|
1492
|
|
1493 /*
|
|
1494 * Subtype 0x000a - Incoming SSI del.
|
|
1495 *
|
|
1496 * XXX - It would probably be good for the client to actually do something when it gets this.
|
|
1497 */
|
13592
|
1498 static int parsedel(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1499 {
|
|
1500 int ret = 0;
|
|
1501 aim_rxcallback_t userfunc;
|
|
1502 guint16 gid, bid;
|
|
1503 struct aim_ssi_item *del;
|
|
1504
|
13592
|
1505 while (byte_stream_empty(bs)) {
|
|
1506 byte_stream_advance(bs, byte_stream_get16(bs));
|
|
1507 gid = byte_stream_get16(bs);
|
|
1508 bid = byte_stream_get16(bs);
|
|
1509 byte_stream_get16(bs);
|
|
1510 byte_stream_advance(bs, byte_stream_get16(bs));
|
13234
|
1511
|
13592
|
1512 if ((del = aim_ssi_itemlist_find(od->ssi.local, gid, bid)))
|
|
1513 aim_ssi_itemlist_del(&od->ssi.local, del);
|
|
1514 if ((del = aim_ssi_itemlist_find(od->ssi.official, gid, bid)))
|
|
1515 aim_ssi_itemlist_del(&od->ssi.official, del);
|
13234
|
1516
|
13592
|
1517 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1518 ret = userfunc(od, conn, frame);
|
13234
|
1519 }
|
|
1520
|
|
1521 return ret;
|
|
1522 }
|
|
1523
|
|
1524 /*
|
|
1525 * Subtype 0x000e - SSI Add/Mod/Del Ack.
|
|
1526 *
|
|
1527 * Response to add, modify, or delete SNAC (sent with aim_ssi_addmoddel).
|
|
1528 *
|
|
1529 */
|
13592
|
1530 static int parseack(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1531 {
|
|
1532 int ret = 0;
|
|
1533 aim_rxcallback_t userfunc;
|
|
1534 struct aim_ssi_tmp *cur, *del;
|
|
1535
|
|
1536 /* Read in the success/failure flags from the ack SNAC */
|
13592
|
1537 cur = od->ssi.pending;
|
|
1538 while (cur && (byte_stream_empty(bs)>0)) {
|
|
1539 cur->ack = byte_stream_get16(bs);
|
13234
|
1540 cur = cur->next;
|
|
1541 }
|
|
1542
|
|
1543 /*
|
13592
|
1544 * If outcome is 0, then add the item to the item list, or replace the other item,
|
|
1545 * or remove the old item. If outcome is non-zero, then remove the item from the
|
13234
|
1546 * local list, or unmodify it, or add it.
|
|
1547 */
|
13592
|
1548 for (cur=od->ssi.pending; (cur && (cur->ack != 0xffff)); cur=cur->next) {
|
13234
|
1549 if (cur->item) {
|
|
1550 if (cur->ack) {
|
|
1551 /* Our action was unsuccessful, so change the local list back to how it was */
|
13592
|
1552 if (cur->action == SNAC_SUBTYPE_FEEDBAG_ADD) {
|
13234
|
1553 /* Remove the item from the local list */
|
|
1554 /* Make sure cur->item is still valid memory */
|
13592
|
1555 if (aim_ssi_itemlist_valid(od->ssi.local, cur->item)) {
|
13234
|
1556 if (cur->item->name) {
|
|
1557 cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
|
|
1558 strcpy(cur->name, cur->item->name);
|
|
1559 }
|
13592
|
1560 aim_ssi_itemlist_del(&od->ssi.local, cur->item);
|
13234
|
1561 }
|
|
1562 cur->item = NULL;
|
|
1563
|
13592
|
1564 } else if (cur->action == SNAC_SUBTYPE_FEEDBAG_MOD) {
|
13234
|
1565 /* Replace the local item with the item from the official list */
|
13592
|
1566 if (aim_ssi_itemlist_valid(od->ssi.local, cur->item)) {
|
13234
|
1567 struct aim_ssi_item *cur1;
|
13592
|
1568 if ((cur1 = aim_ssi_itemlist_find(od->ssi.official, cur->item->gid, cur->item->bid))) {
|
13234
|
1569 free(cur->item->name);
|
|
1570 if (cur1->name) {
|
|
1571 cur->item->name = (char *)malloc((strlen(cur1->name)+1)*sizeof(char));
|
|
1572 strcpy(cur->item->name, cur1->name);
|
|
1573 } else
|
|
1574 cur->item->name = NULL;
|
|
1575 aim_tlvlist_free(&cur->item->data);
|
|
1576 cur->item->data = aim_tlvlist_copy(cur1->data);
|
|
1577 }
|
|
1578 } else
|
|
1579 cur->item = NULL;
|
|
1580
|
13592
|
1581 } else if (cur->action == SNAC_SUBTYPE_FEEDBAG_DEL) {
|
13234
|
1582 /* Add the item back into the local list */
|
13592
|
1583 if (aim_ssi_itemlist_valid(od->ssi.official, cur->item)) {
|
|
1584 aim_ssi_itemlist_add(&od->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
|
13234
|
1585 } else
|
|
1586 cur->item = NULL;
|
|
1587 }
|
|
1588
|
|
1589 } else {
|
|
1590 /* Do the exact opposite */
|
13592
|
1591 if (cur->action == SNAC_SUBTYPE_FEEDBAG_ADD) {
|
13234
|
1592 /* Add the local item to the official list */
|
13592
|
1593 if (aim_ssi_itemlist_valid(od->ssi.local, cur->item)) {
|
|
1594 aim_ssi_itemlist_add(&od->ssi.official, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
|
13234
|
1595 } else
|
|
1596 cur->item = NULL;
|
|
1597
|
13592
|
1598 } else if (cur->action == SNAC_SUBTYPE_FEEDBAG_MOD) {
|
13234
|
1599 /* Replace the official item with the item from the local list */
|
13592
|
1600 if (aim_ssi_itemlist_valid(od->ssi.local, cur->item)) {
|
13234
|
1601 struct aim_ssi_item *cur1;
|
13592
|
1602 if ((cur1 = aim_ssi_itemlist_find(od->ssi.official, cur->item->gid, cur->item->bid))) {
|
13234
|
1603 free(cur1->name);
|
|
1604 if (cur->item->name) {
|
|
1605 cur1->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
|
|
1606 strcpy(cur1->name, cur->item->name);
|
|
1607 } else
|
|
1608 cur1->name = NULL;
|
|
1609 aim_tlvlist_free(&cur1->data);
|
|
1610 cur1->data = aim_tlvlist_copy(cur->item->data);
|
|
1611 }
|
|
1612 } else
|
|
1613 cur->item = NULL;
|
|
1614
|
13592
|
1615 } else if (cur->action == SNAC_SUBTYPE_FEEDBAG_DEL) {
|
13234
|
1616 /* Remove the item from the official list */
|
13592
|
1617 if (aim_ssi_itemlist_valid(od->ssi.official, cur->item))
|
|
1618 aim_ssi_itemlist_del(&od->ssi.official, cur->item);
|
13234
|
1619 cur->item = NULL;
|
|
1620 }
|
|
1621
|
|
1622 }
|
|
1623 } /* End if (cur->item) */
|
|
1624 } /* End for loop */
|
|
1625
|
13592
|
1626 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1627 ret = userfunc(od, conn, frame, od->ssi.pending);
|
13234
|
1628
|
|
1629 /* Free all aim_ssi_tmp's with an outcome */
|
13592
|
1630 cur = od->ssi.pending;
|
13234
|
1631 while (cur && (cur->ack != 0xffff)) {
|
|
1632 del = cur;
|
|
1633 cur = cur->next;
|
|
1634 free(del->name);
|
|
1635 free(del);
|
|
1636 }
|
13592
|
1637 od->ssi.pending = cur;
|
13234
|
1638
|
|
1639 /* If we're not waiting for any more acks, then send more SNACs */
|
13592
|
1640 if (!od->ssi.pending) {
|
|
1641 od->ssi.pending = NULL;
|
|
1642 od->ssi.waiting_for_ack = 0;
|
|
1643 aim_ssi_sync(od);
|
13234
|
1644 }
|
|
1645
|
|
1646 return ret;
|
|
1647 }
|
|
1648
|
|
1649 /*
|
|
1650 * Subtype 0x000f - SSI Data Unchanged.
|
|
1651 *
|
|
1652 * Response to aim_ssi_reqifchanged() if the server-side data is not newer than
|
|
1653 * posted local stamp/revision.
|
|
1654 *
|
|
1655 */
|
13592
|
1656 static int parsedataunchanged(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1657 {
|
|
1658 int ret = 0;
|
|
1659 aim_rxcallback_t userfunc;
|
|
1660
|
13592
|
1661 od->ssi.received_data = 1;
|
13234
|
1662
|
13592
|
1663 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1664 ret = userfunc(od, conn, frame);
|
13234
|
1665
|
|
1666 return ret;
|
|
1667 }
|
|
1668
|
|
1669 /*
|
|
1670 * Subtype 0x0011 - SSI Begin Data Modification.
|
|
1671 *
|
13592
|
1672 * Tell the server you're going to start modifying data.
|
13234
|
1673 */
|
13592
|
1674 int aim_ssi_modbegin(OscarData *od)
|
13234
|
1675 {
|
13592
|
1676 FlapConnection *conn;
|
13234
|
1677
|
13592
|
1678 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)))
|
13234
|
1679 return -EINVAL;
|
|
1680
|
13592
|
1681 return aim_genericreq_n(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_EDITSTART);
|
13234
|
1682 }
|
|
1683
|
|
1684 /*
|
|
1685 * Subtype 0x0012 - SSI End Data Modification.
|
|
1686 *
|
13592
|
1687 * Tell the server you're finished modifying data.
|
13234
|
1688 *
|
|
1689 */
|
13592
|
1690 int aim_ssi_modend(OscarData *od)
|
13234
|
1691 {
|
13592
|
1692 FlapConnection *conn;
|
13234
|
1693
|
13592
|
1694 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)))
|
13234
|
1695 return -EINVAL;
|
|
1696
|
13592
|
1697 return aim_genericreq_n(od, conn, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_EDITSTOP);
|
13234
|
1698 }
|
|
1699
|
|
1700 /*
|
|
1701 * Subtype 0x0014 - Grant authorization
|
|
1702 *
|
|
1703 * Authorizes a contact so they can add you to their contact list.
|
|
1704 *
|
|
1705 */
|
13592
|
1706 int aim_ssi_sendauth(OscarData *od, char *sn, char *msg)
|
13234
|
1707 {
|
13592
|
1708 FlapConnection *conn;
|
|
1709 FlapFrame *frame;
|
13234
|
1710 aim_snacid_t snacid;
|
|
1711
|
13592
|
1712 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn)
|
13234
|
1713 return -EINVAL;
|
|
1714
|
13592
|
1715 frame = flap_frame_new(od, 0x02, 10+1+strlen(sn)+2+(msg ? strlen(msg)+1 : 0)+2);
|
13234
|
1716
|
13592
|
1717 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTH, 0x0000, NULL, 0);
|
|
1718 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTH, 0x0000, snacid);
|
13234
|
1719
|
|
1720 /* Screen name */
|
13592
|
1721 byte_stream_put8(&frame->data, strlen(sn));
|
|
1722 byte_stream_putstr(&frame->data, sn);
|
13234
|
1723
|
|
1724 /* Message (null terminated) */
|
13592
|
1725 byte_stream_put16(&frame->data, msg ? strlen(msg) : 0);
|
13234
|
1726 if (msg) {
|
13592
|
1727 byte_stream_putstr(&frame->data, msg);
|
|
1728 byte_stream_put8(&frame->data, 0x00);
|
13234
|
1729 }
|
|
1730
|
|
1731 /* Unknown */
|
13592
|
1732 byte_stream_put16(&frame->data, 0x0000);
|
13234
|
1733
|
13592
|
1734 flap_connection_send(conn, frame);
|
13234
|
1735
|
|
1736 return 0;
|
|
1737 }
|
|
1738
|
|
1739 /*
|
|
1740 * Subtype 0x0015 - Receive an authorization grant
|
|
1741 */
|
13592
|
1742 static int receiveauthgrant(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1743 {
|
|
1744 int ret = 0;
|
|
1745 aim_rxcallback_t userfunc;
|
|
1746 guint16 tmp;
|
|
1747 char *sn, *msg;
|
|
1748
|
|
1749 /* Read screen name */
|
13592
|
1750 if ((tmp = byte_stream_get8(bs)))
|
|
1751 sn = byte_stream_getstr(bs, tmp);
|
13234
|
1752 else
|
|
1753 sn = NULL;
|
|
1754
|
|
1755 /* Read message (null terminated) */
|
13592
|
1756 if ((tmp = byte_stream_get16(bs)))
|
|
1757 msg = byte_stream_getstr(bs, tmp);
|
13234
|
1758 else
|
|
1759 msg = NULL;
|
|
1760
|
|
1761 /* Unknown */
|
13592
|
1762 tmp = byte_stream_get16(bs);
|
13234
|
1763
|
13592
|
1764 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1765 ret = userfunc(od, conn, frame, sn, msg);
|
13234
|
1766
|
|
1767 free(sn);
|
|
1768 free(msg);
|
|
1769
|
|
1770 return ret;
|
|
1771 }
|
|
1772
|
|
1773 /*
|
|
1774 * Subtype 0x0018 - Send authorization request
|
|
1775 *
|
|
1776 * Sends a request for authorization to the given contact. The request will either be
|
|
1777 * granted, denied, or dropped.
|
|
1778 *
|
|
1779 */
|
13592
|
1780 int aim_ssi_sendauthrequest(OscarData *od, char *sn, const char *msg)
|
13234
|
1781 {
|
13592
|
1782 FlapConnection *conn;
|
|
1783 FlapFrame *frame;
|
13234
|
1784 aim_snacid_t snacid;
|
|
1785
|
13592
|
1786 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn)
|
13234
|
1787 return -EINVAL;
|
|
1788
|
13592
|
1789 frame = flap_frame_new(od, 0x02, 10+1+strlen(sn)+2+(msg ? strlen(msg)+1 : 0)+2);
|
13234
|
1790
|
13592
|
1791 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREQ, 0x0000, NULL, 0);
|
|
1792 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREQ, 0x0000, snacid);
|
13234
|
1793
|
|
1794 /* Screen name */
|
13592
|
1795 byte_stream_put8(&frame->data, strlen(sn));
|
|
1796 byte_stream_putstr(&frame->data, sn);
|
13234
|
1797
|
|
1798 /* Message (null terminated) */
|
13592
|
1799 byte_stream_put16(&frame->data, msg ? strlen(msg) : 0);
|
13234
|
1800 if (msg) {
|
13592
|
1801 byte_stream_putstr(&frame->data, msg);
|
|
1802 byte_stream_put8(&frame->data, 0x00);
|
13234
|
1803 }
|
|
1804
|
|
1805 /* Unknown */
|
13592
|
1806 byte_stream_put16(&frame->data, 0x0000);
|
13234
|
1807
|
13592
|
1808 flap_connection_send(conn, frame);
|
13234
|
1809
|
|
1810 return 0;
|
|
1811 }
|
|
1812
|
|
1813 /*
|
|
1814 * Subtype 0x0019 - Receive an authorization request
|
|
1815 */
|
13592
|
1816 static int receiveauthrequest(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1817 {
|
|
1818 int ret = 0;
|
|
1819 aim_rxcallback_t userfunc;
|
|
1820 guint16 tmp;
|
|
1821 char *sn, *msg;
|
|
1822
|
|
1823 /* Read screen name */
|
13592
|
1824 if ((tmp = byte_stream_get8(bs)))
|
|
1825 sn = byte_stream_getstr(bs, tmp);
|
13234
|
1826 else
|
|
1827 sn = NULL;
|
|
1828
|
|
1829 /* Read message (null terminated) */
|
13592
|
1830 if ((tmp = byte_stream_get16(bs)))
|
|
1831 msg = byte_stream_getstr(bs, tmp);
|
13234
|
1832 else
|
|
1833 msg = NULL;
|
|
1834
|
|
1835 /* Unknown */
|
13592
|
1836 tmp = byte_stream_get16(bs);
|
13234
|
1837
|
13592
|
1838 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1839 ret = userfunc(od, conn, frame, sn, msg);
|
13234
|
1840
|
|
1841 free(sn);
|
|
1842 free(msg);
|
|
1843
|
|
1844 return ret;
|
|
1845 }
|
|
1846
|
|
1847 /*
|
|
1848 * Subtype 0x001a - Send authorization reply
|
|
1849 *
|
|
1850 * Sends a reply to a request for authorization. The reply can either
|
|
1851 * grant authorization or deny authorization.
|
|
1852 *
|
|
1853 * if reply=0x00 then deny
|
|
1854 * if reply=0x01 then grant
|
|
1855 *
|
|
1856 */
|
13592
|
1857 int aim_ssi_sendauthreply(OscarData *od, char *sn, guint8 reply, const char *msg)
|
13234
|
1858 {
|
13592
|
1859 FlapConnection *conn;
|
|
1860 FlapFrame *frame;
|
13234
|
1861 aim_snacid_t snacid;
|
|
1862
|
13592
|
1863 if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_FEEDBAG)) || !sn)
|
13234
|
1864 return -EINVAL;
|
|
1865
|
13592
|
1866 frame = flap_frame_new(od, 0x02, 10 + 1+strlen(sn) + 1 + 2+(msg ? strlen(msg)+1 : 0) + 2);
|
13234
|
1867
|
13592
|
1868 snacid = aim_cachesnac(od, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREP, 0x0000, NULL, 0);
|
|
1869 aim_putsnac(&frame->data, SNAC_FAMILY_FEEDBAG, SNAC_SUBTYPE_FEEDBAG_SENDAUTHREP, 0x0000, snacid);
|
13234
|
1870
|
|
1871 /* Screen name */
|
13592
|
1872 byte_stream_put8(&frame->data, strlen(sn));
|
|
1873 byte_stream_putstr(&frame->data, sn);
|
13234
|
1874
|
|
1875 /* Grant or deny */
|
13592
|
1876 byte_stream_put8(&frame->data, reply);
|
13234
|
1877
|
|
1878 /* Message (null terminated) */
|
13592
|
1879 byte_stream_put16(&frame->data, msg ? (strlen(msg)+1) : 0);
|
13234
|
1880 if (msg) {
|
13592
|
1881 byte_stream_putstr(&frame->data, msg);
|
|
1882 byte_stream_put8(&frame->data, 0x00);
|
13234
|
1883 }
|
|
1884
|
|
1885 /* Unknown */
|
13592
|
1886 byte_stream_put16(&frame->data, 0x0000);
|
13234
|
1887
|
13592
|
1888 flap_connection_send(conn, frame);
|
13234
|
1889
|
|
1890 return 0;
|
|
1891 }
|
|
1892
|
|
1893 /*
|
|
1894 * Subtype 0x001b - Receive an authorization reply
|
|
1895 * You get this bad boy when other people respond to the authorization
|
|
1896 * request that you have previously sent them.
|
|
1897 */
|
13592
|
1898 static int receiveauthreply(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1899 {
|
|
1900 int ret = 0;
|
|
1901 aim_rxcallback_t userfunc;
|
|
1902 guint16 tmp;
|
|
1903 guint8 reply;
|
|
1904 char *sn, *msg;
|
|
1905
|
|
1906 /* Read screen name */
|
13592
|
1907 if ((tmp = byte_stream_get8(bs)))
|
|
1908 sn = byte_stream_getstr(bs, tmp);
|
13234
|
1909 else
|
|
1910 sn = NULL;
|
|
1911
|
|
1912 /* Read reply */
|
13592
|
1913 reply = byte_stream_get8(bs);
|
13234
|
1914
|
|
1915 /* Read message (null terminated) */
|
13592
|
1916 if ((tmp = byte_stream_get16(bs)))
|
|
1917 msg = byte_stream_getstr(bs, tmp);
|
13234
|
1918 else
|
|
1919 msg = NULL;
|
|
1920
|
|
1921 /* Unknown */
|
13592
|
1922 tmp = byte_stream_get16(bs);
|
13234
|
1923
|
13592
|
1924 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1925 ret = userfunc(od, conn, frame, sn, reply, msg);
|
13234
|
1926
|
|
1927 free(sn);
|
|
1928 free(msg);
|
|
1929
|
|
1930 return ret;
|
|
1931 }
|
|
1932
|
|
1933 /*
|
|
1934 * Subtype 0x001c - Receive a message telling you someone added you to their list.
|
|
1935 */
|
13592
|
1936 static int receiveadded(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1937 {
|
|
1938 int ret = 0;
|
|
1939 aim_rxcallback_t userfunc;
|
|
1940 guint16 tmp;
|
|
1941 char *sn;
|
|
1942
|
|
1943 /* Read screen name */
|
13592
|
1944 if ((tmp = byte_stream_get8(bs)))
|
|
1945 sn = byte_stream_getstr(bs, tmp);
|
13234
|
1946 else
|
|
1947 sn = NULL;
|
|
1948
|
13592
|
1949 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
1950 ret = userfunc(od, conn, frame, sn);
|
13234
|
1951
|
|
1952 free(sn);
|
|
1953
|
|
1954 return ret;
|
|
1955 }
|
|
1956
|
13592
|
1957 static int
|
|
1958 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
1959 {
|
13592
|
1960 if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_RIGHTSINFO)
|
|
1961 return parserights(od, conn, mod, frame, snac, bs);
|
|
1962 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_LIST)
|
|
1963 return parsedata(od, conn, mod, frame, snac, bs);
|
|
1964 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_ADD)
|
|
1965 return parseadd(od, conn, mod, frame, snac, bs);
|
|
1966 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_MOD)
|
|
1967 return parsemod(od, conn, mod, frame, snac, bs);
|
|
1968 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_DEL)
|
|
1969 return parsedel(od, conn, mod, frame, snac, bs);
|
|
1970 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_SRVACK)
|
|
1971 return parseack(od, conn, mod, frame, snac, bs);
|
|
1972 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_NOLIST)
|
|
1973 return parsedataunchanged(od, conn, mod, frame, snac, bs);
|
|
1974 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_RECVAUTH)
|
|
1975 return receiveauthgrant(od, conn, mod, frame, snac, bs);
|
|
1976 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_RECVAUTHREQ)
|
|
1977 return receiveauthrequest(od, conn, mod, frame, snac, bs);
|
|
1978 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_RECVAUTHREP)
|
|
1979 return receiveauthreply(od, conn, mod, frame, snac, bs);
|
|
1980 else if (snac->subtype == SNAC_SUBTYPE_FEEDBAG_ADDED)
|
|
1981 return receiveadded(od, conn, mod, frame, snac, bs);
|
13234
|
1982
|
|
1983 return 0;
|
|
1984 }
|
|
1985
|
13592
|
1986 static void
|
|
1987 ssi_shutdown(OscarData *od, aim_module_t *mod)
|
13234
|
1988 {
|
13592
|
1989 aim_ssi_freelist(od);
|
13234
|
1990 }
|
|
1991
|
13592
|
1992 int
|
|
1993 ssi_modfirst(OscarData *od, aim_module_t *mod)
|
13234
|
1994 {
|
13592
|
1995 mod->family = SNAC_FAMILY_FEEDBAG;
|
13234
|
1996 mod->version = 0x0004;
|
|
1997 mod->toolid = 0x0110;
|
|
1998 mod->toolversion = 0x0629;
|
|
1999 mod->flags = 0;
|
|
2000 strncpy(mod->name, "feedbag", sizeof(mod->name));
|
|
2001 mod->snachandler = snachandler;
|
|
2002 mod->shutdown = ssi_shutdown;
|
|
2003
|
|
2004 return 0;
|
|
2005 }
|