wlanutilities/wlansniffer/wlansnifferkeepalive/src/wsfkeepaliveesock.cpp
author hgs
Mon, 24 May 2010 21:11:39 +0300
changeset 31 e8f4211554fb
permissions -rw-r--r--
201021
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
* Esock library (RConnection) interface implementation.
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
// System include files
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include <e32base.h>
hgs
parents:
diff changeset
    21
#include <es_sock.h>
hgs
parents:
diff changeset
    22
#include <in_sock.h>
hgs
parents:
diff changeset
    23
#include <extendedconnpref.h>
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
// User include files
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
#include "wsfkeepaliveesock.h"
hgs
parents:
diff changeset
    28
#include "OstTraceDefinitions.h"
hgs
parents:
diff changeset
    29
#ifdef OST_TRACE_COMPILER_IN_USE
hgs
parents:
diff changeset
    30
#include "wsfkeepaliveesockTraces.h"
hgs
parents:
diff changeset
    31
#endif
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
// External function prototypes
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
// Local constants
hgs
parents:
diff changeset
    36
hgs
parents:
diff changeset
    37
// ======== LOCAL FUNCTIONS ========
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
// ======== MEMBER FUNCTIONS ========
hgs
parents:
diff changeset
    40
hgs
parents:
diff changeset
    41
CWsfKeepaliveEsock* CWsfKeepaliveEsock::NewL()
hgs
parents:
diff changeset
    42
    {
hgs
parents:
diff changeset
    43
    OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_NEWL_ENTRY );
hgs
parents:
diff changeset
    44
    
hgs
parents:
diff changeset
    45
    CWsfKeepaliveEsock* me = new ( ELeave ) CWsfKeepaliveEsock();
hgs
parents:
diff changeset
    46
    CleanupStack::PushL( me );
hgs
parents:
diff changeset
    47
    me->ConstructL();
hgs
parents:
diff changeset
    48
    CleanupStack::Pop( me );
hgs
parents:
diff changeset
    49
    
hgs
parents:
diff changeset
    50
    OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_NEWL_EXIT );
hgs
parents:
diff changeset
    51
    return me;
hgs
parents:
diff changeset
    52
    }
hgs
parents:
diff changeset
    53
 
hgs
parents:
diff changeset
    54
CWsfKeepaliveEsock::~CWsfKeepaliveEsock()
hgs
parents:
diff changeset
    55
    {
hgs
parents:
diff changeset
    56
    OstTraceFunctionEntry0(
hgs
parents:
diff changeset
    57
        DUP1_CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_ENTRY );
hgs
parents:
diff changeset
    58
 
hgs
parents:
diff changeset
    59
    Cancel();
hgs
parents:
diff changeset
    60
    iSocketServer.Close();
hgs
parents:
diff changeset
    61
    
hgs
parents:
diff changeset
    62
    OstTraceFunctionExit0( DUP1_CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_EXIT );
hgs
parents:
diff changeset
    63
    }
hgs
parents:
diff changeset
    64
hgs
parents:
diff changeset
    65
void CWsfKeepaliveEsock::ConnectL( TUint aIapId )
hgs
parents:
diff changeset
    66
    {
hgs
parents:
diff changeset
    67
    OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_CONNECTL_ENTRY );
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
    // Open an RConnection object.
hgs
parents:
diff changeset
    70
    User::LeaveIfError( iConnection.Open( iSocketServer ) );
hgs
parents:
diff changeset
    71
    
hgs
parents:
diff changeset
    72
    // Create overrides for connection preferences to force opening of the
hgs
parents:
diff changeset
    73
    // given IAP without any user prompts.
hgs
parents:
diff changeset
    74
    TConnPrefList prefList;
hgs
parents:
diff changeset
    75
    TExtendedConnPref prefs;
hgs
parents:
diff changeset
    76
    prefs.SetIapId( aIapId );
hgs
parents:
diff changeset
    77
    prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent );
hgs
parents:
diff changeset
    78
    prefList.AppendL( &prefs );
hgs
parents:
diff changeset
    79
     
hgs
parents:
diff changeset
    80
    // Start a connection with connection preferences
hgs
parents:
diff changeset
    81
    iConnection.Start( prefList, iStatus );
hgs
parents:
diff changeset
    82
    
hgs
parents:
diff changeset
    83
    SetActive();
