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
This commit is contained in:
Denis Kenzior 2009-10-27 19:47:52 -05:00
parent ed813455c2
commit 24d8a5722b
3 changed files with 22 additions and 10 deletions

View File

@ -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
}

View File

@ -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));

View File

@ -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)