Try to move all the AT parsing / generating out of applications, just send
ready envelopes, terminal responses, commands between the application
and the SimRules class.
---
 src/control.cpp             |   35 +++++++++++
 src/control.h               |    1 +
 src/controlbase.ui          |   71 ++++++++++++++++++++++
 src/hardwaremanipulator.cpp |   42 +++++++++++++
 src/hardwaremanipulator.h   |    7 ++
 src/phonesim.cpp            |  138 +++++++++++++++++++++++++++++++++++++++----
 src/phonesim.h              |    6 ++
 src/simapplication.cpp      |  137 ++++++++++++++----------------------------
 src/simapplication.h        |   27 +++++----
 9 files changed, 349 insertions(+), 115 deletions(-)

diff --git a/src/control.cpp b/src/control.cpp
index c14909f..34a228f 100644
--- a/src/control.cpp
+++ b/src/control.cpp
@@ -49,6 +49,7 @@ public:
 
     void handleFromData( const QString& );
     void handleToData( const QString& );
+    void handleNewApp();
 
 private slots:
     void sendSQ();
@@ -70,6 +71,9 @@ private slots:
     void sendEVMNotify();
     void sendUSSD();
     void cancelUSSD();
+    void simInsertRemove();
+    void simAppStart();
+    void simAppAbort();
 
 signals:
     void unsolicitedCommand(const QString &);
@@ -134,12 +138,17 @@ ControlWidget::ControlWidget(const QString &ruleFile, 
Control *parent)
     connect(ui->pbNotifyUDHEnhanced, SIGNAL(clicked()), this, 
SLOT(sendEVMNotify()));
     connect(ui->pbSendUSSD, SIGNAL(clicked()), this, SLOT(sendUSSD()));
     connect(ui->pbCancelUSSD, SIGNAL(clicked()), this, SLOT(cancelUSSD()));
+    connect(ui->cbSimInserted, SIGNAL(clicked()), this, 
SLOT(simInsertRemove()));
+    connect(ui->pbStart, SIGNAL(clicked()), this, SLOT(simAppStart()));
+    connect(ui->pbAbort, SIGNAL(clicked()), this, SLOT(simAppAbort()));
 
     QStringList headers;
     headers << "Sender" << "Priority" << "Notification Status";
     ui->twMessageList->setHorizontalHeaderLabels( headers );
     ui->twMessageList->verticalHeader()->hide();
 
+    handleNewApp();
+
     show();
 }
 
@@ -473,3 +482,29 @@ void ControlWidget::cancelUSSD()
     ui->lblResponse->setText( "" );
     ui->leUSSDString->setText( "" );
 }
+
+void ControlWidget::simInsertRemove()
+{
+    p->setSimPresent( ui->cbSimInserted->isChecked() );
+}
+
+void ControlWidget::handleNewApp()
+{
+    ui->lblApplicationName->setText( "Current application: " +
+            p->getSimAppName() );
+}
+
+void Control::handleNewApp()
+{
+    widget->handleNewApp();
+}
+
+void ControlWidget::simAppStart()
+{
+    p->simAppStart();
+}
+
+void ControlWidget::simAppAbort()
+{
+    p->simAppAbort();
+}
diff --git a/src/control.h b/src/control.h
index e8b20a9..32db57e 100644
--- a/src/control.h
+++ b/src/control.h
@@ -36,6 +36,7 @@ public slots:
     void handleFromData( const QString& );
     void handleToData( const QString& );
     void setPhoneNumber( const QString& );
+    void handleNewApp();
 
 protected:
     virtual void warning( const QString&, const QString& );
diff --git a/src/controlbase.ui b/src/controlbase.ui
index a0468f2..eca1898 100644
--- a/src/controlbase.ui
+++ b/src/controlbase.ui
@@ -1370,6 +1370,77 @@ p, li { white-space: pre-wrap; }
        </item>
       </layout>
      </widget>
