Revision: 201030 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 10:18:49 +0300
branchRCL_3
changeset 55 fc7b30ed2058
parent 54 984e13af52c4
child 57 05bc53fe583b
Revision: 201030 Kit: 201033
accesspointcontrol/apcontrollistplugin/inc/apcontrollistapiwrapper.h
accesspointcontrol/apcontrollistplugin/src/apcontrollistapiwrapper.cpp
apengine/apsettingshandlerui/inc/ApSelPopupList.h
apengine/apsettingshandlerui/src/ApSelPopupList.cpp
bearermanagement/S60MCPR/src/s60mpmrequests.cpp
bearermanagement/mpm/group/mpmserver.mmp
bearermanagement/mpm/inc/mpmconnpermquerytimer.h
bearermanagement/mpm/inc/mpmdatausagewatcher.h
bearermanagement/mpm/inc/mpmexpirytimer.h
bearermanagement/mpm/inc/mpmexpirytimercallback.h
bearermanagement/mpm/inc/mpmiapselection.h
bearermanagement/mpm/inc/mpmlogger.h
bearermanagement/mpm/inc/mpmserver.h
bearermanagement/mpm/inc/mpmserver.inl
bearermanagement/mpm/inc/mpmserversession.h
bearermanagement/mpm/src/mpmconfirmdlgstarting.cpp
bearermanagement/mpm/src/mpmconnpermquerytimer.cpp
bearermanagement/mpm/src/mpmdatausagewatcher.cpp
bearermanagement/mpm/src/mpmdisconnectdlg.cpp
bearermanagement/mpm/src/mpmexpirytimer.cpp
bearermanagement/mpm/src/mpmiapselection.cpp
bearermanagement/mpm/src/mpmserver.cpp
bearermanagement/mpm/src/mpmserversession.cpp
cmmanager/cmmgr/Framework/BWinsCw/CmManager_prot_setupU.DEF
cmmanager/cmmgr/Framework/EABI/CmManager_prot_setupU.def
cmmanager/cmmgr/Framework/Inc/cmconnselectrbpage.h
cmmanager/cmmgr/Framework/Inc/cmsettingsuiimpl.h
cmmanager/cmmgr/Framework/Src/ccmpluginbaseeng.cpp
cmmanager/cmmgr/Framework/Src/cmconnselectrbpage.cpp
cmmanager/cmmgr/Framework/Src/cmdlg.cpp
cmmanager/cmmgr/Framework/Src/cmmanagerimpl.cpp
cmmanager/cmmgr/Framework/Src/cmsettingsui.cpp
cmmanager/cmmgr/Framework/Src/cmsettingsuiimpl.cpp
cmmanager/cmmgr/Framework/Src/uncatdlg.cpp
cmmanager/cmmgr/Framework/conf/cmmanager.confml
cmmanager/cmmgr/Framework/conf/cmmanager_10207376.crml
cmmanager/cmmgr/Plugins/cmpluginvpn/src/cmpluginvpn.cpp
connectionmonitoring/connectionmonitorui/inc/ConnectionInfoBase.h
connectionmonitoring/connectionmonitorui/src/ConnectionInfoBase.cpp
connectionmonitoring/connectionmonitorui/src/CsdConnectionInfo.cpp
connectionmonitoring/connectionmonitorui/src/EasyWLANConnectionInfo.cpp
connectionmonitoring/connectionmonitorui/src/GprsConnectionInfo.cpp
connectionmonitoring/connectionmonitorui/src/WlanConnectionInfo.cpp
connectionmonitoring/connmon/connectionmonitor/group/ConnMon.mmp
connectionmonitoring/connmon/connectionmonitor/inc/ConnMonDef.h
connectionmonitoring/connmon/connectionmonitor/inc/ConnMonIAP.h
connectionmonitoring/connmon/connectionmonitor/inc/ConnMonNoti.h
connectionmonitoring/connmon/connectionmonitor/inc/ConnMonServ.h
connectionmonitoring/connmon/connectionmonitor/inc/cellulardatausagekeyupdater.h
connectionmonitoring/connmon/connectionmonitor/inc/connmondialupoverridenotifier.h
connectionmonitoring/connmon/connectionmonitor/src/CPsdFax.cpp
connectionmonitoring/connmon/connectionmonitor/src/ConnMonIAP.cpp
connectionmonitoring/connmon/connectionmonitor/src/ConnMonNoti.cpp
connectionmonitoring/connmon/connectionmonitor/src/ConnMonServ.cpp
connectionmonitoring/connmon/connectionmonitor/src/cellulardatausagekeyupdater.cpp
connectionmonitoring/connmon/connectionmonitor/src/connmondialupoverridenotifier.cpp
connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp
connectionutilities/ConnectionDialogs/group/CConnDlgPlugin.mmp
data/cccccc00_emulator.cre
inc/meshpreface1.cfg
ipcm_plat/connection_monitor_extension_api/group/bld.inf
ipcm_plat/connection_monitor_extension_api/inc/connectionmonitorpskeys.h
ipcm_plat/extended_connection_settings_api/inc/cmmanagerkeys.h
ipcm_plat/extended_connection_settings_api/inc/cmsettingsui.h
--- a/accesspointcontrol/apcontrollistplugin/inc/apcontrollistapiwrapper.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/accesspointcontrol/apcontrollistplugin/inc/apcontrollistapiwrapper.h	Thu Aug 19 10:18:49 2010 +0300
@@ -133,6 +133,10 @@
         * Handles asynchronous function completion 
         */
 		void RunL(); 
+		/** 
+		* Shows SIM card error note in error cases
+		*/
+		void ShowSimCardErrorNoteL();
 		
 	private:
         // New functions
@@ -196,6 +200,12 @@
         */
 		void FinishReadDataL();
 		
+	    /**
+	     * From CActive, handles leaves from RunL.
+	     * @param aLeaveCode The leave code.
+	     */
+	    TInt RunError( TInt aLeaveCode );
+		
 	private: // Data
 		
         //@var reference to the view
@@ -233,6 +243,8 @@
 		TUint32 						iSize;
         //@var index of item currently read from the ACL list 
 		TUint32 						iIndex;
+		
+		TBool                           iSimCardError;
 	} ;
 
 #endif
--- a/accesspointcontrol/apcontrollistplugin/src/apcontrollistapiwrapper.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/accesspointcontrol/apcontrollistplugin/src/apcontrollistapiwrapper.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -43,7 +43,8 @@
 							CAPControlListPlugin& aPlugin, TInt aPriority ) : 
 											CActive( aPriority ), 
 											iPlugin(aPlugin),
-											iApnPKG(iApn)
+											iApnPKG(iApn),
+											iSimCardError( EFalse )
 	{
 	CActiveScheduler::Add( this ); 
 	}
