diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-05-28 13:22:23 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-05-28 13:22:23 +0000 |
commit | a1a1a2637ec9090c021dd83ed7707aabf5a8c0f4 (patch) | |
tree | 529bf2feeab6594457eb223ce50fea7459dc7123 | |
parent | 24cce397c3479e95f3e525da9285234fbafd2984 (diff) |
Add basic D-Bus skeleton
-rw-r--r-- | serial/main.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/serial/main.c b/serial/main.c index 24de70a5..fcff75f5 100644 --- a/serial/main.c +++ b/serial/main.c @@ -31,8 +31,7 @@ #include <bluetooth/bluetooth.h> -#include <glib.h> -#include <dbus/dbus.h> +#include <gdbus.h> #include "plugin.h" #include "device.h" @@ -40,18 +39,54 @@ #include "dbus-service.h" #include "manager.h" +#define SERIAL_INTERFACE "org.bluez.Serial" + +static DBusMessage *serial_connect(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + const char *target, *device = "/dev/rfcomm0"; + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &target, + DBUS_TYPE_INVALID) == FALSE) + return NULL; + + return g_dbus_create_reply(msg, DBUS_TYPE_STRING, &device, + DBUS_TYPE_INVALID); +} + +static DBusMessage *serial_disconnect(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + const char *device; + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &device, + DBUS_TYPE_INVALID) == FALSE) + return NULL; + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static GDBusMethodTable serial_methods[] = { + { "Connect", "s", "s", serial_connect }, + { "Disconnect", "s", "", serial_disconnect }, + { } +}; + static DBusConnection *conn; static int serial_probe(const char *path) { debug("path %s", path); - return 0; + return g_dbus_register_interface(conn, path, SERIAL_INTERFACE, + serial_methods, NULL, NULL, NULL, NULL); } static void serial_remove(const char *path) { debug("path %s", path); + + g_dbus_unregister_interface(conn, path, SERIAL_INTERFACE); } static struct btd_device_driver serial_driver = { |