diff -r 50c53e893c3f -r 1221b68b8a5f omadrm/drmengine/roap/src/RoapConnection.cpp --- a/omadrm/drmengine/roap/src/RoapConnection.cpp Thu Aug 19 10:12:10 2010 +0300 +++ b/omadrm/drmengine/roap/src/RoapConnection.cpp Tue Aug 31 15:29:38 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2002-2010 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" @@ -22,54 +22,16 @@ #include #include #include -#include +#include #include +#include // IAP, COMMDB_ID #include -#ifdef __SERIES60_NATIVE_BROWSER -#include -#endif #include "RoapConnection.h" #include "RoapDef.h" #include "RoapLog.h" -#ifndef __SERIES60_NATIVE_BROWSER - const TUid KCRUidBrowser = {0x10008D39}; - const TUint32 KBrowserDefaultAccessPoint = 0x0000000E; - const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E; - const TUint32 KBrowserNGDefaultSnapId = 0x00000053; -#endif - - -// ================= LOCAL FUNCTIONS ========================================= -// --------------------------------------------------------------------------- -// IapIdOfDefaultSnapL -// for trapping purposes only -// --------------------------------------------------------------------------- -// -LOCAL_C TUint32 IapIdOfDefaultSnapL( - RCmManager& aCmManager, - const TUint32 aDefaultSnap ) - { - RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) ); - CleanupClosePushL( dest ); - TUint32 iapIdOfDest( 0 ); - - if ( dest.ConnectionMethodCount() <= 0 ) - { - User::Leave( KErrNotFound ); - } - - RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) ); - CleanupClosePushL( cMeth ); - - iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId ); - CleanupStack::PopAndDestroy( &cMeth ); - CleanupStack::PopAndDestroy( &dest ); - return iapIdOfDest; - } - // ================= MEMBER FUNCTIONS ======================= // --------------------------------------------------------------------------- @@ -104,8 +66,6 @@ ( TUint32 aIap, TRequestStatus* aStatus ) { LOGLIT( "CRoapConnection::ConnectL" ) - const TInt KAlwaysAskSelectionMode( 1 ); - const TInt KDestinationSelectionMode( 2 ); if ( iState == EInit ) { @@ -120,11 +80,9 @@ CleanupClosePushL( iConnection ); TConnectionInfoBuf connInfo; - TInt ap = 0; - TInt alwaysAsk = 0; - TUint count; + TUint count(0); User::LeaveIfError( iConnection.EnumerateConnections( count ) ); - TUint i; + TUint i(0); if ( count ) { // Select from existing connections. Try to make AP match. @@ -152,71 +110,44 @@ else { // No existing connections, create new one. -#ifdef __WINS__ - // WINS connection creation does not work if preferences are given. - // Defaults are to be used always. - iConnection.Start( iStatus ); -#else - // Note: the TCommDbConnPref must NOT be stack variable. - // It must persist until completion of RConnection::Start(). - iConnPref.SetDirection( ECommDbConnectionDirectionOutgoing ); - //iConnPref.SetDialogPreference( ECommDbDialogPrefWarn ) - iConnPref.SetBearerSet( ECommDbBearerCSD | ECommDbBearerWcdma ); - // New connection is always created with user-selected AP - // so 0 is used instead of aIap. + // Create overrides + TConnPrefList prefList; + TExtendedConnPref prefs; + + prefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent); - TInt defaultSnap( 0 ); - CRepository* repository( NULL ); - repository = CRepository::NewL( KCRUidBrowser ); - CleanupStack::PushL( repository ); - - repository->Get( KBrowserDefaultAccessPoint, ap); - repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk ); - repository->Get( KBrowserNGDefaultSnapId, defaultSnap ); - CleanupStack::PopAndDestroy( repository ); - repository = NULL; - - TUint32 iapd32 = 0; - TInt err = KErrNone; - - if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound ) + //Fetch default connection + TBool hasDefault(ETrue); + TCmDefConnValue defConn; + RCmManager cmManager; + cmManager.OpenLC(); + cmManager.ReadDefConnL(defConn); + if (defConn.iType == ECmDefConnConnectionMethod) { - alwaysAsk = KAlwaysAskSelectionMode; + prefs.SetIapId(defConn.iId); + } + else if (defConn.iType == ECmDefConnDestination) + { + prefs.SetSnapId(defConn.iId); } else { - RCmManager cmManager; - cmManager.OpenLC(); - if ( !alwaysAsk ) - { - TRAP( err, iapd32 = cmManager.GetConnectionMethodInfoIntL( - ap, CMManager::ECmIapId ) ); - } - else if ( alwaysAsk == KDestinationSelectionMode ) - { - TRAP( err, iapd32 = IapIdOfDefaultSnapL( - cmManager, defaultSnap ) ); - } - CleanupStack::PopAndDestroy( &cmManager ); + hasDefault = EFalse; } - - if ( err || alwaysAsk == KAlwaysAskSelectionMode ) + // End of fetch default connection + if (hasDefault) { - // Always ask - LOGLIT( "SetDialogPreference( ECommDbDialogPrefPrompt )" ) - iConnPref.SetDialogPreference( ECommDbDialogPrefPrompt ); - iapd32 = 0; + prefList.AppendL(&prefs); + + // Start an Outgoing Connection with overrides + iConnection.Start(prefList, iStatus); } else { - // User defined - LOGLIT( "SetDialogPreference( ECommDbDialogPrefDoNotPrompt )" ) - iConnPref.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); + // No default found --> trying with query + iConnection.Start(iStatus); } - - iConnPref.SetIapId( iapd32 ); - iConnection.Start( iConnPref, iStatus ); -#endif + CleanupStack::PopAndDestroy(&cmManager); iState = EConnecting; SetActive(); // The only path with a real async request. }