From: Daniel Wagner <[email protected]>
---
plugins/elect.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/plugins/elect.c b/plugins/elect.c
index ddd641b..7528653 100644
--- a/plugins/elect.c
+++ b/plugins/elect.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 ELECT_SERVICE "org.ofono.elect"
+
static DBusConnection *connection;
+static GHashTable *elect_devices = NULL;
+
+struct elect_data {
+};
+
+static void device_destroy(gpointer data)
+{
+ struct elect_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 elect_driver = {
.disable = elect_disable,
};
+static void elect_connect(DBusConnection *connection, void *user_data)
+{
+ DBG("connection %p", connection);
+
+ elect_devices = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, device_destroy);
+}
+
+static void elect_disconnect(DBusConnection *connection, void *user_data)
+{
+ DBG("connection %p", connection);
+
+ g_hash_table_destroy(elect_devices);
+ elect_devices = NULL;
+}
+
+static guint watch;
+
static int elect_init(void)
{
int err;
@@ -111,6 +145,14 @@ static int elect_init(void)
if (connection == NULL)
return -EIO;
+ watch = g_dbus_add_service_watch(connection, ELECT_SERVICE,
+ elect_connect, elect_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 elect_init(void)
return 0;
remove:
+ g_dbus_remove_watch(connection, watch);
+
dbus_connection_unref(connection);
return err;
@@ -131,6 +175,8 @@ remove:
static void elect_exit(void)
{
+ g_dbus_remove_watch(connection, watch);
+
connman_device_driver_unregister(&elect_driver);
connman_network_driver_unregister(&network_driver);
--
1.7.8.110.g4cb5d1
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman