wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepaliveesock.cpp
branchRCL_3
changeset 24 63be7eb3fc78
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
       
     1 /*
       
     2 * Copyright (c) 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 * Esock library (RConnection) interface implementation.
       
    16 */
       
    17 
       
    18 // System include files
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <es_sock.h>
       
    22 #include <in_sock.h>
       
    23 #include <extendedconnpref.h>
       
    24 
       
    25 // User include files
       
    26 
       
    27 #include "wsfkeepaliveesock.h"
       
    28 #include "OstTraceDefinitions.h"
       
    29 #ifdef OST_TRACE_COMPILER_IN_USE
       
    30 #include "wsfkeepaliveesockTraces.h"
       
    31 #endif
       
    32 
       
    33 // External function prototypes
       
    34 
       
    35 // Local constants
       
    36 
       
    37 // ======== LOCAL FUNCTIONS ========
       
    38 
       
    39 // ======== MEMBER FUNCTIONS ========
       
    40 
       
    41 CWsfKeepaliveEsock* CWsfKeepaliveEsock::NewL()
       
    42     {
       
    43     OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_NEWL_ENTRY );
       
    44     
       
    45     CWsfKeepaliveEsock* me = new ( ELeave ) CWsfKeepaliveEsock();
       
    46     CleanupStack::PushL( me );
       
    47     me->ConstructL();
       
    48     CleanupStack::Pop( me );
       
    49     
       
    50     OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_NEWL_EXIT );
       
    51     return me;
       
    52     }
       
    53  
       
    54 CWsfKeepaliveEsock::~CWsfKeepaliveEsock()
       
    55     {
       
    56     OstTraceFunctionEntry0(
       
    57         DUP1_CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_ENTRY );
       
    58  
       
    59     Cancel();
       
    60     iSocketServer.Close();
       
    61     
       
    62     OstTraceFunctionExit0( DUP1_CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_EXIT );
       
    63     }
       
    64 
       
    65 void CWsfKeepaliveEsock::ConnectL( TUint aIapId )
       
    66     {
       
    67     OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_CONNECTL_ENTRY );
       
    68 
       
    69     // Open an RConnection object.
       
    70     User::LeaveIfError( iConnection.Open( iSocketServer ) );
       
    71     
       
    72     // Create overrides for connection preferences to force opening of the
       
    73     // given IAP without any user prompts.
       
    74     TConnPrefList prefList;
       
    75     TExtendedConnPref prefs;
       
    76     prefs.SetIapId( aIapId );
       
    77     prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent );
       
    78     prefList.AppendL( &prefs );
       
    79      
       
    80     // Start a connection with connection preferences
       
    81     iConnection.Start( prefList, iStatus );
       
    82     
       
    83     SetActive();
       
    84     
       
    85     OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_CONNECTL_EXIT );
       
    86     }
       
    87 
       
    88 void CWsfKeepaliveEsock::Disconnect()
       
    89     {      
       
    90     OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_DISCONNECT_ENTRY );
       
    91     
       
    92     iConnection.Close();
       
    93     
       
    94     OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_DISCONNECT_EXIT );
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // Default constructor
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CWsfKeepaliveEsock::CWsfKeepaliveEsock() :
       
   102     CActive( EPriorityStandard )
       
   103     {
       
   104     OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_ENTRY );
       
   105     OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_EXIT );
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // Leaving constructor
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CWsfKeepaliveEsock::ConstructL()
       
   113     {
       
   114     OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_CONSTRUCTL_ENTRY );
       
   115     
       
   116     CActiveScheduler::Add( this );
       
   117     User::LeaveIfError( iSocketServer.Connect() );
       
   118     
       
   119     OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_CONSTRUCTL_EXIT );
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // Handles an active object's request completion event
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 void CWsfKeepaliveEsock::RunL()
       
   127     {
       
   128     OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_RUNL_ENTRY );
       
   129 
       
   130     OstTrace1(
       
   131         TRACE_NORMAL,
       
   132         CWSFKEEPALIVEESOCK_RUNL,
       
   133         "CWsfKeepaliveEsock::RunL;iStatus.Int()=%d",
       
   134         iStatus.Int() );
       
   135     
       
   136     OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_RUNL_EXIT );
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // Implements cancellation of an outstanding request
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void CWsfKeepaliveEsock::DoCancel()
       
   144     {
       
   145     OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_DOCANCEL_ENTRY );
       
   146     
       
   147     // Disconnect a (possibly) ongoing request
       
   148     Disconnect();
       
   149     
       
   150     OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_DOCANCEL_EXIT );
       
   151     }