satui/satapp/src/satappinputprovider.cpp
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Provides input methods like query dialogs
       
    15 *
       
    16 */
       
    17 
       
    18 // qt
       
    19 #include <QTimer>
       
    20 #include <QtDebug>
       
    21 // hb
       
    22 #include <hbglobal.h>
       
    23 #include <hbinputdialog.h>
       
    24 #include <hbinputeditorinterface.h>
       
    25 #include <hbinputstandardfilters.h>
       
    26 #include <hbmessagebox.h>
       
    27 #include <hblabel.h>
       
    28 #include <hbaction.h>
       
    29 // satapp
       
    30 #include "satappinputprovider.h"
       
    31 #include "satappconstant.h"
       
    32 #include "satappaction.h"
       
    33 
       
    34 
       
    35 // ----------------------------------------------------------------------------
       
    36 // SatAppInputProvider::SatAppInputProvider
       
    37 // ----------------------------------------------------------------------------
       
    38 //
       
    39 SatAppInputProvider::SatAppInputProvider(QObject *parent)
       
    40     : QObject(parent), mCurrentAction(0), mCurrentDialog(0)
       
    41 {
       
    42     qDebug("SATAPP: SatAppInputProvider::SatAppInputProvider >");
       
    43     mDurationTimer = new QTimer(this);
       
    44     qDebug("SATAPP: SatAppInputProvider::SatAppInputProvider <");
       
    45 }
       
    46 
       
    47 // ----------------------------------------------------------------------------
       
    48 // SatAppInputProvider::~SatAppInputProvider
       
    49 // ----------------------------------------------------------------------------
       
    50 //
       
    51 SatAppInputProvider::~SatAppInputProvider()
       
    52 {
       
    53     qDebug("SATAPP: SatAppInputProvider::~SatAppInputProvider >");
       
    54     delete mCurrentDialog;
       
    55     mCurrentDialog = 0;
       
    56     qDebug("SATAPP: SatAppInputProvider::~SatAppInputProvider <");
       
    57 }
       
    58 
       
    59 // ----------------------------------------------------------------------------
       
    60 // SatAppInputProvider::getInkey
       
    61 // requests user to enter a SINGLE key, character or digit
       
    62 // ----------------------------------------------------------------------------
       
    63 //
       
    64 void SatAppInputProvider::getInkey(SatAppAction& action)
       
    65 {
       
    66     qDebug("SATAPP: SatAppInputProvider::getInkey >");
       
    67     
       
    68     delete mCurrentDialog;
       
    69     mCurrentDialog=0;
       
    70     
       
    71     QString heading = action.value(KeyText).toString();
       
    72     qDebug() << "SATAPP: getInkey: heading=" << heading;
       
    73     
       
    74     TSatCharacterSet characterSet = 
       
    75         static_cast<TSatCharacterSet>(action.value(KeyCharacterSet).toInt());
       
    76 
       
    77     qDebug("SATAPP: SatAppInputProvider::getInkey char set %d", characterSet);
       
    78 
       
    79     // yes no query must have text.
       
    80     if ((0 == heading.length()) && (ESatYesNo == characterSet)) {
       
    81         action.completeWithFailure();
       
    82         return;
       
    83     }
       
    84     
       
    85     // duration
       
    86     int duration = action.value(KeyDuration).toInt();
       
    87     if (duration == 0) {
       
    88         duration = KDefaultSelectionTimeoutMseconds;
       
    89     }
       
    90     qDebug("SATAPP: getInkey: duration=%d", duration);
       
    91     mInputTimer.start();
       
    92 
       
    93     if (heading.isEmpty()) {
       
    94         if (ESatDigitOnly == characterSet) {
       
    95             heading = hbTrId("txt_simatk_dialog_entern1_digit_09");
       
    96         } else {
       
    97             // ESatCharSmsDefaultAlphabet or ESatCharUcs2Alphabet
       
    98             heading = hbTrId("txt_simatk_dialog_entern1_character");
       
    99         }
       
   100     }
       
   101     qDebug() << "SATAPP: getInkey: heading=" << heading;
       
   102 
       
   103     mCurrentAction = &action;
       
   104     bool immediate = action.value(KeyImmediate).toBool();
       
   105     qDebug() << "SATAPP: getInkey: immediate=" << immediate;
       
   106     
       
   107     if (characterSet == ESatYesNo) {
       
   108         //Yes no imediate will be combine with YES no.
       
   109         showGetYesNoQuery(heading, duration);
       
   110     }
       
   111     else if (immediate) {
       
   112         // we only have digit immediate
       
   113         showGetImmediateQuery(heading, duration);
       
   114     }
       
   115     else {
       
   116         // Reminder, there is no default inkey in get inkey
       
   117         // proactive command.
       
   118         showGetInkeyQuery(heading, characterSet, duration);
       
   119     }
       
   120     SAT_ASSERT(connect(mCurrentAction, SIGNAL(actionCompleted(SatAppAction*)),
       
   121         this, SLOT(clearDurationTimer())));
       
   122     qDebug("SATAPP: SatAppInputProvider::getInkey <");
       
   123 }
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // SatAppInputProvider::getInput
       
   127 // requests user to enter a STRING of free text, number or password etc.
       
   128 // ----------------------------------------------------------------------------
       
   129 //
       
   130 void SatAppInputProvider::getInput(SatAppAction& action)
       
   131 {
       
   132     qDebug("SATAPP: SatAppInputProvider::getInput >");
       
   133  
       
   134     delete mCurrentDialog;
       
   135     mCurrentDialog=0;
       
   136     // character set
       
   137     TSatCharacterSet characterSet = 
       
   138         static_cast<TSatCharacterSet>(action.value(KeyCharacterSet).toInt());
       
   139 
       
   140     qDebug("SATAPP: SatAppInputProvider::getInput char set %d", characterSet);
       
   141 
       
   142     // heading
       
   143     QString heading = action.value(KeyText).toString();
       
   144     qDebug() << "SATAPP: getInput: heading=" << heading;
       
   145     if (heading.isEmpty()) {
       
   146         if (ESatDigitOnly == characterSet) {
       
   147             heading = hbTrId("txt_simatk_dialog_entern1_digit_09");
       
   148         } else {
       
   149             // ESatCharSmsDefaultAlphabet or ESatCharUcs2Alphabet
       
   150             heading = hbTrId("txt_simatk_dialog_entern1_character");
       
   151         }
       
   152     }
       
   153     qDebug() << "SATAPP: getInput: heading=" << heading;
       
   154 
       
   155     // min length
       
   156     int minLength = action.value(KeyMinLength).toInt();
       
   157     if (minLength<0) {
       
   158         minLength=0;
       
   159     }
       
   160     if (minLength>KGetInputStringMaxSize){
       
   161         minLength=KGetInputStringMaxSize;
       
   162     }
       
   163 
       
   164     // max length
       
   165     int maxLength = action.value(KeyMaxLength).toInt();
       
   166     if (maxLength<minLength) {
       
   167         maxLength=minLength;
       
   168     }
       
   169     if (maxLength>KGetInputStringMaxSize) {
       
   170         maxLength=KGetInputStringMaxSize;
       
   171     }
       
   172     qDebug("SATAPP: SatAppInputProvider::getInput min %d", minLength);
       
   173     qDebug("SATAPP: SatAppInputProvider::getInput max %d", maxLength);
       
   174 
       
   175     // default input text
       
   176     QString inputText = action.value(KeyInputString).toString();
       
   177     if (inputText.length() < minLength || inputText.length() > maxLength){
       
   178         inputText = "";
       
   179     }
       
   180     qDebug() << "SATAPP: getInput: inputText=" << inputText;
       
   181 
       
   182     // hide input
       
   183     bool hideInput = action.value(KeyHideInput).toBool();
       
   184     qDebug("SATAPP: SatAppInputProvider::getInput hide %d", hideInput);
       
   185 
       
   186     qDebug("SATAPP: getInput: min=%d,max=%d,hide=%d",
       
   187         minLength, maxLength, hideInput);
       
   188     
       
   189     mCurrentAction = &action;
       
   190     showGetInputQuery( heading, inputText,
       
   191             characterSet, minLength, maxLength, hideInput);
       
   192  
       
   193     SAT_ASSERT(connect(mCurrentAction, SIGNAL(actionCompleted(SatAppAction*)),
       
   194         this, SLOT(clearDurationTimer())));
       
   195     qDebug("SATAPP: SatAppInputProvider::getInput <");
       
   196 }
       
   197 
       
   198 // ----------------------------------------------------------------------------
       
   199 // SatAppInputProvider::showGetInkeyQuery
       
   200 // ----------------------------------------------------------------------------
       
   201 //
       
   202 void SatAppInputProvider::showGetInkeyQuery(
       
   203     const QString &heading,
       
   204     TSatCharacterSet characterSet,
       
   205     int duration)
       
   206 {
       
   207     qDebug("SATAPP: SatAppInputProvider::showGetInkeyQuery >");
       
   208 
       
   209     HbInputDialog* inputDialog = new HbInputDialog();
       
   210     mCurrentDialog = inputDialog;
       
   211     // Set PromptText
       
   212     inputDialog->setPromptText(heading);
       
   213     // Set ContentText
       
   214     HbEditorInterface inputMode(inputDialog->lineEdit());
       
   215     inputDialog->lineEdit()->setFocus();
       
   216     if (ESatDigitOnly == characterSet) {
       
   217         // digit mode, digits only (0 9, *, #, and +)
       
   218         inputMode.setFilter(HbPhoneNumberFilter::instance());
       
   219         inputMode.setMode(HbInputModeNumeric);
       
   220         inputMode.setInputConstraints(HbEditorConstraintFixedInputMode);
       
   221     } else {
       
   222         // char mode
       
   223         inputMode.setUpAsLatinAlphabetOnlyEditor();
       
   224     }
       
   225     composeDialog(inputDialog, GetInkey);
       
   226     mCurrentAction->set(KeyMinLength, 1); 
       
   227     inputDialog->lineEdit()->setMaxLength(1);
       
   228 
       
   229     // when input changed, enable/disable OK button
       
   230     SAT_ASSERT(connect(inputDialog->lineEdit(), SIGNAL(textChanged(QString)),
       
   231         this, SLOT(updateQueryAction(QString))));
       
   232     // when OK pressed, fill in data to action and complete it
       
   233     SAT_ASSERT(connect(inputDialog->actions().at(0), SIGNAL(triggered()),
       
   234         this, SLOT(transmitInkeyFromDialog())));
       
   235     // when cancel pressed, complete action with ESatBackwardModeRequestedByUser
       
   236     SAT_ASSERT(connect(inputDialog->actions().at(1), SIGNAL(triggered()),
       
   237         mCurrentAction, SLOT(completeWithBackRequested())));
       
   238     // after timeout, reset the provider
       
   239     startDurationTimer(duration);
       
   240     // open the dialog. When the dialog closes, reset everything
       
   241     inputDialog->open();
       
   242 
       
   243     qDebug("SATAPP: SatAppInputProvider::showGetInkeyQuery <");
       
   244 }
       
   245 
       
   246 // ----------------------------------------------------------------------------
       
   247 // SatAppInputProvider::showGetImmediateQuery
       
   248 // ----------------------------------------------------------------------------
       
   249 //
       
   250 void SatAppInputProvider::showGetImmediateQuery(
       
   251     const QString &heading,
       
   252     int duration)
       
   253 {
       
   254     qDebug("SATAPP: SatAppInputProvider::showGetImmediateQuery >");
       
   255 
       
   256     HbInputDialog* inputDialog = new HbInputDialog();
       
   257     mCurrentDialog = inputDialog;
       
   258     // Set PromptText
       
   259     inputDialog->setPromptText(heading);
       
   260     // Set ContentText
       
   261     HbEditorInterface inputMode(inputDialog->lineEdit());
       
   262     inputDialog->lineEdit()->setFocus();
       
   263 
       
   264     inputMode.setFilter(HbPhoneNumberFilter::instance());
       
   265     inputMode.setMode(HbInputModeNumeric);
       
   266     inputMode.setInputConstraints(HbEditorConstraintFixedInputMode);
       
   267     
       
   268     composeDialog(inputDialog, GetImmediate);
       
   269 
       
   270     // when receiving first input character, send it immediately
       
   271     SAT_ASSERT(connect(inputDialog->lineEdit(), SIGNAL(textChanged(QString)),
       
   272         this, SLOT(transmitInkeyImmediately(QString))));
       
   273     // when cancel pressed, complete action with ESatBackwardModeRequestedByUser
       
   274     SAT_ASSERT(connect(inputDialog->actions().at(0), SIGNAL(triggered()),
       
   275         mCurrentAction, SLOT(completeWithBackRequested())));
       
   276     // after timeout, reset the provider
       
   277     startDurationTimer(duration);
       
   278     // open the dialog. When the dialog closes, reset everything
       
   279     inputDialog->open();
       
   280 
       
   281     qDebug("SATAPP: SatAppInputProvider::showGetImmediateQuery <");
       
   282 }
       
   283 
       
   284 // ----------------------------------------------------------------------------
       
   285 // SatAppInputProvider::showGetYesNoQuery
       
   286 // ----------------------------------------------------------------------------
       
   287 //
       
   288 void SatAppInputProvider::showGetYesNoQuery(
       
   289     const QString &text,
       
   290     int duration)
       
   291 {
       
   292     qDebug("SATAPP: SatAppInputProvider::showGetYesNoQuery >");
       
   293     HbMessageBox* messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
       
   294     mCurrentDialog = messageBox;
       
   295 
       
   296     // Set the label as heading widget
       
   297     HbLabel *lHeading = new HbLabel(text, messageBox);
       
   298     messageBox->setHeadingWidget(lHeading);
       
   299     messageBox->setIconVisible(false);
       
   300 
       
   301     composeDialog(messageBox, GetYesNo);
       
   302 
       
   303     // when YES pressed, complete action with ESatSuccess, inkey set to 1
       
   304     SAT_ASSERT(connect(messageBox->actions().at(0), SIGNAL(triggered()),
       
   305         this, SLOT(transmitInkeyTrue())));
       
   306     // when NO pressed, complete action with ESatSuccess, inkey set to 0
       
   307     SAT_ASSERT(connect(messageBox->actions().at(1), SIGNAL(triggered()),
       
   308         this, SLOT(transmitInkeyFalse())));
       
   309  
       
   310     startDurationTimer(duration);     
       
   311     // show dialog.
       
   312     messageBox->open();
       
   313 
       
   314     qDebug("SATAPP: SatAppInputProvider::showGetYesNoQuery <");
       
   315 }
       
   316 
       
   317 // ----------------------------------------------------------------------------
       
   318 // SatAppInputProvider::showGetInputQuery
       
   319 // ----------------------------------------------------------------------------
       
   320 //
       
   321 void SatAppInputProvider::showGetInputQuery(
       
   322     const QString& heading,
       
   323     const QString& content,
       
   324     TSatCharacterSet characterSet,
       
   325     int minLength,
       
   326     int maxLength,
       
   327     bool hideInput)
       
   328 {
       
   329     Q_UNUSED(minLength);
       
   330     qDebug("SATAPP: SatAppInputProvider::showGetInputQuery >");
       
   331 
       
   332     HbInputDialog* inputQuery = new HbInputDialog();
       
   333     mCurrentDialog = inputQuery;
       
   334     inputQuery->setPromptText(heading);
       
   335     inputQuery->setValue(QVariant(content));
       
   336     HbEditorInterface inputMode(inputQuery->lineEdit());
       
   337     inputQuery->lineEdit()->setFocus();
       
   338     if (ESatDigitOnly == characterSet) {
       
   339         // digit mode, digits only (0 9, *, #, and +)
       
   340         inputMode.setFilter(HbPhoneNumberFilter::instance());
       
   341         inputMode.setMode(HbInputModeNumeric);
       
   342         inputMode.setInputConstraints(HbEditorConstraintFixedInputMode);
       
   343     } else {
       
   344         // char mode
       
   345         inputMode.setUpAsLatinAlphabetOnlyEditor();
       
   346     }
       
   347 
       
   348     inputQuery->lineEdit()->setMaxLength(maxLength);
       
   349 
       
   350     composeDialog(inputQuery, GetInput);
       
   351     // initially set the button states
       
   352     updateQueryAction(inputQuery->value().toString());
       
   353 
       
   354     if (hideInput) {
       
   355         inputQuery->lineEdit()->setEchoMode(HbLineEdit::Password);
       
   356         qDebug("SATAPP: showGetInputQuery: hiding input");
       
   357     }
       
   358 
       
   359     // when dialog content changes, dim ok button accordingly, use
       
   360     // use contentChanged signal from the base class of the editor
       
   361     // to get the signal when in password mode
       
   362     SAT_ASSERT(connect(inputQuery->lineEdit(), SIGNAL(contentsChanged()), 
       
   363         this, SLOT(updateQueryAction())));
       
   364     // transmit the text on OK press
       
   365     SAT_ASSERT(connect(inputQuery->actions().at(0), SIGNAL(triggered()),
       
   366         this, SLOT(transmitStringFromDialog())));
       
   367     // on Cancel key complete action with ESatBackwardModeRequestedByUser
       
   368     SAT_ASSERT(connect(inputQuery->actions().at(1), SIGNAL(triggered()),
       
   369         mCurrentAction, SLOT(completeWithBackRequested())));
       
   370     // after timeout, reset the provider
       
   371     startDurationTimer(KDefaultSelectionTimeoutMseconds);
       
   372     // open dialog. When it closes, reset everything
       
   373     inputQuery->open();
       
   374 
       
   375     qDebug("SATAPP: SatAppInputProvider::showGetInputQuery <");
       
   376 }
       
   377 
       
   378 // ----------------------------------------------------------------------------
       
   379 // SatAppInputProvider::resetState
       
   380 // ----------------------------------------------------------------------------
       
   381 //
       
   382 void SatAppInputProvider::resetState()
       
   383 {
       
   384     qDebug("SATAPP: SatAppInputProvider::resetState >");
       
   385     if (mCurrentAction) {
       
   386         qDebug("SATAPP: SatAppInputProvider::resetState action");        
       
   387         mCurrentAction->completeWithNoResponse();
       
   388         mCurrentAction = 0;
       
   389     }
       
   390 
       
   391     qDebug("SATAPP: SatAppInputProvider::resetState action done");
       
   392 
       
   393     delete mCurrentDialog;
       
   394     mCurrentDialog = 0;
       
   395     qDebug("SATAPP: SatAppInputProvider::resetState <");
       
   396 }
       
   397 
       
   398 // ----------------------------------------------------------------------------
       
   399 // SatAppInputProvider::composeDialog
       
   400 // make sure dlg has 2 buttons
       
   401 // ----------------------------------------------------------------------------
       
   402 //
       
   403 void SatAppInputProvider::composeDialog(
       
   404     HbDialog *dlg,
       
   405     DialogMode mode)
       
   406 {
       
   407     qDebug("SATAPP: SatAppInputProvider::composeDialog >");
       
   408     Q_ASSERT(mCurrentAction);
       
   409 
       
   410     dlg->setModal(true);
       
   411     dlg->setDismissPolicy(HbDialog::NoDismiss);
       
   412 
       
   413     dlg->clearActions();
       
   414     HbAction *primaryAction = new HbAction(dlg);
       
   415     dlg->addAction(primaryAction);
       
   416     
       
   417     HbAction *secondaryAction = new HbAction(dlg);
       
   418     dlg->addAction(secondaryAction);
       
   419     
       
   420     switch(mode){
       
   421         case GetYesNo:
       
   422         {
       
   423             primaryAction->setText(hbTrId("txt_common_button_yes"));
       
   424             secondaryAction->setText(hbTrId("txt_common_button_no"));
       
   425             break;
       
   426         }
       
   427         case GetImmediate:
       
   428         {
       
   429             dlg->removeAction(primaryAction);
       
   430             secondaryAction->setText(hbTrId("txt_common_button_cancel"));
       
   431             break;
       
   432         }
       
   433         default:
       
   434         {
       
   435             primaryAction->setText(hbTrId("txt_common_button_ok"));
       
   436             primaryAction->setEnabled(false);
       
   437             secondaryAction->setText(hbTrId("txt_common_button_cancel"));
       
   438             break;
       
   439         }
       
   440     }
       
   441     qDebug("SATAPP: SatAppInputProvider::composeDialog <");
       
   442 }
       
   443 
       
   444 // ----------------------------------------------------------------------------
       
   445 // SatAppInputProvider::updateQueryAction
       
   446 // Updates dialog's OK button according to input text length limits
       
   447 // ----------------------------------------------------------------------------
       
   448 //
       
   449 void SatAppInputProvider::updateQueryAction()
       
   450 {
       
   451     qDebug("SATAPP: SatAppInputProvider::updateQueryAction >");
       
   452     Q_ASSERT(mCurrentDialog);
       
   453     QString content = 
       
   454         qobject_cast<HbInputDialog*>(mCurrentDialog)->value().toString();
       
   455     qDebug() << "SATAPP: updateQueryAction: content=" << content;
       
   456     updateQueryAction(content);
       
   457     qDebug("SATAPP: SatAppInputProvider::updateQueryAction >");
       
   458 }
       
   459 
       
   460 // ----------------------------------------------------------------------------
       
   461 // SatAppInputProvider::updateQueryAction
       
   462 // Updates dialog's OK button according to input text length limits
       
   463 // ----------------------------------------------------------------------------
       
   464 //
       
   465 void SatAppInputProvider::updateQueryAction(QString text)
       
   466 {
       
   467     qDebug("SATAPP: SatAppInputProvider::updateQueryAction 2>");
       
   468     Q_ASSERT(mCurrentDialog);
       
   469     qDebug() << "SATAPP: updateQueryAction 2: text=" << text;
       
   470     int min=0;
       
   471     if (mCurrentAction->hasValue(KeyMinLength))
       
   472         min=mCurrentAction->value(KeyMinLength).toInt();
       
   473     int max=10;
       
   474     if (mCurrentAction->hasValue(KeyMaxLength))
       
   475         max=mCurrentAction->value(KeyMaxLength).toInt();
       
   476     if (mCurrentDialog->actions().at(0)) {
       
   477         if (text.length() >= min && text.length() <= max) {
       
   478             mCurrentDialog->actions().at(0)->setEnabled(true);
       
   479         } else {
       
   480             mCurrentDialog->actions().at(0)->setEnabled(false);
       
   481         }
       
   482     }
       
   483     qDebug("SATAPP: SatAppInputProvider::updateQueryAction 2<");
       
   484 }
       
   485 
       
   486 // ----------------------------------------------------------------------------
       
   487 // SatAppInputProvider::transmitInkeyFromDialog
       
   488 // ----------------------------------------------------------------------------
       
   489 //
       
   490 void SatAppInputProvider::transmitInkeyFromDialog()
       
   491 {
       
   492     qDebug("SATAPP: SatAppInputProvider::transmitInkeyFromDialog >");
       
   493     Q_ASSERT(mCurrentDialog);
       
   494     Q_ASSERT(mCurrentAction->action()==ESatGetInkeyAction);
       
   495     // grab the input string
       
   496     HbInputDialog* inkeyQuery = static_cast<HbInputDialog*>(mCurrentDialog);
       
   497     QString inputString = inkeyQuery->value().toString();
       
   498     qDebug() << "SATAPP: transmitInkeyFromDialog: input=" << inputString;
       
   499     transmitInkeyImmediately(inputString);
       
   500     qDebug("SATAPP: SatAppInputProvider::transmitInkeyFromDialog <");
       
   501 }
       
   502 
       
   503 // ----------------------------------------------------------------------------
       
   504 // SatAppInputProvider::transmitInkeyImmediately
       
   505 // ----------------------------------------------------------------------------
       
   506 //
       
   507 void SatAppInputProvider::transmitInkeyImmediately(QString text)
       
   508 {
       
   509     qDebug("SATAPP: SatAppInputProvider::transmitInkeyImmediately >");
       
   510     transmitInkey((int)text.utf16()[0]);
       
   511     qDebug("SATAPP: SatAppInputProvider::transmitInkeyImmediately <");
       
   512 }
       
   513 
       
   514 
       
   515 // ----------------------------------------------------------------------------
       
   516 // SatAppInputProvider::transmitInkeyTrue
       
   517 // ----------------------------------------------------------------------------
       
   518 //
       
   519 void SatAppInputProvider::transmitInkeyTrue()
       
   520 {
       
   521     qDebug("SATAPP: SatAppInputProvider::transmitInkeyTrue >");
       
   522     Q_ASSERT(mCurrentAction);
       
   523     Q_ASSERT(mCurrentAction->action()==ESatGetInkeyAction);
       
   524     Q_ASSERT(mCurrentAction->value(KeyCharacterSet).toInt()==ESatYesNo);
       
   525     transmitInkey(1);
       
   526     qDebug("SATAPP: SatAppInputProvider::transmitInkeyTrue <");
       
   527 }
       
   528 
       
   529 // ----------------------------------------------------------------------------
       
   530 // SatAppInputProvider::transmitInkeyFalse
       
   531 // ----------------------------------------------------------------------------
       
   532 //
       
   533 void SatAppInputProvider::transmitInkeyFalse()
       
   534 {
       
   535     qDebug("SATAPP: SatAppInputProvider::transmitInkeyFalse >");
       
   536     Q_ASSERT(mCurrentAction);
       
   537     Q_ASSERT(mCurrentAction->action()==ESatGetInkeyAction);
       
   538     Q_ASSERT(mCurrentAction->value(KeyCharacterSet).toInt()==ESatYesNo);
       
   539     transmitInkey(0);
       
   540     qDebug("SATAPP: SatAppInputProvider::transmitInkeyFalse >");
       
   541 }
       
   542 
       
   543 // ----------------------------------------------------------------------------
       
   544 // SatAppInputProvider::transmit
       
   545 // ----------------------------------------------------------------------------
       
   546 //
       
   547 void SatAppInputProvider::transmitInkey(int key)
       
   548 {
       
   549     qDebug("SATAPP: SatAppInputProvider::transmitInkey >");
       
   550     qDebug("SATAPP: SatAppInputProvider::transmitInkey %d",key);
       
   551     Q_ASSERT(mCurrentAction);
       
   552     Q_ASSERT(mCurrentAction->action()==ESatGetInkeyAction);
       
   553     // write inkey
       
   554     mCurrentAction->set(KeyInKey,key);
       
   555     // overwrite timer duration
       
   556     if (mCurrentAction->hasValue(KeyDuration)) {
       
   557         int newDuration = mInputTimer.elapsed();
       
   558         qDebug("SATAPP: SatAppInputProvider::transmitInkey dur ", newDuration);
       
   559         mCurrentAction->set(KeyDuration, newDuration);
       
   560     }
       
   561     bool immediate = mCurrentAction->value(KeyImmediate).toBool();
       
   562     if(immediate) {
       
   563         mCurrentDialog->close();
       
   564     }
       
   565     mCurrentAction->completeWithSuccess();
       
   566     mCurrentAction = 0;
       
   567     qDebug("SATAPP: SatAppInputProvider::transmitInkey >");
       
   568 }
       
   569 
       
   570 // ----------------------------------------------------------------------------
       
   571 // SatAppInputProvider::transmitStringFromDialog
       
   572 // ----------------------------------------------------------------------------
       
   573 //
       
   574 void SatAppInputProvider::transmitStringFromDialog()
       
   575 {
       
   576     qDebug("SATAPP: SatAppInputProvider::transmitStringFromDialog >");
       
   577     Q_ASSERT(mCurrentDialog);
       
   578     Q_ASSERT(mCurrentAction);
       
   579     Q_ASSERT(mCurrentAction->action()==ESatGetInputAction);
       
   580     // write input string
       
   581     HbInputDialog* inputQuery = static_cast<HbInputDialog*>(mCurrentDialog);
       
   582     QString inputString = inputQuery->value().toString();
       
   583     qDebug() << "SATAPP: transmitStringFromDialog: string=" << inputString;
       
   584 
       
   585     mCurrentAction->set(KeyInputString,inputString);
       
   586     // overwrite timer duration
       
   587     if (mCurrentAction->hasValue(KeyDuration)) {
       
   588         int newDuration = mInputTimer.elapsed();
       
   589         qDebug("SATAPP: SatAppInputProvider::transmitStringFromDialog dur ",
       
   590             newDuration);
       
   591         mCurrentAction->set(KeyDuration, newDuration);
       
   592     }
       
   593     mCurrentAction->completeWithSuccess();
       
   594     mCurrentAction = 0;
       
   595     qDebug("SATAPP: SatAppInputProvider::transmitStringFromDialog >");
       
   596 }
       
   597 
       
   598 // ----------------------------------------------------------------------------
       
   599 // SatAppInputProvider::startDurationTimer
       
   600 // ----------------------------------------------------------------------------
       
   601 //
       
   602 void SatAppInputProvider::startDurationTimer(int duration)
       
   603 {
       
   604     qDebug("SATAPP: SatAppInputProvider::startDurationTimer %d>", duration);
       
   605     Q_ASSERT(mDurationTimer);    
       
   606     if (duration) {
       
   607         mDurationTimer->setSingleShot(true);
       
   608         SAT_ASSERT(connect(mDurationTimer, SIGNAL(timeout()),
       
   609             this, SLOT(resetState())));
       
   610         mDurationTimer->start(duration);
       
   611     }
       
   612     qDebug("SATAPP: SatAppInputProvider::startDurationTimer <");    
       
   613 }
       
   614 
       
   615 // ----------------------------------------------------------------------------
       
   616 // SatAppInputProvider::clearDurationTimer
       
   617 // ----------------------------------------------------------------------------
       
   618 //
       
   619 void SatAppInputProvider::clearDurationTimer()
       
   620 {
       
   621     qDebug("SATAPP: SatAppInputProvider::clearDurationTimer >");    
       
   622     Q_ASSERT(mDurationTimer);
       
   623     Q_ASSERT(mCurrentAction);
       
   624 
       
   625     bool res = disconnect(mCurrentAction, SIGNAL(actionCompleted(SatAppAction*)),
       
   626         this, SLOT(clearDurationTimer()));
       
   627     qDebug("SATAPP: SatAppInputProvider::clearDurationTimer act %d>", res);
       
   628     res = disconnect(mDurationTimer, SIGNAL(timeout()), 
       
   629         this, SLOT(resetState()));
       
   630     qDebug("SATAPP: SatAppInputProvider::clearDurationTimer dur %d>", res);
       
   631     
       
   632     mDurationTimer->stop();
       
   633     qDebug("SATAPP: SatAppInputProvider::clearDurationTimer <");    
       
   634 }
       
   635 
       
   636 //End of file