diff options
author | Philippe Nunes <philippe.nunes@linux.intel.com> | 2012-06-25 16:38:03 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2012-06-22 09:05:13 -0500 |
commit | b2c90295bb907f060bf57507778ea5e07bac3da3 (patch) | |
tree | 8b885eec43eeb387db31b0ffea19f588fab0434c | |
parent | 110f1483154d221cd18ebab8a5f5547c40c23985 (diff) | |
download | phonesim-b2c90295bb907f060bf57507778ea5e07bac3da3.tar.gz |
hardwaremanipulator: Add USC2 encoding for USSD
-rw-r--r-- | src/hardwaremanipulator.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/hardwaremanipulator.cpp b/src/hardwaremanipulator.cpp index 909ce2a..2d7b141 100644 --- a/src/hardwaremanipulator.cpp +++ b/src/hardwaremanipulator.cpp @@ -287,14 +287,37 @@ void HardwareManipulator::sendVMNotify( int type, int count, const QList<QVMMess void HardwareManipulator::sendUSSD( bool cancel, bool response, const QString &content ) { - QTextCodec *codec = QAtUtils::codec( rules->variable("SCS") ); /* TODO: if rules->variable("USD") == "0" then return */ if (cancel) emit unsolicitedCommand( "+CUSD: 2" ); - else + else { + QTextCodec *codec = QAtUtils::codec( "gsm-noloss" ); + bool gsmSafe; + QString request; + + // Check the body for non-GSM characters. + gsmSafe = codec->canEncode( content ); + + // Use the default alphabet if everything is GSM-compatible. + if ( gsmSafe ) { + QTextCodec *codec = QAtUtils::codec( rules->variable("SCS") ); + request= QAtUtils::quote( content, codec ); + } else { + // Encode the text using the 16-bit UCS2 alphabet. + uint u; + QByteArray binary; + uint len = content.length(); + + for ( u = 0; u < len; u++ ) { + binary += (unsigned char)(content[u].unicode() >> 8); + binary += (unsigned char)(content[u].unicode() & 0xFF); + } + request = PS_toHex( binary ); + } emit unsolicitedCommand( "+CUSD: " + - QString::number( response ? 1 : 0 ) + ",\"" + - QAtUtils::quote( content, codec ) + "\",0" ); + QString::number( response ? 1 : 0 ) + ",\"" + + request + "\"," + QString::number( gsmSafe ? 0 : 0x48 )); + } } bool HardwareManipulator::getSimPresent() |