wlansecuritysettings/wifiprotectedsetup/src/wifiprotsyncclient.cpp
branchRCL_3
changeset 18 bad0cc58d154
parent 17 30e048a7b597
child 19 c74b3d9f6b9e
equal deleted inserted replaced
17:30e048a7b597 18:bad0cc58d154
     1 /*
       
     2 * Copyright (c) 2001-2009 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 the License "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 class CWiFiProtSyncClient.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: tr1cfwln#8 %
       
    20 */
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "wifiprotsyncclient.h"
       
    24 #include "wifiprotlogger.h"
       
    25 
       
    26 //
       
    27 // WiFiProtSyncClient definitions
       
    28 //
       
    29 // --------------------------------------------------------------------------
       
    30 // NewL
       
    31 // --------------------------------------------------------------------------
       
    32 //
       
    33 CWiFiProtSyncClient* CWiFiProtSyncClient::NewL( RWiFiProtSession& aClient,
       
    34                     TInt aPriority )
       
    35     {
       
    36     CWiFiProtSyncClient* self = new(ELeave) CWiFiProtSyncClient( aClient,
       
    37                                                                 aPriority );
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop(); // self
       
    41     return self;
       
    42     }
       
    43 
       
    44 // --------------------------------------------------------------------------
       
    45 // CWiFiProtSyncClient
       
    46 // --------------------------------------------------------------------------
       
    47 //
       
    48 CWiFiProtSyncClient::CWiFiProtSyncClient( RWiFiProtSession& aClient,
       
    49                                           TInt aPriority ) 
       
    50                                          : CActive( aPriority ),
       
    51                                            iClient( aClient )
       
    52     {
       
    53     }
       
    54 
       
    55 // --------------------------------------------------------------------------
       
    56 // ConstructL
       
    57 // --------------------------------------------------------------------------
       
    58 //
       
    59 void CWiFiProtSyncClient::ConstructL()
       
    60     {
       
    61     CActiveScheduler::Add( this );
       
    62     iState = ENoState;
       
    63     }
       
    64 
       
    65 // --------------------------------------------------------------------------
       
    66 // ~CWiFiProtSyncClient
       
    67 // --------------------------------------------------------------------------
       
    68 //
       
    69 CWiFiProtSyncClient::~CWiFiProtSyncClient()
       
    70     {
       
    71     Cancel();
       
    72     }
       
    73 
       
    74 // --------------------------------------------------------------------------
       
    75 // StartWiFiProtL
       
    76 // --------------------------------------------------------------------------
       
    77 //
       
    78 WiFiProt::TWiFiReturn
       
    79     CWiFiProtSyncClient::StartWiFiProtL( const TWlanSsid& aSSid, 
       
    80                                          TBool aConnectionNeeded,
       
    81                                          RArray<TUint32>& aUidsReturned )
       
    82     {
       
    83     WiFiProt::TWiFiReturn ret;
       
    84     iClient.StartWiFiProtL( aSSid, aConnectionNeeded, aUidsReturned, ret,
       
    85                             iStatus );
       
    86     SetActive( ERunWiFiProt );
       
    87     iWait.Start(); //wait for request to complete
       
    88     return ret;
       
    89     }
       
    90 
       
    91 
       
    92     
       
    93 // --------------------------------------------------------------------------
       
    94 // SetActive
       
    95 // --------------------------------------------------------------------------
       
    96 //
       
    97 void CWiFiProtSyncClient::SetActive( TWiFiState aState )
       
    98     {
       
    99     iState = aState;
       
   100     CActive::SetActive();
       
   101     }
       
   102 
       
   103 // --------------------------------------------------------------------------
       
   104 // RunL
       
   105 // --------------------------------------------------------------------------
       
   106 //
       
   107 void CWiFiProtSyncClient::RunL()
       
   108     {
       
   109     const TWiFiState state = iState;
       
   110     iState = ENoState;
       
   111 
       
   112     switch (state)
       
   113         {
       
   114         case ERunWiFiProt:
       
   115             {
       
   116             iWait.AsyncStop();
       
   117             break;
       
   118             }
       
   119         default:
       
   120             {
       
   121             User::Leave(KErrGeneral);
       
   122             break;
       
   123             }
       
   124         }
       
   125     }
       
   126 
       
   127 // --------------------------------------------------------------------------
       
   128 // DoCancel
       
   129 // --------------------------------------------------------------------------
       
   130 //
       
   131 void CWiFiProtSyncClient::DoCancel()
       
   132     { 
       
   133     switch (iState)
       
   134         {
       
   135         case ERunWiFiProt:
       
   136             {
       
   137             CLOG_WRITE( "CWiFiProtSyncClient::DoCancel()" );
       
   138             iClient.CancelWiFiProt();
       
   139             break;
       
   140             }
       
   141         default:
       
   142             {
       
   143             break;
       
   144             }
       
   145         }
       
   146     iState = ENoState;
       
   147     }
       
   148 // End of File