2 * libwebsockets - small server side websockets and web server implementation
4 * Copyright (C) 2010-2019 Andy Green <andy@warmcat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation:
9 * version 2.1 of the License.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * must be included manually as
23 * #include <libwebsockets/lws-dbus.h>
28 #if !defined(__LWS_DBUS_H__)
29 #define __LWS_DBUS_H__
31 #include <dbus/dbus.h>
33 /* helper type to simplify implementing methods as individual functions */
34 typedef DBusHandlerResult (*lws_dbus_message_handler)(DBusConnection *conn,
35 DBusMessage *message, DBusMessage **reply, void *d);
38 typedef void (*lws_dbus_closing_t)(struct lws_dbus_ctx *ctx);
41 struct lws_dll2_owner owner; /* dbusserver ctx: HEAD of accepted list */
42 struct lws_dll2 next; /* dbusserver ctx: HEAD of accepted list */
43 struct lws_vhost *vh; /* the vhost we logically bind to in lws */
44 int tsi; /* the lws thread service index (0 if only one service
45 thread as is the default */
54 /* cb_closing callback will be called after the connection and this
55 * related ctx struct have effectively gone out of scope.
57 * The callback should close and clean up the connection and free the
60 lws_dbus_closing_t cb_closing;
64 * lws_dbus_connection_setup() - bind dbus connection object to lws event loop
66 * \param ctx: additional information about the connection
67 * \param conn: the DBusConnection object to bind
69 * This configures a DBusConnection object to use lws for watchers and timeout
72 LWS_VISIBLE LWS_EXTERN int
73 lws_dbus_connection_setup(struct lws_dbus_ctx *ctx, DBusConnection *conn,
74 lws_dbus_closing_t cb_closing);
77 * lws_dbus_server_listen() - bind dbus connection object to lws event loop
79 * \param ctx: additional information about the connection
80 * \param ads: the DBUS address to listen on, eg, "unix:abstract=mysocket"
81 * \param err: a DBusError object to take any extra error information
82 * \param new_conn: a callback function to prepare new accepted connections
84 * This creates a DBusServer and binds it to the lws event loop, and your
85 * callback to accept new connections.
87 LWS_VISIBLE LWS_EXTERN DBusServer *
88 lws_dbus_server_listen(struct lws_dbus_ctx *ctx, const char *ads,
89 DBusError *err, DBusNewConnectionFunction new_conn);