connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp
changeset 20 9c97ad6591ae
parent 0 5a93021fdf25
child 41 bbb64eb3bdee
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 #include "ConnDlgPlugin.h"
    19 #include "ConnDlgPlugin.h"
    20 #include "AuthenticationDialog.h"
    20 
    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"
       
    28 #include <centralrepository.h>
    21 #include <centralrepository.h>
    29 
    22 
    30 #include "ConnectionDialogsUidDefs.h"
    23 #include "ConnectionDialogsUidDefs.h"
    31 #include "ConnectionDialogsLogger.h"
    24 #include "ConnectionDialogsLogger.h"
    32 
    25 
    33 #include <eikenv.h>
    26 #include <eikenv.h>
    34 #include <bautils.h>
    27 #include <bautils.h>
    35 #include <e32property.h> 
    28 #include <e32property.h> 
    36 #include <rmpm.h>
    29 #include <rmpm.h>
    37 
    30 #include <cmmanager.h>
    38 #include <CConnDlgPlugin.rsg>
    31 #include <cmdestination.h>
       
    32 #include <commsdat.h>
       
    33 
    39 #include <data_caging_path_literals.hrh>
    34 #include <data_caging_path_literals.hrh>
    40 
    35 
       
    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 
    41 using namespace CommsDat;
    41 using namespace CommsDat;
    42 
    42 
    43 // CONSTANTS
    43 // CONSTANTS
    44 
    44 
    45 // RSC file name.
       
    46 _LIT( KResourceFileName, "CConnDlgPlugin.rsc" );
       
    47 
       
    48 // Panic string
       
    49 _LIT( KConnDlgPluginPanic, "CConnDlgPlugin" );
       
    50 
       
    51 LOCAL_D const TInt KPluginGranularity = 4;
    45 LOCAL_D const TInt KPluginGranularity = 4;
    52 
       
    53 #if defined(_DEBUG)
       
    54 _LIT( KErrActiveObjectNull, "iActivePlugin not NULL" );
       
    55 #endif
       
    56 
       
    57 
    46 
    58 
    47 
    59 LOCAL_C void CreateNotifiersL( 
    48 LOCAL_C void CreateNotifiersL( 
    60                             CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers );
    49                             CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers );
    61 
    50 
   158 //
   147 //
   159 
   148 
   160 void CConnDlgIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot,
   149 void CConnDlgIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot,
   161                                 const RMessagePtr2& aMessage )
   150                                 const RMessagePtr2& aMessage )
   162     {
   151     {
   163     iPrefs.Copy( (TPtrC8) aBuffer );
       
   164 
   152 
   165     iCancelled = EFalse;
   153     iCancelled = EFalse;
   166     iReplySlot = aReplySlot;
   154     iReplySlot = aReplySlot;
   167     iMessage = aMessage;
   155     iMessage = aMessage;
   168     
   156     
   169     // Check if there is a suitable active connection
   157     // The UI is deprectad, complete the request and return the best available iap
   170     TInt iap( 0 );
   158     RCmManager cmManager;
   171     TInt bearer( ECommDbBearerWLAN ); // User conn. is always WLAN in 9.1
   159     cmManager.OpenL();     
   172                                       
   160     CleanupClosePushL( cmManager ); 
   173     // Is there active User connection
   161     
   174     TInt err = GetUserConnection( iap );
   162     RArray<TUint32> destinationArray;    
   175     
   163     cmManager.AllDestinationsL( destinationArray );
   176     if ( err != KErrNone || iap == 0 )
   164     CleanupClosePushL(destinationArray);   
   177         {
   165     TInt error = KErrNotFound;
   178         // Is there any active connection
   166     
   179     	err = GetActiveConnection( iap, bearer );
   167     // loop the destinations and find the internet snap
   180         }
   168     for (TInt i = 0; i < destinationArray.Count(); ++i)
   181 
   169         {   
   182     if ( ( err == KErrNone ) && 
   170         RCmDestination destination = cmManager.DestinationL( destinationArray[i] );
   183          ( iap != 0 )        &&  
   171         CleanupClosePushL(destination);
   184          ( iPrefs().iBearerSet & bearer ) )
   172         TUint32 purposeMetaData = destination.MetadataL( CMManager::ESnapMetadataPurpose );
   185         {
   173         
   186     	// a suitable connection is already active
   174         // If the internet snap was found, check out the IAPs
   187     	iIAP = iap;
   175         if ( CMManager::ESnapPurposeInternet ==  purposeMetaData )
   188     	CompleteL( KErrNone );
   176             {
   189         }
   177             RMPM mpm;
   190     else
   178             User::LeaveIfError(mpm.Connect());
   191         {
   179             TMpmSnapBuffer buffer;
   192         // display a dialog
   180             buffer.Reset();
   193         __ASSERT_DEBUG( !iActivePlugin, 
   181             User::LeaveIfError( mpm.SortSNAP( destination.Id(), buffer )); 
   194                     User::Panic( KErrActiveObjectNull, KErrNone ) );
   182             mpm.Close();
   195     
   183             // if there are iaps in the list, return the first
   196         iActivePlugin = CActiveCConnDlgIapPlugin::NewL( this, iPrefs() );
   184             // if there are none, return an error
   197         iActivePlugin->StartSearchIAPsL();	
   185             if ( buffer.Count() > 0 )
   198         }
   186                 {
   199     }
   187                 iIAP = buffer.iIapId[0];
   200 
   188                 error = KErrNone;
   201 
   189                 }
       
   190             CleanupStack::PopAndDestroy(); //destination
       
   191             break;
       
   192             }                
       
   193         CleanupStack::PopAndDestroy(); //destination
       
   194         }
       
   195     CleanupStack::PopAndDestroy(); //destinationArray
       
   196     CleanupStack::PopAndDestroy(); //cmManager
       
   197     
       
   198     CompleteL( error );
       
   199     }
   202 
   200 
   203 // ---------------------------------------------------------
   201 // ---------------------------------------------------------
   204 // void CConnDlgIapPlugin::Cancel()
   202 // void CConnDlgIapPlugin::Cancel()
   205 // ---------------------------------------------------------
   203 // ---------------------------------------------------------
   206 //
   204 //
   207 void CConnDlgIapPlugin::Cancel()
   205 void CConnDlgIapPlugin::Cancel()
   208     {
   206     { 
   209     delete iActivePlugin;
       
   210     iActivePlugin = NULL;
       
   211     
       
   212     if ( !iCancelled )
   207     if ( !iCancelled )
   213         {
   208         {
   214         iCancelled = ETrue;
   209         iCancelled = ETrue;
   215         if ( !iMessage.IsNull() )
   210         if ( !iMessage.IsNull() )
   216             {
   211             {
   249 // ---------------------------------------------------------
   244 // ---------------------------------------------------------
   250 // CConnDlgIapPlugin* CConnDlgIapPlugin::NewL()
   245 // CConnDlgIapPlugin* CConnDlgIapPlugin::NewL()
   251 // ---------------------------------------------------------
   246 // ---------------------------------------------------------
   252 //
   247 //
   253 CConnDlgIapPlugin* CConnDlgIapPlugin::NewL( 
   248 CConnDlgIapPlugin* CConnDlgIapPlugin::NewL( 
   254                                         const TBool aResourceFileResponsible )
   249                                         const TBool /*aResourceFileResponsible*/ )
   255     {
   250     {
   256     CConnDlgIapPlugin* self = new (ELeave) CConnDlgIapPlugin();
   251     CConnDlgIapPlugin* self = new (ELeave) CConnDlgIapPlugin();
   257     CleanupStack::PushL( self );
       
   258     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   259     CleanupStack::Pop();
       
   260 
       
   261     return self;
   252     return self;
   262     }
       
   263 
       
   264 // ---------------------------------------------------------
       
   265 // CConnDlgIapPlugin::SetPreferredIapIdL
       
   266 // ---------------------------------------------------------
       
   267 //    
       
   268 void CConnDlgIapPlugin::SetPreferredIapIdL( TUint32 aIAPId )
       
   269     {
       
   270     CLOG_ENTERFN( "CConnDlgIapPlugin::SetPreferredIapIdL " );
       
   271     
       
   272     iIAP = aIAPId;
       
   273         
       
   274     CLOG_LEAVEFN( "CConnDlgIapPlugin::SetPreferredIapIdL " );
       
   275     }
       
   276     
       
   277     
       
   278 // ---------------------------------------------------------
       
   279 // CConnDlgIapPlugin::GetActiveConnection
       
   280 // ---------------------------------------------------------
       
   281 //    
       
   282 TInt CConnDlgIapPlugin::GetActiveConnection( TInt& aIapId, 
       
   283                                              TInt& aBearer )
       
   284     {
       
   285     aIapId  = 0;
       
   286     aBearer = 0;
       
   287     
       
   288     TInt err = RProperty::Get( KMPMActiveConnectionCategory, 
       
   289                                KMPMPSKeyActiveConnectionIap, 
       
   290                                aIapId );
       
   291                                
       
   292     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionIap : %d" ), aIapId );                           
       
   293     CLOG_WRITEF( _L( "err : %d" ), err );                           
       
   294                                
       
   295     if ( err == KErrNone )
       
   296         {
       
   297     	err = RProperty::Get( KMPMActiveConnectionCategory, 
       
   298                               KMPMPSKeyActiveConnectionBearer, 
       
   299                               aBearer );
       
   300         }
       
   301         
       
   302     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionBearer : %d" ), aBearer );                           
       
   303     CLOG_WRITEF( _L( "err : %d" ), err );
       
   304     CLOG_WRITEF( _L( "iPrefs().iBearerSet : %d" ), iPrefs().iBearerSet );
       
   305     
       
   306     return err;
       
   307     }
       
   308     
       
   309     
       
   310 // ---------------------------------------------------------
       
   311 // CConnDlgIapPlugin::GetUserConnection
       
   312 // ---------------------------------------------------------
       
   313 //    
       
   314 TInt CConnDlgIapPlugin::GetUserConnection( TInt& aIapId )
       
   315     {
       
   316     aIapId  = 0;
       
   317     
       
   318     TInt err = RProperty::Get( KMPMUserConnectionCategory, 
       
   319                                KMPMPSKeyUserConnectionIap, 
       
   320                                aIapId );
       
   321                 
       
   322     CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionIap : %d" ), aIapId );                           
       
   323     CLOG_WRITEF( _L( "err : %d" ), err );                            
       
   324         
       
   325     return err;    
       
   326     }
   253     }
   327             
   254             
   328 
   255 
   329 // ---------------------------------------------------------
   256 // ---------------------------------------------------------
   330 // CConnDlgAuthenticationPlugin::TNotifierInfo
   257 // CConnDlgAuthenticationPlugin::TNotifierInfo
   351                                            TInt aReplySlot,
   278                                            TInt aReplySlot,
   352                                            const RMessagePtr2& aMessage )
   279                                            const RMessagePtr2& aMessage )
   353     {
   280     {
   354     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::StartL" );
   281     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::StartL" );
   355 
   282 
   356     if ( aBuffer.Length() > iAuthPairBuff.Length() )
       
   357         {
       
   358         CLOG_WRITE( "User::Panic, EConnDlgIllegalRequest" );
       
   359         User::Panic( KConnDlgPluginPanic, EConnDlgIllegalRequest );
       
   360         }
       
   361 
       
   362     iAuthPairBuff.Copy( aBuffer );
       
   363 
       
   364     iReplySlot = aReplySlot;
   283     iReplySlot = aReplySlot;
   365     iMessage = aMessage;
   284     iMessage = aMessage;
   366     iCancelled = EFalse;
   285     iCancelled = EFalse;
   367 
   286 
   368     GetAuthenticationL();
   287     // The UI is deprecated, just complete the request
       
   288     CompleteL(KErrNotSupported);
   369 
   289 
   370     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::StartL" );
   290     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::StartL" );
   371     }
   291     }
   372 
   292 
   373 
   293 
   385         iCancelled = ETrue;
   305         iCancelled = ETrue;
   386         if ( !iMessage.IsNull() )
   306         if ( !iMessage.IsNull() )
   387             {
   307             {
   388             iMessage.Complete( KErrCancel );
   308             iMessage.Complete( KErrCancel );
   389             }
   309             }
   390         delete iDialog;
       
   391         iDialog = NULL;
       
   392         }
   310         }
   393 
   311 
   394     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::Cancel" );
   312     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::Cancel" );
   395     }
       
   396 
       
   397 
       
   398 // ---------------------------------------------------------
       
   399 // void CConnDlgAuthenticationPlugin::GetAuthenticationL()
       
   400 // ---------------------------------------------------------
       
   401 //
       
   402 void CConnDlgAuthenticationPlugin::GetAuthenticationL()
       
   403     {
       
   404     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::GetAuthenticationL" );
       
   405 
       
   406     iDialog = CAuthenticationDialog::NewL( this, iAuthPairBuff().iUsername, 
       
   407                                            iAuthPairBuff().iPassword );
       
   408 
       
   409 
       
   410     iDialog->ExecuteLD( R_CONNDLG_AUTHENTICATION );
       
   411 
       
   412     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::GetAuthenticationL" );
       
   413     }
   313     }
   414 
   314 
   415 
   315 
   416 // ---------------------------------------------------------
   316 // ---------------------------------------------------------
   417 // void CConnDlgAuthenticationPlugin::CompleteL( TInt aStatus )
   317 // void CConnDlgAuthenticationPlugin::CompleteL( TInt aStatus )
   422     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::CompleteL" );
   322     CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::CompleteL" );
   423 
   323 
   424     iCancelled = ETrue;
   324     iCancelled = ETrue;
   425     if ( !iMessage.IsNull() )
   325     if ( !iMessage.IsNull() )
   426         {
   326         {
   427         if ( aStatus == KErrNone )
       
   428             {
       
   429             iMessage.WriteL( iReplySlot, iAuthPairBuff );
       
   430             }
       
   431 
       
   432         iMessage.Complete( aStatus );
   327         iMessage.Complete( aStatus );
   433         }
   328         }
   434     Cancel();
   329     Cancel();
   435 
   330 
   436     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::CompleteL" );
   331     CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::CompleteL" );
   440 // ---------------------------------------------------------
   335 // ---------------------------------------------------------
   441 // CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL()
   336 // CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL()
   442 // ---------------------------------------------------------
   337 // ---------------------------------------------------------
   443 //
   338 //
   444 CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL( 
   339 CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL( 
   445                                         const TBool aResourceFileResponsible )
   340                                         const TBool /*aResourceFileResponsible*/ )
   446     {
   341     {
   447     CConnDlgAuthenticationPlugin* self = new (ELeave) 
   342     CConnDlgAuthenticationPlugin* self = new (ELeave) 
   448                                                 CConnDlgAuthenticationPlugin();
   343                                                 CConnDlgAuthenticationPlugin();
   449     CleanupStack::PushL( self );
       
   450     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   451     CleanupStack::Pop();
       
   452 
       
   453     return self;
   344     return self;
   454     }
   345     }
   455 
   346 
   456 
   347 
   457 // ---------------------------------------------------------
   348 // ---------------------------------------------------------
   458 // CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin()
   349 // CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin()
   459 // ---------------------------------------------------------
   350 // ---------------------------------------------------------
   460 //
   351 //
   461 CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin()
   352 CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin()
   462 : iAuthPair( TAuthenticationPair() )
       
   463     {
   353     {
   464     }
   354     }
   465 
   355 
   466 
   356 
   467 // ---------------------------------------------------------
   357 // ---------------------------------------------------------
   487     {
   377     {
   488     iReplySlot = aReplySlot;
   378     iReplySlot = aReplySlot;
   489     iMessage = aMessage;
   379     iMessage = aMessage;
   490     iCancelled = EFalse;
   380     iCancelled = EFalse;
   491 
   381 
   492     GetReconnectL();
   382     CompleteL(KErrNotSupported);
   493     }
   383     }
   494 
   384 
   495 
   385 
   496 // ---------------------------------------------------------
   386 // ---------------------------------------------------------
   497 // void CConnDlgQosPlugin::Cancel()
   387 // void CConnDlgQosPlugin::Cancel()
   504         iCancelled = ETrue;
   394         iCancelled = ETrue;
   505         if ( !iMessage.IsNull() )
   395         if ( !iMessage.IsNull() )
   506             {
   396             {
   507             iMessage.Complete( KErrCancel );
   397             iMessage.Complete( KErrCancel );
   508             }
   398             }
   509         delete iDialog;
   399         }
   510         iDialog = NULL;
       
   511         }
       
   512     }
       
   513 
       
   514 
       
   515 // ---------------------------------------------------------
       
   516 // void CConnDlgQosPlugin::GetReconnectL()
       
   517 // ---------------------------------------------------------
       
   518 //
       
   519 void CConnDlgQosPlugin::GetReconnectL()
       
   520     {
       
   521     iDialog = new (ELeave) CQosDialog( this, iBool );
       
   522     iDialog->ExecuteLD( R_CONNDLG_QOS );
       
   523     }
   400     }
   524 
   401 
   525 
   402 
   526 // ---------------------------------------------------------
   403 // ---------------------------------------------------------
   527 // void CConnDlgQosPlugin::CompleteL( TInt aStatus )
   404 // void CConnDlgQosPlugin::CompleteL( TInt aStatus )
   530 void CConnDlgQosPlugin::CompleteL( TInt aStatus )
   407 void CConnDlgQosPlugin::CompleteL( TInt aStatus )
   531     {
   408     {
   532     iCancelled = ETrue;
   409     iCancelled = ETrue;
   533     if ( !iMessage.IsNull() )
   410     if ( !iMessage.IsNull() )
   534         {
   411         {
   535         if ( aStatus == KErrNone )
       
   536             {
       
   537             TRAP_IGNORE( iMessage.WriteL( iReplySlot, TPckg<TBool>( iBool ) ) );
       
   538             }
       
   539 
       
   540         iMessage.Complete( aStatus );
   412         iMessage.Complete( aStatus );
   541         }
   413         }
   542     Cancel();
   414     Cancel();
   543     }
   415     }
   544 
   416 
   546 // ---------------------------------------------------------
   418 // ---------------------------------------------------------
   547 // CConnDlgQosPlugin* CConnDlgQosPlugin::NewL()
   419 // CConnDlgQosPlugin* CConnDlgQosPlugin::NewL()
   548 // ---------------------------------------------------------
   420 // ---------------------------------------------------------
   549 //
   421 //
   550 CConnDlgQosPlugin* CConnDlgQosPlugin::NewL( 
   422 CConnDlgQosPlugin* CConnDlgQosPlugin::NewL( 
   551                                         const TBool aResourceFileResponsible )
   423                                         const TBool /*aResourceFileResponsible*/ )
   552     {
   424     {
   553     CConnDlgQosPlugin* self = new (ELeave) CConnDlgQosPlugin();
   425     CConnDlgQosPlugin* self = new (ELeave) CConnDlgQosPlugin();
   554     CleanupStack::PushL( self );
       
   555     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   556     CleanupStack::Pop();
       
   557 
       
   558     return self;
   426     return self;
   559     }
   427     }
   560 
   428 
   561 
   429 
   562 // ---------------------------------------------------------
   430 // ---------------------------------------------------------
   583     {
   451     {
   584     iReplySlot = aReplySlot;
   452     iReplySlot = aReplySlot;
   585     iMessage = aMessage;
   453     iMessage = aMessage;
   586     iCancelled = EFalse;
   454     iCancelled = EFalse;
   587 
   455 
   588     GetReconnectL();
   456     // The UI is deprecated, just complete the request
       
   457     CompleteL(KErrNotSupported);
   589     }
   458     }
   590 
   459 
   591 
   460 
   592 // ---------------------------------------------------------
   461 // ---------------------------------------------------------
   593 // void CConnDlgReconnectPlugin::Cancel()
   462 // void CConnDlgReconnectPlugin::Cancel()
   600         iCancelled = ETrue;
   469         iCancelled = ETrue;
   601         if ( !iMessage.IsNull() )
   470         if ( !iMessage.IsNull() )
   602             {
   471             {
   603             iMessage.Complete( KErrCancel );
   472             iMessage.Complete( KErrCancel );
   604             }
   473             }
   605         delete iDialog;
   474         }
   606         iDialog = NULL;
       
   607         }
       
   608     }
       
   609 
       
   610 
       
   611 // ---------------------------------------------------------
       
   612 // void CConnDlgReconnectPlugin::GetReconnectL()
       
   613 // ---------------------------------------------------------
       
   614 //
       
   615 void CConnDlgReconnectPlugin::GetReconnectL()
       
   616     {
       
   617     iDialog = new (ELeave) CReconnectDialog( this, iBool );
       
   618     iDialog->ExecuteLD( R_CONNDLG_RECONNECT );
       
   619     }
   475     }
   620 
   476 
   621 
   477 
   622 // ---------------------------------------------------------
   478 // ---------------------------------------------------------
   623 // void CConnDlgReconnectPlugin::CompleteL( TInt aStatus )
   479 // void CConnDlgReconnectPlugin::CompleteL( TInt aStatus )
   626 void CConnDlgReconnectPlugin::CompleteL( TInt aStatus )
   482 void CConnDlgReconnectPlugin::CompleteL( TInt aStatus )
   627     {
   483     {
   628     iCancelled = ETrue;
   484     iCancelled = ETrue;
   629     if ( !iMessage.IsNull() )
   485     if ( !iMessage.IsNull() )
   630         {
   486         {
   631         if ( aStatus == KErrNone )
       
   632             {
       
   633             iMessage.WriteL( iReplySlot, TPckg<TBool>( iBool ) );
       
   634             }
       
   635 
       
   636         iMessage.Complete( aStatus );
   487         iMessage.Complete( aStatus );
   637         }
   488         }
   638     Cancel();
   489     Cancel();
   639     
   490     
   640     }
   491     }
   643 // ---------------------------------------------------------
   494 // ---------------------------------------------------------
   644 // CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL()
   495 // CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL()
   645 // ---------------------------------------------------------
   496 // ---------------------------------------------------------
   646 //
   497 //
   647 CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL( 
   498 CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL( 
   648                                         const TBool aResourceFileResponsible )
   499                                         const TBool /*aResourceFileResponsible*/ )
   649     {
   500     {
   650     CConnDlgReconnectPlugin* self = new (ELeave) CConnDlgReconnectPlugin();
   501     CConnDlgReconnectPlugin* self = new (ELeave) CConnDlgReconnectPlugin();
   651     CleanupStack::PushL( self );
       
   652     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   653     CleanupStack::Pop();
       
   654 
       
   655     return self;
   502     return self;
   656     }
   503     }
   657 
   504 
   658 
   505 
   659 // ---------------------------------------------------------
   506 // ---------------------------------------------------------
   676 //
   523 //
   677 
   524 
   678 void CConnDlgNewIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot,
   525 void CConnDlgNewIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot,
   679                                    const RMessagePtr2& aMessage )
   526                                    const RMessagePtr2& aMessage )
   680     {
   527     {
   681     if ( aBuffer.Length() > iPrefs.Length() )
       
   682         {
       
   683         User::Panic( KConnDlgPluginPanic, EConnDlgIllegalRequest );
       
   684         }
       
   685 
       
   686     iPrefs.Copy( aBuffer );
       
   687     iReplySlot = aReplySlot;
   528     iReplySlot = aReplySlot;
   688     iMessage = aMessage;
   529     iMessage = aMessage;
   689     iCancelled = EFalse;
   530     iCancelled = EFalse;
   690 
   531 
   691     GetNewIapL();
   532     // This api has been deprecated, just Complete the request
       
   533     CompleteL(KErrNotSupported);
   692     }
   534     }
   693 
   535 
   694 
   536 
   695 // ---------------------------------------------------------
   537 // ---------------------------------------------------------
   696 // void CConnDlgNewIapPlugin::Cancel()
   538 // void CConnDlgNewIapPlugin::Cancel()
   703         iCancelled = ETrue;
   545         iCancelled = ETrue;
   704         if ( !iMessage.IsNull() )
   546         if ( !iMessage.IsNull() )
   705             {
   547             {
   706             iMessage.Complete( KErrCancel );
   548             iMessage.Complete( KErrCancel );
   707             }
   549             }
   708         delete iDialog;
   550         }
   709         iDialog = NULL;
       
   710         }
       
   711     }
       
   712 
       
   713 
       
   714 // ---------------------------------------------------------
       
   715 // void CConnDlgNewIapPlugin::GetNewIapL()
       
   716 // ---------------------------------------------------------
       
   717 //
       
   718 void CConnDlgNewIapPlugin::GetNewIapL()
       
   719     {
       
   720     iDialog = new (ELeave) CNewIapDialog( this, iConnect, iPrefs() );
       
   721     iDialog->ExecuteLD( R_CONNDLG_NEW_IAP );
       
   722     }
   551     }
   723 
   552 
   724 
   553 
   725 // ---------------------------------------------------------
   554 // ---------------------------------------------------------
   726 // void CConnDlgNewIapPlugin::CompleteL( TInt aStatus )
   555 // void CConnDlgNewIapPlugin::CompleteL( TInt aStatus )
   729 void CConnDlgNewIapPlugin::CompleteL( TInt aStatus )
   558 void CConnDlgNewIapPlugin::CompleteL( TInt aStatus )
   730     {
   559     {
   731     iCancelled = ETrue;
   560     iCancelled = ETrue;
   732     if ( !iMessage.IsNull() )
   561     if ( !iMessage.IsNull() )
   733         {
   562         {
   734         if ( aStatus == KErrNone )
       
   735             {
       
   736             iMessage.WriteL( iReplySlot, TPckg<TBool>( iConnect ) );
       
   737             }
       
   738 
       
   739         iMessage.Complete( aStatus );
   563         iMessage.Complete( aStatus );
   740         }
   564         }
   741     Cancel();
   565     Cancel();
   742     }
   566     }
   743 
   567 
   745 // ---------------------------------------------------------
   569 // ---------------------------------------------------------
   746 // CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL()
   570 // CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL()
   747 // ---------------------------------------------------------
   571 // ---------------------------------------------------------
   748 //
   572 //
   749 CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL( 
   573 CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL( 
   750                                         const TBool aResourceFileResponsible )
   574                                         const TBool /*aResourceFileResponsible*/ )
   751     {
   575     {
   752     CConnDlgNewIapPlugin* self = new (ELeave) CConnDlgNewIapPlugin();
   576     CConnDlgNewIapPlugin* self = new (ELeave) CConnDlgNewIapPlugin();
   753     CleanupStack::PushL( self );
       
   754     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   755     CleanupStack::Pop();
       
   756 
       
   757     return self;
   577     return self;
   758     }
   578     }
   759 
   579 
   760     
   580     
   761 // ---------------------------------------------------------
   581 // ---------------------------------------------------------
   777 // ---------------------------------------------------------
   597 // ---------------------------------------------------------
   778 // void CConnDlgSelectConnectionPlugin::StartL
   598 // void CConnDlgSelectConnectionPlugin::StartL
   779 // ---------------------------------------------------------
   599 // ---------------------------------------------------------
   780 //
   600 //
   781 
   601 
   782 void CConnDlgSelectConnectionPlugin::StartL( const TDesC8& aBuffer, 
   602 void CConnDlgSelectConnectionPlugin::StartL( const TDesC8& /*aBuffer*/, 
   783                                              TInt aReplySlot,
   603                                              TInt aReplySlot,
   784                                              const RMessagePtr2& aMessage )
   604                                              const RMessagePtr2& aMessage )
   785     {
   605     {
   786     if ( iActivePlugin )
       
   787         {
       
   788         aMessage.Complete( KErrServerBusy );
       
   789         return;
       
   790         }
       
   791         
   606         
   792     iPrefs.Copy( ( TPtrC8 ) aBuffer );
       
   793 
       
   794     iCancelled = ETrue; // This method could leave before displaying the dialog.
       
   795     iReplySlot = aReplySlot;
   607     iReplySlot = aReplySlot;
   796     iMessage = aMessage;
   608     iMessage = aMessage;
   797     
   609     
   798     __ASSERT_DEBUG( !iActivePlugin, 
   610     // because the connection dialog is deprecated and removed functionality,
   799                      User::Panic( KErrActiveObjectNull, KErrNone ) );
   611     // return the Internet SNAP and complete
   800     
   612     RCmManager cmManager;
   801     iElementID = iPrefs().iRank;
   613     cmManager.OpenL();     
   802     iActivePlugin = CActiveSelectConnectionPlugin::NewL( this,
   614     CleanupClosePushL( cmManager ); 
   803                                                          iElementID,
   615     
   804                                                          iPrefs().iBearerSet );
   616     RArray<TUint32> destinationArray;    
   805     // Check if there is a suitable active connection
   617     cmManager.AllDestinationsL( destinationArray );
   806     TInt snap( 0 );
   618     CleanupClosePushL(destinationArray);   
   807     TInt iap( 0 );
   619     bool found = false;
   808     TInt bearer( ECommDbBearerWLAN ); // User conn. is always WLAN in 9.1
   620     
   809     
   621     // loop the destinations and find the internet snap
   810     // Is there active User connection
   622     for (TInt i = 0; i < destinationArray.Count() && !found; ++i)
   811     TInt err = GetUserConnection( iap, snap );
   623         {   
   812     
   624         RCmDestination destination = cmManager.DestinationL( destinationArray[i] );
   813     if ( ( err != KErrNone ) || ( iap == 0 && snap == 0 ) )
   625         CleanupClosePushL(destination);
   814         {
   626         
   815         // Is there any active connection
   627         TUint32 purposeMetaData = destination.MetadataL( CMManager::ESnapMetadataPurpose );
   816     	err = GetActiveConnection( iap, snap, bearer );
   628         if ( CMManager::ESnapPurposeInternet ==  purposeMetaData )
   817         }
   629             {
   818                                       
   630             iElementID = destination.ElementId();
   819     if ( ( err == KErrNone ) && 
   631             found = true;
   820          ( iap != 0 || snap != 0 ) && 
   632             }                
   821          ( iPrefs().iBearerSet & bearer ) &&
   633         CleanupStack::PopAndDestroy(); //destination
   822          ( iPrefs().iDirection == 0 ) )     // JavaVM sets iDirection to "1"
   634         }
   823         {
   635     CleanupStack::PopAndDestroy(); //destinationArray
   824     	// a suitable connection is already active
   636     CleanupStack::PopAndDestroy(); //cmManager
   825     	SetElementIDL( iap, snap );
   637     
   826     	CompleteL( KErrNone );
   638     if (found)
   827         }
   639         {
   828     else
   640         CompleteL(KErrNone);
   829         {
   641         } 
   830         // display dialog
   642     else 
   831         iActivePlugin->ShowSelectConnectionL();
   643         {
   832         iCancelled = EFalse; // Dialog is now up and running
   644         CompleteL(KErrNotFound);
   833         }
   645         }
   834     }
   646     }
   835 
       
   836 
       
   837 
   647 
   838 // ---------------------------------------------------------
   648 // ---------------------------------------------------------
   839 // void CConnDlgSelectConnectionPlugin::Cancel()
   649 // void CConnDlgSelectConnectionPlugin::Cancel()
   840 // ---------------------------------------------------------
   650 // ---------------------------------------------------------
   841 //
   651 //
   842 void CConnDlgSelectConnectionPlugin::Cancel()
   652 void CConnDlgSelectConnectionPlugin::Cancel()
   843     {
   653     {
   844     CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::Cancel" );      
   654     CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::Cancel" );          
   845 
       
   846     delete iActivePlugin;
       
   847     CLOG_WRITE( "iActivePlugin deleted" );      
       
   848     iActivePlugin = NULL;
       
   849     CLOG_WRITE( "iActivePlugin NULLed" );      
       
   850     
   655     
   851     if ( !iCancelled )
   656     if ( !iCancelled )
   852         {
   657         {
   853         CLOG_WRITE( "iCancelled == EFalse" );      
   658         CLOG_WRITE( "iCancelled == EFalse" );      
   854         iCancelled = ETrue;
   659         iCancelled = ETrue;
   893 // ---------------------------------------------------------
   698 // ---------------------------------------------------------
   894 // CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL()
   699 // CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL()
   895 // ---------------------------------------------------------
   700 // ---------------------------------------------------------
   896 //
   701 //
   897 CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL( 
   702 CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL( 
   898                                         const TBool aResourceFileResponsible )
   703                                         const TBool /*aResourceFileResponsible*/ )
   899     {
   704     {
   900     CConnDlgSelectConnectionPlugin* self = 
   705     CConnDlgSelectConnectionPlugin* self = 
   901                             new (ELeave) CConnDlgSelectConnectionPlugin();
   706                             new (ELeave) CConnDlgSelectConnectionPlugin();
   902     CleanupStack::PushL( self );
       
   903     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
   904     CleanupStack::Pop();
       
   905 
       
   906     return self;
   707     return self;
   907     }
   708     }
   908 
   709     
   909 
       
   910 // ---------------------------------------------------------
       
   911 // CConnDlgSelectConnectionPlugin::SetSelectedIDsL
       
   912 // ---------------------------------------------------------
       
   913 //    
       
   914 void CConnDlgSelectConnectionPlugin::SetElementIDL( TUint32 aIAPId, 
       
   915                                                     TUint32 aDestinationId )
       
   916     {
       
   917     iElementID = iActivePlugin->GetElementIDL( aIAPId, aDestinationId );
       
   918     }
       
   919     
       
   920     
       
   921 // ---------------------------------------------------------
       
   922 // CConnDlgSelectConnectionPlugin::GetUserConnection
       
   923 // ---------------------------------------------------------
       
   924 //    
       
   925 TInt CConnDlgSelectConnectionPlugin::GetUserConnection( TInt& aIapId, 
       
   926                                                         TInt& aSnapId )
       
   927     {
       
   928     aIapId  = 0;
       
   929     aSnapId = 0;
       
   930     
       
   931     TInt err = RProperty::Get( KMPMUserConnectionCategory, 
       
   932                                KMPMPSKeyUserConnectionSnap, 
       
   933                                aSnapId );
       
   934     
       
   935     if ( err != KErrNone || aSnapId == 0 )
       
   936         {
       
   937         err = RProperty::Get( KMPMUserConnectionCategory, 
       
   938                               KMPMPSKeyUserConnectionIap, 
       
   939                               aIapId );
       
   940         }
       
   941        
       
   942     CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionSnap : %d" ), aSnapId );                      
       
   943     CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionIap : %d" ), aIapId );                           
       
   944     CLOG_WRITEF( _L( "err : %d" ), err );
       
   945         
       
   946     return err;    
       
   947     }
       
   948 
       
   949 
       
   950 // ---------------------------------------------------------
       
   951 // CConnDlgSelectConnectionPlugin::GetActiveConnection
       
   952 // ---------------------------------------------------------
       
   953 //    
       
   954 TInt CConnDlgSelectConnectionPlugin::GetActiveConnection( TInt& aIapId, 
       
   955                                                           TInt& aSnapId,
       
   956                                                           TInt& aBearer )
       
   957     {
       
   958     aIapId  = 0;
       
   959     aSnapId = 0;
       
   960     aBearer = 0;
       
   961     
       
   962     TInt err = RProperty::Get( KMPMActiveConnectionCategory, 
       
   963                                KMPMPSKeyActiveConnectionSnap, 
       
   964                                aSnapId );
       
   965                                   
       
   966     if ( err != KErrNone || aSnapId == 0 )
       
   967         {
       
   968         err = RProperty::Get( KMPMActiveConnectionCategory, 
       
   969                               KMPMPSKeyActiveConnectionIap, 
       
   970                               aIapId );
       
   971         }
       
   972          
       
   973     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionSnap : %d" ), aSnapId );                      
       
   974     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionIap : %d" ), aIapId );                           
       
   975     CLOG_WRITEF( _L( "err : %d" ), err );                           
       
   976                                
       
   977     if ( err == KErrNone )
       
   978         {
       
   979     	err = RProperty::Get( KMPMActiveConnectionCategory, 
       
   980                               KMPMPSKeyActiveConnectionBearer, 
       
   981                               aBearer );
       
   982         }
       
   983 
       
   984     CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionBearer : %d" ), aBearer );                           
       
   985     CLOG_WRITEF( _L( "iPrefs().iBearerSet : %d" ), iPrefs().iBearerSet );
       
   986     CLOG_WRITEF( _L( "err : %d" ), err );
       
   987     
       
   988     return err;
       
   989     }
       
   990 
   710 
   991 // End of File
   711 // End of File