securitydialogs/SecUi/Src/SecQueryUi.cpp
branchRCL_3
changeset 50 03674e5abf46
parent 49 09b1ac925e3f
child 54 94da73d93b58
equal deleted inserted replaced
49:09b1ac925e3f 50:03674e5abf46
     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:  Implementation of RSecQueryUiCli class.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "SecQueryUi.h"                              // CSecQueryUi
       
    19 // #include <SecQueryUidefs.h>                          // SIF UI device dialog parameters
       
    20 #include <hb/hbcore/hbdevicedialogsymbian.h>    // CHbDeviceDialogSymbian
       
    21 #include <hb/hbcore/hbsymbianvariant.h>         // CHbSymbianVariantMap
       
    22 #include <apgicnfl.h>                           // CApaMaskedBitmap
       
    23 #include <securityuisprivatepskeys.h>
       
    24 
       
    25 #include <cphcltemergencycall.h>
       
    26 #include <SCPClient.h>
       
    27 #include "SecUi.h"
       
    28 
       
    29 const TUid KSWInstHelpUid =
       
    30     {
       
    31     0x101F8512
       
    32     }; // TODO
       
    33 
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // CSecQueryUi::NewLC()
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C CSecQueryUi* CSecQueryUi::NewLC()
       
    42     {
       
    43     CSecQueryUi* self = new (ELeave) CSecQueryUi();
       
    44     CleanupStack::PushL(self);
       
    45     self->ConstructL();
       
    46     return self;
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CSecQueryUi::NewL()
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 EXPORT_C CSecQueryUi* CSecQueryUi::NewL()
       
    54     {
       
    55     CSecQueryUi* self = CSecQueryUi::NewLC();
       
    56     CleanupStack::Pop(self);
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CSecQueryUi::~CSecQueryUi()
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CSecQueryUi::~CSecQueryUi()
       
    65     {
       
    66     Cancel();
       
    67     delete iWait;
       
    68     delete iDeviceDialog;
       
    69     delete iVariantMap;
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CSecQueryUi::InstallConfirmationQueryL()
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C TBool CSecQueryUi::InstallConfirmationQueryL(TInt aType,
       
    77         RMobilePhone::TMobilePassword& password)
       
    78 /*
       
    79  const TDesC& aAppName,
       
    80  const TDesC& aIconFile, const TDesC& aAppVersion, TInt aAppSize,
       
    81  const TDesC& aAppDetails ) */
       
    82     {
       
    83     // this is never used. Kept as a reference
       
    84     RDEBUG("This should never be called. Obsolete aType", aType);
       
    85     return KErrAbort;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CSecQueryUi::SecQueryDialog()
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 EXPORT_C TInt CSecQueryUi::SecQueryDialog(const TDesC& aCaption,
       
    93         TDes& aDataText, TInt aMinLength, TInt aMaxLength, TInt aMode)
       
    94     {
       
    95     RDEBUG("aCaption", 0);
       
    96     RDEBUGSTR(aCaption);
       
    97     RDEBUG("aMode", aMode);
       
    98     TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized);
       
    99     TInt err = RProperty::Get(KPSUidSecurityUIs,
       
   100             KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
       
   101     RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery);
       
   102     if (secUiOriginatedQuery == ESecurityUIsSecUIOriginatedUninitialized )	// &&  )
       
   103         {
       
   104         // set only if not set
       
   105         err = RProperty::Set(KPSUidSecurityUIs,
       
   106                 KSecurityUIsSecUIOriginatedQuery,
       
   107                 ESecurityUIsETelAPIOriginated);
       
   108         RDEBUG("setting secUiOriginatedQuery", ESecurityUIsETelAPIOriginated);
       
   109       	}
       
   110 		else if ( secUiOriginatedQuery != ESecurityUIsSecUIOriginated )
       
   111 				{
       
   112         RDEBUG("!!!! warning: secUiOriginatedQuery", secUiOriginatedQuery);
       
   113         // The query is already shown. This is valid for ESecurityUIsSecUIOriginated, and maybe for ESecurityUIsETelAPIOriginated
       
   114         // For ESecurityUIsSystemLockOriginated it means that the "lock" dialog is already present.
       
   115         // Try to dismiss the dialog. Do same as CSecurityHandler::CancelSecCodeQuery
       
   116         TInt aDismissDialog = -1;
       
   117         err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog);
       
   118         // it might happen that the dialog is already dismissing. Well, it won't harm to try again.
       
   119         RDEBUG("aDismissDialog", aDismissDialog);
       
   120         RDEBUG("err", err);
       
   121         RDEBUG("set KSecurityUIsDismissDialog", ESecurityUIsDismissDialogOn);
       
   122         err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn);
       
   123         RDEBUG("err", err);
       
   124         }
       
   125 		RDEBUG("calling ClearParamsAndSetNoteTypeL aMode", aMode);
       
   126     ClearParamsAndSetNoteTypeL(aMode);
       
   127     AddParamL(_L("KSecQueryUiApplicationName"), aCaption);
       
   128 
       
   129     _LIT(KTitle, "title");
       
   130     // _LIT(KTitleValue1, "Enter PIN");
       
   131     AddParamL(KTitle, aCaption);
       
   132     AddParamL(_L("MinLength"), aMinLength);
       
   133     AddParamL(_L("MaxLength"), aMaxLength);
       
   134 
       
   135     switch (aMode & ESecUiBasicTypeMask) {
       
   136     	case ESecUiBasicTypeCheck:
       
   137                              _LIT(KChecboxDialog, "ChecboxDialog");
       
   138                              _LIT(KChecbox, "ChecboxDialog");
       
   139                              AddParamL(KChecboxDialog,KChecbox);
       
   140                              break;
       
   141     	case ESecUiBasicTypeMultiCheck:
       
   142                             _LIT(KMultiChecboxDialog, "MultiChecboxDialog");
       
   143                             _LIT(KMultiChecbox, "MultiChecboxDialog");
       
   144                             AddParamL(KMultiChecboxDialog,KMultiChecbox);
       
   145                             break;
       
   146     	default:
       
   147                             _LIT(KCodeTop, "codeTop");
       
   148                             _LIT(KCodeTopValue, "codeTop");
       
   149                             AddParamL(KCodeTop, KCodeTopValue);
       
   150     }
       
   151 
       
   152     if (aCaption.Find(_L("|")) > 0)
       
   153         {
       
   154         RDEBUG("codeBottom aMode", aMode);
       
   155         _LIT(KCodeBottom, "codeBottom");
       
   156         _LIT(KCodeBottomValue, "codeBottom");
       
   157         AddParamL(KCodeBottom, KCodeBottomValue);
       
   158         }
       
   159     if (aDataText.Length() > 0)
       
   160         {
       
   161         RDEBUG("aDataText", 1);
       
   162         _LIT(KDefaultCode, "DefaultCode");
       
   163         AddParamL(KDefaultCode, aDataText);
       
   164         }
       
   165 
       
   166     RDEBUG("0", 0);
       
   167     DisplayDeviceDialogL();
       
   168     TSecUi::UnInitializeLib();	// the counterpart is at DisplayDeviceDialogL
       
   169     TInt error = WaitUntilDeviceDialogClosed();
       
   170     RDEBUG("error", error);
       
   171     User::LeaveIfError(error);
       
   172     RDEBUG("iPassword", 0);
       
   173 		RDEBUGSTR(iPassword);
       
   174     aDataText.Copy(iPassword);
       
   175 
       
   176     err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
       
   177             ESecurityUIsSecUIOriginatedUninitialized);
       
   178     RDEBUG("clearing secUiOriginatedQuery",
       
   179             ESecurityUIsSecUIOriginatedUninitialized);
       
   180 
       
   181     RDEBUG("iReturnValue", iReturnValue);
       
   182     return iReturnValue;
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // CSecQueryUi::DisplayInformationNoteL()
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C void CSecQueryUi::DisplayInformationNoteL(const TDesC& aText)
       
   190     {
       
   191     // this is never used. Kept as a reference
       
   192     RDEBUG("This should never be called. Obsolete", 0);
       
   193     /*
       
   194      ClearParamsAndSetNoteTypeL( SecQueryUiInformationNote );
       
   195      AddParamL( KNotifDeviceDialogKeyText, aText );
       
   196      AddParamL( KNotifDeviceDialogKeyTimeOut, 0 );
       
   197      iDeviceDialog->Show( KNotifDeviceDialogLiteral, *iVariantMap, this );
       
   198      User::LeaveIfError( WaitUntilDeviceDialogClosed() );
       
   199      */
       
   200     }
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 // CSecQueryUi::DisplayWarningNoteL()
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 EXPORT_C void CSecQueryUi::DisplayWarningNoteL(const TDesC& aText)
       
   207     {
       
   208     }
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // CSecQueryUi::DisplayErrorNoteL()
       
   212 // ---------------------------------------------------------------------------
       
   213 //
       
   214 EXPORT_C void CSecQueryUi::DisplayErrorNoteL(const TDesC& aText)
       
   215     {
       
   216     }
       
   217 
       
   218 // ---------------------------------------------------------------------------
       
   219 // CSecQueryUi::DisplayPermanentNoteL()
       
   220 // ---------------------------------------------------------------------------
       
   221 //
       
   222 EXPORT_C void CSecQueryUi::DisplayPermanentNoteL(const TDesC& aText)
       
   223     {
       
   224     }
       
   225 
       
   226 // ---------------------------------------------------------------------------
       
   227 // CSecQueryUi::ClosePermanentNote()
       
   228 // ---------------------------------------------------------------------------
       
   229 //
       
   230 EXPORT_C void CSecQueryUi::ClosePermanentNote()
       
   231     {
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------------------------
       
   235 // CSecQueryUi::DisplayProgressNoteL()
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 EXPORT_C void CSecQueryUi::DisplayProgressNoteL(const TDesC& aText,
       
   239         TInt aFinalValue)
       
   240     {
       
   241     /*
       
   242      ClearParamsAndSetNoteTypeL( ESecQueryUiProgressNoteType );
       
   243      AddParamL( KSecQueryUiProgressNoteText, aText );
       
   244      AddParamL( KSecQueryUiProgressNoteFinalValue, aFinalValue );
       
   245      DisplayDeviceDialogL();
       
   246      */}
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // CSecQueryUi::UpdateProgressNoteValueL()
       
   250 // ---------------------------------------------------------------------------
       
   251 //
       
   252 EXPORT_C void CSecQueryUi::UpdateProgressNoteValueL(TInt aNewValue)
       
   253     {
       
   254     /*
       
   255      ClearParamsAndSetNoteTypeL( ESecQueryUiProgressNoteType );
       
   256      AddParamL( KSecQueryUiProgressNoteValue, aNewValue );
       
   257      DisplayDeviceDialogL();
       
   258      */}
       
   259 
       
   260 // ---------------------------------------------------------------------------
       
   261 // CSecQueryUi::CloseProgressNoteL()
       
   262 // ---------------------------------------------------------------------------
       
   263 //
       
   264 EXPORT_C void CSecQueryUi::CloseProgressNoteL()
       
   265     {
       
   266     }
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // CSecQueryUi::DisplayWaitNoteL()
       
   270 // ---------------------------------------------------------------------------
       
   271 //
       
   272 EXPORT_C void CSecQueryUi::DisplayWaitNoteL(const TDesC& aText,
       
   273         TRequestStatus& aStatus)
       
   274     {
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CSecQueryUi::CloseWaitNote()
       
   279 // ---------------------------------------------------------------------------
       
   280 //
       
   281 EXPORT_C void CSecQueryUi::CloseWaitNote()
       
   282     {
       
   283     }
       
   284 
       
   285 // ---------------------------------------------------------------------------
       
   286 // CSecQueryUi::LaunchHelpL()
       
   287 // ---------------------------------------------------------------------------
       
   288 //
       
   289 EXPORT_C void CSecQueryUi::LaunchHelpL(const TDesC& aContext,
       
   290         const TUid& aUid)
       
   291     {
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // CSecQueryUi::LaunchHelpL()
       
   296 // ---------------------------------------------------------------------------
       
   297 //
       
   298 EXPORT_C void CSecQueryUi::LaunchHelpL(const TDesC& aContext)
       
   299     {
       
   300     LaunchHelpL(aContext, KSWInstHelpUid);
       
   301     }
       
   302 
       
   303 // ---------------------------------------------------------------------------
       
   304 // CSecQueryUi::DoCancel()
       
   305 // ---------------------------------------------------------------------------
       
   306 //
       
   307 void CSecQueryUi::DoCancel()
       
   308     {
       
   309     RDEBUG("0", 0);
       
   310     if (iWait && iWait->IsStarted() && iWait->CanStopNow())
       
   311         {
       
   312         iCompletionCode = KErrCancel;
       
   313         iWait->AsyncStop();
       
   314         }
       
   315     RDEBUG("0", 0);
       
   316     }
       
   317 
       
   318 // ---------------------------------------------------------------------------
       
   319 // CSecQueryUi::RunL()
       
   320 // ---------------------------------------------------------------------------
       
   321 //
       
   322 void CSecQueryUi::RunL()
       
   323     {
       
   324     RDEBUG("0", 0);
       
   325     if (iWait)
       
   326         {
       
   327         iWait->AsyncStop();
       
   328         }
       
   329     RDEBUG("0", 0);
       
   330     }
       
   331 
       
   332 // ---------------------------------------------------------------------------
       
   333 // CSecQueryUi::DataReceived()
       
   334 // ---------------------------------------------------------------------------
       
   335 //
       
   336 void CSecQueryUi::DataReceived(CHbSymbianVariantMap& aData)
       
   337     {
       
   338     RDEBUG("0", 0);
       
   339     const CHbSymbianVariant* acceptedVariant = aData.Get(_L("accepted")); // KSecQueryUiQueryAccepted
       
   340     RDEBUG("0", 0);
       
   341     if (acceptedVariant)
       
   342         {
       
   343         RDEBUG("0", 0);
       
   344         TInt* acceptedValue = acceptedVariant->Value<TInt> ();
       
   345         RDEBUG("acceptedValue", acceptedValue);
       
   346         RDEBUG("*acceptedValue", *acceptedValue);
       
   347         if (acceptedValue)
       
   348             {
       
   349             iReturnValue = *acceptedValue;
       
   350             }
       
   351         }
       
   352     const CHbSymbianVariant* acceptedVariantTop = aData.Get(_L("codeTop")); // KSecQueryUiQueryAccepted
       
   353     RDEBUG("0", 0);
       
   354     if (acceptedVariantTop)
       
   355         {
       
   356         TPtrC acceptedValueTop = *acceptedVariantTop->Value<TDesC> ();
       
   357         RDEBUG("acceptedValueTop", 0);
       
   358         RDEBUGSTR(acceptedValueTop);
       
   359         iPassword.Copy(acceptedValueTop);
       
   360 
       
   361         if (iReturnValue == KErrCompletion) // the user didn't OK. It was send automatically because validating new lock code through TARM
       
   362             {
       
   363             _LIT(KInvalidNewLockCode, "invalidNewLockCode");
       
   364             _LIT(KInvalidNewLockCode0, "invalidNewLockCode$-1");
       
   365             AddParamL(KInvalidNewLockCode, KInvalidNewLockCode0); // for starter
       
   366             RSCPClient scpClient;
       
   367             TSCPSecCode newCode;
       
   368             newCode.Copy(acceptedValueTop);
       
   369             RDEBUG("scpClient.Connect", 0);
       
   370             if (scpClient.Connect() == KErrNone)
       
   371                 {
       
   372                  RArray<TDevicelockPolicies> aFailedPolicies;
       
   373                  TDevicelockPolicies failedPolicy;
       
   374                  TInt retLockcode = KErrNone;
       
   375                  TInt nPoliciesFailed = 0;
       
   376                  RDEBUG( "scpClient.VerifyNewLockcodeAgainstPolicies", 0 );
       
   377                  retLockcode = scpClient.VerifyNewLockcodeAgainstPolicies( newCode, aFailedPolicies );
       
   378                  RDEBUG( "retLockcode", retLockcode );
       
   379                  nPoliciesFailed = aFailedPolicies.Count();
       
   380                  RDEBUG( "nPoliciesFailed", nPoliciesFailed );
       
   381                  for(TInt i=0; i<nPoliciesFailed; i++)
       
   382 	                 {
       
   383 	                 failedPolicy = aFailedPolicies[i];
       
   384 	                 RDEBUG( "failedPolicy", failedPolicy );
       
   385 	                 TBuf<0x100> KInvalidNewLockCodeX;   KInvalidNewLockCodeX.Zero();    KInvalidNewLockCodeX.Append(_L("invalidNewLockCode"));  KInvalidNewLockCodeX.Append(_L("$"));
       
   386 	                 KInvalidNewLockCodeX.AppendNum(failedPolicy);
       
   387 	                 AddParamL( KInvalidNewLockCode, KInvalidNewLockCodeX );	// it overwrites the previous one
       
   388 	                 }
       
   389                 // TODO this should be able to modify MinLenght, MaxLenght
       
   390                 scpClient.Close();
       
   391                 }
       
   392             RDEBUG("iDeviceDialog->Update", 0);
       
   393             iDeviceDialog->Update(*iVariantMap);
       
   394             } // KErrCompletion
       
   395 
       
   396         if (acceptedValueTop.Length() <= 4) // TODO store aMinLenght and check it here, instead of "4"
       
   397             {
       
   398             RDEBUG("CPhCltEmergencyCall", 0);
       
   399             CPhCltEmergencyCall* emergencyCall = CPhCltEmergencyCall::NewL(
       
   400                     NULL);
       
   401             RDEBUG("PushL", 0);
       
   402             CleanupStack::PushL(emergencyCall);
       
   403             TPhCltEmergencyNumber emNumber;
       
   404 
       
   405             // this relies on the fact that emergency has 3 digits, and password needs at least 4
       
   406             TBool isEmergency(EFalse);
       
   407             RDEBUG("calling IsEmergencyPhoneNumber", 0);
       
   408             TInt error = emergencyCall->IsEmergencyPhoneNumber(
       
   409                     acceptedValueTop, isEmergency);
       
   410             RDEBUG("error", error);
       
   411             RDEBUG("emNumber", 0);
       
   412 
       
   413             RDEBUG("isEmergency", isEmergency);
       
   414 #ifdef __WINS__
       
   415             RDEBUG( "__WINS__ checking", 0 );
       
   416             if(!acceptedValueTop.CompareF(_L("112")) || !acceptedValueTop.CompareF(_L("911")) || !acceptedValueTop.CompareF(_L("555")) )
       
   417                 {
       
   418                 isEmergency = ETrue;
       
   419                 error = KErrNone;
       
   420                 RDEBUG( "__WINS__ isEmergency", isEmergency );
       
   421                 }
       
   422 #endif
       
   423 
       
   424             if (!error) // oddly enough, missing capabilities also gives KErrNone
       
   425                 {
       
   426                 if (iReturnValue == KErrAbort) // the user didn't OK. It was send automatically because short code
       
   427                     {
       
   428                     _LIT(KEmergency, "emergency");
       
   429                     _LIT(KEmergencyValueYes, "emergencyYes");
       
   430                     _LIT(KEmergencyValueNo, "emergencyNo");
       
   431                     if (isEmergency)
       
   432                         {
       
   433                         RDEBUG("KEmergencyValueYes", 1);
       
   434                         AddParamL(KEmergency, KEmergencyValueYes);
       
   435                         }
       
   436                     else
       
   437                         {
       
   438                         RDEBUG("KEmergencyValueNo", 0);
       
   439                         AddParamL(KEmergency, KEmergencyValueNo);
       
   440                         }
       
   441                     iDeviceDialog->Update(*iVariantMap);
       
   442                     }
       
   443                 else if (iReturnValue == KErrNone)
       
   444                     { // user pressed Call and number is valid
       
   445                     if (isEmergency)
       
   446                         {
       
   447                         RDEBUG("DialEmergencyCallL", isEmergency);
       
   448                         emergencyCall->DialEmergencyCallL(emNumber);
       
   449                         iReturnValue = KErrAbort; // this means emergency call
       
   450                         }
       
   451                     }
       
   452                 } // if !error
       
   453             RDEBUG("0", 0);
       
   454             CleanupStack::PopAndDestroy(emergencyCall);
       
   455             } // lenght<3
       
   456         } // acceptedVariantTop
       
   457     RDEBUG("iReturnValue", iReturnValue);
       
   458     }
       
   459 
       
   460 // ---------------------------------------------------------------------------
       
   461 // CSecQueryUi::DeviceDialogClosed()
       
   462 // ---------------------------------------------------------------------------
       
   463 //
       
   464 void CSecQueryUi::DeviceDialogClosed(TInt aCompletionCode)
       
   465     {
       
   466     RDEBUG("aCompletionCode", aCompletionCode);
       
   467     iCompletionCode = aCompletionCode;
       
   468     iIsDisplayingDialog = EFalse;
       
   469 
       
   470     TRequestStatus* status(&iStatus);
       
   471     RDEBUG("0", 0);
       
   472     User::RequestComplete(status, KErrNone);
       
   473     RDEBUG("0", 0);
       
   474     }
       
   475 
       
   476 // ---------------------------------------------------------------------------
       
   477 // CSecQueryUi::CSecQueryUi()
       
   478 // ---------------------------------------------------------------------------
       
   479 //
       
   480 CSecQueryUi::CSecQueryUi() :
       
   481     CActive(CActive::EPriorityStandard)
       
   482     {
       
   483     RDEBUG("0", 0);
       
   484     CActiveScheduler::Add(this);
       
   485     }
       
   486 
       
   487 // ---------------------------------------------------------------------------
       
   488 // CSecQueryUi::ConstructL()
       
   489 // ---------------------------------------------------------------------------
       
   490 //
       
   491 void CSecQueryUi::ConstructL()
       
   492     {
       
   493     RDEBUG("0", 0);
       
   494     iWait = new (ELeave) CActiveSchedulerWait;
       
   495     // iDeviceDialog is allocated later, first call of DisplayDeviceDialogL()
       
   496     }
       
   497 
       
   498 // ---------------------------------------------------------------------------
       
   499 // CSecQueryUi::ClearParamsL()
       
   500 // ---------------------------------------------------------------------------
       
   501 //
       
   502 void CSecQueryUi::ClearParamsL()
       
   503     {
       
   504     RDEBUG("0", 0);
       
   505     if (iVariantMap)
       
   506         {
       
   507         delete iVariantMap;
       
   508         iVariantMap = NULL;
       
   509         }
       
   510     iVariantMap = CHbSymbianVariantMap::NewL();
       
   511     }
       
   512 
       
   513 // ---------------------------------------------------------------------------
       
   514 // CSecQueryUi::ClearParamsAndSetNoteTypeL()
       
   515 // ---------------------------------------------------------------------------
       
   516 //
       
   517 void CSecQueryUi::ClearParamsAndSetNoteTypeL(TInt aType)
       
   518     {
       
   519     RDEBUG("aType", aType);
       
   520     ClearParamsL();
       
   521     AddParamL(_L("type"), aType);
       
   522     }
       
   523 
       
   524 // ---------------------------------------------------------------------------
       
   525 // CSecQueryUi::AddParamL()
       
   526 // ---------------------------------------------------------------------------
       
   527 //
       
   528 void CSecQueryUi::AddParamL(const TDesC& aKey, TInt aValue)
       
   529     {
       
   530     RDEBUG("aValue", aValue);
       
   531     CHbSymbianVariant* variant = NULL;
       
   532     variant = CHbSymbianVariant::NewL(&aValue, CHbSymbianVariant::EInt);
       
   533     iVariantMap->Add(aKey, variant);
       
   534     }
       
   535 
       
   536 // ---------------------------------------------------------------------------
       
   537 // CSecQueryUi::AddParamL()
       
   538 // ---------------------------------------------------------------------------
       
   539 //
       
   540 void CSecQueryUi::AddParamL(const TDesC& aKey, const TDesC& aValue)
       
   541     {
       
   542     RDEBUG("0", 0);
       
   543     CHbSymbianVariant* variant = NULL;
       
   544     variant = CHbSymbianVariant::NewL(&aValue, CHbSymbianVariant::EDes);
       
   545     iVariantMap->Add(aKey, variant);
       
   546     }
       
   547 
       
   548 // ---------------------------------------------------------------------------
       
   549 // CSecQueryUi::DisplayDeviceDialogL()
       
   550 // ---------------------------------------------------------------------------
       
   551 //
       
   552 void CSecQueryUi::DisplayDeviceDialogL()
       
   553     {
       
   554     RDEBUG("0", 0);
       
   555     TInt err = KErrNone;
       
   556     RDEBUG("iIsDisplayingDialog", iIsDisplayingDialog);
       
   557     if (iDeviceDialog && iIsDisplayingDialog)
       
   558         {
       
   559     		RDEBUG("iDeviceDialog", 1);
       
   560         iDeviceDialog->Update(*iVariantMap);
       
   561         }
       
   562     else
       
   563         {
       
   564     		RDEBUG("!iDeviceDialog", 0);
       
   565         if (!iDeviceDialog)
       
   566             {
       
   567             RDEBUG("new iDeviceDialog", 0);
       
   568             iDeviceDialog = CHbDeviceDialogSymbian::NewL();
       
   569             }
       
   570         _LIT(KSecQueryUiDeviceDialog, "com.nokia.secuinotificationdialog/1.0");
       
   571         RDEBUG("Show", 0);
       
   572         err = iDeviceDialog->Show(KSecQueryUiDeviceDialog, *iVariantMap, this);
       
   573         RDEBUG("err", err);
       
   574         TSecUi::InitializeLibL();
       
   575         RDEBUG("iIsDisplayingDialog", iIsDisplayingDialog);
       
   576         iIsDisplayingDialog = ETrue;
       
   577         RDEBUG("iIsDisplayingDialog", iIsDisplayingDialog);
       
   578         }
       
   579     RDEBUG("0", 0);
       
   580     }
       
   581 
       
   582 // ---------------------------------------------------------------------------
       
   583 // CSecQueryUi::WaitUntilDeviceDialogClosed()
       
   584 // ---------------------------------------------------------------------------
       
   585 //
       
   586 TInt CSecQueryUi::WaitUntilDeviceDialogClosed()
       
   587     {
       
   588     RDEBUG("0", 0);
       
   589     iCompletionCode = KErrInUse;
       
   590     iReturnValue = KErrUnknown;
       
   591     if (!IsActive() && iWait && !iWait->IsStarted())
       
   592         {
       
   593         RDEBUG("KRequestPending", KRequestPending);
       
   594         iStatus = KRequestPending;
       
   595         SetActive();
       
   596         RDEBUG("Start", 0);
       
   597         iWait->Start();
       
   598         RDEBUG("Started", 1);
       
   599         }
       
   600     RDEBUG("iCompletionCode", iCompletionCode);
       
   601     return iCompletionCode;
       
   602     }
       
   603