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