Mercurial > pidgin
annotate src/privacy.c @ 6374:ca73fdf3eb38
[gaim-migrate @ 6879]
The permit/deny list is now a bit taller, making it easier to see the
people in it.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 05 Aug 2003 11:18:27 +0000 |
parents | 4d61775a5741 |
children | 72023626d5b8 |
rev | line source |
---|---|
6371 | 1 /** |
2 * gaim | |
3 * | |
4 * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program 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 | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
20 #include "internal.h" | |
21 | |
22 #include "account.h" | |
23 #include "privacy.h" | |
24 #include "server.h" | |
25 #include "util.h" | |
26 | |
27 static GaimPrivacyUiOps *privacy_ops = NULL; | |
28 | |
29 gboolean | |
30 gaim_privacy_permit_add(GaimAccount *account, const char *who) | |
31 { | |
32 GSList *l; | |
33 char *name; | |
34 | |
35 g_return_val_if_fail(account != NULL, FALSE); | |
36 g_return_val_if_fail(who != NULL, FALSE); | |
37 | |
38 name = g_strdup(normalize(who)); | |
39 | |
40 for (l = account->permit; l != NULL; l = l->next) { | |
41 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) | |
42 break; | |
43 } | |
44 | |
45 g_free(name); | |
46 | |
47 if (l != NULL) | |
48 return FALSE; | |
49 | |
50 account->permit = g_slist_append(account->permit, g_strdup(who)); | |
51 | |
6373
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
52 if (gaim_account_is_connected(account)) |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
53 serv_add_permit(gaim_account_get_connection(account), who); |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
54 |
6371 | 55 gaim_blist_save(); |
56 | |
57 if (privacy_ops != NULL && privacy_ops->permit_added != NULL) | |
58 privacy_ops->permit_added(account, who); | |
59 | |
60 return TRUE; | |
61 } | |
62 | |
63 gboolean | |
64 gaim_privacy_permit_remove(GaimAccount *account, const char *who) | |
65 { | |
66 GSList *l; | |
67 char *name; | |
68 | |
69 g_return_val_if_fail(account != NULL, FALSE); | |
70 g_return_val_if_fail(who != NULL, FALSE); | |
71 | |
72 name = g_strdup(normalize(who)); | |
73 | |
74 for (l = account->permit; l != NULL; l = l->next) { | |
75 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) | |
76 break; | |
77 } | |
78 | |
79 g_free(name); | |
80 | |
81 if (l == NULL) | |
82 return FALSE; | |
83 | |
84 account->permit = g_slist_remove(account->permit, l->data); | |
85 g_free(l->data); | |
86 | |
6373
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
87 if (gaim_account_is_connected(account)) |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
88 serv_rem_deny(gaim_account_get_connection(account), who); |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
89 |
6371 | 90 gaim_blist_save(); |
91 | |
92 if (privacy_ops != NULL && privacy_ops->permit_removed != NULL) | |
93 privacy_ops->permit_removed(account, who); | |
94 | |
95 return TRUE; | |
96 } | |
97 | |
98 gboolean | |
99 gaim_privacy_deny_add(GaimAccount *account, const char *who) | |
100 { | |
101 GSList *l; | |
102 char *name; | |
103 | |
104 g_return_val_if_fail(account != NULL, FALSE); | |
105 g_return_val_if_fail(who != NULL, FALSE); | |
106 | |
107 name = g_strdup(normalize(who)); | |
108 | |
109 for (l = account->deny; l != NULL; l = l->next) { | |
110 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) | |
111 break; | |
112 } | |
113 | |
114 g_free(name); | |
115 | |
116 if (l != NULL) | |
117 return FALSE; | |
118 | |
119 account->deny = g_slist_append(account->deny, g_strdup(who)); | |
120 | |
6373
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
121 if (gaim_account_is_connected(account)) |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
122 serv_add_deny(gaim_account_get_connection(account), who); |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
123 |
6371 | 124 gaim_blist_save(); |
125 | |
126 if (privacy_ops != NULL && privacy_ops->deny_added != NULL) | |
127 privacy_ops->deny_added(account, who); | |
128 | |
129 return TRUE; | |
130 } | |
131 | |
132 gboolean | |
133 gaim_privacy_deny_remove(GaimAccount *account, const char *who) | |
134 { | |
135 GSList *l; | |
136 char *name; | |
137 | |
138 g_return_val_if_fail(account != NULL, FALSE); | |
139 g_return_val_if_fail(who != NULL, FALSE); | |
140 | |
141 name = g_strdup(normalize(who)); | |
142 | |
143 for (l = account->deny; l != NULL; l = l->next) { | |
144 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) | |
145 break; | |
146 } | |
147 | |
148 g_free(name); | |
149 | |
150 if (l == NULL) | |
151 return FALSE; | |
152 | |
153 account->deny = g_slist_remove(account->deny, l->data); | |
154 g_free(l->data); | |
155 | |
6373
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
156 if (gaim_account_is_connected(account)) |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
157 serv_rem_deny(gaim_account_get_connection(account), who); |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
158 |
6371 | 159 gaim_blist_save(); |
160 | |
161 if (privacy_ops != NULL && privacy_ops->deny_removed != NULL) | |
162 privacy_ops->deny_removed(account, who); | |
163 | |
164 return TRUE; | |
165 } | |
166 | |
167 void | |
168 gaim_set_privacy_ui_ops(GaimPrivacyUiOps *ops) | |
169 { | |
170 privacy_ops = ops; | |
171 } | |
172 | |
173 GaimPrivacyUiOps * | |
174 gaim_get_privacy_ui_ops(void) | |
175 { | |
176 return privacy_ops; | |
177 } | |
178 | |
179 void | |
180 gaim_privacy_init(void) | |
181 { | |
182 } |