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