phonesim: Add Send Short Message commands to sim app menu.
PATCH 1/4 phonesim: Add Send Short Message commands to sim app menu.
--- src/simapplication.cpp | 148 +++++++++++++++++++++++++++++++++++++++++++++++- src/simapplication.h | 5 ++ 2 files changed, 152 insertions(+), 1 deletions(-)
src/simapplication.cpp +147 -1
@@ -21,6 +21,7 @@ #include <qatutils.h> #include <qdebug.h> #include <QTextCodec> +#include "qsmsmessage.h" class SimApplicationPrivate {
@@ -258,7 +259,8 @@ void SimApplication::endSession() } DemoSimApplication::DemoSimApplication( SimRules *rules, QObject *parent ) - : SimApplication( rules, parent ) + : SimApplication( rules, parent ), smsDestNumber( "12345" ), + smsText( "Hello" ) { }
@@ -284,6 +286,7 @@ const QString DemoSimApplication::getName() #define MainMenu_SendSS 11 #define MainMenu_Language 12 #define MainMenu_SendUSSD 13 +#define MainMenu_SendSMS 14 #define SportsMenu_Chess 1 #define SportsMenu_Painting 2
@@ -342,6 +345,13 @@ const QString DemoSimApplication::getName() #define SendUSSD_Error 4 #define SendUSSD_Main 5 +enum SendSMSMenuItems { + SendSMS_Unpacked = 1, + SendSMS_Packed, + SendSMS_SetDestination, + SendSMS_SetContents, +}; + void DemoSimApplication::mainMenu() { QSimCommand cmd;
@@ -402,6 +412,10 @@ void DemoSimApplication::mainMenu() item.setLabel( "Send USSD" ); items += item; + item.setIdentifier( MainMenu_SendSMS ); + item.setLabel( "Send SMS request" ); + items += item; + cmd.setMenuItems( items ); command( cmd, 0, 0 );
@@ -514,6 +528,12 @@ void DemoSimApplication::mainMenuSelection( int id ) } break; + case MainMenu_SendSMS: + { + sendSMSMenu(); + } + break; + default: { // Don't know what this item is, so just re-display the main menu.
@@ -1832,3 +1852,129 @@ void DemoSimApplication::USSDMenu( const QSimTerminalResponse& resp ) endSession(); } } + +void DemoSimApplication::sendSMSMenu() +{ + QSimCommand cmd; + QSimMenuItem item; + QList<QSimMenuItem> items; + + cmd.setType( QSimCommand::SelectItem ); + cmd.setTitle( "Send SMS" ); + + item.setIdentifier( SendSMS_Unpacked ); + item.setLabel( "Unpacked" ); + items += item; + + item.setIdentifier( SendSMS_Packed ); + item.setLabel( "Packed text" ); + items += item; + + item.setIdentifier( SendSMS_SetDestination ); + item.setLabel( "Set destination (" + smsDestNumber + ")" ); + items += item; + + item.setIdentifier( SendSMS_SetContents ); + item.setLabel( "Set content text" ); + items += item; + + cmd.setMenuItems( items ); + + command( cmd, this, SLOT(smsMenuResp(QSimTerminalResponse)) ); +} + +void DemoSimApplication::smsMenuResp( const QSimTerminalResponse& resp ) +{ + QSimCommand cmd; + + if ( resp.result() != QSimTerminalResponse::Success ) { + /* Unknown response - just go back to the main menu. */ + endSession(); + + return; + } + + /* Item selected. */ + switch ( resp.menuItem() ) { + case SendSMS_Unpacked: + break; + + case SendSMS_Packed: + cmd.setSmsPacking( true ); + break; + + case SendSMS_SetDestination: + cmd.setType( QSimCommand::GetInput ); + cmd.setText( "Enter recipient number" ); + cmd.setWantDigits( true ); + cmd.setMinimumLength( 2 ); + cmd.setMaximumLength( 20 ); + cmd.setDefaultText( smsDestNumber ); + command( cmd, this, SLOT(smsSetDestResp(QSimTerminalResponse)) ); + return; + + case SendSMS_SetContents: + cmd.setType( QSimCommand::GetInput ); + cmd.setText( "Enter message text" ); + cmd.setMaximumLength( 100 ); + cmd.setDefaultText( smsText ); + command( cmd, this, SLOT(smsSetTextResp(QSimTerminalResponse)) ); + return; + } + + QSMSMessage sms; + sms.setValidityPeriod( -1 ); + sms.setMessageClass( 2 ); + sms.setProtocol( 0 ); + sms.setRecipient( smsDestNumber ); + sms.setText( smsText ); + sms.setForceGsm( false ); + sms.setBestScheme( QSMS_8BitAlphabet ); + sms.setDataCodingScheme( 0xf6 ); + + cmd.setType( QSimCommand::SendSMS ); + cmd.setText( "Sending an SMS to our friends at " + smsDestNumber ); + cmd.setNumber( "123" ); + cmd.addExtensionField( 0x8b, sms.toPdu().mid( 1 ) ); + cmd.setDestinationDevice( QSimCommand::Network ); + + command( cmd, this, SLOT(endSession()) ); +} + +void DemoSimApplication::smsSetDestResp( const QSimTerminalResponse& resp ) +{ + if ( resp.result() == QSimTerminalResponse::BackwardMove ) { + sendSMSMenu(); + + return; + } + + if ( resp.result() != QSimTerminalResponse::Success ) { + /* Unknown response - just go back to the main menu. */ + endSession(); + + return; + } + + smsDestNumber = resp.text(); + sendSMSMenu(); +} + +void DemoSimApplication::smsSetTextResp( const QSimTerminalResponse& resp ) +{ + if ( resp.result() == QSimTerminalResponse::BackwardMove ) { + sendSMSMenu(); + + return; + } + + if ( resp.result() != QSimTerminalResponse::Success ) { + /* Unknown response - just go back to the main menu. */ + endSession(); + + return; + } + + smsText = resp.text(); + sendSMSMenu(); +}
src/simapplication.h +5 -0
@@ -113,10 +113,15 @@ protected slots: void languageMenu( const QSimTerminalResponse& resp );void sendUSSDMenu (); void USSDMenu( const QSimTerminalResponse& resp ); +void sendSMSMenu (); + void smsMenuResp( const QSimTerminalResponse& resp ); + void smsSetDestResp( const QSimTerminalResponse& resp ); + void smsSetTextResp( const QSimTerminalResponse& resp ); private:int sticksLeft;bool immediateResponse; + QString smsDestNumber, smsText; };#endif
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 2/4 phonesim: Add SIM Polling commands to sim app menu.
--- src/simapplication.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ src/simapplication.h | 2 + 3 files changed, 72 insertions(+), 4 deletions(-)
src/simapplication.cpp +66 -0
@@ -287,6 +287,7 @@ const QString DemoSimApplication::getName() #define MainMenu_Language 12 #define MainMenu_SendUSSD 13 #define MainMenu_SendSMS 14 +#define MainMenu_Polling 15 #define SportsMenu_Chess 1 #define SportsMenu_Painting 2
@@ -352,6 +353,11 @@ enum SendSMSMenuItems { SendSMS_SetContents, }; +enum PollingMenuItems { + Polling_Off = 1, + Polling_30s, +}; + void DemoSimApplication::mainMenu() { QSimCommand cmd;
@@ -416,6 +422,10 @@ void DemoSimApplication::mainMenu() item.setLabel( "Send SMS request" ); items += item; + item.setIdentifier( MainMenu_Polling ); + item.setLabel( "SIM Polling" ); + items += item; + cmd.setMenuItems( items ); command( cmd, 0, 0 );
@@ -534,6 +544,12 @@ void DemoSimApplication::mainMenuSelection( int id ) } break; + case MainMenu_Polling: + { + sendPollingMenu(); + } + break; + default: { // Don't know what this item is, so just re-display the main menu.
@@ -1978,3 +1994,53 @@ void DemoSimApplication::sendSMSSetTextResp( const QSimTerminalResponse& resp ) smsText = resp.text(); sendSMSMenu(); } + +void DemoSimApplication::sendPollingMenu() +{ + QSimCommand cmd; + QSimMenuItem item; + QList<QSimMenuItem> items; + + cmd.setType( QSimCommand::SelectItem ); + cmd.setTitle( "Polling Menu" ); + + item.setIdentifier( Polling_Off ); + item.setLabel( "Polling Off" ); + items += item; + + item.setIdentifier( Polling_30s ); + item.setLabel( "Poll Interval of 30s" ); + items += item; + + cmd.setMenuItems( items ); + + command( cmd, this, SLOT(pollingMenuResp(QSimTerminalResponse)) ); +} + +void DemoSimApplication::pollingMenuResp( const QSimTerminalResponse& resp ) +{ + QSimCommand cmd; + + if ( resp.result() != QSimTerminalResponse::Success ) { + /* Unknown response - just go back to the main menu. */ + endSession(); + + return; + } + + /* Item selected. */ + switch ( resp.menuItem() ) { + case Polling_Off: + cmd.setType( QSimCommand::PollingOff ); + cmd.setDestinationDevice( QSimCommand::ME ); + command( cmd, this, SLOT(endSession()) ); + break; + + case Polling_30s: + cmd.setType( QSimCommand::PollInterval ); + cmd.setDuration( 30000 ); + cmd.setDestinationDevice( QSimCommand::ME ); + command( cmd, this, SLOT(endSession()) ); + break; + } +}
src/simapplication.h +2 -0
@@ -117,6 +117,8 @@ protected slots: void smsMenuResp( const QSimTerminalResponse& resp ); void smsSetDestResp( const QSimTerminalResponse& resp ); void smsSetTextResp( const QSimTerminalResponse& resp ); +void sendPollingMenu (); + void pollingMenuResp( const QSimTerminalResponse& resp ); private:int sticksLeft;
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 3/4 phonesim: Add Timer Management commands to sim app menu.
In reply to Andrzej Zaborowski--- src/qsimcommand.cpp | 83 ++++++++++++++++++++ src/qsimcommand.h | 3 + src/qsimterminalresponse.cpp | 59 ++++++++++++++ src/qsimterminalresponse.h | 3 + src/simapplication.cpp | 171 ++++++++++++++++++++++++++++++++++++++++++ src/simapplication.h | 6 ++ 6 files changed, 325 insertions(+), 0 deletions(-)
src/qsimcommand.cpp +83 -0
@@ -66,6 +66,7 @@ public: defaultItem = 0; iconId = 0; otherIconId = 0; + timerId = 0; device = -1; qualifier = 0; }
@@ -97,6 +98,7 @@ public: language = other->language; iconId = other->iconId; otherIconId = other->otherIconId; + timerId = other->timerId; device = other->device; qualifier = other->qualifier; extensionData = other->extensionData;
@@ -159,6 +161,7 @@ public: QString language; uint iconId; uint otherIconId; + uint timerId; int device; int qualifier; QByteArray extensionData;
@@ -2173,6 +2176,33 @@ void QSimCommand::setSmsPacking( bool value ) } /*! + Returns the number of the timer to which a Timer Management command is + addressed. + + Applies to: \c TimerManagement + + \sa setTimerId() +*/ +int QSimCommand::timerId() const +{ + return d->timerId; +} + +/*! + Sets the identifier of the timer to which the Timer Management command + is being sent. \a id should be between 1 and 8 to address one of the + eight timers available. + + Applies to: \c TimerManagement + + \sa timerId() +*/ +void QSimCommand::setTimerId( int id ) +{ + dwrite()->timerId = id; +} + +/*! Copy the QSimCommand object \a value. */ QSimCommand& QSimCommand::operator=( const QSimCommand & value )
@@ -2669,6 +2699,27 @@ QSimCommand QSimCommand::fromPdu( const QByteArray& pdu ) } break; + case 0x24: + { + // Timer identifier. + sc.setTimerId( pdu[posn] ); + } + break; + + case 0x25: + { + // Timer value. + int secs = 0; + secs += ((uint8_t) pdu[posn + 0] >> 4) * 3600; + secs += ((uint8_t) pdu[posn + 0] & 15) * 36000; + secs += ((uint8_t) pdu[posn + 1] >> 4) * 60; + secs += ((uint8_t) pdu[posn + 1] & 15) * 600; + secs += ((uint8_t) pdu[posn + 2] >> 4) * 1; + secs += ((uint8_t) pdu[posn + 2] & 15) * 10; + sc.setDuration( secs * 1000 ); + } + break; + case 0x2B: { // Immediate response block.
@@ -2963,6 +3014,31 @@ static void writeTextAttribute( QByteArray& data, const QByteArray& attr ) } } +// Write a Timer Id field. +void _qtopiaphone_writeTimerId( QByteArray& data, uint timerId ) +{ + data += 0xa4; + data += 0x01; + data += (char) timerId; +} +#define writeTimerId _qtopiaphone_writeTimerId + +// Write a Timer Value field. +void _qtopiaphone_writeTimerValue( QByteArray& data, uint value ) +{ + if (!value) + return; + + data += 0xa5; + data += 0x03; +#define TO_BCD(bin) (char) ((((bin) / 10) & 0xf) | (((bin) % 10) << 4)) + data += TO_BCD(value / 3600); + data += TO_BCD((value / 60) % 60); + data += TO_BCD(value % 60); +#undef TO_BCD +} +#define writeTimerValue _qtopiaphone_writeTimerValue + /*! \enum QSimCommand::ToPduOptions This enum defines additional options to use when encoding SIM commands with QSimCommand::toPdu().
@@ -3189,6 +3265,13 @@ QByteArray QSimCommand::toPdu( QSimCommand::ToPduOptions options ) const } break; + case TimerManagement: + { + writeTimerId( data, timerId() ); + writeTimerValue( data, duration() / 1000 ); + } + break; + case SetupIdleModeText: { writeTextString( data, text(), options );
src/qsimcommand.h +3 -0
@@ -356,6 +356,9 @@ public: bool smsPacking() const; void setSmsPacking( bool value ); + int timerId() const; + void setTimerId( int id ); + int qualifier() const; void setQualifier( int value );
src/qsimterminalresponse.cpp +59 -0
100 lines not on this page · raw message
src/qsimterminalresponse.h +3 -0
@@ -145,6 +145,9 @@ public: int dataCodingScheme() const; void setDataCodingScheme( int value ); + int timerId() const; + void setTimerId( int id ); + QByteArray extensionData() const; void setExtensionData( QByteArray value );
src/simapplication.cpp +171 -0
198 lines not on this page · raw message
src/simapplication.h +6 -0
@@ -70,6 +70,8 @@ public:const QString getName (); + bool envelope( const QSimEnvelope& env ); + protected slots:void mainMenu ();void mainMenuSelection (int id );
@@ -119,11 +121,15 @@ protected slots: void smsSetTextResp( const QSimTerminalResponse& resp );void sendPollingMenu (); void pollingMenuResp( const QSimTerminalResponse& resp ); +void sendTimersMenu (); + void timersMenuResp( const QSimTerminalResponse& resp ); + void timersCmdResp( const QSimTerminalResponse& resp ); private:int sticksLeft;bool immediateResponse;QString smsDestNumber, smsText; + QString timerStatus; };#endif
Signature · 1 line
1.7.1.86.g0e460.dirty
PATCH 4/4 phonesim: Add SIM Refresh commands to sim app menu.
In reply to Andrzej Zaborowski--- src/simapplication.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ src/simapplication.h | 2 + 2 files changed, 106 insertions(+), 0 deletions(-)
src/simapplication.cpp +104 -0
@@ -289,6 +289,7 @@ const QString DemoSimApplication::getName() #define MainMenu_SendSMS 14 #define MainMenu_Polling 15 #define MainMenu_Timers 16 +#define MainMenu_Refresh 17 #define SportsMenu_Chess 1 #define SportsMenu_Painting 2
@@ -438,6 +439,10 @@ void DemoSimApplication::mainMenu() item.setLabel( "Timers" ); items += item; + item.setIdentifier( MainMenu_Refresh ); + item.setLabel( "SIM Refresh" ); + items += item; + cmd.setMenuItems( items ); command( cmd, 0, 0 );
@@ -568,6 +573,12 @@ void DemoSimApplication::mainMenuSelection( int id ) } break; + case MainMenu_Refresh: + { + sendRefreshMenu(); + } + break; + default: { // Don't know what this item is, so just re-display the main menu.
@@ -2215,3 +2226,96 @@ bool DemoSimApplication::envelope( const QSimEnvelope& env ) return true; } + +void DemoSimApplication::sendRefreshMenu() +{ + QSimCommand cmd; + QSimMenuItem item; + QList<QSimMenuItem> items; + + cmd.setType( QSimCommand::SelectItem ); + cmd.setTitle( "SIM Refresh menu" ); + + /* Use qualifier value + 1 for id */ + item.setIdentifier( 1 ); + item.setLabel( "NAA Initialization+Full File Change Notification" ); + items += item; + + item.setIdentifier( 2 ); + item.setLabel( "File Change Notification (EFmsisdn,EFecc,EFfdn)" ); + items += item; + + item.setIdentifier( 3 ); + item.setLabel( "NAA Initialization+File Change Notification" ); + items += item; + + item.setIdentifier( 4 ); + item.setLabel( "NAA Initialization" ); + items += item; + + item.setIdentifier( 5 ); + item.setLabel( "UICC Reset" ); + items += item; + + item.setIdentifier( 6 ); + item.setLabel( "NAA Application Reset" ); + items += item; + + item.setIdentifier( 7 ); + item.setLabel( "NAA Session Reset" ); + items += item; + + cmd.setMenuItems( items ); + + command( cmd, this, SLOT(refreshMenuResp(QSimTerminalResponse)) ); +} + +void DemoSimApplication::refreshMenuResp( const QSimTerminalResponse& resp ) +{ + QSimCommand cmd; + + if ( resp.result() != QSimTerminalResponse::Success ) { + /* Unknown response - just go back to the main menu. */ + endSession(); + + return; + } + + /* Item selected. */ + + cmd.setType( QSimCommand::Refresh ); + cmd.setQualifier( resp.menuItem() - 1 ); + cmd.setDestinationDevice( QSimCommand::ME ); + cmd.setText( "" ); + + if ( cmd.refreshType() == QSimCommand::FileChange || + cmd.refreshType() == QSimCommand::InitAndFileChange || + cmd.refreshType() == QSimCommand::NaaSessionReset ) { + QByteArray files; + files += (char) 0x03; + /* EFmsisdn */ + files += (char) 0x3f; + files += (char) 0x00; + files += (char) 0x7f; + files += (char) 0xff; + files += (char) 0x6f; + files += (char) 0x40; + /* EFecc */ + files += (char) 0x3f; + files += (char) 0x00; + files += (char) 0x7f; + files += (char) 0xff; + files += (char) 0x6f; + files += (char) 0xb7; + /* EFfdn */ + files += (char) 0x3f; + files += (char) 0x00; + files += (char) 0x7f; + files += (char) 0xff; + files += (char) 0x6f; + files += (char) 0x3b; + cmd.addExtensionField( 0x92, files ); + } + + command( cmd, this, SLOT(endSession()) ); +}
src/simapplication.h +2 -0
@@ -124,6 +124,8 @@ protected slots:void sendTimersMenu (); void timersMenuResp( const QSimTerminalResponse& resp ); void timersCmdResp( const QSimTerminalResponse& resp ); +void sendRefreshMenu (); + void refreshMenuResp( const QSimTerminalResponse& resp ); private:int sticksLeft;
Signature · 1 line
1.7.1.86.g0e460.dirty
Re: [PATCH 3/4] phonesim: Add Timer Management commands to sim app menu.
In reply to Andrzej ZaborowskiHi Andrew,
Quoted 9 lines · Andrzej Zaborowski
--- src/qsimcommand.cpp | 83 ++++++++++++++++++++ src/qsimcommand.h | 3 + src/qsimterminalresponse.cpp | 59 ++++++++++++++ src/qsimterminalresponse.h | 3 + src/simapplication.cpp | 171 ++++++++++++++++++++++++++++++++++++++++++ src/simapplication.h | 6 ++ 6 files changed, 325 insertions(+), 0 deletions(-)
CXX src/qsimcommand.o
src/qsimcommand.cpp: In static member function ‘static QSimCommand QSimCommand::fromPdu(const QByteArray&)’:
src/qsimcommand.cpp:2713: error: ‘uint8_t’ was not declared in this scope src/qsimcommand.cpp:2713: error: expected ‘)’ before ‘pdu’ src/qsimcommand.cpp:2714: error: expected ‘)’ before ‘pdu’ src/qsimcommand.cpp:2715: error: expected ‘)’ before ‘pdu’ src/qsimcommand.cpp:2716: error: expected ‘)’ before ‘pdu’ src/qsimcommand.cpp:2717: error: expected ‘)’ before ‘pdu’ src/qsimcommand.cpp:2718: error: expected ‘)’ before ‘pdu’
Regards,
-Denis
Hi Andrew,
Quoted 5 lines · Andrzej Zaborowski
--- src/simapplication.cpp | 148 +++++++++++++++++++++++++++++++++++++++++++++++- src/simapplication.h | 5 ++ 2 files changed, 152 insertions(+), 1 deletions(-)
Patch has been applied, thanks.
Regards,
-Denis
Re: [PATCH 2/4] phonesim: Add SIM Polling commands to sim app menu.
In reply to Andrzej ZaborowskiHi Andrew,
Quoted 5 lines · Andrzej Zaborowski
--- src/simapplication.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ src/simapplication.h | 2 + 3 files changed, 72 insertions(+), 4 deletions(-)
Patch has been applied, thanks.
Regards,
-Denis