annotate src/protocols/oscar/ssi.c @ 5297:d4c9c5491812

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