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(); }
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); }
void tst_QSimToolkit::testDeliverSendDTMF() { 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 ); Q_UNUSED(resptype); Q_UNUSED(html); // 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::SendDTMF ); cmd.setDestinationDevice( QSimCommand::Network ); cmd.setText( text ); cmd.setNumber( number ); cmd.setIconId( (uint)iconId ); cmd.setIconSelfExplanatory( iconSelfExplanatory ); cmd.setTextAttribute( textAttribute ); 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.text() == cmd.text() ); QVERIFY( deliveredCommand.number() == cmd.number() ); QVERIFY( deliveredCommand.iconId() == cmd.iconId() ); QVERIFY( deliveredCommand.iconSelfExplanatory() == cmd.iconSelfExplanatory() ); QVERIFY( deliveredCommand.textAttribute() == cmd.textAttribute() ); QCOMPARE( deliveredCommand.toPdu( (QSimCommand::ToPduOptions)options ), data ); // The terminal response should have been sent immediately to ack reception of the command. // We cannot check the return data explicitly because that will be handled in the modem // and will typically be invisible to Qtopia. We therefore compare against what the // response would be without the return data. QCOMPARE( server->responseCount(), 1 ); QCOMPARE( server->envelopeCount(), 0 ); QSimTerminalResponse resp2; resp2.setCommand( deliveredCommand ); resp2.setResult( QSimTerminalResponse::Success ); QCOMPARE( server->lastResponse(), resp2.toPdu() ); }
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); } }
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); }
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); }
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); }
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); }
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 ); }
// 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); } } }
void tst_QSimToolkit::testEncodeSendSMS() { QFETCH( QByteArray, data ); QFETCH( QByteArray, resp ); QFETCH( QByteArray, tpdu ); QFETCH( int, resptype ); QFETCH( QString, text ); QFETCH( QString, number ); QFETCH( bool, smsPacking ); 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::SendSMS ); QVERIFY( decoded.destinationDevice() == QSimCommand::Network ); QCOMPARE( decoded.text(), text ); if ( text.isEmpty() ) { if ( ( options & QSimCommand::EncodeEmptyStrings ) != 0 ) QVERIFY( decoded.suppressUserFeedback() ); else QVERIFY( !decoded.suppressUserFeedback() ); } else { QVERIFY( !decoded.suppressUserFeedback() ); } QCOMPARE( decoded.number(), number ); QCOMPARE( decoded.smsPacking(), smsPacking ); QCOMPARE( (int)decoded.iconId(), iconId ); QCOMPARE( decoded.iconSelfExplanatory(), iconSelfExplanatory ); QCOMPARE( decoded.textAttribute(), textAttribute ); if ( !textAttribute.isEmpty() ) QCOMPARE( decoded.textHtml(), html ); // Check the final TPDU. If packing is specified, we have to parse the SMS // and then re-encode it with the 7-bit alphabet. QByteArray newtpdu = decoded.extensionField(0x8B); if ( smsPacking ) { // Add dummy service center address that isn't in the TPDU before decoding. QSMSMessage msg = QSMSMessage::fromPdu( QByteArray( 1, 0 ) + newtpdu ); msg.setDataCodingScheme( msg.dataCodingScheme() & 0xF3 ); // Convert to 7-bit // Convert back into a pdu and strip off the dummy service center address. newtpdu = msg.toPdu().mid(1); } // The TPDU in the command will have a message reference of 0. // We need to change it to the transmission message reference of 1 // before we do the comparison. newtpdu[1] = (char)1; QCOMPARE( newtpdu, tpdu ); // 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 ); }
void tst_QSimToolkit::testDeliverSendSMS() { QFETCH( QByteArray, data ); QFETCH( QByteArray, resp ); QFETCH( QByteArray, tpdu ); QFETCH( int, resptype ); QFETCH( QString, text ); QFETCH( QString, number ); QFETCH( bool, smsPacking ); QFETCH( int, iconId ); QFETCH( bool, iconSelfExplanatory ); QFETCH( QByteArray, textAttribute ); QFETCH( QString, html ); QFETCH( int, options ); Q_UNUSED(html); // 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::SendSMS ); cmd.setDestinationDevice( QSimCommand::Network ); cmd.setText( text ); if ( text.isEmpty() && ( options & QSimCommand::EncodeEmptyStrings ) != 0 ) cmd.setSuppressUserFeedback( true ); cmd.setNumber( number ); cmd.setSmsPacking( smsPacking ); cmd.setIconId( (uint)iconId ); cmd.setIconSelfExplanatory( iconSelfExplanatory ); cmd.setTextAttribute( textAttribute ); QByteArray newtpdu = tpdu; if ( smsPacking ) { // To prevent truncation of the 1.4.1 test data during 7-bit to 8-bit conversion, // we extract the TPDU from "data" rather than use "tpdu". newtpdu = QSimCommand::fromPdu( data ).extensionField(0x8B); } newtpdu[1] = (char)0; cmd.addExtensionField( 0x8B, newtpdu ); 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.text() == cmd.text() ); QVERIFY( deliveredCommand.suppressUserFeedback() == cmd.suppressUserFeedback() ); QVERIFY( deliveredCommand.number() == cmd.number() ); QVERIFY( deliveredCommand.smsPacking() == cmd.smsPacking() ); QVERIFY( deliveredCommand.iconId() == cmd.iconId() ); QVERIFY( deliveredCommand.iconSelfExplanatory() == cmd.iconSelfExplanatory() ); QVERIFY( deliveredCommand.extensionData() == cmd.extensionData() ); QVERIFY( deliveredCommand.textAttribute() == cmd.textAttribute() ); QCOMPARE( deliveredCommand.toPdu( (QSimCommand::ToPduOptions)options ), data ); // The terminal response should have been sent immediately to ack reception of the command. QCOMPARE( server->responseCount(), 1 ); QCOMPARE( server->envelopeCount(), 0 ); if ( resptype != 0x0004 ) { QCOMPARE( server->lastResponse(), resp ); } else { // We cannot test the "icon not displayed" case because the qtopiaphone // library will always respond with "command performed successfully". // Presumably the Qtopia user interface can always display icons. QByteArray resp2 = resp; resp2[resp2.size() - 1] = 0x00; QCOMPARE( server->lastResponse(), resp2 ); } }