201041_1
authorhgs
Wed, 27 Oct 2010 18:01:02 +0300
changeset 72 0c32cf868819
parent 71 9f263f780e41
child 73 70ee5458c95d
201041_1
bearermanagement/mpm/inc/mpmserver.h
bearermanagement/mpm/src/mpmdatausagewatcher.cpp
bearermanagement/mpm/src/mpmserver.cpp
bearermanagement/mpm/src/mpmserversession.cpp
cmmanager/cpdestinationplugin/src/cpadddestinationentryitemdata.cpp
connectionmonitoring/cellularindicatorplugin/src/cellularindicatorplugin.cpp
connectionmonitoring/connmon/connectionmonitor/inc/CPsdFax.h
connectionmonitoring/connmon/connectionmonitor/inc/ConnMonIAP.h
connectionmonitoring/connmon/connectionmonitor/src/CPsdFax.cpp
connectionmonitoring/connmon/connectionmonitor/src/CWlanSupport.cpp
connectionmonitoring/connmon/connectionmonitor/src/ConnMonIAP.cpp
connectionmonitoring/connmon/connectionmonitor/src/ConnMonServ.cpp
connectionmonitoring/connmon/dataconnectionlogger/inc/dcl.h
connectionmonitoring/connmon/dataconnectionlogger/src/dcl.cpp
ipcm_pub/connection_settings_api/inc/cmmanager.h
--- a/bearermanagement/mpm/inc/mpmserver.h	Wed Oct 27 17:51:11 2010 +0300
+++ b/bearermanagement/mpm/inc/mpmserver.h	Wed Oct 27 18:01:02 2010 +0300
@@ -51,6 +51,9 @@
 //
 const TInt    KPhoneRetryTimeout = 100000;
 
+const TUint32 KMaxOpenTransAttempts = 5;
+const TUint32 KRetryAfter = 200000;
+
 // The granularity with which roaming and starting dialogs will allocate memory chunks. 
 // If set to two there will be space for two instances before new memory will be allocated.
 const TInt    KGranularity       = 2;
@@ -832,9 +835,10 @@
         
         /**
         * Stops cellular connections, except MMS
+        * @param aSilentOnly stop only silent cellular connections
         * @since 5.2
         */
-        void StopCellularConns();
+        void StopCellularConns( TBool aSilentOnly = EFalse );
         
         /**
         * Handle to connection ui utilities
@@ -918,6 +922,13 @@
                                 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
--- a/bearermanagement/mpm/src/mpmdatausagewatcher.cpp	Wed Oct 27 17:51:11 2010 +0300
+++ b/bearermanagement/mpm/src/mpmdatausagewatcher.cpp	Wed Oct 27 18:01:02 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 );
+                }
+
             }
         }
     
--- a/bearermanagement/mpm/src/mpmserver.cpp	Wed Oct 27 17:51:11 2010 +0300
+++ b/bearermanagement/mpm/src/mpmserver.cpp	Wed Oct 27 18:01:02 2010 +0300
@@ -481,28 +481,29 @@
 // -----------------------------------------------------------------------------
 //
 void CMPMServer::RemoveBMConnection( const TConnectionId aConnId,
-                                     CMPMServerSession&  /*aSession*/ )
+                                     CMPMServerSession&  aSession )
     {
     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 );
+            CheckIapForDisconnect( closeIapId );
             }
         }
 
@@ -812,23 +813,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 )
             {
@@ -915,37 +906,61 @@
         }
 #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;