+     <widget class="QWidget" name="tab_6" >
+      <attribute name="title" >
+       <string>SIM</string>
+      </attribute>
+      <layout class="QVBoxLayout" >
+       <property name="spacing" >
+        <number>6</number>
+       </property>
+       <property name="leftMargin" >
+        <number>9</number>
+       </property>
+       <property name="topMargin" >
+        <number>9</number>
+       </property>
+       <property name="rightMargin" >
+        <number>9</number>
+       </property>
+       <property name="bottomMargin" >
+        <number>9</number>
+       </property>
+       <item>
+        <widget class="QGroupBox" name="gbCard" >
+         <property name="title" >
+          <string>Card</string>
+         </property>
+         <layout class="QVBoxLayout" >
+          <item>
+           <widget class="QCheckBox" name="cbSimInserted" >
+            <property name="text" >
+             <string>Card inserted</string>
+            </property>
+            <property name="checked" >
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="gbSATK" >
+         <property name="title" >
+          <string>Application</string>
+         </property>
+         <layout class="QHBoxLayout" >
+          <item>
+           <widget class="QPushButton" name="pbStart" >
+            <property name="text" >
+             <string>Start</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QPushButton" name="pbAbort" >
+            <property name="text" >
+             <string>Abort</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QLabel" name="lblApplicationName" >
+            <property name="toolTip" >
+             <string>Shows current selected application's name</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </widget>
     </widget>
    </item>
    <item>
diff --git a/src/hardwaremanipulator.cpp b/src/hardwaremanipulator.cpp
index 61b98f3..f7b13e9 100644
--- a/src/hardwaremanipulator.cpp
+++ b/src/hardwaremanipulator.cpp
@@ -28,6 +28,7 @@
 #include <qwsppdu.h>
 #include <qatutils.h>
 #include <phonesim.h>
+#include <simapplication.h>
 
 #define NIBBLE_MAX 15
 #define TWO_BYTE_MAX 65535
@@ -56,6 +57,7 @@ void HardwareManipulator::warning( const QString &title, 
const QString &message)
 
 void HardwareManipulator::setPhoneNumber( const QString& )
 {
+    simPresent = true;
 }
 
 QString PS_toHex( const QByteArray& binary );
@@ -290,3 +292,43 @@ void HardwareManipulator::sendUSSD( bool cancel, bool 
response,
                         QString::number( response ? 1 : 0 ) + ",\"" +
                         QAtUtils::quote( content, codec ) + "\",0" );
 }
+
+bool HardwareManipulator::getSimPresent()
+{
+    return simPresent;
+}
+
+void HardwareManipulator::setSimPresent( bool present )
+{
+    simPresent = present;
+}
+
+QString HardwareManipulator::getSimAppName()
+{
+    SimApplication *app = rules->simApplication();
+
+    if (app)
+        return app->getName();
+
+    return "None";
+}
+
+void HardwareManipulator::handleNewApp()
+{
+}
+
+void HardwareManipulator::simAppStart()
+{
+    SimApplication *app = rules->simApplication();
+
+    if (app)
+        return app->start();
+}
+
+void HardwareManipulator::simAppAbort()
+{
+    SimApplication *app = rules->simApplication();
+
+    if (app)
+        return app->abort();
+}
diff --git a/src/hardwaremanipulator.h b/src/hardwaremanipulator.h
index 7b59167..6571c06 100644
--- a/src/hardwaremanipulator.h
+++ b/src/hardwaremanipulator.h
@@ -34,6 +34,8 @@ Q_OBJECT
 public:
     HardwareManipulator(SimRules *sr, QObject *parent=0);
     QSMSMessageList & getSMSList();
+    bool getSimPresent();
+    QString getSimAppName();
 
 public slots:
     virtual void handleFromData( const QString& );
@@ -43,6 +45,10 @@ public slots:
     virtual void sendSMS( const QSMSMessage& m );
     virtual void sendVMNotify( int type, int count, const QList<QVMMessage> 
&received, const QList<QVMMessage> &deleted, const QString &mailbox );
     virtual void sendUSSD( bool cancel, bool response, const QString &content 
);
+    virtual void setSimPresent( bool present );
+    virtual void simAppStart();
+    virtual void simAppAbort();
+    virtual void handleNewApp();
 
 signals:
     void unsolicitedCommand(const QString &cmd);
