summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorYang Gu <yang.gu@intel.com>2010-06-17 18:35:10 +0800
committerDenis Kenzior <denkenz@gmail.com>2010-06-21 09:19:01 -0500
commitc80432bfde1bdea41ec7d079f9ad064a0f493a11 (patch)
tree7a27aeb6b3f82c5302a1d0387d0afb3b6ef7f8b8 /drivers
parent11d9063e575dd8c8bc54ff384ff9349459b88899 (diff)
Refactor ussd parser
Diffstat (limited to 'drivers')
-rw-r--r--drivers/isimodem/ussd.c35
1 files changed, 6 insertions, 29 deletions
diff --git a/drivers/isimodem/ussd.c b/drivers/isimodem/ussd.c
index 8be20b68..7002d099 100644
--- a/drivers/isimodem/ussd.c
+++ b/drivers/isimodem/ussd.c
@@ -73,44 +73,21 @@ static void ussd_parse(struct ofono_ussd *ussd, const void *restrict data,
size_t len)
{
const unsigned char *msg = data;
- unsigned char buf[256];
- unsigned char *unpacked;
- long written;
- int status;
+ int status = OFONO_USSD_STATUS_NOT_SUPPORTED;
char *converted = NULL;
- gboolean udhi;
- enum sms_charset charset;
- gboolean compressed;
- gboolean iso639;
if (!msg || len < 4)
- goto error;
+ goto out;
status = isi_type_to_status(msg[2]);
if (msg[3] == 0 || (size_t)(msg[3] + 4) > len)
- goto error;
-
- if (!cbs_dcs_decode(msg[1], &udhi, NULL, &charset,
- &compressed, NULL, &iso639))
- goto error;
-
- if (udhi || compressed || iso639)
- goto error;
-
- if (charset != SMS_CHARSET_7BIT)
- goto error;
-
- unpacked = unpack_7bit_own_buf(msg + 4, msg[3], 0, TRUE,
- SS_MAX_USSD_LENGTH, &written, 0, buf);
+ goto out;
- converted = convert_gsm_to_utf8((const guint8 *)unpacked, written,
- NULL, NULL, 0);
+ converted = ussd_decode(msg[1], msg[3], msg + 4);
- goto out;
-
-error:
- status = OFONO_USSD_STATUS_NOT_SUPPORTED;
+ if (converted)
+ status = OFONO_USSD_STATUS_NOTIFY;
out:
ofono_ussd_notify(ussd, status, converted);