connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     1 /*
     1 /*
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 #include "ConnDlgPlugin.h"
    19 #include "ConnDlgPlugin.h"
    20 
    20 #include "AuthenticationDialog.h"
       
    21 #include "ReconnectDialog.h"
       
    22 #include "QosDialog.h"
       
    23 #include "NewIapDialog.h"
       
    24 #include "ActiveIapPlugin.h"
       
    25 
       
    26 #include "ActiveSelectConnectionPlugin.h"
       
    27 #include "CConnDlgPrivateCRKeys.h"
    21 #include <centralrepository.h>
    28 #include <centralrepository.h>
    22 
    29 
    23 #include "ConnectionDialogsUidDefs.h"
    30 #include "ConnectionDialogsUidDefs.h"
    24 #include "ConnectionDialogsLogger.h"
    31 #include "ConnectionDialogsLogger.h"
    25 
    32 
    26 #include <eikenv.h>
    33 #include <eikenv.h>
    27 #include <bautils.h>
    34 #include <bautils.h>
    28 #include <e32property.h> 
    35 #include <e32property.h> 
    29 #include <rmpm.h>
    36 #include <rmpm.h>
    30 #include <cmmanager.h>
    37 #include <startupdomainpskeys.h>
    31 #include <cmdestination.h>
    38 
    32 #include <commsdat.h>
    39 #include <CConnDlgPlugin.rsg>
    33 
       
    34 #include <data_caging_path_literals.hrh>
    40 #include <data_caging_path_literals.hrh>
    35 
    41 #include <vpnapi.h>
    36 
       
    37 // NOTE that the functionality this file is DEPRECATED
       
    38 // None on the methods have UI functionality, the plugins complete the requests
       
    39 // immediately when they are started
       
    40 
    42 
    41 using namespace CommsDat;
    43 using namespace CommsDat;
    42 
    44 
    43 // CONSTANTS
    45 // CONSTANTS
    44 
    46 
       
    47 // RSC file name.
       
    48 _LIT( KResourceFileName, "CConnDlgPlugin.rsc" );
       
    49 
       
    50 // Panic string
       
    51 _LIT( KConnDlgPluginPanic, "CConnDlgPlugin" );
       
    52 
    45 LOCAL_D const TInt KPluginGranularity = 4;
    53 LOCAL_D const TInt KPluginGranularity = 4;
       
    54 
       
    55 #if defined(_DEBUG)
       
    56 _LIT( KErrActiveObjectNull, "iActivePlugin not NULL" );
       
    57 #endif
       
    58 
    46 
    59 
    47 
    60 
    48 LOCAL_C void CreateNotifiersL( 
    61 LOCAL_C void CreateNotifiersL( 
    49                             CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers );
    62                             CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers );
    50 
    63 
    57 // ---------------------------------------------------------
    70 // ---------------------------------------------------------
    58 //
    71 //
    59 
    72 
    60 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
    73 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
    61     {
    74     {
    62     CArrayPtrFlat<MEikSrvNotifierBase2>* array = NULL;
    75     CArrayPtrFlat<MEikSrvNotifierBase2>* array = new (ELeave) 
    63     TRAP_IGNORE( array = new (ELeave) 
    76                     CArrayPtrFlat<MEikSrvNotifierBase2>( KPluginGranularity );
    64                     CArrayPtrFlat<MEikSrvNotifierBase2>( KPluginGranularity ); )
       
    65 
    77 
    66     if ( array )
    78     if ( array )
    67         {
    79         {
    68         TRAPD( err, CreateNotifiersL( array ) );
    80         TRAPD( err, CreateNotifiersL( array ) );
    69         if( err )
    81         if( err )
   147 // ---------------------------------------------------------
   159 // ---------------------------------------------------------
   148 //
   160 //
   149 
   161 
   150 void CConnDlgIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot,
   162 void CConnDlgIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot,
   151                                 const RMessagePtr2& aMessage )
   163                                 const RMessagePtr2& aMessage )
   152     {
   164     {    
       
   165     if ( ScreenSaverOn() || AutolockOn() )
       
   166         {
       
   167         // Screen saver or Autolock is active. Cancel the dialog. 
       
   168         CLOG_WRITE( "CConnDlgAuthenticationPlugin::StartL: Screen saver or Autolock is active." );
       
   169         aMessage.Complete( KErrCancel );
       
   170         return;
       
   171         }
       
   172 
       
   173     iPrefs.Copy( (TPtrC8) aBuffer );
   153 
   174 
   154     iCancelled = EFalse;
   175     iCancelled = EFalse;
   155     iReplySlot = aReplySlot;
   176     iReplySlot = aReplySlot;
   156     iMessage = aMessage;
   177     iMessage = aMessage;
   157     
   178     
   158     // The UI is deprectad, complete the request and return the best available iap
   179     // Check if there is a suitable active connection
   159     RCmManager cmManager;
   180     TInt iap( 0 );
   160     cmManager.OpenL();     
   181     TInt bearer( ECommDbBearerWLAN ); // User conn. is always WLAN in 9.1
   161     CleanupClosePushL( cmManager ); 
   182                                       
   162     
   183     // Is there active User connection
   163     RArray<TUint32> destinationArray;    
   184     TInt err = GetUserConnection( iap );
   164     cmManager.AllDestinationsL( destinationArray );
   185     
   165     CleanupClosePushL(destinationArray);   
   186     if ( err != KErrNone || iap == 0 )
   166     TInt error = KErrNotFound;
   187         {
   167     
   188         // Is there any active connection
   168     // loop the destinations and find the internet snap
   189     	err = GetActiveConnection( iap, bearer );
   169     for (TInt i = 0; i < destinationArray.Count(); ++i)
   190         }
   170         {   
   191 
   171         RCmDestination destination = cmManager.DestinationL( destinationArray[i] );
   192     if ( ( err == KErrNone ) && 
   172         CleanupClosePushL(destination);
   193          ( iap != 0 )        &&  
   173         TUint32 purposeMetaData = destination.MetadataL( CMManager::ESnapMetadataPurpose );
   194          ( iPrefs().iBearerSet & bearer ) )
   174         
   195         {
   175         // If the internet snap was found, check out the IAPs
   196     	// a suitable connection is already active
   176         if ( CMManager::ESnapPurposeInternet ==  purposeMetaData )
   197     	iIAP = iap;
   177             {
   198     	CompleteL( KErrNone );
   178             RMPM mpm;
   199         }
   179             User::LeaveIfError(mpm.Connect());
   200     else
   180             TMpmSnapBuffer buffer;
   201         {
   181             buffer.Reset();
   202         // display a dialog
   182             User::LeaveIfError( mpm.SortSNAP( destination.Id(), buffer )); 
   203         __ASSERT_DEBUG( !iActivePlugin, 
   183             mpm.Close();
   204                     User::Panic( KErrActiveObjectNull, KErrNone ) );
   184             // if there are iaps in the list, return the first
   205     
   185             // if there are none, return an error
   206         iActivePlugin = CActiveCConnDlgIapPlugin::NewL( this, iPrefs() );
   186             if ( buffer.Count() > 0 )
   207         iActivePlugin->StartSearchIAPsL();	
   187                 {
   208         }
   188                 iIAP = buffer.iIapId[0];
   209     }
   189                 error = KErrNone;
   210 
   190                 }
   211 
   191             CleanupStack::PopAndDestroy(); //destination
       
   192             break;
       
   193             }                
       
   194         CleanupStack::PopAndDestroy(); //destination
       
   195         }
       
   196     CleanupStack::PopAndDestroy(); //destinationArray
       
   197     CleanupStack::PopAndDestroy(); //cmManager
       
   198     
       
   199     CompleteL( error );
       
   200     }
       
   201 
   212 
   202 // ---------------------------------------------------------
   213 // ---------------------------------------------------------
   203 // void CConnDlgIapPlugin::Cancel()
   214 // void CConnDlgIapPlugin::Cancel()
   204 // ---------------------------------------------------------
   215 // ---------------------------------------------------------
   205 //
   216 //
   206 void CConnDlgIapPlugin::Cancel()
   217 void CConnDlgIapPlugin::Cancel()
   207     { 
   218     {
       
   219     delete iActivePlugin;
       
   220     iActivePlugin = NULL;
       
   221     
   208     if ( !iCancelled )
   222     if ( !iCancelled )
   209         {
   223         {
   210         iCancelled = ETrue;
   224         iCancelled = ETrue;
   211         if ( !iMessage.IsNull() )
   225         if ( !iMessage.IsNull() )
   212             {
   226             {
   245 // ---------------------------------------------------------
   259 // ---------------------------------------------------------
   246 // CConnDlgIapPlugin* CConnDlgIapPlugin::NewL()
   260 // CConnDlgIapPlugin* CConnDlgIapPlugin::NewL()
   247 // ---------------------------------------------------------
   261 // ---------------------------------------------------------
   248 //
   262 //
   249 CConnDlgIapPlugin* CConnDlgIapPlugin::NewL( 
   263 CConnDlgIapPlugin* CConnDlgIapPlugin::NewL( 
   250                                         const TBool /*aResourceFileResponsible*/ )
   264                                         const TBool aResourceFileResponsible )
   251     {
   265     {
   252     CConnDlgIapPlugin* self = new (ELeave) CConnDlgIapPlugin();
   266     CConnDlgIapPlugin* self = new (ELeave) CConnDlgIapPlugin();
       
   267     CleanupStack::PushL( self );
       
   268     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   269     CleanupStack::Pop();
       
   270 
   253     return self;
   271     return self;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------
       
   275 // CConnDlgIapPlugin::SetPreferredIapIdL
       
   276 // ---------------------------------------------------------
       
   277 //    
       
   278 void CConnDlgIapPlugin::SetPreferredIapIdL( TUint32 aIAPId )
       
   279     {
       
   280     CLOG_ENTERFN( "CConnDlgIapPlugin::SetPreferredIapIdL " );
       
   281     
       
   282     iIAP = aIAPId;
       
   283         
       
   284     CLOG_LEAVEFN( "CConnDlgIapPlugin::SetPreferredIapIdL " );
       
   285     }
       
   286     
       
   287     
       
   288 // ---------------------------------------------------------
       
   289 // CConnDlgIapPlugin::GetActiveConnection
       
   290 // ---------------------------------------------------------
       
   291 //    
       
   292 TInt CConnDlgIapPlugin::GetActiveConnection( TInt& aIapId, 
       
   293                                              TInt& aBearer )
       
   294     {
       
   295     aIapId  = 0;
       
   296     aBearer = 0;
       
   297     
       
   298     TInt err = RProperty::Get( KMPMActiveConnectionCategory, 
       
   299                                KMPMPSKeyActiveConnectionIap, 
       
   300                                aIapId );
       
   301                                
       
   302     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionIap : %d" ), aIapId );                           
       
   303     CLOG_WRITEF( _L( "err : %d" ), err );                           
       
   304                                
       
   305     if ( err == KErrNone )
       
   306         {
       
   307     	err = RProperty::Get( KMPMActiveConnectionCategory, 
       
   308                               KMPMPSKeyActiveConnectionBearer, 
       
   309                               aBearer );
       
   310         }
       
   311         
       
   312     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionBearer : %d" ), aBearer );                           
       
   313     CLOG_WRITEF( _L( "err : %d" ), err );
       
   314     CLOG_WRITEF( _L( "iPrefs().iBearerSet : %d" ), iPrefs().iBearerSet );
       
   315     
       
   316     return err;
       
   317     }
       
   318     
       
   319     
       
   320 // ---------------------------------------------------------
       
   321 // CConnDlgIapPlugin::GetUserConnection
       
   322 // ---------------------------------------------------------
       
   323 //    
       
   324 TInt CConnDlgIapPlugin::GetUserConnection( TInt& aIapId )
       
   325     {
       
   326     aIapId  = 0;
       
   327     
       
   328     TInt err = RProperty::Get( KMPMUserConnectionCategory, 
       
   329                                KMPMPSKeyUserConnectionIap, 
       
   330                                aIapId );
       
   331                 
       
   332     CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionIap : %d" ), aIapId );                           
       
   333     CLOG_WRITEF( _L( "err : %d" ), err );                            
       
   334         
       
   335     return err;    
   254     }
   336     }
   255             
   337             
   256 
   338 
   257 // ---------------------------------------------------------
   339 // ---------------------------------------------------------
   258 // CConnDlgAuthenticationPlugin::TNotifierInfo
   340 // CConnDlgAuthenticationPlugin::TNotifierInfo
   279                                            TInt aReplySlot,
   361                                            TInt aReplySlot,
   280                                            const RMessagePtr2& aMessage )
   362                                            const RMessagePtr2& aMessage )
   281     {
   363     {
   282     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::StartL" );
   364     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::StartL" );
   283 
   365 
       
   366     if ( ScreenSaverOn() || AutolockOn() )
       
   367         {
       
   368         // Screen saver or Autolock is active. Cancel the dialog. 
       
   369         CLOG_WRITE( "CConnDlgAuthenticationPlugin::StartL: Screen saver or Autolock is active." );
       
   370         aMessage.Complete( KErrCancel );
       
   371         return;
       
   372         }
       
   373 
       
   374     if ( aBuffer.Length() > iAuthPairBuff.Length() )
       
   375         {
       
   376         CLOG_WRITE( "User::Panic, EConnDlgIllegalRequest" );
       
   377         User::Panic( KConnDlgPluginPanic, EConnDlgIllegalRequest );
       
   378         }
       
   379 
       
   380     iAuthPairBuff.Copy( aBuffer );
       
   381 
   284     iReplySlot = aReplySlot;
   382     iReplySlot = aReplySlot;
   285     iMessage = aMessage;
   383     iMessage = aMessage;
   286     iCancelled = EFalse;
   384     iCancelled = EFalse;
   287 
   385 
   288     // The UI is deprecated, just complete the request
   386     GetAuthenticationL();
   289     CompleteL(KErrNotSupported);
       
   290 
   387 
   291     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::StartL" );
   388     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::StartL" );
   292     }
   389     }
   293 
   390 
   294 
   391 
   306         iCancelled = ETrue;
   403         iCancelled = ETrue;
   307         if ( !iMessage.IsNull() )
   404         if ( !iMessage.IsNull() )
   308             {
   405             {
   309             iMessage.Complete( KErrCancel );
   406             iMessage.Complete( KErrCancel );
   310             }
   407             }
       
   408         delete iDialog;
       
   409         iDialog = NULL;
   311         }
   410         }
   312 
   411 
   313     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::Cancel" );
   412     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::Cancel" );
       
   413     }
       
   414 
       
   415 
       
   416 // ---------------------------------------------------------
       
   417 // void CConnDlgAuthenticationPlugin::GetAuthenticationL()
       
   418 // ---------------------------------------------------------
       
   419 //
       
   420 void CConnDlgAuthenticationPlugin::GetAuthenticationL()
       
   421     {
       
   422     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::GetAuthenticationL" );
       
   423 
       
   424     iDialog = CAuthenticationDialog::NewL( this, iAuthPairBuff().iUsername, 
       
   425                                            iAuthPairBuff().iPassword );
       
   426 
       
   427 
       
   428     iDialog->ExecuteLD( R_CONNDLG_AUTHENTICATION );
       
   429 
       
   430     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::GetAuthenticationL" );
   314     }
   431     }
   315 
   432 
   316 
   433 
   317 // ---------------------------------------------------------
   434 // ---------------------------------------------------------
   318 // void CConnDlgAuthenticationPlugin::CompleteL( TInt aStatus )
   435 // void CConnDlgAuthenticationPlugin::CompleteL( TInt aStatus )
   323     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::CompleteL" );
   440     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::CompleteL" );
   324 
   441 
   325     iCancelled = ETrue;
   442     iCancelled = ETrue;
   326     if ( !iMessage.IsNull() )
   443     if ( !iMessage.IsNull() )
   327         {
   444         {
       
   445         if ( aStatus == KErrNone )
       
   446             {
       
   447             iMessage.WriteL( iReplySlot, iAuthPairBuff );
       
   448             }
       
   449 
   328         iMessage.Complete( aStatus );
   450         iMessage.Complete( aStatus );
   329         }
   451         }
   330     Cancel();
   452     Cancel();
   331 
   453 
   332     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::CompleteL" );
   454     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::CompleteL" );
   336 // ---------------------------------------------------------
   458 // ---------------------------------------------------------
   337 // CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL()
   459 // CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL()
   338 // ---------------------------------------------------------
   460 // ---------------------------------------------------------
   339 //
   461 //
   340 CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL( 
   462 CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL( 
   341                                         const TBool /*aResourceFileResponsible*/ )
   463                                         const TBool aResourceFileResponsible )
   342     {
   464     {
   343     CConnDlgAuthenticationPlugin* self = new (ELeave) 
   465     CConnDlgAuthenticationPlugin* self = new (ELeave) 
   344                                                 CConnDlgAuthenticationPlugin();
   466                                                 CConnDlgAuthenticationPlugin();
       
   467     CleanupStack::PushL( self );
       
   468     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   469     CleanupStack::Pop();
       
   470 
   345     return self;
   471     return self;
   346     }
   472     }
   347 
   473 
   348 
   474 
   349 // ---------------------------------------------------------
   475 // ---------------------------------------------------------
   350 // CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin()
   476 // CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin()
   351 // ---------------------------------------------------------
   477 // ---------------------------------------------------------
   352 //
   478 //
   353 CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin()
   479 CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin()
       
   480 : iAuthPair( TAuthenticationPair() )
   354     {
   481     {
   355     }
   482     }
   356 
   483 
   357 
   484 
   358 // ---------------------------------------------------------
   485 // ---------------------------------------------------------
   378     {
   505     {
   379     iReplySlot = aReplySlot;
   506     iReplySlot = aReplySlot;
   380     iMessage = aMessage;
   507     iMessage = aMessage;
   381     iCancelled = EFalse;
   508     iCancelled = EFalse;
   382 
   509 
   383     CompleteL(KErrNotSupported);
   510     GetReconnectL();
   384     }
   511     }
   385 
   512 
   386 
   513 
   387 // ---------------------------------------------------------
   514 // ---------------------------------------------------------
   388 // void CConnDlgQosPlugin::Cancel()
   515 // void CConnDlgQosPlugin::Cancel()
   395         iCancelled = ETrue;
   522         iCancelled = ETrue;
   396         if ( !iMessage.IsNull() )
   523         if ( !iMessage.IsNull() )
   397             {
   524             {
   398             iMessage.Complete( KErrCancel );
   525             iMessage.Complete( KErrCancel );
   399             }
   526             }
   400         }
   527         delete iDialog;
       
   528         iDialog = NULL;
       
   529         }
       
   530     }
       
   531 
       
   532 
       
   533 // ---------------------------------------------------------
       
   534 // void CConnDlgQosPlugin::GetReconnectL()
       
   535 // ---------------------------------------------------------
       
   536 //
       
   537 void CConnDlgQosPlugin::GetReconnectL()
       
   538     {
       
   539     iDialog = new (ELeave) CQosDialog( this, iBool );
       
   540     iDialog->ExecuteLD( R_CONNDLG_QOS );
   401     }
   541     }
   402 
   542 
   403 
   543 
   404 // ---------------------------------------------------------
   544 // ---------------------------------------------------------
   405 // void CConnDlgQosPlugin::CompleteL( TInt aStatus )
   545 // void CConnDlgQosPlugin::CompleteL( TInt aStatus )
   408 void CConnDlgQosPlugin::CompleteL( TInt aStatus )
   548 void CConnDlgQosPlugin::CompleteL( TInt aStatus )
   409     {
   549     {
   410     iCancelled = ETrue;
   550     iCancelled = ETrue;
   411     if ( !iMessage.IsNull() )
   551     if ( !iMessage.IsNull() )
   412         {
   552         {
       
   553         if ( aStatus == KErrNone )
       
   554             {
       
   555             TRAP_IGNORE( iMessage.WriteL( iReplySlot, TPckg<TBool>( iBool ) ) );
       
   556             }
       
   557 
   413         iMessage.Complete( aStatus );
   558         iMessage.Complete( aStatus );
   414         }
   559         }
   415     Cancel();
   560     Cancel();
   416     }
   561     }
   417 
   562 
   419 // ---------------------------------------------------------
   564 // ---------------------------------------------------------
   420 // CConnDlgQosPlugin* CConnDlgQosPlugin::NewL()
   565 // CConnDlgQosPlugin* CConnDlgQosPlugin::NewL()
   421 // ---------------------------------------------------------
   566 // ---------------------------------------------------------
   422 //
   567 //
   423 CConnDlgQosPlugin* CConnDlgQosPlugin::NewL( 
   568 CConnDlgQosPlugin* CConnDlgQosPlugin::NewL( 
   424                                         const TBool /*aResourceFileResponsible*/ )
   569                                         const TBool aResourceFileResponsible )
   425     {
   570     {
   426     CConnDlgQosPlugin* self = new (ELeave) CConnDlgQosPlugin();
   571     CConnDlgQosPlugin* self = new (ELeave) CConnDlgQosPlugin();
       
   572     CleanupStack::PushL( self );
       
   573     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   574     CleanupStack::Pop();
       
   575 
   427     return self;
   576     return self;
   428     }
   577     }
   429 
   578 
   430 
   579 
   431 // ---------------------------------------------------------
   580 // ---------------------------------------------------------
   452     {
   601     {
   453     iReplySlot = aReplySlot;
   602     iReplySlot = aReplySlot;
   454     iMessage = aMessage;
   603     iMessage = aMessage;
   455     iCancelled = EFalse;
   604     iCancelled = EFalse;
   456 
   605 
   457     // The UI is deprecated, just complete the request
   606     GetReconnectL();
   458     CompleteL(KErrNotSupported);
       
   459     }
   607     }
   460 
   608 
   461 
   609 
   462 // ---------------------------------------------------------
   610 // ---------------------------------------------------------
   463 // void CConnDlgReconnectPlugin::Cancel()
   611 // void CConnDlgReconnectPlugin::Cancel()
   470         iCancelled = ETrue;
   618         iCancelled = ETrue;
   471         if ( !iMessage.IsNull() )
   619         if ( !iMessage.IsNull() )
   472             {
   620             {
   473             iMessage.Complete( KErrCancel );
   621             iMessage.Complete( KErrCancel );
   474             }
   622             }
   475         }
   623         delete iDialog;
       
   624         iDialog = NULL;
       
   625         }
       
   626     }
       
   627 
       
   628 
       
   629 // ---------------------------------------------------------
       
   630 // void CConnDlgReconnectPlugin::GetReconnectL()
       
   631 // ---------------------------------------------------------
       
   632 //
       
   633 void CConnDlgReconnectPlugin::GetReconnectL()
       
   634     {
       
   635     iDialog = new (ELeave) CReconnectDialog( this, iBool );
       
   636     iDialog->ExecuteLD( R_CONNDLG_RECONNECT );
   476     }
   637     }
   477 
   638 
   478 
   639 
   479 // ---------------------------------------------------------
   640 // ---------------------------------------------------------
   480 // void CConnDlgReconnectPlugin::CompleteL( TInt aStatus )
   641 // void CConnDlgReconnectPlugin::CompleteL( TInt aStatus )
   483 void CConnDlgReconnectPlugin::CompleteL( TInt aStatus )
   644 void CConnDlgReconnectPlugin::CompleteL( TInt aStatus )
   484     {
   645     {
   485     iCancelled = ETrue;
   646     iCancelled = ETrue;
   486     if ( !iMessage.IsNull() )
   647     if ( !iMessage.IsNull() )
   487         {
   648         {
       
   649         if ( aStatus == KErrNone )
       
   650             {
       
   651             iMessage.WriteL( iReplySlot, TPckg<TBool>( iBool ) );
       
   652             }
       
   653 
   488         iMessage.Complete( aStatus );
   654         iMessage.Complete( aStatus );
   489         }
   655         }
   490     Cancel();
   656     Cancel();
   491     
   657     
   492     }
   658     }
   495 // ---------------------------------------------------------
   661 // ---------------------------------------------------------
   496 // CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL()
   662 // CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL()
   497 // ---------------------------------------------------------
   663 // ---------------------------------------------------------
   498 //
   664 //
   499 CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL( 
   665 CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL( 
   500                                         const TBool /*aResourceFileResponsible*/ )
   666                                         const TBool aResourceFileResponsible )
   501     {
   667     {
   502     CConnDlgReconnectPlugin* self = new (ELeave) CConnDlgReconnectPlugin();
   668     CConnDlgReconnectPlugin* self = new (ELeave) CConnDlgReconnectPlugin();
       
   669     CleanupStack::PushL( self );
       
   670     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   671     CleanupStack::Pop();
       
   672 
   503     return self;
   673     return self;
   504     }
   674     }
   505 
   675 
   506 
   676 
   507 // ---------------------------------------------------------
   677 // ---------------------------------------------------------
   524 //
   694 //
   525 
   695 
   526 void CConnDlgNewIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot,
   696 void CConnDlgNewIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot,
   527                                    const RMessagePtr2& aMessage )
   697                                    const RMessagePtr2& aMessage )
   528     {
   698     {
       
   699     if ( aBuffer.Length() > iPrefs.Length() )
       
   700         {
       
   701         User::Panic( KConnDlgPluginPanic, EConnDlgIllegalRequest );
       
   702         }
       
   703 
       
   704     iPrefs.Copy( aBuffer );
   529     iReplySlot = aReplySlot;
   705     iReplySlot = aReplySlot;
   530     iMessage = aMessage;
   706     iMessage = aMessage;
   531     iCancelled = EFalse;
   707     iCancelled = EFalse;
   532 
   708 
   533     // This api has been deprecated, just Complete the request
   709     GetNewIapL();
   534     CompleteL(KErrNotSupported);
       
   535     }
   710     }
   536 
   711 
   537 
   712 
   538 // ---------------------------------------------------------
   713 // ---------------------------------------------------------
   539 // void CConnDlgNewIapPlugin::Cancel()
   714 // void CConnDlgNewIapPlugin::Cancel()
   546         iCancelled = ETrue;
   721         iCancelled = ETrue;
   547         if ( !iMessage.IsNull() )
   722         if ( !iMessage.IsNull() )
   548             {
   723             {
   549             iMessage.Complete( KErrCancel );
   724             iMessage.Complete( KErrCancel );
   550             }
   725             }
   551         }
   726         delete iDialog;
       
   727         iDialog = NULL;
       
   728         }
       
   729     }
       
   730 
       
   731 
       
   732 // ---------------------------------------------------------
       
   733 // void CConnDlgNewIapPlugin::GetNewIapL()
       
   734 // ---------------------------------------------------------
       
   735 //
       
   736 void CConnDlgNewIapPlugin::GetNewIapL()
       
   737     {
       
   738     iDialog = new (ELeave) CNewIapDialog( this, iConnect, iPrefs() );
       
   739     iDialog->ExecuteLD( R_CONNDLG_NEW_IAP );
   552     }
   740     }
   553 
   741 
   554 
   742 
   555 // ---------------------------------------------------------
   743 // ---------------------------------------------------------
   556 // void CConnDlgNewIapPlugin::CompleteL( TInt aStatus )
   744 // void CConnDlgNewIapPlugin::CompleteL( TInt aStatus )
   559 void CConnDlgNewIapPlugin::CompleteL( TInt aStatus )
   747 void CConnDlgNewIapPlugin::CompleteL( TInt aStatus )
   560     {
   748     {
   561     iCancelled = ETrue;
   749     iCancelled = ETrue;
   562     if ( !iMessage.IsNull() )
   750     if ( !iMessage.IsNull() )
   563         {
   751         {
       
   752         if ( aStatus == KErrNone )
       
   753             {
       
   754             iMessage.WriteL( iReplySlot, TPckg<TBool>( iConnect ) );
       
   755             }
       
   756 
   564         iMessage.Complete( aStatus );
   757         iMessage.Complete( aStatus );
   565         }
   758         }
   566     Cancel();
   759     Cancel();
   567     }
   760     }
   568 
   761 
   570 // ---------------------------------------------------------
   763 // ---------------------------------------------------------
   571 // CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL()
   764 // CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL()
   572 // ---------------------------------------------------------
   765 // ---------------------------------------------------------
   573 //
   766 //
   574 CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL( 
   767 CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL( 
   575                                         const TBool /*aResourceFileResponsible*/ )
   768                                         const TBool aResourceFileResponsible )
   576     {
   769     {
   577     CConnDlgNewIapPlugin* self = new (ELeave) CConnDlgNewIapPlugin();
   770     CConnDlgNewIapPlugin* self = new (ELeave) CConnDlgNewIapPlugin();
       
   771     CleanupStack::PushL( self );
       
   772     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   773     CleanupStack::Pop();
       
   774 
   578     return self;
   775     return self;
   579     }
   776     }
   580 
   777 
   581     
   778     
   582 // ---------------------------------------------------------
   779 // ---------------------------------------------------------
   598 // ---------------------------------------------------------
   795 // ---------------------------------------------------------
   599 // void CConnDlgSelectConnectionPlugin::StartL
   796 // void CConnDlgSelectConnectionPlugin::StartL
   600 // ---------------------------------------------------------
   797 // ---------------------------------------------------------
   601 //
   798 //
   602 
   799 
   603 void CConnDlgSelectConnectionPlugin::StartL( const TDesC8& /*aBuffer*/, 
   800 void CConnDlgSelectConnectionPlugin::StartL( const TDesC8& aBuffer, 
   604                                              TInt aReplySlot,
   801                                              TInt aReplySlot,
   605                                              const RMessagePtr2& aMessage )
   802                                              const RMessagePtr2& aMessage )
   606     {
   803     {
   607         
   804      CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::StartL" );      	
       
   805     	
       
   806     if ( iActivePlugin )
       
   807         {
       
   808         aMessage.Complete( KErrServerBusy );
       
   809         return;
       
   810         }
       
   811      
       
   812     TInt iStartUpPhaseValue( EStartupUiPhaseUninitialized );
       
   813     RProperty::Get( KPSUidStartup, KPSStartupUiPhase, iStartUpPhaseValue );
       
   814     CLOG_WRITEF( _L( "CConnDlgSelectConnectionPlugin::Phone start up phase: %d" ), 
       
   815     									iStartUpPhaseValue );           
       
   816     // Don't show the dialog if phone boot up isn't complete or screen saver or Autolock is on.
       
   817     if ( iStartUpPhaseValue != EStartupUiPhaseAllDone || ScreenSaverOn() || AutolockOn() )
       
   818         { 
       
   819         CLOG_WRITE( "CConnDlgSelectConnectionPlugin::StartL: Screen saver or Autolock is active or start up phase not completed yet." );
       
   820         aMessage.Complete( KErrCancel );
       
   821         return;
       
   822         }
       
   823 
       
   824     iPrefs.Copy( ( TPtrC8 ) aBuffer );
       
   825 
       
   826     iCancelled = ETrue; // This method could leave before displaying the dialog.
   608     iReplySlot = aReplySlot;
   827     iReplySlot = aReplySlot;
   609     iMessage = aMessage;
   828     iMessage = aMessage;
   610     
   829     
   611     // because the connection dialog is deprecated and removed functionality,
   830     __ASSERT_DEBUG( !iActivePlugin, 
   612     // return the Internet SNAP and complete
   831                      User::Panic( KErrActiveObjectNull, KErrNone ) );
   613     RCmManager cmManager;
   832     
   614     cmManager.OpenL();     
   833     iElementID = iPrefs().iRank;
   615     CleanupClosePushL( cmManager ); 
   834     iActivePlugin = CActiveSelectConnectionPlugin::NewL( this,
   616     
   835                                                          iElementID,
   617     RArray<TUint32> destinationArray;    
   836                                                          iPrefs().iBearerSet );
   618     cmManager.AllDestinationsL( destinationArray );
   837     // Check if there is a suitable active connection
   619     CleanupClosePushL(destinationArray);   
   838     TInt snap( 0 );
   620     bool found = false;
   839     TInt iap( 0 );
   621     
   840     TInt bearer( ECommDbBearerWLAN ); // User conn. is always WLAN in 9.1
   622     // loop the destinations and find the internet snap
   841     
   623     for (TInt i = 0; i < destinationArray.Count() && !found; ++i)
   842     // Is there active User connection
   624         {   
   843     TInt err = GetUserConnection( iap, snap );
   625         RCmDestination destination = cmManager.DestinationL( destinationArray[i] );
   844     
   626         CleanupClosePushL(destination);
   845     if ( ( err != KErrNone ) || ( iap == 0 && snap == 0 ) )
       
   846         {
       
   847         // Is there any active connection
       
   848     	err = GetActiveConnection( iap, snap, bearer );
       
   849         }
       
   850                                       
       
   851     RVpnServ vpn;
       
   852     TInt vpnErr( KErrNone );
       
   853     TInt policyCount( 0 );
       
   854     TBool forceDialogForIntranetUsers( EFalse );
       
   855     
       
   856     vpnErr = vpn.Connect();
       
   857     if ( !vpnErr ) 
       
   858     	  {
       
   859     	  vpnErr = vpn.EnumeratePolicies(policyCount);
       
   860     	  if ( !vpnErr && policyCount > 0 )
       
   861     	  	  {
       
   862     	  	  forceDialogForIntranetUsers = ETrue;
       
   863     	  	  }
       
   864         vpn.Close();
       
   865         }
   627         
   866         
   628         TUint32 purposeMetaData = destination.MetadataL( CMManager::ESnapMetadataPurpose );
   867     if ( !forceDialogForIntranetUsers &&
   629         if ( CMManager::ESnapPurposeInternet ==  purposeMetaData )
   868     	 ( err == KErrNone ) && 
   630             {
   869          ( iap != 0 || snap != 0 ) && 
   631             iElementID = destination.ElementId();
   870          ( iPrefs().iBearerSet & bearer ) &&
   632             found = true;
   871          ( iPrefs().iDirection == 0 ) )     // JavaVM sets iDirection to "1"
   633             }                
   872         {
   634         CleanupStack::PopAndDestroy(); //destination
   873     	// a suitable connection is already active
   635         }
   874     	SetElementIDL( iap, snap );
   636     CleanupStack::PopAndDestroy(); //destinationArray
   875     	CompleteL( KErrNone );
   637     CleanupStack::PopAndDestroy(); //cmManager
   876         }
   638     
   877     else
   639     if (found)
   878         {
   640         {
   879         // display dialog
   641         CompleteL(KErrNone);
   880         iActivePlugin->ShowSelectConnectionL();
   642         } 
   881         iCancelled = EFalse; // Dialog is now up and running
   643     else 
   882         }
   644         {
   883     }
   645         CompleteL(KErrNotFound);
   884 
   646         }
   885 
   647     }
       
   648 
   886 
   649 // ---------------------------------------------------------
   887 // ---------------------------------------------------------
   650 // void CConnDlgSelectConnectionPlugin::Cancel()
   888 // void CConnDlgSelectConnectionPlugin::Cancel()
   651 // ---------------------------------------------------------
   889 // ---------------------------------------------------------
   652 //
   890 //
   653 void CConnDlgSelectConnectionPlugin::Cancel()
   891 void CConnDlgSelectConnectionPlugin::Cancel()
   654     {
   892     {
   655     CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::Cancel" );          
   893     CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::Cancel" );      
       
   894 
       
   895     delete iActivePlugin;
       
   896     CLOG_WRITE( "iActivePlugin deleted" );      
       
   897     iActivePlugin = NULL;
       
   898     CLOG_WRITE( "iActivePlugin NULLed" );      
   656     
   899     
   657     if ( !iCancelled )
   900     if ( !iCancelled )
   658         {
   901         {
   659         CLOG_WRITE( "iCancelled == EFalse" );      
   902         CLOG_WRITE( "iCancelled == EFalse" );      
   660         iCancelled = ETrue;
   903         iCancelled = ETrue;
   699 // ---------------------------------------------------------
   942 // ---------------------------------------------------------
   700 // CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL()
   943 // CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL()
   701 // ---------------------------------------------------------
   944 // ---------------------------------------------------------
   702 //
   945 //
   703 CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL( 
   946 CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL( 
   704                                         const TBool /*aResourceFileResponsible*/ )
   947                                         const TBool aResourceFileResponsible )
   705     {
   948     {
   706     CConnDlgSelectConnectionPlugin* self = 
   949     CConnDlgSelectConnectionPlugin* self = 
   707                             new (ELeave) CConnDlgSelectConnectionPlugin();
   950                             new (ELeave) CConnDlgSelectConnectionPlugin();
       
   951     CleanupStack::PushL( self );
       
   952     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   953     CleanupStack::Pop();
       
   954 
   708     return self;
   955     return self;
   709     }
   956     }
   710     
   957 
       
   958 
       
   959 // ---------------------------------------------------------
       
   960 // CConnDlgSelectConnectionPlugin::SetSelectedIDsL
       
   961 // ---------------------------------------------------------
       
   962 //    
       
   963 void CConnDlgSelectConnectionPlugin::SetElementIDL( TUint32 aIAPId, 
       
   964                                                     TUint32 aDestinationId )
       
   965     {
       
   966     iElementID = iActivePlugin->GetElementIDL( aIAPId, aDestinationId );
       
   967     }
       
   968     
       
   969     
       
   970 // ---------------------------------------------------------
       
   971 // CConnDlgSelectConnectionPlugin::GetUserConnection
       
   972 // ---------------------------------------------------------
       
   973 //    
       
   974 TInt CConnDlgSelectConnectionPlugin::GetUserConnection( TInt& aIapId, 
       
   975                                                         TInt& aSnapId )
       
   976     {
       
   977     aIapId  = 0;
       
   978     aSnapId = 0;
       
   979     
       
   980     TInt err = RProperty::Get( KMPMUserConnectionCategory, 
       
   981                                KMPMPSKeyUserConnectionSnap, 
       
   982                                aSnapId );
       
   983     
       
   984     if ( err != KErrNone || aSnapId == 0 )
       
   985         {
       
   986         err = RProperty::Get( KMPMUserConnectionCategory, 
       
   987                               KMPMPSKeyUserConnectionIap, 
       
   988                               aIapId );
       
   989         }
       
   990        
       
   991     CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionSnap : %d" ), aSnapId );                      
       
   992     CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionIap : %d" ), aIapId );                           
       
   993     CLOG_WRITEF( _L( "err : %d" ), err );
       
   994         
       
   995     return err;    
       
   996     }
       
   997 
       
   998 
       
   999 // ---------------------------------------------------------
       
  1000 // CConnDlgSelectConnectionPlugin::GetActiveConnection
       
  1001 // ---------------------------------------------------------
       
  1002 //    
       
  1003 TInt CConnDlgSelectConnectionPlugin::GetActiveConnection( TInt& aIapId, 
       
  1004                                                           TInt& aSnapId,
       
  1005                                                           TInt& aBearer )
       
  1006     {
       
  1007     aIapId  = 0;
       
  1008     aSnapId = 0;
       
  1009     aBearer = 0;
       
  1010     
       
  1011     TInt err = RProperty::Get( KMPMActiveConnectionCategory, 
       
  1012                                KMPMPSKeyActiveConnectionSnap, 
       
  1013                                aSnapId );
       
  1014                                   
       
  1015     if ( err != KErrNone || aSnapId == 0 )
       
  1016         {
       
  1017         err = RProperty::Get( KMPMActiveConnectionCategory, 
       
  1018                               KMPMPSKeyActiveConnectionIap, 
       
  1019                               aIapId );
       
  1020         }
       
  1021          
       
  1022     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionSnap : %d" ), aSnapId );                      
       
  1023     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionIap : %d" ), aIapId );                           
       
  1024     CLOG_WRITEF( _L( "err : %d" ), err );                           
       
  1025                                
       
  1026     if ( err == KErrNone )
       
  1027         {
       
  1028     	err = RProperty::Get( KMPMActiveConnectionCategory, 
       
  1029                               KMPMPSKeyActiveConnectionBearer, 
       
  1030                               aBearer );
       
  1031         }
       
  1032 
       
  1033     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionBearer : %d" ), aBearer );                           
       
  1034     CLOG_WRITEF( _L( "iPrefs().iBearerSet : %d" ), iPrefs().iBearerSet );
       
  1035     CLOG_WRITEF( _L( "err : %d" ), err );
       
  1036     
       
  1037     return err;
       
  1038     }
   711 
  1039 
   712 // End of File
  1040 // End of File