annotate src/privacy.c @ 14173:178540dc0517

[gaim-migrate @ 16823] Patch #1541744 ("Memleak"): "This plugs a possible memleak." The memleak would happen if you switch from an account with account-options to an account with none. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 18 Aug 2006 00:23:39 +0000
parents 7f276f375789
children
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;
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
37 GaimBuddy *buddy;
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 g_return_val_if_fail(account != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 g_return_val_if_fail(who != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
42 name = g_strdup(gaim_normalize(account, who));
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 for (l = account->permit; l != NULL; l = l->next) {
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
45 if (!gaim_utf8_strcasecmp(name, (char *)l->data))
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 break;
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
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
49 if (l != NULL)
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
50 {
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
51 g_free(name);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
52 return FALSE;
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
53 }
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
55 account->permit = g_slist_append(account->permit, name);
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
57 if (!local_only && gaim_account_is_connected(account))
6373
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
58 serv_add_permit(gaim_account_get_connection(account), who);
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
59
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 if (privacy_ops != NULL && privacy_ops->permit_added != NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 privacy_ops->permit_added(account, who);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
10704
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
63 gaim_blist_schedule_save();
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
64
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
65 /* This lets the UI know a buddy has had its privacy setting changed */
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
66 buddy = gaim_find_buddy(account, name);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
67 if (buddy != NULL) {
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
68 gaim_signal_emit(gaim_blist_get_handle(),
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
69 "buddy-privacy-changed", buddy);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
70 }
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 return TRUE;
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
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 gboolean
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
75 gaim_privacy_permit_remove(GaimAccount *account, const char *who,
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
76 gboolean local_only)
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 GSList *l;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 char *name;
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
80 GaimBuddy *buddy;
6371
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 g_return_val_if_fail(account != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 g_return_val_if_fail(who != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
85 name = gaim_normalize(account, who);
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 for (l = account->permit; l != NULL; l = l->next) {
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
88 if (!gaim_utf8_strcasecmp(name, (char *)l->data))
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 break;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 if (l == NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 return FALSE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 g_free(l->data);
11719
109ee3bfeac5 [gaim-migrate @ 14010]
Richard Laager <rlaager@wiktel.com>
parents: 11111
diff changeset
96 account->permit = g_slist_delete_link(account->permit, l);
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
98 if (!local_only && gaim_account_is_connected(account))
7581
48f31501c3c1 [gaim-migrate @ 8199]
Mark Doliner <mark@kingant.net>
parents: 7261
diff changeset
99 serv_rem_permit(gaim_account_get_connection(account), who);
6373
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
100
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 if (privacy_ops != NULL && privacy_ops->permit_removed != NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 privacy_ops->permit_removed(account, who);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103
10704
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
104 gaim_blist_schedule_save();
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
105
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
106 buddy = gaim_find_buddy(account, name);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
107 if (buddy != NULL) {
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
108 gaim_signal_emit(gaim_blist_get_handle(),
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
109 "buddy-privacy-changed", buddy);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
110 }
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 return TRUE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 }
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 gboolean
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
115 gaim_privacy_deny_add(GaimAccount *account, const char *who,
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
116 gboolean local_only)
6371
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 GSList *l;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 char *name;
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
120 GaimBuddy *buddy;
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 g_return_val_if_fail(account != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 g_return_val_if_fail(who != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
125 name = g_strdup(gaim_normalize(account, who));
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 for (l = account->deny; l != NULL; l = l->next) {
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7107
diff changeset
128 if (!gaim_utf8_strcasecmp(name, gaim_normalize(account, (char *)l->data)))
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 break;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
132 if (l != NULL)
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
133 {
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
134 g_free(name);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
135 return FALSE;
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
136 }
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
138 account->deny = g_slist_append(account->deny, name);
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
140 if (!local_only && gaim_account_is_connected(account))
6373
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
141 serv_add_deny(gaim_account_get_connection(account), who);
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
142
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 if (privacy_ops != NULL && privacy_ops->deny_added != NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 privacy_ops->deny_added(account, who);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145
10704
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
146 gaim_blist_schedule_save();
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
147
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
148 buddy = gaim_find_buddy(account, name);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
149 if (buddy != NULL) {
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
150 gaim_signal_emit(gaim_blist_get_handle(),
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
151 "buddy-privacy-changed", buddy);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
152 }
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 return TRUE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 }
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 gboolean
6378
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
157 gaim_privacy_deny_remove(GaimAccount *account, const char *who,
01289157fc37 [gaim-migrate @ 6883]
Christian Hammond <chipx86@chipx86.com>
parents: 6375
diff changeset
158 gboolean local_only)
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 GSList *l;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 char *name;
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
162 GaimBuddy *buddy;
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 g_return_val_if_fail(account != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 g_return_val_if_fail(who != NULL, FALSE);
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
167 name = gaim_normalize(account, who);
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 for (l = account->deny; l != NULL; l = l->next) {
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
170 if (!gaim_utf8_strcasecmp(name, (char *)l->data))
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 break;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
174 buddy = gaim_find_buddy(account, name);
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 if (l == NULL)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 return FALSE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178
13149
18e621aa8a43 [gaim-migrate @ 15512]
Richard Laager <rlaager@wiktel.com>
parents: 11719
diff changeset
179 name = l->data;
11719
109ee3bfeac5 [gaim-migrate @ 14010]
Richard Laager <rlaager@wiktel.com>
parents: 11111
diff changeset
180 account->deny = g_slist_delete_link(account->deny, l);
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181
8150
20262ccefdd8 [gaim-migrate @ 8862]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
182 if (!local_only && gaim_account_is_connected(account))
13149
18e621aa8a43 [gaim-migrate @ 15512]
Richard Laager <rlaager@wiktel.com>
parents: 11719
diff changeset
183 serv_rem_deny(gaim_account_get_connection(account), name);
6373
4d61775a5741 [gaim-migrate @ 6878]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
184
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 if (privacy_ops != NULL && privacy_ops->deny_removed != NULL)
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
186 privacy_ops->deny_removed(account, who);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
187
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
188 if (buddy != NULL) {
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
189 gaim_signal_emit(gaim_blist_get_handle(),
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
190 "buddy-privacy-changed", buddy);
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
191 }
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192
13149
18e621aa8a43 [gaim-migrate @ 15512]
Richard Laager <rlaager@wiktel.com>
parents: 11719
diff changeset
193 g_free(name);
10704
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
194 gaim_blist_schedule_save();
a4ae4fb7f939 [gaim-migrate @ 12288]
Mark Doliner <mark@kingant.net>
parents: 9741
diff changeset
195
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 return TRUE;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198
11111
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
199 gboolean
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
200 gaim_privacy_check(GaimAccount *account, const char *who)
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 GSList *list;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
203
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
204 switch (account->perm_deny) {
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
205 case GAIM_PRIVACY_ALLOW_ALL:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
206 return TRUE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
207
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
208 case GAIM_PRIVACY_DENY_ALL:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
209 return FALSE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
210
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
211 case GAIM_PRIVACY_ALLOW_USERS:
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
212 who = gaim_normalize(account, who);
11111
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
213 for (list=account->permit; list!=NULL; list=list->next) {
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
214 if (!gaim_utf8_strcasecmp(who, (char *)list->data))
11111
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
215 return TRUE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
216 }
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
217 return FALSE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
218
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
219 case GAIM_PRIVACY_DENY_USERS:
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
220 who = gaim_normalize(account, who);
11111
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
221 for (list=account->deny; list!=NULL; list=list->next) {
14138
7f276f375789 [gaim-migrate @ 16780]
Aaron Sheldon <aaronsheldon>
parents: 13149
diff changeset
222 if (!gaim_utf8_strcasecmp(who, (char *)list->data ))
11111
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
223 return FALSE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
224 }
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
225 return TRUE;
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
226
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
227 case GAIM_PRIVACY_ALLOW_BUDDYLIST:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
228 return (gaim_find_buddy(account, who) != NULL);
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
229
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
230 default:
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
231 g_return_val_if_reached(TRUE);
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
232 }
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
233 }
f03dce7ea408 [gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents: 10704
diff changeset
234
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 void
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
236 gaim_privacy_set_ui_ops(GaimPrivacyUiOps *ops)
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 privacy_ops = ops;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 GaimPrivacyUiOps *
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6378
diff changeset
242 gaim_privacy_get_ui_ops(void)
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 return privacy_ops;
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 }
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 void
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 gaim_privacy_init(void)
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 {
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 }