Add dun_watch to watch emulator status update in gprs atom. So that gprs
atom could get notified when we get request to create new PPP connection
from DUN client;
---
src/gprs.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index 6c6f07e..8002cf4 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -80,6 +80,9 @@ struct ofono_gprs {
const struct ofono_gprs_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+ struct ofono_emulator *dun;
+ unsigned int dun_watch;
+ unsigned int dun_status_watch;
};
struct ofono_gprs_context {
@@ -1459,6 +1462,39 @@ void ofono_gprs_context_deactivated(struct ofono_gprs_context *gc,
}
}
+static void dun_status_watch(struct ofono_emulator *e,
+ enum ofono_emulator_status status,
+ void *data, void *user_data)
+{
+ if (e == NULL)
+ return;
+
+ switch (status) {
+ default:
+ break;
+ }
+}
+
+static void dun_watch(struct ofono_atom *atom,
+ enum ofono_atom_watch_condition cond,
+ void *data)
+{
+ struct ofono_gprs *gprs = data;
+ struct ofono_emulator *e = __ofono_atom_get_data(atom);
+
+ if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
+ gprs->dun_status_watch = 0;
+ gprs->dun = NULL;
+ return;
+ }
+
+ DBG("");
+
+ gprs->dun = e;
+ gprs->dun_status_watch = __ofono_emulator_add_status_watch(e,
+ dun_status_watch, gprs, NULL);
+}
+
int ofono_gprs_context_driver_register(const struct ofono_gprs_context_driver *d)
{
DBG("driver: %p, name: %s", d, d->name);
@@ -1608,6 +1644,18 @@ static void gprs_unregister(struct ofono_atom *atom)
gprs->netreg = NULL;
}
+ if (gprs->dun_watch) {
+ if (gprs->dun_status_watch) {
+ __ofono_emulator_remove_status_watch(gprs->dun,
+ gprs->dun_status_watch);
+ gprs->dun_status_watch = 0;
+ }
+
+ __ofono_modem_remove_atom_watch(modem, gprs->dun_watch);
+ gprs->dun_watch = 0;
+ gprs->dun = NULL;
+ }
+
ofono_modem_remove_interface(modem,
OFONO_DATA_CONNECTION_MANAGER_INTERFACE);
g_dbus_unregister_interface(conn, path,
@@ -1862,6 +1910,7 @@ void ofono_gprs_register(struct ofono_gprs *gprs)
const char *path = __ofono_atom_get_path(gprs->atom);
struct ofono_atom *netreg_atom;
struct ofono_atom *sim_atom;
+ struct ofono_atom *dun_atom;
if (!g_dbus_register_interface(conn, path,
OFONO_DATA_CONNECTION_MANAGER_INTERFACE,
@@ -1895,6 +1944,17 @@ void ofono_gprs_register(struct ofono_gprs *gprs)
netreg_watch(netreg_atom,
OFONO_ATOM_WATCH_CONDITION_REGISTERED, gprs);
+ gprs->dun_watch = __ofono_modem_add_atom_watch(modem,
+ OFONO_ATOM_TYPE_EMULATOR_DUN,
+ dun_watch, gprs, NULL);
+
+ dun_atom = __ofono_modem_find_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_DUN);
+
+ if (dun_atom && __ofono_atom_get_registered(dun_atom))
+ dun_watch(dun_atom,
+ OFONO_ATOM_WATCH_CONDITION_REGISTERED, gprs);
+
__ofono_atom_register(gprs->atom, gprs_unregister);
}
--
1.7.0.4