Exemplo n.º 1
0
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, NULL);
	struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);
	struct gprs_attach_data *attach_data;
	int attach_aux = attached;

	DBG("attached: %d", attached);

	if (g_ril_get_version(gd->ril) < 10) {
		/*
		 * Older RILs offer 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;

		/*
		 * Call from idle loop, so core can set driver_attached before
		 * the callback is invoked.
		 */
		g_idle_add(ril_gprs_set_attached_cb, cbd);
		return;
	}

	attach_data = g_new0(struct gprs_attach_data, 1);
	attach_data->gd = gd;
	attach_data->ril = gd->ril;
	attach_data->set_attached = attached;
	attach_data->detaching_other_slot = FALSE;

	/* If we want to attach we have to detach the other slot */
	if (attached && ril_get_gril_complement(gd->modem)) {
		attach_data->ril = ril_get_gril_complement(gd->modem);
		attach_data->detaching_other_slot = TRUE;

		attach_aux = !attached;
	}

	cbd = cb_data_new(cb, data, attach_data);

	send_allow_data(cbd, attach_data->ril, attach_aux);
}
Exemplo n.º 2
0
Arquivo: sim.c Projeto: morphis/ofono
static void ril_change_passwd(struct ofono_sim *sim,
				enum ofono_sim_password_type passwd_type,
				const char *old_passwd, const char *new_passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data, sim);
	struct parcel rilp;
	int request = RIL_REQUEST_CHANGE_SIM_PIN;

	sd->passwd_type = passwd_type;

	g_ril_request_change_passwd(sd->ril,
					old_passwd,
					new_passwd,
					sd->aid_str,
					&rilp);

	if (passwd_type == OFONO_SIM_PASSWORD_SIM_PIN2)
		request = RIL_REQUEST_CHANGE_SIM_PIN2;

	if (g_ril_send(sd->ril, request, &rilp, ril_pin_change_state_cb,
			cbd, g_free) == 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
Exemplo n.º 3
0
static void mtk_set_fast_dormancy(struct ofono_radio_settings *rs,
				ofono_bool_t enable,
				ofono_radio_settings_fast_dormancy_set_cb_t cb,
				void *data)
{
	struct radio_data *rsd = ofono_radio_settings_get_data(rs);
	struct set_fd_mode *user = g_malloc0(sizeof(*user));
	struct cb_data *cbd;
	struct parcel rilp;

	user->rst = rs;
	user->on = enable;

	cbd = cb_data_new(cb, data, user);

	g_mtk_request_set_fd_mode(rsd->ril, MTK_FD_MODE_SCREEN_STATUS,
					enable ? FALSE : TRUE, 0, &rilp);

	if (g_ril_send(rsd->ril, MTK_RIL_REQUEST_SET_FD_MODE, &rilp,
			mtk_set_fd_mode_cb, cbd, g_free) <= 0) {
		g_free(cbd);
		g_free(user);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
Exemplo n.º 4
0
Arquivo: sms.c Projeto: leinomii/ofono
static void ril_csca_set(struct ofono_sms *sms,
			const struct ofono_phone_number *sca,
			ofono_sms_sca_set_cb_t cb, void *user_data)
{
	struct sms_data *data = ofono_sms_get_data(sms);
	struct cb_data *cbd = cb_data_new(cb, user_data);
	struct parcel rilp;
	int ret = -1;
	char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 4];

	if (sca->type == 129)
		snprintf(number, sizeof(number), "\"%s\"", sca->number);
	else
		snprintf(number, sizeof(number), "\"+%s\"", sca->number);

	DBG("Setting sca: %s", number);

	parcel_init(&rilp);
	parcel_w_string(&rilp, number);

	/* Send request to RIL */
	ret = g_ril_send(data->ril, RIL_REQUEST_SET_SMSC_ADDRESS, rilp.data,
				rilp.size, ril_csca_set_cb, cbd, g_free);
	parcel_free(&rilp);

	/* In case of error free cbd and return the cb with failure */
	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, user_data);
	}
}
Exemplo n.º 5
0
Arquivo: sim.c Projeto: endocode/ofono
static void ril_pin_send_puk(struct ofono_sim *sim,
				const char *puk, const char *passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data, sim);
	struct parcel rilp;

	sd->passwd_type = OFONO_SIM_PASSWORD_SIM_PUK;

	parcel_init(&rilp);

	parcel_w_int32(&rilp, 3);
	parcel_w_string(&rilp, puk);
	parcel_w_string(&rilp, passwd);
	parcel_w_string(&rilp, sd->aid_str);

	g_ril_append_print_buf(sd->ril, "(puk=%s,pin=%s,aid=%s)",
				puk, passwd, sd->aid_str);

	if (g_ril_send(sd->ril, RIL_REQUEST_ENTER_SIM_PUK, &rilp,
			ril_enter_sim_puk_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, data);
}
Exemplo n.º 6
0
Arquivo: ril.c Projeto: CODeRUS/ofono
static void ril_set_online(struct ofono_modem *modem, ofono_bool_t online,
				ofono_modem_online_cb_t callback, void *data)
{
	DBG("Set online state (online = 1, offline = 0)): %i", online);
	struct ril_data *ril = ofono_modem_get_data(modem);
	struct cb_data *cbd = cb_data_new(callback, data);
	struct parcel rilp;
	int ret = 0;

	parcel_init(&rilp);
	parcel_w_int32(&rilp, 1);	/* Number of params */
	parcel_w_int32(&rilp, online);	/* Radio ON = 1, Radio OFF = 0 */

	ofono_info("%s: RIL_REQUEST_RADIO_POWER %d", __func__, online);
	ret = g_ril_send(ril->modem, RIL_REQUEST_RADIO_POWER, rilp.data,
				rilp.size, ril_set_online_cb, cbd, g_free);

	parcel_free(&rilp);
	DBG("RIL_REQUEST_RADIO_POWER done");
	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(callback, data);
	} else {
		if (online)
			current_online_state = RIL_ONLINE_PREF;
		else
			current_online_state = RIL_OFFLINE;
	}
}
Exemplo n.º 7
0
static void ril_network_state_change(struct ril_msg *message, gpointer user_data)
{
	struct ofono_netreg *netreg = user_data;
	struct netreg_data *nd = ofono_netreg_get_data(netreg);
	struct cb_data *cbd = cb_data_new(ril_creg_notify, netreg);
	int request = RIL_REQUEST_VOICE_REGISTRATION_STATE;
	int ret;

	cbd->user = nd;

	if (message->req != RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED)
		goto error;

	g_ril_print_unsol_no_args(nd->ril, message);

	ret = g_ril_send(nd->ril, request, NULL,
				0, ril_creg_cb, cbd, g_free);

	/* For operator update ofono will use the current_operator cb
	 * so we don't need to probe ril here */

	g_ril_print_request_no_args(nd->ril, ret, request);

	if (ret > 0)
		return;

error:
	ofono_error("Unable to request network state changed");
	g_free(cbd);
}
Exemplo n.º 8
0
static void icera_set_rat_mode(struct ofono_radio_settings *rs,
				enum ofono_radio_access_mode mode,
				ofono_radio_settings_rat_mode_set_cb_t cb,
				void *data)
{
	struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);
	struct cb_data *cbd = cb_data_new(cb, data);
	char buf[20];
	int value = 5;

	switch (mode) {
	case OFONO_RADIO_ACCESS_MODE_ANY:
		value = 5;
		break;
	case OFONO_RADIO_ACCESS_MODE_GSM:
		value = 0;
		break;
	case OFONO_RADIO_ACCESS_MODE_UMTS:
		value = 1;
		break;
	case OFONO_RADIO_ACCESS_MODE_LTE:
		goto error;
	}

	snprintf(buf, sizeof(buf), "AT%%IPSYS=%u,2", value);

	if (g_at_chat_send(rsd->chat, buf, none_prefix,
					ipsys_modify_cb, cbd, g_free) > 0)
		return;

