wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsconmonwrapperdisconnect_symbian.cpp
branchRCL_3
changeset 24 63be7eb3fc78
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
       
     1 /*
       
     2  * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:
       
    15  * Private implementation of wrapper for Symbian Connection Monitor
       
    16  * library's connection disconnect interface.
       
    17  */
       
    18 
       
    19 // System includes
       
    20 
       
    21 // User includes
       
    22 
       
    23 #include "wlanqtutilsconmonwrapper.h"
       
    24 #include "wlanqtutilsconmonwrapperdisconnect_symbian.h"
       
    25 
       
    26 #include "OstTraceDefinitions.h"
       
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "wlanqtutilsconmonwrapperdisconnect_symbianTraces.h"
       
    29 #endif
       
    30 
       
    31 /*!
       
    32     \class WlanQtUtilsConMonWrapperDisconnect
       
    33     \brief Private wrapper for Symbian Connection Monitor library.
       
    34 
       
    35     Provides functionality to disconnect connections regardless of how
       
    36     many applications are using the connection.
       
    37 */
       
    38 
       
    39 // External function prototypes
       
    40 
       
    41 // Local constants
       
    42 
       
    43 // ======== LOCAL FUNCTIONS ========
       
    44 
       
    45 // ======== MEMBER FUNCTIONS ========
       
    46 
       
    47 /*!
       
    48     Constructor.
       
    49     
       
    50     @param [in] wrapper Wrapper to report progress to.
       
    51  */
       
    52 
       
    53 WlanQtUtilsConMonWrapperDisconnect::WlanQtUtilsConMonWrapperDisconnect(
       
    54     WlanQtUtilsConMonWrapper *wrapper) :
       
    55     q_ptr(wrapper)
       
    56 {
       
    57     OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_ENTRY, this);
       
    58     
       
    59     // Errors in Connection Monitor Server connection are fatal so just
       
    60     // throw them as exceptions
       
    61     QT_TRAP_THROWING(iMonitor.ConnectL());
       
    62 
       
    63     OstTraceFunctionExit1(WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_EXIT, this);
       
    64 }
       
    65 
       
    66 /*!
       
    67     Destructor.
       
    68  */
       
    69 
       
    70 WlanQtUtilsConMonWrapperDisconnect::~WlanQtUtilsConMonWrapperDisconnect()
       
    71 {
       
    72     OstTraceFunctionEntry1(DUP1_WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_ENTRY, this);
       
    73 
       
    74     iMonitor.Close();
       
    75 
       
    76     OstTraceFunctionExit1(DUP1_WLANQTUTILSCONMONWRAPPERDISCONNECT_WLANQTUTILSCONMONWRAPPERDISCONNECT_EXIT, this);
       
    77 }
       
    78 
       
    79 /*!
       
    80     Disconnects the connection with the given IAP ID.
       
    81     
       
    82     @param [in] wrapper Wrapper to report progress to.
       
    83  */
       
    84 
       
    85 void WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection(int iapId)
       
    86 {
       
    87     OstTraceFunctionEntry1(WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_ENTRY, this);
       
    88 
       
    89     OstTrace1(
       
    90         TRACE_NORMAL,
       
    91         WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION,
       
    92         "WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection;iapId=%d", iapId);
       
    93     
       
    94     // Loop through connections to find the one with the IAP ID we want
       
    95     TUint count;
       
    96     TRequestStatus status;
       
    97     iMonitor.GetConnectionCount(count, status);
       
    98     User::WaitForRequest(status);
       
    99     if (status.Int() == KErrNone) {
       
   100         for (TInt i = 1; i <= count; i++) {
       
   101             TUint numSubConnections;
       
   102             TUint iap = 0;
       
   103             TUint connectionId = 0;
       
   104             TInt ret = iMonitor.GetConnectionInfo(
       
   105                 i,
       
   106                 connectionId,
       
   107                 numSubConnections);
       
   108             if (ret == KErrNone) {
       
   109                 iMonitor.GetUintAttribute(connectionId, 0, KIAPId, iap, status);
       
   110                 User::WaitForRequest(status);
       
   111                 if (status.Int() == KErrNone) {
       
   112                     if (iap == iapId) {
       
   113                         OstTrace1(
       
   114                             TRACE_NORMAL,
       
   115                             WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_STOP,
       
   116                             "WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection Stopping connection;connectionId=%u",
       
   117                             connectionId);
       
   118                         
       
   119                         // Match found, stop connection
       
   120                         TInt KErr = iMonitor.SetBoolAttribute(
       
   121                             connectionId,
       
   122                             0,
       
   123                             KConnectionStop,
       
   124                             ETrue);
       
   125     
       
   126                         OstTrace1(
       
   127                             TRACE_NORMAL,
       
   128                             WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_RESULT,
       
   129                             "WlanQtUtilsConMonWrapperDisconnect::DisconnectConnection Result;KErr=%d", KErr);
       
   130                     }
       
   131                 }
       
   132             }
       
   133         }
       
   134     }
       
   135     
       
   136     OstTraceFunctionExit1( WLANQTUTILSCONMONWRAPPERDISCONNECT_DISCONNECTCONNECTION_EXIT, this);
       
   137 }