@@ -63,6 +69,7 @@ protected:
 private:
     QSMSMessageList SMSList;
     SimRules *rules;
+    bool simPresent;
 };
 
 class HardwareManipulatorFactory
diff --git a/src/phonesim.cpp b/src/phonesim.cpp
index a1d3546..d363c29 100644
--- a/src/phonesim.cpp
+++ b/src/phonesim.cpp
@@ -544,10 +544,11 @@ SimRules::SimRules( int fd, QObject *p,  const QString& 
filename, HardwareManipu
     currentChannel = 1;
     incomingUsed = 0;
     lineUsed = 0;
-    defaultToolkitApp = toolkitApp = new DemoSimApplication( this );
-    toolkitApp->setSimRules( this );
+    defaultToolkitApp = toolkitApp = new DemoSimApplication( this, this );
     connect( _callManager, SIGNAL(controlEvent(QSimControlEvent)),
              toolkitApp, SLOT(controlEvent(QSimControlEvent)) );
+    if ( machine )
+        machine->handleNewApp();
 
     // Load the simulator rules into memory as a DOM-like tree.
     SimXmlHandler *handler = new SimXmlHandler();
@@ -857,8 +858,10 @@ void SimRules::setSimApplication( SimApplication *app )
     if ( toolkitApp != defaultToolkitApp )
         delete toolkitApp;
     toolkitApp = ( app ? app : defaultToolkitApp );
-    toolkitApp->setSimRules( this );
     toolkitApp->start();
+
+    if ( getMachine() )
+        getMachine()->handleNewApp();
 }
 
 void SimRules::switchTo(const QString& name)
@@ -890,23 +893,111 @@ SimState *SimRules::state( const QString& name ) const
     return 0;
 }
 
