Ejemplo n.º 1
0
void DemoSimApplication::toneMenu( const QSimTerminalResponse& resp )
{
    QSimCommand cmd;

    if ( resp.result() == QSimTerminalResponse::Success ) {
        // Item selected.
        cmd.setType( QSimCommand::PlayTone );
        cmd.setDestinationDevice( QSimCommand::Earpiece );
        cmd.setTone( (QSimCommand::Tone)( resp.menuItem() ) );
        if ( cmd.tone() == QSimCommand::ToneDial )
            cmd.setDuration( 5000 );
        else if ( cmd.tone() == QSimCommand::ToneGeneralBeep ||
                  cmd.tone() == QSimCommand::TonePositiveBeep ||
                  cmd.tone() == QSimCommand::ToneNegativeBeep )
            cmd.setDuration( 1000 );
        else
            cmd.setDuration( 3000 );
        command( cmd, this, SLOT(sendToneMenu()) );
    } else if ( resp.result() == QSimTerminalResponse::BackwardMove ) {
        // Request to move backward.
        mainMenu();
    } else {
        // Unknown response - just go back to the main menu.
        mainMenu();
    }
}
Ejemplo n.º 2
0
void DemoSimApplication::sendBrowserMenu()
{
    QSimCommand cmd;
    QSimMenuItem item;
    QList<QSimMenuItem> items;

    cmd.setType( QSimCommand::SelectItem );
    cmd.setTitle( "Web Browser" );

    item.setIdentifier( 1 );
    item.setLabel( "Qt Extended" );
    items += item;

    item.setIdentifier( 2 );
    item.setLabel( "Google (normal)" );
    items += item;

    item.setIdentifier( 3 );
    item.setLabel( "Google (if browser not in use)" );
    items += item;

    item.setIdentifier( 4 );
    item.setLabel( "Google (clear history)" );
    items += item;

    item.setIdentifier( 5 );
    item.setLabel( "Default Home Page" );
    items += item;

    cmd.setMenuItems( items );

    command( cmd, this, SLOT(browserMenu(QSimTerminalResponse)) );
}
Ejemplo n.º 3
0
void DemoSimApplication::sendSportsMenu()
{
    QSimCommand cmd;
    QSimMenuItem item;
    QList<QSimMenuItem> items;

    cmd.setType( QSimCommand::SelectItem );
    cmd.setTitle( "Sports" );

    item.setIdentifier( SportsMenu_Chess );
    item.setLabel( "Chess" );
    items += item;

    item.setIdentifier( SportsMenu_Painting );
    item.setLabel( "Finger Painting" );
    items += item;

    item.setIdentifier( SportsMenu_Snakes );
    item.setLabel( "Snakes and Ladders" );
    items += item;

    item.setIdentifier( SportsMenu_Main );
    item.setLabel( "Return to main menu" );
    items += item;

    cmd.setMenuItems( items );

    command( cmd, this, SLOT(sportsMenu(QSimTerminalResponse)) );
}
Ejemplo n.º 4
0
void DemoSimApplication::sendIconSEMenu()
{
    QSimCommand cmd;
    QSimMenuItem item;
    QList<QSimMenuItem> items;

    cmd.setType( QSimCommand::SelectItem );
    cmd.setTitle( "Icons SE" );

    item.setIdentifier( 1 );
    item.setLabel( "Basic Icon" );
    item.setIconId( 1 );
    item.setIconSelfExplanatory( true );
    items += item;

    item.setIdentifier( 2 );
    item.setLabel( "Color Icon" );
    item.setIconId( 2 );
    item.setIconSelfExplanatory( true );
    items += item;

    item.setIdentifier( 3 );
    item.setLabel( "Bad Icon" );
    item.setIconId( 70 );
    item.setIconSelfExplanatory( true );
    items += item;

    cmd.setMenuItems( items );

    command( cmd, this, SLOT(iconSEMenu(QSimTerminalResponse)) );
}
Ejemplo n.º 5
0
bool SimApp::listViewPreferred(const QSimCommand& cmd)
{
    if (!cmd.softKeysPreferred())
        return true;
    // reserve one key for back button
    if ((QSoftMenuBar::keys().count() - 1) >= cmd.menuItems().count())
        return false;
    else
        return true;
}
Ejemplo n.º 6
0
void DemoSimApplication::sendToneMenu()
{
    QSimCommand cmd;
    QSimMenuItem item;
    QList<QSimMenuItem> items;

    cmd.setType( QSimCommand::SelectItem );
    cmd.setTitle( "Tones" );

    item.setIdentifier( (uint)QSimCommand::ToneDial );
    item.setLabel( "Dial" );
    items += item;

    item.setIdentifier( (uint)QSimCommand::ToneBusy );
    item.setLabel( "Busy" );
    items += item;

    item.setIdentifier( (uint)QSimCommand::ToneCongestion );
    item.setLabel( "Congestion" );
    items += item;

    item.setIdentifier( (uint)QSimCommand::ToneRadioAck );
    item.setLabel( "Radio Ack" );
    items += item;

    item.setIdentifier( (uint)QSimCommand::ToneDropped );
    item.setLabel( "Dropped" );
    items += item;

    item.setIdentifier( (uint)QSimCommand::ToneError );
    item.setLabel( "Error" );
    items += item;

    item.setIdentifier( (uint)QSimCommand::ToneCallWaiting );
    item.setLabel( "Call Waiting" );
    items += item;

    item.setIdentifier( (uint)QSimCommand::ToneGeneralBeep );
    item.setLabel( "General Beep" );
    items += item;

    item.setIdentifier( (uint)QSimCommand::TonePositiveBeep );
    item.setLabel( "Positive Beep" );
    items += item;

    item.setIdentifier( (uint)QSimCommand::ToneNegativeBeep );
    item.setLabel( "Negative Beep" );
    items += item;

    cmd.setMenuItems( items );

    command( cmd, this, SLOT(toneMenu(QSimTerminalResponse)) );
}
Ejemplo n.º 7
0
void DemoSimApplication::getInputLoop( const QSimTerminalResponse& resp )
{
    QSimCommand cmd;
    if ( resp.result() == QSimTerminalResponse::HelpInformationRequested ) {
        // Display help for the game.
        cmd.setType( QSimCommand::DisplayText );
        cmd.setDestinationDevice( QSimCommand::Display );
        cmd.setText("Enter code of the company." );
        command( cmd, this, SLOT(mainMenu()) );
    } else {
        mainMenu();
    }
}
Ejemplo n.º 8
0
void DemoSimApplication::mainMenu()
{
    QSimCommand cmd;
    QSimMenuItem item;
    QList<QSimMenuItem> items;

    cmd.setType( QSimCommand::SetupMenu );

    item.setIdentifier( MainMenu_News );
    item.setLabel( "News" );
    items += item;

    item.setIdentifier( MainMenu_Sports );
    item.setLabel( "Sports" );
    items += item;

    item.setIdentifier( MainMenu_Time );
    item.setLabel( "Time" );
    items += item;

    item.setIdentifier( MainMenu_SticksGame );
    item.setLabel( "Sticks Game" );
    items += item;

    item.setIdentifier( MainMenu_Tones );
    item.setLabel( "Tones" );
    items += item;

    item.setIdentifier( MainMenu_Icons );
    item.setLabel( "Icons (not self-explanatory)" );
    items += item;

    item.setIdentifier( MainMenu_IconsSE );
    item.setLabel( "Icons (self-explanatory)" );
    items += item;

    item.setIdentifier( MainMenu_Finance );
    item.setLabel( "Finance" );
    items += item;

    item.setIdentifier( MainMenu_Browser );
    item.setLabel( "Web Browser" );
    items += item;

    cmd.setMenuItems( items );

    command( cmd, 0, 0 );
}
Ejemplo n.º 9
0
void tst_QSimToolkit::testEncodeSendDTMF()
{
    QFETCH( QByteArray, data );
    QFETCH( QByteArray, resp );
    QFETCH( int, resptype );
    QFETCH( QString, text );
    QFETCH( QString, number );
    QFETCH( int, iconId );
    QFETCH( bool, iconSelfExplanatory );
    QFETCH( QByteArray, textAttribute );
    QFETCH( QString, html );
    QFETCH( int, options );

    // Output a dummy line to give some indication of which test we are currently running.
    qDebug() << "";

    // Check that the command PDU can be parsed correctly.
    QSimCommand decoded = QSimCommand::fromPdu(data);
    QVERIFY( decoded.type() == QSimCommand::SendDTMF );
    QVERIFY( decoded.destinationDevice() == QSimCommand::Network );
    QCOMPARE( decoded.text(), text );
    QCOMPARE( decoded.number(), number );
    QCOMPARE( (int)decoded.iconId(), iconId );
    QCOMPARE( decoded.iconSelfExplanatory(), iconSelfExplanatory );
    QCOMPARE( decoded.textAttribute(), textAttribute );
    if ( !textAttribute.isEmpty() )
        QCOMPARE( decoded.textHtml(), html );

    // Check that the original command PDU can be reconstructed correctly.
    QByteArray encoded = decoded.toPdu( (QSimCommand::ToPduOptions)options );
    QCOMPARE( encoded, data );

    // Check that the terminal response PDU can be parsed correctly.
    QSimTerminalResponse decodedResp = QSimTerminalResponse::fromPdu(resp);
    QVERIFY( data.contains( decodedResp.commandPdu() ) );
    if ( resptype < 0x0100 ) {
        QVERIFY( decodedResp.result() == (QSimTerminalResponse::Result)resptype );
        QVERIFY( decodedResp.causeData().isEmpty() );
        QVERIFY( decodedResp.cause() == QSimTerminalResponse::NoSpecificCause );
    } else {
        QVERIFY( decodedResp.result() == (QSimTerminalResponse::Result)(resptype >> 8) );
        QVERIFY( decodedResp.causeData().size() == 1 );
        QVERIFY( decodedResp.cause() == (QSimTerminalResponse::Cause)(resptype & 0xFF) );
    }

    // Check that the original terminal response PDU can be reconstructed correctly.
    QCOMPARE( decodedResp.toPdu(), resp );
}
Ejemplo n.º 10
0
void SimApp::cmdSetupEventList(const QSimCommand &cmd)
{
    QByteArray events = cmd.extensionField(0x99);
    int newEvents = 0;
    foreach ( char ev, events )
        newEvents |= (1 << (int)(ev & 0xFF));
    changeEventList( newEvents );
}
Ejemplo n.º 11
0
// Shows info to user when, e.g. SMS is sent.
void SimApp::showNotification(const QSimCommand &cmd)
{
    if (!cmd.text().isEmpty() || !cmd.suppressUserFeedback()) {
        if (notification) {
            notification->setCommand(cmd);
            stack->setCurrentWidget(notification);
            emit viewChanged(notification);
        } else {
            if ( cmd.iconId() > 0 )
                createIconReader();
            notification = new SimText(cmd, iconReader, stack);
            stack->addWidget(notification);
            stack->setCurrentWidget(notification);
            emit viewChanged(notification);
        }
    }
}
Ejemplo n.º 12
0
void SimApp::cmdIdleModeText(const QSimCommand &cmd)
{
    idleModeText = cmd;
    if ( cmd.iconId() != 0 ) {
        createIconReader();
        if ( iconReader->haveIcon( cmd.iconId() ) ) {
            // Icon already cached from last time.
            idleModeImage = iconReader->icon( cmd.iconId() );
        } else {
            // Request that the icon be fetched from the sim.
            iconReader->requestIcon( cmd.iconId() );
            idleModeImage = QImage();
        }
    } else {
        idleModeImage = QImage();
    }
    updateValueSpace();
}
Ejemplo n.º 13
0
void SimApp::cmdTone(const QSimCommand & cmd )
{
    if ( cmd.iconId() > 0 )
        createIconReader();
    SimTone *tone = new SimTone(cmd, iconReader, stack);
    connect(tone, SIGNAL(sendResponse(QSimTerminalResponse)),
            this, SLOT(sendResponse(QSimTerminalResponse)) );
    setView(tone);
}
Ejemplo n.º 14
0
void SimApp::cmdDisplayText(const QSimCommand &cmd)
{
#ifndef QTOPIA_TEST
    // DisplayText with low priority came while screen is busy
    if ( !this->isVisible()
            && !(HomeScreenControl::instance()->homeScreen()->windowState() & Qt::WindowActive)
            && !cmd.highPriority() ) {
        QSimTerminalResponse resp;
        resp.setCommand(cmd);
        resp.setCause(QSimTerminalResponse::ScreenIsBusy);
        resp.setResult(QSimTerminalResponse::MEUnableToProcess);
        sendResponse( resp );
        return;
    }
#endif
    if ( cmd.iconId() > 0 )
        createIconReader();

    hasSustainedDisplayText = cmd.immediateResponse();

    if (view && qobject_cast<SimText*>(view)) {
        SimText *text = (SimText *)view;
        if (cmd.highPriority() || !text->hasHighPriority()) {
            if (cmd.iconId())
                text->setCommand(cmd, iconReader);
            else
                text->setCommand(cmd);
            stack->setCurrentWidget(text);
        } else {
            // send screen busy response
            QSimTerminalResponse resp;
            resp.setCommand(cmd);
            resp.setCause(QSimTerminalResponse::ScreenIsBusy);
            resp.setResult(QSimTerminalResponse::MEUnableToProcess);
            sendResponse( resp );
        }
    } else {
        SimText *text = new SimText(cmd, iconReader, stack);
        connect(text, SIGNAL(sendResponse(QSimTerminalResponse)),
                this, SLOT(sendResponse(QSimTerminalResponse)) );
        connect(text, SIGNAL(hideApp()), this, SLOT(hideApp()));
        setView(text);
    }
}
Ejemplo n.º 15
0
void SimApp::cmdInKey(const QSimCommand &cmd)
{
    if ( cmd.iconId() > 0 )
        createIconReader();

    SimInKey *inKey = new SimInKey(cmd, iconReader, stack);
    connect(inKey, SIGNAL(sendResponse(QSimTerminalResponse)),
            this, SLOT(sendResponse(QSimTerminalResponse)) );
    setView(inKey);
}
Ejemplo n.º 16
0
void tst_QSimToolkit::testDeliverPowerOffCard()
{
    QFETCH( QByteArray, data );
    QFETCH( QByteArray, resp );
    QFETCH( int, resptype );
    QFETCH( int, device );
    QFETCH( int, options );

    // Output a dummy line to give some indication of which test we are currently running.
    qDebug() << "";

    // Clear the client/server state.
    server->clear();
    deliveredCommand = QSimCommand();

    // Compose and send the command.
    QSimCommand cmd;
    cmd.setType( QSimCommand::PowerOffCard );
    cmd.setDestinationDevice( (QSimCommand::Device)( device + 0x10 ) );
    server->emitCommand( cmd );

    // Wait for the command to arrive in the client.
    QVERIFY( QFutureSignal::wait( this, SIGNAL(commandSeen()), 100 ) );

    // Verify that the command was delivered exactly as we asked.
    QVERIFY( deliveredCommand.type() == cmd.type() );
    QCOMPARE( deliveredCommand.toPdu( (QSimCommand::ToPduOptions)options ), data );

    // The response should have been sent immediately.
    QCOMPARE( server->responseCount(), 1 );
    QCOMPARE( server->envelopeCount(), 0 );
    if ( resptype == 0x0000 ) {
        QCOMPARE( server->lastResponse(), resp );
    } else {
        // We cannot test the "no card inserted" case because the qtopiaphone
        // library will always respond with "command performed successfully".
        static unsigned char const ok_resp[] =
            {0x81, 0x03, 0x01, 0x32, 0x00, 0x82, 0x02, 0x82, 0x81, 0x83, 0x01, 0x00};
        QByteArray resp2 = QByteArray( (char *)ok_resp, sizeof( ok_resp ) );
        QCOMPARE( server->lastResponse(), resp2 );
    }
}
Ejemplo n.º 17
0
void tst_QSimToolkit::testDeliverPowerOnCard()
{
    QFETCH( QByteArray, data );
    QFETCH( QByteArray, resp );
    QFETCH( QByteArray, atr );
    QFETCH( int, resptype );
    QFETCH( int, device );
    QFETCH( int, options );

    Q_UNUSED(resp);
    Q_UNUSED(resptype);
    Q_UNUSED(atr);

    // Output a dummy line to give some indication of which test we are currently running.
    qDebug() << "";

    // Clear the client/server state.
    server->clear();
    deliveredCommand = QSimCommand();

    // Compose and send the command.
    QSimCommand cmd;
    cmd.setType( QSimCommand::PowerOnCard );
    cmd.setDestinationDevice( (QSimCommand::Device)( device + 0x10 ) );
    server->emitCommand( cmd );

    // Wait for the command to arrive in the client.
    QVERIFY( QFutureSignal::wait( this, SIGNAL(commandSeen()), 100 ) );

    // Verify that the command was delivered exactly as we asked.
    QVERIFY( deliveredCommand.type() == cmd.type() );
    QCOMPARE( deliveredCommand.toPdu( (QSimCommand::ToPduOptions)options ), data );

    // The response should have been sent immediately, and should always be success.
    // We cannot test the answer to reset behaviour with this interface.
    QCOMPARE( server->responseCount(), 1 );
    QCOMPARE( server->envelopeCount(), 0 );
    static unsigned char const ok_resp[] =
        {0x81, 0x03, 0x01, 0x31, 0x00, 0x82, 0x02, 0x82, 0x81, 0x83, 0x01, 0x00};
    QByteArray resp2 = QByteArray( (char *)ok_resp, sizeof( ok_resp ) );
    QCOMPARE( server->lastResponse(), resp2 );
}
Ejemplo n.º 18
0
/*!
    Sends a proactive SIM command, \a cmd, to the ME, and instructs
    SimApplication to invoke \a slot on \a target when the response
    arrives back.  The \a options provides extra information about
    how the command should be transmitted to the ME in PDU form.

    For \c SetupMenu commands, \a target and \a slot should be null.
    When the user responds to the main menu, mainMenuSelection() or
    mainMenuHelpRequest() will be invoked.

    \sa mainMenuSelection(), mainMenuHelpRequest()
*/
void SimApplication::command( const QSimCommand& cmd,
                              QObject *target, const char *slot,
                              QSimCommand::ToPduOptions options )
{
    // Record the command details, together with the type of
    // TERMINAL RESPONSE or ENVELOPE that we expect in answer.
    d->currentCommand = cmd.toPdu( options );
    d->expectedType = cmd.type();
    d->target = target;
    d->slot = slot;

    // Send an unsolicited notification to indicate that a new
    // proactive SIM command is available.  If we are already in
    // 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() ) );
    }
}
Ejemplo n.º 19
0
void SimApp::cmdMenu(const QSimCommand &cmd)
{
    if (!simToolkitAvailable) {
        // First time that we have seen the toolkit menu, so this
        // SIM obviously has a SIM toolkit application on it.
        simToolkitAvailable = true;
        mainMenuTitle = cmd.title();
        updateValueSpace();
    }

    // Create QSimIconReader if the menu contains them.
    QList<QSimMenuItem> items = cmd.menuItems();
    QList<QSimMenuItem>::ConstIterator it;
    bool needIcon = false;
    for (it = items.begin(); it != items.end(); ++it) {
        if ( (int)(*it).iconId() ) {
            needIcon = true;
            if ( !iconReader )
                createIconReader();
            else
                break;
        }
    }

    // Create the menu widgetry.
    SimMenu *menu;
    if ( needIcon )
        menu = new SimMenu(cmd, iconReader, stack);
    else
        menu = new SimMenu(cmd, stack);

    // main menu send QSimEnvelope,sub menu sends QSimTerminalResponse
    if (cmd.type() == QSimCommand::SetupMenu) {
        connect(menu, SIGNAL(sendEnvelope(QSimEnvelope)),
                this, SLOT(sendEnvelope(QSimEnvelope)) );
    } else {
        connect(menu, SIGNAL(sendResponse(QSimTerminalResponse)),
                this, SLOT(sendResponse(QSimTerminalResponse)) );
    }
    setView(menu);
}
Ejemplo n.º 20
0
void tst_QSimToolkit::testEncodePowerOnCard()
{
    QFETCH( QByteArray, data );
    QFETCH( QByteArray, resp );
    QFETCH( QByteArray, atr );
    QFETCH( int, resptype );
    QFETCH( int, device );
    QFETCH( int, options );

    // Output a dummy line to give some indication of which test we are currently running.
    qDebug() << "";

    // Check that the command PDU can be parsed correctly.
    QSimCommand decoded = QSimCommand::fromPdu(data);
    QVERIFY( decoded.type() == QSimCommand::PowerOnCard );
    QVERIFY( decoded.destinationDevice() == (QSimCommand::Device)( device + 0x10 ) );

    // Check that the original command PDU can be reconstructed correctly.
    QByteArray encoded = decoded.toPdu( (QSimCommand::ToPduOptions)options );
    QCOMPARE( encoded, data );

    // Check that the terminal response PDU can be parsed correctly.
    QSimTerminalResponse decodedResp = QSimTerminalResponse::fromPdu(resp);
    QVERIFY( data.contains( decodedResp.commandPdu() ) );
    if ( resptype < 0x0100 ) {
        QVERIFY( decodedResp.result() == (QSimTerminalResponse::Result)resptype );
        QVERIFY( decodedResp.causeData().isEmpty() );
        QVERIFY( decodedResp.cause() == QSimTerminalResponse::NoSpecificCause );
    } else {
        QVERIFY( decodedResp.result() == (QSimTerminalResponse::Result)(resptype >> 8) );
        QVERIFY( decodedResp.causeData().size() == 1 );
        QVERIFY( decodedResp.cause() == (QSimTerminalResponse::Cause)(resptype & 0xFF) );
    }
    QCOMPARE( decodedResp.extensionField(0xA1), atr );

    // Check that the original terminal response PDU can be reconstructed correctly.
    QCOMPARE( decodedResp.toPdu(), resp );
}
Ejemplo n.º 21
0
void SimApp::cmdChannel(const QSimCommand& cmd)
{
    SimChannel *channel;
    if ( cmd.iconId() > 0 ) {
        createIconReader();
        channel = new SimChannel(cmd, iconReader, stack);
    } else {
        channel = new SimChannel(cmd, stack);
    }

    connect(channel, SIGNAL(sendResponse(QSimTerminalResponse)),
            this, SLOT(sendResponse(QSimTerminalResponse)) );
    setView(channel);
}
Ejemplo n.º 22
0
void SimApp::cmdLaunchBrowser(const QSimCommand &cmd)
{
    SimLaunchBrowser *browser;
    if ( cmd.iconId() > 0 ) {
        createIconReader();
        browser = new SimLaunchBrowser(cmd, iconReader, stack);
    } else {
        browser = new SimLaunchBrowser(cmd, stack);
    }

    connect(browser, SIGNAL(sendResponse(QSimTerminalResponse)),
            this, SLOT(sendResponse(QSimTerminalResponse)) );
    setView(browser);
}
Ejemplo n.º 23
0
void tst_QSimToolkit::testDeliverProvideLocalInformation()
{
    QFETCH( QByteArray, data );
    QFETCH( QByteArray, resp );
    QFETCH( QByteArray, info );
    QFETCH( int, resptype );
    QFETCH( int, localtype );
    QFETCH( int, options );

    // Output a dummy line to give some indication of which test we are currently running.
    qDebug() << "";

    // Clear the client/server state.
    server->clear();
    deliveredCommand = QSimCommand();

    // Compose and send the command.
    QSimCommand cmd;
    cmd.setType( QSimCommand::ProvideLocalInformation );
    cmd.setQualifier( localtype );
    server->emitCommand( cmd );

    // Wait for the command to arrive in the client.
    QVERIFY( QFutureSignal::wait( this, SIGNAL(commandSeen()), 100 ) );

    // Verify that the command was delivered exactly as we asked.
    QVERIFY( deliveredCommand.type() == cmd.type() );
    QVERIFY( deliveredCommand.qualifier() == cmd.qualifier() );
    QCOMPARE( deliveredCommand.toPdu( (QSimCommand::ToPduOptions)options ), data );

    // The response should have been sent immediately.
    QCOMPARE( server->responseCount(), 1 );
    QCOMPARE( server->envelopeCount(), 0 );
    QSimTerminalResponse resp2 = QSimTerminalResponse::fromPdu( server->lastResponse() );
    QVERIFY( resp2.result() == (QSimTerminalResponse::Result)resptype );
    QVERIFY( resp2.cause() == QSimTerminalResponse::NoSpecificCause );
}
Ejemplo n.º 24
0
void SimApp::cmdSetupCall(const QSimCommand &cmd)
{
    SimSetupCall *setupCall;

    if ( cmd.iconId() > 0 ) {
        createIconReader();
        setupCall = new SimSetupCall( cmd, iconReader, stack );
    } else {
        setupCall = new SimSetupCall( cmd, stack );
    }

    connect(setupCall, SIGNAL(sendResponse(QSimTerminalResponse)),
            this, SLOT(sendResponse(QSimTerminalResponse)) );
    setView(setupCall);
}
Ejemplo n.º 25
0
void tst_QSimToolkit::testDeliverRefresh()
{
    QFETCH( QByteArray, data );
    QFETCH( QByteArray, resp );
    QFETCH( int, resptype );
    QFETCH( int, refreshtype );
    QFETCH( int, numfiles );
    QFETCH( QString, fileids );
    QFETCH( int, options );

    // Output a dummy line to give some indication of which test we are currently running.
    qDebug() << "";

    // Clear the client/server state.
    server->clear();
    deliveredCommand = QSimCommand();

    // Compose and send the command.
    QSimCommand cmd;
    cmd.setType( QSimCommand::Refresh );
    cmd.setRefreshType( (QSimCommand::RefreshType)refreshtype );
    if ( numfiles > 0 ) {
        QByteArray extData;
        extData += (char)numfiles;
        extData += QAtUtils::fromHex( fileids );
        cmd.addExtensionField( 0x92, extData );
    }
    server->emitCommand( cmd );

    // Wait for the command to arrive in the client.
    QVERIFY( QFutureSignal::wait( this, SIGNAL(commandSeen()), 100 ) );

    // Verify that the command was delivered exactly as we asked.
    QVERIFY( deliveredCommand.type() == cmd.type() );
    QVERIFY( deliveredCommand.refreshType() == cmd.refreshType() );
    QVERIFY( deliveredCommand.extensionData() == cmd.extensionData() );
    QCOMPARE( deliveredCommand.toPdu( (QSimCommand::ToPduOptions)options ), data );

    // The response should have been sent immediately.
    QCOMPARE( server->responseCount(), 1 );
    QCOMPARE( server->envelopeCount(), 0 );
    if ( resptype != 0x0003 ) {
        QCOMPARE( server->lastResponse(), resp );
    } else {
        // We cannot test the "additional EF's read" case because the qtopiaphone
        // library will always respond with "command performed successfully".
        QByteArray resp2 = resp;
        resp2[resp2.size() - 1] = 0x00;
        QCOMPARE( server->lastResponse(), resp2 );
    }
}
Ejemplo n.º 26
0
void DemoSimApplication::sticksGameShow()
{
    QSimCommand cmd;
    if ( sticksLeft == 1 ) {
        cmd.setType( QSimCommand::GetInkey );
        cmd.setText( "There is only 1 stick left.  You lose.  Play again?" );
        cmd.setWantYesNo( true );
        command( cmd, this, SLOT(sticksGamePlayAgain(QSimTerminalResponse)) );
    } else {
        cmd.setType( QSimCommand::GetInkey );
        cmd.setText( "There are 21 sticks left.  How many do you take (1, 2, or 3)?" );
        cmd.setWantDigits( true );
        if ( sticksLeft == 21 )
            cmd.setHasHelp( true );
        command( cmd, this, SLOT(sticksGameLoop(QSimTerminalResponse)) );
    }
}
Ejemplo n.º 27
0
void SimApp::softKeysMenu(const QSimCommand& cmd)
{
    // Request icons from the SIM if the menu contains them.
    QList<QSimMenuItem> items = cmd.menuItems();
    QList<QSimMenuItem>::ConstIterator it;
    for (it = items.begin(); it != items.end(); ++it) {
        int iconId = (int)((*it).iconId());
        if ( iconId > 0 )
            createIconReader();
    }

    // Create the menu widgetry.
    SoftKeysMenu *menu = new SoftKeysMenu(cmd, iconReader, stack);

    // main menu send QSimEnvelope,sub menu sends QSimTerminalResponse
    if (cmd.type() == QSimCommand::SetupMenu) {
        connect(menu, SIGNAL(sendEnvelope(QSimEnvelope)),
                this, SLOT(sendEnvelope(QSimEnvelope)) );
    } else {
        connect(menu, SIGNAL(sendResponse(QSimTerminalResponse)),
                this, SLOT(sendResponse(QSimTerminalResponse)) );
    }
    setView(menu);
}
Ejemplo n.º 28
0
void tst_QSimToolkit::testEncodeRefresh()
{
    QFETCH( QByteArray, data );
    QFETCH( QByteArray, resp );
    QFETCH( int, resptype );
    QFETCH( int, refreshtype );
    QFETCH( int, numfiles );
    QFETCH( QString, fileids );
    QFETCH( int, options );

    // Output a dummy line to give some indication of which test we are currently running.
    qDebug() << "";

    // Check that the command PDU can be parsed correctly.
    QSimCommand decoded = QSimCommand::fromPdu(data);
    QVERIFY( decoded.type() == QSimCommand::Refresh );
    QVERIFY( decoded.destinationDevice() == QSimCommand::ME );
    QCOMPARE( (int)decoded.refreshType(), refreshtype );
    if ( numfiles > 0 ) {
        QCOMPARE( decoded.extensionField(0x92)[0] & 0xFF, numfiles );
        QCOMPARE( decoded.extensionField(0x92).mid(1), QAtUtils::fromHex(fileids) );
    } else {
        QCOMPARE( decoded.extensionField(0x92), QByteArray() );
    }

    // Check that the original command PDU can be reconstructed correctly.
    QByteArray encoded = decoded.toPdu( (QSimCommand::ToPduOptions)options );
    QCOMPARE( encoded, data );

    // Check that the terminal response PDU can be parsed correctly.
    QSimTerminalResponse decodedResp = QSimTerminalResponse::fromPdu(resp);
    QVERIFY( data.contains( decodedResp.commandPdu() ) );
    if ( resptype < 0x0100 ) {
        QVERIFY( decodedResp.result() == (QSimTerminalResponse::Result)resptype );
        QVERIFY( decodedResp.causeData().isEmpty() );
        QVERIFY( decodedResp.cause() == QSimTerminalResponse::NoSpecificCause );
    } else {
        QVERIFY( decodedResp.result() == (QSimTerminalResponse::Result)(resptype >> 8) );
        QVERIFY( decodedResp.causeData().size() == 1 );
        QVERIFY( decodedResp.cause() == (QSimTerminalResponse::Cause)(resptype & 0xFF) );
    }

    // Check that the original terminal response PDU can be reconstructed correctly.
    QCOMPARE( decodedResp.toPdu(), resp );
}
Ejemplo n.º 29
0
void DemoSimApplication::sendDisplayText()
{
    // Display a text string and then go back to the main menu once the
    // text is accepted by the user.
    QSimCommand cmd;
    cmd.setType( QSimCommand::DisplayText );
    cmd.setDestinationDevice( QSimCommand::Display );
    cmd.setClearAfterDelay(false);
    cmd.setImmediateResponse(true);
    cmd.setHighPriority(false);
    immediateResponse = true;
    cmd.setText( "Police today arrested a man on suspicion "
            "of making phone calls while intoxicated.  Witnesses claimed "
            "that they heard the man exclaim \"I washent dwinkn!\" as "
            "officers escorted him away." );
    command( cmd, this, SLOT(displayTextResponse(QSimTerminalResponse)) );
}
Ejemplo n.º 30
0
void SimApp::simCommand(const QSimCommand &cmd)
{
    switch (cmd.type()) {
        case QSimCommand::SetupMenu: {
            // prevent No SIM message from appearing while fetching main menu
            if ( failLabel ) {
                stack->removeWidget( failLabel );
                delete failLabel;
                failLabel = 0;
            }
            QWidget *oldView = view;
            if (listViewPreferred(cmd))
                cmdMenu(cmd);
            else
                softKeysMenu(cmd);
            removeView(oldView);
            break;
        }
        case QSimCommand::DisplayText:
            cmdDisplayText(cmd);
            break;
        case QSimCommand::GetInkey:
            cmdInKey(cmd);
            break;
        case QSimCommand::GetInput:
            cmdInput(cmd);
            break;
        case QSimCommand::SetupCall:
            cmdSetupCall(cmd);
            break;
        case QSimCommand::PlayTone:
            cmdTone(cmd);
            break;
        case QSimCommand::SelectItem:
            if (listViewPreferred(cmd))
                cmdMenu(cmd);
            else
                softKeysMenu(cmd);
            break;
        case QSimCommand::Refresh:
            cmdRefresh(cmd);
            break;
        case QSimCommand::SendSS:
        case QSimCommand::SendSMS:
        case QSimCommand::SendUSSD:
        case QSimCommand::SendDTMF:
        case QSimCommand::RunATCommand:
        case QSimCommand::CloseChannel:
        case QSimCommand::ReceiveData:
        case QSimCommand::SendData:
            // Pop up a notification to the user if text is not empty.
            showNotification(cmd);
            break;
        case QSimCommand::Timeout:
            // Wavecom only - ignore this.
            break;
        case QSimCommand::EndSession:
            qApp->quit();
            break;
        case QSimCommand::LaunchBrowser:
            cmdLaunchBrowser(cmd);
            break;
        case QSimCommand::OpenChannel:
            cmdChannel(cmd);
            break;
        case QSimCommand::SetupIdleModeText:
            cmdIdleModeText(cmd);
            break;
        case QSimCommand::NoCommand:
        case QSimCommand::MoreTime:
        case QSimCommand::PollInterval:
        case QSimCommand::PollingOff:
        case QSimCommand::ProvideLocalInformation:
        case QSimCommand::PerformCardAPDU:
        case QSimCommand::PowerOffCard:
        case QSimCommand::PowerOnCard:
        case QSimCommand::GetReaderStatus:
        case QSimCommand::TimerManagement:
        case QSimCommand::GetChannelStatus:
        case QSimCommand::LanguageNotification:
            // Ignore these commands: they are handled by modem vendor plugins.
            break;
        case QSimCommand::SetupEventList:
            cmdSetupEventList(cmd);
            break;

        default: break;
    }
}