+            User::After( retryAfter );
+            }
+        } while( err && maxOpenTransAttempts-- );
+    
+    // Start possible forced roaming
+    if ( !err )
+        {
+        if ( usageOfWlan == ECmUsageOfWlanKnown || usageOfWlan == ECmUsageOfWlanKnownAndNew )
+            {
+            if ( IsWlanConnectionStartedL( CommsDatAccess() ) )
+                {
+                iConnMonIapInfo = aIapInfo;
                 
-            if ( iRoamingToWlanPeriodic )
-                {
-                iRoamingToWlanPeriodic->Cancel();
+                if ( iRoamingToWlanPeriodic )
+                    {
+                    iRoamingToWlanPeriodic->Cancel();
+                    }
+                else
+                    {
+                    iRoamingToWlanPeriodic = CPeriodic::NewL( 
+                                                   CActive::EPriorityStandard );
+                    }
+                // 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 ) );
                 }
             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 )
         }
     
     // Send notifications for all sessions
@@ -1835,7 +1850,7 @@
 // Stop all cellular connections except MMS
 // ---------------------------------------------------------------------------
 //
-void CMPMServer::StopCellularConns()
+void CMPMServer::StopCellularConns( TBool aSilentOnly )
     {
     MPMLOGSTRING( "CMPMServer::StopCellularConns" )
 
@@ -1864,7 +1879,14 @@
                 if (!(err == KErrNone && iapId == mmsIap))
                     {
                     // Stop the conn / IAP.
-                    StopConnections( iapId );
+					if ( aSilentOnly )
+                        {
+                        CheckIapForDisconnect( iapId );
+                        }
+                    else
+                        {
+                        StopConnections( iapId );
+                        }
                     stoppedIaps.Append( iapId );
                     }
                 }
@@ -2118,6 +2140,79 @@
     }
 
 // -----------------------------------------------------------------------------
+// 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	Wed Oct 27 17:51:11 2010 +0300
+++ b/bearermanagement/mpm/src/mpmserversession.cpp	Wed Oct 27 18:01:02 2010 +0300
@@ -111,8 +111,6 @@
 //
 CMPMServerSession::~CMPMServerSession()
     {
-    delete iConfirmDlgRoaming;
-    delete iIapSelection;
 
     // Remove serverside objects for notification session.
     // 
@@ -142,6 +140,9 @@
     
     // Cancel discreet popup
     iMyServer.ConnUiUtils()->CancelConnectingViaDiscreetPopup();
+
+	delete iConfirmDlgRoaming;
+    delete iIapSelection;
     }
 
 
