annotate src/protocols/oscar/family_feedbag.c @ 13609:5796551db930

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