[PATCH 07/15] emulator: Add emulator status watches in netreg
Zhenhua Zhang
zhenhua.zhang at intel.com
Wed Jul 7 03:01:44 PDT 2010
Add dun_watch to watch emulator status update for netreg atom.
---
src/network.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/src/network.c b/src/network.c
index c6410a8..b9f0a08 100644
--- a/src/network.c
+++ b/src/network.c
@@ -80,6 +80,9 @@ struct ofono_netreg {
GKeyFile *settings;
char *imsi;
struct ofono_watchlist *status_watches;
+ struct ofono_emulator *dun;
+ unsigned int dun_watch;
+ unsigned int dun_status_watch;
const struct ofono_netreg_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -1613,6 +1616,37 @@ const char *ofono_netreg_get_mnc(struct ofono_netreg *netreg)
return netreg->current_operator->mnc;
}
+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_netreg *netreg = data;
+ struct ofono_emulator *e = __ofono_atom_get_data(atom);
+
+ if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
+ netreg->dun_status_watch = 0;
+ netreg->dun = NULL;
+ return;
+ }
+
+ netreg->dun = e;
+ netreg->dun_status_watch = __ofono_emulator_add_status_watch(e,
+ dun_status_watch, netreg, NULL);
+}
+
int ofono_netreg_driver_register(const struct ofono_netreg_driver *d)
{
DBG("driver: %p, name: %s", d, d->name);
@@ -1669,6 +1703,19 @@ static void netreg_unregister(struct ofono_atom *atom)
netreg->settings = NULL;
}
+ if (netreg->dun_watch) {
+ if (netreg->dun_status_watch) {
+ __ofono_emulator_remove_status_watch(netreg->dun,
+ netreg->dun_status_watch);
+ netreg->dun_status_watch = 0;
+ netreg->dun = NULL;
+ }
+
+ __ofono_modem_remove_atom_watch(modem, netreg->dun_watch);
+ netreg->dun_watch = 0;
+ netreg->dun = NULL;
+ }
+
g_dbus_unregister_interface(conn, path,
OFONO_NETWORK_REGISTRATION_INTERFACE);
ofono_modem_remove_interface(modem,
@@ -1773,6 +1820,7 @@ void ofono_netreg_register(struct ofono_netreg *netreg)
struct ofono_modem *modem = __ofono_atom_get_modem(netreg->atom);
const char *path = __ofono_atom_get_path(netreg->atom);
struct ofono_atom *sim_atom;
+ struct ofono_atom *dun_atom;
if (!g_dbus_register_interface(conn, path,
OFONO_NETWORK_REGISTRATION_INTERFACE,
@@ -1809,6 +1857,16 @@ void ofono_netreg_register(struct ofono_netreg *netreg)
sim_spn_read_cb, netreg);
}
+ netreg->dun_watch = __ofono_modem_add_atom_watch(modem,
+ OFONO_ATOM_TYPE_EMULATOR_DUN,
+ dun_watch, netreg, 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,
+ netreg);
+
__ofono_atom_register(netreg->atom, netreg_unregister);
}
--
1.6.3.3
More information about the ofono
mailing list