IMPSengine/client/src/impsaccesshandler.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2002-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: 
       
    15 * handler for data accessor.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32std.h>
       
    21 
       
    22 #include "ImpsAccessCli.h"
       
    23 #include "ImpsAccessHandler.h"
       
    24 #include "ImpsUtils.h"
       
    25 #include "impserrors.h"
       
    26 
       
    27 // MACROS
       
    28 #ifndef _DEBUG
       
    29 #define _NO_IMPS_LOGGING_
       
    30 #endif
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 
       
    34 // ----------------------------------------------------------------------------
       
    35 // CImpsAccessHandler2::CImpsAccessHandler2
       
    36 // ----------------------------------------------------------------------------
       
    37 CImpsAccessHandler2::CImpsAccessHandler2( 
       
    38     TInt aPriority, 
       
    39     RImpsAccessClient2& aClient  ) :
       
    40     // The base class adds this to the scheduler
       
    41     CImpsHandler2( aPriority, aClient)
       
    42     {
       
    43     }
       
    44 
       
    45 // ----------------------------------------------------------------------------
       
    46 // CImpsAccessHandler2::NewL
       
    47 // ----------------------------------------------------------------------------
       
    48 CImpsAccessHandler2* CImpsAccessHandler2::NewL( 
       
    49      RImpsAccessClient2& aClient,
       
    50      TInt aPriority )
       
    51      {
       
    52 
       
    53       // Perform the construction.
       
    54       CImpsAccessHandler2* self = new (ELeave)
       
    55             CImpsAccessHandler2( aPriority , aClient);
       
    56 
       
    57       CleanupStack::PushL( self );
       
    58       self->ConstructL();
       
    59       CleanupStack::Pop( self );
       
    60 
       
    61       return self;
       
    62      }
       
    63 
       
    64 // ----------------------------------------------------------------------------
       
    65 // CImpsAccessHandler2::~CImpsAccessHandler2()
       
    66 // ----------------------------------------------------------------------------
       
    67 CImpsAccessHandler2::~CImpsAccessHandler2()
       
    68      {
       
    69 
       
    70      }
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // CImpsAccessHandler2::HandleEventL()
       
    74 // ----------------------------------------------------------------------------
       
    75 
       
    76 void CImpsAccessHandler2::HandleEventL( CImpsFields* aErrorFields )
       
    77     {
       
    78     // get the event data from server thread.
       
    79 #ifndef _NO_IMPS_LOGGING_
       
    80      CImpsClientLogger::Log(_L("CImpsAccessHandler2::HandleEventL begins"));
       
    81 #endif
       
    82 
       
    83     SImpsEventData* event = (SImpsEventData*)iEventData.Ptr();
       
    84 
       
    85     // SAP initiated Disconnect is another special case 
       
    86     // First is SAP initiated disconnect response
       
    87     if ( event->iReqMesType == EImpsMessageNone &&  
       
    88               event->iMessageType == EImpsDisconnect )
       
    89         {
       
    90         HandleAccessEventL( ); 
       
    91         }
       
    92     else
       
    93         {
       
    94         if ( event->iStatus != ( Imps_ERROR_BASE - 200 ) &&
       
    95                  event->iStatus != KErrNone )
       
    96             {
       
    97             HandleErrorEventL( event->iOpCode, event->iStatus, aErrorFields );
       
    98             }
       
    99             // Call regular observer
       
   100             // iStatus is error code or message size
       
   101          else if ( iStatus >= 0 )
       
   102             {
       
   103             HandleAccessEventL( ); 
       
   104             }
       
   105         }
       
   106     }
       
   107 
       
   108 // ----------------------------------------------------------------------------
       
   109 // CImpsAccessHandler2::HandleAccessEventL()
       
   110 // ----------------------------------------------------------------------------
       
   111 void CImpsAccessHandler2::HandleAccessEventL( )
       
   112     {
       
   113     SImpsEventData* event = (SImpsEventData*)iEventData.Ptr();
       
   114     // RImpsAccessClient2& client = (RImpsAccessClient2&)iClient;
       
   115     MImpsAccessHandler2* handler = ((RImpsAccessClient2&)iClient).Handler();
       
   116 
       
   117 	TInt err( KErrNone );
       
   118 	
       
   119 #ifndef _NO_IMPS_LOGGING_
       
   120      CImpsClientLogger::Log(_L("CImpsAccessHandler2::HandleAccessEvent BEgins"));
       
   121 #endif
       
   122 
       
   123 	// special case, login is cancelled
       
   124 	if ( ((RImpsAccessClient2&)iClient).LoginCancelled() )
       
   125 	{
       
   126 		// check that operation id is the same 
       
   127 		// that was used when logged in
       
   128 		if ( ((RImpsAccessClient2&)iClient).LoginOpId() == event->iOpCode )	
       
   129 		{
       
   130 #ifndef _NO_IMPS_LOGGING_
       
   131      CImpsClientLogger::Log(_L("CImpsAccessHandler2::HandleLoginCancelL call opid=%d sta=%d"), 
       
   132          event->iOpCode, event->iStatus);
       
   133 #endif
       
   134 
       
   135             TRAP( err, handler->HandleLoginCancelL(
       
   136                 event->iOpCode,
       
   137                 *iClient.CspIdentifier() ));                 
       
   138 #ifndef _NO_IMPS_LOGGING_
       
   139      CImpsClientLogger::Log(_L("CImpsAccessHandler2::HandleLoginCancelL call OK"));
       
   140 #endif	
       
   141 		// reset the variables
       
   142 		((RImpsAccessClient2&)iClient).CancelHandled();
       
   143 		return;
       
   144 		}
       
   145 	}
       
   146 	
       
   147 	// normal case,
       
   148     // call application's event handler
       
   149     TInt myType = event->iRequestType;
       
   150     switch ( myType )
       
   151         {
       
   152 
       
   153         case EImpsServWVLogin:
       
   154             {
       
   155 #ifndef _NO_IMPS_LOGGING_
       
   156      CImpsClientLogger::Log(_L("CImpsAccessHandler2::HandleLoginL call opid=%d sta=%d"), 
       
   157          event->iOpCode, event->iStatus);
       
   158 #endif
       
   159 
       
   160             TRAP( err, handler->HandleLoginL(
       
   161                 event->iOpCode,
       
   162                 *iClient.CspIdentifier() ));                 
       
   163 #ifndef _NO_IMPS_LOGGING_
       
   164      CImpsClientLogger::Log(_L("CImpsAccessHandler2::HandleLoginL call OK"));
       
   165 #endif
       
   166             break;
       
   167             }
       
   168 
       
   169         case EImpsServWVLogout:
       
   170             {
       
   171 #ifndef _NO_IMPS_LOGGING_
       
   172      CImpsClientLogger::Log(_L("CImpsAccessHandler2::HandleLogoutL call opid=%d sta=%d"), 
       
   173          event->iOpCode, event->iStatus);
       
   174 #endif
       
   175             TRAP( err, handler->HandleLogoutL(
       
   176                 event->iOpCode,
       
   177                 *iClient.CspIdentifier() ));   
       
   178 #ifndef _NO_IMPS_LOGGING_
       
   179      CImpsClientLogger::Log(_L("CImpsAccessHandler2::HandleLogoutL call OK"));
       
   180 #endif
       
   181             break;
       
   182             }
       
   183 
       
   184         default:
       
   185             break;
       
   186         }
       
   187     }
       
   188 //  End of File