Пример #1
0
static void ril_ussd_request(struct ofono_ussd *ussd, int dcs,
			const unsigned char *pdu, int len,
			ofono_ussd_cb_t cb, void *data)
{
	struct ussd_data *ud = ofono_ussd_get_data(ussd);
	struct cb_data *cbd = cb_data_new(cb, data, ussd);
	enum sms_charset charset;
	char *text = NULL;
	int ret = 0;

	if (cbs_dcs_decode(dcs, NULL, NULL, &charset, NULL, NULL, NULL)) {

		if (charset == SMS_CHARSET_7BIT) {
			long written;

			text = (char *) unpack_7bit(pdu, len, 0, TRUE,
							0, &written, 1);
			if (text != NULL)
				*(text + written) = '\0';

		} else if (charset == SMS_CHARSET_UCS2) {
			text = g_convert((char *) pdu, len,
					"UTF-8//TRANSLIT", "UCS-2BE",
					NULL, NULL, NULL);
		} else {
			ofono_error("%s: No support for charset %d",
					__func__, charset);
		}
	}

	if (text) {
		struct parcel rilp;

		g_ril_request_send_ussd(ud->ril, text, &rilp);

		ret = g_ril_send(ud->ril, RIL_REQUEST_SEND_USSD,
					&rilp, ril_ussd_cb, ussd, NULL);
		g_free(text);
	}

	/*
	 * We do not wait for the SEND_USSD reply to do the callback, as some
	 * networks send it after sending one or more ON_USSD events. From the
	 * ofono core perspective, Initiate() does not return until one ON_USSD
	 * event is received: making here a successful callback just makes the
	 * core wait for that event.
	 */
	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	} else {
		g_idle_add(request_success, cbd);
	}
}
Пример #2
0
static void ril_ussd_request(struct ofono_ussd *ussd, int dcs,
			const unsigned char *pdu, int len,
			ofono_ussd_cb_t cb, void *data)
{
	struct ussd_data *ud = ofono_ussd_get_data(ussd);
	struct cb_data *cbd = cb_data_new(cb, data, ussd);
	enum sms_charset charset;
	int ret = 0;

	if (cbs_dcs_decode(dcs, NULL, NULL, &charset, NULL, NULL, NULL)) {
		/* TODO: send other alphabets (maybe needed by STK) */
		if (charset == SMS_CHARSET_7BIT) {
			unsigned char *unpacked_buf;
			long written;

			unpacked_buf = unpack_7bit(pdu, len, 0, TRUE, 0,
							&written, 1);

			if (written >= 1) {
				struct parcel rilp;

				*(unpacked_buf + written) = '\0';
				g_ril_request_send_ussd(ud->ril,
							(char *) unpacked_buf,
							&rilp);

				ret = g_ril_send(ud->ril, RIL_REQUEST_SEND_USSD,
							&rilp, ril_ussd_cb,
							ussd, NULL);
			}

			g_free(unpacked_buf);
		} else {
			ofono_error("%s: No support for charset %d",
					__func__, charset);
		}
	}

	/*
	 * We do not wait for the SEND_USSD reply to do the callback, as some
	 * networks send it after sending one or more ON_USSD events. From the
	 * ofono core perspective, Initiate() does not return until one ON_USSD
	 * event is received: making here a successful callback just makes the
	 * core wait for that event.
	 */
	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	} else {
		g_idle_add(request_success, cbd);
	}
}
Пример #3
0
static void ril_ussd_request(struct ofono_ussd *ussd, int dcs,
			const unsigned char *pdu, int len,
			ofono_ussd_cb_t cb, void *data)
{
	struct ussd_data *ud = ofono_ussd_get_data(ussd);
	struct cb_data *cbd = cb_data_new(cb, data);
	enum sms_charset charset;
	int ret = -1;

	if (cbs_dcs_decode(dcs, NULL, NULL, &charset,
					NULL, NULL, NULL)) {
		if (charset == SMS_CHARSET_7BIT) {
			unsigned char unpacked_buf[182] = "";
			long written;

			unpack_7bit_own_buf(pdu, len, 0, TRUE,
					sizeof(unpacked_buf), &written, 0,
					unpacked_buf);

			if (written >= 1) {
				struct parcel rilp;
				parcel_init(&rilp);
				parcel_w_string(&rilp, (char *)unpacked_buf);
				ret = g_ril_send(ud->ril,
						RIL_REQUEST_SEND_USSD,
						rilp.data, rilp.size,
						ril_ussd_cb, cbd, g_free);
				parcel_free(&rilp);
			}
		}
	}

	/*
	 * It cannot be guaranteed that response is received before notify or
	 * user-activity request so we must complete the request now and later
	 * ignore the actual response.
	 */
	if (ret <= 0) {
		g_free(cbd);
		CALLBACK_WITH_FAILURE(cb, data);
	} else {
		CALLBACK_WITH_SUCCESS(cb, cbd->data);
	}

}