[PATCH 06/15] emulator: Add emulator status watches in gprs atom
Zhenhua Zhang
zhenhua.zhang at intel.com
Wed Jul 7 03:01:43 PDT 2010
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 | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index 829a22c..dd58c51 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -77,6 +77,10 @@ struct ofono_gprs {
char *imsi;
DBusMessage *pending;
struct ofono_gprs_context *context_driver;
+ struct ofono_watchlist *status_watches;
+ struct ofono_emulator *dun;
+ unsigned int dun_watch;
+ unsigned int dun_status_watch;
const struct ofono_gprs_driver *driver;
void *driver_data;
struct ofono_atom *atom;
@@ -1386,6 +1390,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);
@@ -1535,6 +1572,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,
@@ -1778,6 +1827,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,
@@ -1792,6 +1842,8 @@ void ofono_gprs_register(struct ofono_gprs *gprs)
ofono_modem_add_interface(modem,
OFONO_DATA_CONNECTION_MANAGER_INTERFACE);
+ gprs->status_watches = __ofono_watchlist_new(g_free);
+
sim_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
if (sim_atom) {
@@ -1811,6 +1863,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.6.3.3
More information about the ofono
mailing list