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