+bool SimRules::simCsimOk( const QByteArray& payload )
+{
+    unsigned char sw1 = 0x90;
+    unsigned char sw2 = 0x00;
+    QByteArray resp = payload;
+
+    if ( toolkitApp ) {
+        QByteArray cmd = toolkitApp->fetch();
+        if ( !cmd.isEmpty() )
+            sw1 = 0x91;
+            sw2 = cmd.size();
+    }
+
+    resp += sw1;
+    resp += sw2;
+    respond( "+CSIM: " + QString::number( resp.size() * 2 ) + "," +
+                           QAtUtils::toHex( resp ) + "\\n\\nOK" );
+
+    return true;
+}
 
 bool SimRules::simCommand( const QString& cmd )
 {
+    /* Process SIM toolkit begin and end commands by forcing the
+     * app back to the main menu.  */
+    if ( cmd == "AT*TSTB" || cmd == "AT*TSTE" ) {
+        if ( !toolkitApp ) {
+            respond( "ERROR" );
+            return true;
+        }
+
+        respond( "OK" );
+        toolkitApp->abort();
+        return true;
+    }
+
     // If not AT+CSIM, then this is not a SIM toolkit command.
     if ( !cmd.startsWith( "AT+CSIM=" ) )
         return false;
 
+    if ( getMachine() && !getMachine()->getSimPresent() )
+        return true;
+
     // Extract the binary payload of the AT+CSIM command.
     int comma = cmd.indexOf( QChar(',') );
     if ( comma < 0 )
         return false;
     QByteArray param = QAtUtils::fromHex( cmd.mid(comma + 1) );
-    if ( param.length() < 5 || param[0] != (char)0xA0 )
+
+    if ( param.length() < 4 ) {
+        /* Wrong length */
+        respond( "+CSIM: 4,6700\\n\\nOK" );
         return false;
+    }
+
+    if ( param[0] != (char)0xA0 ) {
+        /* CLA not supported */
+        respond( "+CSIM: 4,6800\\n\\nOK" );
+        return false;
+    }
 
     // Determine what kind of command we are dealing with.
-    if ( param[1] == (char)0x2C && param[4] == (char)0x10 && param.size() >= 
21 ) {
+    // Check for TERMINAL PROFILE, FETCH, TERMINAL RESPONSE,
+    // ENVELOPE and UNBLOCK CHV packets.
+    if ( param[1] == (char)0x10 ) {
+        /* Abort the SIM application and force it to return to the main menu. 
*/
+        if ( toolkitApp )
+            toolkitApp->abort();
+
+        /* Download of a TERMINAL PROFILE.  We respond with a simple OK,
+         * on the assumption that what we were sent was valid.  */
+        return simCsimOk( QByteArray() );
+    } else if ( param[1] == (char)0x12 ) {
+        if ( !toolkitApp ) {
+            respond( "+CSIM: 4,6F00\\n\\nOK" );
+            return true;
+        }
+
+        /* Fetch the current command contents. */
+        QByteArray resp = toolkitApp->fetch( true );
+        if ( resp.isEmpty() ) {
+            /* We weren't expecting a FETCH. */
+            respond( "+CSIM: 4,6F00\\n\\nOK" );
+            return true;
+        }
+
+        return simCsimOk( resp );
+    } else if ( param.length() >= 5 && param[1] == (char)0x14 ) {
+        if ( !toolkitApp ) {
+            respond( "+CSIM: 4,6F00\\n\\nOK" );
+            return true;
+        }
+
+        /* Process a TERMINAL RESPONSE message. */
+        QSimTerminalResponse resp =
+            QSimTerminalResponse::fromPdu( param.mid(5) );
+
+        if ( toolkitApp->response( resp ) )
+            return simCsimOk( QByteArray() );
+
+        /* Response to the wrong type of command. */
+        respond( "+CSIM: 4,6F00\\n\\nOK" );
+        return true;
+    } else if ( param.length() >= 5 && param[1] == (char)0x2c &&
+                    param[4] == (char)0x10 && param.size() >= 21 ) {
         // UNBLOCK CHV command, for resetting a PIN using a PUK.
         QString pinName = "PINVALUE";
         QString pukName = "PUKVALUE";
@@ -924,13 +1015,32 @@ bool SimRules::simCommand( const QString& cmd )
             respond( "+CSIM: 4,9804\\n\\nOK" );
         } else {
             setVariable( pinName, QString::fromUtf8( pinValue ) );
-            respond( "+CSIM: 4,9000\\n\\nOK" );
+            simCsimOk( QByteArray() );
+        }
+
+        return true;
+    } else if ( param.length() >= 5 && param[1] == (char)0xC2 ) {
+        /* ENVELOPE */
+        if ( !toolkitApp ) {
+            respond( "+CSIM: 4,6F00\\n\\nOK" );
+            return true;
         }
+
+        QSimEnvelope env = QSimEnvelope::fromPdu( param.mid(5) );
+        if ( toolkitApp->envelope( env ) )
+            return simCsimOk( QByteArray() );
+
+        /* Envelope not supported or current command doesn't allow envelopes. 
*/
+        respond( "+CSIM: 4,6F00\\n\\nOK" );
         return true;
+    } else if ( param[1] == (char)0xf2 ) {
+        /* STATUS command, for now ignore the parameters */
+        return simCsimOk( QByteArray() );
     }
 
     // Don't know this SIM command.
-    return false;
+    respond( "+CSIM: 4,6D00\\n\\nOK" );
+    return true;
 }
 
 void SimRules::command( const QString& cmd )
@@ -943,10 +1053,6 @@ void SimRules::command( const QString& cmd )
         return;
 
     // Process SIM toolkit related commands with the current SIM application.
-    if ( toolkitApp && toolkitApp->execute( cmd ) )
-        return;
-
-    // Process other SIM commands sent via AT+CSIM.
     if ( simCommand( cmd ) )
         return;
 
