radioengine/utils/stub/src/cradioaccessoryobserver_stub.cpp
author hgs
Mon, 23 Aug 2010 14:17:50 +0300
changeset 44 0a3ad94fc71c
parent 34 bc10a61bd7d3
child 57 21be958eb3ce
permissions -rw-r--r--
201033
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include "cradioenginelogger.h"
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include "cradioaccessoryobserver_stub.h"
hgs
parents:
diff changeset
    21
#include "mradioheadseteventobserver.h"
hgs
parents:
diff changeset
    22
hgs
parents:
diff changeset
    23
#define STUB  iRadioStubManager->iAccessoryObserver
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    26
//
hgs
parents:
diff changeset
    27
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    28
//
hgs
parents:
diff changeset
    29
CRadioAccessoryObserver::CRadioAccessoryObserver()
hgs
parents:
diff changeset
    30
    {
hgs
parents:
diff changeset
    31
    LOG_METHOD_AUTO;
hgs
parents:
diff changeset
    32
    }
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    36
//
hgs
parents:
diff changeset
    37
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    38
//
hgs
parents:
diff changeset
    39
void CRadioAccessoryObserver::ConstructL()
hgs
parents:
diff changeset
    40
    {
hgs
parents:
diff changeset
    41
    LOG_METHOD_AUTO;
hgs
parents:
diff changeset
    42
    // Open chunk for test configuration/control data
hgs
parents:
diff changeset
    43
    TInt err = iRadioStubManagerChunk.OpenGlobal(
hgs
parents:
diff changeset
    44
            KRadioStubManagerLocalChunkName,
hgs
parents:
diff changeset
    45
            EFalse, // == Read | Write
hgs
parents:
diff changeset
    46
            EOwnerThread );
hgs
parents:
diff changeset
    47
    User::LeaveIfError( err );
hgs
parents:
diff changeset
    48
    if ( sizeof(SRadioStubManager) > iRadioStubManagerChunk.MaxSize() )
hgs
parents:
diff changeset
    49
        {
hgs
parents:
diff changeset
    50
        User::Leave( KErrTooBig );
hgs
parents:
diff changeset
    51
        }
hgs
parents:
diff changeset
    52
    TUint8* basePtr = iRadioStubManagerChunk.Base();
hgs
parents:
diff changeset
    53
    User::LeaveIfNull( basePtr );    
hgs
parents:
diff changeset
    54
    iRadioStubManager = (SRadioStubManager*)basePtr;
hgs
parents:
diff changeset
    55
    if ( STUB.iLeaveNewL.iError )
hgs
parents:
diff changeset
    56
        {
hgs
parents:
diff changeset
    57
        User::Leave( STUB.iLeaveNewL.iError );
hgs
parents:
diff changeset
    58
        }
hgs
parents:
diff changeset
    59
    if ( STUB.iLeaveConstructL.iError )
hgs
parents:
diff changeset
    60
        {
hgs
parents:
diff changeset
    61
        User::Leave( STUB.iLeaveConstructL.iError );
hgs
parents:
diff changeset
    62
        }
hgs
parents:
diff changeset
    63
    }
hgs
parents:
diff changeset
    64
hgs
parents:
diff changeset
    65
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    66
//
hgs
parents:
diff changeset
    67
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    68
//
hgs
parents:
diff changeset
    69
CRadioAccessoryObserver* CRadioAccessoryObserver::NewL()
hgs
parents:
diff changeset
    70
    {
hgs
parents:
diff changeset
    71
    LOG_METHOD_AUTO;
hgs
parents:
diff changeset
    72
    CRadioAccessoryObserver* self = new( ELeave ) CRadioAccessoryObserver;
hgs
parents:
diff changeset
    73
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
    74
    self->ConstructL();
hgs
parents:
diff changeset
    75
    CleanupStack::Pop( self );
hgs
parents:
diff changeset
    76
    return self;
hgs
parents:
diff changeset
    77
    }
hgs
parents:
diff changeset
    78
hgs
parents:
diff changeset
    79
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    80
//
hgs
parents:
diff changeset
    81
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    82
//
hgs
parents:
diff changeset
    83
CRadioAccessoryObserver::~CRadioAccessoryObserver()
hgs
parents:
diff changeset
    84
    {
hgs
parents:
diff changeset
    85
    LOG_METHOD_AUTO;
hgs
parents:
diff changeset
    86
    iRadioStubManagerChunk.Close();
hgs
parents:
diff changeset
    87
    }
hgs
parents:
diff changeset
    88
hgs
parents:
diff changeset
    89
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    90
//
hgs
parents:
diff changeset
    91
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
    92
//
hgs
parents:
diff changeset
    93
TBool CRadioAccessoryObserver::IsHeadsetConnectedL() const
hgs
parents:
diff changeset
    94
    {
hgs
parents:
diff changeset
    95
    LOG_METHOD_AUTO;
hgs
parents:
diff changeset
    96
    if ( STUB.iLeaveIsHeadsetConnectedL.iError )
hgs
parents:
diff changeset
    97
        {
hgs
parents:
diff changeset
    98
        User::Leave( STUB.iLeaveIsHeadsetConnectedL.iError );
hgs
parents:
diff changeset
    99
        }
hgs
parents:
diff changeset
   100
    return STUB.iHeadsetConnected;
hgs
parents:
diff changeset
   101
    }
hgs
parents:
diff changeset
   102
hgs
parents:
diff changeset
   103
hgs
parents:
diff changeset
   104
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   105
//
hgs
parents:
diff changeset
   106
// ---------------------------------------------------------------------------
hgs
parents:
diff changeset
   107
//
hgs
parents:
diff changeset
   108
void CRadioAccessoryObserver::SetObserver( MRadioHeadsetEventObserver* aObserver )
hgs
parents:
diff changeset
   109
    {
hgs
parents:
diff changeset
   110
    LOG_METHOD_AUTO;
hgs
parents:
diff changeset
   111
    STUB.iObserver = aObserver;
hgs
parents:
diff changeset
   112
    }
hgs
parents:
diff changeset
   113