1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-*/
3 #ifndef fooreservemonitorhfoo
4 #define fooreservemonitorhfoo
7 Copyright 2009 Lennart Poettering
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation files
11 (the "Software"), to deal in the Software without restriction,
12 including without limitation the rights to use, copy, modify, merge,
13 publish, distribute, sublicense, and/or sell copies of the Software,
14 and to permit persons to whom the Software is furnished to do so,
15 subject to the following conditions:
17 The above copyright notice and this permission notice shall be
18 included in all copies or substantial portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
24 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include <dbus/dbus.h>
36 typedef struct rm_monitor rm_monitor;
38 /* Prototype for a function that is called whenever the reservation
39 * device of a device changes. Use rm_monitor_busy() to find out the
41 typedef void (*rm_change_cb_t)(rm_monitor *m);
43 /* Creates a monitor for watching the lock status of a device. Returns
44 * 0 on success, a negative errno style return value on error. The
45 * DBus error might be set as well if the error was caused D-Bus. */
47 rm_monitor **m, /* On success a pointer to the newly allocated rm_device object will be filled in here */
48 DBusConnection *connection, /* Session bus (when D-Bus learns about user busses we should switch to user busses) */
49 const char *device_name, /* The device to monitor, e.g. "Audio0" */
50 rm_change_cb_t change_cb, /* Will be called whenever the lock status changes. May be NULL */
51 DBusError *error); /* If we fail due to a D-Bus related issue the error will be filled in here. May be NULL. */
53 /* Free a rm_monitor object */
54 void rm_release(rm_monitor *m);
56 /* Checks whether the device is currently reserved, and returns 1
57 * then, 0 if not, negative errno style error code value on error. */
58 int rm_busy(rm_monitor *m);
60 /* Attach a userdata pointer to an rm_monitor */
61 void rm_set_userdata(rm_monitor *m, void *userdata);
63 /* Query the userdata pointer from an rm_monitor. Returns NULL if no
64 * userdata was set. */
65 void* rm_get_userdata(rm_monitor *m);