static void ril_creg_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_status_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct reply_reg_state *reply; DBG(""); if (message->error != RIL_E_SUCCESS) { ofono_error("%s: failed to pull registration state", __func__); goto error; } if ((reply = g_ril_reply_parse_voice_reg_state(nd->ril, message)) == NULL) goto error; nd->tech = reply->tech; CALLBACK_WITH_SUCCESS(cb, reply->status, reply->lac, reply->ci, ril_tech_to_access_tech(reply->tech), cbd->data); g_free(reply); return; error: CALLBACK_WITH_FAILURE(cb, -1, -1, -1, -1, cbd->data); }
static void ril_cops_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_operator_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct reply_operator *reply; struct ofono_network_operator op; if (message->error != RIL_E_SUCCESS) { ofono_error("%s: failed to retrive the current operator", __func__); goto error; } if ((reply = g_ril_reply_parse_operator(nd->ril, message)) == NULL) goto error; set_oper_name(reply, &op); extract_mcc_mnc(reply->numeric, op.mcc, op.mnc); /* Set to current */ op.status = OPERATOR_STATUS_CURRENT; op.tech = ril_tech_to_access_tech(nd->tech); CALLBACK_WITH_SUCCESS(cb, &op, cbd->data); g_ril_reply_free_operator(reply); return; error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); }
static void ril_cops_list_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_operator_list_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct reply_avail_ops *reply = NULL; struct ofono_network_operator *ops; struct reply_operator *operator; GSList *l; unsigned int i = 0; if (message->error != RIL_E_SUCCESS) { ofono_error("%s: failed to retrive the list of operators", __func__); goto error; } reply = g_ril_reply_parse_avail_ops(nd->ril, message); if (reply == NULL) goto error; ops = g_try_new0(struct ofono_network_operator, reply->num_ops); if (ops == NULL) { ofono_error("%s: can't allocate ofono_network_operator", __func__); goto error; } for (l = reply->list; l; l = l->next) { operator = l->data; set_oper_name(operator, &ops[i]); extract_mcc_mnc(operator->numeric, ops[i].mcc, ops[i].mnc); ops[i].tech = ril_tech_to_access_tech(operator->tech); /* Set the proper status */ if (!strcmp(operator->status, "unknown")) ops[i].status = OPERATOR_STATUS_UNKNOWN; else if (!strcmp(operator->status, "available")) ops[i].status = OPERATOR_STATUS_AVAILABLE; else if (!strcmp(operator->status, "current")) ops[i].status = OPERATOR_STATUS_CURRENT; else if (!strcmp(operator->status, "forbidden")) ops[i].status = OPERATOR_STATUS_FORBIDDEN; i++; } CALLBACK_WITH_SUCCESS(cb, reply->num_ops, ops, cbd->data); g_ril_reply_free_avail_ops(reply); return; error: CALLBACK_WITH_FAILURE(cb, 0, NULL, cbd->data); g_ril_reply_free_avail_ops(reply); }