wim/WimServer/src/WimSecurityDlgHandler.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2003 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:  WIM Security Dialog Handler. Calls WimSecDlgs to query PIN(s)
       
    15 *               from user.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include    "WimSecurityDlgHandler.h"
       
    23 #include    "WimTrace.h"
       
    24 
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CWimSecurityDlgHandler::CWimSecurityDlgHandler
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CWimSecurityDlgHandler::CWimSecurityDlgHandler()
       
    35     {
       
    36     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::CWimSecurityDlgHandler | Begin"));
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CWimSecurityDlgHandler::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CWimSecurityDlgHandler::ConstructL()
       
    45     {
       
    46     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::ConstructL | Begin"));
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CWimSecurityDlgHandler::NewL
       
    51 // Two-phased constructor.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CWimSecurityDlgHandler* CWimSecurityDlgHandler::NewL()
       
    55     {
       
    56     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::NewL | Begin"));
       
    57     CWimSecurityDlgHandler* self = new( ELeave ) CWimSecurityDlgHandler;
       
    58     
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     CleanupStack::Pop( self );
       
    62 
       
    63     return self;
       
    64     }
       
    65 
       
    66     
       
    67 // Destructor
       
    68 CWimSecurityDlgHandler::~CWimSecurityDlgHandler()
       
    69     {
       
    70     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::~CWimSecurityDlgHandler | Begin"));
       
    71     if ( iSecurityDlg )
       
    72         {
       
    73         _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::~CWimSecurityDlgHandler | Release dialog"));
       
    74         iSecurityDlg->Release();
       
    75         _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::~CWimSecurityDlgHandler | Dialog released"));
       
    76         }
       
    77     /*if ( iPKIDlg )
       
    78         {    
       
    79         iPKIDlg->Release();
       
    80         }*/
       
    81     iLibrary.Close();
       
    82     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::~CWimSecurityDlgHandler | Library closed"));
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CWimSecurityDlgHandler::EnablePIN
       
    87 // Shows a security dialog for fetching PIN value from the user for enabling or 
       
    88 // disabling PIN query.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CWimSecurityDlgHandler::EnablePIN(
       
    92     TBool aEnable,
       
    93     TBool aRetry, 
       
    94     const TPINParams& aPINParams, 
       
    95     TPINValue& aPINValue,
       
    96     TRequestStatus& aStatus )
       
    97     {
       
    98     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::GetPINValue | Begin"));
       
    99 
       
   100     // First try to load security dialog
       
   101     TInt loadError = LoadSecurityDialog( aStatus );
       
   102 
       
   103     if ( loadError == KErrNone ) // Dialog loaded succesfully
       
   104         {
       
   105         if ( aEnable )
       
   106             {
       
   107             iSecurityDlg->EnablePIN( aPINParams, aRetry, aPINValue, aStatus );
       
   108             }
       
   109         else
       
   110             {
       
   111             iSecurityDlg->DisablePIN( aPINParams, aRetry, aPINValue, aStatus );
       
   112             }
       
   113         }
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CWimSecurityDlgHandler::ChangePINValue
       
   118 // Shows a security dialog for changing PIN value.
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void CWimSecurityDlgHandler::ChangePINValue(
       
   122     TBool aRetry,
       
   123     const TPINParams& aPINParams, 
       
   124     TPINValue& aOldPINValue,
       
   125     TPINValue& aNewPINValue,
       
   126     TRequestStatus& aStatus )
       
   127     {
       
   128     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::ChangePINValue | Begin"));
       
   129 
       
   130     // First try to load security dialog
       
   131     TInt loadError = LoadSecurityDialog( aStatus );
       
   132 
       
   133     if ( loadError == KErrNone ) // Dialog loaded succesfully
       
   134         {
       
   135         iSecurityDlg->ChangePIN( aPINParams, 
       
   136                                  aRetry, 
       
   137                                  aOldPINValue, 
       
   138                                  aNewPINValue, 
       
   139                                  aStatus );
       
   140         }
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CWimSecurityDlgHandler::ShowPINBlocked
       
   145 // Shows the note about blocked PIN to the user.
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 void CWimSecurityDlgHandler::ShowPINBlocked( 
       
   149     const TPINParams& aPINParams, 
       
   150     TRequestStatus& aStatus )
       
   151     {
       
   152     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::ShowPINBlocked | Begin"));
       
   153     // First try to load security dialog
       
   154     TInt loadError = LoadSecurityDialog( aStatus );
       
   155 
       
   156     if ( loadError == KErrNone ) // Dialog loaded succesfully
       
   157         {
       
   158         iSecurityDlg->PINBlocked( aPINParams, aStatus );
       
   159         }
       
   160     }
       
   161     
       
   162 // -----------------------------------------------------------------------------
       
   163 // CWimSecurityDlgHandler::ShowPINTotalBlocked
       
   164 // Shows the note about total blocked PIN to the user.
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 void CWimSecurityDlgHandler::ShowPINTotalBlocked( 
       
   168     const TPINParams& aPINParams, 
       
   169     TRequestStatus& aStatus )
       
   170     {
       
   171     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::ShowPINTotalBlocked | Begin"));
       
   172     // First try to load security dialog
       
   173     TInt loadError = LoadSecurityDialog( aStatus );
       
   174 
       
   175     if ( loadError == KErrNone ) // Dialog loaded succesfully
       
   176         {
       
   177         iSecurityDlg->TotalBlocked( aPINParams, aStatus );
       
   178         }
       
   179     }    
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CWimSecurityDlgHandler::ShowCardRemoved
       
   183 // Shows the note about card removed to the user.
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 void CWimSecurityDlgHandler::ShowCardRemoved( 
       
   187     TRequestStatus& /*aStatus*/ )
       
   188     {
       
   189     /*_WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::ShowCardRemoved | Begin"));
       
   190     // First try to load security dialog
       
   191     TInt loadError = LoadPKIDialog( aStatus );
       
   192 
       
   193     if ( loadError == KErrNone ) // Dialog loaded succesfully
       
   194         {
       
   195         iPKIDlg->Note( MPKIDialog::ENoSecurityModule, aStatus );
       
   196         }*/
       
   197     return;
       
   198     }
       
   199 
       
   200 
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CWimSecurityDlgHandler::UnblockPIN
       
   204 // Shows a security dialog for fetching PIN and PUK values 
       
   205 // for unblocking blocked PIN.
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 void CWimSecurityDlgHandler::UnblockPIN(
       
   209     TBool aRetry,
       
   210     const TPINParams& aBlockedPINParams,
       
   211     const TPINParams& aUnblockingPINParams, 
       
   212     TPINValue& aUnblockingPINValue, 
       
   213     TPINValue& aNewPINValue,
       
   214     TRequestStatus& aStatus )
       
   215     {
       
   216     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::UnblockPIN | Begin"));
       
   217 
       
   218     // First try to load security dialog
       
   219     TInt loadError = LoadSecurityDialog( aStatus );
       
   220 
       
   221     if ( loadError == KErrNone ) // Dialog loaded succesfully
       
   222         {
       
   223         iSecurityDlg->UnblockPIN( aBlockedPINParams,
       
   224                                   aUnblockingPINParams, 
       
   225                                   aRetry,
       
   226                                   aUnblockingPINValue, 
       
   227                                   aNewPINValue,
       
   228                                   aStatus );
       
   229         }
       
   230     }
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 // CWimSecurityDlgHandler::EnterPIN
       
   234 // Shows a security dialog for asking user to enter PIN code.
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 void CWimSecurityDlgHandler::EnterPIN( 
       
   238     TBool aRetry, 
       
   239     const TPINParams& aPINParams, 
       
   240     TPINValue& aPINValue,
       
   241     TRequestStatus& aStatus )
       
   242     {
       
   243     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::EnterPIN | Begin"));
       
   244 
       
   245     // First try to load security dialog
       
   246     TInt loadError = LoadSecurityDialog( aStatus );
       
   247 
       
   248     if ( loadError == KErrNone ) // Dialog loaded succesfully
       
   249         {
       
   250         _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::EnterPIN | Call EnterPIN"));
       
   251         iSecurityDlg->EnterPIN( aPINParams, aRetry, aPINValue, aStatus );
       
   252         _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::EnterPIN | EnterPIN called"));
       
   253         }
       
   254     }
       
   255 
       
   256 // -----------------------------------------------------------------------------
       
   257 // CWimSecurityDlgHandler::Close()
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 void CWimSecurityDlgHandler::Cancel()
       
   261     {
       
   262 	TRAPD( err, DoLoadSecurityDialogL() );
       
   263 	if ( err == KErrNone ) // Dialog loaded succesfully
       
   264         {
       
   265         _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::EnterPIN | Call EnterPIN"));
       
   266         iSecurityDlg->Cancel();
       
   267         _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::EnterPIN | EnterPIN called"));
       
   268         }
       
   269     }
       
   270 
       
   271 // -----------------------------------------------------------------------------
       
   272 // CWimSecurityDlgHandler::LoadSecurityDialog
       
   273 // Load Security Dialog if not yet done. Completes message with error if load
       
   274 // fails.
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 TInt CWimSecurityDlgHandler::LoadSecurityDialog( TRequestStatus& aStatus )
       
   278     {
       
   279     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::LoadSecurityDialog | Begin"));
       
   280 
       
   281     // Load CTSecDlgs.dll, trap if leave occurred
       
   282     TRAPD( err, DoLoadSecurityDialogL() );
       
   283     
       
   284     if ( err ) // Dll load failed, complete message with error
       
   285         {
       
   286         _WIMTRACE2(_L("WIM | WIMServer | CWimSecurityDlgHandler::LoadSecurityDialog | DoLoadSecurityDialogL()=%d"), err);
       
   287         TRequestStatus* status = &aStatus;
       
   288         User::RequestComplete( status, err );
       
   289         }
       
   290     return err;
       
   291     }
       
   292     
       
   293 // -----------------------------------------------------------------------------
       
   294 // CWimSecurityDlgHandler::LoadPKIDialog
       
   295 // Load PKI Dialog if not yet done. Completes message with error if load
       
   296 // fails.
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 TInt CWimSecurityDlgHandler::LoadPKIDialog( TRequestStatus& /*aStatus*/ )
       
   300     {
       
   301     //Keep it for future usage 
       
   302     
       
   303     /*_WIMTRACE(_L("WIM | WIMServer | CWimPKIDlgHandler::LoadPKIDialog | Begin"));
       
   304 
       
   305     // Load CTSecDlgs.dll, trap if leave occurred
       
   306     TRAPD( err, DoLoadPKIDialogL() );
       
   307     
       
   308     if ( err ) // Dll load failed, complete message with error
       
   309         {
       
   310         _WIMTRACE2(_L("WIM | WIMServer | CWimSecurityDlgHandler::LoadPKIDialog | DoLoadPKIDialogL()=%d"), err);
       
   311         TRequestStatus* status = &aStatus;
       
   312         User::RequestComplete( status, err );
       
   313         }
       
   314     return err;*/
       
   315     return 0;
       
   316     }
       
   317 
       
   318 
       
   319 // -----------------------------------------------------------------------------
       
   320 // CWimSecurityDlgHandler::DoLoadSecurityDialogL
       
   321 // Load security dialog if not yet done
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 void CWimSecurityDlgHandler::DoLoadSecurityDialogL()
       
   325     {
       
   326     _WIMTRACE(_L("WIM | WIMServer | CWimSecurityDlgHandler::DoLoadSecurityDialogL | Begin"));
       
   327 
       
   328     if ( !iSecurityDlg ) // Dialog not loaded yet
       
   329         {
       
   330         // Load security dialog dll
       
   331 
       
   332         iSecurityDlg = SecurityDialogFactory::CreateL();
       
   333 
       
   334         _WIMTRACE2(_L("WIM | WIMServer | CWimSecurityDlgHandler::LoadSecurityDialog | iSecurityDlg=%d"), iSecurityDlg );
       
   335         }
       
   336     }
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 // CWimSecurityDlgHandler::DoLoadPKIDialogL
       
   340 // Load PKI dialog if not yet done
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 void CWimSecurityDlgHandler::DoLoadPKIDialogL()
       
   344     {
       
   345     //iPKIDlg = PKIDialogFactory::CreateNoteL();
       
   346     return;
       
   347     }
       
   348 
       
   349 
       
   350 
       
   351 //  End of File