From: Zhenhua Zhang <[email protected]>
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 4cb5eaf..c7793ea 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -82,6 +82,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 {
@@ -2014,6 +2017,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);
@@ -2175,6 +2211,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_CONNECTION_MANAGER_INTERFACE);
g_dbus_unregister_interface(conn, path,
@@ -2464,6 +2512,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_CONNECTION_MANAGER_INTERFACE,
@@ -2500,6 +2549,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.1
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono