56ce771e03591b24fc67a5f5dc757a5982befe9f
[platform/upstream/dbus.git] / dbus / dbus-connection-internal.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-connection-internal.h DBusConnection internal interfaces
3  *
4  * Copyright (C) 2002  Red Hat Inc.
5  *
6  * Licensed under the Academic Free License version 2.1
7  * 
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.
12  *
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.
17  * 
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23 #ifndef DBUS_CONNECTION_INTERNAL_H
24 #define DBUS_CONNECTION_INTERNAL_H
25
26 #include <dbus/dbus-internals.h>
27 #include <dbus/dbus-connection.h>
28 #include <dbus/dbus-message.h>
29 #include <dbus/dbus-transport.h>
30 #include <dbus/dbus-resources.h>
31 #include <dbus/dbus-list.h>
32 #include <dbus/dbus-timeout.h>
33 #include <dbus/dbus-dataslot.h>
34
35 DBUS_BEGIN_DECLS
36
37 typedef enum
38 {
39   DBUS_ITERATION_DO_WRITING = 1 << 0, /**< Write messages out. */
40   DBUS_ITERATION_DO_READING = 1 << 1, /**< Read messages in. */
41   DBUS_ITERATION_BLOCK      = 1 << 2  /**< Block if nothing to do. */
42 } DBusIterationFlags;
43
44 /** default timeout value when waiting for a message reply, 25 seconds */
45 #define _DBUS_DEFAULT_TIMEOUT_VALUE (25 * 1000)
46
47 void              _dbus_connection_lock                        (DBusConnection     *connection);
48 void              _dbus_connection_unlock                      (DBusConnection     *connection);
49 DBusConnection *  _dbus_connection_ref_unlocked                (DBusConnection     *connection);
50 void              _dbus_connection_unref_unlocked              (DBusConnection     *connection);
51 void              _dbus_connection_queue_received_message_link (DBusConnection     *connection,
52                                                                 DBusList           *link);
53 dbus_bool_t       _dbus_connection_has_messages_to_send_unlocked (DBusConnection     *connection);
54 DBusMessage*      _dbus_connection_get_message_to_send         (DBusConnection     *connection);
55 void              _dbus_connection_message_sent_unlocked       (DBusConnection     *connection,
56                                                                 DBusMessage        *message);
57 dbus_bool_t       _dbus_connection_add_watch_unlocked          (DBusConnection     *connection,
58                                                                 DBusWatch          *watch);
59 void              _dbus_connection_remove_watch_unlocked       (DBusConnection     *connection,
60                                                                 DBusWatch          *watch);
61 void              _dbus_connection_toggle_watch_unlocked       (DBusConnection     *connection,
62                                                                 DBusWatch          *watch,
63                                                                 dbus_bool_t         enabled);
64 dbus_bool_t       _dbus_connection_handle_watch                (DBusWatch          *watch,
65                                                                 unsigned int        condition,
66                                                                 void               *data);
67 dbus_bool_t       _dbus_connection_add_timeout_unlocked        (DBusConnection     *connection,
68                                                                 DBusTimeout        *timeout);
69 void              _dbus_connection_remove_timeout_unlocked     (DBusConnection     *connection,
70                                                                 DBusTimeout        *timeout);
71 void              _dbus_connection_toggle_timeout_unlocked     (DBusConnection     *connection,
72                                                                 DBusTimeout        *timeout,
73                                                                 dbus_bool_t         enabled);
74 DBusConnection*   _dbus_connection_new_for_transport           (DBusTransport      *transport);
75 DBusConnection*   _dbus_connection_new_for_used_transport       (DBusTransport *transport);
76 void              _dbus_connection_do_iteration_unlocked       (DBusConnection     *connection,
77                                                                 DBusPendingCall    *pending,
78                                                                 unsigned int        flags,
79                                                                 int                 timeout_milliseconds);
80 void              _dbus_connection_close_possibly_shared       (DBusConnection     *connection);
81 void              _dbus_connection_close_if_only_one_ref       (DBusConnection     *connection);
82
83 DBusPendingCall*  _dbus_pending_call_new                       (DBusConnection     *connection,
84                                                                 int                 timeout_milliseconds,
85                                                                 DBusTimeoutHandler  timeout_handler);
86 void              _dbus_pending_call_notify                    (DBusPendingCall    *pending);
87 void              _dbus_connection_remove_pending_call         (DBusConnection     *connection,
88                                                                 DBusPendingCall    *pending);
89 void              _dbus_connection_block_pending_call          (DBusPendingCall    *pending);
90 void              _dbus_pending_call_complete_and_unlock       (DBusPendingCall    *pending,
91                                                                 DBusMessage        *message);
92 dbus_bool_t       _dbus_connection_send_and_unlock             (DBusConnection     *connection,
93                                                                 DBusMessage        *message,
94                                                                 dbus_uint32_t      *client_serial);
95
96 void              _dbus_connection_queue_synthesized_message_link (DBusConnection *connection,
97                                                                    DBusList *link);
98 void              _dbus_connection_test_get_locks                 (DBusConnection *conn,
99                                                                    DBusMutex **mutex_loc,
100                                                                    DBusMutex **dispatch_mutex_loc,
101                                                                    DBusMutex **io_path_mutex_loc,
102                                                                    DBusCondVar **dispatch_cond_loc,
103                                                                    DBusCondVar **io_path_cond_loc);
104
105 /* if DBUS_ENABLE_STATS */
106 void _dbus_connection_get_stats (DBusConnection *connection,
107                                  dbus_uint32_t  *in_messages,
108                                  dbus_uint32_t  *in_bytes,
109                                  dbus_uint32_t  *in_fds,
110                                  dbus_uint32_t  *in_peak_bytes,
111                                  dbus_uint32_t  *in_peak_fds,
112                                  dbus_uint32_t  *out_messages,
113                                  dbus_uint32_t  *out_bytes,
114                                  dbus_uint32_t  *out_fds,
115                                  dbus_uint32_t  *out_peak_bytes,
116                                  dbus_uint32_t  *out_peak_fds);
117
118
119 /* if DBUS_ENABLE_EMBEDDED_TESTS */
120 const char* _dbus_connection_get_address (DBusConnection *connection);
121
122 /* This _dbus_bus_* stuff doesn't really belong here, but dbus-bus-internal.h seems
123  * silly for one function
124  */
125 /**
126  * @addtogroup DBusBusInternals
127  * @{
128  */
129
130 void           _dbus_bus_notify_shared_connection_disconnected_unlocked (DBusConnection *connection);
131
132 /** @} */
133
134
135 DBUS_END_DECLS
136
137 #endif /* DBUS_CONNECTION_INTERNAL_H */