---
drivers/isimodem/ussd.c | 56 ++++++++++++++++++++++++++++------------------
1 files changed, 34 insertions(+), 22 deletions(-)
diff --git a/drivers/isimodem/ussd.c b/drivers/isimodem/ussd.c
index d164d10..7ed81f5 100644
--- a/drivers/isimodem/ussd.c
+++ b/drivers/isimodem/ussd.c
@@ -74,7 +74,9 @@ static void ussd_parse(struct ofono_ussd *ussd, const void *restrict
data,
{
const unsigned char *msg = data;
int status = OFONO_USSD_STATUS_NOT_SUPPORTED;
- char *converted = NULL;
+ int msg_len = 0;
+ int dcs = -1;
+ unsigned char *coded_msg = NULL;
if (!msg || len < 4)
goto out;
@@ -84,14 +86,12 @@ static void ussd_parse(struct ofono_ussd *ussd, const void *restrict
data,
if (msg[3] == 0 || (size_t)(msg[3] + 4) > len)
goto out;
- converted = ussd_decode(msg[1], msg[3], msg + 4);
-
- if (converted)
- status = OFONO_USSD_STATUS_NOTIFY;
-
+ dcs = msg[1];
+ msg_len = msg[3];
+ coded_msg = g_memdup(msg+4, msg_len);
out:
- ofono_ussd_notify(ussd, status, converted);
- g_free(converted);
+ ofono_ussd_notify(ussd, status, dcs, coded_msg, msg_len);
+ g_free(coded_msg);
}
@@ -130,8 +130,8 @@ out:
return TRUE;
}
-static GIsiRequest *ussd_send_make(GIsiClient *client, uint8_t *str,
- size_t len, void *data)
+static GIsiRequest *ussd_send_make(GIsiClient *client, int dcs, uint8_t *str,
+ size_t len, void *data)
{
const uint8_t msg[] = {
SS_GSM_USSD_SEND_REQ,
@@ -139,7 +139,7 @@ static GIsiRequest *ussd_send_make(GIsiClient *client, uint8_t *str,
0x01, /* subblock count */
SS_GSM_USSD_STRING,
4 + len + 3, /* subblock length */
- 0x0f, /* DCS */
+ dcs, /* DCS */
len, /* string length */
/* USSD string goes here */
};
@@ -153,8 +153,9 @@ static GIsiRequest *ussd_send_make(GIsiClient *client, uint8_t *str,
ussd_send_resp_cb, data);
}
-static void isi_request(struct ofono_ussd *ussd, const char *str,
- ofono_ussd_cb_t cb, void *data)
+static void isi_request(struct ofono_ussd *ussd, int dcs,
+ const unsigned char *str, int str_len,
+ ofono_ussd_cb_t cb, void *data)
{
struct ussd_data *ud = ofono_ussd_get_data(ussd);
struct isi_cb_data *cbd = isi_cb_data_new(ussd, cb, data);
@@ -163,24 +164,35 @@ static void isi_request(struct ofono_ussd *ussd, const char *str,
unsigned char *converted = NULL;
long num_packed;
long written;
+ int dcs_value = 0x0f; // GSM 7 bit default alphabet
if (!cbd)
goto error;
- converted = convert_utf8_to_gsm(str, strlen(str), NULL, &written, 0);
- if (!converted)
- goto error;
+ if (dcs == -1){
+ converted = convert_utf8_to_gsm((const char *) str, str_len, NULL, &written, 0);
- packed = pack_7bit_own_buf(converted, written, 0, TRUE,
- &num_packed, 0, buf);
+ if (!converted)
+ goto error;
- g_free(converted);
+ packed = pack_7bit_own_buf(converted, written, 0, TRUE,
+ &num_packed, 0, buf);
- if (written > SS_MAX_USSD_LENGTH)
+ g_free(converted);
+
+ if (written > SS_MAX_USSD_LENGTH)
goto error;
- if (ussd_send_make(ud->client, packed, num_packed, cbd))
- return;
+ if (ussd_send_make(ud->client, dcs_value, packed, num_packed, cbd))
+ return;
+ }else{
+ dcs_value = dcs;
+ if (str_len > SS_MAX_USSD_LENGTH)
+ goto error;
+
+ if (ussd_send_make(ud->client, dcs_value, (guint8 *) str, str_len, cbd))
+ return;
+ }
error:
CALLBACK_WITH_FAILURE(cb, data);
--
1.7.0.4
----------------------------------------------------------------
Please note: This e-mail may contain confidential information
intended solely for the addressee. If you have received this
e-mail in error, please do not disclose it to anyone, notify
the sender promptly, and delete the message from your system.
Thank you.
----------------------------------------------------------------
Please note: This e-mail may contain confidential information
intended solely for the addressee. If you have received this
e-mail in error, please do not disclose it to anyone, notify
the sender promptly, and delete the message from your system.
Thank you.