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