Example #1
0
static void ril_ussd_notify(struct ril_msg *message, gpointer user_data)
{
	struct ofono_ussd *ussd = user_data;
	struct ussd_data *ud = ofono_ussd_get_data(ussd);
	struct unsol_ussd *unsol;

	unsol = g_ril_unsol_parse_ussd(ud->ril, message);
	if (unsol == NULL) {
		ofono_error("%s: Parsing error", __func__);
		return;
	}

	/*
	 * TODO
	 *
	 * With data coding scheme 0x44, we are saying that the ussd string is
	 * 8-bit data, uncompressed, and with unspecified message class. This
	 * must be changed in the future so we get the UTF16 from the RIL parcel
	 * and decode it properly. For the DCS coding, see 3gpp 23.038, sect. 5.
	 */
	if (unsol->message != NULL)
		ofono_ussd_notify(ussd, unsol->type, 0x44,
					(const unsigned char *) unsol->message,
					strlen(unsol->message));
	else
		ofono_ussd_notify(ussd, unsol->type, 0, NULL, 0);

	g_ril_unsol_free_ussd(unsol);
}
Example #2
0
static void ril_ussd_notify(struct ril_msg *message, gpointer user_data)
{
	struct ofono_ussd *ussd = user_data;
	struct ussd_data *ud = ofono_ussd_get_data(ussd);
	struct unsol_ussd *unsol;
	enum ofono_ril_vendor vendor;

	unsol = g_ril_unsol_parse_ussd(ud->ril, message);
	if (unsol == NULL) {
		ofono_error("%s: Parsing error", __func__);
		return;
	}

	/* To fix bug in MTK: USSD-Notify arrive with type 2 instead of 0 */
	vendor = g_ril_vendor(ud->ril);
	if ((vendor == OFONO_RIL_VENDOR_MTK ||
				vendor == OFONO_RIL_VENDOR_MTK2)
			&& unsol->message != NULL && unsol->type == 2)
		unsol->type = 0;

	/*
	 * With data coding scheme 0x48, we are saying that the ussd string is a
	 * UCS-2 string, uncompressed, and with unspecified message class. For
	 * the DCS coding, see 3gpp 23.038, sect. 5.
	 */
	if (unsol->message != NULL) {
		gsize written;
		char *ucs2;

		ucs2 = g_convert(unsol->message, -1, "UCS-2BE//TRANSLIT",
					"UTF-8", NULL, &written, NULL);
		if (ucs2 != NULL) {
			ofono_ussd_notify(ussd, unsol->type, 0x48,
					(unsigned char *) ucs2, written);
			g_free(ucs2);
		} else {
			ofono_error("%s: Error transcoding", __func__);
		}
	} else {
		ofono_ussd_notify(ussd, unsol->type, 0, NULL, 0);
	}

	g_ril_unsol_free_ussd(unsol);
}