annotate src/privacy.c @ 11249:b4b1be482b4e

[gaim-migrate @ 13418] sf patch #1235519, from Sadrul Habib Chowdhury This is a pretty big patch that makes Gaim correctly save and restore the current status (away/available, away message, available message, invisible, etc). The GaimGtkStatusBoxWidget thing I think defaults to "Available" every time its created, which overrides the setting that was saved to the XML file. So that still needs to be fixed before this will really work. Anyway, mad props to Sadrul for putting up with my requests on this patch committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 13 Aug 2005 05:22:09 +0000
parents f03dce7ea408
children 109ee3bfeac5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * gaim
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8007
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8007
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8007
diff changeset
6 * source distribution.
8007
a13118091bc7 [gaim-migrate @ 8685]
Christian Hammond <chipx86@chipx86.com>
parents: 7581
diff changeset
7 *
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 #include "internal.h"
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "account.h"
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "privacy.h"
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #include "server.h"
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 #include "util.h"
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 static GaimPrivacyUiOps *privacy_ops = NULL;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 gboolean
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
32 gaim_privacy_permit_add(GaimAccount *account, const char *who,
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
33 gboolean local_only)
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 GSList *l;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 char *name;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 g_return_val_if_fail(account != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 g_return_val_if_fail(who != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
41 name = g_strdup(gaim_normalize(account, who));
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 for (l = account->permit; l != NULL; l = l->next) {
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
44 if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data)))
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 break;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 g_free(name);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 if (l != NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 return FALSE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 account->permit = g_slist_append(account->permit, g_strdup(who));
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
55 if (!local_only && gaim_account_is_connected(account))
6373
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
56 serv_add_permit(gaim_account_get_connection(account), who);
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
57
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 if (privacy_ops != NULL && privacy_ops->permit_added != NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 privacy_ops->permit_added(account, who);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
10704
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
61 gaim_blist_schedule_save();
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
62
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 return TRUE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 gboolean
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
67 gaim_privacy_permit_remove(GaimAccount *account, const char *who,
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
68 gboolean local_only)
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 GSList *l;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 char *name;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 g_return_val_if_fail(account != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 g_return_val_if_fail(who != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
76 name = g_strdup(gaim_normalize(account, who));
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 for (l = account->permit; l != NULL; l = l->next) {
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
79 if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data)))
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 break;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 g_free(name);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 if (l == NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 return FALSE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 account->permit = g_slist_remove(account->permit, l->data);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 g_free(l->data);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
91 if (!local_only && gaim_account_is_connected(account))
7581
48f31501c3c1 [gaim-migrate @ 8199]
Mark Doliner <mark@kingant.net>
parents: 7261
diff changeset
92 serv_rem_permit(gaim_account_get_connection(account), who);
6373
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
93
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 if (privacy_ops != NULL && privacy_ops->permit_removed != NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 privacy_ops->permit_removed(account, who);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96
10704
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
97 gaim_blist_schedule_save();
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
98
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 return TRUE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 gboolean
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
103 gaim_privacy_deny_add(GaimAccount *account, const char *who,
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
104 gboolean local_only)
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 GSList *l;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 char *name;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 g_return_val_if_fail(account != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 g_return_val_if_fail(who != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
112 name = g_strdup(gaim_normalize(account, who));
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 for (l = account->deny; l != NULL; l = l->next) {
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
115 if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data)))
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 break;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 g_free(name);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 if (l != NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 return FALSE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 account->deny = g_slist_append(account->deny, g_strdup(who));
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
126 if (!local_only && gaim_account_is_connected(account))
6373
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
127 serv_add_deny(gaim_account_get_connection(account), who);
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
128
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 if (privacy_ops != NULL && privacy_ops->deny_added != NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 privacy_ops->deny_added(account, who);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131
10704
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
132 gaim_blist_schedule_save();
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
133
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 return TRUE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 gboolean
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
138 gaim_privacy_deny_remove(GaimAccount *account, const char *who,
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
139 gboolean local_only)
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 GSList *l;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 char *name;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 g_return_val_if_fail(account != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 g_return_val_if_fail(who != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
147 name = g_strdup(gaim_normalize(account, who));
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 for (l = account->deny; l != NULL; l = l->next) {
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
150 if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data)))
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 break;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 g_free(name);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 if (l == NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 return FALSE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 account->deny = g_slist_remove(account->deny, l->data);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 g_free(l->data);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161
8150
20262ccefdd8 [gaim-migrate @ 8862]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
162 if (!local_only && gaim_account_is_connected(account))
6373
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
163 serv_rem_deny(gaim_account_get_connection(account), who);
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
164
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 if (privacy_ops != NULL && privacy_ops->deny_removed != NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 privacy_ops->deny_removed(account, who);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167
10704
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
168 gaim_blist_schedule_save();
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
169
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 return TRUE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172
11111
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
173 gboolean
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
174 gaim_privacy_check(GaimAccount *account, const char *who)
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
175 {
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
176 GSList *list;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
177
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
178 switch (account->perm_deny) {
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
179 case GAIM_PRIVACY_ALLOW_ALL:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
180 return TRUE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
181
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
182 case GAIM_PRIVACY_DENY_ALL:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
183 return FALSE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
184
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
185 case GAIM_PRIVACY_ALLOW_USERS:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
186 for (list=account->permit; list!=NULL; list=list->next) {
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
187 if (!gaim_utf8_strcasecmp(who, gaim_normalize(account, (char *)list->data)))
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
188 return TRUE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
189 }
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
190 return FALSE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
191
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
192 case GAIM_PRIVACY_DENY_USERS:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
193 for (list=account->deny; list!=NULL; list=list->next) {
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
194 if (!gaim_utf8_strcasecmp(who, gaim_normalize( account, (char *)list->data )))
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
195 return FALSE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
196 }
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
197 return TRUE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
198
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
199 case GAIM_PRIVACY_ALLOW_BUDDYLIST:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
200 return (gaim_find_buddy(account, who) != NULL);
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
201
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
202 default:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
203 g_return_val_if_reached(TRUE);
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
204 }
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
205 }
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
206
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 void
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
208 gaim_privacy_set_ui_ops(GaimPrivacyUiOps *ops)
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 privacy_ops = ops;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 GaimPrivacyUiOps *
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
214 gaim_privacy_get_ui_ops(void)
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 return privacy_ops;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 void
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 gaim_privacy_init(void)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 }