static void ril_call_barring_query_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_call_barring_query_cb_t cb = cbd->cb; struct barring_data *bd = cbd->user; struct parcel rilp; int bearer_class; if (message->error != RIL_E_SUCCESS) goto error; g_ril_init_parcel(message, &rilp); /* TODO: infineon returns two integers, use a quirk here */ if (parcel_r_int32(&rilp) < 1) goto error; bearer_class = parcel_r_int32(&rilp); if (bearer_class < 0 || rilp.malformed) goto error; g_ril_append_print_buf(bd->ril, "{%d}", bearer_class); g_ril_print_response(bd->ril, message); CALLBACK_WITH_SUCCESS(cb, bearer_class, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, -1, cbd->data); }
static void ril_call_barring_set_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_call_barring_set_cb_t cb = cbd->cb; struct barring_data *bd = cbd->user; struct parcel rilp; int retries = -1; if (message->error != RIL_E_SUCCESS) goto error; g_ril_init_parcel(message, &rilp); /* mako reply has no payload for call barring */ if (parcel_data_avail(&rilp) == 0) goto done; if (parcel_r_int32(&rilp) != 1) goto error; retries = parcel_r_int32(&rilp); if (rilp.malformed) goto error; done: g_ril_append_print_buf(bd->ril, "{%d}", retries); g_ril_print_response(bd->ril, message); CALLBACK_WITH_SUCCESS(cb, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, cbd->data); }
int g_ril_reply_parse_query_call_waiting(GRil *gril, const struct ril_msg *message) { struct parcel rilp; int numint, enabled, cls; g_ril_init_parcel(message, &rilp); numint = parcel_r_int32(&rilp); if (numint < 1) { ofono_error("%s Wrong format", __func__); goto error; } enabled = parcel_r_int32(&rilp); if (enabled > 0) cls = parcel_r_int32(&rilp); else cls = 0; g_ril_append_print_buf(gril, "{%d,0x%x}", enabled, cls); g_ril_print_response(gril, message); return cls; error: return -1; }
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); }
struct parcel_str_array *g_ril_reply_oem_hook_strings(GRil *gril, const struct ril_msg *message) { struct parcel rilp; struct parcel_str_array *str_arr; int i; g_ril_init_parcel(message, &rilp); str_arr = parcel_r_str_array(&rilp); if (str_arr == NULL) { ofono_error("%s: no strings", __func__); goto out; } g_ril_append_print_buf(gril, "{"); for (i = 0; i < str_arr->num_str; ++i) { if (i + 1 == str_arr->num_str) g_ril_append_print_buf(gril, "%s%s}", print_buf, str_arr->str[i]); else g_ril_append_print_buf(gril, "%s%s, ", print_buf, str_arr->str[i]); } g_ril_print_response(gril, message); out: return str_arr; }
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 parcel rilp; gchar *imsi; DBG(""); if (message->error != RIL_E_SUCCESS) { ofono_error("Reply failure: %s", ril_error_to_string(message->error)); goto error; } g_ril_init_parcel(message, &rilp); imsi = parcel_r_string(&rilp); g_ril_append_print_buf(sd->ril, "{%s}", imsi ? imsi : "NULL"); g_ril_print_response(sd->ril, message); if (imsi == NULL) goto error; CALLBACK_WITH_SUCCESS(cb, imsi, cbd->data); g_free(imsi); return; error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); }
int g_ril_reply_parse_sms_response(GRil *gril, const struct ril_msg *message) { struct parcel rilp; int error, mr; char *ack_pdu; /* Set up Parcel struct for proper parsing */ g_ril_init_parcel(message, &rilp); /* * TP-Message-Reference for GSM/ * BearerData MessageId for CDMA */ mr = parcel_r_int32(&rilp); ack_pdu = parcel_r_string(&rilp); error = parcel_r_int32(&rilp); g_ril_append_print_buf(gril, "{%d,%s,%d}", mr, ack_pdu, error); g_ril_print_response(gril, message); g_free(ack_pdu); return mr; }
static void ril_query_facility_lock_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_query_facility_lock_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct parcel rilp; ofono_bool_t status; int numparams; if (message->error != RIL_E_SUCCESS) goto error; g_ril_init_parcel(message, &rilp); numparams = parcel_r_int32(&rilp); if (numparams < 1) goto error; status = (ofono_bool_t) parcel_r_int32(&rilp); g_ril_append_print_buf(sd->ril, "{%d}", status); g_ril_print_response(sd->ril, message); CALLBACK_WITH_SUCCESS(cb, status, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, 0, cbd->data); }
static void ril_enter_sim_puk_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_lock_unlock_cb_t cb = cbd->cb; struct ofono_sim *sim = cbd->user; struct sim_data *sd = ofono_sim_get_data(sim); struct parcel rilp; g_ril_init_parcel(message, &rilp); parcel_r_int32(&rilp); if (message->error != RIL_E_SUCCESS) { sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = parcel_r_int32(&rilp); } else { sd->retries[OFONO_SIM_PASSWORD_SIM_PIN] = -1; sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = -1; } g_ril_append_print_buf(sd->ril, "{%d}", sd->retries[OFONO_SIM_PASSWORD_SIM_PUK]); g_ril_print_response(sd->ril, message); if (message->error == RIL_E_SUCCESS) { CALLBACK_WITH_SUCCESS(cb, cbd->data); return; } CALLBACK_WITH_FAILURE(cb, cbd->data); }
static gboolean parse_sim_io(GRil *ril, struct ril_msg *message, int *sw1, int *sw2, char **hex_response) { struct parcel rilp; /* * Minimum length of SIM_IO_Response is 12: * sw1 (int32) * sw2 (int32) * simResponse (string) */ if (message->buf_len < 12) { ofono_error("Invalid SIM IO reply: size too small (< 12): %u", message->buf_len); return FALSE; } g_ril_init_parcel(message, &rilp); *sw1 = parcel_r_int32(&rilp); *sw2 = parcel_r_int32(&rilp); *hex_response = parcel_r_string(&rilp); g_ril_append_print_buf(ril, "(sw1=0x%.2X,sw2=0x%.2X,%s)", *sw1, *sw2, *hex_response); g_ril_print_response(ril, message); if (rilp.malformed) { g_free(*hex_response); return FALSE; } return TRUE; }
int g_ril_reply_parse_query_facility_lock(GRil *gril, const struct ril_msg *message) { struct parcel rilp; int status, numint; g_ril_init_parcel(message, &rilp); /* infineon returns two integers */ numint = parcel_r_int32(&rilp); if (numint < 1) { ofono_error("%s: wrong format", __func__); goto error; } status = parcel_r_int32(&rilp); if (rilp.malformed) { ofono_error("%s: malformed parcel", __func__); goto error; } g_ril_append_print_buf(gril, "{%d}", status); g_ril_print_response(gril, message); return status; error: return -1; }
int g_ril_reply_parse_set_facility_lock(GRil *gril, const struct ril_msg *message) { struct parcel rilp; int retries = -1, numint; g_ril_init_parcel(message, &rilp); /* mako reply has no payload for call barring */ if (parcel_data_avail(&rilp) == 0) goto end; numint = parcel_r_int32(&rilp); if (numint != 1) { ofono_error("%s: wrong format", __func__); goto end; } retries = parcel_r_int32(&rilp); if (rilp.malformed) { ofono_error("%s: malformed parcel", __func__); goto end; } end: g_ril_append_print_buf(gril, "{%d}", retries); g_ril_print_response(gril, message); return retries; }
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); }
struct ofono_phone_number *g_ril_reply_parse_get_smsc_address( GRil *gril, const struct ril_msg *message) { struct ofono_phone_number *sca; struct parcel rilp; char *number, *temp_buf; sca = g_new0(struct ofono_phone_number, 1); if (sca == NULL) { ofono_error("%s Out of memory", __func__); goto err_alloc; } g_ril_init_parcel(message, &rilp); temp_buf = parcel_r_string(&rilp); if (temp_buf == NULL) { ofono_error("%s Cannot read SMSC address", __func__); goto err_readsca; } /* RIL gives address in quotes */ number = strtok(temp_buf, "\""); if (number == NULL || *number == '\0') { ofono_error("%s Invalid SMSC address", __func__); goto err_scaformat; } if (number[0] == '+') { number = number + 1; sca->type = OFONO_NUMBER_TYPE_INTERNATIONAL; } else { sca->type = OFONO_NUMBER_TYPE_UNKNOWN; } strncpy(sca->number, number, OFONO_MAX_PHONE_NUMBER_LENGTH); sca->number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0'; g_ril_append_print_buf(gril, "{type=%d,number=%s}", sca->type, sca->number); g_ril_print_response(gril, message); g_free(temp_buf); return sca; err_scaformat: g_free(temp_buf); err_readsca: g_free(sca); err_alloc: return NULL; }
struct reply_sim_io *g_ril_reply_parse_sim_io(GRil *gril, const struct ril_msg *message) { struct parcel rilp; char *response = NULL; struct reply_sim_io *reply; /* * Minimum length of SIM_IO_Response is 12: * sw1 (int32) * sw2 (int32) * simResponse (string) */ if (message->buf_len < 12) { ofono_error("Invalid SIM IO reply: size too small (< 12): %d ", (int) message->buf_len); return NULL; } reply = g_new0(struct reply_sim_io, 1); g_ril_init_parcel(message, &rilp); reply->sw1 = parcel_r_int32(&rilp); reply->sw2 = parcel_r_int32(&rilp); response = parcel_r_string(&rilp); g_ril_append_print_buf(gril, "(sw1=0x%.2X,sw2=0x%.2X,%s)", reply->sw1, reply->sw2, response); g_ril_print_response(gril, message); if (rilp.malformed) goto error; if (response != NULL) { reply->hex_response = decode_hex(response, strlen(response), (long *) &reply->hex_len, -1); g_free(response); if (reply->hex_response == NULL) goto error; } return reply; error: g_free(reply); return NULL; }
int g_ril_reply_parse_get_preferred_network_type(GRil *gril, const struct ril_msg *message) { struct parcel rilp; int numint, parcel_net_type, net_type; g_ril_init_parcel(message, &rilp); numint = parcel_r_int32(&rilp); if (numint != 1) { ofono_error("%s: Wrong format", __func__); goto error; } parcel_net_type = parcel_r_int32(&rilp); net_type = parcel_net_type; /* Try to translate special MTK settings */ if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) { switch (net_type) { /* 4G preferred */ case MTK_PREF_NET_TYPE_LTE_GSM_WCDMA: case MTK_PREF_NET_TYPE_LTE_GSM_WCDMA_MMDC: case MTK_PREF_NET_TYPE_LTE_GSM_TYPE: case MTK_PREF_NET_TYPE_LTE_GSM_MMDC_TYPE: net_type = PREF_NET_TYPE_LTE_GSM_WCDMA; break; /* 3G or 2G preferred over LTE */ case MTK_PREF_NET_TYPE_GSM_WCDMA_LTE: case MTK_PREF_NET_TYPE_GSM_WCDMA_LTE_MMDC: net_type = PREF_NET_TYPE_GSM_WCDMA; break; } } if (net_type < 0 || net_type > PREF_NET_TYPE_LTE_ONLY) { ofono_error("%s: unknown network type", __func__); goto error; } if (rilp.malformed) { ofono_error("%s: malformed parcel", __func__); goto error; } g_ril_append_print_buf(gril, "{%d}", parcel_net_type); g_ril_print_response(gril, message); return net_type; error: return -1; }
static void inf_pin_retries_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_pin_retries_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct parcel rilp; int32_t *data; int len; char *hex_dump; int expected; DBG(""); if (message->error != RIL_E_SUCCESS) { ofono_error("Reply failure: %s", ril_error_to_string(message->error)); goto error; } g_ril_init_parcel(message, &rilp); data = parcel_r_raw(&rilp, &len); if (data == NULL) { ofono_error("%s: malformed parcel", __func__); goto error; } hex_dump = encode_hex((unsigned char *) data, len, '\0'); g_ril_append_print_buf(sd->ril, "{%d,%s}", len, hex_dump); g_ril_print_response(sd->ril, message); g_free(hex_dump); expected = sizeof(int32_t) * 5; if (len < expected) { ofono_error("%s: reply too small", __func__); g_free(data); goto error; } /* First integer is INF_RIL_REQUEST_OEM_GET_REMAIN_SIM_PIN_ATTEMPTS */ sd->retries[OFONO_SIM_PASSWORD_SIM_PIN] = data[1]; sd->retries[OFONO_SIM_PASSWORD_SIM_PIN2] = data[2]; sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = data[3]; sd->retries[OFONO_SIM_PASSWORD_SIM_PUK2] = data[4]; g_free(data); CALLBACK_WITH_SUCCESS(cb, sd->retries, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); }
gchar *g_ril_reply_parse_imsi(GRil *gril, const struct ril_msg *message) { struct parcel rilp; gchar *imsi; g_ril_init_parcel(message, &rilp); imsi = parcel_r_string(&rilp); g_ril_append_print_buf(gril, "{%s}", imsi ? imsi : "NULL"); g_ril_print_response(gril, message); return imsi; }
static void mtk_pin_retries_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_pin_retries_cb_t cb = cbd->cb; struct sim_data *sd = cbd->user; struct parcel rilp; char **strv; char *debug_str; int pin[MTK_EPINC_NUM_PASSWD]; int num_pin; if (message->error != RIL_E_SUCCESS) { ofono_error("Reply failure: %s", ril_error_to_string(message->error)); goto error; } g_ril_init_parcel(message, &rilp); strv = parcel_r_strv(&rilp); if (strv == NULL) { ofono_error("%s: parse error", __func__); goto error; } debug_str = g_strjoinv(",", strv); g_ril_append_print_buf(sd->ril, "{%d,%s}", g_strv_length(strv), debug_str); g_free(debug_str); g_ril_print_response(sd->ril, message); num_pin = sscanf(strv[0], "+EPINC:%d,%d,%d,%d", &pin[0], &pin[1], &pin[2], &pin[3]); g_strfreev(strv); if (num_pin != MTK_EPINC_NUM_PASSWD) goto error; sd->retries[OFONO_SIM_PASSWORD_SIM_PIN] = pin[0]; sd->retries[OFONO_SIM_PASSWORD_SIM_PIN2] = pin[1]; sd->retries[OFONO_SIM_PASSWORD_SIM_PUK] = pin[2]; sd->retries[OFONO_SIM_PASSWORD_SIM_PUK2] = pin[3]; CALLBACK_WITH_SUCCESS(cb, sd->retries, cbd->data); return; error: CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); }
char *g_ril_reply_parse_baseband_version(GRil *gril, const struct ril_msg *message) { struct parcel rilp; char *version; g_ril_init_parcel(message, &rilp); version = parcel_r_string(&rilp); g_ril_append_print_buf(gril, "{%s}", version); g_ril_print_response(gril, message); return version; }
gchar *g_ril_reply_parse_imsi(GRil *gril, const struct ril_msg *message) { struct parcel rilp; gchar *imsi; g_ril_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(gril, "{%s}", imsi); g_ril_print_response(gril, message); return imsi; }
int g_ril_reply_parse_get_mute(GRil *gril, const struct ril_msg *message) { struct parcel rilp; int muted; g_ril_init_parcel(message, &rilp); /* skip length of int[] */ parcel_r_int32(&rilp); muted = parcel_r_int32(&rilp); g_ril_append_print_buf(gril, "{%d}", muted); g_ril_print_response(gril, message); return muted; }
static void ril_enter_sim_pin_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_sim_lock_unlock_cb_t cb = cbd->cb; struct ofono_sim *sim = cbd->user; struct sim_data *sd = ofono_sim_get_data(sim); struct parcel rilp; /* * There is no reason to ask SIM status until * unsolicited sim status change indication * Looks like state does not change before that. */ DBG("Enter password: type %d, result %d", sd->passwd_type, message->error); g_ril_init_parcel(message, &rilp); parcel_r_int32(&rilp); if (message->error == RIL_E_SUCCESS) sd->retries[sd->passwd_type] = -1; else sd->retries[sd->passwd_type] = parcel_r_int32(&rilp); g_ril_append_print_buf(sd->ril, "{%d}", sd->retries[sd->passwd_type]); g_ril_print_response(sd->ril, message); if (message->error == RIL_E_SUCCESS) { CALLBACK_WITH_SUCCESS(cb, cbd->data); return; } CALLBACK_WITH_FAILURE(cb, cbd->data); /* * Refresh passwd_state (not needed if the unlock is * successful, as an event will refresh the state in that case) */ send_get_sim_status(sim); }
static void probe_mute_cb(struct ril_msg *message, gpointer user_data) { struct ofono_call_volume *cv = user_data; struct cv_data *cvd = ofono_call_volume_get_data(cv); struct parcel rilp; int muted; if (message->error != RIL_E_SUCCESS) return; g_ril_init_parcel(message, &rilp); /* skip length of int[] */ parcel_r_int32(&rilp); muted = parcel_r_int32(&rilp); g_ril_append_print_buf(cvd->ril, "{%d}", muted); g_ril_print_response(cvd->ril, message); ofono_call_volume_set_muted(cv, muted); }
enum ofono_disconnect_reason g_ril_reply_parse_call_fail_cause( GRil *gril, const struct ril_msg *message) { enum ofono_disconnect_reason reason = OFONO_DISCONNECT_REASON_ERROR; int last_cause = CALL_FAIL_ERROR_UNSPECIFIED; struct parcel rilp; g_ril_init_parcel(message, &rilp); if (rilp.size < sizeof(int32_t)) ofono_error("%s: Parcel is too small", __func__); else if (parcel_r_int32(&rilp) > 0) last_cause = parcel_r_int32(&rilp); if (last_cause == CALL_FAIL_NORMAL || last_cause == CALL_FAIL_BUSY) reason = OFONO_DISCONNECT_REASON_REMOTE_HANGUP; g_ril_append_print_buf(gril, "{%d}", last_cause); g_ril_print_response(gril, message); return reason; }
struct reply_oem_hook *g_ril_reply_oem_hook_raw(GRil *gril, const struct ril_msg *message) { struct reply_oem_hook *reply = NULL; struct parcel rilp; reply = g_try_malloc0(sizeof(*reply)); if (reply == NULL) { ofono_error("%s: out of memory", __func__); goto end; } g_ril_init_parcel(message, &rilp); reply->data = parcel_r_raw(&rilp, &(reply->length)); if (rilp.malformed) { ofono_error("%s: malformed parcel", __func__); g_ril_reply_free_oem_hook(reply); reply = NULL; goto end; } g_ril_append_print_buf(gril, "{%d", reply->length); if (reply->data != NULL) { char *hex_dump; hex_dump = encode_hex(reply->data, reply->length, '\0'); g_ril_append_print_buf(gril, "%s,%s", print_buf, hex_dump); g_free(hex_dump); } g_ril_append_print_buf(gril, "%s}", print_buf); g_ril_print_response(gril, message); end: return reply; }
struct reply_clir *g_ril_reply_parse_get_clir(GRil *gril, const struct ril_msg *message) { struct parcel rilp; struct reply_clir *rclir; int numint; rclir = g_try_malloc0(sizeof(*rclir)); if (rclir == NULL) { ofono_error("%s Out of memory", __func__); goto error; } g_ril_init_parcel(message, &rilp); /* Length */ numint = parcel_r_int32(&rilp); if (numint != 2) { ofono_error("%s Wrong format", __func__); goto error; } /* Set HideCallerId property from network */ rclir->status = parcel_r_int32(&rilp); /* State of the CLIR supplementary service in the network */ rclir->provisioned = parcel_r_int32(&rilp); g_ril_append_print_buf(gril, "{%d,%d}", rclir->status, rclir->provisioned); g_ril_print_response(gril, message); return rclir; error: g_free(rclir); return NULL; }
int g_ril_reply_parse_query_clip(GRil *gril, const struct ril_msg *message) { struct parcel rilp; int clip_status, numint; g_ril_init_parcel(message, &rilp); numint = parcel_r_int32(&rilp); if (numint != 1) { ofono_error("%s Wrong format", __func__); goto error; } clip_status = parcel_r_int32(&rilp); g_ril_append_print_buf(gril, "{%d}", clip_status); g_ril_print_response(gril, message); return clip_status; error: return -1; }
GSList *g_ril_reply_parse_get_calls(GRil *gril, const struct ril_msg *message) { struct ofono_call *call; struct parcel rilp; GSList *l = NULL; int num, i; gchar *number, *name; g_ril_init_parcel(message, &rilp); g_ril_append_print_buf(gril, "{"); /* maguro signals no calls with empty event data */ if (rilp.size < sizeof(int32_t)) goto no_calls; /* Number of RIL_Call structs */ num = parcel_r_int32(&rilp); for (i = 0; i < num; i++) { call = g_try_new(struct ofono_call, 1); if (call == NULL) break; ofono_call_init(call); call->status = parcel_r_int32(&rilp); call->id = parcel_r_int32(&rilp); call->phone_number.type = parcel_r_int32(&rilp); parcel_r_int32(&rilp); /* isMpty */ parcel_r_int32(&rilp); /* isMT */ parcel_r_int32(&rilp); /* als */ call->type = parcel_r_int32(&rilp); /* isVoice */ parcel_r_int32(&rilp); /* isVoicePrivacy */ number = parcel_r_string(&rilp); if (number) { strncpy(call->phone_number.number, number, OFONO_MAX_PHONE_NUMBER_LENGTH); g_free(number); } parcel_r_int32(&rilp); /* numberPresentation */ name = parcel_r_string(&rilp); if (name) { strncpy(call->name, name, OFONO_MAX_CALLER_NAME_LENGTH); g_free(name); } parcel_r_int32(&rilp); /* namePresentation */ parcel_r_int32(&rilp); /* uusInfo */ if (strlen(call->phone_number.number) > 0) call->clip_validity = 0; else call->clip_validity = 2; g_ril_append_print_buf(gril, "%s [id=%d,status=%d,type=%d," "number=%s,name=%s]", print_buf, call->id, call->status, call->type, call->phone_number.number, call->name); l = g_slist_insert_sorted(l, call, g_ril_call_compare); } no_calls: g_ril_append_print_buf(gril, "%s}", print_buf); g_ril_print_response(gril, message); return l; }
struct reply_avail_ops *g_ril_reply_parse_avail_ops(GRil *gril, const struct ril_msg *message) { struct parcel rilp; struct reply_operator *operator; struct reply_avail_ops *reply = NULL; unsigned int num_ops, num_strings; unsigned int i; int strings_per_opt; if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) strings_per_opt = 5; else strings_per_opt = 4; /* * Minimum message length is 4: * - array size */ if (message->buf_len < 4) { ofono_error("%s: invalid QUERY_AVAIL_NETWORKS reply: " "size too small (< 4): %d ", __func__, (int) message->buf_len); goto error; } g_ril_init_parcel(message, &rilp); g_ril_append_print_buf(gril, "{"); /* Number of operators at the list */ num_strings = (unsigned int) parcel_r_int32(&rilp); if (num_strings % strings_per_opt) { ofono_error("%s: invalid QUERY_AVAIL_NETWORKS reply: " "num_strings (%d) MOD %d != 0", __func__, num_strings, strings_per_opt); goto error; } num_ops = num_strings / strings_per_opt; DBG("noperators = %d", num_ops); reply = g_try_new0(struct reply_avail_ops, 1); if (reply == NULL) { ofono_error("%s: can't allocate reply struct", __func__); goto error; } reply->num_ops = num_ops; for (i = 0; i < num_ops; i++) { operator = g_try_new0(struct reply_operator, 1); if (operator == NULL) { ofono_error("%s: can't allocate reply struct", __func__); goto error; } operator->lalpha = parcel_r_string(&rilp); operator->salpha = parcel_r_string(&rilp); operator->numeric = parcel_r_string(&rilp); operator->status = parcel_r_string(&rilp); /* * MTK: additional string with technology: 2G/3G are the only * valid values currently. */ if (g_ril_vendor(gril) == OFONO_RIL_VENDOR_MTK) { char *tech = parcel_r_string(&rilp); if (strcmp(tech, "3G") == 0) operator->tech = RADIO_TECH_UMTS; else operator->tech = RADIO_TECH_GSM; g_free(tech); } else { operator->tech = RADIO_TECH_GSM; } if (operator->lalpha == NULL && operator->salpha == NULL) { ofono_error("%s: operator (%s) doesn't specify names", operator->numeric, __func__); g_ril_reply_free_operator(operator); continue; } if (operator->numeric == NULL) { ofono_error("%s: operator (%s/%s) " "doesn't specify numeric", operator->lalpha, operator->salpha, __func__); g_ril_reply_free_operator(operator); continue; } if (operator->status == NULL) { ofono_error("%s: operator (%s/%s) " "doesn't specify status", operator->lalpha, operator->salpha, __func__); g_ril_reply_free_operator(operator); continue; } reply->list = g_slist_append(reply->list, operator); g_ril_append_print_buf(gril, "%s [lalpha=%s, salpha=%s, " " numeric=%s status=%s tech=%s]", print_buf, operator->lalpha, operator->salpha, operator->numeric, operator->status, ril_radio_tech_to_string(operator->tech)); } g_ril_append_print_buf(gril, "%s}", print_buf); g_ril_print_response(gril, message); return reply; error: if (reply) g_ril_reply_free_avail_ops(reply); return NULL; }