comparison src/privacy.c @ 6371:8f94cce8faa5

[gaim-migrate @ 6876] I think I touched almost every file. Here's what happened. I started off fixing up the Makefile.am and configure.ac files to help with the core/UI split some. Then I got annoyed with the build_{allow,deny}_list() functions that everything used, and decided to core/UI split privacy. While doing that, I decided to redesign the dialog. So now, a lot has changed, but not really so much. Just that most files got affected. Oh yeah, and the UI stuff was taken out of internal.h and moved to gtkinternal.h. If you use this, please be aware of this change. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 05 Aug 2003 10:55:04 +0000
parents
children 4d61775a5741
comparison
equal deleted inserted replaced
6370:a4b83df2165b 6371:8f94cce8faa5
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 g_return_val_if_fail(gaim_account_is_connected(account), 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
53 serv_add_permit(gaim_account_get_connection(account), who);
54 gaim_blist_save();
55
56 if (privacy_ops != NULL && privacy_ops->permit_added != NULL)
57 privacy_ops->permit_added(account, who);
58
59 return TRUE;
60 }
61
62 gboolean
63 gaim_privacy_permit_remove(GaimAccount *account, const char *who)
64 {
65 GSList *l;
66 char *name;
67
68 g_return_val_if_fail(account != NULL, FALSE);
69 g_return_val_if_fail(who != NULL, FALSE);
70 g_return_val_if_fail(gaim_account_is_connected(account), 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
87 serv_rem_deny(gaim_account_get_connection(account), who);
88 gaim_blist_save();
89
90 if (privacy_ops != NULL && privacy_ops->permit_removed != NULL)
91 privacy_ops->permit_removed(account, who);
92
93 return TRUE;
94 }
95
96 gboolean
97 gaim_privacy_deny_add(GaimAccount *account, const char *who)
98 {
99 GSList *l;
100 char *name;
101
102 g_return_val_if_fail(account != NULL, FALSE);
103 g_return_val_if_fail(who != NULL, FALSE);
104 g_return_val_if_fail(gaim_account_is_connected(account), FALSE);
105
106 name = g_strdup(normalize(who));
107
108 for (l = account->deny; l != NULL; l = l->next) {
109 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data)))
110 break;
111 }
112
113 g_free(name);
114
115 if (l != NULL)
116 return FALSE;
117
118 account->deny = g_slist_append(account->deny, g_strdup(who));
119
120 serv_add_deny(gaim_account_get_connection(account), who);
121 gaim_blist_save();
122
123 if (privacy_ops != NULL && privacy_ops->deny_added != NULL)
124 privacy_ops->deny_added(account, who);
125
126 return TRUE;
127 }
128
129 gboolean
130 gaim_privacy_deny_remove(GaimAccount *account, const char *who)
131 {
132 GSList *l;
133 char *name;
134
135 g_return_val_if_fail(account != NULL, FALSE);
136 g_return_val_if_fail(who != NULL, FALSE);
137 g_return_val_if_fail(gaim_account_is_connected(account), FALSE);
138
139 name = g_strdup(normalize(who));
140
141 for (l = account->deny; l != NULL; l = l->next) {
142 if (!gaim_utf8_strcasecmp(name, normalize((char *)l->data)))
143 break;
144 }
145
146 g_free(name);
147
148 if (l == NULL)
149 return FALSE;
150
151 account->deny = g_slist_remove(account->deny, l->data);
152 g_free(l->data);
153
154 serv_rem_deny(gaim_account_get_connection(account), who);
155 gaim_blist_save();
156
157 if (privacy_ops != NULL && privacy_ops->deny_removed != NULL)
158 privacy_ops->deny_removed(account, who);
159
160 return TRUE;
161 }
162
163 void
164 gaim_set_privacy_ui_ops(GaimPrivacyUiOps *ops)
165 {
166 privacy_ops = ops;
167 }
168
169 GaimPrivacyUiOps *
170 gaim_get_privacy_ui_ops(void)
171 {
172 return privacy_ops;
173 }
174
175 void
176 gaim_privacy_init(void)
177 {
178 }