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