@@ -200,28 +201,23 @@
 //
 void CAPControlListAPIWrapper::RunL()
 	{
-	if ( iStatus != KErrNone )
-		{
-		CLOG( ( ESelector, 0, _L( "Bad RequestStatus: %d for request: %d" ), 
-													iStatus.Int(), iRequest) );	    
+    CLOG( ( ESelector, 0, _L( "RequestStatus: %d for request: %d" ), 
+                                                iStatus.Int(), iRequest) );     
 
-		// KErrOverflow can occur during APN adding process, if the APN list is full
-		// or there is no space for an additional entry in SIM card.
-	    if( iStatus.Int() == KErrOverflow && iRequest == EAddAPN)
-	        {
-            HBufC* text = StringLoader::LoadLC ( 
-                R_QTN_ACL_ERR_SIM_CARD );
-            CAknErrorNote* note = new ( ELeave ) CAknErrorNote(
-                 ETrue );
-            note->ExecuteLD( *text );
+    // If there happens an error show error note and set this sw to error
+    // state --> does not accept any operations but closing.
+	if ( iStatus.Int() != KErrNone )
+		{
+        ShowSimCardErrorNoteL();
 
-            CleanupStack::PopAndDestroy( text );
-	        }
-	    
+        iSimCardError = ETrue;
 	    iRequest = ENoRequest;  
 
 		return;
 		}
+	
+	iSimCardError = EFalse;
+	
 	switch(iRequest)
 	{
 	case EGetACLStatus:
@@ -367,7 +363,7 @@
 // ---------------------------------------------------------
 void CAPControlListAPIWrapper::EnumerateAPN() 
     {
-    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::ReadData" ) ) );
+    CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::EnumerateAPN" ) ) );
 	if( !IsActive() )
 		{
 		iRequest = EEnumerateAPN;			
@@ -375,7 +371,7 @@
 		iPhone.EnumerateAPNEntries(iStatus, iSize);
 		SetActive();
 		}    
-    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::ReadData" ) ) );
+    CLOG( ( ESelector, 0, _L( "<- CAPControlListAPIWrapper::EnumerateAPN" ) ) );
     }
     
 // ---------------------------------------------------------
@@ -386,6 +382,13 @@
     {   	
     CLOG( ( ESelector, 0, _L( 
     			"-> CAPControlListAPIWrapper::DeActivateACLL" ) ) );
+    
+    // Check if in error state
+    if ( iSimCardError )
+        {
+        ShowSimCardErrorNoteL();
+        return;
+        }
 	if (iSecurityChecked)
 		{
 		SetACLStatus( RMobilePhone::EAPNControlListServiceDisabled );
@@ -407,6 +410,13 @@
     {   	
     CLOG( ( ESelector, 0, _L( 
     			"-> CAPControlListAPIWrapper::ActivateACLL" ) ) );
+
+    // Check if in error state
+    if ( iSimCardError )
+        {
+        ShowSimCardErrorNoteL();
+        return;
+        }
 	if (iSecurityChecked)
 		{
 		SetACLStatus( RMobilePhone::EAPNControlListServiceEnabled );
@@ -429,6 +439,14 @@
     {   	
     CLOG( ( ESelector, 0, 
     				_L( "-> CAPControlListAPIWrapper::SetACLStatus" ) ) );
+    
+    // Check if in error state
+    if ( iSimCardError )
+        {
+        ShowSimCardErrorNoteL();
+        return;
+        }
+
 	if( !IsActive() )
 		{
    		iPhone.SetAPNControlListServiceStatus( iStatus, 
@@ -456,6 +474,14 @@
 void CAPControlListAPIWrapper::RemoveAPN()
     {   	
     CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::RemoveAPNL" ) ) );
+    
+    // Check if in error state
+    if ( iSimCardError )
+        {
+        ShowSimCardErrorNoteL();
+        return;
+        }
+
     if( iPlugin.Container()->NumberOfItems() > 0)
         {
     	if (iSecurityChecked)
@@ -477,6 +503,14 @@
 void CAPControlListAPIWrapper::DoRemoveAPN()
     {   	
     CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::RemoveAPN2L" ) ) );
+    
+    // Check if in error state
+    if ( iSimCardError )
+        {
+        ShowSimCardErrorNoteL();
+        return;
+        }
+
 	if( !IsActive() )
 		{
 		TInt index = iPlugin.Container()->CurrentItemIndex();
@@ -494,6 +528,13 @@
 void CAPControlListAPIWrapper::AddAPNL()
     {   	
     CLOG( ( ESelector, 0, _L( "-> CAPControlListAPIWrapper::AddAPNL" ) ) );
+    
+    // Check if in error state
+    if ( iSimCardError )
+        {
+        ShowSimCardErrorNoteL();
+        return;
+        }
 	if (iSecurityChecked)
 		{
 		DoAddAPNL();
@@ -704,3 +745,30 @@
     CLOG( ( ESelector, 0, 
         _L( "<- CAPControlListAPIWrapper::CancelNotify" ) ) );
     }
+// ----------------------------------------------------------
+// CAPControlListPlugin::ShowSimCardErrorNoteL()
+// ----------------------------------------------------------
+//
+void CAPControlListAPIWrapper::ShowSimCardErrorNoteL()
+    {
+    HBufC* text = StringLoader::LoadLC ( 
+        R_QTN_ACL_ERR_SIM_CARD );
+    CAknErrorNote* note = new ( ELeave ) CAknErrorNote(
+         ETrue );
+    note->ExecuteLD( *text );
+
+    CleanupStack::PopAndDestroy( text );
+    }
+// -----------------------------------------------------------------------------
+// Handles the leave from the RunL()
+// -----------------------------------------------------------------------------
+//
+TInt CAPControlListAPIWrapper::RunError( TInt /*aLeaveCode*/ )
+    {
+    iSimCardError = ETrue;
+    iRequest = ENoRequest;  
+
+    return KErrNone;
+    }
+
+
--- a/apengine/apsettingshandlerui/inc/ApSelPopupList.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/apengine/apsettingshandlerui/inc/ApSelPopupList.h	Thu Aug 19 10:18:49 2010 +0300
@@ -337,6 +337,10 @@
         TBool							iHelpSupported;
         TBool							iProtectionSupported;
         TBool                           iDoExit;
+        TBool                           iFirstEnter;  // pressing the enter key
+                                                      // first time will be
+                                                      // handled as an uparrow 
+                                                      // key
     };
 
 #endif
--- a/apengine/apsettingshandlerui/src/ApSelPopupList.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/apengine/apsettingshandlerui/src/ApSelPopupList.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -243,7 +243,8 @@
 iVpnFilterType( aVpnFilterType ),
 iVariant( aHandler.iExt->iVariant ),
 iIncludeEasyWlan( EFalse ),
-iNoEdit( aNoEdit )
+iNoEdit( aNoEdit ),
+iFirstEnter( ETrue )
     {
     }
 
@@ -281,7 +282,8 @@
 iVariant( aHandler.iExt->iVariant ),
 iIncludeEasyWlan( aIncludeEasyWlan ),
 iInitialised( EFalse ),
-iNoEdit( aNoEdit )
+iNoEdit( aNoEdit ),
+iFirstEnter( ETrue )
     {
     }
 
@@ -837,11 +839,29 @@
                 ( ( iSelMenuType == EApSettingsSelMenuSelectOnly ) ||
                     ( iSelMenuType == EApSettingsSelMenuSelectNormal ) ) )
                 { // process only if command is available...
-                ProcessCommandL( EApSelCmdSelect );
-                retval = EKeyWasConsumed;
+                if ( aKeyEvent.iCode == EKeyEnter  &&  iFirstEnter )
+                    {//pressing the enter key at the first time will be changed
+                     //to an up arrow key so the first item in the list will be highlighted
+                    iFirstEnter = EFalse;
+                    iPreferredUid = 0;
+                    SetHighlighted();
+                    TKeyEvent aKeyEventmy = aKeyEvent;
+                    aKeyEventmy.iCode = EKeyUpArrow;
+                    retval = CAknRadioButtonSettingPage::OfferKeyEventL( aKeyEventmy, aType );
+                    }
+                else
+                    {
+                    iFirstEnter = ETrue; //change back to true for the next session
+                    ProcessCommandL( EApSelCmdSelect );
+                    retval = EKeyWasConsumed;
+                    }
                 }
             else
                 {
+                if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
+                    {//we will have highligt so the following enter key should select the item
+                    iFirstEnter = EFalse;
+                    }
                 retval = CAknRadioButtonSettingPage::OfferKeyEventL(
                                         aKeyEvent, aType );
                 }
--- a/bearermanagement/S60MCPR/src/s60mpmrequests.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/S60MCPR/src/s60mpmrequests.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -847,10 +847,15 @@
     // Asynchronous cancellation adds message to MPMServer's IPC queue but since we
     // queue all requests we can safely always call the SendCancelRequest()
     
+    // Sanity check.
+    S60MCPRLOGSTRING2( "S60MCPR::CMPMPolicyRequests<%x>::CancelRequest() %d", this, (TInt)aRequestCode )
+    if ( iPolicyRequests.Count() == 0 )
+        {
+        S60MCPRLOGSTRING1( "S60MCPR::CMPMPolicyRequests<%x>::CancelRequest(): Error: Nothing to cancel!", this )
+        return;
+        }
     // If the cancelled request is the active one.
-    //
-    S60MCPRLOGSTRING2( "S60MCPR::CMPMPolicyRequests<%x>::CancelRequest() %d", this, (TInt)aRequestCode )
-    if ( iPolicyRequests[0].iRequestType == aRequestCode )
+    else if ( iPolicyRequests[0].iRequestType == aRequestCode )
         {
         // Cancel the query if active
         //
@@ -877,7 +882,6 @@
             }
         }
     // Else we need to find it from the queue
-    //
     else 
         {
         S60MCPRLOGSTRING1( "S60MCPR::CMPMPolicyRequests<%x>::CancelRequest() Cancelling pending request", this )
--- a/bearermanagement/mpm/group/mpmserver.mmp	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/group/mpmserver.mmp	Thu Aug 19 10:18:49 2010 +0300
@@ -56,6 +56,8 @@
 SOURCE            mpmdialogbase.cpp
 SOURCE            mpmdatausagewatcher.cpp
 SOURCE            mpmofflinewatcher.cpp
+SOURCE            mpmexpirytimer.cpp
+SOURCE            mpmconnpermquerytimer.cpp
 
 USERINCLUDE       ../inc
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bearermanagement/mpm/inc/mpmconnpermquerytimer.h	Thu Aug 19 10:18:49 2010 +0300
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Declaration of class CMPMConnPermQueryTimer.
+*
+*/
+
+#ifndef MPMCONNPERMQUERYTIMER_H
+#define MPMCONNPERMQUERYTIMER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include "mpmexpirytimercallback.h"
+
+class CMPMServer;
+class CMPMExpiryTimer;
+
+/**
+* Class that implements Connection permission query's cancellation delay timer
+* and callback.
+* @since 5.2
+*/
+class CMPMConnPermQueryTimer : public CBase, public MMPMExpiryTimerCallback
+    {
+
+public:
+
+    /**
+    * New for calling the two-phased constructor.
+    * @since 5.2
+    * @param aServer Pointer to the MPM server object, for callback purposes    
+    * @return Pointer to created object instance
+    */
+    static CMPMConnPermQueryTimer* NewL( CMPMServer* aServer );
+
+    /**
+    * Destructor.
+    * @since 5.2
+    */
+    virtual ~CMPMConnPermQueryTimer();
+
+    /**
+    * Start the timer.
+    * @since 5.2
+    */
+    void StartTimer();
+
+    /**
+    * Dialog expiration timeout callback, inherited from MMPMExpiryTimerCallback.
+    * @since 5.2
+    */
+    void HandleTimedOut();
+    
+private:
+
+    /**
+    * C++ default constructor.
+    * @since 5.2
+    * @param aServer Pointer to the MPM server object, for callback purposes    
+    */
+    CMPMConnPermQueryTimer( CMPMServer* aServer );
+
+    /**
+    * Symbian 2nd phase constructor.
+    * @since 5.2
+    */
+    void ConstructL();
+
+
+private: // data
+
+    /**
+    * Pointer to the MPM Server object. Not own.
+    */
+    CMPMServer* iServer;
+    
+    /**
+    * Pointer to the common MPM expiry timer object.
+    */
+    CMPMExpiryTimer* iExpiryTimer;
+
+    /**
+    * Timeout constant.
+    */
+    static const TInt KTimeout = 10000000; // 10 sec
+
+    };
+
+#endif // MPMCONNPERMQUERYTIMER_H
--- a/bearermanagement/mpm/inc/mpmdatausagewatcher.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/inc/mpmdatausagewatcher.h	Thu Aug 19 10:18:49 2010 +0300
@@ -61,6 +61,12 @@
     * Active object's DoCancel.
     */
     void DoCancel();
+    
+    /**
+    * Current cellular data usage.
+    * See TCmCellularDataUsage
+    */
+    TInt CellularDataUsage() const;
 
 private:
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bearermanagement/mpm/inc/mpmexpirytimer.h	Thu Aug 19 10:18:49 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of class CMPMExpiryTimer.
+*
+*/
+
+#ifndef MPMEXPIRYTIMER_H
+#define MPMEXPIRYTIMER_H
+
+// INCLUDES
+#include <e32base.h>  
+#include <e32std.h>		
+
+#include "mpmexpirytimercallback.h"
+
+/**
+* Class that implements simple microsecond timer and callback.
+* @since 5.2
+*/
+NONSHARABLE_CLASS( CMPMExpiryTimer ): public CTimer
+    {
+public:
+
+    /**
+    * New for calling the two-phased constructor.
+    * @since 5.2
+    * @param aCallback Pointer to the class where callback goes    
+    * @param aTimeout Timeout value in microseconds
+    * @return Pointer to created object instance
+    */
+    static CMPMExpiryTimer* NewL( MMPMExpiryTimerCallback& aCallback,
+            TInt aTimeout);  
+    
+    /**
+    * Starts up the timer.
+    * @since 5.2
+    */
+    void Start();
+    
+private:
+    /**
+    * C++ constructor.
+    * @since 5.2
+    * @param aCallback Pointer to the class where callback goes
+    * @param aTimer Timeout value in microseconds
+    */
+    CMPMExpiryTimer( MMPMExpiryTimerCallback& aCallback,
+            TInt aTimeout );
+
+    /**
+    * ConstructL.       
+    * @since 5.2
+    */
+    void ConstructL();
+
+    /**
+    * RunL. Inherited from CTimer.       
+    * @since 5.2
+    */
+    void RunL();
+
+private:
+    /**
+    * Callback reference.
+    */
+    MMPMExpiryTimerCallback& iCallback;
+    
+    /**
+    * Timeout value in microseconds.
+    */
+    TInt iTimeout;
+    };
+
+#endif // MPMEXPIRYTIMER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bearermanagement/mpm/inc/mpmexpirytimercallback.h	Thu Aug 19 10:18:49 2010 +0300
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of class MMPMExpiryTimerCallback.
+*
+*/
+
+#ifndef MPMEXPIRYTIMERCALLBACK_H
+#define MPMEXPIRYTIMERCALLBACK_H
+
+// INCLUDES
+#include <e32std.h>
+
+/**
+* Callback class for timer expiration.
+* @since 5.2
+*/
+class MMPMExpiryTimerCallback
+    {
+public:
+    /**
+    * Callback function for handling the timeout.
+    * @since 5.2
+    */
+    virtual void HandleTimedOut() = 0;
+    };
+
+#endif // MPMEXPIRYTIMERCALLBACK_H
--- a/bearermanagement/mpm/inc/mpmiapselection.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/inc/mpmiapselection.h	Thu Aug 19 10:18:49 2010 +0300
@@ -269,6 +269,12 @@
      */
     void ImplicitConnectionWlanNoteL();
     
+    /**
+     * Gets current cellular data usage setting
+     * @since 5.2
+     */
+    TInt CurrentCellularDataUsage() const;
+    
 private:
 
     /**
--- a/bearermanagement/mpm/inc/mpmlogger.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/inc/mpmlogger.h	Thu Aug 19 10:18:49 2010 +0300
@@ -138,4 +138,4 @@
 
 #endif // MPMLOGGER_H
 
-// End of File
\ No newline at end of file
+// End of File
--- a/bearermanagement/mpm/inc/mpmserver.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/inc/mpmserver.h	Thu Aug 19 10:18:49 2010 +0300
@@ -33,6 +33,7 @@
 #include "mpmcommon.h"
 #include "rmpm.h"
 #include "mpmroamingwatcher.h"
+#include "mpmdatausagewatcher.h"
 
 
 class CMPMCommsDatAccess;
@@ -48,6 +49,9 @@
 //
 const TInt    KPhoneRetryTimeout = 100000;
 
+const TUint32 KMaxOpenTransAttempts = 5;
+const TUint32 KRetryAfter = 200000;
+
 // The granularity with which iDisconnectQueue will allocate memory chunks. 
 // If set to two there will be space for two instances of CMPMDisconnectDlg
 // before new memory will be allocated.
@@ -61,6 +65,10 @@
 // roaming to connected wlan wait interval
 // in micro seconds (10 sec)
 const TInt KRoamingToWlanUpdateInterval = 10000000; 
+
+// roaming to connected hotspot wlan wait interval
+// in micro seconds (120 sec)                    
+const TInt KRoamingToHotspotWlanUpdateInterval = 120000000; 
  
 //Definition of the ranges of IPC numbers
 const TInt KMPMPolicyRanges[KMPMPolicyRangeCount] = 
@@ -192,6 +200,7 @@
 class CMPMDefaultConnection;
 class CMPMWlanQueryDialog;
 class CMPMDialog;
+class CMPMConnPermQueryTimer;
 
 // CLASS DECLARATION
 /**
@@ -469,6 +478,21 @@
         void UpdateSessionConnectionDlgL();
 
         /**
+        * Completes pending messages
+        * @since 5.2
+        * @param aIapId IAP Id of the connection.
+        * @param aError Message status
+        * @param aErrorReturned Error value to be returned, NULL if no 
+        * value should be passed
+        * @param aNeededAction Needed action to be returned, NULL if no 
+        * value should be passed
+        */
+        void HandlePendingMsgs( TUint aIapId,
+                                TInt aError,
+                                TInt* aErrorReturned,
+                                TBMNeededAction* aNeededAction );
+
+        /**
         * Handling of blacklisting certain IAP and the presumed IAP for 
         * the certain connection.
         * @since 3.1
@@ -731,6 +755,15 @@
         static TInt StartForcedRoamingToConnectedWlanL( TAny* aUpdater );
         
         /**
+        * Starts forced roaming sequence to connected hotspot wlan
+        *
+        * @param aIapInfo Info about available IAPs
+        * @return Always zero...
+        * @since 5.2
+        */
+        static TInt StartForcedRoamingToConnectedHotspotWlanL( TAny* aUpdater );
+
+        /**
         * Starts forced roaming sequence from WLAN if necessary
         *
         * @param aIapInfo Info about available IAPs
@@ -753,7 +786,14 @@
 		* @return RoamingWatcher pointer
         */
         inline CMPMRoamingWatcher* RoamingWatcher() const;
-        
+
+         /**
+        * Returns the DataUsageWatcher pointer
+        *
+        * @since 5.2
+        * @return DataUsageWatcher pointer
+        */
+        inline CMpmDataUsageWatcher* DataUsageWatcher() const;        
         
         
     public: // Functions from base classes
@@ -873,9 +913,10 @@
         
         /**
         * Stops cellular connections, except MMS
+        * @param aSilentOnly stop only silent cellular connections
         * @since 5.2
         */
-        void StopCellularConns();
+        void StopCellularConns( TBool aSilentOnly = EFalse );
 
         /**
         * Offline mode watcher updates the mode variable stored by MPM server.
@@ -905,6 +946,27 @@
         */
         void SetOfflineWlanQueryResponse( TOfflineWlanQueryResponse aResponse);
 
+        /**
+        * Starts the connection permission query timer.
+        * During the timer, no connection permission query can be initiated.
+        * @since 5.2
+        */
+        void StartConnPermQueryTimer();
+
+        /**
+        * Resets the connection permission query timer.
+        * @since 5.2
+        */
+        void ResetConnPermQueryTimer();
+
+        /**
+        * Returns true if the connection permission query timer is running.
+        * During the timer, no connection permission query can be initiated.
+        * @since 5.2
+        * @return ETrue if timer is running, EFalse otherwise.
+        */
+        TBool IsConnPermQueryTimerOn();
+
     private:
 
         /**
@@ -933,6 +995,12 @@
                                 TBool aCheckForBestIap,
                                 TMPMBearerType aDestinationBearerType );
         
+        /**
+         * Check if iap can be disconnected, and disconnect it
+         * @since 5.2
+         * @param aIapId Iap id for checking
+         */
+        void CheckIapForDisconnect( TInt aIapId );
 
     private: // Data
         // Pointer to the ConnMonEvents object
@@ -1042,9 +1110,15 @@
         
         // Timer to start roaming to connected WLAN network 
         CPeriodic* iRoamingToWlanPeriodic;
-
+        
+        // Timer to start roaming to connected WLAN network 
+        CPeriodic* iRoamingToHotspotWlanPeriodic;
+        
         // TConnMonIapInfo Info about available IAPs
         TConnMonIapInfo iConnMonIapInfo;
+        
+        // Connection permission query cancellation delay timer
+        CMPMConnPermQueryTimer* iConnPermQueryTimer;
     };
 
 #include "mpmserver.inl"
--- a/bearermanagement/mpm/inc/mpmserver.inl	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/inc/mpmserver.inl	Thu Aug 19 10:18:49 2010 +0300
@@ -267,4 +267,13 @@
     return iRoamingWatcher;
     }
 
+// -----------------------------------------------------------------------------
+// CMPMServer::DataUsageWatcher()
+// -----------------------------------------------------------------------------
+//
+CMpmDataUsageWatcher* CMPMServer::DataUsageWatcher() const
+    {
+    return iMpmDataUsageWatcher;
+    }
+
 // End of File
--- a/bearermanagement/mpm/inc/mpmserversession.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/inc/mpmserversession.h	Thu Aug 19 10:18:49 2010 +0300
@@ -957,6 +957,10 @@
         // showing duplicate cellulara data usage dialog
         //
         TBool iDisconnectDialogShown;
+        
+        // Set when error discreet popup shown for IAP so it is
+        // not shown again if the SNAP is empty
+        TBool iErrorDiscreetPopupShown;
     };
 
 #include "mpmserversession.inl"
--- a/bearermanagement/mpm/src/mpmconfirmdlgstarting.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/src/mpmconfirmdlgstarting.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -195,6 +195,9 @@
     {
     MPMLOGSTRING3( "CMPMConfirmDlgStarting<0x%x>::UserSelectedCancel:\
  Complete %d", iConnId, aError )
+    // User cancelled the connection permission query,
+    // don't try again until the timer expires.
+    iServer.StartConnPermQueryTimer();
     iIapSelection.ChooseIapComplete( aError, NULL );
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bearermanagement/mpm/src/mpmconnpermquerytimer.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Implementation of class CMPMConnPermQueryTimer.
+ * This timer is used for preventing excessive connection permission queries,
+ * when the used has cancelled the previous connection permission query.
+ *
+ */
+
+#include "mpmlogger.h"
+#include "mpmserver.h"
+#include "mpmexpirytimer.h"
+#include "mpmconnpermquerytimer.h"
+
+// ---------------------------------------------------------------------------
+// Creates a new object by calling the two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CMPMConnPermQueryTimer* CMPMConnPermQueryTimer::NewL( CMPMServer* aServer )
+    {
+    MPMLOGSTRING( "CMPMConnPermQueryTimer::NewL" )
+            
+    CMPMConnPermQueryTimer* self = new( ELeave ) CMPMConnPermQueryTimer( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Default C++ constructor.
+// ---------------------------------------------------------------------------
+//
+CMPMConnPermQueryTimer::CMPMConnPermQueryTimer( CMPMServer* aServer ) :
+    iServer( aServer )
+    {
+    MPMLOGSTRING( "CMPMConnPermQueryTimer::CMPMConnPermQueryTimer" )
+    }
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor.
+// ---------------------------------------------------------------------------
+//
+void CMPMConnPermQueryTimer::ConstructL()
+    {
+    MPMLOGSTRING( "CMPMConnPermQueryTimer::ConstructL" )
+    iExpiryTimer = CMPMExpiryTimer::NewL( *this, KTimeout );
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CMPMConnPermQueryTimer::~CMPMConnPermQueryTimer()
+    {
+    MPMLOGSTRING( "CMPMConnPermQueryTimer::~CMPMConnPermQueryTimer" )
+    if ( iExpiryTimer )
+        {
+        iExpiryTimer->Cancel();
+        delete iExpiryTimer;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Start the timer.
+// ---------------------------------------------------------------------------
+//
+void CMPMConnPermQueryTimer::StartTimer()
+    {
+    MPMLOGSTRING( "CMPMConnPermQueryTimer::StartTimer" )
+    if ( iExpiryTimer )
+        {
+        iExpiryTimer->Cancel();
+        iExpiryTimer->Start();    
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Handles the timeout.
+// ---------------------------------------------------------------------------
+//
+void CMPMConnPermQueryTimer::HandleTimedOut()
+    {
+    MPMLOGSTRING( "CMPMConnPermQueryTimer::HandleTimedOut" )
+    iServer->ResetConnPermQueryTimer();
+    }
--- a/bearermanagement/mpm/src/mpmdatausagewatcher.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/src/mpmdatausagewatcher.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -118,15 +118,24 @@
         // Get the new Cellular data usage setting value from central repository.
         TInt oldCellularDataUsage = iCellularDataUsage;
 
-        if ( GetCurrentDataUsageValue() == KErrNone )
+        if ( GetCurrentDataUsageValue() == KErrNone // Updates iCellularDataUsage
+             && oldCellularDataUsage != iCellularDataUsage
+             && iServer->RoamingWatcher()->RoamingStatus() != EMPMRoamingStatusUnknown )
             {
-            // Stop cellular connections if the setting changes into Disabled.
-            if ( oldCellularDataUsage != ECmCellularDataUsageDisabled &&
-                    iCellularDataUsage == ECmCellularDataUsageDisabled &&
-                    iServer->RoamingWatcher()->RoamingStatus() != EMPMRoamingStatusUnknown )
+            // Setting changed while cellular is in use
+
+            if ( iCellularDataUsage == ECmCellularDataUsageDisabled )
                 {
+                // Cellular data usage disabled -> disconnect cellular
                 iServer->StopCellularConns();
                 }
+            else if ( iCellularDataUsage == ECmCellularDataUsageConfirm )
+                {
+                // Cellular data usage needs to be confirmed -> disconnect if 
+                // there are only silent cellular connections left.
+                iServer->StopCellularConns( ETrue );
+                }
+
             }
         }
     
@@ -182,3 +191,12 @@
         }
     return err;
     }
+
+// -----------------------------------------------------------------------------
+// CMpmDataUsageWatcher::CellularDataUsage
+// -----------------------------------------------------------------------------
+//
+TInt CMpmDataUsageWatcher::CellularDataUsage() const
+    {
+    return iCellularDataUsage;
+    }
--- a/bearermanagement/mpm/src/mpmdisconnectdlg.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/src/mpmdisconnectdlg.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -118,9 +118,18 @@
     MPMLOGSTRING( "CMPMDisconnectDlg::UserSelectedOk: \
 Tell BM to ignore error and do reselection" )
 
-    TBMNeededAction neededAction( EDoReselection );
     TInt error = aError;
 
+    // Get the current connection IapId for this connId 
+    TUint32 iapId = iSession.MyServer().GetBMIap( iSession.ConnectionId() );
+    
+    TBMNeededAction neededActionForPendingMsgs( EIgnoreError );
+    iSession.MyServer().HandlePendingMsgs( iapId, 
+                                           KErrNone,
+                                           &error,
+                                           &neededActionForPendingMsgs );
+										   
+    TBMNeededAction neededAction( EDoReselection );
     iSession.ProcessErrorComplete( KErrNone,
                                    &error,
                                    &neededAction );
@@ -157,6 +166,10 @@
     TConnectionState state;
     iSession.MyServer().GetConnectionState( connId, state );
 
+    // Get the current connection IapId for this connId 
+    //
+    TUint32 currentIap = iSession.MyServer().GetBMIap( connId );
+
     if ( state == EStarting )
         {
         MPMLOGSTRING2( "CMPMDisconnectDlg::UserSelectedCancelL: \
@@ -173,10 +186,6 @@
         iSession.StoredIapInfo().ResetStoredIapInfo();
         neededAction = EIgnoreError;
 
-        // Get the current connection IapId for this connId 
-        //
-        TUint32 currentIap = iSession.MyServer().GetBMIap( connId );
-
         TConnMonIapInfo availableIAPs;
         availableIAPs = iSession.GetAvailableIAPs();
 
@@ -208,6 +217,11 @@
 Unsupported state %d", state )
         }
 
+    iSession.MyServer().HandlePendingMsgs( currentIap,
+                                           KErrNone,
+                                           errorPtr,
+                                           &neededAction );
+
     iSession.ProcessErrorComplete( KErrNone,
                                    errorPtr,
                                    &neededAction );
@@ -229,8 +243,13 @@
         "CMPMDisconnectDlg::RunError: RunL made a leave with error = %i", 
         aError )
 
+    // Get the current connection IapId for this connId 
+    TUint32 iapId = iSession.MyServer().GetBMIap( iSession.ConnectionId() );
+
+    iSession.MyServer().HandlePendingMsgs( iapId, aError, NULL, NULL );
+
     iSession.ProcessErrorComplete( aError, NULL, NULL );
-
+	
     // Return KErrNone to prevent panic 
     // 
     return KErrNone;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bearermanagement/mpm/src/mpmexpirytimer.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of class CMPMExpiryTimer, a common timer class for MPM.
+*
+*/
+
+#include "mpmexpirytimer.h"
+#include "mpmexpirytimercallback.h"
+
+// ---------------------------------------------------------------------------
+// Constructs and returns the class object.
+// ---------------------------------------------------------------------------
+//
+CMPMExpiryTimer* CMPMExpiryTimer::NewL( MMPMExpiryTimerCallback& aCallback, TInt aTimeout )
+    {
+    CMPMExpiryTimer* self = new( ELeave ) CMPMExpiryTimer( aCallback, aTimeout );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Default C++ constructor.
+// ---------------------------------------------------------------------------
+//
+
+CMPMExpiryTimer::CMPMExpiryTimer( MMPMExpiryTimerCallback& aCallback, TInt aTimeout ):
+        CTimer( CActive::EPriorityStandard ),
+        iCallback( aCallback ),
+        iTimeout( aTimeout )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor.
+// ---------------------------------------------------------------------------
+//
+
+void CMPMExpiryTimer::ConstructL()
+    {
+    CTimer::ConstructL();        
+    }
+
+// ---------------------------------------------------------------------------
+// RunL, from CTimer, starts up the timer.
+// ---------------------------------------------------------------------------
+//
+
+void CMPMExpiryTimer::Start()
+    {
+    After( iTimeout );
+    }
+
+// ---------------------------------------------------------------------------
+// RunL, from CTimer, called when the timer expires.
+// ---------------------------------------------------------------------------
+//
+
+void CMPMExpiryTimer::RunL()
+    {
+    iCallback.HandleTimedOut();
+    }
--- a/bearermanagement/mpm/src/mpmiapselection.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/src/mpmiapselection.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -154,10 +154,13 @@
         MPMLOGSTRING2( "CMPMIapSelection::ChooseIapL: bearerType: %i", bearerType )
 
         // Complete selection with error code if wlan only was set and cellular IAP other 
-        // than MMS IAP was tried to access  
-        if ( wlanOnly && 
-                ( bearerType == EMPMBearerTypePacketData ) && 
-                ( iSession->IsMMSIap( iChooseIapPref.IapId() ) == EFalse ) ) 
+        // than MMS IAP was tried to access
+        // Note that CurrentCellularDataUsage()tells if internal cellular connections are 
+        // temporarily disabled because dial-up connection is prioritized over internal connections.
+        // 
+        if ( ( wlanOnly || CurrentCellularDataUsage() == ECmCellularDataUsageDisabled ) && 
+             ( bearerType == EMPMBearerTypePacketData ) && 
+             ( iSession->IsMMSIap( iChooseIapPref.IapId() ) == EFalse ) ) 
             {            
             ChooseIapComplete( KErrPermissionDenied, NULL );
             return;
@@ -379,8 +382,10 @@
                 // to the user in this country
                 if ( iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
                     {
-                    // Check whether queries are enabled
-                    if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) )
+                    // Check that queries aren't disabled and
+                    // enough time has elapsed from the last query cancelled by the user.
+                    if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
+                            !iSession->MyServer().IsConnPermQueryTimerOn() )
                         {
                         TConnectionId connId = iSession->ConnectionId();
                                                             
@@ -532,8 +537,10 @@
              ( iSession->MyServer().CommsDatAccess()->CheckWlanL( validateIapId ) == ENotWlanIap ) &&
              !( iSession->MyServer().CommsDatAccess()->IsVirtualIapL( validateIapId ) ) )
             {
-            // Check whether queries are disabled
-            if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) )
+            // Check that queries aren't disabled and
+            // enough time has elapsed from the last query cancelled by the user.
+            if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
+                    !iSession->MyServer().IsConnPermQueryTimerOn() )
                 {
                 if ( iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
                     {
@@ -922,8 +929,10 @@
             // to the user in this country
             if ( iSession->MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
                 {
-                // Check whether queries are enabled
-                if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) )
+                // Check that queries aren't disabled and
+                // enough time has elapsed from the last query cancelled by the user.
+                if ( !( iChooseIapPref.NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
+                        !iSession->MyServer().IsConnPermQueryTimerOn() )
                     {
                     TConnectionId connId = iSession->ConnectionId();
                                                                     
@@ -1283,3 +1292,11 @@
     return iChooseIapPref;
     }
 
+// ---------------------------------------------------------------------------
+// Get current cellular data usage setting
+// ---------------------------------------------------------------------------
+//
+TInt CMPMIapSelection::CurrentCellularDataUsage() const
+    {
+    return iSession->MyServer().DataUsageWatcher()->CellularDataUsage();
+    }
--- a/bearermanagement/mpm/src/mpmserver.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/src/mpmserver.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -46,6 +46,7 @@
 #include "mpmdatausagewatcher.h"
 #include "mpmpropertydef.h"
 #include "mpmofflinewatcher.h"
+#include "mpmconnpermquerytimer.h"
 
 // ============================= LOCAL FUNCTIONS ===============================
 
@@ -292,6 +293,10 @@
         }
         
     PublishActiveConnection();
+    
+    iRoamingToWlanPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
+    iRoamingToHotspotWlanPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
+            
     }
 
 
@@ -306,6 +311,11 @@
         iRoamingToWlanPeriodic->Cancel();
 		delete iRoamingToWlanPeriodic;
         }
+    if ( iRoamingToHotspotWlanPeriodic )
+        {
+        iRoamingToHotspotWlanPeriodic->Cancel();
+        delete iRoamingToHotspotWlanPeriodic;
+        }
     if ( iDisconnectQueue )
         {
         iDisconnectQueue->ResetAndDestroy();
@@ -368,7 +378,9 @@
 
     iDedicatedClients.Close();
 
-    delete iCommsDatAccess;    
+    delete iCommsDatAccess;
+    
+    delete iConnPermQueryTimer;
     }
 
 
@@ -431,19 +443,13 @@
         "CMPMServer::AppendBMConnection - aConnId = 0x%x, aSnap = %i",
         aConnId, aSnap )
 
-    // Set the Connection Id, SNAP, Iap Id and connection state
-    // 
-    TConnectionInfo connInfo;
-    connInfo.iConnId = aConnId;
-    connInfo.iSnap   = aSnap;
-    connInfo.iIapId  = aIapId;
-    connInfo.iState  = aState;
-    connInfo.iAppUid = aSession.AppUid();
-
-    // Package into TActiveBMConn //TODO Redundant.. remove the other one.
-    // 
+    // Set the Connection Id, SNAP, Iap Id and connection state, into TActiveBMConn
     TActiveBMConn conn;
-    conn.iConnInfo          = connInfo;
+    conn.iConnInfo.iConnId = aConnId;
+    conn.iConnInfo.iSnap   = aSnap;
+    conn.iConnInfo.iIapId  = aIapId;
+    conn.iConnInfo.iState  = aState;
+    conn.iConnInfo.iAppUid = aSession.AppUid();
 
     TInt index1 = iActiveBMConns.Find( conn, TActiveBMConn::MatchConnInfo );
 
@@ -547,32 +553,33 @@
     MPMLOGSTRING2( "CMPMServer::RemoveBMConnection - aConnId = 0x%x", 
         aConnId )
 
-    TInt count = iActiveBMConns.Count();
-    
-    // Decrement by one, because count is n, 
-    // but indexes in array are 0 .. n-1.
-    // 
-    count--;
-
     // This time we are browsing the array from the end to the beginning, 
     // because removing one element from array affects index numbering.
-    // 
-    for ( TInt i = count; i >= 0; i-- )
+    // Decrement i by one, because count is n, but indexes in array are 0 .. n-1
+    for ( TInt i = iActiveBMConns.Count() - 1; i >= 0; i-- )
         {
         if ( iActiveBMConns[i].iConnInfo.iConnId == aConnId )
             {
+            
+            TInt closeIapId = iActiveBMConns[i].iConnInfo.iIapId;
+            if ( !closeIapId )
+                {
+                TRAP_IGNORE( closeIapId = aSession.IapSelectionL()->MpmConnPref().IapId() );
+                }
+
             // If Connection Id found, remove it. 
-            //
             iActiveBMConns.Remove( i );
-
+            
             // Update active connection
             if ( aSession.ChooseBestIapCalled() )
                 {
                 UpdateActiveConnection( aSession );
                 }
+            
+            CheckIapForDisconnect( closeIapId );
             }
         }
-
+    
 #ifdef _DEBUG
     // Dump array of active connections to log in order to support testing.
     // 
@@ -591,7 +598,6 @@
     TUint32 connectionIapId( 0 );
 
     // Set the Connection Id and SNAP
-    // 
     TConnectionInfo connInfo;
     connInfo.iConnId = aConnId;
 
@@ -603,7 +609,6 @@
     if ( ( index1 != KErrNotFound ) && ( index1 < iActiveBMConns.Count() ) )
         {
         // If connInfo found, set the Iap Id as connectionIapId
-        //
         connectionIapId = iActiveBMConns[index1].iConnInfo.iIapId;
         }
 
@@ -870,23 +875,13 @@
         "CMPMServer::RemoveBMIAPConnection - aIapId = %i, aConnId = 0x%x", 
         aIapId, aConnId )
 
-    TActiveBMConn conn;
-    conn.iConnInfo.iIapId = aIapId;
-
     // The IAP connection lifetime is determined by the two calls 
     // IAPConnectionStarted and IAPConnectionStopped. 
-    //
-    TInt count = iActiveBMConns.Count();
-
-    // Decrement by one, because count is n, 
-    // but indexes in array are 0 .. n-1.
-    // 
-    count--;
 
     // This time we are browsing the array from the end to the beginning, 
     // because removing one element from array affects index numbering.
-    // 
-    for ( TInt i = count; i >= 0; i-- )
+    // Decrement i by one, because count is n, but indexes in array are 0 .. n-1
+    for ( TInt i = iActiveBMConns.Count() - 1; i >= 0; i-- )
         {
         if ( iActiveBMConns[i].iConnInfo.iIapId == aIapId )
             {
@@ -969,7 +964,7 @@
     MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIapL - IAPs count: %d", 
         aIapInfo.iCount)
     TConnMonIapInfo iapInfo = aIapInfo;
-    
+    iConnMonIapInfo = aIapInfo;
 #ifdef _DEBUG
     for (TUint i = 0; i < iapInfo.Count(); i++)
         {
@@ -978,37 +973,62 @@
         }
 #endif // _DEBUG
 
-    // Start possible forced roaming
-    TCmUsageOfWlan usageOfWlan = CommsDatAccess()->ForcedRoamingL();
-    if ( usageOfWlan == ECmUsageOfWlanKnown || usageOfWlan == ECmUsageOfWlanKnownAndNew )
+    // Read info for forced roaming from Commdat
+    TUint32 maxOpenTransAttempts ( KMaxOpenTransAttempts ) ;
+    TUint32 retryAfter ( KRetryAfter );
+    TInt err;
+    // CommDat reading might fail because CommDat session could be locked by another process at the moment
+    // So, we may wait/retry to read from CommDat a bit later.
+    TCmUsageOfWlan usageOfWlan ( ECmUsageOfWlanKnown );
+    do
         {
-        if ( IsWlanConnectionStartedL( CommsDatAccess() ) )
+        TRAP ( err, usageOfWlan = CommsDatAccess()->ForcedRoamingL() );
+        
+        if( err )
             {
-            iConnMonIapInfo = aIapInfo;
-                
-            if ( iRoamingToWlanPeriodic )
+            User::After( retryAfter );
+            }
+        } while( err && maxOpenTransAttempts-- );
+    
+    // Start possible forced roaming
+    if ( !err )
+        {
+        if ( usageOfWlan == ECmUsageOfWlanKnown || usageOfWlan == ECmUsageOfWlanKnownAndNew )
+            {
+            if ( IsWlanConnectionStartedL( CommsDatAccess() ) )
                 {
                 iRoamingToWlanPeriodic->Cancel();
+                iRoamingToHotspotWlanPeriodic->Cancel();
+                        
+                // Start periodic object that calls StartForcedRoamingToWlanL after 10s. 
+                // this handles the case when new wlan connection is 
+                // started from e.g. wlan sniffer but IAP is not yet in Internet SNAP 
+                iRoamingToWlanPeriodic->Start( 
+                        TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), 
+                        TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), 
+                        TCallBack( StartForcedRoamingToConnectedWlanL, this ) );
+                
+                // Start periodic object that calls StartForcedRoamingToWlanL after 120s. 
+                // this handles the case when new captive portal hotspot wlan 
+                // connection is started. IAP will be moved to Internet SNAP after 
+                // successful login only. 
+                iRoamingToHotspotWlanPeriodic->Start( 
+                        TTimeIntervalMicroSeconds32( KRoamingToHotspotWlanUpdateInterval ), 
+                        TTimeIntervalMicroSeconds32( KRoamingToHotspotWlanUpdateInterval ), 
+                        TCallBack( StartForcedRoamingToConnectedHotspotWlanL, this ) );
                 }
             else
                 {
-                iRoamingToWlanPeriodic = CPeriodic::NewL( 
-                                                   CActive::EPriorityStandard );
+                StartForcedRoamingToWlanL( iapInfo );
                 }
-            // start periodic object that calls StartForcedRoamingToWlanL after 10s. 
-            // this handles the case when new wlan connection is 
-            // started from e.g. wlan sniffer but IAP is not yet in Internet SNAP 
-            iRoamingToWlanPeriodic->Start( 
-                   TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), 
-                   TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), 
-                   TCallBack( StartForcedRoamingToConnectedWlanL, this ) );
+
+            StartForcedRoamingFromWlanL( iapInfo );
             }
-        else
-            {
-            StartForcedRoamingToWlanL( iapInfo );
-            }
-
-        StartForcedRoamingFromWlanL( iapInfo );
+        }
+    else
+        {
+        MPMLOGSTRING2( "CMPMServer::NotifyBMPrefIapL - \
+reading info for forced roaming fails with err %d, forced roaming fails", err )
         }
     
     MPMLOGSTRING2(
@@ -1049,6 +1069,39 @@
         }
     }
 
+
+// -----------------------------------------------------------------------------
+// CMPMServer::HandlePendingMsgs
+// -----------------------------------------------------------------------------
+//
+void CMPMServer::HandlePendingMsgs( TUint            aIapId,
+                                    TInt             aError, 
+                                    TInt*            aErrorReturned,
+                                    TBMNeededAction* aNeededAction )
+    {
+    MPMLOGSTRING3( "CMPMServer::HandlePendingMsgs aError = %d iapId = %d", 
+                   aError, aIapId )
+
+    for ( TInt i( 0 ); i < iSessions.Count(); i++ )
+        {
+        // Read the Connection Id of the application
+        TConnectionId connId = iSessions[i]->ConnectionId();
+
+        // Get the current connection IapId for this connId 
+        TUint32 currentIap = iSessions[i]->MyServer().GetBMIap( connId );
+
+        MPMLOGSTRING2( "Session IapId = %d", currentIap );
+
+        if ( currentIap == aIapId && !iSessions[i]->ChooseBestIapCalled() )
+            {
+            iSessions[i]->ProcessErrorComplete( aError, 
+                                                aErrorReturned, 
+                                                aNeededAction );
+            }
+        }
+    }
+
+
 // -----------------------------------------------------------------------------
 // CMPMServer::HandleServerBlackListIap
 // -----------------------------------------------------------------------------
@@ -1190,7 +1243,7 @@
 aCategory = %i blacklisted Id count = %d", 
                    aCategory, iBlackListIdList.Count() )
 
-    for( TInt i( 0 ); i < iBlackListIdList.Count(); i++ )
+    for (TInt i = iBlackListIdList.Count()-1; i >= 0; i--)
         {
         // found blacklisted Connection Id
         TMPMBlackListConnId connIdInfo = iBlackListIdList[i];
@@ -1200,7 +1253,7 @@
 aConnId = 0x%x, blacklisted IapId count = %d", connIdInfo.iConnId, 
         connIdInfo.Count() )
         
-        for (TInt j = 0; j < connIdInfo.Count(); j++)
+        for (TInt j = connIdInfo.Count()-1; j >= 0; j--)
             {
             if ( connIdInfo.Category( j ) == aCategory ) 
                 {
@@ -1827,13 +1880,7 @@
 void CMPMServer::StartForcedRoamingToWlanL( const TConnMonIapInfo& aIapInfo )
     {
     MPMLOGSTRING( "CMPMServer::StartForcedRoamingToWlan" )
-    
-    // cancel the periodic object
-    if ( iRoamingToWlanPeriodic != NULL )
-        {
-        iRoamingToWlanPeriodic->Cancel();
-        }
-
+ 
     // Copy all available wlan iap ids to own array
     RArray<TUint32> wlanIapIds;
     CleanupClosePushL( wlanIapIds );
@@ -1842,7 +1889,9 @@
 
     for ( TUint index = 0; index < aIapInfo.iCount; index++ )
         {
-        if ( CommsDatAccess()->CheckWlanL( aIapInfo.iIap[index].iIapId ) != ENotWlanIap )
+        TWlanIapType iapType ( ENotWlanIap );
+        TRAPD (leave, iapType = CommsDatAccess()->CheckWlanL( aIapInfo.iIap[index].iIapId ) );
+        if ( ( iapType != ENotWlanIap ) && ( leave == KErrNone ) )
             {
             // Accept only wlan iaps in internet snap
             if ( iCommsDatAccess->IsInternetSnapL( aIapInfo.iIap[index].iIapId, 0 ) )
@@ -1850,10 +1899,12 @@
                 wlanIapIds.AppendL( aIapInfo.iIap[index].iIapId );
                 }
             }
-        // Fill iap list to be used later to check best iap
-        iapList.AppendL( aIapInfo.iIap[index].iIapId );
+        // Fill iap list to be used later to check best iap;
+        if ( leave == KErrNone )
+            {
+            iapList.AppendL( aIapInfo.iIap[index].iIapId );
+            }
         }
-
     // No wlans available -> no reason to continue
     if ( !wlanIapIds.Count() )
         {
@@ -1898,12 +1949,33 @@
 //    
 TInt CMPMServer::StartForcedRoamingToConnectedWlanL( TAny* aUpdater )
     {
-    MPMLOGSTRING( "CMPMServer::StartForcedRoamingToConnectedWlanL" );
-    static_cast<CMPMServer*>( aUpdater )->StartForcedRoamingToWlanL( 
-            static_cast<CMPMServer*>( aUpdater )->iConnMonIapInfo );
+    MPMLOGSTRING( "CMPMServer::StartForcedRoamingToConnectedWlanL" )
+    CMPMServer* self = static_cast<CMPMServer*>( aUpdater );
+    if ( self )
+        {
+        // cancel the periodic object        
+        self->iRoamingToWlanPeriodic->Cancel();
+        self->StartForcedRoamingToWlanL( self->iConnMonIapInfo );
+        }
     return 0;
     }
 
+// ---------------------------------------------------------------------------
+// CMPMServer::StartForcedRoamingToConnectedHotspotWlanL
+// ---------------------------------------------------------------------------
+//    
+TInt CMPMServer::StartForcedRoamingToConnectedHotspotWlanL( TAny* aUpdater )
+    {
+    MPMLOGSTRING( "CMPMServer::StartForcedRoamingToConnectedHotspotWlanL" )
+    CMPMServer* self = static_cast<CMPMServer*>( aUpdater );
+    if ( self )
+        {        
+        // cancel the periodic object
+        self->iRoamingToHotspotWlanPeriodic->Cancel();
+        self->StartForcedRoamingToWlanL( self->iConnMonIapInfo );
+        }
+    return 0;
+    }
 
 // -----------------------------------------------------------------------------
 // CMPMServer::StartForcedRoamingFromWlanL
@@ -2138,7 +2210,7 @@
 // Stop all cellular connections except MMS
 // ---------------------------------------------------------------------------
 //
-void CMPMServer::StopCellularConns()
+void CMPMServer::StopCellularConns( TBool aSilentOnly )
     {
     MPMLOGSTRING( "CMPMServer::StopCellularConns" )
 
@@ -2167,7 +2239,14 @@
                 if (!(err == KErrNone && iapId == mmsIap))
                     {
                     // Stop the conn / IAP.
-                    StopConnections( iapId );
+                    if ( aSilentOnly )
+                        {
+                        CheckIapForDisconnect( iapId );
+                        }
+                    else
+                        {
+                        StopConnections( iapId );
+                        }
                     stoppedIaps.Append( iapId );
                     }
                 }
@@ -2245,6 +2324,134 @@
     iOfflineWlanQueryResponse = aResponse;
     }
 
+// ---------------------------------------------------------------------------
+// CMPMServer::StartConnPermQueryTimer
+// Starts the connection permission query timer.
+// ---------------------------------------------------------------------------
+//
+void CMPMServer::StartConnPermQueryTimer()
+    {
+    MPMLOGSTRING( "CMPMServer::StartConnPermQueryTimer" )
+
+    if ( !iConnPermQueryTimer )
+        {
+        TRAPD( err, iConnPermQueryTimer = CMPMConnPermQueryTimer::NewL( this ) );
+        if ( err == KErrNone )
+            {
+            iConnPermQueryTimer->StartTimer();
+            MPMLOGSTRING( "CMPMServer::StartConnPermQueryTimer: Ok." )
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CMPMServer::ResetConnPermQueryTimer
+// Resets the connection permission query timer.
+// ---------------------------------------------------------------------------
+//
+void CMPMServer::ResetConnPermQueryTimer()
+    {
+    MPMLOGSTRING( "CMPMServer::ResetConnPermQueryTimer" )
+
+    if ( iConnPermQueryTimer )
+        {
+        delete iConnPermQueryTimer;
+        iConnPermQueryTimer = NULL;
+        MPMLOGSTRING( "CMPMServer::ResetConnPermQueryTimer: Ok." )
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CMPMServer::IsConnPermQueryTimerOn
+// Tells if the connection permission query timer is on.
+// ---------------------------------------------------------------------------
+//
+TBool CMPMServer::IsConnPermQueryTimerOn()
+    {
+    MPMLOGSTRING( "CMPMServer::IsConnPermQueryTimerOn" )
+
+    TBool retval = EFalse;
+    if ( iConnPermQueryTimer )
+        {
+        retval = ETrue;
+        MPMLOGSTRING( "CMPMServer::IsConnPermQueryTimerOn: Yes." )
+        }
+    return retval;
+    }
+
+// -----------------------------------------------------------------------------
+// CMPMServer::CheckIapForDisconnect
+// -----------------------------------------------------------------------------
+//
+void CMPMServer::CheckIapForDisconnect( TInt aIapId )
+    {
+    MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - aIapId = 0x%x", 
+        aIapId )
+
+    // Fix for case ou1cimx1#468999: stop sessions to cellular iap
+    // when there is only silent connections to it, and cellular usage is set
+    // to always ask
+    
+    // Check iap type and usage policy
+    TMPMBearerType bearerType( EMPMBearerTypeNone );
+    TRAP_IGNORE( bearerType = CommsDatAccess()->GetBearerTypeL( aIapId ) );
+
+    TBool closeIap = ( bearerType == EMPMBearerTypePacketData
+                && DataUsageWatcher()->CellularDataUsage() == ECmCellularDataUsageConfirm ); 
+    
+    // No need to put iapSessions to CleanupStack; there are no leaves
+    RPointerArray<CMPMServerSession> iapSessions;
+    if ( closeIap )
+        {
+        // Check for non-silent sessions to iap
+        // closeIap is left true also when there are no sessions using the iap
+        for ( TInt i = 0; i < iActiveBMConns.Count(); i++ )
+            {
+
+            CMPMServerSession* session
+                = GetServerSession( iActiveBMConns[i].iConnInfo.iConnId );
+
+            TInt sessionIapId = iActiveBMConns[i].iConnInfo.iIapId;
+            if ( !sessionIapId )
+                {
+                TRAP_IGNORE( sessionIapId = session->IapSelectionL()->MpmConnPref().IapId() );
+                }
+
+            if ( sessionIapId == aIapId )
+                {
+                iapSessions.Append( session ); // Don't mind if Append fails
+                
+                TBool silent( ETrue );
+                TRAP_IGNORE( silent = session->IapSelectionL()->MpmConnPref().NoteBehaviour()
+                                      & TExtendedConnPref::ENoteBehaviourConnDisableNotes );
+                if ( !silent )
+                    {
+                    // Non-silent session to iap found
+                    closeIap = EFalse;
+                    break; // for
+                    }
+                }
+            }
+        }
+    
+    if ( closeIap )
+        {
+        MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping silent sessions to iap 0x%x", 
+            aIapId )
+        // Stop all (silent) sessions to iap
+        for ( TInt i = 0; i < iapSessions.Count(); i++)
+            {
+            MPMLOGSTRING2( "CMPMServer::CheckIapForDisconnect - stopping connId 0x%x",
+                    iapSessions[i]->ConnectionId());
+            iapSessions[i]->StopConnection();
+            }
+        }
+
+    iapSessions.Close();
+    
+    }
+
+
 // -----------------------------------------------------------------------------
 // TMPMBlackListConnId::Append
 // -----------------------------------------------------------------------------
--- a/bearermanagement/mpm/src/mpmserversession.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/bearermanagement/mpm/src/mpmserversession.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -76,7 +76,8 @@
       iStoredIapInfo(),
       iIapSelection( NULL ),
       iMigrateState( EMigrateNone ),
-      iDisconnectDialogShown( EFalse )
+      iDisconnectDialogShown( EFalse ),
+      iErrorDiscreetPopupShown( EFalse )
     {
     }
 
@@ -106,9 +107,7 @@
 //
 CMPMServerSession::~CMPMServerSession()
     {
-    delete iDisconnectDlg;
-    delete iConfirmDlgRoaming;
-    delete iIapSelection;
+
 
     // Remove serverside objects for notification session.
     // 
@@ -137,6 +136,11 @@
     
     // Make sure the connection is removed from server's information array.
     iMyServer.RemoveBMConnection( iConnId, *this );
+
+    delete iDisconnectDlg;
+    delete iConfirmDlgRoaming;
+    delete iIapSelection;
+
     }
 
 
@@ -936,7 +940,10 @@
         //Display confirm dialog only if we are moving to cellular IAP
         if ( MyServer().CommsDatAccess()->CheckWlanL( iMigrateIap ) == ENotWlanIap )
             {
-            if ( !( iIapSelection->MpmConnPref().NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) )
+            // Check that connection preferences don't deny queries, and
+            // enough time has elapsed from the last query cancelled by the user.
+            if ( !( iIapSelection->MpmConnPref().NoteBehaviour() & TExtendedConnPref::ENoteBehaviourConnDisableQueries ) &&
+                    !MyServer().IsConnPermQueryTimerOn() )
                 {
                 if ( MyServer().RoamingWatcher()->RoamingStatus() == EMPMInternationalRoaming )
                     {
@@ -1042,6 +1049,10 @@
         {
         if( aResponse == EMsgQueryCancelled )
             {
+            // User cancelled the connection permission query,
+            // don't try again until the timer expires.
+            MyServer().StartConnPermQueryTimer();
+            
             if( !aReconnect )
                 {
                 // Send a preferred IAP notification
@@ -1416,12 +1427,30 @@
         return;
         }
 
+    // Read the Connection Id of the application
+    // 
+    TConnectionId connId = iProcessErrorMessage.Int1();
+    
+    MPMLOGSTRING3( "CMPMServerSession::HandleServerProcessErrorL \
+- error code = %i, Connection Id = 0x%x", error, connId )
+
     if ( !ChooseBestIapCalled() )
         {
         MPMLOGSTRING( "CMPMServerSession::HandleServerProcessErrorL - \
-Warning: ChooseBestIap has not been called yet" )
-        TBMNeededAction neededAction( EPropagateError );
-        ProcessErrorComplete( KErrNone, &error, &neededAction );
+ChooseBestIap has not been called yet" )
+
+        // If it is not disconnect dialog error then complete message. 
+        // If it is then leave message pending and it will be completed when 
+        // disconnect dialog completes in other session.
+        if ( !DisconnectDlgErrorCode( error ) )
+            {
+            TBMNeededAction neededAction( EPropagateError );
+            ProcessErrorComplete( KErrNone, &error, &neededAction );
+            }
+        else
+            {
+            MPMLOGSTRING( "Disconnect dlg error - leave msg pending" );
+            }
         return;
         }
 
@@ -1442,16 +1471,13 @@
             connUiUtils->ConnectionErrorDiscreetPopup( error );
             delete connUiUtils;
             connUiUtils = NULL;
+            
+            // Error discreet popup has been shown. This is needed so that we
+            // dont show it again for SNAP.
+            iErrorDiscreetPopupShown = ETrue;
             }
         }
 
-    // Read the Connection Id of the application
-    // 
-    TConnectionId connId = iProcessErrorMessage.Int1();
-
-    MPMLOGSTRING3( "CMPMServerSession::HandleServerProcessErrorL\
- - error code = %i, Connection Id = 0x%x", error, connId )
-
     // Get the current connection IapId for this connId 
     //
     TUint32 currentIap = iMyServer.GetBMIap( connId );
@@ -1605,6 +1631,11 @@
             ProcessErrorComplete( KErrNone,
                                   returnError,
                                   &neededAction );
+            
+            iMyServer.HandlePendingMsgs( currentIap,
+                                         KErrNone,
+                                         returnError,
+                                         &neededAction );
             return;
             }
         }
@@ -1615,7 +1646,8 @@
         // KErrConnectionTerminated is received when user disconnects
         // connection from Settings/Connection mgr.
         //       
-        if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) || ( error == KErrConnectionTerminated ) )
+        if ( ( error == KErrCancel ) || ( error == KErrTimedOut ) || ( error == KErrConnectionTerminated )
+                || ( error == KErrDisconnected && iMyServer.IsPhoneOffline() ) )
             {
             neededAction = EPropagateError;
 
@@ -3325,11 +3357,11 @@
     MPMLOGSTRING2( "CMPMServerSession::ChooseIapComplete aError = %d", aError )
 
     // Show error popup if it's allowed per client request.
-	// No error popup shown to SNAP.
+	// Error popup shown to SNAP only if error discreet has not been shown for IAP.
     if ( ChooseBestIapCalled() && (!( iIapSelection->MpmConnPref().NoteBehaviour() &
             TExtendedConnPref::ENoteBehaviourConnDisableNotes ))
-            && ( aError != KErrNone ) 
-            && ( iIapSelection->MpmConnPref().SnapId() == 0 ) )
+              && ( aError != KErrNone )
+              && ( iErrorDiscreetPopupShown == EFalse ) )
         {
         CConnectionUiUtilities* connUiUtils = NULL;
         TRAPD( error, connUiUtils = CConnectionUiUtilities::NewL() );
@@ -3398,6 +3430,9 @@
         MPMLOGSTRING( "CMPMServerSession::ChooseIapComplete Message completed" )
         iChooseIapMessage.Complete( aError );
         }
+    
+    // Enable showing error discreet popup for SNAP again
+    iErrorDiscreetPopupShown = EFalse;
     }
 
 
--- a/cmmanager/cmmgr/Framework/BWinsCw/CmManager_prot_setupU.DEF	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/BWinsCw/CmManager_prot_setupU.DEF	Thu Aug 19 10:18:49 2010 +0300
@@ -388,5 +388,6 @@
 	?WatcherUnRegister@CCmManagerImpl@@QAEXXZ @ 387 NONAME ; void CCmManagerImpl::WatcherUnRegister(void)
 	?RemoveDestFromPool@CCmManagerImpl@@QAEXPAVCCmDestinationImpl@@@Z @ 388 NONAME ; void CCmManagerImpl::RemoveDestFromPool(class CCmDestinationImpl *)
 	?OfferKeyEventL@CmPluginBaseSettingsDlg@@MAE?AW4TKeyResponse@@ABUTKeyEvent@@W4TEventCode@@@Z @ 389 NONAME ; enum TKeyResponse CmPluginBaseSettingsDlg::OfferKeyEventL(struct TKeyEvent const &, enum TEventCode)
+	?AddCmL@CCmSettingsUi@@QAEKAAKK@Z @ 390 NONAME ; unsigned long CCmSettingsUi::AddCmL(unsigned long &, unsigned long)
+	?EditCmL@CCmSettingsUi@@QAE?AW4TResult@1@K@Z @ 391 NONAME ; enum CCmSettingsUi::TResult CCmSettingsUi::EditCmL(unsigned long)
 
-
--- a/cmmanager/cmmgr/Framework/EABI/CmManager_prot_setupU.def	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/EABI/CmManager_prot_setupU.def	Thu Aug 19 10:18:49 2010 +0300
@@ -435,4 +435,6 @@
 	_ZN14CCmManagerImpl18RemoveDestFromPoolEP18CCmDestinationImpl @ 434 NONAME
 	_ZN14CCmManagerImpl24DestinationStillExistedLEP18CCmDestinationImpl @ 435 NONAME
 	_ZN23CmPluginBaseSettingsDlg14OfferKeyEventLERK9TKeyEvent10TEventCode @ 436 NONAME
+	_ZN13CCmSettingsUi6AddCmLERmm @ 437 NONAME
+	_ZN13CCmSettingsUi7EditCmLEm @ 438 NONAME
 
--- a/cmmanager/cmmgr/Framework/Inc/cmconnselectrbpage.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Inc/cmconnselectrbpage.h	Thu Aug 19 10:18:49 2010 +0300
@@ -159,6 +159,10 @@
          * Previously selected item
          */
         TInt iPrevItem;
+        /*
+         * pressing the enter key first time will be handled as an uparrow key        
+         */
+        TBool iFirstEnter;
     };
     
 #endif // C_CMAPPSETTRBPAGE_H
--- a/cmmanager/cmmgr/Framework/Inc/cmsettingsuiimpl.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Inc/cmsettingsuiimpl.h	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
@@ -59,6 +59,24 @@
         * @return TBool
         */
         TBool SelectDestinationDlgL( TUint32& aDestinationId );
+        
+        /**
+        * Launches the dialog for adding connection methods
+        * @since 3.2.3
+        * @param  aDestUid destination id for the new cm
+        * @param  aBearerType bearer type for the new cm
+        * @return TUint32 id of the new cm
+        */
+        TUint32 AddCmL( TUint32& aDestUid, TUint32 aBearerType );
+
+        /**
+        * Launches the dialog for editing connection methods
+        * @since 3.2.3
+        * @param  aCmId id of the cm to edit
+        * @return TInt - KDialogUserExit or KDialogUserBack
+        */
+        TInt EditCmL( TUint32 aCmId );
+
 
     private:
 
--- a/cmmanager/cmmgr/Framework/Src/ccmpluginbaseeng.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Src/ccmpluginbaseeng.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -710,24 +710,18 @@
 
     HBufC8* retVal = NULL;
     
-    switch ( aAttribute )
-        {
-        default:
-            {
-            TUint32 attribute = CheckForCommonAttribute( aAttribute );
-            CMDBField<TDesC8>* field;
-                        
-            FindFieldL( attribute, ECmText8, (CMDBElement*&)field );
+    TUint32 attribute = CheckForCommonAttribute( aAttribute );
+    CMDBField<TDesC8>* field;
+                
+    FindFieldL( attribute, ECmText8, (CMDBElement*&)field );
 
-            if ( !field->IsNull() )
-                {
-                retVal = field->GetL().AllocL();
-                }
-            else
-                {
-                retVal = KNullDesC8().AllocL();
-                }
-            }
+    if ( !field->IsNull() )
+        {
+        retVal = field->GetL().AllocL();
+        }
+    else
+        {
+        retVal = KNullDesC8().AllocL();
         }
         
     return retVal;
@@ -950,24 +944,17 @@
     {
     LOGGER_ENTERFN( "CCmPluginBaseEng::SetString8AttributeL" );
 
-    switch ( aAttribute )
+    TUint32 attribute = CheckForCommonAttribute( aAttribute );
+    CMDBField<TDesC8>* field;
+
+    TValidationFunctionL func = FindFieldL( attribute, ECmText8, (CMDBElement*&)field );
+
+    if( func )
         {
-        default:
-            {
-            TUint32 attribute = CheckForCommonAttribute( aAttribute );
-            CMDBField<TDesC8>* field;
-            
-            TValidationFunctionL func = 
-                        FindFieldL( attribute, ECmText8, (CMDBElement*&)field );
-            
-            if( func )
-                {
-                func( this, attribute, (const TAny*)&aValue );
-                }
+        func( this, attribute, (const TAny*)&aValue );
+        }
 
-            field->SetL( aValue );
-            }
-        }
+    field->SetL( aValue );
     }
     
 // ---------------------------------------------------------------------------
@@ -2427,7 +2414,9 @@
                 {
                 pf /= 10;
                 if ( !pf )
+                    {
                     break;
+                    }
                 }
             TPtr sgdptr( temp->Des() );
             TPtr sgdptr2( temp2->Des() );
@@ -2783,7 +2772,7 @@
     }
     
 // ---------------------------------------------------------------------------
-// CCmPluginBaseEng::AddConverstionTableL
+// CCmPluginBaseEng::AddCommonConversionTableL
 // ---------------------------------------------------------------------------
 //
 EXPORT_C void CCmPluginBaseEng::AddCommonConversionTableL( 
@@ -2822,7 +2811,8 @@
     {
     LOGGER_ENTERFN( "CCmPluginBaseEng::RemoveCommonConversionTable" );
 
-    for ( TInt i = 0; i < iPriv->iCommonConvTblArray.Count(); ++i )
+    // When calling Remove(), it's safer to loop starting from end.
+    for ( TInt i = iPriv->iCommonConvTblArray.Count()-1; i >= 0; i-- )
         {
         if ( iPriv->iCommonConvTblArray[i] == aConvTable )
             {
@@ -2876,10 +2866,6 @@
                 {
                 aElement = &field;
                 }
-            else
-                {
-                User::Leave( KErrNotSupported );
-                }
             }
             break;
 
@@ -2889,10 +2875,6 @@
                 {
                 aElement = &field;
                 }
-            else
-                {
-                User::Leave( KErrNotSupported );
-                }
             }
             break;
             
@@ -2905,10 +2887,6 @@
                 {
                 aElement = &field;
                 }
-            else
-                {
-                User::Leave( KErrNotSupported );
-                }
             }
             break;
             
--- a/cmmanager/cmmgr/Framework/Src/cmconnselectrbpage.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Src/cmconnselectrbpage.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -49,6 +49,7 @@
     , iAreDestinations( areDestinations )
     , iOpenDestination( aOpenDestination )
     , iHelpContext ( aContext )
+    , iFirstEnter( ETrue )
     {
     CLOG_CREATE;
     iPrevItem = iDestinations[aCurrentSelectionIndex];
@@ -256,7 +257,28 @@
     // save for the future use
     iPrevItem = iDestinations[ListBoxControl()->CurrentItemIndex()];
     
-    switch ( aKeyEvent.iScanCode )
+    TKeyEvent aKeyEventmy = aKeyEvent;
+    if ( aKeyEventmy.iCode == EKeyEnter )
+        {
+        if ( iFirstEnter )
+            {//pressing the enter key at the first time will be changed
+             //to an up arrow key so the first item in the list will be highlighted
+            iFirstEnter = EFalse;
+            aKeyEventmy.iScanCode = EStdKeyUpArrow;
+            aKeyEventmy.iCode = EKeyUpArrow;
+            }
+        else
+            {//change back to true for the next session
+            iFirstEnter=ETrue;
+            }
+        }
+    else if ( aKeyEventmy.iScanCode == EStdKeyDownArrow || aKeyEventmy.iScanCode == EStdKeyUpArrow )
+             {
+             //we will have highligt so the following enter key should select the item
+             iFirstEnter = EFalse;
+             }
+    
+    switch ( aKeyEventmy.iScanCode )
         {
         case EStdKeyDownArrow:
         case EStdKeyUpArrow:
@@ -289,7 +311,7 @@
             break;
             }
         }
-    retVal = CAknRadioButtonSettingPage::OfferKeyEventL( aKeyEvent, aType );
+    retVal = CAknRadioButtonSettingPage::OfferKeyEventL( aKeyEventmy, aType );
     
     return retVal;
     }
@@ -363,27 +385,27 @@
 					    
 		            if ( iOpenDestination ) //only if we are on 'destination level' and we are able to
         		        //open destinations
-                		{            
-                		// If focus is on the 'uncategorised' destination, 
-                		// change the soft key to 'Open'
-                		if ( iDestinations[ ListBoxControl()->CurrentItemIndex() ] == 
+                	    {            
+                	    // If focus is on the 'uncategorised' destination, 
+                	    // change the soft key to 'Open'
+                	    if ( iDestinations[ ListBoxControl()->CurrentItemIndex() ] == 
 		                                                        KDestItemUncategorized )
         		            {
-                		    HBufC* text = StringLoader::LoadLC( R_QTN_MSK_OPEN );
-                    		Cba()->SetCommandL( EAknSoftkeySelect, *text );
-                    		Cba()->DrawNow();
-                    		CleanupStack::PopAndDestroy( text );                
-                    		}
-                		else
-                    		{
-                    		HBufC* text = StringLoader::LoadLC( R_QTN_MSK_SELECT );
-                    		Cba()->SetCommandL( EAknSoftkeySelect, *text );
-                    		Cba()->DrawNow();
-                    		CleanupStack::PopAndDestroy( text );
-                    		}
-                		CAknRadioButtonSettingPage::SelectCurrentItemL();
-                		}
-                	}
+                	        HBufC* text = StringLoader::LoadLC( R_QTN_MSK_OPEN );
+                   		    Cba()->SetCommandL( EAknSoftkeySelect, *text );
+                   		    Cba()->DrawNow();
+                   		    CleanupStack::PopAndDestroy( text );                
+                   		    }
+                	    else
+                   		    {
+                   		    HBufC* text = StringLoader::LoadLC( R_QTN_MSK_SELECT );
+                   		    Cba()->SetCommandL( EAknSoftkeySelect, *text );
+                   		    Cba()->DrawNow();
+                   		    CleanupStack::PopAndDestroy( text );
+                   		    }
+                         CAknRadioButtonSettingPage::SelectCurrentItemL();
+                	     }
+                    }
                 break;
                 
             case MEikListBoxObserver::EEventItemDoubleClicked:
--- a/cmmanager/cmmgr/Framework/Src/cmdlg.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Src/cmdlg.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -1850,9 +1850,10 @@
 //
 TInt CCmDlg::GetInsertIndexL( TInt aCount, TUint32 aPriority )
     {
-    TInt ret = -1;
+    TInt ret = aCount;
     TUint32 priority;
     
+    
     for ( TInt index = 0; index < aCount; index++ )
         {
         CCmPluginBase* cm = iCmDestinationImpl->GetConnectionMethodL( iItemIndex[index] );
@@ -1979,15 +1980,11 @@
                 TInt insertAt = GetInsertIndexL( index, underlyingPrio );
                 
                 // Modify the priority of this VPN Iap
-                if (insertAt != -1)
-                    {
-                    iCmDestinationImpl->ModifyPriorityL( *cm, insertAt );
-                    iCmDestinationImpl->UpdateL();
-                    break;
-                    }
+                iCmDestinationImpl->ModifyPriorityL( *cm, insertAt );
                 }
             }
         }
+        iCmDestinationImpl->UpdateL();
     }
 
 // --------------------------------------------------------------------------
--- a/cmmanager/cmmgr/Framework/Src/cmmanagerimpl.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Src/cmmanagerimpl.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
@@ -155,7 +155,7 @@
     }
 
 //-----------------------------------------------------------------------------
-//  CCmManagerImpl::CCmManagerImpl()
+//  CCmManagerImpl::~CCmManagerImpl()
 //-----------------------------------------------------------------------------
 //
 CCmManagerImpl::~CCmManagerImpl()
@@ -196,8 +196,11 @@
     
     delete iPluginImpl;
 
-    delete &Session();
-    delete iTrans;
+    if (iTrans)
+        {
+        delete &Session();
+        delete iTrans;
+        }
 
     if( iIsFeatureManagerInitialised )
         {
@@ -709,10 +712,17 @@
     // Two instances of class CCmCommsDatNotifier are created here and
     // referred by all watchers in CmManager. One is to watch change in Iap Table
     // and the other is to watch change in Snap Table.
-    iCommsDatIapNotifier = CCmCommsDatNotifier::NewL( KCDTIdIAPRecord );
+    
+    if ( iCommsDatIapNotifier == NULL )
+        {
+        iCommsDatIapNotifier = CCmCommsDatNotifier::NewL( KCDTIdIAPRecord );
+        }
     
-    TUint32 snapTableId = GetSnapTableIdL();
-    iCommsDatSnapNotifier = CCmCommsDatNotifier::NewL( snapTableId );
+    if ( iCommsDatSnapNotifier == NULL )
+        {
+        TUint32 snapTableId = GetSnapTableIdL();
+        iCommsDatSnapNotifier = CCmCommsDatNotifier::NewL( snapTableId );
+        }
     }
 
 //=============================================================================
@@ -2586,8 +2596,6 @@
     {
     LOGGER_ENTERFN( "CCmManagerImpl::FilterOutVirtualsL" );
 
-    TInt count = aCmDataArray.Count();
-    
     for ( TInt i = 0; i < aCmDataArray.Count(); i++ )
         {
         if ( aCmDataArray[i]->GetBoolAttributeL( ECmVirtual ) )
@@ -2634,10 +2642,9 @@
     // get the possible embedded destinations to be able to list their content, too
     // we only have to check in cmArray
     // put them in a sep. array and get their data into another.    
-    TInt cmCount = aCmArray.Count();
     RArray<TUint32> cmEmbDestArray ( KCmArrayMediumGranularity );
     CleanupClosePushL( cmEmbDestArray );
-    for ( TInt i = 0; i < cmCount; i++ )
+    for ( TInt i = 0; i < aCmArray.Count(); i++ )
         {
         if ( aCmArray[i]->GetBoolAttributeL( ECmDestination ) )
             {
@@ -2645,7 +2652,7 @@
             //remove embedded destination right now
             delete aCmArray[i];
             aCmArray.Remove(i);
-           // i--;
+            i--; // Array gets re-indexed after calling Remove().
             }
         }
     // now we stored the needed emb.dest, 
@@ -2761,16 +2768,16 @@
                 // now we either found a correct place or 
                 // we are at the end of the list
                 // ( we break-ed for cycle when found the correct place )
-                if ( ii == cc )
-                    {
-                    // end of the list, append
-                    aCmArray.AppendL( aCmLinkedArray[i]);
-                    }
-                else
-                    {
-                    // we found the place to be inserted
-                    aCmArray.InsertL( aCmLinkedArray[i], ii );
-                    }   
+            if ( ii == cc )
+                {
+                // end of the list, append
+                aCmArray.AppendL( aCmLinkedArray[i]);
+                }
+            else
+                {
+                // we found the place to be inserted
+                aCmArray.InsertL( aCmLinkedArray[i], ii );
+                }   
             }
         else
             {
--- a/cmmanager/cmmgr/Framework/Src/cmsettingsui.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Src/cmsettingsui.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
@@ -15,7 +15,10 @@
 *
 */
 
-#include <cmsettingsui.h>
+//This include contains full path because there is 
+//an other version of the same file available in the public
+//SDK and we want to make sure that the internal header is used.
+#include <platform/mw/cmsettingsui.h> 
 #include "cmsettingsuiimpl.h"
 #include <cmcommonconstants.h>
 
@@ -82,3 +85,30 @@
     {
     return iImpl->SelectDestinationDlgL( aDestinationId );
     }
+    
+//-----------------------------------------------------------------------------
+//  CCmSettingsUi::AddCmL()
+//-----------------------------------------------------------------------------
+//    
+
+EXPORT_C TUint32 CCmSettingsUi::AddCmL( TUint32& aDestUid, TUint32 aBearerType )
+    {
+    return iImpl->AddCmL( aDestUid, aBearerType );
+    }
+
+//-----------------------------------------------------------------------------
+//  CCmSettingsUi::EditCmL()
+//-----------------------------------------------------------------------------
+//
+
+EXPORT_C CCmSettingsUi::TResult CCmSettingsUi::EditCmL( TUint32 aCmId )
+    {
+    if ( iImpl->EditCmL( aCmId ) == KDialogUserExit )
+        {
+        return EExit;
+        }
+     else
+        {
+        return EBack;
+        }
+    }
--- a/cmmanager/cmmgr/Framework/Src/cmsettingsuiimpl.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Src/cmsettingsuiimpl.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
@@ -20,7 +20,11 @@
 #include "cmsettingsuiimpl.h"
 #include "cmmanagerimpl.h"
 #include "destdlg.h"
+#include <cmcommonui.h>
+#include <cmpluginbase.h>
+#include <cmmanagerdef.h>
 #include <cmcommonconstants.h>
+#include <cmpluginwlandef.h>
 #include "selectdestinationdlg.h"
 #include <data_caging_path_literals.hrh>
 
@@ -122,3 +126,102 @@
                                                               
     return dlg->ExecuteLD( R_CMMANAGER_LIST_QUERY_WITH_MSGBOX );    
     }
+//-----------------------------------------------------------------------------
+//  CCmSettingsUiImpl::AddCmL
+//-----------------------------------------------------------------------------
+//
+TUint32 CCmSettingsUiImpl::AddCmL( TUint32& aDestUid, TUint32 aBearerType )
+    {
+    // Add new connection method
+    TUint32 addedIapId(0);
+
+    CCmDestinationImpl* destImpl = iCmManagerImpl->DestinationL( aDestUid );
+    CleanupStack::PushL(destImpl);
+    
+    // Check first if parent destination is protected
+    if ( destImpl->ProtectionLevel() == CMManager::EProtLevel1 )
+        {
+        TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED,
+                                TCmCommonUi::ECmErrorNote );
+        }
+    else
+        {
+        // Automatically check for available conn methods?
+    
+        TBool manualConfigure = ETrue;    
+        if (aBearerType == KUidWlanBearerType)
+            {
+            TInt retval =
+                    TCmCommonUi::ShowConfirmationQueryL( R_CMWIZARD_AUTOMATIC_CHECK );
+    
+            manualConfigure = ( retval == EAknSoftkeyYes || retval == EAknSoftkeyOk )
+                                      ?  EFalse : ETrue;
+            }
+            
+        CCmPluginBase* plugin = destImpl->CreateConnectionMethodL( aBearerType );
+        CleanupStack::PushL( plugin );
+       
+        // Bearer-specific UI-supported initialization is done by plug-ins
+        if ( plugin->InitializeWithUiL( manualConfigure ) )
+            {
+            destImpl->UpdateL();  // commit changes
+
+            RArray<TUint32> additionalCms;
+            CleanupClosePushL (additionalCms);
+            plugin->GetAdditionalUids( additionalCms );
+            //if there are additional cms created, move them to the target destination as well
+            for ( TInt i = 0; i<additionalCms.Count(); i++)
+                {
+                CCmPluginBase* cm = iCmManagerImpl->GetConnectionMethodL( additionalCms[i] );
+                CleanupStack::PushL(cm);
+                iCmManagerImpl->CopyConnectionMethodL( *destImpl, *cm );
+                CleanupStack::PopAndDestroy( cm );
+                }
+            CleanupStack::PopAndDestroy( &additionalCms );   
+            addedIapId = plugin->GetIntAttributeL( CMManager::ECmIapId );
+            }
+        CleanupStack::PopAndDestroy(plugin);
+        }    
+    CleanupStack::PopAndDestroy(destImpl);
+    
+    return addedIapId;
+    }
+
+//-----------------------------------------------------------------------------
+//  CCmSettingsUiImpl::EditCmL
+//-----------------------------------------------------------------------------
+//
+TInt CCmSettingsUiImpl::EditCmL( TUint32 aCmId )
+    {
+    // Edit connection method  
+    TInt ret( KDialogUserBack );
+    
+    CCmPluginBase* cm = iCmManagerImpl->GetConnectionMethodL( aCmId );
+    CleanupStack::PushL( cm );
+    
+    cm->ReLoadL();
+    if ( cm->GetBoolAttributeL( CMManager::ECmProtected ) ||
+         cm->GetBoolAttributeL( CMManager::ECmDestination ) )
+        {
+        TCmCommonUi::ShowNoteL( R_CMMANAGERUI_INFO_PROTECTED_CANNOT_EDIT,
+                                            TCmCommonUi::ECmErrorNote );
+        }
+   else if ( cm->GetBoolAttributeL( CMManager::ECmBearerHasUi ) )
+        {
+        // check if the cm is in use
+        if ( cm->GetBoolAttributeL( CMManager::ECmConnected ) )
+            {
+            TCmCommonUi::ShowNoteL( R_QTN_SET_NOTE_AP_IN_USE_EDIT,
+                                    TCmCommonUi::ECmErrorNote );
+            }
+        else
+            {
+            //Makes sure that the commsdat notifier is initialized.           
+            cm->CmMgr().StartCommsDatNotifierL();
+            ret = cm->RunSettingsL();
+            }
+        }
+    CleanupStack::PopAndDestroy(cm);
+    return ret;
+    }
+
--- a/cmmanager/cmmgr/Framework/Src/uncatdlg.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Framework/Src/uncatdlg.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -200,7 +200,7 @@
                 TInt selected = iListbox->CurrentItemIndex();
                 TInt noi = iListbox->Model()->NumberOfItems();
                 // If it is the last then the previous will be selected.
-                if( selected == noi-1 )
+                if( ( selected == noi-1 ) && ( selected > 0 ))
                     {
                     selected--;
                     }
Binary file cmmanager/cmmgr/Framework/conf/cmmanager.confml has changed
Binary file cmmanager/cmmgr/Framework/conf/cmmanager_10207376.crml has changed
--- a/cmmanager/cmmgr/Plugins/cmpluginvpn/src/cmpluginvpn.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/cmmanager/cmmgr/Plugins/cmpluginvpn/src/cmpluginvpn.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -246,7 +246,16 @@
                 User::Leave( KErrNotSupported );
                 }
 
-            retVal = ServiceRecord().iServiceNetwork;
+            TUint32 snapId = iVirtualRecord->iNextLayerSNAP;
+            if ( snapId > KCmDefaultDestinationAPTagId &&
+                    snapId < ( KCmDefaultDestinationAPTagId+255 ) )
+                {
+                retVal = snapId - KCmDefaultDestinationAPTagId;
+                }
+            else
+                {
+                retVal = 0;
+                }
             }
             break;
         case ECmNextLayerIapId:    
--- a/connectionmonitoring/connectionmonitorui/inc/ConnectionInfoBase.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connectionmonitorui/inc/ConnectionInfoBase.h	Thu Aug 19 10:18:49 2010 +0300
@@ -391,6 +391,19 @@
         */
         void InitializeConnectionInfoL();
 
+        /**
+         * Compare the provided UID array with the current cached UID array
+         * iClientBuf.
+         * @param aClients New array of UIDs.
+         * @return ETrue if the contents are the same, EFalse otherwise.
+         */
+        TBool IsTheSameUids( TConnMonClientEnumBuf& aClients );
+
+        /**
+         * Copy the provided UIDs into the cached UID array.
+         * @param aClients New array of UIDs.
+         */
+        void CopyUidsToBuf( TConnMonClientEnumBuf& aClients );
 
     protected:
         
@@ -478,6 +491,13 @@
         * The active object for info. refreshing. NOT Owned.
         */
         CActiveWrapper*                     iActiveWrapper;
+
+        /**
+         * Buffer to cache a connection's client application UIDs.
+         * These are kept in cache so application names are resolved only when
+         * the client list has changed.
+         */
+        TConnMonClientEnumBuf               iClientBuf;
     };
 
 
--- a/connectionmonitoring/connectionmonitorui/src/ConnectionInfoBase.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connectionmonitorui/src/ConnectionInfoBase.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -34,7 +34,11 @@
 
 const TUint KUpArrowChar = 0x2191; ///< ASCII code of UpArrow
 const TUint KDownArrowChar = 0x2193; ///< ASCII code of DownArrow
-const TUint KBannedServerUID = 0x101fd9c5; // Banned DHCP server UID
+
+#ifndef _DEBUG
+const TUint KHiddenDhcpServerUid = 0x101fd9c5; ///< Hidden DHCP server UID (dhcpserv.exe)
+const TUint KHiddenDnsServerUid = 0x10000882; ///< Hidden DNS server UID (dnd.exe)
+#endif
 
 const TInt KFeedsServerUid         = 0x1020728E;
 const TInt KDownloadMgrServerUid   = 0x10008D60;
@@ -82,6 +86,7 @@
     iConnectionStatus = EConnectionUninitialized;
     iConnectionId = aConnectionId;
     iConnectionBearerType = aConnectionBearerType;
+    iClientBuf().iCount = 0;
     CMUILOGGER_WRITE( "CConnectionInfoBase constuctor - end " );
     }
 
