diff options
author | Michal Čihař <nijel@debian.org> | 2017-10-18 10:25:29 +0200 |
---|---|---|
committer | Michal Čihař <nijel@debian.org> | 2017-10-18 10:25:29 +0200 |
commit | 1b4e1bec085a3a96d5683821a5f8875db8a45964 (patch) | |
tree | 1621cd0cb4fbbb567af9adb2516ee4c40ff9bbee /libgammu/phone/at/atgen.c | |
parent | 105250a08aeaef4c4690ac00d4f956d04bc3a9f5 (diff) | |
parent | aad5c0f31b8583d1de28434597fb81a2079434a0 (diff) |
Updated version 1.38.5 from 'upstream/1.38.5'
with Debian dir ec9e041589bbe58997654cc8ebb3f0cd170098ed
Diffstat (limited to 'libgammu/phone/at/atgen.c')
-rw-r--r-- | libgammu/phone/at/atgen.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/libgammu/phone/at/atgen.c b/libgammu/phone/at/atgen.c index 29ee97e..8d9ac36 100644 --- a/libgammu/phone/at/atgen.c +++ b/libgammu/phone/at/atgen.c @@ -1618,7 +1618,7 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_USSDMessage ussd; - GSM_Error error; + GSM_Error error = ERR_NONE; unsigned char *pos = NULL; int code = 0; int dcs = 0; @@ -1676,10 +1676,12 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s) break; case 4: ussd.Status = USSD_NotSupported; - return ERR_NETWORK_ERROR; + error = ERR_NETWORK_ERROR; + goto done; case 5: ussd.Status = USSD_Timeout; - return ERR_TIMEOUT; + error = ERR_TIMEOUT; + goto done; default: ussd.Status = USSD_Unknown; } @@ -1699,7 +1701,7 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s) hex_encoded, sizeof(hex_encoded)); } if (error != ERR_NONE) { - return error; + goto done; } if ((dcs & 0xc0) == 0) { @@ -1731,7 +1733,10 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s) GSM_UnpackEightBitsToSeven(0, strlen(hex_encoded), sizeof(decoded), packed, decoded); DecodeDefault(ussd.Text, decoded, strlen(decoded), TRUE, NULL); } else { - DecodeDefault(ussd.Text, hex_encoded, strlen(hex_encoded), TRUE, NULL); + error = ATGEN_DecodeText(s, hex_encoded, strlen(hex_encoded), ussd.Text, sizeof(ussd.Text) - 1, FALSE, FALSE); + if (error != ERR_NONE) { + return error; + } } } else if (coding == SMS_Coding_Unicode_No_Compression) { DecodeHexUnicode(ussd.Text, hex_encoded + offset, strlen(hex_encoded)); @@ -1749,17 +1754,18 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s) &code, ussd.Text, sizeof(ussd.Text)); if (error != ERR_NONE) { - return error; + goto done; } } +done: /* Notify application */ if (s->User.IncomingUSSD != NULL) { s->User.IncomingUSSD(s, &ussd, s->User.IncomingUSSDUserData); } } - return ERR_NONE; + return error; } GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, gboolean enable) @@ -4405,7 +4411,11 @@ GSM_Error ATGEN_DialService(GSM_StateMachine *s, char *number) return ERR_MOREMEMORY; } /* Prefer unicode to be able to deal with unicode response */ - error = ATGEN_SetCharset(s, AT_PREF_CHARSET_UNICODE); + if (GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_USSD_GSM_CHARSET)) { + error = ATGEN_SetCharset(s, AT_PREF_CHARSET_GSM); + } else { + error = ATGEN_SetCharset(s, AT_PREF_CHARSET_UNICODE); + } if (error != ERR_NONE) { free(req); @@ -4496,7 +4506,7 @@ GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode *Code) { GSM_Error error; GSM_SecurityCodeType Status; - unsigned char req[GSM_SECURITY_CODE_LEN + 12] = {'\0'}; + unsigned char req[GSM_SECURITY_CODE_LEN + 30] = {'\0'}; size_t len; if (Code->Type == SEC_Pin2 && @@ -6229,6 +6239,7 @@ GSM_Reply_Function ATGENReplyFunctions[] = { {ATGEN_GenericReplyIgnore, "+ZEND" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_GenericReplyIgnore, "+CDSI:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_GenericReplyIgnore, "+CLCC:" ,0x00,0x00,ID_IncomingFrame }, +{ATGEN_GenericReplyIgnore, "#STN:" ,0x00,0x00,ID_IncomingFrame }, /* Sony Ericsson screenshot */ {SONYERICSSON_Reply_Screenshot, "AT*ZISI=?\r", 0x00,0x00,ID_Screenshot }, |