diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-06-08 21:21:54 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-06-08 21:21:54 +0000 |
commit | 0f62b72c8564608f849b3bbe54bf48db07c45015 (patch) | |
tree | c89510b81cfbea07853d8214de51767117490c5a | |
parent | 6a87d1b7e5ad1046abfcc2e89cc924b6e1d0db67 (diff) |
Update plugin interface registration
-rw-r--r-- | input/main.c | 8 | ||||
-rw-r--r-- | network/main.c | 43 | ||||
-rw-r--r-- | 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) |