示例#1
0
文件: sim.c 项目: morphis/ofono
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_str_array *str_arr = NULL;
	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;
	}

	str_arr = g_ril_reply_oem_hook_strings(sd->ril, message);
	if (str_arr == NULL || str_arr->num_str < 1) {
		ofono_error("%s: parse error", __func__);
		goto error;
	}

	num_pin = sscanf(str_arr->str[0], "+EPINC:%d,%d,%d,%d",
					&pin[0], &pin[1], &pin[2], &pin[3]);

	if (num_pin != MTK_EPINC_NUM_PASSWD) {
		ofono_error("%s: failed parsing %s", __func__, str_arr->str[0]);
		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];

	parcel_free_str_array(str_arr);
	CALLBACK_WITH_SUCCESS(cb, sd->retries, cbd->data);
	return;

error:
	parcel_free_str_array(str_arr);
	CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
}
示例#2
0
文件: mtk.c 项目: semafor/ofono
static void plmn_changed(struct ril_msg *message, gpointer user_data)
{
	struct ofono_modem *modem = user_data;
	struct mtk_data *md = ofono_modem_get_data(modem);
	struct parcel_str_array *plmns;

	plmns = g_mtk_unsol_parse_plmn_changed(md->ril, message);
	if (plmns == NULL) {
		ofono_error("%s: parse error", __func__);
		return;
	}

	md->sensed_plmn_type = get_plmn_type(plmns->str[0]);

	DBG("Best PLMN is %s (type %d)", plmns->str[0], md->sensed_plmn_type);

	parcel_free_str_array(plmns);

	check_modem_fw(modem);
}
示例#3
0
struct parcel_str_array *parcel_r_str_array(struct parcel *p)
{
	int i;
	struct parcel_str_array *str_arr;
	int num_str = parcel_r_int32(p);

	if (p->malformed || num_str <= 0)
		return NULL;

	str_arr = g_try_malloc0(sizeof(*str_arr) + num_str * sizeof(char *));
	if (str_arr == NULL)
		return NULL;

	str_arr->num_str = num_str;
	for (i = 0; i < num_str; ++i)
		str_arr->str[i] = parcel_r_string(p);

	if (p->malformed) {
		parcel_free_str_array(str_arr);
		return NULL;
	}

	return str_arr;
}
示例#4
0
文件: grilreply.c 项目: morphis/ofono
struct reply_data_reg_state *g_ril_reply_parse_data_reg_state(GRil *gril,
						const struct ril_msg *message)
{
	struct parcel rilp;
	struct parcel_str_array *str_arr;
	struct reply_data_reg_state *reply = NULL;
	int i;

	g_ril_init_parcel(message, &rilp);

	str_arr = parcel_r_str_array(&rilp);
	if (str_arr == NULL) {
		ofono_error("%s: parse error for %s", __func__,
				ril_request_id_to_string(message->req));
		goto out;
	}

	reply =	g_try_malloc0(sizeof(*reply));
	if (reply == NULL) {
		ofono_error("%s: out of memory", __func__);
		goto out;
	}

	reply->reg_state.status = -1;
	reply->reg_state.lac = -1;
	reply->reg_state.ci = -1;

	g_ril_append_print_buf(gril, "{");

	for (i = 0; i < str_arr->num_str; ++i) {
		char *str = str_arr->str[i];

		if (i > 0)
			g_ril_append_print_buf(gril, "%s,", print_buf);

		switch (i) {
		case RST_IX_STATE: case RST_IX_LAC:
		case RST_IX_CID:   case RST_IX_RAT:
			set_reg_state(gril, &reply->reg_state, i, str);
			break;
		case RDST_IX_MAXDC:
			set_data_reg_state(gril, reply, i, str);
			break;
		default:
			g_ril_append_print_buf(gril, "%s%s", print_buf,
						str ? str : "(null)");
		}
	}

	g_ril_append_print_buf(gril, "%s}", print_buf);
	g_ril_print_response(gril, message);

	/* As a minimum we require a valid status string */
	if (reply->reg_state.status == -1) {
		ofono_error("%s: invalid status", __func__);
		g_free(reply);
		reply = NULL;
	}

out:
	parcel_free_str_array(str_arr);

	return reply;
}