radioengine/utils/stub/src/cradioaccessoryobserver_stub.cpp
branchRCL_3
changeset 20 93c594350b9a
parent 19 cce62ebc198e
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
     1 /*
       
     2 * Copyright (c) 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cradioenginelogger.h"
       
    19 
       
    20 #include "cradioaccessoryobserver_stub.h"
       
    21 #include "mradioheadseteventobserver.h"
       
    22 
       
    23 #define STUB  iRadioStubManager->iAccessoryObserver
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 CRadioAccessoryObserver::CRadioAccessoryObserver()
       
    30     {
       
    31     LOG_METHOD_AUTO;
       
    32     }
       
    33 
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 void CRadioAccessoryObserver::ConstructL()
       
    40     {
       
    41     LOG_METHOD_AUTO;
       
    42     // Open chunk for test configuration/control data
       
    43     TInt err = iRadioStubManagerChunk.OpenGlobal(
       
    44             KRadioStubManagerLocalChunkName,
       
    45             EFalse, // == Read | Write
       
    46             EOwnerThread );
       
    47     User::LeaveIfError( err );
       
    48     if ( sizeof(SRadioStubManager) > iRadioStubManagerChunk.MaxSize() )
       
    49         {
       
    50         User::Leave( KErrTooBig );
       
    51         }
       
    52     TUint8* basePtr = iRadioStubManagerChunk.Base();
       
    53     User::LeaveIfNull( basePtr );    
       
    54     iRadioStubManager = (SRadioStubManager*)basePtr;
       
    55     if ( STUB.iLeaveNewL.iError )
       
    56         {
       
    57         User::Leave( STUB.iLeaveNewL.iError );
       
    58         }
       
    59     if ( STUB.iLeaveConstructL.iError )
       
    60         {
       
    61         User::Leave( STUB.iLeaveConstructL.iError );
       
    62         }
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CRadioAccessoryObserver* CRadioAccessoryObserver::NewL()
       
    70     {
       
    71     LOG_METHOD_AUTO;
       
    72     CRadioAccessoryObserver* self = new( ELeave ) CRadioAccessoryObserver;
       
    73     CleanupStack::PushL( self );
       
    74     self->ConstructL();
       
    75     CleanupStack::Pop( self );
       
    76     return self;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 CRadioAccessoryObserver::~CRadioAccessoryObserver()
       
    84     {
       
    85     LOG_METHOD_AUTO;
       
    86     iRadioStubManagerChunk.Close();
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 TBool CRadioAccessoryObserver::IsHeadsetConnectedL() const
       
    94     {
       
    95     LOG_METHOD_AUTO;
       
    96     if ( STUB.iLeaveIsHeadsetConnectedL.iError )
       
    97         {
       
    98         User::Leave( STUB.iLeaveIsHeadsetConnectedL.iError );
       
    99         }
       
   100     return STUB.iHeadsetConnected;
       
   101     }
       
   102 
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CRadioAccessoryObserver::SetObserver( MRadioHeadsetEventObserver* aObserver )
       
   109     {
       
   110     LOG_METHOD_AUTO;
       
   111     STUB.iObserver = aObserver;
       
   112     }
       
   113