wlansecuritysettings/wlaneapsettingsui/EapMschapv2/NotifierUi/src/MsChapv2NotifDlgPlugin.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2009 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 the License "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 MsChapv2NotifDlg dialog plugin.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <coemain.h>
       
    22 #include <eikenv.h>
       
    23 #include <bautils.h>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 #include <MsChapv2NotifDlgUi.rsg>
       
    26 
       
    27 #include <e32property.h>		// For RProperty 
       
    28 #include <UikonInternalPSKeys.h> // For KPSUidUikon and KUikGlobalNotesAllowed.
       
    29 
       
    30 #include "MsChapv2NotifDlgPlugin.h"
       
    31 #include "MsChapv2NotifDialog.h"
       
    32 
       
    33 
       
    34 
       
    35 // ================= OTHER EXPORTED FUNCTIONS ==============
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CreateNotifiersL
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 LOCAL_C void CreateNotifiersL( 
       
    42                           CArrayPtrFlat< MEikSrvNotifierBase2 >* aNotifiers )
       
    43     {
       
    44     MEikSrvNotifierBase2 *serNotify;
       
    45     serNotify = CMsChapv2DialogPlugin::NewL();
       
    46     CleanupStack::PushL( serNotify );
       
    47     aNotifiers->AppendL( serNotify );
       
    48     CleanupStack::Pop( serNotify );
       
    49     }
       
    50 
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // NotifierArray
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CArrayPtr< MEikSrvNotifierBase2 >* NotifierArray()
       
    57     {
       
    58     // NotifierArray() can't leave
       
    59     CArrayPtrFlat< MEikSrvNotifierBase2 >* array = 
       
    60                 new CArrayPtrFlat< MEikSrvNotifierBase2 >( KPluginGranularity );
       
    61 
       
    62     if ( array )
       
    63         {
       
    64         TRAPD( err, CreateNotifiersL( array ) );
       
    65         
       
    66         if( err )
       
    67             {
       
    68             TInt count = array->Count();
       
    69 
       
    70             while( count-- )
       
    71                 {
       
    72                 ( *array )[ count ]->Release();
       
    73                 }
       
    74 
       
    75             delete array;
       
    76             array = NULL;
       
    77             }
       
    78         }
       
    79 
       
    80     return( array );
       
    81     }
       
    82 
       
    83 
       
    84 //////////////////////////////////////////////////////////////
       
    85 // MsChapv2 dialog plugin
       
    86 /////////////////////////////////////////////////////////////
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CMsChapv2DialogPlugin::CMsChapv2DialogPlugin
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 CMsChapv2DialogPlugin::CMsChapv2DialogPlugin()
       
    93 : iCancelled( EFalse )
       
    94     {
       
    95     iManager = NULL;
       
    96     }
       
    97 
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CMsChapv2DialogPlugin::~CMsChapv2DialogPlugin
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 CMsChapv2DialogPlugin::~CMsChapv2DialogPlugin()
       
   104     {
       
   105     CCoeEnv::Static()->DeleteResourceFile( iResource );
       
   106 
       
   107     if ( !iCancelled )
       
   108         {
       
   109         delete iMSCHAPV2Dialog;
       
   110         }
       
   111     }
       
   112 
       
   113 
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CMsChapv2DialogPlugin::RegisterL
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 CMsChapv2DialogPlugin::TNotifierInfo CMsChapv2DialogPlugin::RegisterL()
       
   120     {
       
   121     iInfo.iUid      = KUidMsChapv2Dialog;
       
   122     iInfo.iPriority = ENotifierPriorityHigh;
       
   123     iInfo.iChannel  = KUidMsChapv2Dialog;
       
   124     return iInfo;
       
   125     }
       
   126 
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CMsChapv2DialogPlugin::NewL
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 CMsChapv2DialogPlugin* CMsChapv2DialogPlugin::NewL()
       
   133     {
       
   134     CMsChapv2DialogPlugin* self = new( ELeave ) CMsChapv2DialogPlugin();
       
   135     CleanupStack::PushL( self );
       
   136     self->ConstructL();
       
   137     CleanupStack::Pop( self );
       
   138     return self;
       
   139     }
       
   140 
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CMsChapv2DialogPlugin::ConstructL
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 void CMsChapv2DialogPlugin::ConstructL()
       
   147     {
       
   148     TFileName fileName;
       
   149 
       
   150     fileName.Append( KDriveZ );
       
   151     fileName.Append( KDC_RESOURCE_FILES_DIR );   
       
   152     fileName.Append( KResourceFileName );
       
   153 
       
   154     BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), fileName );
       
   155     iResource = CCoeEnv::Static()->AddResourceFileL( fileName );
       
   156     }
       
   157 
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CMsChapv2DialogPlugin::StartL
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 TPtrC8 CMsChapv2DialogPlugin::StartL( const TDesC8& /*aBuffer*/ )
       
   164     {
       
   165     return KNullDesC8().Ptr();
       
   166     }
       
   167 
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CMsChapv2DialogPlugin::StartL
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 void CMsChapv2DialogPlugin::StartL( const TDesC8& aBuffer, 
       
   174                                     TInt aReplySlot, 
       
   175                                     const RMessagePtr2& aMessage )
       
   176     {
       
   177     iCancelled = EFalse;
       
   178     iReplySlot = aReplySlot;
       
   179     iMessage   = aMessage;
       
   180      
       
   181     // This object gets constructed only once where as this gets called many 
       
   182     // times, if user is not answering the query. 
       
   183     // So initialize everything here itself.
       
   184     iMSCHAPV2Dialog = NULL;
       
   185     iDataPtr = NULL;
       
   186     iDataPckgPtr = NULL;
       
   187     
       
   188     // We are about to display the password prompt.
       
   189     // Since this part of the code can be executed during the bootup, check if 
       
   190     // the UI has really started up to display notes/dialogs.
       
   191     TInt notesAllowed = 0;
       
   192     TInt error = RProperty::Get( KPSUidUikon, KUikGlobalNotesAllowed, 
       
   193                                  notesAllowed );
       
   194 
       
   195     // The above call can return error. Don't care the error. What we care is 
       
   196     // if notesAllowed has turned to 1 from 0.
       
   197     if ( notesAllowed )
       
   198         {    
       
   199         iDataPtr = new( ELeave ) TEapMsChapv2UsernamePasswordInfo;
       
   200         iDataPtr->iIsIdentityQuery = ETrue;
       
   201         iDataPtr->iPasswordPromptEnabled = ETrue;    
       
   202         iDataPckgPtr = new( ELeave ) TPckg<TEapMsChapv2UsernamePasswordInfo>(
       
   203                                                                 *iDataPtr );
       
   204         iDataPckgPtr->Copy(aBuffer);    
       
   205     
       
   206         iMSCHAPV2Dialog = CMsChapv2Dialog::NewL( iDataPtr->iUsername, 
       
   207                                                  iDataPtr->iPassword, this );
       
   208         iMSCHAPV2Dialog->ExecuteLD( R_MSCHAPV2NOTIF_USERNAME_PASSWORD_QUERY );
       
   209         }
       
   210 
       
   211     // In case if the notes are not allowed, this message gets completed when
       
   212     // EAPOL time out occurs and a subsequent call to cancel from 
       
   213     // eap_am_type_mschapv2_symbian_c::DoCancel().
       
   214     }
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // CMsChapv2DialogPlugin::UpdateL
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 TPtrC8 CMsChapv2DialogPlugin::UpdateL( const TDesC8& /*aBuffer*/ )
       
   221     {
       
   222     return KNullDesC8().Ptr();
       
   223     }
       
   224 
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // CMsChapv2DialogPlugin::Cancel
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 void CMsChapv2DialogPlugin::Cancel()
       
   231     {
       
   232     if ( !iCancelled )
       
   233         {
       
   234         iCancelled = ETrue;
       
   235         if ( !iMessage.IsNull() )
       
   236             {
       
   237             iMessage.Complete( KErrCancel );
       
   238             }
       
   239 
       
   240         if ( iMSCHAPV2Dialog )
       
   241             {
       
   242             delete iMSCHAPV2Dialog;
       
   243             iMSCHAPV2Dialog = NULL;
       
   244             }
       
   245         }
       
   246 
       
   247     if ( iDataPtr )
       
   248         {
       
   249         delete iDataPtr;
       
   250         iDataPtr = NULL;
       
   251         }
       
   252 
       
   253     if ( iDataPckgPtr )
       
   254         {
       
   255         delete iDataPckgPtr;
       
   256         iDataPckgPtr = NULL;
       
   257         }
       
   258     }
       
   259 
       
   260 
       
   261 // -----------------------------------------------------------------------------
       
   262 // CMsChapv2DialogPlugin::CompleteL
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 void CMsChapv2DialogPlugin::CompleteL( TInt aStatus )
       
   266     { 
       
   267     if ( aStatus == KErrNone && !iMessage.IsNull() )
       
   268         {
       
   269         iMessage.WriteL( iReplySlot, *iDataPckgPtr );
       
   270         }
       
   271     iCancelled = ETrue;
       
   272     if ( !iMessage.IsNull() )
       
   273         {
       
   274         iMessage.Complete( aStatus );
       
   275         }
       
   276 
       
   277     if ( iDataPtr ) 
       
   278         {
       
   279         delete iDataPtr;
       
   280         iDataPtr = NULL;		
       
   281         }
       
   282 
       
   283     if ( iDataPckgPtr )
       
   284         {
       
   285         delete iDataPckgPtr;
       
   286         iDataPckgPtr = NULL;
       
   287         }
       
   288     }
       
   289 
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // CMsChapv2DialogPlugin::Release
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 void CMsChapv2DialogPlugin::Release()
       
   296     {
       
   297     delete this;
       
   298     }
       
   299 
       
   300 
       
   301 // -----------------------------------------------------------------------------
       
   302 // CMsChapv2DialogPlugin::Info
       
   303 // -----------------------------------------------------------------------------
       
   304 //
       
   305 CMsChapv2DialogPlugin::TNotifierInfo CMsChapv2DialogPlugin::Info() const
       
   306     {
       
   307     return iInfo;
       
   308     }
       
   309 
       
   310 
       
   311 // End of File