diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-10-27 19:47:52 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-10-27 19:47:52 -0500 |
commit | 24d8a5722b0c72c01a04d0aa84995643db7dd705 (patch) | |
tree | 8c1533e4373731903e4cb57bfa24ace8e4da1a0c | |
parent | ed813455c2cd9e942e63b1dd6a1b64fdf6c048a8 (diff) | |
download | ofono-24d8a5722b0c72c01a04d0aa84995643db7dd705.tar.bz2 |
Refactor: replace netreg get_operator with mcc/mnc
The full operator information is useless as only mcc/mnc are really
required. The internal structures will be changing soon
-rw-r--r-- | include/netreg.h | 4 | ||||
-rw-r--r-- | src/cbs.c | 12 | ||||
-rw-r--r-- | src/network.c | 16 |
3 files changed, 22 insertions, 10 deletions
diff --git a/include/netreg.h b/include/netreg.h index a19409e3..e97917ff 100644 --- a/include/netreg.h +++ b/include/netreg.h @@ -112,8 +112,8 @@ int ofono_netreg_get_location(struct ofono_netreg *netreg); int ofono_netreg_get_cellid(struct ofono_netreg *netreg); int ofono_netreg_get_status(struct ofono_netreg *netreg); int ofono_netreg_get_technology(struct ofono_netreg *netreg); -const struct ofono_network_operator * - ofono_netreg_get_operator(struct ofono_netreg *netreg); +const char *ofono_netreg_get_mcc(struct ofono_netreg *netreg); +const char *ofono_netreg_get_mnc(struct ofono_netreg *netreg); #ifdef __cplusplus } @@ -767,7 +767,8 @@ static void netreg_watch(struct ofono_atom *atom, void *data) { struct ofono_cbs *cbs = data; - const struct ofono_network_operator *op; + const char *mcc; + const char *mnc; if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) { cbs->location_watch = 0; @@ -779,11 +780,12 @@ static void netreg_watch(struct ofono_atom *atom, cbs->location_watch = __ofono_netreg_add_status_watch(cbs->netreg, cbs_location_changed, cbs, NULL); - op = ofono_netreg_get_operator(cbs->netreg); + mcc = ofono_netreg_get_mcc(cbs->netreg); + mnc = ofono_netreg_get_mnc(cbs->netreg); - if (op) { - memcpy(cbs->mcc, op->mcc, sizeof(cbs->mcc)); - memcpy(cbs->mnc, op->mnc, sizeof(cbs->mnc)); + if (mcc && mnc) { + memcpy(cbs->mcc, mcc, sizeof(cbs->mcc)); + memcpy(cbs->mnc, mnc, sizeof(cbs->mnc)); } else { memset(cbs->mcc, 0, sizeof(cbs->mcc)); memset(cbs->mnc, 0, sizeof(cbs->mnc)); diff --git a/src/network.c b/src/network.c index 43ee5734..4d77eacd 100644 --- a/src/network.c +++ b/src/network.c @@ -1379,8 +1379,7 @@ int ofono_netreg_get_technology(struct ofono_netreg *netreg) return netreg->technology; } -const struct ofono_network_operator * - ofono_netreg_get_operator(struct ofono_netreg *netreg) +const char *ofono_netreg_get_mcc(struct ofono_netreg *netreg) { if (netreg == NULL) return NULL; @@ -1388,7 +1387,18 @@ const struct ofono_network_operator * if (netreg->current_operator == NULL) return NULL; - return netreg->current_operator->info; + return netreg->current_operator->info->mcc; +} + +const char *ofono_netreg_get_mnc(struct ofono_netreg *netreg) +{ + if (netreg == NULL) + return NULL; + + if (netreg->current_operator == NULL) + return NULL; + + return netreg->current_operator->info->mnc; } int ofono_netreg_driver_register(const struct ofono_netreg_driver *d) |