From a1a1a2637ec9090c021dd83ed7707aabf5a8c0f4 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 28 May 2008 13:22:23 +0000 Subject: Add basic D-Bus skeleton --- serial/main.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file 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 -#include -#include +#include #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 = { -- cgit