diff -r fc7b30ed2058 -r 05bc53fe583b connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp --- a/connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp Thu Aug 19 10:18:49 2010 +0300 +++ b/connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp Tue Aug 31 15:35:44 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -17,14 +17,7 @@ // INCLUDE FILES #include "ConnDlgPlugin.h" -#include "AuthenticationDialog.h" -#include "ReconnectDialog.h" -#include "QosDialog.h" -#include "NewIapDialog.h" -#include "ActiveIapPlugin.h" -#include "ActiveSelectConnectionPlugin.h" -#include "CConnDlgPrivateCRKeys.h" #include #include "ConnectionDialogsUidDefs.h" @@ -34,29 +27,23 @@ #include #include #include -#include +#include +#include +#include -#include #include -#include + + +// NOTE that the functionality this file is DEPRECATED +// None on the methods have UI functionality, the plugins complete the requests +// immediately when they are started using namespace CommsDat; // CONSTANTS -// RSC file name. -_LIT( KResourceFileName, "CConnDlgPlugin.rsc" ); - -// Panic string -_LIT( KConnDlgPluginPanic, "CConnDlgPlugin" ); - LOCAL_D const TInt KPluginGranularity = 4; -#if defined(_DEBUG) -_LIT( KErrActiveObjectNull, "iActivePlugin not NULL" ); -#endif - - LOCAL_C void CreateNotifiersL( CArrayPtrFlat* aNotifiers ); @@ -72,8 +59,9 @@ EXPORT_C CArrayPtr* NotifierArray() { - CArrayPtrFlat* array = new (ELeave) - CArrayPtrFlat( KPluginGranularity ); + CArrayPtrFlat* array = NULL; + TRAP_IGNORE( array = new (ELeave) + CArrayPtrFlat( KPluginGranularity ); ) if ( array ) { @@ -161,64 +149,62 @@ void CConnDlgIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage ) - { - if ( ScreenSaverOn() || AutolockOn() ) - { - // Screen saver or Autolock is active. Cancel the dialog. - CLOG_WRITE( "CConnDlgAuthenticationPlugin::StartL: Screen saver or Autolock is active." ); - aMessage.Complete( KErrCancel ); - return; - } - - iPrefs.Copy( (TPtrC8) aBuffer ); + { iCancelled = EFalse; iReplySlot = aReplySlot; iMessage = aMessage; - // Check if there is a suitable active connection - TInt iap( 0 ); - TInt bearer( ECommDbBearerWLAN ); // User conn. is always WLAN in 9.1 - - // Is there active User connection - TInt err = GetUserConnection( iap ); + // The UI is deprectad, complete the request and return the best available iap + RCmManager cmManager; + cmManager.OpenL(); + CleanupClosePushL( cmManager ); + + RArray destinationArray; + cmManager.AllDestinationsL( destinationArray ); + CleanupClosePushL(destinationArray); + TInt error = KErrNotFound; - if ( err != KErrNone || iap == 0 ) - { - // Is there any active connection - err = GetActiveConnection( iap, bearer ); + // loop the destinations and find the internet snap + for (TInt i = 0; i < destinationArray.Count(); ++i) + { + RCmDestination destination = cmManager.DestinationL( destinationArray[i] ); + CleanupClosePushL(destination); + TUint32 purposeMetaData = destination.MetadataL( CMManager::ESnapMetadataPurpose ); + + // If the internet snap was found, check out the IAPs + if ( CMManager::ESnapPurposeInternet == purposeMetaData ) + { + RMPM mpm; + User::LeaveIfError(mpm.Connect()); + TMpmSnapBuffer buffer; + buffer.Reset(); + User::LeaveIfError( mpm.SortSNAP( destination.Id(), buffer )); + mpm.Close(); + // if there are iaps in the list, return the first + // if there are none, return an error + if ( buffer.Count() > 0 ) + { + iIAP = buffer.iIapId[0]; + error = KErrNone; + } + CleanupStack::PopAndDestroy(); //destination + break; + } + CleanupStack::PopAndDestroy(); //destination } - - if ( ( err == KErrNone ) && - ( iap != 0 ) && - ( iPrefs().iBearerSet & bearer ) ) - { - // a suitable connection is already active - iIAP = iap; - CompleteL( KErrNone ); - } - else - { - // display a dialog - __ASSERT_DEBUG( !iActivePlugin, - User::Panic( KErrActiveObjectNull, KErrNone ) ); + CleanupStack::PopAndDestroy(); //destinationArray + CleanupStack::PopAndDestroy(); //cmManager - iActivePlugin = CActiveCConnDlgIapPlugin::NewL( this, iPrefs() ); - iActivePlugin->StartSearchIAPsL(); - } + CompleteL( error ); } - - // --------------------------------------------------------- // void CConnDlgIapPlugin::Cancel() // --------------------------------------------------------- // void CConnDlgIapPlugin::Cancel() - { - delete iActivePlugin; - iActivePlugin = NULL; - + { if ( !iCancelled ) { iCancelled = ETrue; @@ -261,79 +247,11 @@ // --------------------------------------------------------- // CConnDlgIapPlugin* CConnDlgIapPlugin::NewL( - const TBool aResourceFileResponsible ) + const TBool /*aResourceFileResponsible*/ ) { CConnDlgIapPlugin* self = new (ELeave) CConnDlgIapPlugin(); - CleanupStack::PushL( self ); - self->ConstructL( KResourceFileName, aResourceFileResponsible ); - CleanupStack::Pop(); - return self; } - -// --------------------------------------------------------- -// CConnDlgIapPlugin::SetPreferredIapIdL -// --------------------------------------------------------- -// -void CConnDlgIapPlugin::SetPreferredIapIdL( TUint32 aIAPId ) - { - CLOG_ENTERFN( "CConnDlgIapPlugin::SetPreferredIapIdL " ); - - iIAP = aIAPId; - - CLOG_LEAVEFN( "CConnDlgIapPlugin::SetPreferredIapIdL " ); - } - - -// --------------------------------------------------------- -// CConnDlgIapPlugin::GetActiveConnection -// --------------------------------------------------------- -// -TInt CConnDlgIapPlugin::GetActiveConnection( TInt& aIapId, - TInt& aBearer ) - { - aIapId = 0; - aBearer = 0; - - TInt err = RProperty::Get( KMPMActiveConnectionCategory, - KMPMPSKeyActiveConnectionIap, - aIapId ); - - CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionIap : %d" ), aIapId ); - CLOG_WRITEF( _L( "err : %d" ), err ); - - if ( err == KErrNone ) - { - err = RProperty::Get( KMPMActiveConnectionCategory, - KMPMPSKeyActiveConnectionBearer, - aBearer ); - } - - CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionBearer : %d" ), aBearer ); - CLOG_WRITEF( _L( "err : %d" ), err ); - CLOG_WRITEF( _L( "iPrefs().iBearerSet : %d" ), iPrefs().iBearerSet ); - - return err; - } - - -// --------------------------------------------------------- -// CConnDlgIapPlugin::GetUserConnection -// --------------------------------------------------------- -// -TInt CConnDlgIapPlugin::GetUserConnection( TInt& aIapId ) - { - aIapId = 0; - - TInt err = RProperty::Get( KMPMUserConnectionCategory, - KMPMPSKeyUserConnectionIap, - aIapId ); - - CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionIap : %d" ), aIapId ); - CLOG_WRITEF( _L( "err : %d" ), err ); - - return err; - } // --------------------------------------------------------- @@ -363,27 +281,12 @@ { CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::StartL" ); - if ( ScreenSaverOn() || AutolockOn() ) - { - // Screen saver or Autolock is active. Cancel the dialog. - CLOG_WRITE( "CConnDlgAuthenticationPlugin::StartL: Screen saver or Autolock is active." ); - aMessage.Complete( KErrCancel ); - return; - } - - if ( aBuffer.Length() > iAuthPairBuff.Length() ) - { - CLOG_WRITE( "User::Panic, EConnDlgIllegalRequest" ); - User::Panic( KConnDlgPluginPanic, EConnDlgIllegalRequest ); - } - - iAuthPairBuff.Copy( aBuffer ); - iReplySlot = aReplySlot; iMessage = aMessage; iCancelled = EFalse; - GetAuthenticationL(); + // The UI is deprecated, just complete the request + CompleteL(KErrNotSupported); CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::StartL" ); } @@ -405,8 +308,6 @@ { iMessage.Complete( KErrCancel ); } - delete iDialog; - iDialog = NULL; } CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::Cancel" ); @@ -414,24 +315,6 @@ // --------------------------------------------------------- -// void CConnDlgAuthenticationPlugin::GetAuthenticationL() -// --------------------------------------------------------- -// -void CConnDlgAuthenticationPlugin::GetAuthenticationL() - { - CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::GetAuthenticationL" ); - - iDialog = CAuthenticationDialog::NewL( this, iAuthPairBuff().iUsername, - iAuthPairBuff().iPassword ); - - - iDialog->ExecuteLD( R_CONNDLG_AUTHENTICATION ); - - CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::GetAuthenticationL" ); - } - - -// --------------------------------------------------------- // void CConnDlgAuthenticationPlugin::CompleteL( TInt aStatus ) // --------------------------------------------------------- // @@ -442,11 +325,6 @@ iCancelled = ETrue; if ( !iMessage.IsNull() ) { - if ( aStatus == KErrNone ) - { - iMessage.WriteL( iReplySlot, iAuthPairBuff ); - } - iMessage.Complete( aStatus ); } Cancel(); @@ -460,14 +338,10 @@ // --------------------------------------------------------- // CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL( - const TBool aResourceFileResponsible ) + const TBool /*aResourceFileResponsible*/ ) { CConnDlgAuthenticationPlugin* self = new (ELeave) CConnDlgAuthenticationPlugin(); - CleanupStack::PushL( self ); - self->ConstructL( KResourceFileName, aResourceFileResponsible ); - CleanupStack::Pop(); - return self; } @@ -477,7 +351,6 @@ // --------------------------------------------------------- // CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin() -: iAuthPair( TAuthenticationPair() ) { } @@ -507,7 +380,7 @@ iMessage = aMessage; iCancelled = EFalse; - GetReconnectL(); + CompleteL(KErrNotSupported); } @@ -524,24 +397,11 @@ { iMessage.Complete( KErrCancel ); } - delete iDialog; - iDialog = NULL; } } // --------------------------------------------------------- -// void CConnDlgQosPlugin::GetReconnectL() -// --------------------------------------------------------- -// -void CConnDlgQosPlugin::GetReconnectL() - { - iDialog = new (ELeave) CQosDialog( this, iBool ); - iDialog->ExecuteLD( R_CONNDLG_QOS ); - } - - -// --------------------------------------------------------- // void CConnDlgQosPlugin::CompleteL( TInt aStatus ) // --------------------------------------------------------- // @@ -550,11 +410,6 @@ iCancelled = ETrue; if ( !iMessage.IsNull() ) { - if ( aStatus == KErrNone ) - { - TRAP_IGNORE( iMessage.WriteL( iReplySlot, TPckg( iBool ) ) ); - } - iMessage.Complete( aStatus ); } Cancel(); @@ -566,13 +421,9 @@ // --------------------------------------------------------- // CConnDlgQosPlugin* CConnDlgQosPlugin::NewL( - const TBool aResourceFileResponsible ) + const TBool /*aResourceFileResponsible*/ ) { CConnDlgQosPlugin* self = new (ELeave) CConnDlgQosPlugin(); - CleanupStack::PushL( self ); - self->ConstructL( KResourceFileName, aResourceFileResponsible ); - CleanupStack::Pop(); - return self; } @@ -603,7 +454,8 @@ iMessage = aMessage; iCancelled = EFalse; - GetReconnectL(); + // The UI is deprecated, just complete the request + CompleteL(KErrNotSupported); } @@ -620,24 +472,11 @@ { iMessage.Complete( KErrCancel ); } - delete iDialog; - iDialog = NULL; } } // --------------------------------------------------------- -// void CConnDlgReconnectPlugin::GetReconnectL() -// --------------------------------------------------------- -// -void CConnDlgReconnectPlugin::GetReconnectL() - { - iDialog = new (ELeave) CReconnectDialog( this, iBool ); - iDialog->ExecuteLD( R_CONNDLG_RECONNECT ); - } - - -// --------------------------------------------------------- // void CConnDlgReconnectPlugin::CompleteL( TInt aStatus ) // --------------------------------------------------------- // @@ -646,11 +485,6 @@ iCancelled = ETrue; if ( !iMessage.IsNull() ) { - if ( aStatus == KErrNone ) - { - iMessage.WriteL( iReplySlot, TPckg( iBool ) ); - } - iMessage.Complete( aStatus ); } Cancel(); @@ -663,13 +497,9 @@ // --------------------------------------------------------- // CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL( - const TBool aResourceFileResponsible ) + const TBool /*aResourceFileResponsible*/ ) { CConnDlgReconnectPlugin* self = new (ELeave) CConnDlgReconnectPlugin(); - CleanupStack::PushL( self ); - self->ConstructL( KResourceFileName, aResourceFileResponsible ); - CleanupStack::Pop(); - return self; } @@ -696,17 +526,12 @@ void CConnDlgNewIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage ) { - if ( aBuffer.Length() > iPrefs.Length() ) - { - User::Panic( KConnDlgPluginPanic, EConnDlgIllegalRequest ); - } - - iPrefs.Copy( aBuffer ); iReplySlot = aReplySlot; iMessage = aMessage; iCancelled = EFalse; - GetNewIapL(); + // This api has been deprecated, just Complete the request + CompleteL(KErrNotSupported); } @@ -723,24 +548,11 @@ { iMessage.Complete( KErrCancel ); } - delete iDialog; - iDialog = NULL; } } // --------------------------------------------------------- -// void CConnDlgNewIapPlugin::GetNewIapL() -// --------------------------------------------------------- -// -void CConnDlgNewIapPlugin::GetNewIapL() - { - iDialog = new (ELeave) CNewIapDialog( this, iConnect, iPrefs() ); - iDialog->ExecuteLD( R_CONNDLG_NEW_IAP ); - } - - -// --------------------------------------------------------- // void CConnDlgNewIapPlugin::CompleteL( TInt aStatus ) // --------------------------------------------------------- // @@ -749,11 +561,6 @@ iCancelled = ETrue; if ( !iMessage.IsNull() ) { - if ( aStatus == KErrNone ) - { - iMessage.WriteL( iReplySlot, TPckg( iConnect ) ); - } - iMessage.Complete( aStatus ); } Cancel(); @@ -765,13 +572,9 @@ // --------------------------------------------------------- // CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL( - const TBool aResourceFileResponsible ) + const TBool /*aResourceFileResponsible*/ ) { CConnDlgNewIapPlugin* self = new (ELeave) CConnDlgNewIapPlugin(); - CleanupStack::PushL( self ); - self->ConstructL( KResourceFileName, aResourceFileResponsible ); - CleanupStack::Pop(); - return self; } @@ -797,105 +600,59 @@ // --------------------------------------------------------- // -void CConnDlgSelectConnectionPlugin::StartL( const TDesC8& aBuffer, +void CConnDlgSelectConnectionPlugin::StartL( const TDesC8& /*aBuffer*/, TInt aReplySlot, const RMessagePtr2& aMessage ) { - CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::StartL" ); - - if ( iActivePlugin ) - { - aMessage.Complete( KErrServerBusy ); - return; - } - - TInt iStartUpPhaseValue( EStartupUiPhaseUninitialized ); - RProperty::Get( KPSUidStartup, KPSStartupUiPhase, iStartUpPhaseValue ); - CLOG_WRITEF( _L( "CConnDlgSelectConnectionPlugin::Phone start up phase: %d" ), - iStartUpPhaseValue ); - // Don't show the dialog if phone boot up isn't complete or screen saver or Autolock is on. - if ( iStartUpPhaseValue != EStartupUiPhaseAllDone || ScreenSaverOn() || AutolockOn() ) - { - CLOG_WRITE( "CConnDlgSelectConnectionPlugin::StartL: Screen saver or Autolock is active or start up phase not completed yet." ); - aMessage.Complete( KErrCancel ); - return; - } - - iPrefs.Copy( ( TPtrC8 ) aBuffer ); - - iCancelled = ETrue; // This method could leave before displaying the dialog. + iReplySlot = aReplySlot; iMessage = aMessage; - __ASSERT_DEBUG( !iActivePlugin, - User::Panic( KErrActiveObjectNull, KErrNone ) ); - - iElementID = iPrefs().iRank; - iActivePlugin = CActiveSelectConnectionPlugin::NewL( this, - iElementID, - iPrefs().iBearerSet ); - // Check if there is a suitable active connection - TInt snap( 0 ); - TInt iap( 0 ); - TInt bearer( ECommDbBearerWLAN ); // User conn. is always WLAN in 9.1 + // because the connection dialog is deprecated and removed functionality, + // return the Internet SNAP and complete + RCmManager cmManager; + cmManager.OpenL(); + CleanupClosePushL( cmManager ); - // Is there active User connection - TInt err = GetUserConnection( iap, snap ); - - if ( ( err != KErrNone ) || ( iap == 0 && snap == 0 ) ) - { - // Is there any active connection - err = GetActiveConnection( iap, snap, bearer ); - } - - RVpnServ vpn; - TInt vpnErr( KErrNone ); - TInt policyCount( 0 ); - TBool forceDialogForIntranetUsers( EFalse ); + RArray destinationArray; + cmManager.AllDestinationsL( destinationArray ); + CleanupClosePushL(destinationArray); + bool found = false; - vpnErr = vpn.Connect(); - if ( !vpnErr ) - { - vpnErr = vpn.EnumeratePolicies(policyCount); - if ( !vpnErr && policyCount > 0 ) - { - forceDialogForIntranetUsers = ETrue; - } - vpn.Close(); - } + // loop the destinations and find the internet snap + for (TInt i = 0; i < destinationArray.Count() && !found; ++i) + { + RCmDestination destination = cmManager.DestinationL( destinationArray[i] ); + CleanupClosePushL(destination); - if ( !forceDialogForIntranetUsers && - ( err == KErrNone ) && - ( iap != 0 || snap != 0 ) && - ( iPrefs().iBearerSet & bearer ) && - ( iPrefs().iDirection == 0 ) ) // JavaVM sets iDirection to "1" + TUint32 purposeMetaData = destination.MetadataL( CMManager::ESnapMetadataPurpose ); + if ( CMManager::ESnapPurposeInternet == purposeMetaData ) + { + iElementID = destination.ElementId(); + found = true; + } + CleanupStack::PopAndDestroy(); //destination + } + CleanupStack::PopAndDestroy(); //destinationArray + CleanupStack::PopAndDestroy(); //cmManager + + if (found) { - // a suitable connection is already active - SetElementIDL( iap, snap ); - CompleteL( KErrNone ); - } - else + CompleteL(KErrNone); + } + else { - // display dialog - iActivePlugin->ShowSelectConnectionL(); - iCancelled = EFalse; // Dialog is now up and running + CompleteL(KErrNotFound); } } - - // --------------------------------------------------------- // void CConnDlgSelectConnectionPlugin::Cancel() // --------------------------------------------------------- // void CConnDlgSelectConnectionPlugin::Cancel() { - CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::Cancel" ); - - delete iActivePlugin; - CLOG_WRITE( "iActivePlugin deleted" ); - iActivePlugin = NULL; - CLOG_WRITE( "iActivePlugin NULLed" ); + CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::Cancel" ); if ( !iCancelled ) { @@ -944,97 +701,12 @@ // --------------------------------------------------------- // CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL( - const TBool aResourceFileResponsible ) + const TBool /*aResourceFileResponsible*/ ) { CConnDlgSelectConnectionPlugin* self = new (ELeave) CConnDlgSelectConnectionPlugin(); - CleanupStack::PushL( self ); - self->ConstructL( KResourceFileName, aResourceFileResponsible ); - CleanupStack::Pop(); - return self; } - - -// --------------------------------------------------------- -// CConnDlgSelectConnectionPlugin::SetSelectedIDsL -// --------------------------------------------------------- -// -void CConnDlgSelectConnectionPlugin::SetElementIDL( TUint32 aIAPId, - TUint32 aDestinationId ) - { - iElementID = iActivePlugin->GetElementIDL( aIAPId, aDestinationId ); - } - -// --------------------------------------------------------- -// CConnDlgSelectConnectionPlugin::GetUserConnection -// --------------------------------------------------------- -// -TInt CConnDlgSelectConnectionPlugin::GetUserConnection( TInt& aIapId, - TInt& aSnapId ) - { - aIapId = 0; - aSnapId = 0; - - TInt err = RProperty::Get( KMPMUserConnectionCategory, - KMPMPSKeyUserConnectionSnap, - aSnapId ); - - if ( err != KErrNone || aSnapId == 0 ) - { - err = RProperty::Get( KMPMUserConnectionCategory, - KMPMPSKeyUserConnectionIap, - aIapId ); - } - - CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionSnap : %d" ), aSnapId ); - CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionIap : %d" ), aIapId ); - CLOG_WRITEF( _L( "err : %d" ), err ); - - return err; - } - - -// --------------------------------------------------------- -// CConnDlgSelectConnectionPlugin::GetActiveConnection -// --------------------------------------------------------- -// -TInt CConnDlgSelectConnectionPlugin::GetActiveConnection( TInt& aIapId, - TInt& aSnapId, - TInt& aBearer ) - { - aIapId = 0; - aSnapId = 0; - aBearer = 0; - - TInt err = RProperty::Get( KMPMActiveConnectionCategory, - KMPMPSKeyActiveConnectionSnap, - aSnapId ); - - if ( err != KErrNone || aSnapId == 0 ) - { - err = RProperty::Get( KMPMActiveConnectionCategory, - KMPMPSKeyActiveConnectionIap, - aIapId ); - } - - CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionSnap : %d" ), aSnapId ); - CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionIap : %d" ), aIapId ); - CLOG_WRITEF( _L( "err : %d" ), err ); - - if ( err == KErrNone ) - { - err = RProperty::Get( KMPMActiveConnectionCategory, - KMPMPSKeyActiveConnectionBearer, - aBearer ); - } - - CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionBearer : %d" ), aBearer ); - CLOG_WRITEF( _L( "iPrefs().iBearerSet : %d" ), iPrefs().iBearerSet ); - CLOG_WRITEF( _L( "err : %d" ), err ); - - return err; - } // End of File