OSDN Git Service

Update plugin interface registration
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 8 Jun 2008 21:21:54 +0000 (21:21 +0000)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 8 Jun 2008 21:21:54 +0000 (21:21 +0000)
input/main.c
network/main.c
serial/main.c

index 6b5e7c8..6a667f5 100644 (file)
@@ -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)
index 106c2a7..edfd075 100644 (file)
 #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 = {
index ee1cb9f..b042e2e 100644 (file)
 #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)