@@ -492,160 +497,291 @@
 TInt CConnectionInfoBase::RefreshAppNamesL()
     {
     CMUILOGGER_ENTERFN( "CConnectionInfoBase::RefreshAppNamesL" );
-    
+
     TInt sharings( 0 );
-    
-if ( IsAlive() )
-    {
-    if ( iAppNames )
-        {
-        iAppNames->Reset();
-        HBufC* actAppName = NULL;
-        // Check whether it is an internal or external (modem) connection
-        // External (modem) connections does not need application name
-        if ( iConnectionBearerType < EBearerExternalCSD )
-            {
-            TInt count( 0 );
-            TConnMonClientEnumBuf clientBuf;
-            iActiveWrapper->StartGetConnSharings( iConnectionId,
-                                                  iConnectionMonitor,
-                                                  clientBuf );
-            
-            TInt err( iActiveWrapper->iStatus.Int() );
-            CMUILOGGER_WRITE_F( "RefreshSharings status: %d", err );
-            
-            if ( !err )
-                {
-                count = clientBuf().iCount;
-                }
-                
-            CMUILOGGER_WRITE_F( "clientBuf().iCount: %d", count );
-                
-#ifndef __WINS__ // Appl. uid is always zero in emulator
-
-            RApaLsSession appSess;
-            TApaAppInfo appInfo;
-
-            // The connection could be shared by several applications
-            User::LeaveIfError( appSess.Connect() );
-                    
-            TUint i;
-            for ( i = 0; i < count; i++ )
-                {
-                actAppName = NULL;
-                appInfo.iCaption.Zero();
-
-                TInt result = appSess.GetAppInfo( appInfo, 
-                                                  clientBuf().iUid[i] );
 
-                //================================
-                CMUILOGGER_WRITE_F( "result: %d", result ); 
-                CMUILOGGER_WRITE_F( "iClientInfo.iUid[i].iUid: %x", 
-                                    clientBuf().iUid[i].iUid );
-                
-                if ( result != KErrNone )
+    if ( IsAlive() )
+        {
+        if ( iAppNames )
+            {
+            // Check whether it is an internal or external (modem) connection
+            // External (modem) connections does not need application name
+            if ( iConnectionBearerType >= EBearerExternalCSD )
+                {
+                CMUILOGGER_WRITE( "External (modem) connections does not need application name" );
+                return sharings;
+                }
+            else
+                {
+                TInt count( 0 );
+                TConnMonClientEnumBuf clientBuf;
+                iActiveWrapper->StartGetConnSharings( iConnectionId,
+                                                      iConnectionMonitor,
+                                                      clientBuf );
+
+                TInt err( iActiveWrapper->iStatus.Int() );
+                CMUILOGGER_WRITE_F( "RefreshSharings status: %d", err );
+
+                if ( !err )
                     {
-                    TInt resId = 0;
-                    switch ( clientBuf().iUid[i].iUid )
-                        {
-                        case KMessagingServerUid: // Messaging
-                            {
-                            resId = R_QTN_CMON_SHARING_APP_MSG_SERVER;
-                            break;
-                            }
-                        case KDownloadMgrServerUid: // Downloads
-                            {
-                            resId = R_QTN_CMON_SHARING_APP_DL_MG;
-                            break;
-                            }
-                        case KFeedsServerUid: // Web Feeds
-                            {
-                            resId = R_QTN_CMON_SHARING_APP_RSS_SERVER;
-                            break;
-                            }
-                        case KJavaVMUid: // Application
-                            {
-                            resId = R_QTN_CMON_SHARING_APP_JAVA_MIDLET;
-                            break;
-                            }
-                        case KBannedServerUID:
-                            {   // Forget about DHCP server!
-                            break;
-                            }
-                        case KSUPLServerUid:
-                            {
-                            resId = R_QTN_CMON_SHARING_APP_SUPL;
-                            break;
-                            }
-                        default: // (unknown)
-                            {
-                            resId = R_QTN_CMON_SHARING_APP_UNKNOWN;
-                            break;
-                            }
-                        }
+                    count = clientBuf().iCount;
+                    }
+                CMUILOGGER_WRITE_F( "clientBuf().iCount: %d", count );
 
-                    if ( resId )
-                        {
-                        actAppName = StringLoader::LoadL( resId );
-                        }
+                if ( IsTheSameUids( clientBuf ) )
+                    {
+                    // Same client list, use cached application names.
+                    CMUILOGGER_WRITE( "Client list unchanged, use cached names" );
+                    CMUILOGGER_WRITE_F( "sharings: %d", iAppNames->Count() );
+                    return iAppNames->Count();
                     }
                 else
                     {
-                    actAppName =  HBufC::NewL( appInfo.iCaption.Length() );
-                    TPtr actAppNameBuf = actAppName->Des();
-                    actAppNameBuf.Append( appInfo.iCaption );
+                    CMUILOGGER_WRITE( "Client list changed, update names" );
+                    CopyUidsToBuf ( clientBuf );
                     }
 
-                if ( actAppName )
+                iAppNames->Reset();
+                HBufC* actAppName = NULL;
+
+#ifndef __WINS__ // Appl. uid is always zero in emulator
+
+                RApaLsSession appSess;
+                TApaAppInfo appInfo;
+
+                // The connection could be shared by several applications
+                User::LeaveIfError( appSess.Connect() );
+
+                TUint i;
+                for ( i = 0; i < count; i++ )
                     {
-                    iAppNames->AppendL( actAppName->Des() );        
-                    delete actAppName;
+                    actAppName = NULL;
+                    appInfo.iCaption.Zero();
+
+                    TInt result = appSess.GetAppInfo( appInfo,
+                            clientBuf().iUid[i] );
+
+                    //================================
+                    CMUILOGGER_WRITE_F( "result: %d", result );
+                    CMUILOGGER_WRITE_F( "iClientInfo.iUid[i].iUid: %x",
+                            clientBuf().iUid[i].iUid );
+
+                    if ( result != KErrNone )
+                        {
+                        TInt resId = 0;
+                        switch ( clientBuf().iUid[i].iUid )
+                            {
+                            case KMessagingServerUid: // Messaging
+                                {
+                                resId = R_QTN_CMON_SHARING_APP_MSG_SERVER;
+                                break;
+                                }
+                            case KDownloadMgrServerUid: // Downloads
+                                {
+                                resId = R_QTN_CMON_SHARING_APP_DL_MG;
+                                break;
+                                }
+                            case KFeedsServerUid: // Web Feeds
+                                {
+                                resId = R_QTN_CMON_SHARING_APP_RSS_SERVER;
+                                break;
+                                }
+                            case KJavaVMUid: // Application
+                                {
+                                resId = R_QTN_CMON_SHARING_APP_JAVA_MIDLET;
+                                break;
+                                }
+#ifndef _DEBUG
+                            // Hide DHCP & DNS from UI in release build.
+                            case KHiddenDhcpServerUid:
+                            case KHiddenDnsServerUid:
+                                {
+                                break;
+                                }
+#endif
+                            case KSUPLServerUid:
+                                {
+                                resId = R_QTN_CMON_SHARING_APP_SUPL;
+                                break;
+                                }
+                            default: // (unknown)
+                                {
+                                resId = R_QTN_CMON_SHARING_APP_UNKNOWN;
+                                break;
+                                }
+                            }
+
+                        if ( resId && resId != R_QTN_CMON_SHARING_APP_UNKNOWN  )
+                            {
+                            actAppName = StringLoader::LoadL( resId );
+                            }
+                        else if ( resId ) // Try to find application process name from system.
+                            {
+                            TFileName name;
+                            TFindProcess find;
+                            TBool name_solved( EFalse );
+                            while ( find.Next( name ) == KErrNone )
+                                {
+                                RProcess ph;
+                                TInt err2( KErrNone );
+                                err2 = ph.Open( name );
+
+                                if ( err2 )
+                                    {
+                                    ph.Close();
+                                    }
+                                else
+                                    {
+                                    TUidType procUid = ph.Type();
+                                    ph.Close();
+
+                                    // There are three UIDs in procUid. The last one is the second
+                                    // UID defined in MMP file and clientBuf().iUid[i].iUid is also
+                                    // the same kind of UID. So, we only need to compare them to
+                                    // find application name.
+                                    if ( procUid[2].iUid == clientBuf().iUid[i].iUid )
+                                        {
+                                        // Name is in format "app_name[uid]001", so cut rest of
+                                        // string starting from "[".
+                                        TInt index = name.LocateReverse('[');
+                                        if ( index >= 1 )
+                                            {
+                                            name.SetLength( index );
+                                            }
+
+                                        actAppName = HBufC::NewL( name.Length() );
+                                        TPtr actAppNameBuf = actAppName->Des();
+                                        actAppNameBuf.Append( name );
+
+#ifdef _DEBUG
+                                        CMUILOGGER_WRITE( "--------------------" );
+                                        CMUILOGGER_WRITE( " Application is Found:" );
+                                        CMUILOGGER_WRITE_F( "Client Uid: %x", clientBuf().iUid[i].iUid );
+                                        CMUILOGGER_WRITE_F( "Proc Uid: %x", procUid[2].iUid );
+                                        CMUILOGGER_WRITE_F( "App Name: %S", &name);
+                                        CMUILOGGER_WRITE( "--------------------" );
+#endif
+
+                                        name_solved = ETrue;
+                                        break;
+                                        }
+                                    }
+                                }
+
+                            if ( !name_solved )
+                                {
+                                actAppName = StringLoader::LoadL( R_QTN_CMON_SHARING_APP_UNKNOWN );
+                                }
+                            }
+                        }
+                    else
+                        {
+                        actAppName = HBufC::NewL( appInfo.iCaption.Length() );
+                        TPtr actAppNameBuf = actAppName->Des();
+                        actAppNameBuf.Append( appInfo.iCaption );
+                        }
+
+                    if ( actAppName )
+                        {
+                        iAppNames->AppendL( actAppName->Des() );
+                        delete actAppName;
+                        }
                     }
-                }
 
                 iAppNames->Sort();
                 appSess.Close();
 #else
-            TInt countBan( 0 );
+                TInt countBan( 0 );
 
-            if ( !err )
-                {
-                // remove the DHCP server is not actually 
-                // an owner of the connection
-                for ( TUint tmp = 0; tmp < count; ++tmp )
+#ifndef _DEBUG
+                if ( !err )
                     {
-                    TUid uid = clientBuf().iUid[tmp];
-            
-                    if ( uid.iUid == KBannedServerUID )
+                    // Remove DHCP and DNS from the client list. 
+                    for ( TUint tmp = 0; tmp < count; tmp++ )
                         {
-                        ++countBan;
-                        }
-                    } // end
-                }
+                        TUid uid = clientBuf().iUid[tmp];
 
-            _LIT( KStrApplication, "Application" );
-            // Give a dummy name of the application
-            for ( TInt i = 0; i < ( count - countBan ); i++ )
-                {
-                iAppNames->AppendL( KStrApplication );
-                }
+                        if ( uid.iUid == KHiddenDhcpServerUid || uid.iUid == KHiddenDnsServerUid )
+                            {
+                            countBan++;
+                            }
+                        }
+                    }
+#endif
+
+                _LIT( KStrApplication, "Application" );
+                // Give a dummy name for all applications.
+                for ( TInt i = 0; i < ( count - countBan ); i++ )
+                    {
+                    iAppNames->AppendL( KStrApplication );
+                    }
 
 #endif // __WINS__
+                } // End of else in if ( iConnectionBearerType > EBearerExternalCSD )
+            sharings = iAppNames->Count();
+            CMUILOGGER_WRITE_F( "sharings: %d", sharings );
+            } // End of if ( iAppNames )
+        } // End of if ( IsAlive() )
 
-            }
-        /* modem connections does not need application name
-        else 
-            {
-            }
-        */
-        sharings = iAppNames->Count();
-        }
-    }
-        
     CMUILOGGER_LEAVEFN( "CConnectionInfoBase::RefreshAppNamesL" );
     return sharings;
     }
 
