static void ril_call_barring_query_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct parcel rilp; struct ofono_error error; ofono_call_barring_query_cb_t cb = cbd->cb; int bearer_class = 0; if (message->error != RIL_E_SUCCESS) { ofono_error("Call Barring query failed, err: %i", message->error); decode_ril_error(&error, "FAIL"); goto out; } ril_util_init_parcel(message, &rilp); /* * Services for which the specified barring facility is active. * "0" means "disabled for all, -1 if unknown" */ parcel_r_int32(&rilp); /* count - we know there is only 1 */ bearer_class = parcel_r_int32(&rilp); DBG("Active services: %i", bearer_class); decode_ril_error(&error, "OK"); out: cb(&error, bearer_class, cbd->data); }
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 ofono_error error; int status, lac, ci, tech; DBG(""); if (message->error != RIL_E_SUCCESS) { decode_ril_error(&error, "FAIL"); ofono_error("Failed to pull registration state"); cb(&error, -1, -1, -1, -1, cbd->data); return; } decode_ril_error(&error, "OK"); if (ril_util_parse_reg(nd->ril, message, &status, &lac, &ci, &tech, NULL) == FALSE) { CALLBACK_WITH_FAILURE(cb, -1, -1, -1, -1, cbd->data); return; } nd->tech = tech; cb(&error, status, lac, ci, tech, cbd->data); }
static void ril_imsi_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_imsi_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct ofono_error error; struct parcel rilp; gchar *imsi; if (message->error == RIL_E_SUCCESS) { DBG("GET IMSI reply - OK"); decode_ril_error(&error, "OK"); } else { ofono_error("Reply failure: %s", ril_error_to_string(message->error)); decode_ril_error(&error, "FAIL"); cb(&error, NULL, cbd->data); return; } ril_util_init_parcel(message, &rilp); /* 15 is the max length of IMSI * add 4 bytes for string length */ /* FIXME: g_assert(message->buf_len <= 19); */ imsi = parcel_r_string(&rilp); g_ril_append_print_buf(sd->ril, "{%s}", imsi); g_ril_print_response(sd->ril, message); cb(&error, imsi, cbd->data); g_free(imsi); }
static void ril_imsi_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_imsi_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct ofono_error error; gchar *imsi; if (message->error == RIL_E_SUCCESS) { DBG("GET IMSI reply - OK"); decode_ril_error(&error, "OK"); } else { ofono_error("Reply failure: %s", ril_error_to_string(message->error)); goto error; } imsi = g_ril_reply_parse_imsi(sd->ril, message); if (imsi == NULL) { ofono_error("Error empty IMSI"); goto error; } cb(&error, imsi, cbd->data); g_free(imsi); return; error: decode_ril_error(&error, "FAIL"); cb(&error, NULL, cbd->data); }
static void generic_cb(struct ril_msg *message, gpointer user_data) { struct change_state_req *req = user_data; struct voicecall_data *vd = ofono_voicecall_get_data(req->vc); struct ofono_error error; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { decode_ril_error(&error, "FAIL"); goto out; } if (req->affected_types) { GSList *l; struct ofono_call *call; for (l = vd->calls; l; l = l->next) { call = l->data; if (req->affected_types & (1 << call->status)) vd->local_release |= (1 << call->id); } } out: g_ril_send(vd->ril, RIL_REQUEST_GET_CURRENT_CALLS, NULL, 0, clcc_poll_cb, req->vc, NULL); /* We have to callback after we schedule a poll if required */ if (req->cb) req->cb(&error, req->data); }
static void ril_data_probe_reg_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_gprs *gprs = cbd->user; struct gprs_data *gd = ofono_gprs_get_data(gprs); struct ofono_error error; int status, lac, ci, tech; int max_cids = 1; int id = RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED; DBG(""); if (!(gd && message->error == RIL_E_SUCCESS)) { ofono_error("ril_data_reg_cb: reply failure: %s", ril_error_to_string(message->error)); decode_ril_error(&error, "FAIL"); error.error = message->error; status = NETWORK_REGISTRATION_STATUS_UNKNOWN; goto out; } decode_ril_error(&error, "OK"); status = -1; if (ril_util_parse_reg(gd->ril, message, &status, &lac, &ci, &tech, &max_cids) == FALSE) { ofono_error("Failure parsing data registration response."); decode_ril_error(&error, "FAIL"); if (status == -1) status = NETWORK_REGISTRATION_STATUS_UNKNOWN; goto out; } ofono_gprs_register(gprs); registered = TRUE; if (max_cids > gd->max_cids) { DBG("Setting max cids to %d", max_cids); gd->max_cids = max_cids; ofono_gprs_set_cid_range(gprs, 1, max_cids); } if (status == NETWORK_REGISTRATION_STATUS_ROAMING) status = check_if_really_roaming(status); out: ofono_info("data registration status is %d", status); DBG("Starting to listen network status"); gd->registerid = g_ril_register(gd->ril, id, ril_gprs_state_change, gprs); gd->rild_status = status; }
static void ril_data_reg_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_gprs_status_cb_t cb = cbd->cb; struct ofono_gprs *gprs = cbd->user; struct gprs_data *gd = ofono_gprs_get_data(gprs); struct ofono_error error; int status, lac, ci, tech; int max_cids = 1; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { ofono_error("ril_data_reg_cb: reply failure: %s", ril_error_to_string(message->error)); decode_ril_error(&error, "FAIL"); error.error = message->error; status = -1; goto error; } if (ril_util_parse_reg(message, &status, &lac, &ci, &tech, &max_cids) == FALSE) { ofono_error("Failure parsing data registration response."); decode_ril_error(&error, "FAIL"); status = -1; goto error; } if (gd->status == -1) { DBG("calling ofono_gprs_register..."); ofono_gprs_register(gprs); g_ril_register(gd->ril, RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, ril_gprs_state_change, gprs); } if (max_cids > gd->max_cids) { DBG("Setting max cids to %d", max_cids); gd->max_cids = max_cids; ofono_gprs_set_cid_range(gprs, 1, max_cids); } if (gd->status != status) { DBG("gd->status: %d status: %d", gd->status, status); ofono_gprs_status_notify(gprs, status); } gd->status = status; gd->tech = tech; error: if (cb) cb(&error, status, cbd->data); }
static void ril_ussd_cancel_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_ussd_cb_t cb = cbd->cb; struct ofono_error error; DBG("%d", message->error); if (message->error == RIL_E_SUCCESS) decode_ril_error(&error, "OK"); else decode_ril_error(&error, "FAIL"); cb(&error, cbd->data); }
static void ril_hangup_all(struct ofono_voicecall *vc, ofono_voicecall_cb_t cb, void *data) { struct voicecall_data *vd = ofono_voicecall_get_data(vc); struct parcel rilp; struct ofono_error error; struct ofono_call *call; GSList *l; for (l = vd->calls; l; l = l->next) { call = l->data; /* TODO: Hangup just the active ones once we have call * state tracking (otherwise it can't handle ringing) */ DBG("Hanging up call with id %d", call->id); parcel_init(&rilp); parcel_w_int32(&rilp, 1); /* Always 1 - AT+CHLD=1x */ parcel_w_int32(&rilp, call->id); /* Send request to RIL */ ril_template(RIL_REQUEST_HANGUP, vc, generic_cb, 0x3f, rilp.data, rilp.size, NULL, NULL); parcel_free(&rilp); } /* TODO: Deal in case of an error at hungup */ decode_ril_error(&error, "OK"); cb(&error, data); }
static void ril_send_dtmf(struct ofono_voicecall *vc, const char *dtmf, ofono_voicecall_cb_t cb, void *data) { struct voicecall_data *vd = ofono_voicecall_get_data(vc); int len = strlen(dtmf); struct parcel rilp; struct ofono_error error; char *ril_dtmf = g_try_malloc(sizeof(char) * 2); int i; DBG(""); /* Ril wants just one character, but we need to send as string */ ril_dtmf[1] = '\0'; for (i = 0; i < len; i++) { parcel_init(&rilp); ril_dtmf[0] = dtmf[i]; parcel_w_string(&rilp, ril_dtmf); DBG("DTMF: Sending %s", ril_dtmf); g_ril_send(vd->ril, RIL_REQUEST_DTMF, rilp.data, rilp.size, NULL, NULL, NULL); parcel_free(&rilp); } free(ril_dtmf); /* We don't really care about errors here */ decode_ril_error(&error, "OK"); cb(&error, data); }
static void ril_strength_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_strength_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct ofono_error error; int strength; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { ofono_error("Failed to retrive the signal strength"); goto error; } /* The g_ril_unsol* function handles both reply & unsolicited */ strength = g_ril_unsol_parse_signal_strength(nd->ril, message, nd->tech); cb(&error, strength, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, -1, cbd->data); }
static void ril_gprs_set_attached(struct ofono_gprs *gprs, int attached, ofono_gprs_cb_t cb, void *data) { struct cb_data *cbd = cb_data_new(cb, data); struct gprs_data *gd = ofono_gprs_get_data(gprs); struct ofono_error error; DBG("attached: %d", attached); decode_ril_error(&error, "OK"); /* * As RIL offers no actual control over the GPRS 'attached' * state, we save the desired state, and use it to override * the actual modem's state in the 'attached_status' function. * This is similar to the way the core ofono gprs code handles * data roaming ( see src/gprs.c gprs_netreg_update(). * * The core gprs code calls driver->set_attached() when a netreg * notificaiton is received and any configured roaming conditions * are met. */ gd->ofono_attached = attached; cb(&error, cbd->data); g_free(cbd); }
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 ofono_error error; struct parcel rilp; struct ofono_network_operator op; gchar *lalpha, *salpha, *numeric; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { ofono_error("Failed to retrive the current operator"); goto error; } ril_util_init_parcel(message, &rilp); /* Size of char ** */ if (parcel_r_int32(&rilp) == 0) goto error; lalpha = parcel_r_string(&rilp); salpha = parcel_r_string(&rilp); numeric = parcel_r_string(&rilp); /* Try to use long by default */ if (lalpha) strncpy(op.name, lalpha, OFONO_MAX_OPERATOR_NAME_LENGTH); else if (salpha) strncpy(op.name, salpha, OFONO_MAX_OPERATOR_NAME_LENGTH); else goto error; extract_mcc_mnc(numeric, op.mcc, op.mnc); /* Set to current */ op.status = OPERATOR_STATUS_CURRENT; op.tech = nd->tech; g_ril_append_print_buf(nd->ril, "(lalpha=%s, salpha=%s, numeric=%s, %s, mcc=%s, mnc=%s, %s)", lalpha, salpha, numeric, op.name, op.mcc, op.mnc, registration_tech_to_string(op.tech)); g_ril_print_response(nd->ril, message); g_free(lalpha); g_free(salpha); g_free(numeric); cb(&error, &op, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); }
static void submit_sms_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_error error; ofono_sms_submit_cb_t cb = cbd->cb; struct sms_data *sd = cbd->user; int mr; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { decode_ril_error(&error, "FAIL"); } mr = ril_util_parse_sms_response(sd->ril, message); cb(&error, mr, cbd->data); }
static void ril_call_barring_set_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_error error; ofono_call_barring_set_cb_t cb = cbd->cb; if (message->error != RIL_E_SUCCESS) { ofono_error("Call Barring Set request failed, err: %i", message->error); decode_ril_error(&error, "FAIL"); goto out; } decode_ril_error(&error, "OK"); out: cb(&error, cbd->data); }
static void ril_tr_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_stk_generic_cb_t cb = cbd->cb; struct ofono_error error; DBG(""); if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { DBG("Error in sending terminal response"); ofono_error("Error in sending terminal response"); decode_ril_error(&error, "FAIL"); } cb(&error, cbd->data); }
static void ril_envelope_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_stk_envelope_cb_t cb = cbd->cb; struct ofono_error error; DBG(""); if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { DBG("Envelope reply failure: %s", ril_error_to_string(message->error)); decode_ril_error(&error, "FAIL"); } cb(&error, NULL, 0, cbd->data); }
static void ril_register_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_register_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct ofono_error error; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); g_ril_print_response_no_args(nd->ril, message); } else { decode_ril_error(&error, "FAIL"); } cb(&error, cbd->data); }
static void volume_mute_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_call_volume_cb_t cb = cbd->cb; struct cv_data *cvd = cbd->user; struct ofono_error error; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); g_ril_print_response_no_args(cvd->ril, message); } else { ofono_error("Could not set the ril mute state"); decode_ril_error(&error, "FAIL"); } cb(&error, cbd->data); }
static void ril_csca_query_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sms_sca_query_cb_t cb = cbd->cb; struct ofono_error error; struct ofono_phone_number sca; struct parcel rilp; gchar *number, *temp_buf; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { decode_ril_error(&error, "FAIL"); cb(&error, NULL, cbd->data); return; } ril_util_init_parcel(message, &rilp); temp_buf = parcel_r_string(&rilp); if (temp_buf != NULL) { /* RIL gives address in quotes */ number = strtok(temp_buf, "\""); if (number[0] == '+') { number = number + 1; sca.type = 145; } else { sca.type = 129; } strncpy(sca.number, number, OFONO_MAX_PHONE_NUMBER_LENGTH); sca.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0'; DBG("csca_query_cb: %s, %d", sca.number, sca.type); cb(&error, &sca, cbd->data); } else { CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); } }
static void query_revision_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_devinfo_query_cb_t cb = cbd->cb; GRil *ril = cbd->user; struct ofono_error error; char *revision; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { decode_ril_error(&error, "FAIL"); cb(&error, NULL, cbd->data); return; } revision = g_ril_reply_parse_baseband_version(ril, message); cb(&error, revision, cbd->data); g_free(revision); }
static void ril_file_io_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_read_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct ofono_error error; struct reply_sim_io *reply; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { ofono_error("RILD reply failure: %s", ril_error_to_string(message->error)); goto error; } if ((reply = g_ril_reply_parse_sim_io(sd->ril, message)) == NULL) { ofono_error("Can't parse SIM IO response from RILD"); goto error; } if (reply->hex_len == 0) { ofono_error("Null SIM IO response from RILD"); g_ril_reply_free_sim_io(reply); goto error; } cb(&error, reply->hex_response, reply->hex_len, cbd->data); g_ril_reply_free_sim_io(reply); return; error: decode_ril_error(&error, "FAIL"); cb(&error, NULL, 0, cbd->data); }
static void rild_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_voicecall *vc = cbd->user; struct voicecall_data *vd = ofono_voicecall_get_data(vc); ofono_voicecall_cb_t cb = cbd->cb; struct ofono_error error; struct ofono_call *call; GSList *l; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { decode_ril_error(&error, "FAIL"); goto out; } /* On a success, make sure to put all active calls on hold */ for (l = vd->calls; l; l = l->next) { call = l->data; if (call->status != CALL_STATUS_ACTIVE) continue; call->status = CALL_STATUS_HELD; ofono_voicecall_notify(vc, call); } /* CLCC will update the oFono call list with proper ids */ if (!vd->clcc_source) vd->clcc_source = g_timeout_add(POLL_CLCC_INTERVAL, poll_clcc, vc); audioflinger_set_call_mode(); out: cb(&error, cbd->data); }
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 ofono_error error; int status, lac, ci, tech; DBG(""); if (message->error != RIL_E_SUCCESS) { decode_ril_error(&error, "FAIL"); ofono_error("Failed to pull registration state"); cb(&error, -1, -1, -1, -1, cbd->data); return; } decode_ril_error(&error, "OK"); if (ril_util_parse_reg(nd->ril, message, &status, &lac, &ci, &tech, NULL) == FALSE) { CALLBACK_WITH_FAILURE(cb, -1, -1, -1, -1, cbd->data); return; } DBG("voice registration status is %d", status); if (status > 10) status = status - 10; if (status == NETWORK_REGISTRATION_STATUS_ROAMING) status = check_if_really_roaming(status); DBG("voice registration status is %d", status); nd->tech = tech; cb(&error, status, lac, ci, tech, cbd->data); }
static void ril_query_model(struct ofono_devinfo *info, ofono_devinfo_query_cb_t cb, void *data) { const char *attr = "Fake Modem Model"; struct cb_data *cbd = cb_data_new(cb, data, NULL); struct ofono_error error; decode_ril_error(&error, "OK"); cb(&error, attr, cbd->data); /* Note: this will need to change if cbd passed to gril layer */ g_free(cbd); }
static void ril_query_serial(struct ofono_devinfo *info, ofono_devinfo_query_cb_t cb, void *data) { const char *attr = "THIS-IS-A-FAKE-SERIAL-NO"; struct cb_data *cbd = cb_data_new(cb, data); struct ofono_error error; decode_ril_error(&error, "OK"); cb(&error, attr, cbd->data); /* Note: this will need to change if cbd passed to gril layer */ g_free(cbd); }
static void ril_file_io_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_read_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct ofono_error error; int sw1 = 0, sw2 = 0, response_len = 0; guchar *response = NULL; DBG(""); if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { ofono_error("RILD reply failure: %s", ril_error_to_string(message->error)); goto error; } if ((response = (guchar *) ril_util_parse_sim_io_rsp(sd->ril, message, &sw1, &sw2, &response_len)) == NULL) { ofono_error("Error parsing IO response"); goto error; } cb(&error, response, response_len, cbd->data); g_free(response); return; error: decode_ril_error(&error, "FAIL"); cb(&error, NULL, 0, cbd->data); }
static gboolean ril_gprs_set_attached_callback(gpointer user_data) { struct ofono_error error; struct cb_data *cbd = user_data; ofono_gprs_cb_t cb = cbd->cb; struct ofono_gprs *gprs = cbd->user; struct gprs_data *gd = ofono_gprs_get_data(gprs); DBG(""); gd->timer_id = 0; decode_ril_error(&error, "OK"); cb(&error, cbd->data); g_free(cbd); return FALSE; }
static void ril_gprs_set_attached(struct ofono_gprs *gprs, int attached, ofono_gprs_cb_t cb, void *data) { struct cb_data *cbd = cb_data_new(cb, data); struct ofono_error error; DBG(""); decode_ril_error(&error, "OK"); /* This code should just call the callback with OK, and be done * there's no explicit RIL command to cause an attach. * * The core gprs code calls driver->set_attached() when a netreg * notificaiton is received and any configured roaming conditions * are met. */ cb(&error, cbd->data); g_free(cbd); }
static void ril_strength_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_netreg_strength_cb_t cb = cbd->cb; struct netreg_data *nd = cbd->user; struct ofono_error error; int strength; if (message->error == RIL_E_SUCCESS) { decode_ril_error(&error, "OK"); } else { ofono_error("Failed to retrive the signal strength"); goto error; } strength = ril_util_get_signal(nd->ril, message); cb(&error, strength, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, -1, cbd->data); }