wlanutilities/wlansniffer/aiplugin/src/wsfconnectactivewrapper.cpp
branchRCL_3
changeset 25 f28ada11abbf
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Implementation of CWsfConnectActiveWrapper.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "wsflogger.h"
       
    22 #include "wsfmodel.h"
       
    23 #include "wsfwlaninfoarray.h"
       
    24 #include "wsfconnectactivewrapper.h"
       
    25 
       
    26 
       
    27 // --------------------------------------------------------------------------
       
    28 // CWsfConnectActiveWrapper::CWsfConnectActiveWrapper
       
    29 // --------------------------------------------------------------------------
       
    30 //
       
    31 CWsfConnectActiveWrapper::CWsfConnectActiveWrapper() :
       
    32     CActive(EPriorityStandard) // Standard priority
       
    33     {
       
    34     }
       
    35 
       
    36 
       
    37 // --------------------------------------------------------------------------
       
    38 // CWsfConnectActiveWrapper::NewLC
       
    39 // --------------------------------------------------------------------------
       
    40 //
       
    41 CWsfConnectActiveWrapper* CWsfConnectActiveWrapper::NewLC( CWsfModel* aModel )
       
    42     {
       
    43     LOG_ENTERFN( "CWsfConnectActiveWrapper::NewLC" );
       
    44     CWsfConnectActiveWrapper* self =
       
    45             new (ELeave) CWsfConnectActiveWrapper();
       
    46     CleanupStack::PushL(self);
       
    47     self->ConstructL( aModel );
       
    48     return self;
       
    49     }
       
    50 
       
    51 
       
    52 // --------------------------------------------------------------------------
       
    53 // CWsfConnectActiveWrapper::NewL
       
    54 // --------------------------------------------------------------------------
       
    55 //
       
    56 CWsfConnectActiveWrapper* CWsfConnectActiveWrapper::NewL(  CWsfModel* aModel )
       
    57     {
       
    58     LOG_ENTERFN( "CWsfConnectActiveWrapper::NewL" );
       
    59     CWsfConnectActiveWrapper* self = 
       
    60             CWsfConnectActiveWrapper::NewLC( aModel );
       
    61     CleanupStack::Pop(); // self;
       
    62     return self;
       
    63     }
       
    64 
       
    65 
       
    66 // --------------------------------------------------------------------------
       
    67 // CWsfConnectActiveWrapper::ConstructL
       
    68 // --------------------------------------------------------------------------
       
    69 //
       
    70 void CWsfConnectActiveWrapper::ConstructL( CWsfModel* aModel )
       
    71     {
       
    72     LOG_ENTERFN( "CWsfConnectActiveWrapper::ConstructL" );
       
    73     CActiveScheduler::Add(this); // Add to scheduler
       
    74     iModel = aModel;
       
    75     }
       
    76 
       
    77 
       
    78 // --------------------------------------------------------------------------
       
    79 // CWsfConnectActiveWrapper::~CWsfConnectActiveWrapper
       
    80 // --------------------------------------------------------------------------
       
    81 //
       
    82 CWsfConnectActiveWrapper::~CWsfConnectActiveWrapper()
       
    83     {
       
    84     LOG_ENTERFN( 
       
    85             "CWsfConnectActiveWrapper::~CWsfConnectActiveWrapper" );
       
    86     Cancel(); // Cancel any request, if outstanding
       
    87     // Delete instance variables if any
       
    88     }
       
    89 
       
    90 
       
    91 // --------------------------------------------------------------------------
       
    92 // CWsfConnectActiveWrapper::DoCancel
       
    93 // --------------------------------------------------------------------------
       
    94 //
       
    95 void CWsfConnectActiveWrapper::DoCancel()
       
    96     {
       
    97     LOG_ENTERFN( "CWsfConnectActiveWrapper::DoCancel" );
       
    98     }
       
    99 
       
   100 
       
   101 // --------------------------------------------------------------------------
       
   102 // CWsfConnectActiveWrapper::StartL
       
   103 // --------------------------------------------------------------------------
       
   104 //
       
   105 void CWsfConnectActiveWrapper::Start( TUint aIapID, TBool aConnectOnly, 
       
   106                                       TWsfIapPersistence aPersistence )
       
   107     {
       
   108     LOG_ENTERFN( "CWsfConnectActiveWrapper::Start" );
       
   109     Cancel(); // Cancel any request, just to be sure
       
   110     iState = EUninitialized;
       
   111     iIapID = aIapID;
       
   112     iConnectOnly = aConnectOnly;
       
   113     iPersistence = aPersistence;
       
   114     SetActive();
       
   115     TRequestStatus* status = &iStatus;
       
   116     User::RequestComplete( status, KErrNone );
       
   117     }
       
   118 
       
   119 
       
   120 // --------------------------------------------------------------------------
       
   121 // CWsfConnectActiveWrapper::RunL
       
   122 // --------------------------------------------------------------------------
       
   123 //
       
   124 void CWsfConnectActiveWrapper::RunL()
       
   125     {
       
   126     LOG_ENTERFN( "CWsfConnectActiveWrapper::RunL" );
       
   127     if ( iStatus == KErrNone )
       
   128         {
       
   129         if ( iState == EUninitialized )
       
   130             {
       
   131             LOG_WRITE( "Start connect" );
       
   132             iModel->ConnectL( iPckg, iIapID, iConnectOnly, iPersistence, iStatus );
       
   133             iState = EInitialized;
       
   134             SetActive(); // Tell scheduler a request is active
       
   135             }
       
   136         else if ( iState == EInitialized )
       
   137             {
       
   138             LOG_WRITEF( "request result = %d", iPckg() );
       
   139             iModel->SetConnectResultL( iPckg(), iIapID );
       
   140             }
       
   141         else
       
   142             {
       
   143             LOG_WRITEF( "iState = %d", iState );
       
   144             }
       
   145         }
       
   146     else
       
   147         {
       
   148         LOG_WRITEF( "ConnectActiveWrapper iStatus = %d", iStatus.Int() );
       
   149         }
       
   150     }
       
   151 
       
   152 
       
   153 // --------------------------------------------------------------------------
       
   154 // CWsfConnectActiveWrapper::RunError
       
   155 // --------------------------------------------------------------------------
       
   156 //
       
   157 #ifdef _DEBUG
       
   158 TInt CWsfConnectActiveWrapper::RunError( TInt aError )
       
   159     {
       
   160     LOG_ENTERFN( "CWsfConnectActiveWrapper::RunError" );
       
   161     LOG_WRITEF( "aError = %d", aError );
       
   162     TRAP_IGNORE( iModel->SetConnectResultL(iPckg(), iIapID ) );
       
   163     return aError;
       
   164     }
       
   165 #else
       
   166 TInt CWsfConnectActiveWrapper::RunError( TInt /*aError*/ )
       
   167     {
       
   168     TRAP_IGNORE( iModel->SetConnectResultL(iPckg(), iIapID ) );
       
   169     return KErrNone;
       
   170     }
       
   171 #endif
       
   172 
       
   173 
       
   174