hgs
parents:
diff changeset
    84
    
hgs
parents:
diff changeset
    85
    OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_CONNECTL_EXIT );
hgs
parents:
diff changeset
    86
    }
hgs
parents:
diff changeset
    87
hgs
parents:
diff changeset
    88
void CWsfKeepaliveEsock::Disconnect()
hgs
parents:
diff changeset
    89
    {      
hgs
parents:
diff changeset
    90
    OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_DISCONNECT_ENTRY );
hgs
parents:
diff changeset
    91
    
hgs
parents:
diff changeset
    92
    iConnection.Close();
hgs
parents:
diff changeset
    93
    
hgs
parents:
diff changeset
    94
    OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_DISCONNECT_EXIT );
hgs
parents:
diff changeset
    95
    }
hgs
parents:
diff changeset
    96
hgs
parents:
diff changeset
    97
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    98
// Default constructor
hgs
parents:
diff changeset
    99
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   100
//
hgs
parents:
diff changeset
   101
CWsfKeepaliveEsock::CWsfKeepaliveEsock() :
hgs
parents:
diff changeset
   102
    CActive( EPriorityStandard )
hgs
parents:
diff changeset
   103
    {
hgs
parents:
diff changeset
   104
    OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_ENTRY );
hgs
parents:
diff changeset
   105
    OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_CWSFKEEPALIVEESOCK_EXIT );
hgs
parents:
diff changeset
   106
    }
hgs
parents:
diff changeset
   107
hgs
parents:
diff changeset
   108
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   109
// Leaving constructor
hgs
parents:
diff changeset
   110
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   111
//
hgs
parents:
diff changeset
   112
void CWsfKeepaliveEsock::ConstructL()
hgs
parents:
diff changeset
   113
    {
hgs
parents:
diff changeset
   114
    OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_CONSTRUCTL_ENTRY );
hgs
parents:
diff changeset
   115
    
hgs
parents:
diff changeset
   116
    CActiveScheduler::Add( this );
hgs
parents:
diff changeset
   117
    User::LeaveIfError( iSocketServer.Connect() );
hgs
parents:
diff changeset
   118
    
hgs
parents:
diff changeset
   119
    OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_CONSTRUCTL_EXIT );
hgs
parents:
diff changeset
   120
    }
hgs
parents:
diff changeset
   121
hgs
parents:
diff changeset
   122
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   123
// Handles an active object's request completion event
hgs
parents:
diff changeset
   124
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   125
//
hgs
parents:
diff changeset
   126
void CWsfKeepaliveEsock::RunL()
hgs
parents:
diff changeset
   127
    {
hgs
parents:
diff changeset
   128
    OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_RUNL_ENTRY );
hgs
parents:
diff changeset
   129
hgs
parents:
diff changeset
   130
    OstTrace1(
hgs
parents:
diff changeset
   131
        TRACE_NORMAL,
hgs
parents:
diff changeset
   132
        CWSFKEEPALIVEESOCK_RUNL,
hgs
parents:
diff changeset
   133
        "CWsfKeepaliveEsock::RunL;iStatus.Int()=%d",
hgs
parents:
diff changeset
   134
        iStatus.Int() );
hgs
parents:
diff changeset
   135
    
hgs
parents:
diff changeset
   136
    OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_RUNL_EXIT );
hgs
parents:
diff changeset
   137
    }
hgs
parents:
diff changeset
   138
hgs
parents:
diff changeset
   139
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   140
// Implements cancellation of an outstanding request
hgs
parents:
diff changeset
   141
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   142
//
hgs
parents:
diff changeset
   143
void CWsfKeepaliveEsock::DoCancel()
hgs
parents:
diff changeset
   144
    {
hgs
parents:
diff changeset
   145
    OstTraceFunctionEntry0( CWSFKEEPALIVEESOCK_DOCANCEL_ENTRY );
hgs
parents:
diff changeset
   146
    
hgs
parents:
diff changeset
   147
    // Disconnect a (possibly) ongoing request
hgs
parents:
diff changeset
   148
    Disconnect();
hgs
parents:
diff changeset
   149
    
hgs
parents:
diff changeset
   150
    OstTraceFunctionExit0( CWSFKEEPALIVEESOCK_DOCANCEL_EXIT );
hgs
parents:
diff changeset
   151
    }