@@ -1458,6 +1564,16 @@ void SimRules::respond( const QString& resp, int delay, 
bool eol )
         getMachine()->handleFromData(QString(escaped));
 }
 
+void SimRules::proactiveCommandNotify( const QByteArray& cmd )
+{
+    unsolicited( "*TCMD: " + QString::number( cmd.size() ) );
+}
+
+void SimRules::callControlEventNotify( const QSimControlEvent& evt )
+{
+    unsolicited( "*TCC: " + QString::number( (int) (evt.type()) ) +
+              "," + QAtUtils::toHex( evt.toPdu() ) );
+}
 
 void SimRules::delayTimeout()
 {
diff --git a/src/phonesim.h b/src/phonesim.h
index d48b48e..cb7a5e1 100644
--- a/src/phonesim.h
+++ b/src/phonesim.h
@@ -31,6 +31,7 @@
 #include <qmap.h>
 #include <qtimer.h>
 #include <qpointer.h>
+#include <qsimcontrolevent.h>
 
 #include <string.h>
 #include <stdlib.h>
@@ -307,6 +308,9 @@ public slots:
     // Send a response line.
     void respond( const QString& resp ) { respond( resp, 0 ); }
 
+    void proactiveCommandNotify( const QByteArray& cmd );
+    void callControlEventNotify( const QSimControlEvent& event );
+
 private slots:
     void tryReadCommand();
     void destruct();
@@ -352,6 +356,8 @@ private:
     QMap< QString, SimPhoneBook * > phoneBooks;
 
     CallManager *_callManager;
+
+    bool simCsimOk( const QByteArray& payload );
 };
 
 
diff --git a/src/simapplication.cpp b/src/simapplication.cpp
index 09825ab..5212030 100644
--- a/src/simapplication.cpp
+++ b/src/simapplication.cpp
@@ -26,7 +26,6 @@ class SimApplicationPrivate
 public:
     SimApplicationPrivate()
     {
-        rules = 0;
         expectedType = QSimCommand::NoCommand;
         target = 0;
         slot = 0;
@@ -41,10 +40,11 @@ public:
     bool inResponse;
 };
 
-SimApplication::SimApplication( QObject *parent )
+SimApplication::SimApplication( SimRules *rules, QObject *parent )
     : QObject( parent )
 {
     d = new SimApplicationPrivate();
+    d->rules = rules;
 }
 
 SimApplication::~SimApplication()
@@ -80,8 +80,7 @@ void SimApplication::command( const QSimCommand& cmd,
     // the middle of processing a TERMINAL RESPONSE or ENVELOPE,
     // then delay the unsolicited notification until later.
     if ( d->rules && !d->inResponse ) {
-        d->rules->unsolicited
-            ( "*TCMD: " + QString::number( d->currentCommand.size() ) );
+        d->rules->proactiveCommandNotify( d->currentCommand );
     }
 }
 
@@ -90,11 +89,8 @@ void SimApplication::command( const QSimCommand& cmd,
 */
 void SimApplication::controlEvent( const QSimControlEvent& event )
 {
-    if ( d->rules ) {
-        d->rules->unsolicited
-            ( "*TCC: " + QString::number( (int)(event.type()) ) +
-              "," + QAtUtils::toHex( event.toPdu() ) );
-    }
+    if ( d->rules )
+        d->rules->callControlEventNotify( event );
 }
 
 /*!
@@ -160,99 +156,49 @@ void SimApplication::mainMenuHelpRequest( int id )
     mainMenu();
 }
 
-void SimApplication::setSimRules( SimRules *rules )
+bool SimApplication::envelope( const QSimEnvelope& env )
 {
-    d->rules = rules;
-}
-
-bool SimApplication::execute( const QString& cmd )
-{
-    // Process SIM toolkit begin and end commands by forcing the app back to 
the main menu.
-    if ( cmd == "AT*TSTB" || cmd == "AT*TSTE") {
-        d->rules->respond( "OK" );
-        abort();
+    /* Process a menu selection ENVELOPE message.  We turn it into a
+     * QSimTerminalResponse to make it easier to process.  */
+    if ( env.type() == QSimEnvelope::EventDownload )
         return true;
-    }
 