@@ -3447,10 +3448,26 @@
          iMyServer.UserConnection() )
         {
         MPMLOGSTRING( "CMPMServerSession::UseUserConnPref - User connection active" );
+
+        // If user connection is blacklisted for this connection, don't use it.
+        RArray<TUint32> blacklistedIaps;
+        CleanupClosePushL( blacklistedIaps );
+        iMyServer.GetBlacklistedIAP( iConnId, blacklistedIaps );
+        TInt blacklistedIapFoundError = blacklistedIaps.Find( iMyServer.UserConnPref()->IapId() );
+        CleanupStack::PopAndDestroy( &blacklistedIaps );
         
+        if ( blacklistedIapFoundError != KErrNotFound )
+            {
+            MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
+ User connection blacklisted -> don't use user connection" );
+            return EFalse;
+            }
+
         // Check whether default connection will be used
         if ( iIapSelection->MpmConnPref().ConnType() == TMpmConnPref::EConnTypeDefault )
             {
+            MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
+ Default connection -> use user connection" );
             return ETrue;
             }
         else if ( ( iIapSelection->MpmConnPref().ConnType() ==
@@ -3458,7 +3475,7 @@
                   PrefsAllowWlan() )
             {            
             MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
- Prompt from the user" );
+ Prompt from the user -> use user connection" );
             // Prompt from the user -> use user connection
             return ETrue;
             }
@@ -3477,6 +3494,8 @@
 
             if ( ( error == KErrNone ) && ( isInternetSnap ) && PrefsAllowWlan() )
                 {
+                MPMLOGSTRING( "CMPMServerSession::UseUserConnPref -\
+ Application preferencies in Internet SNAP -> use user connection" );
                 // Iap belongs to internet snap -> use user connection
                 return ETrue;
                 }
--- a/cmmanager/cpdestinationplugin/src/cpadddestinationentryitemdata.cpp	Wed Oct 27 17:51:11 2010 +0300
+++ b/cmmanager/cpdestinationplugin/src/cpadddestinationentryitemdata.cpp	Wed Oct 27 18:01:02 2010 +0300
@@ -216,7 +216,7 @@
     HbMessageBox *note = new HbMessageBox(HbMessageBox::MessageTypeInformation);
     note->clearActions();
     note->setAttribute(Qt::WA_DeleteOnClose);
-    QString info = hbTrId("txt_occ_info_invalid_name");
+    QString info = hbTrId("txt_occ_info_name_already_in_use");
     note->setText(info);
     note->setTimeout(HbPopup::NoTimeout);
     HbAction *errorOk = new HbAction(
--- a/connectionmonitoring/cellularindicatorplugin/src/cellularindicatorplugin.cpp	Wed Oct 27 17:51:11 2010 +0300
+++ b/connectionmonitoring/cellularindicatorplugin/src/cellularindicatorplugin.cpp	Wed Oct 27 18:01:02 2010 +0300
@@ -196,8 +196,8 @@
             if ( (indicatorInfo[0].toInt() > 1) && indicatorInfo.count() ) {
                 
                 // More than one connection -> show number of connections
-                QString str = QString(hbTrId("txt_occ_dblist_cellular_data_val_l1_connections"));
-                ret = str.arg(indicatorInfo[0].toInt());
+                int count = indicatorInfo[0].toInt();
+                ret = QString( hbTrId("txt_occ_dblist_cellular_data_val_l1_connections", count ) );
             }
             else if ( indicatorInfo[0].toInt() && (indicatorInfo.count() >= 2)) {
                 
--- a/connectionmonitoring/connmon/connectionmonitor/inc/CPsdFax.h	Wed Oct 27 17:51:11 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/inc/CPsdFax.h	Wed Oct 27 18:01:02 2010 +0300
@@ -18,6 +18,7 @@
 #ifndef __CPSDFAX_H
 #define __CPSDFAX_H
 
+#include <e32base.h>
 #include <etel.h>
 #include <etelmm.h>
 #include <etelpckt.h>
@@ -36,6 +37,9 @@
 // max PSD connection number
 const TInt KMaxPsdConnectionCount = 2;
 
+// Restore attach mode interval (3 sec)
+const TInt KRestoreAttachModeInterval = 3000000;
+
 
 /**
  * CPsdFax
@@ -178,6 +182,21 @@
         */
         void DeleteConnections();
 
+        /**
+        * Timer callback of iRestoreAttachModeTimer
+        *
+        * @param  aObject Object that triggered timer
+        * @since 5.2
+        */
+        static TInt RestoreAttachModeCb( TAny* aObject );
+        
+        /**
+        * Restores attach mode
+        *
+        * @since 5.2
+        */
+        void RestoreAttachMode();
+
     private:
 
     private: // Data
@@ -198,6 +217,9 @@
 
         // Data table for each connection
         CPsdFaxConnectionData* iConnectionData[KMaxPsdConnectionCount];
+
+        // Timer to restore attach mode in case at+cgatt=0 given 
+        CPeriodic* iRestoreAttachModeTimer;
     };
 
 
--- a/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonIAP.h	Wed Oct 27 17:51:11 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/inc/ConnMonIAP.h	Wed Oct 27 18:01:02 2010 +0300
@@ -742,6 +742,13 @@
          */
         TInt GetNetworkRegistration_v2( TInt& aRegistration ) const;
 
+         /**
+         * Restores packet network attach mode.
+         * @since
+         * @return void.
+         */
+        void RestoreAttachMode();
+
 
     private: // New methods
         /**
--- a/connectionmonitoring/connmon/connectionmonitor/src/CPsdFax.cpp	Wed Oct 27 17:51:11 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/src/CPsdFax.cpp	Wed Oct 27 18:01:02 2010 +0300
@@ -81,6 +81,13 @@
         iConnUpNotifier = NULL;
         }
 
+    if ( iRestoreAttachModeTimer )
+        {
+        iRestoreAttachModeTimer->Cancel();
+        delete iRestoreAttachModeTimer;
+        iRestoreAttachModeTimer = NULL;
+        }
+
     // Delete all ConnectionData objects
     for ( TUint index = 0; index < KMaxPsdConnectionCount; index++ )
         {
@@ -540,6 +547,51 @@
     LOGEXITFN("CPsdFax::DeleteConnections()")
     }
 
+// ---------------------------------------------------------
+// CPsdFax::RestoreAttachModeCb
+// ---------------------------------------------------------
+//
+TInt CPsdFax::RestoreAttachModeCb( TAny* aObject )
+    {
+    LOGENTRFN("CPsdFax::RestoreAttachModeCb()")
+
+    CPsdFax* myself = static_cast<CPsdFax*>( aObject );
+    
+    myself->iRestoreAttachModeTimer->Cancel();
+    
+    // Make sure that ETel goes to correct network status
+    // in case AT+CGATT=0 has been sent from PC. 
+    myself->iServer->Iap()->RestoreAttachMode();
+
+    LOGEXITFN("CPsdFax::RestoreAttachModeCb()")
+
+    return 0;
+    }
+    
+ // ---------------------------------------------------------
+// CPsdFax::RestoreAttachMode
+// ---------------------------------------------------------
+//
+void CPsdFax::RestoreAttachMode()
+    {
+    LOGENTRFN("CPsdFax::RestoreAttachMode()")
+
+    if ( iRestoreAttachModeTimer )
+        {
+        iRestoreAttachModeTimer->Cancel();
+        }
+    else
+        {
+        iRestoreAttachModeTimer = CPeriodic::NewL( CActive::EPriorityStandard );
+        }
+
+    iRestoreAttachModeTimer->Start( 
+        TTimeIntervalMicroSeconds32( KRestoreAttachModeInterval ), 
+        TTimeIntervalMicroSeconds32( KRestoreAttachModeInterval ), 
+        TCallBack( RestoreAttachModeCb, this ) );
+
+    LOGEXITFN("CPsdFax::RestoreAttachMode()")
+    }
 
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -1374,6 +1426,10 @@
             // context override is disabled.
             LOGIT("External PSD connection status EStatusDeleted, disabling dial-up override")
             iServer->SetDialUpOverrideStatus( EConnMonDialUpOverrideInactive );
+            
+            // Restore packet data network attach mode in case it has been
+            // changed by sending at+cgatt=0 from PC.
+            iFaxModule->RestoreAttachMode();
 
             // Delete all old connection objects. This method should be used
             // carefully because it will delete ConnectionData and
--- a/connectionmonitoring/connmon/connectionmonitor/src/CWlanSupport.cpp	Wed Oct 27 17:51:11 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/src/CWlanSupport.cpp	Wed Oct 27 18:01:02 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-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"
@@ -17,6 +17,7 @@
 
 #include <e32base.h>
 #include <utf.h>
+#include <cmpluginwlandef.h>
 
 #include "CWlanSupport.h"
 #include "CEventQueue.h"
@@ -27,6 +28,7 @@
 #include "ConnMonUtils.h"
 #include "connmonwlannetwork.h"
 
+using namespace CMManager;
 
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -426,10 +428,24 @@
 
     // Get ssid of current connection
     TWlanSsid currentSsid;
+    TWlanConnectionMode currentMode;
+    TWlanConnectionExtentedSecurityMode currentSecurityMode;
+
     ret = iWlanMgmt->GetConnectionSsid( currentSsid );
+
+    if ( ret == KErrNone )
+        {
+        ret = iWlanMgmt->GetConnectionMode( currentMode );
+        
+        if ( ret == KErrNone )
+            {
+            ret = iWlanMgmt->GetExtendedConnectionSecurityMode( currentSecurityMode );
+            }
+        }
+
     if ( KErrNone != ret )
         {
-        LOGIT1("ERROR reading current connection ssid from wlan engine <%d>", ret)
+        LOGIT1("ERROR reading current connection ssid/mode/security mode from wlan engine <%d>", ret)
         ret = KErrDisconnected;
         }
     else
@@ -443,6 +459,8 @@
         TBuf<CConnMonWlanNetwork::KMaxNameLength> ssid16;
         CnvUtfConverter::ConvertToUnicodeFromUtf8( ssid16, currentSsid );
         LOGIT2("AppendAvailableIapsBySsidL: ssid: %S, length: %d", &ssid16, ssid16.Length())
+        LOGIT1("AppendAvailableIapsBySsidL: mode: %d", currentMode)
+        LOGIT1("AppendAvailableIapsBySsidL: security mode: %d", currentSecurityMode)
 
         // Create wlan service record set
         CMDBRecordSet<CCDWlanServiceRecord>* wlanSet =
@@ -457,11 +475,27 @@
 
         // Set ssid field in wlan service record (see wlancontainer.h)
         wlanRecord->iWLanSSID.SetL( ssid16 );
+
+        // match TWlanConnectionMode to TWlanNetMode
+        switch ( currentMode )
+            {
+            case EWlanConnectionModeInfrastructure:
+            case EWlanConnectionModeSecureInfra:
+                wlanRecord->iWlanConnMode.SetL( EInfra );
+                break;
+            case EWlanConnectionModeAdhoc:
+                wlanRecord->iWlanConnMode.SetL( EAdhoc );
+                break;
+            default:
+            	  wlanRecord->iWlanConnMode.SetL( EInfra );
+                break;
+            }
+
         // Append wlan service record to wlan service record set (currently empty)
         wlanSet->iRecords.AppendL( wlanRecord );
         CleanupStack::Pop( wlanRecord ); // Ownership moved
 
-        // Find matching wlan service records (all wlan service records with same SSID)
+        // Find matching wlan service records (all wlan service records with same SSID and mode)
         if ( wlanSet->FindL( *db ) )
             {
             TInt wlanRecordCount( wlanSet->iRecords.Count() );
@@ -474,6 +508,57 @@
                 // LoadL() will only look at ElementId and updates the rest of the fields
                 wlanRecord->SetElementId( wlanSet->iRecords[i]->ElementId() );
                 wlanRecord->LoadL( *db );
+                
+                // Check security mode
+                // Map TWlanConnectionExtentedSecurityMode given by WlanEngine
+                // to TWlanSecMode used in CommsDat.
+                switch ( currentSecurityMode )
+                    {
+                    case EWlanConnectionExtentedSecurityModeOpen:
+                        if ( wlanRecord->iWlanSecMode != EWlanSecModeOpen )
+                            {
+                            continue;
+                            }
+                        break;
+                    case EWlanConnectionExtentedSecurityModeWepOpen:
+                    case EWlanConnectionExtentedSecurityModeWepShared:
+                        if ( wlanRecord->iWlanSecMode != EWlanSecModeWep )
+                            {
+                            continue;
+                            }
+                        break;
+                    case EWlanConnectionExtentedSecurityMode802d1x:
+                        if ( wlanRecord->iWlanSecMode != EWlanSecMode802_1x )
+                            {
+                            continue;
+                            }
+                        break;
+                    case EWlanConnectionExtentedSecurityModeWapi:
+                    case EWlanConnectionExtentedSecurityModeWapiPsk:
+                        if ( wlanRecord->iWlanSecMode != EWlanSecModeWAPI )
+                            {
+                            continue;
+                            }
+                        break;
+                    case EWlanConnectionExtentedSecurityModeWpa2:
+                    case EWlanConnectionExtentedSecurityModeWpa2Psk:
+                    	  // CommsDat record has EWlanSecModeWpa unless "WPA2 only mode" is set On.
+                        if ( wlanRecord->iWlanSecMode != EWlanSecModeWpa2 && 
+                             wlanRecord->iWlanSecMode != EWlanSecModeWpa )
+                            {
+                            continue;
+                            }
+                        break;
+                    case EWlanConnectionExtentedSecurityModeWpa:
+                    case EWlanConnectionExtentedSecurityModeWpaPsk:
+                        if ( wlanRecord->iWlanSecMode != EWlanSecModeWpa )
+                            {
+                            continue;
+                            }
+                        break;
+                    default:
+                        continue;
+                    }
 
                 // Create IAP record
                 CCDIAPRecord* iapRecord =
--- a/connectionmonitoring/connmon/connectionmonitor/src/ConnMonIAP.cpp	Wed Oct 27 17:51:11 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/src/ConnMonIAP.cpp	Wed Oct 27 18:01:02 2010 +0300
@@ -3839,28 +3839,7 @@
                  nwRegStatus != RPacketService::ERegistrationDenied        &&
                  nwRegStatus != RPacketService::ENotRegisteredAndNotAvailable )
                 {
-                // Query the TSY for the attach mode
-                RPacketService::TAttachMode attachMode( RPacketService::EAttachWhenNeeded );
-                err = iPacketService.GetAttachMode( attachMode );
-
-                LOGIT2("GetBearerSupportInfo: pckt service attach mode:       %d <%d>", attachMode, err)
-                // Query packet network status (but only if the TSY is set to attach when possible)
-                if ( KErrNone == err && attachMode == RPacketService::EAttachWhenPossible )
-                    {
-                    RPacketService::TStatus pcktStatus( RPacketService::EStatusUnattached );
-                    err = iPacketService.GetStatus( pcktStatus );
-
-                    LOGIT2("GetBearerSupportInfo: pckt service status:            %d <%d>", pcktStatus, err)
-                    if ( KErrNone == err && pcktStatus != RPacketService::EStatusUnattached )
-                        {
-                        aByCell = ETrue;
-                        }
-                    }
-                else
-                    {
-                    // Attach mode is 'EAttachWhenNeeded'
-                    aByCell = ETrue;
-                    }
+                aByCell = ETrue;    
                 }
             }
 
@@ -5486,4 +5465,30 @@
     return err;
     }
 
+// ---------------------------------------------------------------------------
+// CConnMonIAP::RestoreAttachMode
+// ---------------------------------------------------------------------------
+//
+void CConnMonIAP::RestoreAttachMode()
+    {
+    // AT command AT+CGATT=0 will detach phone from cellular network.
+    // Restore attach mode to cellmo when attach mode is set to EAttachWhenPossible.
+    //
+    RPacketService::TAttachMode attachMode( RPacketService::EAttachWhenNeeded );
+    TInt err = iPacketService.GetAttachMode( attachMode );
+    LOGIT2("CConnMonIAP::RestoreAttachMode: attach mode:       %d <%d>", attachMode, err)
+    
+    if ( err == KErrNone && attachMode == RPacketService::EAttachWhenPossible )
+        {
+        TRequestStatus status( KErrNone );
+
+        iPacketService.SetAttachMode( status, RPacketService::EAttachWhenPossible );
+        User::WaitForRequest( status );
+        LOGIT1("CConnMonIAP::RestoreAttachMode: set --> EAttachWhenPossible, error <%d>", status.Int() )
+
+        return;
+        }
+    LOGIT("No need to restore attach mode.")    
+    }
+
 // End-of-file
--- a/connectionmonitoring/connmon/connectionmonitor/src/ConnMonServ.cpp	Wed Oct 27 17:51:11 2010 +0300
+++ b/connectionmonitoring/connmon/connectionmonitor/src/ConnMonServ.cpp	Wed Oct 27 18:01:02 2010 +0300
@@ -1082,6 +1082,10 @@
     {
     LOGIT(".")
     LOGIT1("RunL: CConnMonDialUpOverrideTimer <%d>", iStatus.Int())
+    
+    // Make sure that ETel goes to correct network status
+    // in case AT+CGATT=0 has been sent from PC.
+    iServer->Iap()->RestoreAttachMode();
     iServer->SetDialUpOverrideStatus( EConnMonDialUpOverrideInactive );
     }
 
--- a/connectionmonitoring/connmon/dataconnectionlogger/inc/dcl.h	Wed Oct 27 17:51:11 2010 +0300
+++ b/connectionmonitoring/connmon/dataconnectionlogger/inc/dcl.h	Wed Oct 27 18:01:02 2010 +0300
@@ -39,7 +39,6 @@
 #endif // __WLAN
 
 #include "dclevent.h"
-#include "dclTimer.h"
 #include "saeobserver.h"
 
 // CONSTANTS
--- a/connectionmonitoring/connmon/dataconnectionlogger/src/dcl.cpp	Wed Oct 27 17:51:11 2010 +0300
+++ b/connectionmonitoring/connmon/dataconnectionlogger/src/dcl.cpp	Wed Oct 27 18:01:02 2010 +0300
@@ -29,6 +29,7 @@
 #include "DclPrivateCRKeys.h"
 
 #include "dcl.h"
+#include "dclTimer.h"
 #include "dcl_log.h"
 
 // --------------------------------------------------------------------------
--- a/ipcm_pub/connection_settings_api/inc/cmmanager.h	Wed Oct 27 17:51:11 2010 +0300
+++ b/ipcm_pub/connection_settings_api/inc/cmmanager.h	Wed Oct 27 18:01:02 2010 +0300
@@ -221,8 +221,7 @@
         IMPORT_C void AllDestinationsL( RArray<TUint32>& aDestArray ) const;
 
         /**
-        * Returns the destination to which a specified
-        * connection method belongs, search is by destination ID
+        * Returns the destination queried by its ID.
         *
         * @since S60 3.2
         * @param aDestinationId id of destination