34
|
1 |
/*
|
57
|
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 |
*/
|
34
|
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 |
void CRadioAccessoryObserver::ConstructL()
|
|
39 |
{
|
|
40 |
LOG_METHOD_AUTO;
|
|
41 |
// Open chunk for test configuration/control data
|
|
42 |
TInt err = iRadioStubManagerChunk.OpenGlobal(
|
57
|
43 |
KRadioStubManagerLocalChunkName, EFalse, // == Read | Write
|
|
44 |
EOwnerThread);
|
|
45 |
User::LeaveIfError(err);
|
|
46 |
if (sizeof(SRadioStubManager) > iRadioStubManagerChunk.MaxSize())
|
34
|
47 |
{
|
57
|
48 |
User::Leave(KErrTooBig);
|
34
|
49 |
}
|
|
50 |
TUint8* basePtr = iRadioStubManagerChunk.Base();
|
57
|
51 |
User::LeaveIfNull(basePtr);
|
|
52 |
iRadioStubManager = (SRadioStubManager*) basePtr;
|
|
53 |
if (STUB.iLeaveNewL.iError)
|
|
54 |
{
|
|
55 |
User::Leave(STUB.iLeaveNewL.iError);
|
|
56 |
}
|
|
57 |
if (STUB.iLeaveConstructL.iError)
|
34
|
58 |
{
|
57
|
59 |
User::Leave(STUB.iLeaveConstructL.iError);
|
34
|
60 |
}
|
57
|
61 |
iHeadsetObserver = CRadioPropertyObserver::NewL(*this, KStub_KRadioPSUid,
|
|
62 |
SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected,
|
|
63 |
CRadioPropertyObserver::ERadioPropertyInt);
|
|
64 |
iHeadsetObserver->ActivateL();
|
|
65 |
STUB.iHeadsetConnected = iHeadsetObserver->ValueInt();
|
34
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CRadioAccessoryObserver* CRadioAccessoryObserver::NewL()
|
|
73 |
{
|
|
74 |
LOG_METHOD_AUTO;
|
57
|
75 |
CRadioAccessoryObserver* self = new (ELeave) CRadioAccessoryObserver;
|
|
76 |
CleanupStack::PushL(self);
|
34
|
77 |
self->ConstructL();
|
57
|
78 |
CleanupStack::Pop(self);
|
34
|
79 |
return self;
|
|
80 |
}
|
|
81 |
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
CRadioAccessoryObserver::~CRadioAccessoryObserver()
|
|
87 |
{
|
|
88 |
LOG_METHOD_AUTO;
|
57
|
89 |
delete iHeadsetObserver;
|
34
|
90 |
iRadioStubManagerChunk.Close();
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
TBool CRadioAccessoryObserver::IsHeadsetConnectedL() const
|
|
98 |
{
|
|
99 |
LOG_METHOD_AUTO;
|
57
|
100 |
if (STUB.iLeaveIsHeadsetConnectedL.iError)
|
34
|
101 |
{
|
57
|
102 |
User::Leave(STUB.iLeaveIsHeadsetConnectedL.iError);
|
34
|
103 |
}
|
|
104 |
return STUB.iHeadsetConnected;
|
|
105 |
}
|
|
106 |
|
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
//
|
57
|
111 |
void CRadioAccessoryObserver::SetObserver(
|
|
112 |
MRadioHeadsetEventObserver* aObserver)
|
34
|
113 |
{
|
|
114 |
LOG_METHOD_AUTO;
|
|
115 |
STUB.iObserver = aObserver;
|
|
116 |
}
|
|
117 |
|
57
|
118 |
// ---------------------------------------------------------------------------
|
|
119 |
// Handling of the int property changes is done here.
|
|
120 |
// Observer components are getting notifications in correspondence with what
|
|
121 |
// has changed
|
|
122 |
// ---------------------------------------------------------------------------
|
|
123 |
//
|
|
124 |
void CRadioAccessoryObserver::HandlePropertyChangeL(const TUid& aCategory,
|
|
125 |
const TUint aKey, const TInt aValue)
|
|
126 |
{
|
|
127 |
LEVEL2( LOG_METHOD_AUTO );
|
|
128 |
if ((KStub_KRadioPSUid == aCategory)
|
|
129 |
&& (SRadioStubManager::EStub_KRadioTestPSKeyHeadsetConnected
|
|
130 |
== aKey))
|
|
131 |
{
|
|
132 |
STUB.iHeadsetConnected = aValue;
|
|
133 |
if (STUB.iHeadsetConnected)
|
|
134 |
{
|
|
135 |
if ( STUB.iObserver )
|
|
136 |
{
|
|
137 |
STUB.iObserver->HeadsetConnectedCallbackL();
|
|
138 |
}
|
|
139 |
}
|
|
140 |
else
|
|
141 |
{
|
|
142 |
if ( STUB.iObserver )
|
|
143 |
{
|
|
144 |
STUB.iObserver->HeadsetDisconnectedCallbackL();
|
|
145 |
}
|
|
146 |
}
|
|
147 |
}
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// Dummy version for WINS in order to avoid compiler warnings.
|
|
152 |
// The real implementation of function is above.
|
|
153 |
// ---------------------------------------------------------------------------
|
|
154 |
//
|
|
155 |
void CRadioAccessoryObserver::HandlePropertyChangeL(
|
|
156 |
const TUid& /*aCategory*/, const TUint /*aKey*/, const TDesC8& /*aValue*/)
|
|
157 |
{
|
|
158 |
LOG_METHOD_AUTO;
|
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
// Handling of the text property changes is done here.
|
|
163 |
// Observer components are getting notifications in correspondence with what
|
|
164 |
// has changed
|
|
165 |
// ---------------------------------------------------------------------------
|
|
166 |
//
|
|
167 |
void CRadioAccessoryObserver::HandlePropertyChangeL(
|
|
168 |
const TUid& /*aCategory*/, const TUint /*aKey*/, const TDesC& /*aValue*/)
|
|
169 |
{
|
|
170 |
LOG_METHOD_AUTO;
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
// This is a callback function which is called when a P&S components returns
|
|
175 |
// an error
|
|
176 |
// ---------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
void CRadioAccessoryObserver::HandlePropertyChangeErrorL(
|
|
179 |
const TUid& DEBUGVAR(aCategory), const TUint DEBUGVAR(aKey), TInt DEBUGVAR(aError) )
|
|
180 |
{
|
|
181 |
LOG_METHOD_AUTO;
|
|
182 |
LOG_FORMAT( "aCategory = %i, aKey = %i, aError = %i", aCategory, aKey, aError );
|
|
183 |
}
|