-    // If not AT+CSIM, then this is not a SIM toolkit command.
-    if ( !cmd.startsWith( "AT+CSIM=" ) )
+    if ( env.type() != QSimEnvelope::MenuSelection )
+        /* Not supported */
         return false;
 
-    // Extract the binary payload of the AT+CSIM command.
-    int comma = cmd.indexOf( QChar(',') );
-    if ( comma < 0 )
-        return false;
-    QByteArray param = QAtUtils::fromHex( cmd.mid(comma + 1) );
-    if ( param.length() < 5 || param[0] != (char)0xA0 )
+    if ( d->expectedType != QSimCommand::SetupMenu )
+        /* Envelope sent for the wrong type of command. */
         return false;
 
-    // Check for TERMINAL PROFILE, FETCH, TERMINAL RESPONSE,
-    // and ENVELOPE packets.
-    if ( param[1] == (char)0x10 ) {
-        // Download of a TERMINAL PROFILE.  We respond with a simple OK,
-        // on the assumption that what we were sent was valid.
-        d->rules->respond( "+CSIM: 4,9000\\n\\nOK" );
+    d->expectedType = QSimCommand::NoCommand;
+    d->currentCommand = QByteArray();
+    d->target = 0;
+    d->slot = 0;
+    if ( env.requestHelp() )
+        mainMenuHelpRequest( env.menuItem() );
+    else
+        mainMenuSelection( env.menuItem() );
 
-        // Abort the SIM application and force it to return to the main menu.
-        abort();
-    } else if ( param[1] == (char)0x12 ) {
-        // Fetch the current command contents.
-        QByteArray resp = d->currentCommand;
-        if ( resp.isEmpty() ) {
-            // We weren't expecting a FETCH.
-            d->rules->respond( "+CSIM: 4,6F00\\n\\nOK" );
-            return true;
-        }
-        resp += (char)0x90;
-        resp += (char)0x00;
-        d->rules->respond( "+CSIM: " + QString::number( resp.size() * 2 ) + 
"," +
-                           QAtUtils::toHex( resp ) + "\\n\\nOK" );
-    } else if ( param[1] == (char)0x14 ) {
-        // Process a TERMINAL RESPONSE message.
-        QSimTerminalResponse resp;
-        resp = QSimTerminalResponse::fromPdu( param.mid(5) );
-        if ( resp.command().type() != QSimCommand::NoCommand &&
-             resp.command().type() != d->expectedType ) {
-            // Response to the wrong type of command.
-            d->rules->respond( "+CSIM: 4,6F00\\n\\nOK" );
-            return true;
-        }
-        response( resp );
-    } else if ( param[1] == (char)0xC2 ) {
-        // Process a menu selection ENVELOPE message.  We turn it into a
-        // QSimTerminalResponse to make it easier to process.
-        QSimEnvelope env;
-        env = QSimEnvelope::fromPdu( param.mid(5) );
-        if ( env.type() == QSimEnvelope::EventDownload ) {
-            d->rules->respond( "+CSIM: 4,9000\\n\\nOK" );
-            return true;
-        }
-        if ( env.type() != QSimEnvelope::MenuSelection )
-            return false;
-        if ( d->expectedType != QSimCommand::SetupMenu ) {
-            // Envelope sent for the wrong type of command.
-            d->rules->respond( "+CSIM: 4,6F00\\n\\nOK" );
-            return true;
-        }
-        d->rules->respond( "+CSIM: 4,9000\\n\\nOK" );
-        d->expectedType = QSimCommand::NoCommand;
+    return true;
+}
+
+QByteArray SimApplication::fetch( bool clear )
+{
+    QByteArray resp = d->currentCommand;
+
+    if ( clear )
         d->currentCommand = QByteArray();
-        d->target = 0;
-        d->slot = 0;
-        if ( env.requestHelp() )
-            mainMenuHelpRequest( env.menuItem() );
-        else
-            mainMenuSelection( env.menuItem() );
-    } else {
-        // This SIM command is not related to SIM toolkit - ignore it.
-        return false;
-    }
 
