1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-connection-internal.h DBusConnection internal interfaces
4 * Copyright (C) 2002 Red Hat Inc.
6 * Licensed under the Academic Free License version 2.1
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef DBUS_CONNECTION_INTERNAL_H
24 #define DBUS_CONNECTION_INTERNAL_H
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>
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. */
44 /** default timeout value when waiting for a message reply, 25 seconds */
45 #define _DBUS_DEFAULT_TIMEOUT_VALUE (25 * 1000)
47 typedef void (* DBusPendingFdsChangeFunction) (void *data);
50 void _dbus_connection_lock (DBusConnection *connection);
52 void _dbus_connection_unlock (DBusConnection *connection);
54 DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection);
56 void _dbus_connection_unref_unlocked (DBusConnection *connection);
58 dbus_uint32_t _dbus_connection_get_next_client_serial (DBusConnection *connection);
59 void _dbus_connection_queue_received_message_link (DBusConnection *connection,
61 dbus_bool_t _dbus_connection_has_messages_to_send_unlocked (DBusConnection *connection);
62 DBusMessage* _dbus_connection_get_message_to_send (DBusConnection *connection);
63 void _dbus_connection_message_sent_unlocked (DBusConnection *connection,
64 DBusMessage *message);
65 dbus_bool_t _dbus_connection_add_watch_unlocked (DBusConnection *connection,
67 void _dbus_connection_remove_watch_unlocked (DBusConnection *connection,
69 void _dbus_connection_toggle_watch_unlocked (DBusConnection *connection,
72 dbus_bool_t _dbus_connection_handle_watch (DBusWatch *watch,
73 unsigned int condition,
75 dbus_bool_t _dbus_connection_add_timeout_unlocked (DBusConnection *connection,
76 DBusTimeout *timeout);
77 void _dbus_connection_remove_timeout_unlocked (DBusConnection *connection,
78 DBusTimeout *timeout);
79 void _dbus_connection_toggle_timeout_unlocked (DBusConnection *connection,
82 DBusConnection* _dbus_connection_new_for_transport (DBusTransport *transport);
83 void _dbus_connection_do_iteration_unlocked (DBusConnection *connection,
84 DBusPendingCall *pending,
86 int timeout_milliseconds);
87 void _dbus_connection_close_possibly_shared (DBusConnection *connection);
88 void _dbus_connection_close_if_only_one_ref (DBusConnection *connection);
90 DBusPendingCall* _dbus_pending_call_new (DBusConnection *connection,
91 int timeout_milliseconds,
92 DBusTimeoutHandler timeout_handler);
93 void _dbus_pending_call_notify (DBusPendingCall *pending);
94 void _dbus_connection_remove_pending_call (DBusConnection *connection,
95 DBusPendingCall *pending);
96 void _dbus_connection_block_pending_call (DBusPendingCall *pending);
97 void _dbus_pending_call_complete_and_unlock (DBusPendingCall *pending,
98 DBusMessage *message);
99 dbus_bool_t _dbus_connection_send_and_unlock (DBusConnection *connection,
100 DBusMessage *message,
101 dbus_uint32_t *client_serial);
103 void _dbus_connection_queue_synthesized_message_link (DBusConnection *connection,
106 void _dbus_connection_test_get_locks (DBusConnection *conn,
107 DBusMutex **mutex_loc,
108 DBusMutex **dispatch_mutex_loc,
109 DBusMutex **io_path_mutex_loc,
110 DBusCondVar **dispatch_cond_loc,
111 DBusCondVar **io_path_cond_loc);
113 int _dbus_connection_get_pending_fds_count (DBusConnection *connection);
115 void _dbus_connection_set_pending_fds_function (DBusConnection *connection,
116 DBusPendingFdsChangeFunction callback,
120 dbus_bool_t _dbus_connection_get_linux_security_label (DBusConnection *connection,
124 void _dbus_connection_enable_dispatch (DBusConnection *connection);
126 void _dbus_connection_disable_dispatch (DBusConnection *connection);
128 dbus_bool_t _dbus_connection_putback_message (DBusConnection *connection,
129 DBusMessage *after_message,
130 DBusMessage *message,
134 dbus_bool_t _dbus_connection_remove_message (DBusConnection *connection,
135 DBusMessage *message);
136 int _dbus_connection_get_n_incoming (DBusConnection *connection);
139 dbus_bool_t _dbus_connection_is_overflowed (DBusConnection *connection);
141 /* if DBUS_ENABLE_STATS */
143 void _dbus_connection_get_stats (DBusConnection *connection,
144 dbus_uint32_t *in_messages,
145 dbus_uint32_t *in_bytes,
146 dbus_uint32_t *in_fds,
147 dbus_uint32_t *in_peak_bytes,
148 dbus_uint32_t *in_peak_fds,
149 dbus_uint32_t *out_messages,
150 dbus_uint32_t *out_bytes,
151 dbus_uint32_t *out_fds,
152 dbus_uint32_t *out_peak_bytes,
153 dbus_uint32_t *out_peak_fds);
156 /* if DBUS_ENABLE_EMBEDDED_TESTS */
157 const char* _dbus_connection_get_address (DBusConnection *connection);
159 /* This _dbus_bus_* stuff doesn't really belong here, but dbus-bus-internal.h seems
160 * silly for one function
163 * @addtogroup DBusBusInternals
167 void _dbus_bus_notify_shared_connection_disconnected_unlocked (DBusConnection *connection);
174 #endif /* DBUS_CONNECTION_INTERNAL_H */