patch: bus: Fix timeout restarts
[platform/upstream/dbus.git] / bus / check.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* check.h  Bus security policy runtime check
3  *
4  * Copyright (C) 2014  Intel, Inc.
5  * Copyright (c) 2014  Samsung Electronics, Ltd.
6  *
7  * Licensed under the Academic Free License version 2.1
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  */
24
25 #ifndef BUS_CHECK_H
26 #define BUS_CHECK_H
27
28 #include "bus.h"
29 #include "policy.h"
30
31
32 typedef void (*BusCheckResponseFunc) (BusDeferredMessage *message,
33                                       BusResult result);
34
35 typedef enum {
36   BUS_DEFERRED_MESSAGE_CHECK_SEND      = 1 << 0,
37   BUS_DEFERRED_MESSAGE_CHECK_RECEIVE   = 1 << 1,
38   BUS_DEFERRED_MESSAGE_CHECK_OWN       = 1 << 2,
39 } BusDeferredMessageStatus;
40
41
42 BusCheck   *bus_check_new         (BusContext *context,
43                                    DBusError *error);
44 BusCheck   *bus_check_ref         (BusCheck *check);
45 void        bus_check_unref       (BusCheck *check);
46
47 BusContext *bus_check_get_context (BusCheck *check);
48 BusCynara  *bus_check_get_cynara  (BusCheck *check);
49 BusResult   bus_check_privilege   (BusCheck *check,
50                                    DBusMessage *message,
51                                    DBusConnection *sender,
52                                    DBusConnection *addressed_recipient,
53                                    DBusConnection *proposed_recipient,
54                                    const char *privilege,
55                                    BusDeferredMessageStatus check_type,
56                                    BusDeferredMessage **deferred_message);
57
58
59 BusDeferredMessage *bus_deferred_message_new                (DBusMessage *message,
60                                                              DBusConnection *sender,
61                                                              DBusConnection *addressed_recipient,
62                                                              DBusConnection *proposed_recipient,
63                                                              BusResult response);
64
65 BusDeferredMessage *bus_deferred_message_ref                (BusDeferredMessage *deferred_message);
66 void                bus_deferred_message_unref              (BusDeferredMessage *deferred_message);
67 BusResult           bus_deferred_message_dispatch           (BusDeferredMessage *deferred_message);
68 dbus_bool_t         bus_deferred_message_waits_for_check    (BusDeferredMessage *deferred_message);
69 DBusConnection     *bus_deferred_message_get_recipient      (BusDeferredMessage *deferred_message);
70 void                bus_deferred_message_response_received  (BusDeferredMessage *deferred_message,
71                                                              BusResult result);
72 dbus_bool_t         bus_deferred_message_queue_at_recipient (BusDeferredMessage *deferred_message,
73                                                              BusTransaction *transaction,
74                                                              dbus_bool_t full_dispatch,
75                                                              dbus_bool_t prepend);
76 dbus_bool_t         bus_deferred_message_replace            (BusDeferredMessage *old_message,
77                                                              BusDeferredMessage *new_message);
78 void                bus_deferred_message_disable_sender     (BusDeferredMessage *deferred_message);
79 BusResult           bus_deferred_message_get_response       (BusDeferredMessage *deferred_message);
80
81 BusDeferredMessageStatus  bus_deferred_message_get_status   (BusDeferredMessage *deferred_message);
82
83
84 dbus_bool_t         bus_deferred_message_expect_method_reply (BusDeferredMessage *deferred_message,
85                                                               BusTransaction *transaction,
86                                                               DBusError *error);
87 void                bus_deferred_message_create_error        (BusDeferredMessage *deferred_message,
88                                                               const char *error_message,
89                                                               DBusError *error);
90 void                bus_deferred_message_set_policy_check_info (BusDeferredMessage *deferred_message,
91                                                                 dbus_bool_t requested_reply,
92                                                                 int matched_rules,
93                                                                 const char *privilege);
94 dbus_bool_t         bus_deferred_message_check_message_limits (BusDeferredMessage *deferred_message,
95                                                                DBusError *error);
96
97
98 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
99 extern dbus_bool_t (*bus_check_test_override) (DBusConnection *connection,
100                                                const char *privilege);
101 #endif
102
103 #endif /* BUS_CHECK_H */