Open Source Telephony
 help / color / mirror / Atom feed
From: Philippe Nunes <philippe.nunes@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 7/7] hardwaremanipulator: Add USC2 encoding support for USSD.
Date: Mon, 25 Jun 2012 16:38:03 +0200	[thread overview]
Message-ID: <1340635083-5877-8-git-send-email-philippe.nunes@linux.intel.com> (raw)
In-Reply-To: <1340635083-5877-1-git-send-email-philippe.nunes@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2041 bytes --]

---
 src/hardwaremanipulator.cpp |   31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/hardwaremanipulator.cpp b/src/hardwaremanipulator.cpp
index b746229..056480c 100644
--- a/src/hardwaremanipulator.cpp
+++ b/src/hardwaremanipulator.cpp
@@ -320,14 +320,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()
-- 
1.7.9.5


  parent reply	other threads:[~2012-06-25 14:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25 14:37 [PATCH 0/7] phonesim: Add UCS2 encoding support for CBS/USSD Philippe Nunes
2012-06-25 14:37 ` [PATCH 1/7] control: Fix empty sender checking Philippe Nunes
2012-06-22  8:20   ` Denis Kenzior
2012-06-25 14:37 ` [PATCH 2/7] controbase: Add combobox for CBS scheme selection Philippe Nunes
2012-06-22  8:08   ` Denis Kenzior
2012-06-25 14:37 ` [PATCH 3/7] qcbsmessage: Extend QCBSMessage class Philippe Nunes
2012-06-22 14:36   ` Denis Kenzior
2012-06-25 14:38 ` [PATCH 4/7] hardwaremanipulator: Add UCS2 encoding support for CBS message Philippe Nunes
2012-06-25 14:38 ` [PATCH 5/7] hardwaremanipulator: Add multi-page " Philippe Nunes
2012-06-22  8:12   ` Denis Kenzior
2012-06-25 14:38 ` [PATCH 6/7] sms: Extend CBS message formating to use UCS2 scheme Philippe Nunes
2012-06-22 14:36   ` Denis Kenzior
2012-06-25 14:38 ` Philippe Nunes [this message]
2012-06-22 14:09   ` [PATCH 7/7] hardwaremanipulator: Add USC2 encoding support for USSD Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340635083-5877-8-git-send-email-philippe.nunes@linux.intel.com \
    --to=philippe.nunes@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox