satui/satapp/src/satappuiprovider.cpp
changeset 12 ae8abd0db65c
child 13 e32024264ebb
equal deleted inserted replaced
0:ff3b6d0fd310 12:ae8abd0db65c
       
     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:
       
    15 *
       
    16 */
       
    17 #include <QCoreApplication>
       
    18 #include <QTime> // GetInkey duration return
       
    19 #include <QTimer> // timeout callback
       
    20 #include <hbmainwindow.h> // softkey
       
    21 #include <hbdocumentloader.h> // application xml
       
    22 #include <hbaction.h> // action user response
       
    23 #include <hbvalidator.h>
       
    24 #include <hbmessagebox.h> // DisplayText, ConfirmSend, SetUpCall
       
    25 #include <hblabel.h> // DisplayText, GetInput, SetUpCall
       
    26 #include <hbinputdialog.h> // GetInkey
       
    27 #include <hbprogressnote.h> // SendSms wait note
       
    28 #include <hblineedit.h> // For GetInput
       
    29 #include <hbinputeditorinterface.h> // GetInput
       
    30 #include "satappview.h" // SetUpMenu, SelectItem
       
    31 #include "satappgetinkeynote.h" // GetYesNo immediate digit response
       
    32 
       
    33 #include "satappuiprovider.h"
       
    34 #include "tflogger.h"
       
    35 
       
    36 const char *SATAPP_DOCML = ":/xml/satapp.docml";
       
    37 const char *SATAPP_SETUPMENU_VIEW = "setupmenu_view";
       
    38 const char *SATAPP_SELECTITEM_VIEW = "selectitem_view";
       
    39 
       
    40 // ======== MEMBER FUNCTIONS ==================================================
       
    41 
       
    42 // ----------------------------------------------------------------------------
       
    43 // SatAppUiProvider
       
    44 // ----------------------------------------------------------------------------
       
    45 //
       
    46 SatAppUiProvider::SatAppUiProvider(
       
    47     HbMainWindow &window,
       
    48     SatAppEventProvider &event,
       
    49     QObject *parent) :
       
    50     QObject(parent), mMainWindow(window), mLoader(0),
       
    51     mSetupMenuView(0), mSelectItemView(0), mDisplayPopup(0),
       
    52     mGetInkeyQuery(0), mYesNoPopup(0), mGetInputQuery(0),
       
    53     mConfirmSendQuery(0), mSmsWaitNote(0),mDtmfWaitNote(0), mSetUpCallQuery(0),
       
    54     mUserRsp(EUserNoResponse), mDigitalRsp(0), mMinLength(0),mTimer(0),mLoop(0)
       
    55 {
       
    56     TFLOGSTRING("SATAPP: SatAppUiProvider::SatAppUiProvider call");
       
    57 
       
    58     bool docmlLoad = false;
       
    59     mLoader = new SatAppDocumentLoader();
       
    60     // ownership of the objects are transferred to caller
       
    61     mObjects = mLoader->load(SATAPP_DOCML,&docmlLoad);
       
    62     if (docmlLoad) {
       
    63         TFLOGSTRING("SATAPP: SatAppUiProvider::SatAppUiProvider view found")
       
    64         mSetupMenuView = qobject_cast<SatAppView *>(mLoader->findWidget
       
    65         (SATAPP_SETUPMENU_VIEW));
       
    66         if (mSetupMenuView) {
       
    67             mMainWindow.addView(mSetupMenuView);
       
    68             mSetupMenuView->setMainWindow(mMainWindow);
       
    69             mSetupMenuView->initSetupMenu(event, *this);
       
    70             mMainWindow.setCurrentView(mSetupMenuView);
       
    71         }
       
    72 
       
    73         mSelectItemView = qobject_cast<SatAppView *>(mLoader->findWidget
       
    74         (SATAPP_SELECTITEM_VIEW));
       
    75         if (mSelectItemView) {
       
    76             mSelectItemView->setMainWindow(mMainWindow);
       
    77             mSelectItemView->initSelectItem(event, *this);
       
    78         }
       
    79 
       
    80         } else {
       
    81         TFLOGSTRING(
       
    82         "SATAPP: SatAppUiProvider::SatAppUiProvider DOCML failure!");
       
    83         }
       
    84 
       
    85     TFLOGSTRING("SATAPP: SatAppUiProvider::SatAppUiProvider eixt");
       
    86 }
       
    87 
       
    88 // ----------------------------------------------------------------------------
       
    89 // activeView
       
    90 // ----------------------------------------------------------------------------
       
    91 //
       
    92 void SatAppUiProvider::activeView(const QString &view)
       
    93 {
       
    94     TFLOGSTRING("SATAPP: SatAppUiProvider::activeView");
       
    95     if(view == "setupmenu_view") {
       
    96         mMainWindow.removeView(mMainWindow.currentView());
       
    97         mMainWindow.addView(mSetupMenuView);
       
    98         mMainWindow.setCurrentView(mSetupMenuView);
       
    99         TFLOGSTRING("SATAPP: SatAppUiProvider::activeView setup menu");
       
   100     } else {
       
   101         mMainWindow.removeView(mMainWindow.currentView());
       
   102         mMainWindow.addView(mSelectItemView);
       
   103         mMainWindow.setCurrentView(mSelectItemView);
       
   104         TFLOGSTRING("SATAPP: SatAppUiProvider::activeView select item");
       
   105     }
       
   106     TFLOGSTRING("SATAPP: SatAppUiProvider::activeView eixt");
       
   107 }
       
   108 
       
   109 // ----------------------------------------------------------------------------
       
   110 // Destructor
       
   111 // ----------------------------------------------------------------------------
       
   112 //
       
   113 SatAppUiProvider::~SatAppUiProvider()
       
   114 {
       
   115     TFLOGSTRING("SATAPP: SatAppUiProvider::~SatAppUiProvider call");
       
   116     //delete mTopicMonitor;  not in use at the moment
       
   117     delete mLoader;
       
   118     // delete all objects created from DOCML.
       
   119     while (!mObjects.isEmpty()) {
       
   120         TFLOGSTRING(
       
   121         "SATAPP: SatAppUiProvider::~SatAppUiProvider object tree");
       
   122         delete mObjects.takeFirst();
       
   123         }
       
   124     if (mDisplayPopup) {
       
   125         delete mDisplayPopup;
       
   126         mDisplayPopup = 0;
       
   127     }
       
   128     if (mGetInkeyQuery) {
       
   129         delete mGetInkeyQuery;
       
   130         mGetInkeyQuery = 0;
       
   131     }
       
   132     if (mYesNoPopup) {
       
   133         delete mYesNoPopup;
       
   134         mYesNoPopup = 0;
       
   135     }
       
   136     if (mGetInputQuery) {
       
   137         delete mGetInputQuery;
       
   138         mGetInputQuery = 0;
       
   139     }
       
   140     if (mConfirmSendQuery) {
       
   141         delete mConfirmSendQuery;
       
   142         mConfirmSendQuery = 0;
       
   143     }
       
   144     if (mSmsWaitNote) {
       
   145         delete mSmsWaitNote;
       
   146         mSmsWaitNote = 0;
       
   147     }
       
   148     if (mSetUpCallQuery) {
       
   149         delete mSetUpCallQuery;
       
   150         mSetUpCallQuery = 0;
       
   151     }
       
   152     if (mDtmfWaitNote) {
       
   153         delete mDtmfWaitNote;
       
   154         mDtmfWaitNote = 0;
       
   155     }
       
   156 
       
   157     if (mLoop && mLoop->isRunning()) {
       
   158         mLoop->exit();
       
   159         delete mLoop;
       
   160         mLoop = 0;
       
   161         TFLOGSTRING("SatAppUiProvider::~SatAppUiProvider exit loop")
       
   162     }
       
   163 
       
   164     TFLOGSTRING("SATAPP: SatAppUiProvider::~SatAppUiProvider exit");
       
   165 }
       
   166 
       
   167 // ----------------------------------------------------------------------------
       
   168 // userPrimaryResponse
       
   169 // ----------------------------------------------------------------------------
       
   170 //
       
   171 void SatAppUiProvider::userPrimaryResponse()
       
   172 {
       
   173     mUserRsp = EUserPrimaryResponse;
       
   174     TFLOGSTRING("SATAPP: SatAppUiProvider::userPrimaryResponse call-exit")
       
   175 }
       
   176 
       
   177 // ----------------------------------------------------------------------------
       
   178 // userSecondaryResponse
       
   179 // ----------------------------------------------------------------------------
       
   180 //
       
   181 void SatAppUiProvider::userSecondaryResponse()
       
   182 {
       
   183     mUserRsp = EUserSecondaryResponse;
       
   184     TFLOGSTRING("SATAPP: SatAppUiProvider::userSecondaryResponse call-exit")
       
   185 }
       
   186 
       
   187 // ----------------------------------------------------------------------------
       
   188 // showSetUpMenuView
       
   189 // ----------------------------------------------------------------------------
       
   190 //
       
   191 void SatAppUiProvider::showSetUpMenuView(
       
   192     TSatUiResponse &aRes,
       
   193     const QString &aText,
       
   194     const QStringList &aMenuItems,
       
   195     //const CArrayFixFlat<TSatAction> *aMenuItemNextActions,
       
   196     //const HbIcon &aIcon,
       
   197     //const CAknIconArray *aItemIconsArray,
       
   198     const bool aSelfExplanatoryItems,
       
   199     const bool aHelpIsAvailable)
       
   200 {
       
   201     TFLOGSTRING("SATAPP: SatAppUiProvider::showSetUpMenuView call")
       
   202     activeView("setupmenu_view");
       
   203 
       
   204     // The text is the application name
       
   205     // should be shown on the menu area always
       
   206     if (!aText.isEmpty()) {
       
   207         TFLOGSTRING2("SATAPP: SatAppUiProvider::showSetUpMenuView: title1",
       
   208              aText.utf16())
       
   209         mSetupMenuView->setTitle(aText);
       
   210         TFLOGSTRING2("SATAPP: SatAppUiProvider::showSetUpMenuView: title2",
       
   211              aText.utf16())
       
   212         mSelectItemView->setTitle(aText);
       
   213     }
       
   214 
       
   215     mSetupMenuView->showSetUpMenuContent(aRes, aText, aMenuItems,
       
   216             aSelfExplanatoryItems, aHelpIsAvailable);
       
   217     TFLOGSTRING("SATAPP: SatAppUiProvider::showSetUpMenuView exit")
       
   218 }
       
   219 
       
   220 // ----------------------------------------------------------------------------
       
   221 // showSelectItemView
       
   222 // ----------------------------------------------------------------------------
       
   223 //
       
   224 void SatAppUiProvider::showSelectItemView(
       
   225     TSatUiResponse &aRes,
       
   226     const QString &aText,
       
   227     const QStringList &aMenuItems,
       
   228     //const CArrayFixFlat<TSatAction> *aMenuItemNextActions,
       
   229     const int aDefaultItem,
       
   230     unsigned char &aSelection,
       
   231     //const HbIcon &aIcon,
       
   232     //const CAknIconArray *aItemsIconArray,
       
   233     const bool aSelfExplanatoryItems,
       
   234     const bool aHelpIsAvailable)
       
   235 {
       
   236     TFLOGSTRING("SATAPP: SatAppUiProvider::showSelectItemView call")
       
   237     activeView("selectitem_view");
       
   238     mSelectItemView->showSelectItemContent(aRes, aText,
       
   239         aMenuItems, aDefaultItem, aSelection,
       
   240         aSelfExplanatoryItems, aHelpIsAvailable);
       
   241     TFLOGSTRING("SATAPP: SatAppUiProvider::showSelectItemView call")
       
   242 }
       
   243 
       
   244 
       
   245 // ----------------------------------------------------------------------------
       
   246 // showDisplayTextPopup
       
   247 // ----------------------------------------------------------------------------
       
   248 //
       
   249 TSatAppUserResponse SatAppUiProvider::showDisplayTextPopup(
       
   250     const QString &aHeading,
       
   251     const QString &aContent,
       
   252     const int aDuration)
       
   253 {
       
   254     TFLOGSTRING("SATAPP: SatAppUiProvider::showDisplayTextPopup call")
       
   255     resetUserResponse();
       
   256     // Create a note
       
   257     mDisplayPopup = new HbMessageBox(HbMessageBox::MessageTypeInformation);
       
   258 
       
   259     if (mDisplayPopup) {
       
   260         TFLOGSTRING(
       
   261         "SATAPP: SatAppUiProvider::showDisplayTextPopup note created")
       
   262 
       
   263         // Set the label as heading widget
       
   264         HbLabel *heading = new HbLabel(aHeading, mDisplayPopup);
       
   265         mDisplayPopup->setHeadingWidget(heading);
       
   266         mDisplayPopup->setText(aContent);
       
   267         composeDialog(mDisplayPopup, aDuration, ESatDialogDisplayText);
       
   268 
       
   269         TFLOGSTRING(
       
   270         "SATAPP: SatAppUiProvider::showDisplayTextPopup duration before exec")
       
   271         mDisplayPopup->exec();
       
   272         TFLOGSTRING(
       
   273         "SATAPP: SatAppUiProvider::showDisplayTextPopup duration end exec")
       
   274 
       
   275         delete mDisplayPopup;
       
   276         mDisplayPopup = 0;
       
   277     }
       
   278     TFLOGSTRING("SATAPP: SatAppUiProvider::showDisplayTextPopup exit")
       
   279     return mUserRsp;
       
   280 }
       
   281 
       
   282 // ----------------------------------------------------------------------------
       
   283 // showGetInkeyQuery
       
   284 // ----------------------------------------------------------------------------
       
   285 //
       
   286 TSatAppUserResponse SatAppUiProvider::showGetInkeyQuery(
       
   287     const QString &aHeading,
       
   288     QString &aContent,
       
   289     const TSatCharacterSet aCharacterSet,
       
   290     unsigned int &aDuration)
       
   291 {
       
   292     TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInkeyQuery call")
       
   293     TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetInkeyQuery \
       
   294          aHeading=%s", aHeading.utf16())
       
   295     TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetInkeyQuery \
       
   296          aContent=%s", aContent.utf16())
       
   297 
       
   298     resetUserResponse();
       
   299     // Create a query
       
   300     mGetInkeyQuery = new HbInputDialog();
       
   301     if (mGetInkeyQuery) {
       
   302         TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInkeyQuery note created")
       
   303         // Set PromptText
       
   304         mGetInkeyQuery->setPromptText(aHeading);
       
   305         // Set ContentText
       
   306         QVariant vContent(aContent);
       
   307         mGetInkeyQuery->setTextValue(vContent);
       
   308 
       
   309         // Validation rule, what can be entered
       
   310         HbValidator *val =new HbValidator;
       
   311 
       
   312         if (ESatDigitOnly == aCharacterSet) {
       
   313             // digit mode, digits only (0 9, *, #, and +);
       
   314             mGetInkeyQuery->setInputMode(HbInputDialog::IntInput);
       
   315             // Define what digits can be entered
       
   316             QRegExp r("[0123456789*#+]{1,1}"); // from 1 to 1 digits
       
   317             val->setMasterValidator(new QRegExpValidator(r,0));
       
   318             mGetInkeyQuery->setValidator(val);
       
   319         } else {
       
   320             // char mode
       
   321             mGetInkeyQuery->setInputMode(HbInputDialog::TextInput);
       
   322         }
       
   323 
       
   324         unsigned int duration = 60000;
       
   325         if (aDuration) {
       
   326             duration = aDuration * 100;
       
   327         }
       
   328         composeDialog(mGetInkeyQuery, duration, ESatDialogGetInkey);
       
   329         mGetInkeyQuery->lineEdit()->setMaxLength(1);
       
   330         connect(mGetInkeyQuery->lineEdit(), SIGNAL(textChanged(QString)),
       
   331             this, SLOT(updateQueryAction(QString)));
       
   332         TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInkeyQuery before pop")
       
   333         mGetInkeyQuery->exec();
       
   334         TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInkeyQuery end pop")
       
   335 
       
   336         QString inputString = (mGetInkeyQuery->textValue()).toString();
       
   337         TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetInkeyQuery \
       
   338            inputString=%s", inputString.utf16())
       
   339         aContent = inputString;
       
   340         delete val;
       
   341         TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetInkeyQuery \
       
   342                  aContent=%s", aContent.utf16())
       
   343         delete mGetInkeyQuery;
       
   344         mGetInkeyQuery = 0;
       
   345     }
       
   346     TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInkeyQuery exit")
       
   347     return mUserRsp;
       
   348 }
       
   349 
       
   350 // ----------------------------------------------------------------------------
       
   351 // showGetYesNoQuery
       
   352 // ----------------------------------------------------------------------------
       
   353 //
       
   354 int SatAppUiProvider::showGetYesNoQuery(
       
   355     const QString &aText,
       
   356     const TSatCharacterSet aCharacterSet,
       
   357     unsigned int &aDuration,
       
   358     const bool aImmediateDigitResponse)
       
   359 {
       
   360     TFLOGSTRING("SATAPP: SatAppUiProvider::showGetYesNoQuery call")
       
   361     resetUserResponse();
       
   362     TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetYesNoQuery duration in=%d",
       
   363             aDuration)
       
   364     unsigned int duration = 60000;
       
   365     if (aDuration) {
       
   366         duration = aDuration * 100;
       
   367     }
       
   368     TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetYesNoQuery duration=%d",
       
   369             duration)
       
   370     if (ESatYesNo == aCharacterSet) {
       
   371         mYesNoPopup = new SatAppGetInkeyNote(aText);
       
   372         TFLOGSTRING("SATAPP: SatAppUiProvider::showGetYesNoQuery normal")
       
   373         composeDialog(mYesNoPopup, duration, ESatDialogGetYesNo);
       
   374     } else if (aImmediateDigitResponse){
       
   375         // user can choose the charactor or digital , and only cancel
       
   376         // key press, then close current dialog
       
   377         mYesNoPopup = new SatAppGetInkeyNote(aText);
       
   378         composeDialog(mYesNoPopup, duration, ESatDialogGetDigitalRsp);
       
   379 
       
   380         TFLOGSTRING("SATAPP: SatAppUiProvider::showGetYesNoQuery immediate")
       
   381         bool ret = connect(mYesNoPopup, SIGNAL(digitalKeyPressed(int)),
       
   382                  this, SLOT(digitalResponse(int)),
       
   383                  Qt::DirectConnection);
       
   384         TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetYesNoQuery:\
       
   385         digitalKeyPressed=%d", ret)
       
   386     }
       
   387     if (mYesNoPopup) {
       
   388         TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetYesNoQuery duration=%d",
       
   389                 aDuration)
       
   390         QTime time;
       
   391         time.start();
       
   392 
       
   393         TFLOGSTRING("SATAPP: SatAppUiProvider::showGetYesNoQuery befor pop")
       
   394         mYesNoPopup->exec();
       
   395         TFLOGSTRING("SATAPP: SatAppUiProvider::showGetYesNoQuery end pop")
       
   396         aDuration = time.elapsed() / 100;
       
   397         TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetYesNoQuery duration out=%d",
       
   398                 aDuration)
       
   399         delete mYesNoPopup;
       
   400         mYesNoPopup = 0;
       
   401     }
       
   402     if (ESatYesNo == aCharacterSet) {
       
   403         mDigitalRsp = mUserRsp;
       
   404         TFLOGSTRING("SATAPP: SatAppUiProvider::showGetYesNoQuery:yes/no rsp")
       
   405     }
       
   406     return  mDigitalRsp;
       
   407 }
       
   408 
       
   409 
       
   410 // ----------------------------------------------------------------------------
       
   411 // showGetInputQuery
       
   412 // ----------------------------------------------------------------------------
       
   413 //
       
   414 TSatAppUserResponse SatAppUiProvider::showGetInputQuery(
       
   415     const QString &heading,
       
   416     QString &content,
       
   417     const TSatCharacterSet characterSet,
       
   418     const int minLength,
       
   419     const int maxLength,
       
   420     const bool aHideInput)
       
   421 {
       
   422     TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInputQuery call")
       
   423     TFLOGSTRING3("SATAPP: SatAppUiProvider::showGetInputQuery \
       
   424                   min %d max %d length", minLength, maxLength)
       
   425     TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetInputQuery in content=%s",
       
   426     content.utf16())
       
   427     resetUserResponse();
       
   428     mMinLength = minLength;
       
   429     // Create a query
       
   430     mGetInputQuery = new HbInputDialog();
       
   431     // Set PromptText
       
   432     mGetInputQuery->setPromptText(heading);
       
   433     // Set ContentText
       
   434     QVariant vContent(content);
       
   435     mGetInputQuery->setTextValue(vContent);
       
   436 
       
   437     // Validation rule, what can be entered
       
   438     HbValidator *val =new HbValidator;
       
   439     QRegExp r;
       
   440     if (ESatDigitOnly == characterSet) {
       
   441         // digit mode, digits only (0 9, *, #, and +);
       
   442         mGetInputQuery->setInputMode(HbInputDialog::IntInput);
       
   443         // Define what digits can be entered
       
   444         r.setPattern("[0123456789*#+]{0,255}"); // define what characters can be entered
       
   445         val->setMasterValidator(new QRegExpValidator(r,0));
       
   446         mGetInputQuery->lineEdit()->setValidator(val);
       
   447     } else {
       
   448         // char mode
       
   449         mGetInputQuery->setInputMode(HbInputDialog::TextInput);
       
   450     }
       
   451 
       
   452     connect(mGetInputQuery->lineEdit(), SIGNAL(textChanged(QString)),
       
   453         this, SLOT(updateQueryAction(QString)));
       
   454     mGetInputQuery->lineEdit()->setMaxLength(maxLength);
       
   455 
       
   456     composeDialog(mGetInputQuery, 60000, ESatDialogGetInput);
       
   457     // Sets the "OK"-action/button
       
   458     if (0 == minLength || content.length() >= minLength) {
       
   459         HbAction* okAction = new HbAction(tr("OK"), mGetInputQuery);
       
   460         bool ret = connect(okAction, SIGNAL(triggered()),
       
   461                             this, SLOT(userPrimaryResponse()));
       
   462         TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetInputQuery \
       
   463         connect okAction: %d", ret)
       
   464         mGetInputQuery->setPrimaryAction(okAction);
       
   465     } else {
       
   466         // Set default primary action is 0
       
   467         mGetInputQuery->setPrimaryAction(0);
       
   468     }
       
   469 
       
   470     if (aHideInput) {
       
   471         mGetInputQuery->lineEdit()->setEchoMode(HbLineEdit::Password);
       
   472         TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInputQuery hide")
       
   473     }
       
   474 
       
   475     TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInputQuery before pop")
       
   476     mGetInputQuery->exec();
       
   477     TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInputQuery end pop")
       
   478 
       
   479     content = (mGetInputQuery->textValue()).toString();
       
   480     TFLOGSTRING2("SATAPP: SatAppUiProvider::showGetInputQuery out content=%s",
       
   481     content.utf16())
       
   482 
       
   483     delete val;
       
   484     delete mGetInputQuery;
       
   485     mGetInputQuery = 0;
       
   486 
       
   487     TFLOGSTRING("SATAPP: SatAppUiProvider::showGetInputQuery exit")
       
   488     return mUserRsp;
       
   489 
       
   490 }
       
   491 
       
   492 // ----------------------------------------------------------------------------
       
   493 // Called when editor field is modified
       
   494 // ----------------------------------------------------------------------------
       
   495 //
       
   496 void SatAppUiProvider::updateQueryAction(QString text)
       
   497 {
       
   498     TFLOGSTRING("SATAPP: SatAppUiProvider::updateQueryAction call")
       
   499     TFLOGSTRING2("SATAPP: SatAppUiProvider::updateQueryAction text=%s", \
       
   500         text.utf16())
       
   501     // Get Input
       
   502     if (mGetInputQuery) {
       
   503         if (text.length() >= mMinLength) {
       
   504             if (!mGetInputQuery->primaryAction()) {
       
   505                 HbAction *okAction = new HbAction(tr("OK"), mGetInputQuery);
       
   506                 bool ret = connect(
       
   507                     okAction, SIGNAL(triggered()),
       
   508                     this, SLOT(userPrimaryResponse()));
       
   509               TFLOGSTRING2("SATAPP: SatAppUiProvider::updateQueryAction \
       
   510               get input connect okAction: %d", ret)
       
   511               mGetInputQuery->setPrimaryAction(okAction);
       
   512             }
       
   513             TFLOGSTRING("SATAPP: SatAppUiProvider::updateQueryAction \
       
   514                 get input  OK")
       
   515         } else {
       
   516             if (mGetInputQuery->primaryAction()) {
       
   517             mGetInputQuery->removeAction(mGetInputQuery->primaryAction());
       
   518             }
       
   519             TFLOGSTRING("SATAPP: SatAppUiProvider::updateQueryAction \
       
   520                 get input no OK Action")
       
   521         }
       
   522     }
       
   523     // Get InKey
       
   524     if (mGetInkeyQuery) {
       
   525         if (!mGetInkeyQuery->primaryAction() && (text.length() == 1)) {
       
   526             HbAction *okAction = new HbAction(tr("OK"), mGetInkeyQuery);
       
   527             bool ret = connect(okAction, SIGNAL(triggered()),
       
   528                 this, SLOT(userPrimaryResponse()));
       
   529             TFLOGSTRING2("SATAPP: SatAppUiProvider::updateQueryAction \
       
   530                 get inkey  connect okAction: %d", ret)
       
   531             mGetInkeyQuery->setPrimaryAction(okAction);
       
   532         TFLOGSTRING("SATAPP: SatAppUiProvider::updateQueryAction \
       
   533             get inkey OK")
       
   534     } else {
       
   535         if (mGetInkeyQuery->primaryAction()) {
       
   536             mGetInkeyQuery->removeAction(mGetInkeyQuery->primaryAction());
       
   537         }
       
   538         TFLOGSTRING("SATAPP: SatAppUiProvider::updateQueryAction \
       
   539             get inkey not OK Action")
       
   540         }
       
   541     }
       
   542 
       
   543     TFLOGSTRING("SATAPP: SatAppUiProvider::updateQueryAction exit")
       
   544 }
       
   545 
       
   546 // ----------------------------------------------------------------------------
       
   547 // showConfirmSendQuery
       
   548 // ----------------------------------------------------------------------------
       
   549 //
       
   550 void SatAppUiProvider::showConfirmSendQuery(
       
   551     const QString &/*aText*/,
       
   552     bool &aActionAccepted)
       
   553 {
       
   554     TFLOGSTRING("SATAPP: SatAppUiProvider::showConfirmSendQuery call")
       
   555     resetUserResponse();
       
   556     mConfirmSendQuery = new HbMessageBox();
       
   557     if(mConfirmSendQuery) {
       
   558         // Sets the "Yes"-action/button
       
   559         mConfirmSendQuery->setText(tr("Allow SIM card to send message?"));
       
   560         composeDialog(mConfirmSendQuery, 0, ESatDialogConfirmSend);
       
   561 
       
   562         TFLOGSTRING("SATAPP: SatAppUiProvider::confirmSend before exec")
       
   563         mConfirmSendQuery->exec();
       
   564         TFLOGSTRING("SATAPP: SatAppUiProvider::confirmSend after exec")
       
   565 
       
   566         delete mConfirmSendQuery;
       
   567         mConfirmSendQuery = 0;
       
   568     }
       
   569     aActionAccepted = (EUserPrimaryResponse == mUserRsp) ? true : false;
       
   570     TFLOGSTRING("SATAPP: SatAppUiProvider::showConfirmSendQuery exit")
       
   571 }
       
   572 
       
   573 // ----------------------------------------------------------------------------
       
   574 // showSmsWaitNote
       
   575 // ----------------------------------------------------------------------------
       
   576 //
       
   577 void SatAppUiProvider::showSmsWaitNote(const QString &aText)
       
   578 {
       
   579     TFLOGSTRING("SATAPP: SatAppUiProvider::showSmsWaitNote")
       
   580 
       
   581     mSmsWaitNote = new HbProgressNote(HbProgressNote::WaitNote);
       
   582     //remove the default cancel softkey
       
   583     mSmsWaitNote->removeAction(mSmsWaitNote->primaryAction());
       
   584     if(aText.isEmpty()) {
       
   585         mSmsWaitNote->setText(hbTrId("txt_sat_sendingtextmessage"));
       
   586     } else {
       
   587         mSmsWaitNote->setText(aText);
       
   588     }
       
   589     mSmsWaitNote->show();
       
   590     // Extend showing sms wait note  timer for test
       
   591     extendNoteShowtime();
       
   592     TFLOGSTRING("SATAPP: SatAppUiProvider::showSmsWaitNote exit")
       
   593  }
       
   594 
       
   595 // ----------------------------------------------------------------------------
       
   596 // showDtmfWaitNote
       
   597 // ----------------------------------------------------------------------------
       
   598 //
       
   599 void SatAppUiProvider::showDtmfWaitNote(
       
   600     TSatUiResponse &aRes,
       
   601     const QString &aText)
       
   602 {
       
   603     TFLOGSTRING("SATAPP: SatAppUiProvider::showDtmfWaitNote call")
       
   604     aRes = ESatSuccess;
       
   605 
       
   606     if (mDtmfWaitNote) {
       
   607         delete mDtmfWaitNote;
       
   608         mDtmfWaitNote = 0;
       
   609     }
       
   610 
       
   611     mDtmfWaitNote = new HbProgressNote(HbProgressNote::WaitNote);
       
   612     //remove the default cancel softkey
       
   613     bool ret = connect(mDtmfWaitNote->primaryAction(), SIGNAL(triggered()),
       
   614                        this, SLOT(cancelDtmfResponse()));
       
   615     TFLOGSTRING2("SATAPP: SatAppUiProvider::showDtmfWaitNote \
       
   616     primaryAction=%d", ret)
       
   617     if(aText.isEmpty()) {
       
   618         mDtmfWaitNote->setText(tr("Sending DTMF"));
       
   619     } else {
       
   620         mDtmfWaitNote->setText(aText);
       
   621     }
       
   622     mDtmfWaitNote->show();
       
   623     // Extend showing sms wait note  timer for test
       
   624     extendNoteShowtime();
       
   625     TFLOGSTRING("SATAPP: SatAppUiProvider::showDtmfWaitNote exit")
       
   626  }
       
   627 
       
   628 // ----------------------------------------------------------------------------
       
   629 //stopShowWaitNote
       
   630 // ----------------------------------------------------------------------------
       
   631 //
       
   632 void SatAppUiProvider::stopShowWaitNote()
       
   633 {
       
   634     TFLOGSTRING("SATAPP: SatAppUiProvider::stopShowWaitNote call")
       
   635     if(mSmsWaitNote) {
       
   636         TFLOGSTRING("SATAPP: SatAppUiProvider::stopShowWaitNote SMS")
       
   637         mSmsWaitNote->cancel();
       
   638     }
       
   639     if(mDtmfWaitNote) {
       
   640         TFLOGSTRING("SATAPP: SatAppUiProvider::mDtmfWaitNote DTMF")
       
   641         mDtmfWaitNote->close();
       
   642         delete mDtmfWaitNote;
       
   643         mDtmfWaitNote = 0;
       
   644     }
       
   645 
       
   646     TFLOGSTRING("SATAPP: SatAppUiProvider::stopShowWaitNote exit")
       
   647 }
       
   648 
       
   649 // ----------------------------------------------------------------------------
       
   650 // showConfirmSetUpCallQUery
       
   651 // ----------------------------------------------------------------------------
       
   652 //
       
   653 void SatAppUiProvider::showConfirmSetUpCallQuery(
       
   654     const QString &aText,
       
   655     const QString &aSimAppName,
       
   656     bool &aActionAccepted)
       
   657 {
       
   658     TFLOGSTRING("SATAPP: SatAppUiProvider::showConfirmSetUpCallQUery call")
       
   659     resetUserResponse();
       
   660 
       
   661     QString alphaId;
       
   662     if (aText.length() == 0){
       
   663         if (aSimAppName.length() > 0){
       
   664             alphaId.append(aSimAppName);
       
   665         } else {
       
   666             alphaId.append(tr("SIM services"));
       
   667         }
       
   668         alphaId.append(tr(" about to call"));
       
   669     }
       
   670 
       
   671     mSetUpCallQuery = new HbMessageBox(HbMessageBox::MessageTypeInformation);
       
   672     if(mSetUpCallQuery) {
       
   673         mSetUpCallQuery->setText(alphaId);
       
   674         composeDialog(mSetUpCallQuery, 0, ESatDialogSetUpCall);
       
   675 
       
   676         TFLOGSTRING("SATAPP: SatAppSetUpCall::showSetUpCallConfirm before exec")
       
   677         mSetUpCallQuery->exec();
       
   678         TFLOGSTRING("SATAPP: SatAppSetUpCall::showSetUpCallConfirm after exec")
       
   679 
       
   680         delete mSetUpCallQuery;
       
   681         mSetUpCallQuery = 0;
       
   682     }
       
   683     aActionAccepted = (EUserPrimaryResponse == mUserRsp) ? true : false;
       
   684     TFLOGSTRING("SATAPP: SatAppUiProvider::showConfirmSetUpCallQUery exit")
       
   685 }
       
   686 
       
   687 // ----------------------------------------------------------------------------
       
   688 // clearScreen
       
   689 // ----------------------------------------------------------------------------
       
   690 //
       
   691 void SatAppUiProvider::clearScreen()
       
   692 {
       
   693     TFLOGSTRING("SATAPP: SatAppUiProvider::clearScreen called")
       
   694     if (mDisplayPopup) {
       
   695         TFLOGSTRING("SATAPP: SatAppUiProvider::clearScreen DisplayText")
       
   696         mDisplayPopup->close();
       
   697     }
       
   698     if (mGetInkeyQuery) {
       
   699         TFLOGSTRING("SATAPP: SatAppUiProvider::clearScreen GetInkey")
       
   700         mGetInkeyQuery->close();
       
   701     }
       
   702     if (mYesNoPopup) {
       
   703         TFLOGSTRING("SATAPP: SatAppUiProvider::clearScreen GetYesNo")
       
   704         mYesNoPopup->close();
       
   705     }
       
   706     if (mGetInputQuery) {
       
   707         TFLOGSTRING("SATAPP: SatAppUiProvider::clearScreen GetInput")
       
   708         mGetInputQuery->close();
       
   709         }
       
   710     if(mConfirmSendQuery) {
       
   711         mConfirmSendQuery->close();
       
   712         TFLOGSTRING("SATAPP: SatAppUiProvider::clearScreen ConfirmSend")
       
   713     }
       
   714     if (mSetUpCallQuery) {
       
   715         mConfirmSendQuery->close();
       
   716     }
       
   717     mUserRsp = EUserClearResponse;
       
   718     TFLOGSTRING("SATAPP: SatAppUiProvider::clearScreen exit")
       
   719 }
       
   720 
       
   721 // ----------------------------------------------------------------------------
       
   722 // closeUi
       
   723 // ----------------------------------------------------------------------------
       
   724 //
       
   725 void SatAppUiProvider::closeUi()
       
   726     {
       
   727     TFLOGSTRING("SATAPP: SatAppUiProvider::closeUi called")
       
   728     clearScreen();
       
   729     mUserRsp = EUserCloseResponse;
       
   730     QCoreApplication::instance()->quit();
       
   731     TFLOGSTRING("SATAPP: SatAppUiProvider::closeUi exit")
       
   732 }
       
   733 
       
   734 // ----------------------------------------------------------------------------
       
   735 // digitalResponse
       
   736 // ----------------------------------------------------------------------------
       
   737 //
       
   738 void SatAppUiProvider::digitalResponse(const int aKey)
       
   739 {
       
   740     TFLOGSTRING("SATAPP: SatAppGetInkey::digitalResponse call")
       
   741     mDigitalRsp = aKey;
       
   742     if (mYesNoPopup){
       
   743         TFLOGSTRING("SATAPP: SatAppUiProvider::digitalResponse Close")
       
   744         mYesNoPopup->close();
       
   745         }
       
   746     TFLOGSTRING("SATAPP: SatAppUiProvider::digitalResponse exit")
       
   747 }
       
   748 
       
   749 // ----------------------------------------------------------------------------
       
   750 // resetUserResponse
       
   751 // ----------------------------------------------------------------------------
       
   752 //
       
   753 void SatAppUiProvider::resetUserResponse()
       
   754 {
       
   755     TFLOGSTRING("SATAPP: SatAppUiProvider::resetUserResponse call")
       
   756     mUserRsp = EUserNoResponse;
       
   757     mDigitalRsp = 0;
       
   758     mMinLength = 0;
       
   759     TFLOGSTRING("SATAPP: SatAppUiProvider::resetUserResponse exit")
       
   760 }
       
   761 
       
   762 // ----------------------------------------------------------------------------
       
   763 // composeDialog
       
   764 // ----------------------------------------------------------------------------
       
   765 //
       
   766 void SatAppUiProvider::composeDialog(
       
   767     HbDialog *dlg, 
       
   768     int aDuration,
       
   769     TSatAppDialogActionType type,
       
   770     bool aModal,
       
   771     HbDialog::DismissPolicy aDismissPolicy)
       
   772 {
       
   773     TFLOGSTRING("SATAPP: SatAppUiProvider::composeDialog call")
       
   774 
       
   775     dlg->setModal(aModal);
       
   776     dlg->setDismissPolicy(aDismissPolicy);
       
   777     if (aDuration){
       
   778         dlg->setTimeout(aDuration);
       
   779     } else {
       
   780         dlg->setTimeout(HbDialog::NoTimeout);
       
   781     }
       
   782 
       
   783     HbAction *primaryAction = 0;
       
   784     HbAction *secondaryAction = 0;
       
   785 
       
   786     if (ESatDialogDisplayText == type){
       
   787         primaryAction = new HbAction(tr("Ok"), dlg);
       
   788         secondaryAction = new HbAction(tr("Back"), dlg);
       
   789         TFLOGSTRING("SATAPP: SatAppUiProvider::composeDialog \
       
   790             ESatDialogDisplayText")
       
   791     } else if (ESatDialogGetInput == type){
       
   792         secondaryAction = new HbAction(tr("Cancel"), dlg);
       
   793         TFLOGSTRING("SATAPP: SatAppUiProvider::composeDialog \
       
   794             ESatDialogGetInput")
       
   795     } else if (ESatDialogGetInkey == type){
       
   796         secondaryAction = new HbAction(tr("Cancel"), dlg);
       
   797         TFLOGSTRING("SATAPP: SatAppUiProvider::composeDialog \
       
   798             ESatDialogGetInkey")
       
   799     } else if (ESatDialogGetYesNo == type){
       
   800         primaryAction = new HbAction(tr("Yes"), dlg);
       
   801         secondaryAction = new HbAction(tr("No"), dlg);
       
   802         TFLOGSTRING("SATAPP: SatAppUiProvider::composeDialog \
       
   803             ESatDialogGetYesNo")
       
   804     } else if (ESatDialogGetDigitalRsp == type){
       
   805         secondaryAction = new HbAction(tr("Cancel"), dlg);
       
   806         TFLOGSTRING("SATAPP: SatAppUiProvider::composeDialog \
       
   807             ESatDialogGetDigitalRsp")
       
   808     } else if (ESatDialogSetUpCall == type){
       
   809         primaryAction = new HbAction(tr("Call"), dlg);
       
   810         secondaryAction = new HbAction(tr("Cancel"), dlg);
       
   811         TFLOGSTRING("SATAPP: SatAppUiProvider::composeDialog \
       
   812             ESatDialogSetUpCall")
       
   813     } else if (ESatDialogConfirmSend == type){
       
   814         primaryAction = new HbAction(tr("Yes"), dlg);
       
   815         secondaryAction = new HbAction(tr("No"), dlg);
       
   816         TFLOGSTRING("SATAPP: SatAppUiProvider::composeDialog \
       
   817             ESatDialogConfirmSend")
       
   818     }
       
   819 
       
   820     if (primaryAction) {
       
   821         bool ret = connect(
       
   822             primaryAction, SIGNAL(triggered()),
       
   823             this, SLOT(userPrimaryResponse()));
       
   824         TFLOGSTRING2("SATAPP: SatAppUiProvider::composeDialog \
       
   825             primaryAction=%d", ret)
       
   826     }
       
   827     dlg->setPrimaryAction(primaryAction);
       
   828 
       
   829     if (secondaryAction) {
       
   830         bool ret = connect(
       
   831             secondaryAction, SIGNAL(triggered()),
       
   832             this, SLOT(userSecondaryResponse()));
       
   833         TFLOGSTRING2("SATAPP: SatAppUiProvider::composeDialog \
       
   834             secondaryAction=%d", ret)
       
   835     }
       
   836     dlg->setSecondaryAction(secondaryAction);
       
   837 
       
   838     TFLOGSTRING("SATAPP: SatAppUiProvider::composeDialog exit")
       
   839 }
       
   840 
       
   841 // ----------------------------------------------------------------------------
       
   842 // docmlLoader
       
   843 // ----------------------------------------------------------------------------
       
   844 //
       
   845 SatAppDocumentLoader *SatAppUiProvider::docmlLoader()
       
   846 {
       
   847     TFLOGSTRING("SATAPP: SatAppUiProvider::docmlLoader call-exit");
       
   848     return mLoader;
       
   849 }
       
   850 
       
   851 // ----------------------------------------------------------------------------
       
   852 // createObject
       
   853 // ----------------------------------------------------------------------------
       
   854 //
       
   855 QObject *SatAppDocumentLoader::createObject(
       
   856     const QString &type,
       
   857     const QString &name)
       
   858 {
       
   859     TFLOGSTRING("SATAPP: SatAppDocumentLoader::createObject")
       
   860     if (type == SatAppView::staticMetaObject.className()) {
       
   861         QObject *object = new SatAppView();
       
   862         TFLOGSTRING2(
       
   863         "SATAPP: SatAppDocumentLoader::createObject %s", name.utf16())
       
   864         object->setObjectName(name);
       
   865         TFLOGSTRING("SATAPP: SatAppDocumentLoader::createObject sat view exit")
       
   866         return object;
       
   867         }
       
   868     TFLOGSTRING("SATAPP: SatAppDocumentLoader::createObject other exit")
       
   869     return HbDocumentLoader::createObject(type, name);
       
   870 }
       
   871 
       
   872 // ----------------------------------------------------------------------------
       
   873 //extendNoteShowtime
       
   874 // ----------------------------------------------------------------------------
       
   875 //
       
   876 void SatAppUiProvider::extendNoteShowtime()
       
   877 {
       
   878     TFLOGSTRING("SatAppUiProvider::extendNoteShowtime")
       
   879     if (mTimer) {
       
   880         delete mTimer;
       
   881         mTimer = 0;
       
   882         TFLOGSTRING("SatAppUiProvider::extendNoteShowtime delete timer")
       
   883     }
       
   884     if (mLoop) {
       
   885         delete mLoop;
       
   886         mLoop = 0;
       
   887         TFLOGSTRING("SatAppUiProvider::extendNoteShowtime delete loop")
       
   888     }
       
   889     QTimer *mTimer = new QTimer(this);
       
   890     mTimer->start(KExtendTimeoutMseconds);
       
   891     bool ret = connect(mTimer, SIGNAL(timeout()), mTimer, SLOT(stop()));
       
   892     TFLOGSTRING2("SATAPP: SatAppUiProvider::extendNoteShowtime connect\
       
   893         mTimer stop: %d", ret)
       
   894 
       
   895     mLoop = new QEventLoop(this);
       
   896     ret = connect(mTimer, SIGNAL(timeout()), mLoop, SLOT(quit()));
       
   897     TFLOGSTRING2("SATAPP: SatAppUiProvider::extendNoteShowtime connect \
       
   898        syn: %d", ret)
       
   899     mLoop->exec(QEventLoop::AllEvents);
       
   900     TFLOGSTRING("SatAppUiProvider::extendNoteShowtime exit")
       
   901 }
       
   902 
       
   903 // ----------------------------------------------------------------------------
       
   904 //cancelDtmfResponse
       
   905 // ----------------------------------------------------------------------------
       
   906 //
       
   907 void SatAppUiProvider::cancelDtmfResponse()
       
   908 {
       
   909     TFLOGSTRING("SatAppUiProvider::cancelDtmfResponse")
       
   910     if (mDtmfWaitNote) {
       
   911         TFLOGSTRING("SatAppUiProvider::cancelDtmfResponse user cancel")
       
   912         if (mTimer) {
       
   913             mTimer->stop();
       
   914             TFLOGSTRING("SatAppUiProvider::cancelDtmfResponse time out")
       
   915         }
       
   916         if (mLoop && mLoop->isRunning()) {
       
   917             mLoop->exit();
       
   918             TFLOGSTRING("SatAppUiProvider::cancelDtmfResponse exit loop")
       
   919         }
       
   920         mDtmfWaitNote->setEnabled(false);
       
   921         mDtmfWaitNote->close();
       
   922         emit userCancelDtmfResponse();
       
   923     }
       
   924     TFLOGSTRING("SatAppUiProvider::cancelDtmfResponse exit")
       
   925 }
       
   926 
       
   927 // End of file