eapol/eapol_framework/eapol_symbian/am/eap_notifier/src/eap_auth_observer.cpp
changeset 26 9abfd4f00d37
child 34 ad1f037f1ac2
equal deleted inserted replaced
25:e03a3db4489e 26:9abfd4f00d37
       
     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: Dialog observer implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include <hb/hbcore/hbsymbianvariant.h>
       
    19 #include <e32debug.h>
       
    20 #include "eap_auth_notifier.h"
       
    21 #include "eap_auth_observer.h"
       
    22 
       
    23 
       
    24 // ---------------------------------------------------------
       
    25 // CEapAuthObserver* CEapAuthObserver::NewL
       
    26 // ---------------------------------------------------------
       
    27 //
       
    28 CEapAuthObserver* CEapAuthObserver::NewL( 
       
    29     CEapAuthNotifier* aNotifier,
       
    30     CEapAuthNotifier::EEapNotifierType aType )
       
    31     {
       
    32     RDebug::Print(_L("CEapAuthObserver::NewL") );
       
    33     
       
    34     CEapAuthObserver* self = new ( ELeave ) CEapAuthObserver( aNotifier, aType );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------
       
    39 // CEapAuthObserver::CEapAuthObserver
       
    40 // ---------------------------------------------------------
       
    41 //
       
    42 CEapAuthObserver::CEapAuthObserver( 
       
    43     CEapAuthNotifier* aNotifier,
       
    44     CEapAuthNotifier::EEapNotifierType aType ): 
       
    45     iNotifier( aNotifier ),
       
    46     iType(aType)
       
    47     {
       
    48     RDebug::Print(_L("CEapAuthObserver::CEapAuthObserver") );
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------
       
    52 // CEapAuthObserver::~CEapAuthObserver()
       
    53 // ---------------------------------------------------------
       
    54 //
       
    55 CEapAuthObserver::~CEapAuthObserver()
       
    56     {
       
    57     RDebug::Print(_L("CEapAuthObserver::~CEapAuthObserver") );
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------
       
    61 // void CEapAuthObserver::DataReceived
       
    62 // ---------------------------------------------------------
       
    63 //
       
    64 void CEapAuthObserver::DataReceived( CHbSymbianVariantMap& aData )
       
    65 {
       
    66     RDebug::Print(_L("CEapAuthObserver::DataReceived") );
       
    67     
       
    68     if ( iType == CEapAuthNotifier::EEapNotifierTypeLEapUsernamePasswordDialog )
       
    69         {
       
    70         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeLEapUsernamePasswordDialog") );
       
    71         UsernamePasswordDlgDataReceived(aData);
       
    72         }
       
    73     else if ( iType == CEapAuthNotifier::EEapNotifierTypeGTCUsernamePasswordDialog )
       
    74         {
       
    75         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeGTCUsernamePasswordDialog") );
       
    76         UsernamePasswordDlgDataReceived(aData);
       
    77         }
       
    78     else if ( iType == CEapAuthNotifier::EEapNotifierTypePapUsernamePasswordDialog )
       
    79         {
       
    80         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypePapUsernamePasswordDialog") );
       
    81         UsernamePasswordDlgDataReceived(aData);
       
    82         }
       
    83     else if ( iType == CEapAuthNotifier::EEapNotifierTypeEapMsChapV2UsernamePasswordDialog )
       
    84         {
       
    85         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeEapMsChapV2UsernamePasswordDialog") );
       
    86         UsernamePasswordDlgDataReceived(aData);
       
    87         }
       
    88     else if ( iType == CEapAuthNotifier::EEapNotifierTypeMsChapV2UsernamePasswordDialog )
       
    89         {
       
    90         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeMsChapV2UsernamePasswordDialog") );
       
    91         UsernamePasswordDlgDataReceived(aData);
       
    92         }
       
    93     else if ( iType == CEapAuthNotifier::EEapNotifierTypeGTCSecurIDPasscodeQueryUidDialog )
       
    94         {
       
    95         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeGTCSecurIDPasscodeQueryUidDialog") ); 
       
    96         PwdQueryDataReceived(aData);
       
    97         }
       
    98     else if ( iType == CEapAuthNotifier::EEapNotifierTypePapChallengeReplyQueryDialog )
       
    99         {
       
   100         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypePapChallengeReplyQueryDialog") ); 
       
   101         PwdQueryDataReceived(aData);
       
   102         }
       
   103     else if ( iType == CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog )
       
   104         {
       
   105         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeFastPacStorePwQueryDialog") ); 
       
   106         PwdQueryDataReceived(aData);
       
   107         }
       
   108     else if ( iType == CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog )
       
   109         {
       
   110         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeFastCreateMasterkeyQueryDialog") ); 
       
   111         PwdQueryDataReceived(aData);
       
   112         }
       
   113     else if ( iType == CEapAuthNotifier::EEapNotifierTypeFastPacFilePwQueryDialog )
       
   114         {
       
   115         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeFastPacFilePwQueryDialog") ); 
       
   116         PwdQueryDataReceived(aData);
       
   117         }
       
   118     else if ( iType == CEapAuthNotifier::EEapNotifierTypeMsChapV2OldPasswordDialog )
       
   119         {
       
   120         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeMsChapV2OldPasswordDialog") ); 
       
   121         OldPwdQueryDataReceived(aData);
       
   122         }
       
   123     else if ( iType == CEapAuthNotifier::EEapNotifierTypeMsChapV2NewPasswordDialog )
       
   124         {
       
   125         RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeMsChapV2NewPasswordDialog") ); 
       
   126         PwdQueryDataReceived(aData);
       
   127         }
       
   128     
       
   129     TInt status = KErrNone;
       
   130     
       
   131     TRAP_IGNORE( iNotifier->CompleteL( status ));
       
   132 }
       
   133 
       
   134 // ---------------------------------------------------------
       
   135 // void CEapAuthObserver::UsernamePasswordDlgDataReceived
       
   136 // ---------------------------------------------------------
       
   137 //
       
   138 void CEapAuthObserver::UsernamePasswordDlgDataReceived( CHbSymbianVariantMap& aData )
       
   139 {
       
   140     RDebug::Print(_L("CEapAuthObserver::UsernamePasswordDlgDataReceived") ); 
       
   141     
       
   142     _LIT(KUsername, "username");
       
   143     _LIT(KPassword, "password");
       
   144     
       
   145     CEapAuthNotifier::TEapDialogInfo PasswordInfo;
       
   146     TDesC* Data = NULL;
       
   147        
       
   148     PasswordInfo.iIsIdentityQuery = EFalse; 
       
   149     PasswordInfo.iPasswordPromptEnabled = EFalse;
       
   150     
       
   151     const CHbSymbianVariant *my_variant = aData.Get(KUsername); 
       
   152     if ( my_variant != NULL )
       
   153         {
       
   154         ASSERT( my_variant->Type() == CHbSymbianVariant::EDes  );
       
   155     
       
   156         Data = reinterpret_cast<TDesC*>(my_variant->Data());       
       
   157         PasswordInfo.iUsername.Copy( Data->Ptr(), Data->Length() );
       
   158         PasswordInfo.iIsIdentityQuery = ETrue; 
       
   159         RDebug::Print(_L("CEapAuthObserver::DataReceived: PasswordInfo.iUsername = %S\n"), &PasswordInfo.iUsername );
       
   160         }
       
   161     my_variant = aData.Get(KPassword);
       
   162     if ( my_variant != NULL )
       
   163         {
       
   164         ASSERT( my_variant->Type() == CHbSymbianVariant::EDes  );
       
   165     
       
   166         Data = reinterpret_cast<TDesC*>(my_variant->Data());     
       
   167         PasswordInfo.iPassword.Copy( Data->Ptr(), Data->Length() );
       
   168         PasswordInfo.iPasswordPromptEnabled = ETrue;
       
   169         RDebug::Print(_L("CEapAuthObserver::DataReceived: PasswordInfo.iPassword = %S\n"), &PasswordInfo.iPassword );
       
   170         }
       
   171        
       
   172     iNotifier->SetSelectedUnameAndPwd( PasswordInfo );   
       
   173 }
       
   174 
       
   175 // ---------------------------------------------------------
       
   176 // void CEapAuthObserver::OldPwdQueryDataReceived
       
   177 // ---------------------------------------------------------
       
   178 //
       
   179 void CEapAuthObserver::OldPwdQueryDataReceived( CHbSymbianVariantMap& aData )
       
   180 {
       
   181     RDebug::Print(_L("CEapAuthObserver::OldPwdQueryDataReceived") ); 
       
   182     
       
   183     _LIT(KPassword, "password");
       
   184     
       
   185     CEapAuthNotifier::TEapDialogInfo PasswordInfo;
       
   186     TDesC* Data = NULL;
       
   187           
       
   188     const CHbSymbianVariant *my_variant = aData.Get(KPassword); 
       
   189     if ( my_variant != NULL )
       
   190         {
       
   191         ASSERT( my_variant->Type() == CHbSymbianVariant::EDes  );
       
   192     
       
   193         Data = reinterpret_cast<TDesC*>(my_variant->Data());     
       
   194         PasswordInfo.iOldPassword.Copy( Data->Ptr(), Data->Length() );
       
   195 
       
   196         RDebug::Print(_L("CEapAuthObserver::OldPwdQueryDataReceived: PasswordInfo.iOldPassword = %S\n"), &PasswordInfo.iOldPassword );
       
   197         }
       
   198        
       
   199     iNotifier->SetSelectedOldPassword( PasswordInfo );   
       
   200 }
       
   201 
       
   202 // ---------------------------------------------------------
       
   203 // void CEapAuthObserver::PwdQueryDataReceived
       
   204 // ---------------------------------------------------------
       
   205 //
       
   206 void CEapAuthObserver::PwdQueryDataReceived( CHbSymbianVariantMap& aData )
       
   207 {
       
   208     RDebug::Print(_L("CEapAuthObserver::PwdQueryDataReceived") ); 
       
   209     
       
   210     _LIT(KPassword, "password");
       
   211     
       
   212     CEapAuthNotifier::TEapDialogInfo PasswordInfo;
       
   213     TDesC* Data = NULL;
       
   214            
       
   215     const CHbSymbianVariant *my_variant = aData.Get(KPassword); 
       
   216     if ( my_variant != NULL )
       
   217         {
       
   218         ASSERT( my_variant->Type() == CHbSymbianVariant::EDes  );
       
   219     
       
   220         Data = reinterpret_cast<TDesC*>(my_variant->Data());     
       
   221         PasswordInfo.iPassword.Copy( Data->Ptr(), Data->Length() );
       
   222 
       
   223         RDebug::Print(_L("CEapAuthObserver::PwdQueryDataReceived: PasswordInfo.iPassword = %S\n"), &PasswordInfo.iPassword );
       
   224         }
       
   225        
       
   226     iNotifier->SetSelectedPassword( PasswordInfo );   
       
   227 }
       
   228 
       
   229 // ---------------------------------------------------------
       
   230 // void CEapAuthObserver::DeviceDialogClosed
       
   231 // ---------------------------------------------------------
       
   232 //
       
   233 void CEapAuthObserver::DeviceDialogClosed( TInt /*aCompletionCode*/ )
       
   234 {
       
   235     // Dialog was closed, let's complete with that error code
       
   236     RDebug::Print(_L("CEapAuthObserver::DeviceDialogClosed"));
       
   237     
       
   238     TInt status = KErrCancel;
       
   239     
       
   240     if ( iType != CEapAuthNotifier::EEapNotifierTypeFastStartAuthProvWaitNote &&
       
   241          iType != CEapAuthNotifier::EEapNotifierTypeFastStartUnauthProvWaitNote )
       
   242         {
       
   243         TRAP_IGNORE( iNotifier->CompleteL( status ));
       
   244         }
       
   245 }
       
   246 
       
   247