+// ---------------------------------------------------------
+// CConnectionInfoBase::IsTheSameUids
+// ---------------------------------------------------------
+//
+TBool CConnectionInfoBase::IsTheSameUids( TConnMonClientEnumBuf& aClients )
+    {
+    TBool ret( EFalse );
+
+    if ( iClientBuf().iCount != aClients().iCount )
+        {
+        return ret;
+        }
+    else
+        {
+        TInt count = aClients().iCount;
+        for ( TInt i = 0; i < count; i++ )
+            {
+            // Is the current value inside aClients found from iClientBuf.
+            TBool found( EFalse );
+            for ( TInt j = 0; j < count; j++ )
+                {
+                if ( aClients().iUid[i].iUid == iClientBuf().iUid[j].iUid )
+                    {
+                    found = ETrue;
+                    break;
+                    }
+                }
+
+            if ( !found )
+                {
+                return ret;
+                }
+            }
+
+        // If we reach this point, aClients contents are identical with iClientBuf.
+        ret = ETrue;
+        }
+
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CConnectionInfoBase::CopyUidsToBuf
+// ---------------------------------------------------------
+//
+void CConnectionInfoBase::CopyUidsToBuf( TConnMonClientEnumBuf& aClients )
+    {
+    TInt count = aClients().iCount;
+
+    for ( TInt i = 0; i < count; i++ )
+        {
+        iClientBuf().iUid[i].iUid = aClients().iUid[i].iUid;
+        }
+    iClientBuf().iCount = count;
+    }
 
 // ---------------------------------------------------------
 // CConnectionInfoBase::ToDetailsListBoxItemTextL
--- a/connectionmonitoring/connectionmonitorui/src/CsdConnectionInfo.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connectionmonitorui/src/CsdConnectionInfo.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -301,7 +301,7 @@
 
             TInt sharing = RefreshAppNamesL();
 
-            if ( sharing > 1 )
+            if ( sharing >= 1 )
                 {
                 if ( iDetailsArray->Count() > 10 )
                     {
@@ -416,7 +416,7 @@
         {
         TInt sharing = RefreshAppNamesL();
         
-        if ( sharing > 1 )
+        if ( sharing >= 1 )
             {
             for ( TInt i = 0; i < sharing; i++ )
                 {
--- a/connectionmonitoring/connectionmonitorui/src/EasyWLANConnectionInfo.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connectionmonitorui/src/EasyWLANConnectionInfo.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -210,7 +210,7 @@
 
     TInt sharing = RefreshAppNamesL();
         
-    if ( sharing > 1 )
+    if ( sharing >= 1 )
         {
         for ( TInt i = 0; i < ( sharing ); i++ )
             {
@@ -296,7 +296,7 @@
 
     TInt sharing = RefreshAppNamesL();
 
-    if ( sharing > 1 )
+    if ( sharing >= 1 )
         {
         if ( count >= realElementsMaxCount )
             {  
--- a/connectionmonitoring/connectionmonitorui/src/GprsConnectionInfo.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connectionmonitorui/src/GprsConnectionInfo.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -302,7 +302,7 @@
             {
             TInt sharing = RefreshAppNamesL();
                 
-            if ( sharing > 1 )
+            if ( sharing >= 1 )
                 {
                 if ( iDetailsArray->Count() > 10 )
                     {                
@@ -399,7 +399,7 @@
         {
         TInt sharing = RefreshAppNamesL();
 
-        if ( sharing > 1 )
+        if ( sharing >= 1 )
             {
             for ( TInt i = 0; i < sharing; i++ )
                 {
--- a/connectionmonitoring/connectionmonitorui/src/WlanConnectionInfo.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connectionmonitorui/src/WlanConnectionInfo.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -685,7 +685,7 @@
                                  
     TInt sharing = RefreshAppNamesL();
 
-    if ( sharing > 1 )
+    if ( sharing >= 1 )
         {
         for ( TInt i = 0; i < sharing; i++ )
             {
@@ -776,7 +776,7 @@
     
     TInt sharing = RefreshAppNamesL();
 
-    if ( sharing > 1 )
+    if ( sharing >= 1 )
         {
         if ( count >= realElementsMaxCount ) // 15
             {  
--- a/connectionmonitoring/connmon/connectionmonitor/group/ConnMon.mmp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/group/ConnMon.mmp	Thu Aug 19 10:18:49 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"
@@ -57,6 +57,7 @@
 
 SOURCE          ConnMonBearerNotifier.cpp ConnMonEGprsNotifier.cpp ConnMonHsdpaNotifier.cpp
 SOURCE          cellulardatausagekeyupdater.cpp
+SOURCE          connmondialupoverridenotifier.cpp
 
 
 USERINCLUDE     ../inc
--- a/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonDef.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonDef.h	Thu Aug 19 10:18:49 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"
@@ -108,6 +108,16 @@
     };
 
 /**
+ * Status values for dial-up PDP context override functionality.
+ */
+enum TConnMonDialUpOverrideStatus
+    {
+    EConnMonDialUpOverrideDisabled = 0,
+    EConnMonDialUpOverrideInactive,
+    EConnMonDialUpOverrideActive
+    };
+
+/**
  * TEventInfo
  */
 class TEventInfo
--- a/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonIAP.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonIAP.h	Thu Aug 19 10:18:49 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"
@@ -401,10 +401,9 @@
          * closed event.
          * @since
          * @param aConnection The connection info. On return, will contain connection id.
-         * @param aSent On return, value is ETrue if event has been sent, EFalse otherwise.
          * @return KErrNone if successfull, otherwise a system wide error code.
          */
-        TBool GetDeleteNotifyStatus( TConnInfo& aConnection, TBool& aSent );
+        TBool GetDeleteNotifyStatus( TConnInfo& aConnection );
 
         /**
          * Gets a pointer to the activity notifier object for the given connection id.
@@ -492,6 +491,12 @@
         void GetActiveConnectionsIds( const TUint& aBearerId, RArray<TUint>& aIdArray );
 
         /**
+         * Return ETrue if one or more active packetdata connections are found,
+         * EFalse otherwise.
+         */
+        TBool ActivePacketdataConnectionsFound();
+
+        /**
          * Tells whether bearer is supported or not.
          * @since
          * @param aConnectionId Generic bearer id (EBearerIdGPRS, EBEarerIdCSD).
--- a/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonNoti.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonNoti.h	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2007 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"
@@ -674,6 +674,35 @@
         */
         void SetInterfaceClosed();
 
+        /**
+        * Tells whether interface has been closed or not.
+        * @since
+        * @return ETrue if interface has been closed, otherwise EFalse.
+        */
+        TBool InterfaceClosed();
+
+        /**
+        * Sets link layer status to closed.
+        * @since
+        * @return void.
+        */
+        void SetLinkLayerClosed();
+
+        /**
+        * Sets link layer status to NOT closed.
+        * @since
+        * @return void.
+        */
+        void SetLinkLayerOpen();
+
+        /**
+        * Return ETrue if KLinkLayerClosed has been received.
+        * @since
+        * @return ETrue if KLinkLayerClosed has been received, otherwise returns EFalse.
+        */
+        TBool LinkLayerClosed();
+
+
     private: // Methods from base classes
          /**
         * From CActive Cancels the asyncronous request
@@ -700,6 +729,7 @@
         TUint                         iTotalUplinkDataVolume;
         TBool                         iDeleteSent;
         TBool                         iInterfaceClosed;
+        TBool                         iLinkLayerClosed;
     };
 
 /**
--- a/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonServ.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonServ.h	Thu Aug 19 10:18:49 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"
@@ -134,6 +134,8 @@
 class TConnMonSNAPInfo;
 class TConnMonId;
 class CCellularDataUsageKeyUpdater;
+class CConnMonDialUpOverrideNotifier;
+class CConnMonDialUpOverrideTimer;
 
 /**
 * CConnMonServer
@@ -335,6 +337,23 @@
     inline CCellularDataUsageKeyUpdater* CellularDataUsageKeyUpdater() 
                      { return iCellularDataUsageKeyUpdater; }
 
+    /**
+     * Return the current dial-up PDP context override status.
+     */
+    inline TInt GetDialUpOverrideStatus() { return iDialUpOverrideStatus; }
+
+    /**
+     * Set the dial-up PDP context override feature status. Either activates or
+     * deactivates it. Does nothing if the feature itself has not been enabled.
+     */
+    void SetDialUpOverrideStatus( TInt aStatus );
+
+    /**
+     * Signals that all internal PDP connections have closed through the
+     * KDialUpConnection P&S-property.
+     */
+    void ConnectionsClosedForDialUpOverride();
+
 public:
     /**
      * From CServer Creates a new session for a client.
@@ -377,6 +396,15 @@
 
     CConnMonBearerGroupManager*   iBearerGroupManager;
     CCellularDataUsageKeyUpdater* iCellularDataUsageKeyUpdater;
+
+    // Notifier to listen for changes in the the KDialUpConnection P&S-property.
+    CConnMonDialUpOverrideNotifier* iDialUpOverrideNotifier;
+
+    // Timeout timer for the dial-up PDP context override feature.
+    CConnMonDialUpOverrideTimer* iDialUpOverrideTimer;
+
+    // Current status of the dial-up PDP context override feature.
+    TInt iDialUpOverrideStatus;
     };
 
 /**
@@ -462,6 +490,34 @@
     CConnMonServer* iServer;
     };
 
+/**
+* CConnMonDialUpOverrideTimer
+* A simple timer to ensure dial-up PDP context override feature can not stay
+* active longer than the specied timeout value.
+*/
+NONSHARABLE_CLASS( CConnMonDialUpOverrideTimer ) : public CActive
+    {
+public:
+    static CConnMonDialUpOverrideTimer* NewL( CConnMonServer* aServer );
+    static CConnMonDialUpOverrideTimer* NewLC( CConnMonServer* aServer );
+    virtual ~CConnMonDialUpOverrideTimer();
+
+private:
+    CConnMonDialUpOverrideTimer( CConnMonServer* aServer );
+    void ConstructL();
+
+public:
+    void Start();
+
+private:
+    void DoCancel();
+    void RunL();
+
+private: // Data
+    RTimer iTimer;
+    CConnMonServer* iServer;
+    };
+
 // INLINES
 inline CConnMonScheduler::TSignal::TSignal()
         :
--- a/connectionmonitoring/connmon/connectionmonitor/inc/cellulardatausagekeyupdater.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/inc/cellulardatausagekeyupdater.h	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-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"
@@ -38,6 +38,11 @@
     
     void UpdateKeyL( const TInt aRegistration ) const;
 
+    /**
+     * Return ETrue if dial-up PDP context override feature is enabled.
+     */
+    TBool DialUpOverrideEnabled() const;
+
 private:
     CCellularDataUsageKeyUpdater(
             CConnMonServer* aServer );
@@ -56,7 +61,13 @@
 private:
     CConnMonServer* iServer;
     TUint32         iTableId;
-    CRepository*    iRepository;
+
+    // CommsDat central repository.
+    CRepository*    iCommsRepository;
+
+    // CmManager central repository.
+    CRepository*    iCmmRepository;
+
     TInt            iErrorCounter;
     // used for complete runl. Not owned.
     TRequestStatus* iInitStatus;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectionmonitoring/connmon/connectionmonitor/inc/connmondialupoverridenotifier.h	Thu Aug 19 10:18:49 2010 +0300
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Listens for changes in dial-up PDP context override P&S-key.
+*
+*/
+
+#ifndef CONNMONDIALUPOVERRIDENOTIFIER_H
+#define CONNMONDIALUPOVERRIDENOTIFIER_H
+
+class CConnMonServer;
+
+/**
+ * Stop requesting new notifications after this many consecutive errors.
+ */
+const TInt KConnMonPsEventErrorThreshold = 80;
+
+/**
+ * Maximum time that dial-up PDP context override is allowed to stay on.
+ */
+const TUint KConnMonDialUpOverrideInterval = 45000000; // 45sec
+
+/**
+ * Read policy for dial-up PDP context override key.
+ */
+_LIT_SECURITY_POLICY_PASS( KDialUpOverrideReadC0 );
+
+/**
+ * Write policy for dial-up PDP context override key.
+ */
+_LIT_SECURITY_POLICY_C2( KDialUpOverrideWriteC2, ECapabilityNetworkControl, ECapabilityNetworkServices );
+
+/**
+ * An active object to listen for changes in the dial-up PDP context override
+ * P&S-key. Only used if the feature is enabled by the CenRep key
+ * KDialUpOverride in CmManager repository (KCRUidCmManager).
+ */
+NONSHARABLE_CLASS( CConnMonDialUpOverrideNotifier ) : public CActive
+    {
+public:
+    static CConnMonDialUpOverrideNotifier* NewL( CConnMonServer* aServer );
+    static CConnMonDialUpOverrideNotifier* NewLC( CConnMonServer* aServer );
+    virtual ~CConnMonDialUpOverrideNotifier();
+
+    /**
+     * Set the KDialUpConnection-property in Connection Monitor RProperty
+     * category to the initial state of EConnMonReady.
+     */
+    TInt ResetStatus();
+
+private:
+    CConnMonDialUpOverrideNotifier( CConnMonServer* aServer );
+    void ConstructL();
+    void RequestNotifications();
+
+private: // Methods from base class
+    void DoCancel();
+    void RunL();
+
+private:
+    // Pointer back to ConnMon server class.
+    CConnMonServer* iServer;
+
+    // Counter for notification errors.
+    TInt iErrorCounter;
+
+    // Dial-up PDP context override property.
+    // Used to signal an incoming dial-up connection and the completion of
+    // preparatory actions by ConnMon (Closing down internal PDP contexts).
+    RProperty iDialUpProperty;
+    };
+
+#endif // CONNMONDIALUPOVERRIDENOTIFIER_H
+
+// End of file
--- a/connectionmonitoring/connmon/connectionmonitor/src/CPsdFax.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/src/CPsdFax.cpp	Thu Aug 19 10:18:49 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"
@@ -737,7 +737,7 @@
         iOpen = ETrue;
 
         // Start status notifier
-        if ( !iStatusNotifier->IsActive() )
+        if ( iStatusNotifier && !iStatusNotifier->IsActive() )
             {
             LOGIT("OpenContext: start status notifier")
             iStatusNotifier->Start( iContext );
@@ -850,7 +850,7 @@
     err = status.Int();
 
     // Remove from server tables if status notifier is not active.
-    if ( !iStatusNotifier->IsActive() )
+    if ( !iStatusNotifier || !iStatusNotifier->IsActive() )
         {
         // Remove from server tables
         RemoveFromServer();
@@ -1284,6 +1284,11 @@
             // Close the context
             iConnDataModule->CloseContext();
 
+            // Dial-up connection has gone down. Make sure the dial-up PDP
+            // context override is disabled.
+            LOGIT("External PSD connection status EStatusDeleted, disabling dial-up override")
+            iServer->SetDialUpOverrideStatus( EConnMonDialUpOverrideInactive );
+
             // Delete all old connection objects. This method should be used
             // carefully because it will delete ConnectionData and
             // statusnotifier objects. Get out fast from RunL().
@@ -1292,6 +1297,13 @@
             // Stop listening
             return;
             }
+        else if ( iContextStatus == RPacketContext::EStatusActive )
+            {
+            // Dial-up connection has been established. Make sure the dial-up
+            // PDP context override is disabled.
+            LOGIT("External PSD connection status EStatusActive, disabling dial-up override")
+            iServer->SetDialUpOverrideStatus( EConnMonDialUpOverrideInactive );
+            }
 
         // New request
         Receive();
--- a/connectionmonitoring/connmon/connectionmonitor/src/ConnMonIAP.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/src/ConnMonIAP.cpp	Thu Aug 19 10:18:49 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"
@@ -421,7 +421,6 @@
 TInt CConnMonIAP::EnumerateConnections( TUint& aCount )
     {
     // Server must be 'blocked' while updating the connection table.
-    TConnectionInfoBuf connInfoBuf;
     TBearerInfo bearerInfo;
     TConnInfo connInfo( 0, 0, 0, 0, bearerInfo );
     TInt err( KErrNone );
@@ -2298,6 +2297,18 @@
             }
 
         iConnInfos.Remove( index );
+
+        // If dial-up PDP context override feature is enabled and active (a dial-up
+        // connection is about to start), connection closures need to be reported
+        // in case dial-up connection is waiting for a free PDP context.
+        if ( iServer->GetDialUpOverrideStatus() == EConnMonDialUpOverrideActive )
+            {
+            if ( !ActivePacketdataConnectionsFound() )
+                {
+                iServer->ConnectionsClosedForDialUpOverride();
+                }
+            }
+
         err = KErrNone;
         }
 
@@ -2965,7 +2976,7 @@
 // CConnMonIAP::GetDeleteNotifyStatus
 // -----------------------------------------------------------------------------------
 //
-TInt CConnMonIAP::GetDeleteNotifyStatus( TConnInfo& aConnection, TBool& aSent )
+TInt CConnMonIAP::GetDeleteNotifyStatus( TConnInfo& aConnection )
     {
     TInt index( KErrNotFound );
 
@@ -2984,29 +2995,6 @@
     aConnection.iConnectionId = iConnInfos[index].iConnectionId;
     aConnection.iBearer = iConnInfos[index].iBearer;
 
-    TInt connectionStatus( 0 );
-    GetConnectionStatus( index, connectionStatus );
-
-    if ( ( iConnInfos[index].iConnDownNotifier != 0 ) &&
-         ( iConnInfos[index].iProgressNotifier != 0 ) )
-        {
-        if ( !iConnInfos[index].iConnDownNotifier->DeleteSent() &&
-             !iConnInfos[index].iConnDownNotifier->IsActive() &&
-             ( !iConnInfos[index].iProgressNotifier->IsActive() ||
-               ( connectionStatus != KLinkLayerOpen ) ) )
-            {
-            aSent = EFalse;
-            }
-        else
-            {
-            aSent = ETrue;
-            }
-        }
-    else
-        {
-        aSent = EFalse;
-        }
-
     return KErrNone;
     }
 
@@ -3339,6 +3327,64 @@
     //LOGEXITFN("CConnMonIAP::GetActiveConnectionsIds()")
     }
 
+// -----------------------------------------------------------------------------
+// CConnMonIAP::ActivePacketdataConnectionsFound
+// Return ETrue if one or more active packetdata connections are found,
+// EFalse otherwise.
+// -----------------------------------------------------------------------------
+//
+TBool CConnMonIAP::ActivePacketdataConnectionsFound()
+    {
+    LOGENTRFN("CConnMonIAP::ActivePacketdataConnectionsFound()")
+    TBool result( EFalse );
+    TInt unknownBearers( 0 );
+
+    const TInt count = iConnInfos.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        // Bearer might still be uninitialized
+        if ( iConnInfos[i].iBearer == EBearerUnknown )
+            {
+            unknownBearers++;
+            }
+        else if ( iConnInfos[i].iBearer == EBearerGPRS ||
+                iConnInfos[i].iBearer == EBearerEdgeGPRS ||
+                iConnInfos[i].iBearer == EBearerWCDMA )
+            {
+            result = ETrue;
+            break;
+            }
+        }
+    if ( !result && unknownBearers )
+        {
+        for ( TInt i = 0; i < count; i++ )
+            {
+            if ( iConnInfos[i].iBearer == EBearerUnknown )
+                {
+                LOGIT1("ActivePacketdataConnectionsFound: bearer unknown for conn.id %d",
+                        iConnInfos[i].iConnectionId)
+                TInt err = GetBearer(
+                        iConnInfos[i].iConnectionId,
+                        iConnInfos[i].iBearer,
+                        iConnInfos[i].iBearerInfo );
+
+                if ( err == KErrNone )
+                    {
+                    if ( iConnInfos[i].iBearer == EBearerGPRS ||
+                            iConnInfos[i].iBearer == EBearerEdgeGPRS ||
+                            iConnInfos[i].iBearer == EBearerWCDMA )
+                        {
+                        result = ETrue;
+                        break;
+                        }
+                    }
+                }
+            }
+        }
+
+    LOGEXITFN1("CConnMonIAP::ActivePacketdataConnectionsFound()", result)
+    return result;
+    }
 
 // -----------------------------------------------------------------------------
 // CConnMonIAP::GetBearerSupportInfo
--- a/connectionmonitoring/connmon/connectionmonitor/src/ConnMonNoti.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/src/ConnMonNoti.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2007 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"
@@ -170,10 +170,8 @@
                 }
             else
                 {
-                TBool alreadyNotified( EFalse );
-
                 // This updates the correct 'iConnectionId' and 'iBearer' to connInfo
-                TInt ret = iServer->Iap()->GetDeleteNotifyStatus( connInfo, alreadyNotified );
+                TInt ret = iServer->Iap()->GetDeleteNotifyStatus( connInfo );
 
                 if ( ret == KErrNone )
                     {
@@ -202,8 +200,11 @@
                                 iServer->Iap()->EnableWlanScan();
                                 }
 
-                            // Progress and subconn notifiers have died and no delete has been sent
-                            subConnUpDownNotifier->SendDeletedEvent();
+                            if ( subConnUpDownNotifier->LinkLayerClosed() )
+                                {
+                                // KLinkLayerClosed already received, finish with this connection
+                                subConnUpDownNotifier->SendDeletedEvent();
+                                }
                             }
                         else
                             {
@@ -598,6 +599,7 @@
                         if ( !subConnUpDownNotifier->IsActive() )
                             {
                             subConnUpDownNotifier->Receive();
+                            subConnUpDownNotifier->SetLinkLayerOpen();
                             }
                         }
 
@@ -631,7 +633,29 @@
                         {
                         LOGIT("CProgressNotifier::RunL triggered HandleAvailabilityChange()")
                         iServer->AvailabilityManager()->HandleAvailabilityChange();	
-                        }	    
+                        }
+
+                    }
+                else if ( iInfoBuf().iStage == KLinkLayerClosed )
+                    {
+                    CSubConnUpDownNotifier* subConnUpDownNotifier = 0;
+
+                    TInt err = iServer->Iap()->GetSubConnUpDownNotifier(
+                               iConnectionId,
+                               &subConnUpDownNotifier );
+
+                    if ( KErrNone == err )
+                        {
+                        subConnUpDownNotifier->SetLinkLayerClosed();
+
+                        if ( subConnUpDownNotifier->InterfaceClosed() )
+                            {
+                            // EInterfaceDown has arrived before KLinkLayerClosed
+                            // Let's finish with this connection.
+                            subConnUpDownNotifier->SendDeletedEvent();
+                            return;
+                            }
+                        }
                     }
 
                 iFilter = KNoFiltering;
@@ -2116,6 +2140,8 @@
     {
     if ( !iDeleteSent )
         {
+        LOGIT("CSubConnUpDownNotifier::SendDeletedEvent")
+
         iEventInfo.Reset();
 
         iEventInfo.iEventType       = EConnMonDeleteConnection;
@@ -2176,6 +2202,41 @@
     iInterfaceClosed = ETrue;
     }
 
+// -----------------------------------------------------------------------------
+// CSubConnUpDownNotifier::InterfaceClosed
+// -----------------------------------------------------------------------------
+//
+TBool CSubConnUpDownNotifier::InterfaceClosed()
+    {
+    return iInterfaceClosed;
+    }
+
+// -----------------------------------------------------------------------------
+// CSubConnUpDownNotifier::SetLinkLayerClosed
+// -----------------------------------------------------------------------------
+//
+void CSubConnUpDownNotifier::SetLinkLayerClosed()
+    {
+    iLinkLayerClosed = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CSubConnUpDownNotifier::SetLinkLayerOpen
+// -----------------------------------------------------------------------------
+//
+void CSubConnUpDownNotifier::SetLinkLayerOpen()
+    {
+    iLinkLayerClosed = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CSubConnUpDownNotifier::LinkLayerClosed
+// -----------------------------------------------------------------------------
+//
+TBool CSubConnUpDownNotifier::LinkLayerClosed()
+    {
+    return iLinkLayerClosed;
+    }
 
 // -----------------------------------------------------------------------------
 // CSubConnUpDownNotifier::DoCancel
@@ -2219,7 +2280,10 @@
                 // Is progress notifier still alive
                 if ( !progressNotifier->IsActive() )
                     {
+                    iStatus = KErrDied;
+                    // might delete this object
                     SendDeletedEvent();
+                    return;
                     }
                 }
             }
@@ -2240,6 +2304,8 @@
             LOGIT3("SERVER: EVENT -> Connection %d closed, u: %d, d: %d",
                     iConnectionId, iTotalUplinkDataVolume, iTotalDownlinkDataVolume)
 
+            iStatus = KErrDisconnected;
+
             CProgressNotifier* progressNotifier = 0;
             TInt err = iServer->Iap()->GetProgressNotifier( iConnectionId, &progressNotifier );
             if ( err == KErrNone )
@@ -2247,15 +2313,17 @@
                 // Progess notifier has stopped and allinterface closed event has arrived
                 if ( !progressNotifier->IsActive() )
                     {
+                    // might delete this object
                     SendDeletedEvent();
+                    return;
                     }
                 }
             else
                 {
+                // might delete this object
                 SendDeletedEvent();
+                return;
                 }
-
-            iStatus = KErrDisconnected;
             }
         else if ( ( event.iSubConnectionUniqueId == 0 ) &&
                   ( event.iEventType == ESubConnectionOpened ) )
--- a/connectionmonitoring/connmon/connectionmonitor/src/ConnMonServ.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/src/ConnMonServ.cpp	Thu Aug 19 10:18:49 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"
@@ -34,6 +34,7 @@
 #include "ConnMonBearerGroupManager.h"
 #include "connmoncommsdatnotifier.h"
 #include "cellulardatausagekeyupdater.h"
+#include "connmondialupoverridenotifier.h"
 
 // ============================ LOCAL FUNCTIONS ===============================
 
@@ -236,7 +237,21 @@
 CConnMonServer::CConnMonServer()
         :
         CPolicyServer( CActive::EPriorityStandard, KConnMonPolicy ),
-        iAvailabilityManager( NULL )
+        iIap( NULL ),
+        iEventQueue( NULL ),
+        iSessionCount( 0 ),
+        iShutdown( NULL ),
+        iContainerIndex( NULL ),
+        iCommsDatCache( NULL ),
+        iAvailabilityManager( NULL ),
+        iIapTableNotifier( NULL ),
+        iSnapTableNotifier( NULL ),
+        iVirtualTableNotifier( NULL ),
+        iBearerGroupManager( NULL ),
+        iCellularDataUsageKeyUpdater( NULL ),
+        iDialUpOverrideNotifier( NULL ),
+        iDialUpOverrideTimer( NULL ),
+        iDialUpOverrideStatus( EConnMonDialUpOverrideDisabled )
     {
     }
 
@@ -322,7 +337,18 @@
     
     iCellularDataUsageKeyUpdater = CCellularDataUsageKeyUpdater::NewL( this );
     LOGIT("ConstructL: CCellularDataUsageKeyUpdater constructed")
-    
+
+    // Add P&S listener for dial-up PDP context override, if feature enabled.
+    if ( iCellularDataUsageKeyUpdater->DialUpOverrideEnabled() )
+        {
+        iDialUpOverrideNotifier = CConnMonDialUpOverrideNotifier::NewL( this );
+        iDialUpOverrideStatus = EConnMonDialUpOverrideInactive;
+        LOGIT("ConstructL: Dial-up override notifier constructed")
+
+        // Construct dial-up PDP context override timer.
+        iDialUpOverrideTimer = CConnMonDialUpOverrideTimer::NewL( this );
+        }
+
     // Identify ourselves and open for service
     StartL( KConnectionMonitorServerName );
 
@@ -372,9 +398,15 @@
 
     // Bearer Group Manager
     delete iBearerGroupManager;
-    
+
     delete iCellularDataUsageKeyUpdater;
 
+    // Dial-up PDP context override timer.
+    delete iDialUpOverrideTimer;
+
+    // P&S listener for dial-up PDP context override.
+    delete iDialUpOverrideNotifier;
+
     FeatureManager::UnInitializeLib();
     }
 
@@ -784,6 +816,78 @@
     }
 
 // -----------------------------------------------------------------------------
+// Set the dial-up PDP context override feature status. Either activates or
+// deactivates it. Does nothing if the feature itself has not been enabled.
+// -----------------------------------------------------------------------------
+//
+void CConnMonServer::SetDialUpOverrideStatus( TInt aStatus )
+    {
+    LOGENTRFN("CConnMonServer::SetDialUpOverrideStatus()")
+
+    // Do nothing if whole feature is disabled.
+    LOGIT2("iDialUpOverrideStatus = %d, aStatus = %d", iDialUpOverrideStatus, aStatus)
+    if ( iDialUpOverrideStatus == EConnMonDialUpOverrideInactive &&
+            aStatus == EConnMonDialUpOverrideActive )
+        {
+        LOGIT("Setting dial-up override status from inactive to active")
+        // Start the dial-up override timer to ensure packetdata connectivity
+        // is restored to original state eventually. Normally it is restored
+        // after the dial-up connection has been successfully established.
+        iDialUpOverrideTimer->Start();
+        // Status must be set before updating cellular data usage key.
+        iDialUpOverrideStatus = aStatus;
+
+        // Disable cellular data usage until the expected dial-up
+        // connection has been established (or timeout).
+        TRAP_IGNORE( iCellularDataUsageKeyUpdater->UpdateKeyL( 0 ) );
+
+        LOGIT("SetDialUpOverrideStatus() triggered HandleAvailabilityChange()")
+        AvailabilityManager()->HandleAvailabilityChange();
+        }
+    else if ( iDialUpOverrideStatus == EConnMonDialUpOverrideActive &&
+            aStatus == EConnMonDialUpOverrideInactive )
+        {
+        LOGIT("Setting dial-up override status from active to inactive")
+        // Stop the dial-up override timer.
+        iDialUpOverrideTimer->Cancel();
+        // Status must be set before updating cellular data usage key.
+        iDialUpOverrideStatus = aStatus;
+
+        TInt registration( ENetworkRegistrationExtUnknown );
+        TInt err = iIap->GetNetworkRegistration_v2( registration );
+        if ( err == KErrNone )
+            {
+            TRAP_IGNORE( iCellularDataUsageKeyUpdater->UpdateKeyL( registration ) );
+            }
+        else
+            {
+            LOGIT1("GetNetworkRegistration_v2 failed <%d>", err)
+            }
+        iDialUpOverrideNotifier->ResetStatus();
+
+        LOGIT("SetDialUpOverrideStatus() triggered HandleAvailabilityChange()")
+        AvailabilityManager()->HandleAvailabilityChange();
+        }
+
+    LOGEXITFN("CConnMonServer::SetDialUpOverrideStatus()")
+    }
+
+// -----------------------------------------------------------------------------
+// Signals that all internal PDP connections have closed through the
+// KDialUpConnection P&S-property.
+// -----------------------------------------------------------------------------
+//
+void CConnMonServer::ConnectionsClosedForDialUpOverride()
+    {
+    LOGENTRFN("CConnMonServer::ConnectionsClosedForDialUpOverride()")
+    if ( iDialUpOverrideStatus == EConnMonDialUpOverrideActive )
+        {
+        iDialUpOverrideNotifier->ResetStatus();
+        }
+    LOGEXITFN("CConnMonServer::ConnectionsClosedForDialUpOverride()")
+    }
+
+// -----------------------------------------------------------------------------
 // CConnMonServer::CustomSecurityCheckL
 // Implements custom security checking for IPCs marked with
 // TSpecialCase::ECustomCheck.
@@ -881,4 +985,95 @@
     CActiveScheduler::Stop();
     }
 
-// End-of-file
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideTimer::NewL
+// -----------------------------------------------------------------------------
+//
+CConnMonDialUpOverrideTimer* CConnMonDialUpOverrideTimer::NewL(
+        CConnMonServer* aServer )
+    {
+    CConnMonDialUpOverrideTimer* self = CConnMonDialUpOverrideTimer::NewLC( aServer );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideTimer::NewLC
+// -----------------------------------------------------------------------------
+//
+CConnMonDialUpOverrideTimer* CConnMonDialUpOverrideTimer::NewLC(
+        CConnMonServer* aServer )
+    {
+    CConnMonDialUpOverrideTimer* self = new( ELeave ) CConnMonDialUpOverrideTimer( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideTimer::~CConnMonDialUpOverrideTimer
+// -----------------------------------------------------------------------------
+//
+CConnMonDialUpOverrideTimer::~CConnMonDialUpOverrideTimer()
+    {
+    Cancel();
+    iTimer.Close();
+    iServer = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideTimer::CConnMonDialUpOverrideTimer
+// -----------------------------------------------------------------------------
+//
+CConnMonDialUpOverrideTimer::CConnMonDialUpOverrideTimer(
+        CConnMonServer* aServer )
+        :
+        CActive( EConnMonPriorityNormal ),
+        iServer( aServer )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideTimer::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CConnMonDialUpOverrideTimer::ConstructL()
+    {
+    CActiveScheduler::Add( this );
+    User::LeaveIfError( iTimer.CreateLocal() );
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideTimer::Start
+// -----------------------------------------------------------------------------
+//
+void CConnMonDialUpOverrideTimer::Start()
+    {
+    if ( !IsActive() )
+        {
+        iTimer.After( iStatus, KConnMonDialUpOverrideInterval );
+        SetActive();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideTimer::DoCancel
+// -----------------------------------------------------------------------------
+//
+void CConnMonDialUpOverrideTimer::DoCancel()
+    {
+    iTimer.Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideTimer::RunL
+// -----------------------------------------------------------------------------
+//
+void CConnMonDialUpOverrideTimer::RunL()
+    {
+    LOGIT(".")
+    LOGIT1("RunL: CConnMonDialUpOverrideTimer <%d>", iStatus.Int())
+    iServer->SetDialUpOverrideStatus( EConnMonDialUpOverrideInactive );
+    }
+
+// End of file
--- a/connectionmonitoring/connmon/connectionmonitor/src/cellulardatausagekeyupdater.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/src/cellulardatausagekeyupdater.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-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"
@@ -71,7 +71,8 @@
     {
     // Cancel outstanding request, if exists
     Cancel();
-    delete iRepository;
+    delete iCommsRepository;
+    delete iCmmRepository;
     }
 
 // -----------------------------------------------------------------------------
@@ -81,50 +82,75 @@
 void CCellularDataUsageKeyUpdater::UpdateKeyL( const TInt aRegistration ) const
     {
     LOGENTRFN("CCellularDataUsageKeyUpdater::UpdateKeyL()")
-    LOGIT1("CCellularDataUsageKeyUpdater::UpdateKeyL: aRegistration <%d>", 
+    LOGIT1("CCellularDataUsageKeyUpdater::UpdateKeyL: aRegistration <%d>",
             aRegistration)
-                
-    TCmGenConnSettings occSettings = ReadGenConnSettingsL();
-  
+
     TInt value( ECmCellularDataUsageDisabled );
-        
-    if ( aRegistration == ENetworkRegistrationExtRoamingInternational )
-        {           
-        value = occSettings.iCellularDataUsageVisitor;
-        }
-    else if ( aRegistration == ENetworkRegistrationExtHomeNetwork || 
-              aRegistration == ENetworkRegistrationExtRoamingNational )
-        {           
-        value = occSettings.iCellularDataUsageHome;
+
+    // If dial-up PDP context override is active, disable cellular data usage (temporarily).
+    if ( iServer->GetDialUpOverrideStatus() != EConnMonDialUpOverrideActive )
+        {
+        TCmGenConnSettings occSettings = ReadGenConnSettingsL();
+
+        if ( aRegistration == ENetworkRegistrationExtRoamingInternational )
+            {
+            value = occSettings.iCellularDataUsageVisitor;
+            }
+        else if ( aRegistration == ENetworkRegistrationExtHomeNetwork ||
+                  aRegistration == ENetworkRegistrationExtRoamingNational )
+            {
+            value = occSettings.iCellularDataUsageHome;
+            }
         }
 
-    CRepository* cmRepository = NULL;
-    
-    TRAPD( err, cmRepository = CRepository::NewL( KCRUidCmManager ) )
-    
-    if ( err == KErrNone )
+    TInt previous( 0 );
+    TInt err = iCmmRepository->Get( KCurrentCellularDataUsage, previous );
+    if ( err == KErrNone && ( value != previous ) )
+        {
+        iCmmRepository->Set( KCurrentCellularDataUsage, value );
+        LOGIT1("KCurrentCellularDataUsage set to %d", value)
+        }
+    else
         {
-        TInt previous( 0 );
-        err = cmRepository->Get( KCurrentCellularDataUsage, previous );
-           
-        if ( err == KErrNone && ( value != previous ) )
+        LOGIT2("KCurrentCellularDataUsage already up-to-date %d <%d>", previous, err)
+        }
+
+    LOGEXITFN("CCellularDataUsageKeyUpdater::UpdateKeyL()")
+    }
+
+// -----------------------------------------------------------------------------
+// Return ETrue if dial-up PDP context override feature is enabled.
+// -----------------------------------------------------------------------------
+//
+TBool CCellularDataUsageKeyUpdater::DialUpOverrideEnabled() const
+    {
+    LOGENTRFN("CCellularDataUsageKeyUpdater::DialUpOverrideEnabled()")
+    TBool result( EFalse );
+
+    if ( iCmmRepository )
+        {
+        TInt value( 0 );
+        TInt err = iCmmRepository->Get( KDialUpOverride, value );
+        if ( err == KErrNone )
             {
-            cmRepository->Set( KCurrentCellularDataUsage, value );
-            LOGIT1("KCurrentCellularDataUsage set to %d", value)
+            if ( value )
+                {
+                result = ETrue;
+                LOGIT("ConstructL: Dial-up override enabled")
+                }
+            else
+                {
+                LOGIT("ConstructL: Dial-up override disabled")
+                }
             }
         else
             {
-            LOGIT1("KCurrentCellularDataUsage already up-to-date %d", previous)
+            LOGIT1("Failed to read KDialUpOverride-key from repository <%d>", err)
             }
-        
-        delete cmRepository;    
-        }
-    else
-        {
-        LOGIT1("CCRepository::NewL( KCRUidCmManager ) FAILED <%d>", err)
         }
 
-    LOGEXITFN("CCellularDataUsageKeyUpdater::UpdateKeyL()")
+    LOGEXITFN1("CCellularDataUsageKeyUpdater::DialUpOverrideEnabled()", result)
+    return result;
     }
 
 // -----------------------------------------------------------------------------
@@ -136,7 +162,8 @@
         CActive( EConnMonPriorityNormal ),
         iServer( aServer )
     {
-    iRepository = NULL;
+    iCommsRepository = NULL;
+    iCmmRepository = NULL;
     iErrorCounter = 0;
     }
 
@@ -146,13 +173,21 @@
 //
 void CCellularDataUsageKeyUpdater::ConstructL()
     {
-    iRepository = CRepository::NewL( KCDCommsRepositoryId );
-    
+    iCommsRepository = CRepository::NewL( KCDCommsRepositoryId );
+
+    // Open CmManager central repository.
+    TRAPD( err, iCmmRepository = CRepository::NewL( KCRUidCmManager ) )
+    if ( err )
+        {
+        LOGIT1("CRepository::NewL( KCRUidCmManager ) FAILED <%d>", err)
+        err = KErrNone;
+        }
+
     // Find out Default connection table id.
     // It contains iCellularDataUsageHome and iCellularDataUsageVisitor keys.
     CMDBSession* db = CMDBSession::NewLC( CMDBSession::LatestVersion() );	
-    TRAPD( err, iTableId = CCDDefConnRecord::TableIdL( *db ) )
-    	
+    TRAP( err, iTableId = CCDDefConnRecord::TableIdL( *db ) )
+
     if ( err )
         {
         LOGIT1("ERROR, CCDDefConnRecord::TableIdL() <%d>", err)
@@ -176,8 +211,8 @@
 //
 TInt CCellularDataUsageKeyUpdater::RequestNotifications()
     {  	    	
-    LOGIT1("Calling iRepository->NotifyRequest() for table 0x%08X", iTableId)
-    TInt err = iRepository->NotifyRequest( iTableId, KCDMaskShowRecordType, iStatus );
+    LOGIT1("Calling iCommsRepository->NotifyRequest() for table 0x%08X", iTableId)
+    TInt err = iCommsRepository->NotifyRequest( iTableId, KCDMaskShowRecordType, iStatus );
 
     if ( err == KErrNone )
         {
@@ -185,7 +220,7 @@
         }
     else
         {
-        LOGIT1("ERROR, iRepository->NotifyRequest() <%d>", err)
+        LOGIT1("ERROR, iCommsRepository->NotifyRequest() <%d>", err)
         }
 
     return err;
@@ -197,7 +232,7 @@
 //
 void CCellularDataUsageKeyUpdater::DoCancel()
     {
-    iRepository->NotifyCancel( iTableId, KCDMaskShowRecordType );
+    iCommsRepository->NotifyCancel( iTableId, KCDMaskShowRecordType );
     }
 
 // -----------------------------------------------------------------------------
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectionmonitoring/connmon/connectionmonitor/src/connmondialupoverridenotifier.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -0,0 +1,216 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* Listens for changes in dial-up PDP context override P&S-key.
+*
+*/
+
+#include <e32base.h>
+#include <e32property.h>
+
+#include "connmondialupoverridenotifier.h"
+#include "connectionmonitorpskeys.h"
+#include "ConnMonServ.h"
+#include "ConnMonIAP.h"
+#include "log.h"
+
+
+// -----------------------------------------------------------------------------
+// Two phased construction.
+// -----------------------------------------------------------------------------
+//
+CConnMonDialUpOverrideNotifier* CConnMonDialUpOverrideNotifier::NewL(
+        CConnMonServer* aServer )
+    {
+    CConnMonDialUpOverrideNotifier* self =
+            CConnMonDialUpOverrideNotifier::NewLC( aServer );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Two phased construction.
+// -----------------------------------------------------------------------------
+//
+CConnMonDialUpOverrideNotifier* CConnMonDialUpOverrideNotifier::NewLC(
+        CConnMonServer* aServer )
+    {
+    CConnMonDialUpOverrideNotifier* self =
+            new( ELeave ) CConnMonDialUpOverrideNotifier( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CConnMonDialUpOverrideNotifier::~CConnMonDialUpOverrideNotifier()
+    {
+    // Cancel outstanding request, if exists.
+    Cancel();
+    iDialUpProperty.Delete( KConnectionMonitorPS, KDialUpConnection );
+    iDialUpProperty.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideNotifier::ResetStatus
+// -----------------------------------------------------------------------------
+//
+TInt CConnMonDialUpOverrideNotifier::ResetStatus()
+    {
+    // Set property value to EConnMonReady.
+    TInt err = iDialUpProperty.Set( EConnMonReady );
+    LOGIT1("ResetStatus: Dial-up property value set to EConnMonReady <%d>", err)
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor.
+// -----------------------------------------------------------------------------
+//
+CConnMonDialUpOverrideNotifier::CConnMonDialUpOverrideNotifier(
+        CConnMonServer* aServer )
+        :
+        CActive( EConnMonPriorityMedium ),
+        iServer( aServer),
+        iErrorCounter( 0 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Two phased construction.
+// -----------------------------------------------------------------------------
+//
+void CConnMonDialUpOverrideNotifier::ConstructL()
+    {
+    LOGENTRFN("CConnMonDialUpOverrideNotifier::ConstructL()")
+
+    // Define Dial-up property.
+    TInt err = iDialUpProperty.Define(
+            KConnectionMonitorPS,
+            KDialUpConnection,
+            RProperty::EInt,
+            KDialUpOverrideReadC0,  // Read: Always pass
+            KDialUpOverrideWriteC2, // Write: NetworkControl, NetworkServices
+            0 );
+    LOGIT1("Dial-up property defined <%d>", err)
+    User::LeaveIfError( err );
+
+    // Attach to property.
+    err = iDialUpProperty.Attach(
+            KConnectionMonitorPS,
+            KDialUpConnection );
+    LOGIT1("Dial-up property attach <%d>", err)
+    User::LeaveIfError( err );
+
+    // Set property value to EConnMonReady.
+    ResetStatus();
+
+    CActiveScheduler::Add( this );
+    RequestNotifications();
+
+    LOGEXITFN("CConnMonDialUpOverrideNotifier::ConstructL()")
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideNotifier::RequestNotifications
+// -----------------------------------------------------------------------------
+//
+void CConnMonDialUpOverrideNotifier::RequestNotifications()
+    {
+    LOGENTRFN("CConnMonDialUpOverrideNotifier::RequestNotifications()")
+
+    if ( !IsActive() )
+        {
+        iDialUpProperty.Subscribe( iStatus );
+        LOGIT("KDialUpConnection-key, Subscribe()")
+        SetActive();
+        }
+
+    LOGEXITFN("CConnMonDialUpOverrideNotifier::RequestNotifications()")
+    return;
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideNotifier::DoCancel
+// -----------------------------------------------------------------------------
+//
+void CConnMonDialUpOverrideNotifier::DoCancel()
+    {
+    LOGIT("Canceling dialup property subscription.")
+    iDialUpProperty.Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CConnMonDialUpOverrideNotifier::RunL
+// -----------------------------------------------------------------------------
+//
+void CConnMonDialUpOverrideNotifier::RunL()
+    {
+    LOGIT(".")
+    LOGIT1("RunL: CConnMonDialUpOverrideNotifier <%d>", iStatus.Int())
+
+    if ( iStatus.Int() == KErrNone )
+        {
+        iErrorCounter = 0;
+        TInt value = -1;
+        TInt err = iDialUpProperty.Get( value );
+        LOGIT2("Dial-up override value is %d <%d>", value, err)
+
+        switch ( value )
+            {
+            case EConnMonDialUpClosed:
+                {
+                // Deactivate the dial-up override (if active). This will return
+                // cellular data connectivity back to normal.
+                iServer->SetDialUpOverrideStatus( EConnMonDialUpOverrideInactive );
+                ResetStatus();
+                }
+                break;
+            case EConnMonDialUpInit:
+                {
+                // Set the dial-up override status to active. This will block
+                // other cellular data connectivity and start the timeout timer.
+                iServer->SetDialUpOverrideStatus( EConnMonDialUpOverrideActive );
+
+                // If there are no active packetdata connections, signal EConnMonReady
+                // immediately. If there are active connections, EConnMonReady is
+                // signaled when those connections have gone down.
+                if ( !iServer->Iap()->ActivePacketdataConnectionsFound() )
+                    {
+                    ResetStatus();
+                    }
+                }
+                break;
+            case EConnMonReady:
+            default:
+                break;
+            }
+        }
+    else
+        {
+        LOGIT1("Dial-up override notification error <%d>", iStatus.Int())
+        iErrorCounter++;
+        if ( iErrorCounter > KConnMonPsEventErrorThreshold )
+            {
+            LOGIT1("Over %d consecutive errors, stopping", KConnMonPsEventErrorThreshold)
+            return;
+            }
+        }
+    RequestNotifications();
+    }
+
+// End of file
--- a/connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionutilities/ConnectionDialogs/cconndlg/src/ConnDlgPlugin.cpp	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 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"
@@ -38,6 +38,7 @@
 
 #include <CConnDlgPlugin.rsg>
 #include <data_caging_path_literals.hrh>
+#include <vpnapi.h>
 
 using namespace CommsDat;
 
@@ -847,7 +848,24 @@
     	err = GetActiveConnection( iap, snap, bearer );
         }
                                       
-    if ( ( err == KErrNone ) && 
+    RVpnServ vpn;
+    TInt vpnErr( KErrNone );
+    TInt policyCount( 0 );
+    TBool forceDialogForIntranetUsers( EFalse );
+    
+    vpnErr = vpn.Connect();
+    if ( !vpnErr ) 
+    	  {
+    	  vpnErr = vpn.EnumeratePolicies(policyCount);
+    	  if ( !vpnErr && policyCount > 0 )
+    	  	  {
+    	  	  forceDialogForIntranetUsers = ETrue;
+    	  	  }
+        vpn.Close();
+        }
+        
+    if ( !forceDialogForIntranetUsers &&
+    	 ( err == KErrNone ) && 
          ( iap != 0 || snap != 0 ) && 
          ( iPrefs().iBearerSet & bearer ) &&
          ( iPrefs().iDirection == 0 ) )     // JavaVM sets iDirection to "1"
--- a/connectionutilities/ConnectionDialogs/group/CConnDlgPlugin.mmp	Thu Jul 15 19:05:04 2010 +0300
+++ b/connectionutilities/ConnectionDialogs/group/CConnDlgPlugin.mmp	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 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"
@@ -81,6 +81,7 @@
 LIBRARY cmmanagerdatabase.lib
 LIBRARY	egul.lib
 
+LIBRARY vpnapi.lib
 
 DEBUGLIBRARY flogger.lib
 DEBUGLIBRARY efsrv.lib
Binary file data/cccccc00_emulator.cre has changed
--- a/inc/meshpreface1.cfg	Thu Jul 15 19:05:04 2010 +0300
+++ b/inc/meshpreface1.cfg	Thu Aug 19 10:18:49 2010 +0300
@@ -318,6 +318,14 @@
 	FIELD_COUNT=2
 END_ADD
 
+ADD_SECTION
+# COMMDB_ID = 7
+	Name=pdpcpr
+	CprUid=0x102822E2
+	FIELD_COUNT=2
+END_ADD
+
+
 ############################################################
 ## SCprTable
 ## 
@@ -545,7 +553,7 @@
 	Name=spud-ppp
 	Tier=Link.TierTable.271064565
 	MCpr=MCprTable.10
-	Cpr=CprTable.3
+	Cpr=CprTable.7
 	SCpr=SCprTable.4
 	Protocol=ProtocolTable.3
 	FIELD_COUNT=6
@@ -556,7 +564,7 @@
 	Name=spud-rawip
 	Tier=Link.TierTable.271064565
 	MCpr=MCprTable.10
-	Cpr=CprTable.3
+	Cpr=CprTable.7
 	SCpr=SCprTable.4
 	Protocol=ProtocolTable.5
 	FIELD_COUNT=6
@@ -602,3 +610,4 @@
 	FIELD_COUNT=6
 END_ADD
 
+
--- a/ipcm_plat/connection_monitor_extension_api/group/bld.inf	Thu Jul 15 19:05:04 2010 +0300
+++ b/ipcm_plat/connection_monitor_extension_api/group/bld.inf	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-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"
@@ -11,8 +11,8 @@
 *
 * Contributors:
 *
-* Description:  File that exports the files belonging to Connection
-*                Monitor Extension API.
+* Description:
+* File that exports the files belonging to Connection Monitor Extension API.
 *
 */
 
@@ -23,4 +23,5 @@
 
 PRJ_EXPORTS
 
-../inc/ConnMonExt.h     MW_LAYER_PLATFORM_EXPORT_PATH(ConnMonExt.h)
+../inc/ConnMonExt.h                 MW_LAYER_PLATFORM_EXPORT_PATH(ConnMonExt.h)
+../inc/connectionmonitorpskeys.h    MW_LAYER_PLATFORM_EXPORT_PATH(connectionmonitorpskeys.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipcm_plat/connection_monitor_extension_api/inc/connectionmonitorpskeys.h	Thu Aug 19 10:18:49 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Connection Monitor Publish & Subscribe keys.
+*
+*/
+
+
+#ifndef CONNECTIONMONITORPSKEYS_H
+#define CONNECTIONMONITORPSKEYS_H
+
+/**
+ * Connection Monitor RProperty category.
+ */
+const TUid KConnectionMonitorPS = {0x101F6CF0};
+
+/**
+ * Dial-Up override key.
+ * Used only when dial-up override feature is enabled. The purpose for this
+ * feature is to stop and block any packetdata connections while a dial-up
+ * connection is beeing established in single PDP context networks.
+ */
+const TUint KDialUpConnection = 0x00000001;
+
+/**
+ * Values for KDialUpConnection key.
+ */
+enum TDialUpStates
+    {
+    /**
+     * Can be used to indicate to Connection Monitor Server that a dial-up
+     * connection has ended. If the dial-up connection setup fails, this can be
+     * used to restore normal packetdata connectivity a little faster in some
+     * error situations.
+     */
+    EConnMonDialUpClosed,
+    /**
+     * Indicates to Connection Monitor Server that a Dial-Up connection is
+     * starting. Connection Monitor will stop any active packetdata connection
+     * and block further packetdata connections during the dial-up connection
+     * setup.
+     */
+    EConnMonDialUpInit,
+    /**
+     * Connection Monitor Server will indicate with this value that any
+     * preparations for an upcoming dial-up connection are completed.
+     */
+    EConnMonReady
+    };
+
+#endif // CONNECTIONMONITORPSKEYS_H
--- a/ipcm_plat/extended_connection_settings_api/inc/cmmanagerkeys.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/ipcm_plat/extended_connection_settings_api/inc/cmmanagerkeys.h	Thu Aug 19 10:18:49 2010 +0300
@@ -21,7 +21,7 @@
 /**
  * UID of CmManager repository
  *
- * @since S60 5.1
+ * @since S60 5.2
  */
 const TUid KCRUidCmManager = {0x10207376}; 
 
@@ -33,8 +33,19 @@
  * but the value is provided for the country the device is at the moment.
  * See TCmCellularDataUsage in cmgenconnsettings.h for more info.
  *
- * @since S60 5.1
+ * @since S60 5.2
  */
 const TUint32 KCurrentCellularDataUsage  = 0x00000001;
+
+/**
+ * Dial-up override setting.
+ *
+ * When this key is enabled dial-up connection overrides all
+ * internal cellular connections. Internal cellular connections 
+ * are automatically disconnected when dial-up connection starts.
+ *
+ * @since S60 5.2
+ */
+const TUint32 KDialUpOverride  = 0x00000002;
     
 #endif // CMMANAGERKEYS_H
--- a/ipcm_plat/extended_connection_settings_api/inc/cmsettingsui.h	Thu Jul 15 19:05:04 2010 +0300
+++ b/ipcm_plat/extended_connection_settings_api/inc/cmsettingsui.h	Thu Aug 19 10:18:49 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2006-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"
@@ -66,6 +66,23 @@
         */
         IMPORT_C TBool SelectDestinationDlgL( TUint32& aDestinationId );
 
+        /**
+        * Launches the dialog for adding connection methods
+        * @since 3.2.3
+        * @param  aDestUid destination id for the new cm
+        * @param  aBearerType bearer type for the new cm
+        * @return TUint32 id of the new cm
+        */
+        IMPORT_C TUint32 AddCmL( TUint32& aDestUid, TUint32 aBearerType );
+
+        /**
+        * Launches the dialog for editing connection methods
+        * @since 3.2.3
+        * @param  aCmId id of the cm to edit
+        * @return TResult - the softkey the user exited with.
+        *                   EBack in case editing is forbidden.
+        */
+        IMPORT_C TResult EditCmL( TUint32 aCmId );        
     private:
 
         /** First stage constructor */