aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeevaka Badrappan <jeevaka.badrappan@elektrobit.com>2010-09-28 04:09:30 -0700
committerDenis Kenzior <denkenz@gmail.com>2010-09-28 21:09:24 -0500
commit32197645279c470ac913edd5b5c666421ba3aa6d (patch)
tree298f189dbee27dc366d638ee6500b1b7474c9a35
parentde4508b194d8eb9fa218895e7c915cd2baa9976c (diff)
downloadphonesim-32197645279c470ac913edd5b5c666421ba3aa6d.tar.gz
phonesim: simulate Send USSD in sim app
-rw-r--r--src/default.xml23
-rw-r--r--src/qsimcommand.cpp6
-rwxr-xr-x[-rw-r--r--]src/simapplication.cpp114
-rw-r--r--src/simapplication.h2
4 files changed, 142 insertions, 3 deletions
diff --git a/src/default.xml b/src/default.xml
index 135bad3..4287639 100644
--- a/src/default.xml
+++ b/src/default.xml
@@ -1955,7 +1955,28 @@
</chat>
<chat>
- <!-- Initiate USSD query that is not supported b the network -->
+ <!-- SAT initiated 7-Bit USSD query that is supported by the network -->
+ <command>AT+CUSD=1,"ABCD",240</command>
+ <response>+CUSD: 0,"USSD string received from SS",240\n\nOK</response>
+ <set name="USD" value="1"/>
+</chat>
+
+<chat>
+ <!-- SAT initiated 8-Bit USSD query that is supported by the network -->
+ <command>AT+CUSD=1,"41424344",68</command>
+ <response>+CUSD: 0,"5553534420737472696E672072656365697665642066726F6D205353",68\n\nOK</response>
+ <set name="USD" value="1"/>
+</chat>
+
+<chat>
+ <!-- SAT initiated UCS2 USSD query that is supported by the network -->
+ <command>AT+CUSD=1,"041704140420041004120421042204120423041904220415",72</command>
+ <response>+CUSD: 0,"005500530053004400200073007400720069006E0067002000720065006300650069007600650064002000660072006F006D002000530053",72\n\nOK</response>
+ <set name="USD" value="1"/>
+</chat>
+
+<chat>
+ <!-- Initiate USSD query that is not supported by the network -->
<command>AT+CUSD=1,*</command>
<response>+CUSD: 4\n\nOK</response>
<set name="USD" value="1"/>
diff --git a/src/qsimcommand.cpp b/src/qsimcommand.cpp
index df2422c..44bdd9a 100644
--- a/src/qsimcommand.cpp
+++ b/src/qsimcommand.cpp
@@ -3162,8 +3162,10 @@ QByteArray QSimCommand::toPdu( QSimCommand::ToPduOptions options ) const
writeEFADN( data, text(), QSimCommand::NoPduOptions );
if ( ( options & QSimCommand::PackedStrings ) != 0 )
writeTextString( data, number(), options, 0xF08A );
- else
- writeTextString( data, number(), options, 0x408A );
+ else if ( ( options & QSimCommand::UCS2Strings ) != 0 )
+ writeTextString( data, number(), options, 0x488A );
+ else // 8-Bit USSD
+ writeTextString( data, number(), options, 0x448A );
writeIcon( data, iconId(), iconSelfExplanatory(), true );
writeTextAttribute( data, textAttribute() );
}
diff --git a/src/simapplication.cpp b/src/simapplication.cpp
index cc2094d..7dc580f 100644..100755
--- a/src/simapplication.cpp
+++ b/src/simapplication.cpp
@@ -20,6 +20,7 @@
#include "simapplication.h"
#include <qatutils.h>
#include <qdebug.h>
+#include <QTextCodec>
class SimApplicationPrivate
{
@@ -282,6 +283,7 @@ const QString DemoSimApplication::getName()
#define MainMenu_DTMF 10
#define MainMenu_SendSS 11
#define MainMenu_Language 12
+#define MainMenu_SendUSSD 13
#define SportsMenu_Chess 1
#define SportsMenu_Painting 2
@@ -334,6 +336,12 @@ const QString DemoSimApplication::getName()
#define Language_Non_Specific 2
#define Language_Main 3
+#define SendUSSD_7Bit 1
+#define SendUSSD_8Bit 2
+#define SendUSSD_UCS2 3
+#define SendUSSD_Error 4
+#define SendUSSD_Main 5
+
void DemoSimApplication::mainMenu()
{
QSimCommand cmd;
@@ -390,6 +398,10 @@ void DemoSimApplication::mainMenu()
item.setLabel( "Language Notification" );
items += item;
+ item.setIdentifier( MainMenu_SendUSSD );
+ item.setLabel( "Send USSD" );
+ items += item;
+
cmd.setMenuItems( items );
command( cmd, 0, 0 );
@@ -496,6 +508,12 @@ void DemoSimApplication::mainMenuSelection( int id )
}
break;
+ case MainMenu_SendUSSD:
+ {
+ sendUSSDMenu();
+ }
+ break;
+
default:
{
// Don't know what this item is, so just re-display the main menu.
@@ -1718,3 +1736,99 @@ void DemoSimApplication::languageMenu( const QSimTerminalResponse& resp )
endSession();
}
}
+
+void DemoSimApplication::sendUSSDMenu()
+{
+ QSimCommand cmd;
+ QSimMenuItem item;
+ QList<QSimMenuItem> items;
+
+ cmd.setType( QSimCommand::SelectItem );
+ cmd.setTitle( "Send USSD" );
+
+ item.setIdentifier( SendUSSD_7Bit );
+ item.setLabel( "Send USSD - 7-Bit" );
+ items += item;
+
+ item.setIdentifier( SendUSSD_8Bit );
+ item.setLabel( "Send USSD - 8-Bit" );
+ items += item;
+
+ item.setIdentifier( SendUSSD_UCS2 );
+ item.setLabel( "Send USSD - UCS2" );
+ items += item;
+
+ item.setIdentifier( SendUSSD_Error );
+ item.setLabel( "Send USSD - Return Error" );
+ items += item;
+
+ item.setIdentifier( SendUSSD_Main );
+ item.setLabel( "Return to main menu" );
+ items += item;
+
+ cmd.setMenuItems( items );
+
+ command( cmd, this, SLOT(USSDMenu(QSimTerminalResponse)) );
+}
+
+void DemoSimApplication::USSDMenu( const QSimTerminalResponse& resp )
+{
+ QSimCommand cmd;
+
+ if ( resp.result() == QSimTerminalResponse::Success ) {
+
+ // Item selected.
+ switch ( resp.menuItem() ) {
+ case SendUSSD_7Bit:
+ {
+ cmd.setType( QSimCommand::SendUSSD );
+ cmd.setDestinationDevice( QSimCommand::Network );
+ cmd.setText( "7-bit USSD" );
+ cmd.setNumber( "ABCD" );
+ command( cmd, this, SLOT(sendUSSDMenu()),
+ QSimCommand::PackedStrings );
+ }
+ break;
+
+ case SendUSSD_8Bit:
+ {
+ cmd.setType( QSimCommand::SendUSSD );
+ cmd.setDestinationDevice( QSimCommand::Network );
+ cmd.setText( "8-bit USSD" );
+ cmd.setNumber( "ABCD" );
+ command( cmd, this, SLOT(sendUSSDMenu()) );
+ }
+ break;
+
+ case SendUSSD_UCS2:
+ {
+ cmd.setType( QSimCommand::SendUSSD );
+ cmd.setDestinationDevice( QSimCommand::Network );
+ cmd.setText( "UCS2 USSD" );
+ QTextCodec *codec = QTextCodec::codecForName( "utf8" );
+ cmd.setNumber( codec->toUnicode( "ЗДРАВСТВУЙТЕ" ) );
+ command( cmd, this, SLOT(sendUSSDMenu()),
+ QSimCommand::UCS2Strings );
+ }
+ break;
+
+ case SendUSSD_Error:
+ {
+ cmd.setType( QSimCommand::SendUSSD );
+ cmd.setDestinationDevice( QSimCommand::Network );
+ cmd.setText( "7-bit USSD" );
+ cmd.setNumber( "*100#" );
+ command( cmd, this, SLOT(sendUSSDMenu()),
+ QSimCommand::PackedStrings );
+ }
+ break;
+
+ default:
+ endSession();
+ break;
+ }
+ } else {
+ // Unknown response - just go back to the main menu.
+ endSession();
+ }
+}
diff --git a/src/simapplication.h b/src/simapplication.h
index fc57423..9d147ee 100644
--- a/src/simapplication.h
+++ b/src/simapplication.h
@@ -111,6 +111,8 @@ protected slots:
void CoLRMenu( const QSimTerminalResponse& resp );
void sendLanguageMenu();
void languageMenu( const QSimTerminalResponse& resp );
+ void sendUSSDMenu();
+ void USSDMenu( const QSimTerminalResponse& resp );
private:
int sticksLeft;