D-Bus 1.16.0
dbus-server.h
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2/* dbus-server.h DBusServer object
3 *
4 * Copyright (C) 2002, 2003 Red Hat Inc.
5 *
6 * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
7 *
8 * Licensed under the Academic Free License version 2.1
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 *
24 */
25#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION)
26#error "Only <dbus/dbus.h> can be included directly, this file may disappear or change contents."
27#endif
28
29#ifndef DBUS_SERVER_H
30#define DBUS_SERVER_H
31
32#include <dbus/dbus-errors.h>
33#include <dbus/dbus-macros.h>
34#include <dbus/dbus-message.h>
35#include <dbus/dbus-connection.h>
36#include <dbus/dbus-protocol.h>
37
39
45typedef struct DBusServer DBusServer;
46
50typedef void (* DBusNewConnectionFunction) (DBusServer *server,
51 DBusConnection *new_connection,
52 void *data);
53
54DBUS_EXPORT
56 DBusError *error);
57DBUS_EXPORT
59DBUS_EXPORT
60void dbus_server_unref (DBusServer *server);
61DBUS_EXPORT
63DBUS_EXPORT
64dbus_bool_t dbus_server_get_is_connected (DBusServer *server);
65DBUS_EXPORT
67DBUS_EXPORT
68char* dbus_server_get_id (DBusServer *server);
69DBUS_EXPORT
72 void *data,
73 DBusFreeFunction free_data_function);
74DBUS_EXPORT
76 DBusAddWatchFunction add_function,
77 DBusRemoveWatchFunction remove_function,
78 DBusWatchToggledFunction toggled_function,
79 void *data,
80 DBusFreeFunction free_data_function);
81DBUS_EXPORT
83 DBusAddTimeoutFunction add_function,
84 DBusRemoveTimeoutFunction remove_function,
85 DBusTimeoutToggledFunction toggled_function,
86 void *data,
87 DBusFreeFunction free_data_function);
88DBUS_EXPORT
90 const char **mechanisms);
91
92DBUS_EXPORT
93dbus_bool_t dbus_server_allocate_data_slot (dbus_int32_t *slot_p);
94DBUS_EXPORT
95void dbus_server_free_data_slot (dbus_int32_t *slot_p);
96DBUS_EXPORT
97dbus_bool_t dbus_server_set_data (DBusServer *server,
98 int slot,
99 void *data,
100 DBusFreeFunction free_data_func);
101DBUS_EXPORT
102void* dbus_server_get_data (DBusServer *server,
103 int slot);
104
117static inline void
118dbus_clear_server (DBusServer **pointer_to_server)
119{
120 _dbus_clear_pointer_impl (DBusServer, pointer_to_server, dbus_server_unref);
121}
122
126
127#endif /* DBUS_SERVER_H */
void(* DBusWatchToggledFunction)(DBusWatch *watch, void *data)
Called when dbus_watch_get_enabled() may return a different value than it did before.
dbus_bool_t(* DBusAddWatchFunction)(DBusWatch *watch, void *data)
Called when libdbus needs a new watch to be monitored by the main loop.
void(* DBusTimeoutToggledFunction)(DBusTimeout *timeout, void *data)
Called when dbus_timeout_get_enabled() may return a different value than it did before.
dbus_bool_t(* DBusAddTimeoutFunction)(DBusTimeout *timeout, void *data)
Called when libdbus needs a new timeout to be monitored by the main loop.
void(* DBusRemoveWatchFunction)(DBusWatch *watch, void *data)
Called when libdbus no longer needs a watch to be monitored by the main loop.
void(* DBusRemoveTimeoutFunction)(DBusTimeout *timeout, void *data)
Called when libdbus no longer needs a timeout to be monitored by the main loop.
#define DBUS_BEGIN_DECLS
Macro used prior to declaring functions in the D-Bus header files.
Definition dbus-macros.h:36
#define DBUS_END_DECLS
Macro used after declaring functions in the D-Bus header files.
Definition dbus-macros.h:37
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition dbus-memory.h:65
dbus_bool_t dbus_server_allocate_data_slot(dbus_int32_t *slot_p)
Allocates an integer ID to be used for storing application-specific data on any DBusServer.
void dbus_server_disconnect(DBusServer *server)
Releases the server's address and stops listening for new clients.
dbus_bool_t dbus_server_set_auth_mechanisms(DBusServer *server, const char **mechanisms)
Sets the authentication mechanisms that this server offers to clients, as a NULL-terminated array of ...
char * dbus_server_get_id(DBusServer *server)
Returns the unique ID of the server, as a newly-allocated string which must be freed by the caller.
DBusServer * dbus_server_listen(const char *address, DBusError *error)
Listens for new connections on the given address.
char * dbus_server_get_address(DBusServer *server)
Returns the address of the server, as a newly-allocated string which must be freed by the caller.
dbus_bool_t dbus_server_get_is_connected(DBusServer *server)
Returns TRUE if the server is still listening for new connections.
void dbus_server_unref(DBusServer *server)
Decrements the reference count of a DBusServer.
void dbus_server_set_new_connection_function(DBusServer *server, DBusNewConnectionFunction function, void *data, DBusFreeFunction free_data_function)
Sets a function to be used for handling new connections.
dbus_bool_t dbus_server_set_watch_functions(DBusServer *server, DBusAddWatchFunction add_function, DBusRemoveWatchFunction remove_function, DBusWatchToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
Sets the watch functions for the server.
dbus_bool_t dbus_server_set_data(DBusServer *server, int slot, void *data, DBusFreeFunction free_data_func)
Stores a pointer on a DBusServer, along with an optional function to be used for freeing the data whe...
DBusServer * dbus_server_ref(DBusServer *server)
Increments the reference count of a DBusServer.
void * dbus_server_get_data(DBusServer *server, int slot)
Retrieves data previously set with dbus_server_set_data().
void dbus_server_free_data_slot(dbus_int32_t *slot_p)
Deallocates a global ID for server data slots.
dbus_bool_t dbus_server_set_timeout_functions(DBusServer *server, DBusAddTimeoutFunction add_function, DBusRemoveTimeoutFunction remove_function, DBusTimeoutToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
Sets the timeout functions for the server.
void(* DBusNewConnectionFunction)(DBusServer *server, DBusConnection *new_connection, void *data)
Called when a new connection to the server is available.
Definition dbus-server.h:50
Implementation details of DBusConnection.
Object representing an exception.
Definition dbus-errors.h:51
Internals of DBusServer object.
char * address
Address this server is listening on.