error:
	CALLBACK_WITH_FAILURE(cb, data);
	g_free(cbd);
}
Exemplo n.º 9
0
Arquivo: sms.c Projeto: Conjuror/ofono
static void at_cmgs(struct ofono_sms *sms, unsigned char *pdu, int pdu_len,
			int tpdu_len, int mms, ofono_sms_submit_cb_t cb,
			void *user_data)
{
	struct sms_data *data = ofono_sms_get_data(sms);
	struct cb_data *cbd = cb_data_new(cb, user_data);
	char buf[512];
	int len;

	if (mms) {
		snprintf(buf, sizeof(buf), "AT+CMMS=%d", mms);
		g_at_chat_send(data->chat, buf, none_prefix,
				NULL, NULL, NULL);
	}

	len = snprintf(buf, sizeof(buf), "AT+CMGS=%d\r", tpdu_len);
	encode_hex_own_buf(pdu, pdu_len, 0, buf+len);

	if (g_at_chat_send(data->chat, buf, cmgs_prefix,
				at_cmgs_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);

	CALLBACK_WITH_FAILURE(cb, -1, user_data);
}
Exemplo n.º 10
0
static void ril_call_barring_set_passwd(struct ofono_call_barring *barr,
					const char *lock,
					const char *old_passwd,
					const char *new_passwd,
					ofono_call_barring_set_cb_t cb,
					void *data)
{
	struct barring_data *bd = ofono_call_barring_get_data(barr);
	struct cb_data *cbd = cb_data_new(cb, data);
	struct parcel rilp;
	int ret = 0;

	DBG("");

	parcel_init(&rilp);
	parcel_w_int32(&rilp, RIL_SET_PW_STRING_COUNT);	/* Nbr of strings */
	parcel_w_string(&rilp, (char *) lock);		/* Facility code */
	parcel_w_string(&rilp, (char *) old_passwd);
	parcel_w_string(&rilp, (char *) new_passwd);

	ret = g_ril_send(bd->ril, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
			rilp.data, rilp.size, ril_call_barring_set_passwd_cb,
			cbd, g_free);

	parcel_free(&rilp);

	if (ret <= 0) {
		ofono_error("Sending Call Barring Set PW req failed, err: %i",
				ret);
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
Exemplo n.º 11
0
static void ril_gprs_registration_status(struct ofono_gprs *gprs,
					ofono_gprs_status_cb_t cb,
					void *data)
{
	struct gprs_data *gd = ofono_gprs_get_data(gprs);
	struct cb_data *cbd = cb_data_new(cb, data);
	int request = RIL_REQUEST_DATA_REGISTRATION_STATE;
	guint ret;

	DBG("");

	if (gd == NULL || cbd == NULL)
		return;

	cbd->user = gprs;

	ret = g_ril_send(gd->ril, request,
				NULL, 0,
				((gd->rild_status == -1)
				? ril_data_probe_reg_cb
				: ril_data_reg_cb), cbd, g_free);

	g_ril_print_request_no_args(gd->ril, ret, request);

	if (ret <= 0) {
		ofono_error("Send RIL_REQUEST_DATA_RESTISTRATION_STATE fail.");
		g_free(cbd);

		if (cb)
			CALLBACK_WITH_FAILURE(cb, -1, data);
	}
}
Exemplo n.º 12
0
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);

	DBG("attached: %d", attached);
	/*
	* 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
	* notification is received and any configured roaming conditions
	* are met.
	*/

	gd->notified = (gd->ofono_attached == attached) ? TRUE : FALSE;

	gd->ofono_attached = attached;

	cbd->user = gprs;

	/*
	* However we cannot respond immediately, since core sets the
	* value of driver_attached after calling set_attached and that
	* leads to comparison failure in gprs_attached_update in
	* connection drop phase
	*/
	gd->timer_id = g_timeout_add_seconds(1, ril_gprs_set_attached_callback,
						cbd);
}
Exemplo n.º 13
0
Arquivo: gprs.c Projeto: yongsu/oFono
static void at_gprs_registration_status(struct ofono_gprs *gprs,
					ofono_gprs_status_cb_t cb,
					void *data)
{
	struct gprs_data *gd = ofono_gprs_get_data(gprs);
	struct cb_data *cbd = cb_data_new(cb, data);

	if (!cbd)
		goto error;

	cbd->user = gd;

	switch (gd->vendor) {
	case OFONO_VENDOR_NOVATEL:
		/*
		 * Send $CNTI=0 to find out the current tech, it will be
		 * intercepted in nw_cnti_notify in network registration
		 */
		g_at_chat_send(gd->chat, "AT$CNTI=0", none_prefix,
				NULL, NULL, NULL);
		break;
	}

	if (g_at_chat_send(gd->chat, "AT+CGREG?", cgreg_prefix,
				at_cgreg_cb, cbd, g_free) > 0)
		return;

error:
	if (cbd)
		g_free(cbd);

	CALLBACK_WITH_FAILURE(cb, -1, data);
}
Exemplo n.º 14
0
static void qmi_register_manual(struct ofono_netreg *netreg,
				const char *mcc, const char *mnc,
				ofono_netreg_register_cb_t cb, void *user_data)
{
	struct netreg_data *data = ofono_netreg_get_data(netreg);
	struct cb_data *cbd = cb_data_new(cb, user_data);
	struct qmi_nas_param_register_manual_info info;
	struct qmi_param *param;

	DBG("");

	param = qmi_param_new_uint8(QMI_NAS_PARAM_REGISTER_ACTION,
					QMI_NAS_REGISTER_ACTION_MANUAL);
	if (!param)
		goto error;

	info.mcc = atoi(mcc);
	info.mnc = atoi(mnc);
	info.rat = data->current_rat;

	qmi_param_append(param, QMI_NAS_PARAM_REGISTER_MANUAL_INFO,
						sizeof(info), &info);

	if (qmi_service_send(data->nas, QMI_NAS_REGISTER_NET, param,
					register_net_cb, cbd, g_free) > 0)
		return;

	qmi_param_free(param);

error:
	CALLBACK_WITH_FAILURE(cb, cbd->data);

	g_free(cbd);
}
Exemplo n.º 15
0
static void qmi_register_auto(struct ofono_netreg *netreg,
				ofono_netreg_register_cb_t cb, void *user_data)
{
	struct netreg_data *data = ofono_netreg_get_data(netreg);
	struct cb_data *cbd = cb_data_new(cb, user_data);
	struct qmi_param *param;

	DBG("");

	param = qmi_param_new_uint8(QMI_NAS_PARAM_REGISTER_ACTION,
					QMI_NAS_REGISTER_ACTION_AUTO);
	if (!param)
		goto error;

	if (qmi_service_send(data->nas, QMI_NAS_REGISTER_NET, param,
					register_net_cb, cbd, g_free) > 0)
		return;

	qmi_param_free(param);

error:
	CALLBACK_WITH_FAILURE(cb, cbd->data);

	g_free(cbd);
}
Exemplo n.º 16
0
static void ril_call_barring_query(struct ofono_call_barring *cb,
					const char *lock, int cls,
					ofono_call_barring_query_cb_t callback,
					void *data)
{
	struct barring_data *bd = ofono_call_barring_get_data(cb);
	struct cb_data *cbd = cb_data_new(callback, data, bd);
	struct parcel rilp;
	char svcs_str[4];

	DBG("lock: %s, services to query: %d", lock, cls);

	FIXUP_CLS();

	parcel_init(&rilp);
	parcel_w_int32(&rilp, 4);	/* # of strings */
	parcel_w_string(&rilp, lock);
	parcel_w_string(&rilp, "");	/* Password is empty when not needed */
	snprintf(svcs_str, sizeof(svcs_str), "%d", cls);
	parcel_w_string(&rilp, svcs_str);
	parcel_w_string(&rilp, NULL);	/* AID (for FDN, not yet supported) */

	g_ril_append_print_buf(bd->ril, "(%s,\"\",%s,(null))",
				lock, svcs_str);

	if (g_ril_send(bd->ril, RIL_REQUEST_QUERY_FACILITY_LOCK, &rilp,
				ril_call_barring_query_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);
	CALLBACK_WITH_FAILURE(callback, -1, data);
}
Exemplo n.º 17
0
static void ril_dial(struct ofono_voicecall *vc,
			const struct ofono_phone_number *ph,
			enum ofono_clir_option clir, ofono_voicecall_cb_t cb,
			void *data)
{
	struct voicecall_data *vd = ofono_voicecall_get_data(vc);
	struct cb_data *cbd = cb_data_new(cb, data);
	struct parcel rilp;
	int ret;

	cbd->user = vc;

	parcel_init(&rilp);

	/* Number to dial */
        parcel_w_string(&rilp, phone_number_to_string(ph));
	/* CLIR mode */
	parcel_w_int32(&rilp, clir);
	/* USS, need it twice for absent */
	/* TODO: Deal with USS properly */
	parcel_w_int32(&rilp, 0);
	parcel_w_int32(&rilp, 0);

	/* Send request to RIL */
	ret = g_ril_send(vd->ril, RIL_REQUEST_DIAL, rilp.data,
				rilp.size, rild_cb, cbd, g_free);
	parcel_free(&rilp);

	/* In case of error free cbd and return the cb with failure */
	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
Exemplo n.º 18
0
static void hfp_current_operator(struct ofono_netreg *netreg,
				ofono_netreg_operator_cb_t cb, void *data)
{
	struct netreg_data *nd = ofono_netreg_get_data(netreg);
	struct cb_data *cbd = cb_data_new(cb, data);
	gboolean ok;

	if (!cbd)
		goto error;

	cbd->user = netreg;

	ok = g_at_chat_send(nd->chat, "AT+COPS=3,0", NULL,
			NULL, cbd, NULL);

	if (ok)
		ok = g_at_chat_send(nd->chat, "AT+COPS?", cops_prefix,
				cops_cb, cbd, g_free);

	if (ok)
		return;

error:
	CALLBACK_WITH_FAILURE(cb, NULL, data);
}
Exemplo n.º 19
0
static int policy_local_create(struct connman_session *session,
				connman_session_config_func_t cb,
				void *user_data)
{
	struct cb_data *cbd = cb_data_new(cb, user_data);
	struct policy_config *policy;
	const char *owner;
	int err;

	DBG("session %p", session);

	policy = g_new0(struct policy_config, 1);
	policy->config = connman_session_create_default_config();
	policy->session = session;

	cbd->data = policy;

	owner = connman_session_get_owner(session);

	err = connman_dbus_get_connection_unix_user(connection, owner,
						get_uid_reply, cbd);
	if (err < 0) {
		connman_error("Could not get UID");
		cleanup_config(policy);
		g_free(cbd);
		return err;
	}

	return 0;
}
Exemplo n.º 20
0
static void radio_settings_register(const struct ofono_error *error,
					unsigned int available_rats,
					void *data)
{
	struct ofono_radio_settings *rs = data;
	struct radio_data *rd = ofono_radio_settings_get_data(rs);

	g_ril_register(rd->ril, RIL_UNSOL_RADIO_CAPABILITY,
							radio_caps_event, rd);

	rd->gprs_atom_watch =
		__ofono_modem_add_atom_watch(rd->modem, OFONO_ATOM_TYPE_GPRS,
						gprs_watch_cb, rs, NULL);

	/*
	 * If the preferred technology was unknown/unsupported, change to a
	 * valid one (midori can return PREF_NET_TYPE_CDMA_ONLY, for instance).
	 * Changing to anything above GSM can prevent other radios restoring
	 * their settings.
	 */
	if (rd->rat_mode == OFONO_RADIO_ACCESS_MODE_ANY) {
		struct cb_data *cbd = cb_data_new(set_safe_preferred_cb, rd,
							rd->radio_settings);

		set_preferred_network(rd, cbd, OFONO_RADIO_ACCESS_MODE_GSM);
	}

	/*
	 * We register in all cases, setting FD some times fails until radio is
	 * available (this happens on turbo and maybe in other devices).
	 */
	ofono_radio_settings_register(rs);
}
Exemplo n.º 21
0
static void ril_register_manual(struct ofono_netreg *netreg,
				const char *mcc, const char *mnc,
				ofono_netreg_register_cb_t cb, void *data)
{
	struct netreg_data *nd = ofono_netreg_get_data(netreg);
	struct cb_data *cbd = cb_data_new(cb, data);
	char buf[OFONO_MAX_MCC_LENGTH + OFONO_MAX_MNC_LENGTH + 1];
	struct parcel rilp;
	int request = RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL;
	int ret;

	/* add *netreg_data to callback */
	cbd->user = nd;

	parcel_init(&rilp);

	/* RIL expects a char * specifying MCCMNC of network to select */
	snprintf(buf, sizeof(buf), "%s%s", mcc, mnc);
	parcel_w_string(&rilp, buf);

	ret = g_ril_send(nd->ril, request,
				rilp.data, rilp.size, ril_register_cb,
				cbd, g_free);
	parcel_free(&rilp);

	g_ril_append_print_buf(nd->ril,	"(%s)", buf);
	g_ril_print_request(nd->ril, ret, request);

	/* In case of error free cbd and return the cb with failure */
	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
Exemplo n.º 22
0
Arquivo: gprs.c Projeto: saukko/ofono
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);
}
Exemplo n.º 23
0
Arquivo: sim.c Projeto: endocode/ofono
static void ril_pin_send(struct ofono_sim *sim, const char *passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	/*
	 * TODO: This function is supposed to enter the pending password, which
	 * might be also PIN2. So we must check the pending PIN in the future.
	 */

	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd = cb_data_new(cb, data, sim);
	struct parcel rilp;

	sd->passwd_type = OFONO_SIM_PASSWORD_SIM_PIN;

	parcel_init(&rilp);

	parcel_w_int32(&rilp, 2);
	parcel_w_string(&rilp, passwd);
	parcel_w_string(&rilp, sd->aid_str);

	g_ril_append_print_buf(sd->ril, "(%s,aid=%s)", passwd, sd->aid_str);

	if (g_ril_send(sd->ril, RIL_REQUEST_ENTER_SIM_PIN, &rilp,
			ril_enter_sim_pin_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, data);
}
Exemplo n.º 24
0
Arquivo: gprs.c Projeto: morphis/ofono
void ril_gprs_set_ia_apn(struct ofono_gprs *gprs, const char *apn,
				enum ofono_gprs_proto proto, const char *user,
				const char *passwd, const char *mccmnc,
				ofono_gprs_cb_t cb, void *data)
{
	struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);
	struct cb_data *cbd;
	struct parcel rilp;

	if (!ofono_modem_get_boolean(gd->modem, MODEM_PROP_LTE_CAPABLE)) {
		CALLBACK_WITH_SUCCESS(cb, data);
		return;
	}

	cbd = cb_data_new(cb, data, gprs);

	g_ril_request_set_initial_attach_apn(gd->ril, apn, proto, user, passwd,
						mccmnc, &rilp);

	if (g_ril_send(gd->ril, RIL_REQUEST_SET_INITIAL_ATTACH_APN,
			&rilp, set_ia_apn_cb, cbd, g_free) == 0) {
		ofono_error("%s: failure sending request", __func__);

		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
Exemplo n.º 25
0
Arquivo: gprs.c Projeto: morphis/ofono
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, NULL);
	struct ril_gprs_data *gd = ofono_gprs_get_data(gprs);

	DBG("attached: %d", attached);

	/*
	 * 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;

	/*
	 * Call from idle loop, so core can set driver_attached before
	 * the callback is invoked.
	 */
	g_idle_add(ril_gprs_set_attached_cb, cbd);
}
Exemplo n.º 26
0
static void ril_call_barring_set(struct ofono_call_barring *cb,
				const char *lock, int enable,
				const char *passwd, int cls,
				ofono_call_barring_set_cb_t callback,
				void *data)
{
	struct barring_data *bd = ofono_call_barring_get_data(cb);
	struct cb_data *cbd = cb_data_new(callback, data, bd);
	struct parcel rilp;
	char svcs_str[4];

	DBG("lock: %s, enable: %d, bearer class: %d", lock, enable, cls);

	FIXUP_CLS();

	parcel_init(&rilp);
	parcel_w_int32(&rilp, 5);	/* # of strings */
	parcel_w_string(&rilp, lock);
	parcel_w_string(&rilp, enable ? "1" : "0");
	parcel_w_string(&rilp, passwd);
	snprintf(svcs_str, sizeof(svcs_str), "%d", cls);
	parcel_w_string(&rilp, svcs_str);
	parcel_w_string(&rilp, NULL);	/* AID (for FDN, not yet supported) */

	g_ril_append_print_buf(bd->ril, "(%s,%s,%s,%s,(null))",
				lock, enable ? "1" : "0", passwd, svcs_str);

	if (g_ril_send(bd->ril, RIL_REQUEST_SET_FACILITY_LOCK, &rilp,
			ril_call_barring_set_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);
	CALLBACK_WITH_FAILURE(callback, data);
}
Exemplo n.º 27
0
static void hfp16_card_connect(struct ofono_handsfree_card *card,
					ofono_handsfree_card_connect_cb_t cb,
					void *data)
{
	struct hfp *hfp = ofono_handsfree_card_get_data(card);
	struct hfp_slc_info *info = &hfp->info;

	if (info->hf_features & HFP_HF_FEATURE_CODEC_NEGOTIATION &&
			info->ag_features & HFP_AG_FEATURE_CODEC_NEGOTIATION) {
		struct cb_data *cbd = cb_data_new(cb, data);

		cbd->user = card;
		hfp->bcc_id = g_at_chat_send(info->chat, "AT+BCC",
						none_prefix, bcc_cb,
						cbd, g_free);
		return;
	}

	/*
	 * If any side (remote or local) doesn't support codec negotiation,
	 * fallback to direct SCO connection. Calling connect_sco()
	 * hands the connection responsibility to the core, so no need
	 * to call the callback
	 */
	ofono_handsfree_card_connect_sco(card);
}
Exemplo n.º 28
0
static void ril_call_barring_set_passwd(struct ofono_call_barring *barr,
					const char *lock,
					const char *old_passwd,
					const char *new_passwd,
					ofono_call_barring_set_cb_t cb,
					void *data)
{
	struct barring_data *bd = ofono_call_barring_get_data(barr);
	struct cb_data *cbd = cb_data_new(cb, data, bd);
	struct parcel rilp;

	DBG("lock %s old %s new %s", lock, old_passwd, new_passwd);

	parcel_init(&rilp);

	parcel_w_int32(&rilp, 3);	/* # of strings */
	parcel_w_string(&rilp, lock);
	parcel_w_string(&rilp, old_passwd);
	parcel_w_string(&rilp, new_passwd);

	g_ril_append_print_buf(bd->ril, "(%s,%s,%s)",
				lock, old_passwd, new_passwd);

	if (g_ril_send(bd->ril, RIL_REQUEST_CHANGE_BARRING_PASSWORD, &rilp,
			ril_call_barring_set_passwd_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, data);
}
Exemplo n.º 29
0
static void ril_set_rat_mode(struct ofono_radio_settings *rs,
				enum ofono_radio_access_mode mode,
				ofono_radio_settings_rat_mode_set_cb_t cb,
				void *data)
{
	struct radio_data *rd = ofono_radio_settings_get_data(rs);
	struct cb_data *cbd = cb_data_new(cb, data, rs);
	struct parcel rilp;
	int pref = PREF_NET_TYPE_GSM_WCDMA;

	switch (mode) {
	case OFONO_RADIO_ACCESS_MODE_ANY:
		pref = PREF_NET_TYPE_LTE_GSM_WCDMA;
		break;
	case OFONO_RADIO_ACCESS_MODE_GSM:
		pref = PREF_NET_TYPE_GSM_ONLY;
		break;
	case OFONO_RADIO_ACCESS_MODE_UMTS:
		pref = PREF_NET_TYPE_GSM_WCDMA;
		break;
	case OFONO_RADIO_ACCESS_MODE_LTE:
		pref = PREF_NET_TYPE_LTE_GSM_WCDMA;
		break;
	}

	g_ril_request_set_preferred_network_type(rd->ril, pref, &rilp);

	if (g_ril_send(rd->ril, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,
				&rilp, ril_set_rat_cb, cbd, g_free) == 0) {
		ofono_error("%s: unable to set rat mode", __func__);
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}
Exemplo n.º 30
0
Arquivo: sim.c Projeto: morphis/ofono
static void ril_pin_change_state(struct ofono_sim *sim,
				enum ofono_sim_password_type passwd_type,
				int enable, const char *passwd,
				ofono_sim_lock_unlock_cb_t cb, void *data)
{
	struct sim_data *sd = ofono_sim_get_data(sim);
	struct cb_data *cbd;
	struct parcel rilp;
	struct req_pin_change_state req;
	int ret = 0;

	/*
	 * If we want to unlock a password that has not been entered yet,
	 * we enter it before trying to unlock. We need sd->unlock_pending as
	 * the password still has not yet been refreshed when this function is
	 * called from enter_pin_done().
	 */
	if (ofono_sim_get_password_type(sim) == passwd_type
			&& enable == FALSE && sd->unlock_pending == FALSE) {
		struct change_state_cbd *csd = g_malloc0(sizeof(*csd));
		csd->sim = sim;
		csd->passwd_type = passwd_type;
		csd->enable = enable;
		csd->passwd = passwd;
		csd->cb = cb;
		csd->data = data;
		sd->unlock_pending = TRUE;

		ril_pin_send(sim, passwd, enter_pin_done, csd);

		return;
	}

	sd->unlock_pending = FALSE;

	cbd = cb_data_new(cb, data, sim);

	sd->passwd_type = passwd_type;

	req.aid_str = sd->aid_str;
	req.passwd_type = passwd_type;
	req.enable = enable;
	req.passwd = passwd;

	if (!g_ril_request_pin_change_state(sd->ril,
						&req,
						&rilp)) {
		ofono_error("Couldn't build pin change state request");
		goto error;
	}

	ret = g_ril_send(sd->ril, RIL_REQUEST_SET_FACILITY_LOCK, &rilp,
				ril_pin_change_state_cb, cbd, g_free);

error:
	if (ret == 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	}
}