1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* policy.c Policies for what a connection can do
4 * Copyright (C) 2003 Red Hat, Inc.
6 * Licensed under the Academic Free License version 1.2
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 bus_policy_rule_new (BusPolicyRuleType type,
32 rule = dbus_new0 (BusPolicyRule, 1);
44 bus_policy_rule_ref (BusPolicyRule *rule)
46 _dbus_assert (rule->refcount > 0);
52 bus_policy_rule_unref (BusPolicyRule *rule)
54 _dbus_assert (rule->refcount > 0);
58 if (rule->refcount == 0)
62 case DBUS_POLICY_RULE_SEND:
63 dbus_free (rule->d.send.message_name);
64 dbus_free (rule->d.send.destination);
66 case DBUS_POLICY_RULE_RECEIVE:
67 dbus_free (rule->d.receive.message_name);
68 dbus_free (rule->d.receive.origin);
70 case DBUS_POLICY_RULE_OWN:
71 dbus_free (rule->d.own.service_name);
91 policy = dbus_new0 (BusPolicy, 1);
101 bus_policy_ref (BusPolicy *policy)
103 _dbus_assert (policy->refcount > 0);
105 policy->refcount += 1;
109 rule_unref_foreach (void *data,
112 BusPolicyRule *rule = data;
114 bus_policy_rule_unref (rule);
118 bus_policy_unref (BusPolicy *policy)
120 _dbus_assert (policy->refcount > 0);
122 policy->refcount -= 1;
124 if (policy->refcount == 0)
126 _dbus_list_foreach (&policy->rules,
130 _dbus_list_clear (&policy->rules);
137 bus_policy_check_can_send (BusPolicy *policy,
138 DBusConnection *sender,
139 DBusMessage *message)
146 bus_policy_check_can_receive (BusPolicy *policy,
147 DBusConnection *receiver,
148 DBusMessage *message)
155 bus_policy_check_can_own (BusPolicy *policy,
156 DBusConnection *connection,
157 const char *service_name)
163 #endif /* BUS_POLICY_H */