wvuing/wvuieng/EngSrc/CCAAccessManager.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Network operations for chat access handling.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "ChatDebugPrint.h"
       
    21 
       
    22 #include "CCAAccessManager.h"
       
    23 #include "MCAImpsAccessClient.h"
       
    24 #include "CCAAdapterDll.h"
       
    25 #include "MCAImpsFactory.h"
       
    26 #include "CCARequest.h"
       
    27 #include "CCARequestMapper.h"
       
    28 
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 // Symbian OS default constructor can leave.
       
    32 void CCAAccessManager::ConstructL()
       
    33     {
       
    34     CHAT_DP_TXT( "CCAAccessManager::ConstructL, CreateAccessClientL" );
       
    35     iImpsAccessClient = CreateImpsFactoryL()->CreateAccessClientL();
       
    36 
       
    37     iImpsAccessClient->RegisterL( this, CActive::EPriorityIdle );
       
    38     iImpsAccessClient->RegisterErrorObserverL( *this );
       
    39     }
       
    40 
       
    41 // Two-phased constructor.
       
    42 CCAAccessManager* CCAAccessManager::NewL( CCARequestMapper& aRequestMapper )
       
    43     {
       
    44     CCAAccessManager* self = new ( ELeave ) CCAAccessManager( aRequestMapper );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49     }
       
    50 
       
    51 // Destructor
       
    52 CCAAccessManager::~CCAAccessManager()
       
    53     {
       
    54     if ( iImpsAccessClient )
       
    55         {
       
    56         iImpsAccessClient->Unregister();
       
    57         }
       
    58     }
       
    59 
       
    60 // C++ default constructor can NOT contain any code, that
       
    61 // might leave.
       
    62 //
       
    63 CCAAccessManager::CCAAccessManager( CCARequestMapper& aRequestMapper )
       
    64         : iRequestMapper( aRequestMapper )
       
    65     {
       
    66     }
       
    67 
       
    68 void CCAAccessManager::LoginL(   TImpsCspIdentifier& aCspId,
       
    69                                  const TDesC& aPsw,
       
    70                                  const TDesC& aClientId,
       
    71                                  TUint32 aAP,
       
    72                                  const TDesC* aKey1/* = NULL*/,
       
    73                                  const TDesC* aKey2/* = NULL*/ )
       
    74     {
       
    75     CHAT_DP_FUNC_ENTER( "CCAAccessManager::LoginL" );
       
    76     TInt opId = iImpsAccessClient->LoginL( aCspId, aPsw, aClientId,
       
    77                                            aAP, aKey1, aKey2 );
       
    78     CHAT_DP( D_CHAT_LIT( "CCAAccessManager::LoginL - opid=%d" ), opId );
       
    79     TInt error = ExecuteRequestL( opId, ELoginRequest );
       
    80     CHAT_DP( D_CHAT_LIT( "CCAAccessManager::LoginL - opid=%d, status=%d" ),
       
    81              opId, error );
       
    82     CHAT_DP_FUNC_DONE( "CCAAccessManager::LoginL" );
       
    83     }
       
    84 
       
    85 void CCAAccessManager::LogoutL()
       
    86     {
       
    87     CHAT_DP_FUNC_ENTER( "CCAAccessManager::LogoutL" );
       
    88     TInt opId = iImpsAccessClient->LogoutL();
       
    89     TInt error = ExecuteRequestL( opId, ELogoutRequest );
       
    90     CHAT_DP( D_CHAT_LIT( "CCAAccessManager::LogoutL - opid=%d, status=%d" ),
       
    91              opId, error );
       
    92     CHAT_DP_FUNC_DONE( "CCAAccessManager::LogoutL" );
       
    93     }
       
    94 
       
    95 // --------------------------------------------------------
       
    96 // CCAGroupManager::HandleErrorL
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 void CCAAccessManager::HandleErrorL(
       
   100     TInt aStatus,
       
   101     TInt aOpId,
       
   102     const TDesC* /* aDescription */,
       
   103     const CImpsDetailed* /* aDetailedRes */,
       
   104     TImpsCspIdentifier& /*aCspId*/ )
       
   105     {
       
   106     CHAT_DP_FUNC_ENTER( "HandleErrorL" );
       
   107     CHAT_DP( D_CHAT_LIT( "CCAAccessManager::HandleErrorL - opid=%d, status=%d" ),
       
   108              aOpId, aStatus );
       
   109     iRequestMapper.HandleRequest( aOpId, aStatus );
       
   110     CHAT_DP_FUNC_DONE( "HandleErrorL" );
       
   111     }
       
   112 
       
   113 void CCAAccessManager::HandleLoginL( TInt aId,
       
   114                                      TImpsCspIdentifier& /* aCspId */ )
       
   115     {
       
   116     CHAT_DP( D_CHAT_LIT( "CCAAccessManager::HandleLoginL - opid=%d" ), aId );
       
   117     iRequestMapper.HandleRequest( aId, KErrNone );
       
   118     }
       
   119 
       
   120 void CCAAccessManager::HandleLogoutL( TInt aId,
       
   121                                       TImpsCspIdentifier& /* aCspId */ )
       
   122     {
       
   123     CHAT_DP( D_CHAT_LIT( "CCAAccessManager::HandleLogoutL - opid=%d" ), aId );
       
   124     iRequestMapper.HandleRequest( aId, KErrNone );
       
   125     }
       
   126 
       
   127 void CCAAccessManager::HandleLoginCancelL( TInt aCancelledOpId,
       
   128                                            TImpsCspIdentifier& /* aCspId */ )
       
   129     {
       
   130     CHAT_DP( D_CHAT_LIT( "CCAAccessManager::HandleLoginCancelL - opid=%d" ),
       
   131              aCancelledOpId );
       
   132     iRequestMapper.HandleRequest( aCancelledOpId, KErrCancel );
       
   133     }
       
   134 
       
   135 void CCAAccessManager::HandleNbrSessionsL( TInt aId,
       
   136                                            TInt /* aNbr */,
       
   137                                            TImpsCspIdentifier& /* aCspId */ )
       
   138     {
       
   139     CHAT_DP( D_CHAT_LIT( "CCAAccessManager::HandleNbrSessionsL - opid=%d" ),
       
   140              aId );
       
   141     iRequestMapper.HandleRequest( aId, KErrNone );
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------
       
   145 // CCAGroupWrapper::ExecuteRequest
       
   146 // ---------------------------------------------------------
       
   147 //
       
   148 TInt CCAAccessManager::ExecuteRequestL( TInt aOperationId,
       
   149                                         TOperationRequests aRequestType,
       
   150                                         MDesCArray* aAdditionalData )
       
   151     {
       
   152     // creating request
       
   153     CCARequest* request = iRequestMapper.CreateRequestL( aOperationId, EFalse );
       
   154     CCARequestMapper& requestMapper = iRequestMapper;
       
   155 
       
   156     // setting type
       
   157     request->SetRequestType( aRequestType );
       
   158 
       
   159     // setting additional data if exists
       
   160     if ( aAdditionalData )
       
   161         {
       
   162         request->SetAdditionalData( *aAdditionalData );
       
   163         }
       
   164 
       
   165     // Now when the request type and additional data is set we can
       
   166     // activate the synchronous wait
       
   167     if ( aRequestType != ELogoutRequest )
       
   168         {
       
   169         request->StartWait();
       
   170         }
       
   171 
       
   172     TInt retVal( request->ErrorCode() );
       
   173     requestMapper.RemoveRequest( request );
       
   174 
       
   175     return retVal;
       
   176     }
       
   177 
       
   178 //  End of File