satui/satapp/src/satappcommandhandler.cpp
changeset 12 ae8abd0db65c
child 15 d7fc66ccd6fb
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 
       
    18 #include <QTime>
       
    19 #include "satappcommandhandler.h"
       
    20 #include "tflogger.h"
       
    21 #include "satappcommonconstant.h"
       
    22 #include "satappuiprovider.h"
       
    23 
       
    24 // ----------------------------------------------------------------------------
       
    25 // SatAppCommandHandler::DisplayText
       
    26 // (other items were commented in a header).
       
    27 // ----------------------------------------------------------------------------
       
    28 //
       
    29 SatAppCommandHandler::SatAppCommandHandler(SatAppUiProvider &ui, 
       
    30     QObject *parent) : QObject(parent), mUi(ui)
       
    31 {
       
    32     TFLOGSTRING("SATAPP: SatAppCommandHandler::SatAppCommandHandler call-exit")
       
    33 }
       
    34 
       
    35 // ----------------------------------------------------------------------------
       
    36 // SatAppCommandHandler::~SatAppCommandHandler
       
    37 // (other items were commented in a header).
       
    38 // ----------------------------------------------------------------------------
       
    39 //
       
    40 SatAppCommandHandler::~SatAppCommandHandler()
       
    41 {
       
    42 
       
    43 }
       
    44 
       
    45 // ----------------------------------------------------------------------------
       
    46 // SatAppCommandHandler::setUpMenu
       
    47 // (other items were commented in a header).
       
    48 // ----------------------------------------------------------------------------
       
    49 //
       
    50 void SatAppCommandHandler::setUpMenu(
       
    51     TSatUiResponse &aRes,
       
    52     const QString &aText,
       
    53     const QStringList &aMenuItems,
       
    54     //const CArrayFixFlat<TSatAction>* aMenuItemNextActions,
       
    55     //const HbIcon &aIcon,
       
    56     //const CAknIconArray* aItemIconsArray,
       
    57     const bool aSelfExplanatoryItems,
       
    58     const bool aHelpIsAvailable)
       
    59 {
       
    60     TFLOGSTRING("SATAPP: SatAppCommandHandler::setUpMenu call")
       
    61     mUi.showSetUpMenuView(aRes, aText, aMenuItems, 
       
    62             aSelfExplanatoryItems, aHelpIsAvailable);
       
    63     TFLOGSTRING("SATAPP: SatAppCommandHandler::setUpMenu exit")
       
    64 }
       
    65 
       
    66 // ----------------------------------------------------------------------------
       
    67 // SatAppCommandHandler::selectItem
       
    68 // (other items were commented in a header).
       
    69 // ----------------------------------------------------------------------------
       
    70 //
       
    71 void SatAppCommandHandler::selectItem(
       
    72     TSatUiResponse &aRes,
       
    73     const QString &aText,
       
    74     const QStringList &aMenuItems,
       
    75     //const CArrayFixFlat<TSatAction>* aMenuItemNextActions,
       
    76     const int aDefaultItem,
       
    77     unsigned char &aSelection,
       
    78     //const HbIcon &aIcon,
       
    79     //const CAknIconArray* aItemsIconArray,
       
    80     const bool aSelfExplanatoryItems,
       
    81     const bool aHelpIsAvailable)
       
    82 {
       
    83     TFLOGSTRING("SATAPP: SatAppCommandHandler::selectItem call")
       
    84     mUi.showSelectItemView(aRes, aText, aMenuItems, aDefaultItem, aSelection,
       
    85             aSelfExplanatoryItems, aHelpIsAvailable);
       
    86     TFLOGSTRING("SATAPP: SatAppCommandHandler::selectItem exit")
       
    87 }
       
    88 
       
    89 // ----------------------------------------------------------------------------
       
    90 // SatAppCommandHandler::displayText
       
    91 // (other items were commented in a header).
       
    92 // ----------------------------------------------------------------------------
       
    93 //
       
    94 void SatAppCommandHandler::displayText(TSatUiResponse &aRes,
       
    95                        const QString &aText,
       
    96                        const QString &aSimApplicationName,
       
    97                         //      const HbIcon &aIcon,
       
    98                        bool &/*aRequestedIconDisplayed*/,
       
    99                        const bool aSustainedText,
       
   100                        const int aDuration,
       
   101                        const bool aWaitUserToClear)
       
   102 {
       
   103     TFLOGSTRING("SATAPP: SatAppCommandHandler::displayText call")
       
   104 
       
   105     aRes = ESatSuccess;
       
   106     QString heading;
       
   107     if (!aSimApplicationName.isEmpty()) {
       
   108         heading.append(aSimApplicationName);
       
   109     } else {
       
   110         heading.append(QObject::tr("SAT MESSAGE HEADER"));
       
   111     }
       
   112 
       
   113     // set time
       
   114     int duration(0);
       
   115 
       
   116     if (!aDuration) {
       
   117         TFLOGSTRING(
       
   118         "SATAPP: SatAppCommandHandler::displayText duration not given")
       
   119         duration = KDisplayTxtDefaultduration;
       
   120         if (aWaitUserToClear) {
       
   121             TFLOGSTRING(
       
   122             "SATAPP: SatAppCommandHandler::displayText wait user to clear")
       
   123             duration = KDisplayTxtUserClearTimeout;
       
   124         }
       
   125     } else {
       
   126         // if duration  defined
       
   127         duration = aDuration * 1000;
       
   128     }
       
   129     TFLOGSTRING2(
       
   130     "SATAPP: SatAppCommandHandler::displayText duration: %d", 
       
   131     duration)
       
   132     TSatAppUserResponse rsp = EUserNoResponse;
       
   133     rsp = mUi.showDisplayTextPopup(heading, aText, duration);
       
   134 
       
   135     // If user is not expected to clear message used response is success
       
   136     if (aWaitUserToClear && !aSustainedText) {
       
   137         // User press ok key
       
   138         if (EUserPrimaryResponse == rsp || 
       
   139             EUserClearResponse == rsp){
       
   140             aRes = ESatSuccess;
       
   141             TFLOGSTRING(
       
   142             "SATAPP: SatAppCommandHandler::DisplayText successful response")
       
   143         } else if (EUserSecondaryResponse == rsp) {
       
   144                 // User press back key
       
   145                 aRes = ESatBackwardModeRequestedByUser;
       
   146         } else {
       
   147             TFLOGSTRING(
       
   148             "SATAPP: SatAppCommandHandler::DisplayText no user response")
       
   149             // User did not close the text, closed by the timer or MT call
       
   150             aRes = ESatNoResponseFromUser;
       
   151         }
       
   152     }
       
   153 
       
   154     // request to close by the server
       
   155     if (EUserCloseResponse == rsp) {
       
   156         aRes = ESatSessionTerminatedByUser;
       
   157     }
       
   158 
       
   159     // to do
       
   160     //End key by user ESatSessionTerminatedByUser
       
   161     //rsp = EUserNoResponse;
       
   162     TFLOGSTRING("SATAPP: SatAppCommandHandler::displayText exit")
       
   163 }
       
   164 
       
   165 // ----------------------------------------------------------------------------
       
   166 // SatAppCommandHandler::getInkey
       
   167 // (other items were commented in a header).
       
   168 // ----------------------------------------------------------------------------
       
   169 //
       
   170 void SatAppCommandHandler::getInkey(TSatUiResponse &aRes,
       
   171                                 const QString &aTitleText,
       
   172                                 const TSatCharacterSet aCharacterSet,
       
   173                                 QString &aInputText,
       
   174                                 //const QPixmap* /*aIconBitmapGetInput*/,
       
   175                                 const bool /*aSelfExplanatory*/,
       
   176                                 unsigned int &aDuration)
       
   177 {
       
   178     TFLOGSTRING("SATAPP: SatAppCommandHandler::getInkey")
       
   179     aRes = ESatSuccess;
       
   180     // the timeout expires The timer starts when the text is
       
   181     //displayed on the screen and stops when the TERMINALRESPONSE is sent.
       
   182     QTime time;
       
   183     if (aDuration) {
       
   184         TFLOGSTRING2("SATAPP: SatAppCommandHandler::getInkey\
       
   185         in aDuration: %d", aDuration)
       
   186         time.start();
       
   187     }
       
   188 
       
   189     QString heading;
       
   190     if (aTitleText.isEmpty()) {
       
   191         if (ESatDigitOnly == aCharacterSet) {
       
   192             TFLOGSTRING("SATAPP:SatAppCommandHandler::getInkey: ESatDigitOnly")
       
   193             heading = tr("Enternumber (1 digit 0-9) ");
       
   194         } else {
       
   195             // ESatCharSmsDefaultAlphabet or ESatCharUcs2Alphabet
       
   196             TFLOGSTRING("SatAppCommandHandler::getInkey others")
       
   197             heading = tr("Enter character ");
       
   198         }
       
   199      } else {
       
   200          heading = aTitleText;
       
   201          TFLOGSTRING("SatAppCommandHandler::getInkey: Using aTitleText")
       
   202      }
       
   203    //Duration will be implemented in GetInkey proactive command
       
   204     TSatAppUserResponse rsp = EUserNoResponse;
       
   205     rsp = mUi.showGetInkeyQuery(heading, aInputText, aCharacterSet, aDuration);
       
   206 
       
   207     if (aDuration) {
       
   208         aDuration = time.elapsed() / 100;
       
   209         TFLOGSTRING2("SATAPP: SatAppCommandHandler::getInkey\
       
   210                 return for server aDuration: %d", aDuration)
       
   211     }
       
   212     // User press OK key
       
   213     if (EUserPrimaryResponse == rsp) {
       
   214         aRes = ESatSuccess;
       
   215         TFLOGSTRING("SATAPP: SatAppCommandHandler::getInkey successful response")
       
   216     } else if (EUserSecondaryResponse == rsp)
       
   217         {
       
   218         // User press back key
       
   219         aRes = ESatBackwardModeRequestedByUser;
       
   220     } else {
       
   221         TFLOGSTRING("SATAPP: SatAppCommandHandler::getInkey no user response")
       
   222         // User did not close the text, closed by the timer or MT call
       
   223         aRes = ESatNoResponseFromUser;
       
   224     }
       
   225 
       
   226     TFLOGSTRING("SATAPP: SatAppCommandHandler::getInkey exit")
       
   227 }
       
   228 
       
   229 // ----------------------------------------------------------------------------
       
   230 // SatAppCommandHandler::getYesNo
       
   231 // (other items were commented in a header).
       
   232 // ----------------------------------------------------------------------------
       
   233 //
       
   234 void SatAppCommandHandler::getYesNo(
       
   235         TSatUiResponse &aRes,
       
   236         const QString &aText,
       
   237         const TSatCharacterSet aCharacterSet,
       
   238         unsigned int &aInkey,
       
   239         //const TSatIconId &aIconId,
       
   240         const bool &/*aSelfExplanatory*/,
       
   241         unsigned int &aDuration,
       
   242         const bool aImmediateDigitResponse)
       
   243 {
       
   244     TFLOGSTRING("SATAPP: SatAppCommandHandler::getYesNo")
       
   245     TFLOGSTRING2("SATAPP: SatAppCommandHandler::getYesNo: immediate  %d",
       
   246     aImmediateDigitResponse)
       
   247 
       
   248     // the timeout expires The timer starts when the text is
       
   249     //displayed on the screen and stops when the TERMINALRESPONSE is sent.
       
   250     QTime time;
       
   251     if (aDuration) {
       
   252         TFLOGSTRING2("SATAPP: SatAppUiProvider::getYesNo in aDuration: %d",
       
   253         aDuration)
       
   254         time.start();
       
   255     }
       
   256 
       
   257     aRes = ESatSuccess;
       
   258     int rsp = -1;
       
   259     rsp = mUi.showGetYesNoQuery(aText, aCharacterSet, 
       
   260             aDuration, aImmediateDigitResponse);
       
   261     // User press OK key
       
   262     if (EUserPrimaryResponse == rsp) {
       
   263         aRes = ESatSuccess;
       
   264         aInkey = 1;
       
   265         TFLOGSTRING("SATAPP: SatAppCommandHandler::getYesNo successful response")
       
   266     } else if (EUserSecondaryResponse == rsp)
       
   267         {
       
   268         // User press NO key
       
   269         aRes = ESatSuccess;
       
   270         aInkey = 0;
       
   271         TFLOGSTRING("SATAPP: SatAppCommandHandler::getYesNo No request by user")
       
   272     } else if (ESatYesNo != aCharacterSet && !rsp) {
       
   273         aRes = ESatSuccess;
       
   274     }
       
   275     // else if {
       
   276     //    // User press end/back key
       
   277     //    aRes = ESatBackwardModeRequestedByUser;
       
   278     //    aInkey = 1;
       
   279     else {
       
   280         TFLOGSTRING("SATAPP: SatAppCommandHandler::getYesNo no user response")
       
   281         // User did not close the text, closed by the timer or MT call
       
   282         aRes = ESatNoResponseFromUser;
       
   283         aInkey = 0;
       
   284     }
       
   285     TFLOGSTRING("SATAPP: SatAppCommandHandler::getYesNo exit")
       
   286 }
       
   287 
       
   288 // ----------------------------------------------------------------------------
       
   289 // SatAppCommandHandler::getInput
       
   290 // (other items were commented in a header).
       
   291 // ----------------------------------------------------------------------------
       
   292 //
       
   293 void SatAppCommandHandler::getInput(TSatUiResponse &aRes,
       
   294                                 const QString &aTitleText,
       
   295                                 const TSatCharacterSet aCharacterSet,
       
   296                                 QString &aInputText,
       
   297                                 const int aMinLength,
       
   298                                 const int aMaxLength,
       
   299                                 const bool aHideInput,
       
   300                                 //const QPixmap* /*aIconBitmapGetInput*/,
       
   301                                 const bool /*aSelfExplanatory*/,
       
   302                                 unsigned int &/*aDuration*/)
       
   303 {
       
   304     TFLOGSTRING("SATAPP: SatAppCommandHandler::getInput")
       
   305 
       
   306     aRes = ESatNoResponseFromUser;
       
   307     QString heading;
       
   308 
       
   309     if (aTitleText.isEmpty()) {
       
   310         if (ESatDigitOnly == aCharacterSet) {
       
   311             TFLOGSTRING("SATAPP::getInput ESatDigitOnly")
       
   312             heading = tr("Enter:\n(1 digit 0-9)");
       
   313         } else {
       
   314             // ESatCharSmsDefaultAlphabet or ESatCharUcs2Alphabet
       
   315             TFLOGSTRING("SatAppCommandHandler::getInput ESatCharSmsDefaultAlphabet \
       
   316                 or ESatCharUcs2Alphabet")
       
   317                heading = tr("Enter:");
       
   318         }
       
   319     } else {
       
   320         heading.append(aTitleText);
       
   321     }
       
   322 
       
   323     int minLength = 0;
       
   324     int maxLength = 1;
       
   325     if (aMinLength <= KGetInputStringMaxSize && aMinLength > 0){
       
   326          minLength = aMinLength;
       
   327     } else if (aMinLength > KGetInputStringMaxSize){
       
   328         minLength = KGetInputStringMaxSize;
       
   329     }
       
   330     //lint -e{961} else block not needed, maxLength initialized.
       
   331     if (aMaxLength < minLength){
       
   332         maxLength = minLength;
       
   333     } else if (aMaxLength <= KGetInputStringMaxSize && aMaxLength > 1){
       
   334          maxLength = aMaxLength;
       
   335     } else if (aMaxLength > KGetInputStringMaxSize){
       
   336          maxLength = KGetInputStringMaxSize;
       
   337     }
       
   338 
       
   339     QString inputText;
       
   340     if ((aInputText.length() >= minLength)&& (aInputText.length() <= maxLength)){
       
   341         inputText = aInputText;
       
   342     }
       
   343 
       
   344     //Duration will be implemented in GetInkey proactive command
       
   345     TSatAppUserResponse rsp = EUserNoResponse;
       
   346     rsp = mUi.showGetInputQuery( heading, inputText,
       
   347             aCharacterSet, minLength, maxLength, aHideInput);
       
   348 
       
   349     if (EUserPrimaryResponse == rsp) {
       
   350         // User press OK key
       
   351         aRes = ESatSuccess;
       
   352         aInputText = inputText;
       
   353         TFLOGSTRING("SATAPP: SatAppCommandHandler::getInput successful response")
       
   354     } else if (EUserSecondaryResponse == rsp)
       
   355         {
       
   356         // User press back key
       
   357         aRes = ESatBackwardModeRequestedByUser;
       
   358         TFLOGSTRING("SATAPP: SatAppCommandHandler::getInput press back softkey response")
       
   359     } else {
       
   360         // User did not close the getinput query, closed by the timer or MT call
       
   361         aRes = ESatNoResponseFromUser;
       
   362         TFLOGSTRING("SATAPP: GetInputL::getInput no user response")
       
   363     }
       
   364     TFLOGSTRING("SATAPP: SatAppCommandHandler::getInput exit")
       
   365 }
       
   366 
       
   367 // ----------------------------------------------------------------------------
       
   368 // SatAppCommandHandler::confirmSend
       
   369 // (other items were commented in a header).
       
   370 // ----------------------------------------------------------------------------
       
   371 //
       
   372 void SatAppCommandHandler::confirmSend(
       
   373     TSatUiResponse &aRes,
       
   374     const QString &/*aText*/,
       
   375     bool &aActionAccepted,
       
   376     int aType)
       
   377 {
       
   378     TFLOGSTRING2("SATAPP: SatAppCommandHandler::confirmSend call, type=%d", aType)
       
   379     aRes = ESatNoResponseFromUser;
       
   380     QString title;
       
   381     switch (aType) {
       
   382         case ESatUiConfirmSendSms:
       
   383             {
       
   384             title.append(tr("Allow SIM card to send message?"));
       
   385             break;
       
   386             }
       
   387         case ESatUiConfirmSendSs:
       
   388         case ESatUiConfirmSendUssd: //the same string for SS and USSD
       
   389             //title.append(tr("xxxxx"));
       
   390             break;
       
   391         default:
       
   392            aRes = ESatFailure;
       
   393            TFLOGSTRING( "SATAPP: SatAppCommandHandler::confirmSend type unsupport" )  
       
   394            break;
       
   395     }
       
   396     if(ESatFailure != aRes) {
       
   397         mUi.showConfirmSendQuery(title, aActionAccepted);
       
   398         aRes = ESatSuccess;
       
   399         TFLOGSTRING2( "SATAPP: SatAppCommandHandler::confirmSend accept=%d",
       
   400                 aActionAccepted)  
       
   401     }
       
   402     TFLOGSTRING2( "SATAPP: SatAppCommandHandler::confirmSend exit rsp=%d", aRes )
       
   403 }
       
   404 
       
   405 // ----------------------------------------------------------------------------
       
   406 // SatAppCommandHandler::showSmsWaitNote
       
   407 // (other items were commented in a header).
       
   408 // ----------------------------------------------------------------------------
       
   409 //
       
   410 void SatAppCommandHandler::showSmsWaitNote(const QString &aText, 
       
   411     const bool /*aSelfExplanatoryIcon*/)
       
   412 {
       
   413     TFLOGSTRING("SATAPP: SatAppCommandHandler::showSmsWaitNote call")
       
   414     mUi.showSmsWaitNote(aText);
       
   415     TFLOGSTRING("SATAPP: SatAppCommandHandler::showSmsWaitNote exit")
       
   416  }
       
   417 
       
   418 // ----------------------------------------------------------------------------
       
   419 // SatAppCommandHandler::showDtmfWaitNote
       
   420 // (other items were commented in a header).
       
   421 // ----------------------------------------------------------------------------
       
   422 //
       
   423 void SatAppCommandHandler::showDtmfWaitNote(TSatUiResponse &aRes,
       
   424     const QString &aText/*,
       
   425     const bool aSelfExplanatoryIcon*/)
       
   426 {
       
   427     TFLOGSTRING("SATAPP: SatAppCommandHandler::showDtmfWaitNote call")
       
   428     mUi.showDtmfWaitNote(aRes, aText);
       
   429     TFLOGSTRING("SATAPP: SatAppCommandHandler::showDtmfWaitNote exit")
       
   430  }
       
   431 
       
   432 // ----------------------------------------------------------------------------
       
   433 // SatAppCommandHandler::stopShowWaitNote
       
   434 // (other items were commented in a header).
       
   435 // ----------------------------------------------------------------------------
       
   436 //
       
   437 void SatAppCommandHandler::stopShowWaitNote()
       
   438 {
       
   439     TFLOGSTRING("SATAPP: SatAppCommandHandler::stopShowWaitNote call")
       
   440     mUi.stopShowWaitNote();
       
   441     TFLOGSTRING("SATAPP: SatAppCommandHandler::stopShowWaitNote exit")
       
   442 }
       
   443 
       
   444 // ----------------------------------------------------------------------------
       
   445 // SatAppCommandHandler::confirmSetUpCall
       
   446 // (other items were commented in a header).
       
   447 // ----------------------------------------------------------------------------
       
   448 //
       
   449 void SatAppCommandHandler::confirmSetUpCall(
       
   450         const QString &aText,
       
   451         const QString &aSimAppName,
       
   452         bool &aActionAccepted//,
       
   453         //const CFbsBitmap* aIconBitmap,
       
   454         //const TBool aSelfExplanatory
       
   455        )
       
   456 {
       
   457     TFLOGSTRING("SatAppCommandHandler::showSetUpCallConfirm")
       
   458     mUi.showConfirmSetUpCallQuery(aText, aSimAppName, aActionAccepted);
       
   459     TFLOGSTRING("SatAppCommandHandler::showSetUpCallConfirm exit")
       
   460 }
       
   461 
       
   462 //End of file