blob: 90ab8f614f857a6e5da665ce2007ad8905a2c8f9 [file] [log] [blame]
David Herrmann59ab9002013-10-22 00:28:06 +02001/*
2 * Copyright © 2013 David Herrmann <dh.herrmann@gmail.com>
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 */
22
23#ifndef _WESTON_DBUS_H_
24#define _WESTON_DBUS_H_
25
26#include "config.h"
27
28#include <errno.h>
29#include <wayland-server.h>
30
31#include "compositor.h"
32
33#ifdef HAVE_DBUS
34
35#include <dbus/dbus.h>
36
37/*
38 * weston_dbus_open() - Open new dbus connection
39 *
40 * Opens a new dbus connection to the bus given as @bus. It automatically
41 * integrates the new connection into the main-loop @loop. The connection
42 * itself is returned in @out.
43 * This also returns a context source used for dbus dispatching. It is
44 * returned on success in @ctx_out and must be passed to weston_dbus_close()
45 * unchanged. You must not access it from outside of a dbus helper!
46 *
47 * Returns 0 on success, negative error code on failure.
48 */
49int weston_dbus_open(struct wl_event_loop *loop, DBusBusType bus,
50 DBusConnection **out, struct wl_event_source **ctx_out);
51
52/*
53 * weston_dbus_close() - Close dbus connection
54 *
55 * Closes a dbus connection that was previously opened via weston_dbus_open().
56 * It unbinds the connection from the main-loop it was previously bound to,
57 * closes the dbus connection and frees all resources. If you want to access
58 * @c after this call returns, you must hold a dbus-reference to it. But
59 * notice that the connection is closed after this returns so it cannot be
60 * used to spawn new dbus requests.
61 * You must pass the context source returns by weston_dbus_open() as @ctx.
62 */
63void weston_dbus_close(DBusConnection *c, struct wl_event_source *ctx);
64
65#endif /* HAVE_DBUS */
66
67#endif // _WESTON_DBUS_H_