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 --- network/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'network') 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 = { -- cgit