-    return true;
+    return resp;
 }
 
-void SimApplication::response( const QSimTerminalResponse& resp )
+bool SimApplication::response( const QSimTerminalResponse& resp )
 {
+    if ( resp.command().type() != QSimCommand::NoCommand &&
+         resp.command().type() != d->expectedType )
+        return false;
+
     // Save the target information.
     QObject *target = d->target;
     const char *slot = d->slot;
@@ -284,7 +230,7 @@ void SimApplication::response( const QSimTerminalResponse& 
resp )
 
     // Answer the AT+CSIM command and send notification of the new command.
     if ( !d->rules )
-        return;
+        return false;////
     if ( d->currentCommand.isEmpty() || resp.command().type() == 
QSimCommand::SetupMenu ) {
         // No new command, so respond with a simple OK.
         d->rules->respond( "+CSIM: 4,9000\\n\\nOK" );
@@ -300,10 +246,12 @@ void SimApplication::response( const 
QSimTerminalResponse& resp )
         d->rules->unsolicited
             ( "*TCMD: " + QString::number( d->currentCommand.size() ) );
     }
+
+    return true;
 }
 
-DemoSimApplication::DemoSimApplication( QObject *parent )
-    : SimApplication( parent )
+DemoSimApplication::DemoSimApplication( SimRules *rules, QObject *parent )
+    : SimApplication( rules, parent )
 {
 }
 
@@ -311,6 +259,11 @@ DemoSimApplication::~DemoSimApplication()
 {
 }
 
+const QString DemoSimApplication::getName()
+{
+    return "Demo SIM Application";
+}
+
 #define MainMenu_News       1
 #define MainMenu_Sports     2
 #define MainMenu_Time       3
diff --git a/src/simapplication.h b/src/simapplication.h
index 3fd5bcb..1cfcbe4 100644
--- a/src/simapplication.h
+++ b/src/simapplication.h
@@ -31,41 +31,44 @@ class SimApplicationPrivate;
 class SimApplication : public QObject
 {
     Q_OBJECT
-    friend class SimRules;
 public:
-    SimApplication( QObject *parent = 0 );
+    SimApplication( SimRules *rules, QObject *parent = 0 );
     ~SimApplication();
 
-    void command( const QSimCommand& cmd,
-                  QObject *target, const char *slot,
-                  QSimCommand::ToPduOptions options
-                        = QSimCommand::NoPduOptions );
+    virtual bool envelope( const QSimEnvelope& env );
+    virtual bool response( const QSimTerminalResponse& resp );
+    virtual QByteArray fetch( bool clear = false );
+
+    virtual const QString getName() = 0;
 
 public slots:
-    void controlEvent( const QSimControlEvent& event );
     virtual void start();
     virtual void abort();
 
 protected slots:
+    void command( const QSimCommand& cmd,
+                  QObject *target, const char *slot,
+                  QSimCommand::ToPduOptions options
+                        = QSimCommand::NoPduOptions );
+    void controlEvent( const QSimControlEvent& event );
+
     virtual void mainMenu() = 0;
     virtual void mainMenuSelection( int id );
     virtual void mainMenuHelpRequest( int id );
 
 private:
     SimApplicationPrivate *d;
-
-    void setSimRules( SimRules *rules );
-    bool execute( const QString& cmd );
-    void response( const QSimTerminalResponse& resp );
 };
 
 class DemoSimApplication : public SimApplication
 {
     Q_OBJECT
 public:
-    DemoSimApplication( QObject *parent = 0 );
+    DemoSimApplication( SimRules *rules, QObject *parent = 0 );
     ~DemoSimApplication();
 
+    const QString getName();
+
 protected slots:
     void mainMenu();
     void mainMenuSelection( int id );
-- 
1.6.1

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to