From 0f62b72c8564608f849b3bbe54bf48db07c45015 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 8 Jun 2008 21:21:54 +0000 Subject: Update plugin interface registration --- input/main.c | 8 ++++++-- network/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ serial/main.c | 12 ++++++++---- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/input/main.c b/input/main.c index 6b5e7c8f..6a667f51 100644 --- a/input/main.c +++ b/input/main.c @@ -79,8 +79,12 @@ static int input_probe(const char *path) { DBG("path %s", path); - return g_dbus_register_interface(conn, path, INPUT_INTERFACE, - input_methods, input_signals, NULL, NULL, NULL); + if (g_dbus_register_interface(conn, path, INPUT_INTERFACE, + input_methods, input_signals, NULL, + NULL, NULL) == FALSE) + return -1; + + return 0; } static void input_remove(const char *path) diff --git a/network/main.c b/network/main.c index 106c2a76..edfd0757 100644 --- a/network/main.c +++ b/network/main.c @@ -44,18 +44,61 @@ #define NAP_UUID "00001116-0000-1000-8000-00805f9b34fb" #define GN_UUID "00001117-0000-1000-8000-00805f9b34fb" +#define NETWORK_INTERFACE "org.bluez.Network" + +static DBusMessage *network_connect(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + const char *target, *device = "bnep0"; + + 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 *network_disconnect(DBusConnection *conn, + DBusMessage *msg, void *user_data) +{ + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID) == FALSE) + return NULL; + + return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); +} + +static GDBusMethodTable network_methods[] = { + { "Connect", "s", "s", network_connect }, + { "Disconnect", "", "", network_disconnect }, + { } +}; + +static GDBusSignalTable network_signals[] = { + { "Connected", "ss" }, + { "Disconnected", "s" }, + { } +}; + static DBusConnection *conn; static int network_probe(const char *path) { DBG("path %s", path); + if (g_dbus_register_interface(conn, path, NETWORK_INTERFACE, + network_methods, network_signals, NULL, + NULL, NULL) == FALSE) + return -1; + return 0; } static void network_remove(const char *path) { DBG("path %s", path); + + g_dbus_unregister_interface(conn, path, NETWORK_INTERFACE); } static struct btd_device_driver network_driver = { diff --git a/serial/main.c b/serial/main.c index ee1cb9f9..b042e2e7 100644 --- a/serial/main.c +++ b/serial/main.c @@ -38,11 +38,11 @@ #include "logging.h" #include "manager.h" -#define SERIAL_INTERFACE "org.bluez.Serial" - #define SERIAL_PORT_UUID "00001101-0000-1000-8000-00805F9B34FB" #define DIALUP_NET_UUID "00001103-0000-1000-8000-00805F9B34FB" +#define SERIAL_INTERFACE "org.bluez.Serial" + static DBusMessage *serial_connect(DBusConnection *conn, DBusMessage *msg, void *user_data) { @@ -80,8 +80,12 @@ static int serial_probe(const char *path) { DBG("path %s", path); - return g_dbus_register_interface(conn, path, SERIAL_INTERFACE, - serial_methods, NULL, NULL, NULL, NULL); + if (g_dbus_register_interface(conn, path, SERIAL_INTERFACE, + serial_methods, NULL, NULL, + NULL, NULL) == FALSE) + return -1; + + return 0; } static void serial_remove(const char *path) -- cgit