summaryrefslogtreecommitdiff
path: root/plugins/ofono.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-11-21 18:28:01 +0100
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2011-12-12 17:33:58 +0100
commit999cebd01566b7aab95cef2b2d08416839821f92 (patch)
tree4c013e62c2cd8bec58e75aa75d9e645c384b2e90 /plugins/ofono.c
parent677b4e3484e52b76296150ab1e97ff456a170495 (diff)
downloadconnman-999cebd01566b7aab95cef2b2d08416839821f92.tar.gz
connman-999cebd01566b7aab95cef2b2d08416839821f92.tar.bz2
connman-999cebd01566b7aab95cef2b2d08416839821f92.zip
ofono: Listen to oFono's D-Bus signals
The intersting signals are from the Modem, SimManager ConnectionManager, ConnectionContext and the NetwworkRegistration interfaces. In this patch we add the empty functions.
Diffstat (limited to 'plugins/ofono.c')
-rw-r--r--plugins/ofono.c180
1 files changed, 180 insertions, 0 deletions
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 7d979c47..7fbdbac8 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -37,8 +37,88 @@
#include <connman/dbus.h>
#include <connman/log.h>
+#define OFONO_SERVICE "org.ofono"
+
+#define OFONO_MANAGER_INTERFACE OFONO_SERVICE ".Manager"
+#define OFONO_MODEM_INTERFACE OFONO_SERVICE ".Modem"
+#define OFONO_SIM_INTERFACE OFONO_SERVICE ".SimManager"
+#define OFONO_NETREG_INTERFACE OFONO_SERVICE ".NetworkRegistration"
+#define OFONO_CM_INTERFACE OFONO_SERVICE ".ConnectionManager"
+#define OFONO_CONTEXT_INTERFACE OFONO_SERVICE ".ConnectionContext"
+
+#define MODEM_ADDED "ModemAdded"
+#define MODEM_REMOVED "ModemRemoved"
+#define PROPERTY_CHANGED "PropertyChanged"
+#define CONTEXT_ADDED "ContextAdded"
+#define CONTEXT_REMOVED "ContextRemoved"
+
static DBusConnection *connection;
+static gboolean context_changed(DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ return TRUE;
+}
+
+static gboolean cm_context_added(DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ return TRUE;
+}
+
+static gboolean cm_context_removed(DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ return TRUE;
+}
+
+static gboolean netreg_changed(DBusConnection *connection, DBusMessage *message,
+ void *user_data)
+{
+ return TRUE;
+}
+
+static gboolean cm_changed(DBusConnection *connection, DBusMessage *message,
+ void *user_data)
+{
+ return TRUE;
+}
+
+static gboolean sim_changed(DBusConnection *connection, DBusMessage *message,
+ void *user_data)
+{
+ return TRUE;
+}
+
+static gboolean modem_changed(DBusConnection *connection, DBusMessage *message,
+ void *user_data)
+{
+ return TRUE;
+}
+
+static gboolean modem_added(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ return TRUE;
+}
+
+static gboolean modem_removed(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ return TRUE;
+}
+
+static void ofono_connect(DBusConnection *conn, void *user_data)
+{
+}
+
+static void ofono_disconnect(DBusConnection *conn, void *user_data)
+{
+}
+
static int network_probe(struct connman_network *network)
{
DBG("network %p", network);
@@ -109,6 +189,17 @@ static struct connman_device_driver modem_driver = {
.disable = modem_disable,
};
+static guint watch;
+static guint modem_added_watch;
+static guint modem_removed_watch;
+static guint modem_watch;
+static guint cm_watch;
+static guint sim_watch;
+static guint context_added_watch;
+static guint context_removed_watch;
+static guint netreg_watch;
+static guint context_watch;
+
static int ofono_init(void)
{
int err;
@@ -119,6 +210,74 @@ static int ofono_init(void)
if (connection == NULL)
return -EIO;
+ watch = g_dbus_add_service_watch(connection,
+ OFONO_SERVICE, ofono_connect,
+ ofono_disconnect, NULL, NULL);
+
+ modem_added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_MANAGER_INTERFACE,
+ MODEM_ADDED,
+ modem_added,
+ NULL, NULL);
+
+ modem_removed_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_MANAGER_INTERFACE,
+ MODEM_REMOVED,
+ modem_removed,
+ NULL, NULL);
+
+ modem_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_MODEM_INTERFACE,
+ PROPERTY_CHANGED,
+ modem_changed,
+ NULL, NULL);
+
+ cm_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_CM_INTERFACE,
+ PROPERTY_CHANGED,
+ cm_changed,
+ NULL, NULL);
+
+ sim_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_SIM_INTERFACE,
+ PROPERTY_CHANGED,
+ sim_changed,
+ NULL, NULL);
+
+ context_added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_CM_INTERFACE,
+ CONTEXT_ADDED,
+ cm_context_added,
+ NULL, NULL);
+
+ context_removed_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_CM_INTERFACE,
+ CONTEXT_REMOVED,
+ cm_context_removed,
+ NULL, NULL);
+
+ context_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_CONTEXT_INTERFACE,
+ PROPERTY_CHANGED,
+ context_changed,
+ NULL, NULL);
+
+ netreg_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
+ OFONO_NETREG_INTERFACE,
+ PROPERTY_CHANGED,
+ netreg_changed,
+ NULL, NULL);
+
+
+ if (watch == 0 || modem_added_watch == 0 || modem_removed_watch == 0 ||
+ modem_watch == 0 || cm_watch == 0 || sim_watch == 0 ||
+ context_added_watch == 0 ||
+ context_removed_watch == 0 ||
+ context_watch == 0 || netreg_watch == 0) {
+ err = -EIO;
+ goto remove;
+ }
+
err = connman_network_driver_register(&network_driver);
if (err < 0)
goto remove;
@@ -132,6 +291,16 @@ static int ofono_init(void)
return 0;
remove:
+ g_dbus_remove_watch(connection, netreg_watch);
+ g_dbus_remove_watch(connection, context_watch);
+ g_dbus_remove_watch(connection, context_removed_watch);
+ g_dbus_remove_watch(connection, context_added_watch);
+ g_dbus_remove_watch(connection, sim_watch);
+ g_dbus_remove_watch(connection, cm_watch);
+ g_dbus_remove_watch(connection, modem_watch);
+ g_dbus_remove_watch(connection, modem_removed_watch);
+ g_dbus_remove_watch(connection, modem_added_watch);
+ g_dbus_remove_watch(connection, watch);
dbus_connection_unref(connection);
return err;
@@ -144,6 +313,17 @@ static void ofono_exit(void)
connman_device_driver_unregister(&modem_driver);
connman_network_driver_unregister(&network_driver);
+ g_dbus_remove_watch(connection, netreg_watch);
+ g_dbus_remove_watch(connection, context_watch);
+ g_dbus_remove_watch(connection, context_removed_watch);
+ g_dbus_remove_watch(connection, context_added_watch);
+ g_dbus_remove_watch(connection, sim_watch);
+ g_dbus_remove_watch(connection, cm_watch);
+ g_dbus_remove_watch(connection, modem_watch);
+ g_dbus_remove_watch(connection, modem_added_watch);
+ g_dbus_remove_watch(connection, modem_removed_watch);
+ g_dbus_remove_watch(connection, watch);
+
dbus_connection_unref(connection);
}