libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-dbus.h
Go to the documentation of this file.
1 /*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2019 Andy Green <andy@warmcat.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 *
24 * must be included manually as
25 *
26 * #include <libwebsockets/lws-dbus.h>
27 *
28 * if dbus apis needed
29 */
30
31#if !defined(__LWS_DBUS_H__)
32#define __LWS_DBUS_H__
33
34#include <dbus/dbus.h>
35
36/* helper type to simplify implementing methods as individual functions */
37typedef DBusHandlerResult (*lws_dbus_message_handler)(DBusConnection *conn,
38 DBusMessage *message, DBusMessage **reply, void *d);
39
40struct lws_dbus_ctx;
41typedef void (*lws_dbus_closing_t)(struct lws_dbus_ctx *ctx);
42
44 struct lws_dll2_owner owner; /* dbusserver ctx: HEAD of accepted list */
45 struct lws_dll2 next; /* dbusserver ctx: HEAD of accepted list */
46 struct lws_vhost *vh; /* the vhost we logically bind to in lws */
47 int tsi; /* the lws thread service index (0 if only one service
48 thread as is the default */
53
54 char hup;
56
57 /* cb_closing callback will be called after the connection and this
58 * related ctx struct have effectively gone out of scope.
59 *
60 * The callback should close and clean up the connection and free the
61 * ctx.
62 */
64};
65
66/**
67 * lws_dbus_connection_setup() - bind dbus connection object to lws event loop
68 *
69 * \param ctx: additional information about the connection
70 * \param conn: the DBusConnection object to bind
71 *
72 * This configures a DBusConnection object to use lws for watchers and timeout
73 * operations.
74 */
75LWS_VISIBLE LWS_EXTERN int
76lws_dbus_connection_setup(struct lws_dbus_ctx *ctx, DBusConnection *conn,
77 lws_dbus_closing_t cb_closing);
78
79/**
80 * lws_dbus_server_listen() - bind dbus connection object to lws event loop
81 *
82 * \param ctx: additional information about the connection
83 * \param ads: the DBUS address to listen on, eg, "unix:abstract=mysocket"
84 * \param err: a DBusError object to take any extra error information
85 * \param new_conn: a callback function to prepare new accepted connections
86 *
87 * This creates a DBusServer and binds it to the lws event loop, and your
88 * callback to accept new connections.
89 */
90LWS_VISIBLE LWS_EXTERN DBusServer *
91lws_dbus_server_listen(struct lws_dbus_ctx *ctx, const char *ads,
92 DBusError *err, DBusNewConnectionFunction new_conn);
93
94#endif
struct lws_vhost * vh
Definition: lws-dbus.h:46
DBusConnection * conn
Definition: lws-dbus.h:49
LWS_VISIBLE LWS_EXTERN int lws_dbus_connection_setup(struct lws_dbus_ctx *ctx, DBusConnection *conn, lws_dbus_closing_t cb_closing)
char hup
Definition: lws-dbus.h:54
DBusServer * dbs
Definition: lws-dbus.h:50
void(* lws_dbus_closing_t)(struct lws_dbus_ctx *ctx)
Definition: lws-dbus.h:41
char timeouts
Definition: lws-dbus.h:55
lws_dbus_closing_t cb_closing
Definition: lws-dbus.h:63
DBusPendingCall * pc
Definition: lws-dbus.h:52
struct lws_dll2 next
Definition: lws-dbus.h:45
struct lws_dll2_owner owner
Definition: lws-dbus.h:44