Mercurial > pidgin.yaz
annotate libgaim/privacy.c @ 15363:6945eb35fba5
[gaim-migrate @ 18155]
newsination
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Thu, 18 Jan 2007 13:30:17 +0000 |
parents | b17a907065cc |
children |
rev | line source |
---|---|
14192 | 1 /** |
2 * gaim | |
3 * | |
4 * Gaim is the legal property of its developers, whose names are too numerous | |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 */ | |
22 #include "internal.h" | |
23 | |
24 #include "account.h" | |
25 #include "privacy.h" | |
26 #include "server.h" | |
27 #include "util.h" | |
28 | |
29 static GaimPrivacyUiOps *privacy_ops = NULL; | |
30 | |
31 gboolean | |
32 gaim_privacy_permit_add(GaimAccount *account, const char *who, | |
33 gboolean local_only) | |
34 { | |
35 GSList *l; | |
36 char *name; | |
37 GaimBuddy *buddy; | |
38 | |
39 g_return_val_if_fail(account != NULL, FALSE); | |
40 g_return_val_if_fail(who != NULL, FALSE); | |
41 | |
42 name = g_strdup(gaim_normalize(account, who)); | |
43 | |
44 for (l = account->permit; l != NULL; l = l->next) { | |
45 if (!gaim_utf8_strcasecmp(name, (char *)l->data)) | |
46 break; | |
47 } | |
48 | |
14607 | 49 if (l != NULL) |
14192 | 50 { |
51 g_free(name); | |
14607 | 52 return FALSE; |
14192 | 53 } |
54 | |
55 account->permit = g_slist_append(account->permit, name); | |
56 | |
57 if (!local_only && gaim_account_is_connected(account)) | |
58 serv_add_permit(gaim_account_get_connection(account), who); | |
59 | |
60 if (privacy_ops != NULL && privacy_ops->permit_added != NULL) | |
61 privacy_ops->permit_added(account, who); | |
62 | |
63 gaim_blist_schedule_save(); | |
64 | |
65 /* This lets the UI know a buddy has had its privacy setting changed */ | |
66 buddy = gaim_find_buddy(account, name); | |
67 if (buddy != NULL) { | |
68 gaim_signal_emit(gaim_blist_get_handle(), | |
69 "buddy-privacy-changed", buddy); | |
70 } | |
71 return TRUE; | |
72 } | |
73 | |
74 gboolean | |
75 gaim_privacy_permit_remove(GaimAccount *account, const char *who, | |
76 gboolean local_only) | |
77 { | |
78 GSList *l; | |
14212 | 79 const char *name; |
14192 | 80 GaimBuddy *buddy; |
15319
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
81 char *del; |
14192 | 82 |
83 g_return_val_if_fail(account != NULL, FALSE); | |
84 g_return_val_if_fail(who != NULL, FALSE); | |
85 | |
86 name = gaim_normalize(account, who); | |
87 | |
88 for (l = account->permit; l != NULL; l = l->next) { | |
89 if (!gaim_utf8_strcasecmp(name, (char *)l->data)) | |
90 break; | |
91 } | |
92 | |
93 if (l == NULL) | |
94 return FALSE; | |
95 | |
15319
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
96 /* We should not free l->data just yet. There can be occasions where |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
97 * l->data == who. In such cases, freeing l->data here can cause crashes |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
98 * later when who is used. */ |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
99 del = l->data; |
14192 | 100 account->permit = g_slist_delete_link(account->permit, l); |
101 | |
102 if (!local_only && gaim_account_is_connected(account)) | |
103 serv_rem_permit(gaim_account_get_connection(account), who); | |
104 | |
105 if (privacy_ops != NULL && privacy_ops->permit_removed != NULL) | |
106 privacy_ops->permit_removed(account, who); | |
107 | |
108 gaim_blist_schedule_save(); | |
109 | |
110 buddy = gaim_find_buddy(account, name); | |
111 if (buddy != NULL) { | |
112 gaim_signal_emit(gaim_blist_get_handle(), | |
113 "buddy-privacy-changed", buddy); | |
114 } | |
15319
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
115 g_free(del); |
14192 | 116 return TRUE; |
117 } | |
118 | |
119 gboolean | |
120 gaim_privacy_deny_add(GaimAccount *account, const char *who, | |
121 gboolean local_only) | |
122 { | |
123 GSList *l; | |
124 char *name; | |
125 GaimBuddy *buddy; | |
126 | |
127 g_return_val_if_fail(account != NULL, FALSE); | |
128 g_return_val_if_fail(who != NULL, FALSE); | |
129 | |
130 name = g_strdup(gaim_normalize(account, who)); | |
131 | |
132 for (l = account->deny; l != NULL; l = l->next) { | |
133 if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data))) | |
134 break; | |
135 } | |
136 | |
137 if (l != NULL) | |
138 { | |
139 g_free(name); | |
140 return FALSE; | |
141 } | |
142 | |
143 account->deny = g_slist_append(account->deny, name); | |
144 | |
145 if (!local_only && gaim_account_is_connected(account)) | |
146 serv_add_deny(gaim_account_get_connection(account), who); | |
147 | |
148 if (privacy_ops != NULL && privacy_ops->deny_added != NULL) | |
149 privacy_ops->deny_added(account, who); | |
150 | |
151 gaim_blist_schedule_save(); | |
152 | |
153 buddy = gaim_find_buddy(account, name); | |
154 if (buddy != NULL) { | |
155 gaim_signal_emit(gaim_blist_get_handle(), | |
156 "buddy-privacy-changed", buddy); | |
157 } | |
158 return TRUE; | |
159 } | |
160 | |
161 gboolean | |
162 gaim_privacy_deny_remove(GaimAccount *account, const char *who, | |
163 gboolean local_only) | |
164 { | |
165 GSList *l; | |
14212 | 166 const char *normalized; |
14192 | 167 char *name; |
168 GaimBuddy *buddy; | |
169 | |
170 g_return_val_if_fail(account != NULL, FALSE); | |
171 g_return_val_if_fail(who != NULL, FALSE); | |
172 | |
14212 | 173 normalized = gaim_normalize(account, who); |
14192 | 174 |
175 for (l = account->deny; l != NULL; l = l->next) { | |
14212 | 176 if (!gaim_utf8_strcasecmp(normalized, (char *)l->data)) |
14192 | 177 break; |
178 } | |
179 | |
14212 | 180 buddy = gaim_find_buddy(account, normalized); |
14192 | 181 |
182 if (l == NULL) | |
183 return FALSE; | |
184 | |
185 name = l->data; | |
186 account->deny = g_slist_delete_link(account->deny, l); | |
187 | |
188 if (!local_only && gaim_account_is_connected(account)) | |
189 serv_rem_deny(gaim_account_get_connection(account), name); | |
190 | |
191 if (privacy_ops != NULL && privacy_ops->deny_removed != NULL) | |
192 privacy_ops->deny_removed(account, who); | |
193 | |
194 if (buddy != NULL) { | |
195 gaim_signal_emit(gaim_blist_get_handle(), | |
196 "buddy-privacy-changed", buddy); | |
197 } | |
198 | |
199 g_free(name); | |
200 gaim_blist_schedule_save(); | |
201 | |
202 return TRUE; | |
203 } | |
204 | |
15319
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
205 /* This makes sure that only all the buddies are in the permit list. */ |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
206 static void |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
207 add_buddies_in_permit(GaimAccount *account, gboolean local) |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
208 { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
209 GSList *list, *iter; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
210 /* Remove anyone in the permit list who is not in the buddylist */ |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
211 for (list = account->permit; list != NULL; ) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
212 char *person = list->data; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
213 list = list->next; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
214 if (!gaim_find_buddy(account, person)) |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
215 gaim_privacy_permit_remove(account, person, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
216 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
217 /* Now make sure everyone in the buddylist is in the permit list */ |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
218 for (iter = list = gaim_find_buddies(account, NULL); iter; iter = iter->next) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
219 GaimBuddy *buddy = iter->data; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
220 if (!g_slist_find_custom(account->permit, buddy->name, (GCompareFunc)g_utf8_collate)) |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
221 gaim_privacy_permit_add(account, buddy->name, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
222 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
223 g_slist_free(list); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
224 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
225 |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
226 void |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
227 gaim_privacy_allow(GaimAccount *account, const char *who, gboolean local, |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
228 gboolean restore) |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
229 { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
230 GSList *list; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
231 |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
232 switch (account->perm_deny) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
233 case GAIM_PRIVACY_ALLOW_ALL: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
234 return; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
235 case GAIM_PRIVACY_ALLOW_USERS: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
236 gaim_privacy_permit_add(account, who, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
237 break; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
238 case GAIM_PRIVACY_DENY_USERS: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
239 gaim_privacy_deny_remove(account, who, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
240 break; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
241 case GAIM_PRIVACY_DENY_ALL: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
242 if (!restore) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
243 /* Empty the allow-list. */ |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
244 for (list = account->permit; list != NULL;) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
245 char *who = list->data; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
246 list = list->next; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
247 gaim_privacy_permit_remove(account, who, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
248 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
249 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
250 gaim_privacy_permit_add(account, who, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
251 account->perm_deny = GAIM_PRIVACY_ALLOW_USERS; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
252 break; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
253 case GAIM_PRIVACY_ALLOW_BUDDYLIST: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
254 if (!gaim_find_buddy(account, who)) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
255 add_buddies_in_permit(account, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
256 gaim_privacy_permit_add(account, who, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
257 account->perm_deny = GAIM_PRIVACY_ALLOW_USERS; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
258 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
259 break; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
260 default: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
261 g_return_if_reached(); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
262 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
263 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
264 |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
265 void |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
266 gaim_privacy_deny(GaimAccount *account, const char *who, gboolean local, |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
267 gboolean restore) |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
268 { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
269 GSList *list; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
270 |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
271 switch (account->perm_deny) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
272 case GAIM_PRIVACY_ALLOW_ALL: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
273 if (!restore) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
274 /* Empty the deny-list. */ |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
275 for (list = account->deny; list != NULL; ) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
276 char *person = list->data; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
277 list = list->next; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
278 gaim_privacy_deny_remove(account, person, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
279 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
280 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
281 gaim_privacy_deny_add(account, who, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
282 account->perm_deny = GAIM_PRIVACY_DENY_USERS; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
283 break; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
284 case GAIM_PRIVACY_ALLOW_USERS: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
285 gaim_privacy_permit_remove(account, who, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
286 break; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
287 case GAIM_PRIVACY_DENY_USERS: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
288 gaim_privacy_deny_add(account, who, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
289 break; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
290 case GAIM_PRIVACY_DENY_ALL: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
291 break; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
292 case GAIM_PRIVACY_ALLOW_BUDDYLIST: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
293 if (gaim_find_buddy(account, who)) { |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
294 add_buddies_in_permit(account, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
295 gaim_privacy_permit_remove(account, who, local); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
296 account->perm_deny = GAIM_PRIVACY_ALLOW_USERS; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
297 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
298 break; |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
299 default: |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
300 g_return_if_reached(); |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
301 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
302 } |
b17a907065cc
[gaim-migrate @ 18109]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14607
diff
changeset
|
303 |
14192 | 304 gboolean |
305 gaim_privacy_check(GaimAccount *account, const char *who) | |
306 { | |
307 GSList *list; | |
308 | |
309 switch (account->perm_deny) { | |
310 case GAIM_PRIVACY_ALLOW_ALL: | |
311 return TRUE; | |
312 | |
313 case GAIM_PRIVACY_DENY_ALL: | |
314 return FALSE; | |
315 | |
316 case GAIM_PRIVACY_ALLOW_USERS: | |
317 who = gaim_normalize(account, who); | |
318 for (list=account->permit; list!=NULL; list=list->next) { | |
319 if (!gaim_utf8_strcasecmp(who, (char *)list->data)) | |
320 return TRUE; | |
321 } | |
322 return FALSE; | |
323 | |
324 case GAIM_PRIVACY_DENY_USERS: | |
325 who = gaim_normalize(account, who); | |
326 for (list=account->deny; list!=NULL; list=list->next) { | |
327 if (!gaim_utf8_strcasecmp(who, (char *)list->data )) | |
328 return FALSE; | |
329 } | |
330 return TRUE; | |
331 | |
332 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
333 return (gaim_find_buddy(account, who) != NULL); | |
334 | |
335 default: | |
336 g_return_val_if_reached(TRUE); | |
337 } | |
338 } | |
339 | |
340 void | |
341 gaim_privacy_set_ui_ops(GaimPrivacyUiOps *ops) | |
342 { | |
343 privacy_ops = ops; | |
344 } | |
345 | |
346 GaimPrivacyUiOps * | |
347 gaim_privacy_get_ui_ops(void) | |
348 { | |
349 return privacy_ops; | |
350 } | |
351 | |
352 void | |
353 gaim_privacy_init(void) | |
354 { | |
355 } |