diff -r fcbbe021d614 -r 9c97ad6591ae connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp --- a/connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp Fri Apr 16 15:21:37 2010 +0300 +++ b/connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp Mon May 03 12:53:07 2010 +0300 @@ -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,27 +27,23 @@ #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 ); @@ -160,55 +149,61 @@ void CConnDlgIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage ) { - 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; @@ -251,79 +246,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; - } // --------------------------------------------------------- @@ -353,19 +280,12 @@ { CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::StartL" ); - 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" ); } @@ -387,8 +307,6 @@ { iMessage.Complete( KErrCancel ); } - delete iDialog; - iDialog = NULL; } CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::Cancel" ); @@ -396,24 +314,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 ) // --------------------------------------------------------- // @@ -424,11 +324,6 @@ iCancelled = ETrue; if ( !iMessage.IsNull() ) { - if ( aStatus == KErrNone ) - { - iMessage.WriteL( iReplySlot, iAuthPairBuff ); - } - iMessage.Complete( aStatus ); } Cancel(); @@ -442,14 +337,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; } @@ -459,7 +350,6 @@ // --------------------------------------------------------- // CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin() -: iAuthPair( TAuthenticationPair() ) { } @@ -489,7 +379,7 @@ iMessage = aMessage; iCancelled = EFalse; - GetReconnectL(); + CompleteL(KErrNotSupported); } @@ -506,24 +396,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 ) // --------------------------------------------------------- // @@ -532,11 +409,6 @@ iCancelled = ETrue; if ( !iMessage.IsNull() ) { - if ( aStatus == KErrNone ) - { - TRAP_IGNORE( iMessage.WriteL( iReplySlot, TPckg( iBool ) ) ); - } - iMessage.Complete( aStatus ); } Cancel(); @@ -548,13 +420,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; } @@ -585,7 +453,8 @@ iMessage = aMessage; iCancelled = EFalse; - GetReconnectL(); + // The UI is deprecated, just complete the request + CompleteL(KErrNotSupported); } @@ -602,24 +471,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 ) // --------------------------------------------------------- // @@ -628,11 +484,6 @@ iCancelled = ETrue; if ( !iMessage.IsNull() ) { - if ( aStatus == KErrNone ) - { - iMessage.WriteL( iReplySlot, TPckg( iBool ) ); - } - iMessage.Complete( aStatus ); } Cancel(); @@ -645,13 +496,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; } @@ -678,17 +525,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); } @@ -705,24 +547,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 ) // --------------------------------------------------------- // @@ -731,11 +560,6 @@ iCancelled = ETrue; if ( !iMessage.IsNull() ) { - if ( aStatus == KErrNone ) - { - iMessage.WriteL( iReplySlot, TPckg( iConnect ) ); - } - iMessage.Complete( aStatus ); } Cancel(); @@ -747,13 +571,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; } @@ -779,74 +599,59 @@ // --------------------------------------------------------- // -void CConnDlgSelectConnectionPlugin::StartL( const TDesC8& aBuffer, +void CConnDlgSelectConnectionPlugin::StartL( const TDesC8& /*aBuffer*/, TInt aReplySlot, const RMessagePtr2& aMessage ) { - if ( iActivePlugin ) - { - aMessage.Complete( KErrServerBusy ); - 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 ) ); + // because the connection dialog is deprecated and removed functionality, + // return the Internet SNAP and complete + RCmManager cmManager; + cmManager.OpenL(); + CleanupClosePushL( cmManager ); + + RArray destinationArray; + cmManager.AllDestinationsL( destinationArray ); + CleanupClosePushL(destinationArray); + bool found = false; - 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 + // 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); + + TUint32 purposeMetaData = destination.MetadataL( CMManager::ESnapMetadataPurpose ); + if ( CMManager::ESnapPurposeInternet == purposeMetaData ) + { + iElementID = destination.ElementId(); + found = true; + } + CleanupStack::PopAndDestroy(); //destination + } + CleanupStack::PopAndDestroy(); //destinationArray + CleanupStack::PopAndDestroy(); //cmManager - // Is there active User connection - TInt err = GetUserConnection( iap, snap ); - - if ( ( err != KErrNone ) || ( iap == 0 && snap == 0 ) ) + if (found) { - // Is there any active connection - err = GetActiveConnection( iap, snap, bearer ); - } - - if ( ( err == KErrNone ) && - ( iap != 0 || snap != 0 ) && - ( iPrefs().iBearerSet & bearer ) && - ( iPrefs().iDirection == 0 ) ) // JavaVM sets iDirection to "1" + CompleteL(KErrNone); + } + else { - // a suitable connection is already active - SetElementIDL( iap, snap ); - 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 ) { @@ -895,97 +700,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