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