wlansecuritysettings/wifiprotectedsetup/src/wifiprotactiveresp.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 CWiFiProtActiveResp class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "wifiprotactiveresp.h"
       
    21 #include "wifiprotlogger.h"
       
    22 
       
    23 //CONSTS
       
    24 _LIT( KActiveRespPanic , "WPS Active Resp");
       
    25 // ================= MEMBER FUNCTIONS =======================
       
    26 
       
    27 
       
    28 // --------------------------------------------------------------------------
       
    29 // CWiFiProtActiveResp::NewL
       
    30 // --------------------------------------------------------------------------
       
    31 //
       
    32 CWiFiProtActiveResp* CWiFiProtActiveResp::NewL(  const TWlanSsid& aSSid,
       
    33                                          TBool aConnectionNeeded,
       
    34                                          RArray<TUint32>& aUidsReturned,
       
    35                                          WiFiProt::TWiFiReturn&
       
    36                                          aReturnValue )
       
    37     {
       
    38     CLOG_ENTERFN( "CWiFiProtActiveResp::NewL" );
       
    39     CWiFiProtActiveResp* self =
       
    40      new( ELeave )CWiFiProtActiveResp( aSSid , aConnectionNeeded,
       
    41                                        aUidsReturned,
       
    42                                        aReturnValue );
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL();
       
    45     CleanupStack::Pop( self );
       
    46 
       
    47     CLOG_LEAVEFN( "CWiFiProtActiveResp::NewL" );
       
    48     return self;
       
    49     }
       
    50     
       
    51 // --------------------------------------------------------------------------
       
    52 // CWiFiProtActiveResp::NewL
       
    53 // --------------------------------------------------------------------------
       
    54 //
       
    55 CWiFiProtActiveResp* CWiFiProtActiveResp::NewL(  const TWlanSsid& aSSid,
       
    56                                      TWlanProtectedSetupCredentialAttribute&
       
    57                                                             aNetworkSettings,
       
    58                                          WiFiProt::TWiFiReturn&
       
    59                                          aReturnValue )
       
    60     {
       
    61     CLOG_ENTERFN( "CWiFiProtActiveResp::NewL" );
       
    62     CWiFiProtActiveResp* self =
       
    63      new( ELeave )CWiFiProtActiveResp( aSSid , 
       
    64                                        aNetworkSettings,
       
    65                                        aReturnValue );
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL();
       
    68     CleanupStack::Pop( self );
       
    69 
       
    70     CLOG_LEAVEFN( "CWiFiProtActiveResp::NewL" );
       
    71     return self;
       
    72     }
       
    73     
       
    74 // ----------------------------------------------------
       
    75 // CWiFiProtActiveResp::~CWiFiProtActiveResp()
       
    76 // ----------------------------------------------------
       
    77 //
       
    78 CWiFiProtActiveResp::~CWiFiProtActiveResp()
       
    79     {
       
    80     CLOG_ENTERFN( "CWiFiProtActiveResp::~CWiFiProtActiveResp" );
       
    81     Cancel();
       
    82     CLOG_LEAVEFN( "CWiFiProtActiveResp::~CWiFiProtActiveResp" );
       
    83     }
       
    84 
       
    85 // --------------------------------------------------------------------------
       
    86 // CWiFiProtActiveResp::RunL
       
    87 // --------------------------------------------------------------------------
       
    88 //
       
    89 void CWiFiProtActiveResp::RunL()
       
    90     {
       
    91     CLOG_ENTERFN( "CWiFiProtActiveResp::RunL");
       
    92 
       
    93     if ( iWiFiInputParams().iConnectionNeeded )
       
    94         {
       
    95         *iNetworkSettings = iWiFiConnOutputParams().iNetworkSettings;
       
    96         iReturnValue = iWiFiConnOutputParams().iReturn;
       
    97         }
       
    98     else
       
    99         {
       
   100         if ( iStatus.Int() == KErrNone )
       
   101             {            
       
   102             //CM creation mode (WPS phase 1), return iap id array    
       
   103             const TInt elementSize = sizeof( TUint32 );
       
   104             const TInt elementCount = iWiFiOutputParams().iIapIds.Length()
       
   105                                                             / elementSize;
       
   106             const TUint8* ptr = iWiFiOutputParams().iIapIds.Ptr();
       
   107             
       
   108             for ( TInt i = 0; i < elementCount; i++)
       
   109                 {
       
   110                 iIapIds->Append( *( (TUint32*) &( ptr[elementSize*i] ) ) );
       
   111                 }
       
   112             }
       
   113         iReturnValue = iWiFiOutputParams().iReturn;
       
   114         }
       
   115 
       
   116     TRequestStatus* pS = iRequestStatus;
       
   117     User::RequestComplete( pS, iStatus.Int() );
       
   118 
       
   119     CLOG_LEAVEFN( "CWiFiProtActiveResp::RunL");
       
   120     }
       
   121 
       
   122 // --------------------------------------------------------------------------
       
   123 // CWiFiProtActiveResp::DoCancel
       
   124 // --------------------------------------------------------------------------
       
   125 //
       
   126 void CWiFiProtActiveResp::DoCancel()
       
   127     {
       
   128     CLOG_ENTERFN( "CWiFiProtActiveResp:DoCancel");
       
   129     TRequestStatus* pS = iRequestStatus;
       
   130     User::RequestComplete( pS, KErrCancel );
       
   131     CLOG_LEAVEFN( "CWiFiProtActiveResp::DoCancel");
       
   132     }
       
   133 
       
   134 // --------------------------------------------------------------------------
       
   135 // CWiFiProtActiveResp::Observe
       
   136 // --------------------------------------------------------------------------
       
   137 //
       
   138 void CWiFiProtActiveResp::Observe( TRequestStatus &aStatus )
       
   139     {
       
   140     CLOG_ENTERFN( "CWiFiProtActiveResp::Observe");
       
   141     CActiveScheduler::Add( this );
       
   142 
       
   143     iRequestStatus = &aStatus;
       
   144     *iRequestStatus = KRequestPending;
       
   145 
       
   146     SetActive();
       
   147     CLOG_LEAVEFN( "CWiFiProtActiveResp::Observe");
       
   148     }
       
   149 
       
   150 // --------------------------------------------------------------------------
       
   151 // CWiFiProtActiveResp::InputBuffer
       
   152 // --------------------------------------------------------------------------
       
   153 //
       
   154 TPckgBuf<WiFiProt::TWiFiInputParams>* CWiFiProtActiveResp::InputBuffer() 
       
   155     { 
       
   156     return &iWiFiInputParams; 
       
   157     }
       
   158         
       
   159 // --------------------------------------------------------------------------
       
   160 // CWiFiProtActiveResp::OutputBuffer
       
   161 // --------------------------------------------------------------------------
       
   162 //
       
   163 TPckgBuf<WiFiProt::TWiFiOutputParams>* CWiFiProtActiveResp::OutputBuffer() 
       
   164     {
       
   165     if ( iWiFiInputParams().iConnectionNeeded )
       
   166         {
       
   167         // Should use ConnOutputBuffer() if configuring a connection!
       
   168         User::Panic( KActiveRespPanic , KErrNotSupported);
       
   169         }
       
   170     return &iWiFiOutputParams; 
       
   171     }
       
   172 
       
   173 // --------------------------------------------------------------------------
       
   174 // CWiFiProtActiveResp::ConnOutputBuffer
       
   175 // --------------------------------------------------------------------------
       
   176 //
       
   177 TPckgBuf<WiFiProt::TWiFiConnOutputParams>* CWiFiProtActiveResp::ConnOutputBuffer() 
       
   178     { 
       
   179     if ( !(iWiFiInputParams().iConnectionNeeded) )
       
   180         {
       
   181         // Should use OutputBuffer() if not configuring a connection!
       
   182         User::Panic( KActiveRespPanic , KErrNotSupported);
       
   183         }
       
   184     return &iWiFiConnOutputParams; 
       
   185     }
       
   186 
       
   187 // --------------------------------------------------------------------------
       
   188 // CWiFiProtActiveResp::CWiFiProtActiveResp
       
   189 // --------------------------------------------------------------------------
       
   190 //
       
   191 CWiFiProtActiveResp::CWiFiProtActiveResp(
       
   192                      const TWlanSsid& aSSid, TBool aConnectionNeeded,
       
   193                      RArray<TUint32>& aUidsReturned,
       
   194                      WiFiProt::TWiFiReturn& aReturnValue )
       
   195                      : CActive( CActive::EPriorityUserInput ),
       
   196                      iIapIds( &aUidsReturned ),
       
   197                      iReturnValue( aReturnValue ),
       
   198                      iWiFiOutputParams( KNullDesC8() ),
       
   199                      iWiFiInputParams( TPckgBuf<WiFiProt::TWiFiInputParams>
       
   200                      ( WiFiProt::TWiFiInputParams( aSSid, 
       
   201                                                    aConnectionNeeded ) ) ),
       
   202               iWiFiConnOutputParams(TPckgBuf<WiFiProt::TWiFiConnOutputParams>
       
   203                      ( WiFiProt::TWiFiConnOutputParams(
       
   204                       TWlanProtectedSetupCredentialAttribute() ) )  )
       
   205     {
       
   206     }
       
   207     
       
   208 // --------------------------------------------------------------------------
       
   209 // CWiFiProtActiveResp::CWiFiProtActiveResp
       
   210 // --------------------------------------------------------------------------
       
   211 //
       
   212 CWiFiProtActiveResp::CWiFiProtActiveResp(
       
   213                      const TWlanSsid& aSSid,
       
   214                      TWlanProtectedSetupCredentialAttribute&
       
   215                                               aNetworkSettings,
       
   216                      WiFiProt::TWiFiReturn& aReturnValue )
       
   217                      : CActive( CActive::EPriorityUserInput ),
       
   218                      iIapIds( NULL ),
       
   219                      iReturnValue( aReturnValue ),
       
   220                      iWiFiOutputParams( KNullDesC8() ),
       
   221                      iWiFiInputParams( TPckgBuf<WiFiProt::TWiFiInputParams>
       
   222                      ( WiFiProt::TWiFiInputParams( aSSid, 
       
   223                                                    ETrue ) ) ),
       
   224               iWiFiConnOutputParams(TPckgBuf<WiFiProt::TWiFiConnOutputParams>
       
   225                      ( WiFiProt::TWiFiConnOutputParams(
       
   226                       TWlanProtectedSetupCredentialAttribute() ) ) ),
       
   227                      iNetworkSettings( &aNetworkSettings )
       
   228                                                    
       
   229     {
       
   230     }
       
   231     
       
   232 // --------------------------------------------------------------------------
       
   233 // CWiFiProtActiveResp::ConstructL
       
   234 // --------------------------------------------------------------------------
       
   235 //
       
   236 void CWiFiProtActiveResp::ConstructL()
       
   237     {
       
   238     }
       
   239     
       
   240 // End of File