libwebsockets
Lightweight C library for HTML5 websockets
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 */
37 typedef DBusHandlerResult (*lws_dbus_message_handler)(DBusConnection *conn,
38  DBusMessage *message, DBusMessage **reply, void *d);
39 
40 struct lws_dbus_ctx;
41 typedef void (*lws_dbus_closing_t)(struct lws_dbus_ctx *ctx);
42 
43 struct lws_dbus_ctx {
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 */
49  DBusConnection *conn;
50  DBusServer *dbs;
51  DBusWatch *w[4];
52  DBusPendingCall *pc;
53 
54  char hup;
55  char timeouts;
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 
76 lws_dbus_connection_setup(struct lws_dbus_ctx *ctx, DBusConnection *conn,
77  lws_dbus_closing_t cb_closing);
78 
90 LWS_VISIBLE LWS_EXTERN DBusServer *
91 lws_dbus_server_listen(struct lws_dbus_ctx *ctx, const char *ads,
92  DBusError *err, DBusNewConnectionFunction new_conn);
93 
94 #endif
#define LWS_EXTERN
#define LWS_VISIBLE
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
LWS_VISIBLE LWS_EXTERN DBusServer * lws_dbus_server_listen(struct lws_dbus_ctx *ctx, const char *ads, DBusError *err, DBusNewConnectionFunction new_conn)
DBusWatch * w[4]
Definition: lws-dbus.h:51
struct lws_dll2 next
Definition: lws-dbus.h:45
struct lws_dll2_owner owner
Definition: lws-dbus.h:44
DBusHandlerResult(* lws_dbus_message_handler)(DBusConnection *conn, DBusMessage *message, DBusMessage **reply, void *d)
Definition: lws-dbus.h:37