accessoryservices/accessoryserver/src/Server/AccSrvConnectionStatusHandler.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  Connection Status Handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "AccSrvConnectionStatusHandler.h"
       
    21 #include "AccSrvConnectionController.h" //MAccSrvConnectionControllerObserver
       
    22 #include "acc_debug.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 
       
    26 // EXTERNAL FUNCTION PROTOTYPES
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // LOCAL CONSTANTS AND MACROS
       
    33 
       
    34 // MODULE DATA STRUCTURES
       
    35 
       
    36 // LOCAL FUNCTION PROTOTYPES
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 
       
    40 // ============================= LOCAL FUNCTIONS ===============================
       
    41 
       
    42 // ============================ MEMBER FUNCTIONS ===============================
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CAccSrvConnectionStatusHandler::CAccSrvConnectionStatusHandler
       
    46 // C++ default constructor can NOT contain any code, that
       
    47 // might leave.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CAccSrvConnectionStatusHandler::CAccSrvConnectionStatusHandler()
       
    51     : CAccSrvHandlerBase ()
       
    52     {
       
    53     //Never called since only NewL(MAccSrvConnectionControllerObserver* aCallback) is defined
       
    54     TRACE_ASSERT_ALWAYS;
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CAccSrvConnectionStatusHandler::CAccSrvConnectionStatusHandler
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CAccSrvConnectionStatusHandler::CAccSrvConnectionStatusHandler(
       
    62     MAccSrvConnectionControllerObserver* aCallback )
       
    63     : CAccSrvHandlerBase (aCallback)
       
    64     {
       
    65     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::CAccSrvConnectionStatusHandler()" );
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CAccSrvConnectionStatusHandler::ConstructL
       
    70 // Symbian 2nd phase constructor can leave.
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 void CAccSrvConnectionStatusHandler::ConstructL()
       
    74     {
       
    75     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::ConstructL()" );
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CAccSrvConnectionStatusHandler::NewL
       
    80 // Two-phased constructor.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CAccSrvConnectionStatusHandler* CAccSrvConnectionStatusHandler::NewL( 
       
    84     MAccSrvConnectionControllerObserver* aCallback )
       
    85     {
       
    86     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::NewL()" );
       
    87     CAccSrvConnectionStatusHandler* self = 
       
    88         new( ELeave ) CAccSrvConnectionStatusHandler( aCallback );
       
    89 
       
    90     CleanupStack::PushL( self );
       
    91     self->ConstructL();
       
    92     CleanupStack::Pop( self );
       
    93     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::NewL - return self" );
       
    94     return self;
       
    95     }
       
    96 
       
    97 // Destructor
       
    98 CAccSrvConnectionStatusHandler::~CAccSrvConnectionStatusHandler()
       
    99     {
       
   100     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::~CAccSrvConnectionStatusHandler()" );
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CAccSrvConnectionStatusHandler::RunL
       
   105 //
       
   106 // Start Accessory Connection Status update by calling call-back of
       
   107 // Connection Controller. If RunL() leaves RunError from this class will be called.
       
   108 // (other items were commented in a header).
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CAccSrvConnectionStatusHandler::RunL()
       
   112     {
       
   113     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::RunL()" );
       
   114     iCallback->HandleConnectionStatusChangedL();
       
   115     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::RunL - return void" );
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CAccSrvConnectionStatusHandler::RunError
       
   120 //
       
   121 // Called if RunL Leaves
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 TInt CAccSrvConnectionStatusHandler::RunError( TInt aError )
       
   125     {
       
   126     COM_TRACE_1( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::RunError(%d)", aError );
       
   127 
       
   128 #ifdef _DEBUG
       
   129     TRAPD( errHandle, iCallback->HandleAccessoryModeChangedL() );
       
   130     COM_TRACE_1( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::RunError - errHandle == %d", errHandle );
       
   131 #else
       
   132     TRAP_IGNORE( iCallback->HandleAccessoryModeChangedL() );
       
   133 #endif
       
   134 
       
   135     // Avoid Panic in CActiveScheduler
       
   136     aError = KErrNone;
       
   137     COM_TRACE_( "[AccFW:AccServer] CAccSrvConnectionStatusHandler::RunError - return KErrNone" );
       
   138     return aError;
       
   139     }
       
   140 
       
   141 // End of File