summaryrefslogtreecommitdiffstats
path: root/serial
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-05-28 13:22:23 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-05-28 13:22:23 +0000
commita1a1a2637ec9090c021dd83ed7707aabf5a8c0f4 (patch)
tree529bf2feeab6594457eb223ce50fea7459dc7123 /serial
parent24cce397c3479e95f3e525da9285234fbafd2984 (diff)
Add basic D-Bus skeleton
Diffstat (limited to 'serial')
-rw-r--r--serial/main.c41
1 files 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 <bluetooth/bluetooth.h>
-#include <glib.h>
-#include <dbus/dbus.h>
+#include <gdbus.h>
#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 = {