annotate src/protocols/oscar/ssi.c @ 13216:0ce20e0a1396

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