Mercurial > pidgin.yaz
annotate src/privacy.c @ 6375:72023626d5b8
[gaim-migrate @ 6880]
Removed some unnecessary stuff. Oh yeah, and I think privacy is broken. I
can block, but not unblock. I'll fix it tomorrow.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 05 Aug 2003 11:33:18 +0000 |
parents | 4d61775a5741 |
children | 01289157fc37 |
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" | |
6375
72023626d5b8
[gaim-migrate @ 6880]
Christian Hammond <chipx86@chipx86.com>
parents:
6373
diff
changeset
|
23 #include "debug.h" |
6371 | 24 #include "privacy.h" |
25 #include "server.h" | |
26 #include "util.h" | |
27 | |
28 static GaimPrivacyUiOps *privacy_ops = NULL; | |
29 | |
30 gboolean | |
31 gaim_privacy_permit_add(GaimAccount *account, const char *who) | |
32 { | |
33 GSList *l; | |
34 char *name; | |
35 | |
36 g_return_val_if_fail(account != NULL, FALSE); | |
37 g_return_val_if_fail(who != NULL, FALSE); | |
38 | |
39 name = g_strdup(normalize(who)); | |
40 | |
41 for (l = account->permit; l != NULL; l = l->next) { | |
42 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) | |
43 break; | |
44 } | |
45 | |
46 g_free(name); | |
47 | |
48 if (l != NULL) | |
49 return FALSE; | |
50 | |
51 account->permit = g_slist_append(account->permit, g_strdup(who)); | |
52 | |
6373
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
53 if (gaim_account_is_connected(account)) |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
54 serv_add_permit(gaim_account_get_connection(account), who); |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
55 |
6371 | 56 gaim_blist_save(); |
57 | |
58 if (privacy_ops != NULL && privacy_ops->permit_added != NULL) | |
59 privacy_ops->permit_added(account, who); | |
60 | |
61 return TRUE; | |
62 } | |
63 | |
64 gboolean | |
65 gaim_privacy_permit_remove(GaimAccount *account, const char *who) | |
66 { | |
67 GSList *l; | |
68 char *name; | |
69 | |
70 g_return_val_if_fail(account != NULL, FALSE); | |
71 g_return_val_if_fail(who != NULL, FALSE); | |
72 | |
73 name = g_strdup(normalize(who)); | |
74 | |
75 for (l = account->permit; l != NULL; l = l->next) { | |
76 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) | |
77 break; | |
78 } | |
79 | |
80 g_free(name); | |
81 | |
82 if (l == NULL) | |
83 return FALSE; | |
84 | |
85 account->permit = g_slist_remove(account->permit, l->data); | |
86 g_free(l->data); | |
87 | |
6373
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
88 if (gaim_account_is_connected(account)) |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
89 serv_rem_deny(gaim_account_get_connection(account), who); |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
90 |
6371 | 91 gaim_blist_save(); |
92 | |
93 if (privacy_ops != NULL && privacy_ops->permit_removed != NULL) | |
94 privacy_ops->permit_removed(account, who); | |
95 | |
96 return TRUE; | |
97 } | |
98 | |
99 gboolean | |
100 gaim_privacy_deny_add(GaimAccount *account, const char *who) | |
101 { | |
102 GSList *l; | |
103 char *name; | |
104 | |
105 g_return_val_if_fail(account != NULL, FALSE); | |
106 g_return_val_if_fail(who != NULL, FALSE); | |
107 | |
108 name = g_strdup(normalize(who)); | |
109 | |
110 for (l = account->deny; l != NULL; l = l->next) { | |
111 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) | |
112 break; | |
113 } | |
114 | |
115 g_free(name); | |
116 | |
117 if (l != NULL) | |
118 return FALSE; | |
119 | |
120 account->deny = g_slist_append(account->deny, g_strdup(who)); | |
121 | |
6373
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
122 if (gaim_account_is_connected(account)) |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
123 serv_add_deny(gaim_account_get_connection(account), who); |
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
124 |
6371 | 125 gaim_blist_save(); |
126 | |
127 if (privacy_ops != NULL && privacy_ops->deny_added != NULL) | |
128 privacy_ops->deny_added(account, who); | |
129 | |
130 return TRUE; | |
131 } | |
132 | |
133 gboolean | |
134 gaim_privacy_deny_remove(GaimAccount *account, const char *who) | |
135 { | |
136 GSList *l; | |
137 char *name; | |
138 | |
139 g_return_val_if_fail(account != NULL, FALSE); | |
140 g_return_val_if_fail(who != NULL, FALSE); | |
141 | |
142 name = g_strdup(normalize(who)); | |
143 | |
144 for (l = account->deny; l != NULL; l = l->next) { | |
145 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data))) | |
146 break; | |
147 } | |
148 | |
149 g_free(name); | |
150 | |
151 if (l == NULL) | |
152 return FALSE; | |
153 | |
154 account->deny = g_slist_remove(account->deny, l->data); | |
155 g_free(l->data); | |
156 | |
6375
72023626d5b8
[gaim-migrate @ 6880]
Christian Hammond <chipx86@chipx86.com>
parents:
6373
diff
changeset
|
157 if (gaim_account_is_connected(account)) { |
72023626d5b8
[gaim-migrate @ 6880]
Christian Hammond <chipx86@chipx86.com>
parents:
6373
diff
changeset
|
158 gaim_debug(GAIM_DEBUG_INFO, "privacy", |
72023626d5b8
[gaim-migrate @ 6880]
Christian Hammond <chipx86@chipx86.com>
parents:
6373
diff
changeset
|
159 "Removing %s from server-side deny list\n", who); |
6373
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
160 serv_rem_deny(gaim_account_get_connection(account), who); |
6375
72023626d5b8
[gaim-migrate @ 6880]
Christian Hammond <chipx86@chipx86.com>
parents:
6373
diff
changeset
|
161 } |
6373
4d61775a5741
[gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
162 |
6371 | 163 gaim_blist_save(); |
164 | |
165 if (privacy_ops != NULL && privacy_ops->deny_removed != NULL) | |
166 privacy_ops->deny_removed(account, who); | |
167 | |
168 return TRUE; | |
169 } | |
170 | |
171 void | |
172 gaim_set_privacy_ui_ops(GaimPrivacyUiOps *ops) | |
173 { | |
174 privacy_ops = ops; | |
175 } | |
176 | |
177 GaimPrivacyUiOps * | |
178 gaim_get_privacy_ui_ops(void) | |
179 { | |
180 return privacy_ops; | |
181 } | |
182 | |
183 void | |
184 gaim_privacy_init(void) | |
185 { | |
186 } |