summaryrefslogtreecommitdiff
path: root/plugins/dundee.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2012-06-01 16:11:20 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-06-04 16:18:01 +0300
commitcdc1ac15167d96481c994e22cd139e050b6da501 (patch)
tree2ecda2825b51de4f93f6338cbbc960e17df61272 /plugins/dundee.c
parent73ab46064d81eea7d29ec325af18635a90d77a27 (diff)
downloadconnman-cdc1ac15167d96481c994e22cd139e050b6da501.tar.gz
connman-cdc1ac15167d96481c994e22cd139e050b6da501.tar.bz2
connman-cdc1ac15167d96481c994e22cd139e050b6da501.zip
dundee: Watch service on D-Bus
Diffstat (limited to 'plugins/dundee.c')
-rw-r--r--plugins/dundee.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/dundee.c b/plugins/dundee.c
index 9a3e29f1..c61a7436 100644
--- a/plugins/dundee.c
+++ b/plugins/dundee.c
@@ -25,14 +25,30 @@
#include <errno.h>
+#include <gdbus.h>
+
#define CONNMAN_API_SUBJECT_TO_CHANGE
#include <connman/plugin.h>
#include <connman/device.h>
#include <connman/network.h>
#include <connman/dbus.h>
+#define DUNDEE_SERVICE "org.ofono.dundee"
+
static DBusConnection *connection;
+static GHashTable *dundee_devices = NULL;
+
+struct dundee_data {
+};
+
+static void device_destroy(gpointer data)
+{
+ struct dundee_data *info = data;
+
+ g_free(info);
+}
+
static int network_probe(struct connman_network *network)
{
DBG("network %p", network);
@@ -103,6 +119,24 @@ static struct connman_device_driver dundee_driver = {
.disable = dundee_disable,
};
+static void dundee_connect(DBusConnection *connection, void *user_data)
+{
+ DBG("connection %p", connection);
+
+ dundee_devices = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, device_destroy);
+}
+
+static void dundee_disconnect(DBusConnection *connection, void *user_data)
+{
+ DBG("connection %p", connection);
+
+ g_hash_table_destroy(dundee_devices);
+ dundee_devices = NULL;
+}
+
+static guint watch;
+
static int dundee_init(void)
{
int err;
@@ -111,6 +145,14 @@ static int dundee_init(void)
if (connection == NULL)
return -EIO;
+ watch = g_dbus_add_service_watch(connection, DUNDEE_SERVICE,
+ dundee_connect, dundee_disconnect, NULL, NULL);
+
+ if (watch == 0) {
+ err = -EIO;
+ goto remove;
+ }
+
err = connman_network_driver_register(&network_driver);
if (err < 0)
goto remove;
@@ -124,6 +166,8 @@ static int dundee_init(void)
return 0;
remove:
+ g_dbus_remove_watch(connection, watch);
+
dbus_connection_unref(connection);
return err;
@@ -131,6 +175,8 @@ remove:
static void dundee_exit(void)
{
+ g_dbus_remove_watch(connection, watch);
+
connman_device_driver_unregister(&dundee_driver);
connman_network_driver_unregister(&network_driver);