37
|
1 |
/*
|
|
2 |
* Copyright (c) 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: This module contains the implementation of CPEAccessoryModeMonitor class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "cpeaccessorymodemonitor.h"
|
|
22 |
#include <talogger.h>
|
|
23 |
|
|
24 |
// CONSTANTS
|
|
25 |
|
|
26 |
// FORWARD DECLARATIONS
|
|
27 |
|
|
28 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
29 |
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
// CPEAccessoryModeMonitor::CPEAccessoryModeMonitor
|
|
32 |
// C++ default constructor can NOT contain any code, that
|
|
33 |
// might leave.
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
CPEAccessoryModeMonitor::CPEAccessoryModeMonitor():
|
|
37 |
CActive( CActive::EPriorityStandard )
|
|
38 |
{
|
|
39 |
CActiveScheduler::Add( this );
|
|
40 |
}
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// CPEAccessoryModeMonitor::NewL
|
|
44 |
// Two-phased constructor.
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CPEAccessoryModeMonitor* CPEAccessoryModeMonitor::NewL()
|
|
48 |
{
|
|
49 |
CPEAccessoryModeMonitor* self =
|
|
50 |
new (ELeave) CPEAccessoryModeMonitor();
|
|
51 |
|
|
52 |
CleanupStack::PushL( self );
|
|
53 |
CleanupStack::Pop( self );
|
|
54 |
|
|
55 |
return self;
|
|
56 |
}
|
|
57 |
|
|
58 |
// Destructor
|
|
59 |
CPEAccessoryModeMonitor::~CPEAccessoryModeMonitor()
|
|
60 |
{
|
|
61 |
Cancel();
|
|
62 |
iMode.CloseSubSession();
|
|
63 |
iAccServer.Disconnect();
|
|
64 |
}
|
|
65 |
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
// CPEAccessoryModeMonitor::AccessoryServer
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
RAccessoryServer CPEAccessoryModeMonitor::AccessoryServer()
|
|
71 |
{
|
|
72 |
if ( !iAccConn )
|
|
73 |
{
|
|
74 |
TInt error = iAccServer.Connect();
|
|
75 |
if ( error == KErrNone )
|
|
76 |
{
|
|
77 |
iAccConn = ETrue;
|
|
78 |
}
|
|
79 |
}
|
|
80 |
return iAccServer;
|
|
81 |
}
|
|
82 |
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
// CPEAccessoryModeMonitor::AccessoryMode
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
TInt CPEAccessoryModeMonitor::AccessoryMode()
|
|
88 |
{
|
|
89 |
|
|
90 |
if ( !iAccSess )
|
|
91 |
{
|
|
92 |
if ( !iAccConn )
|
|
93 |
{
|
|
94 |
AccessoryServer();
|
|
95 |
}
|
|
96 |
if ( iAccConn )
|
|
97 |
{
|
|
98 |
TInt error = iMode.CreateSubSession( iAccServer );
|
|
99 |
if ( error == KErrNone )
|
|
100 |
{
|
|
101 |
iAccSess = ETrue;
|
|
102 |
}
|
|
103 |
}
|
|
104 |
}
|
|
105 |
if ( iAccSess && !IsActive() )
|
|
106 |
{
|
|
107 |
iMode.GetAccessoryMode( iPolAccessoryMode );
|
|
108 |
iAccessoryMode = iPolAccessoryMode.iAccessoryMode;
|
|
109 |
iAudioOutputStatus = iPolAccessoryMode.iAudioOutputStatus;
|
|
110 |
Start();
|
|
111 |
}
|
|
112 |
TEFLOGSTRING2( KTAINT,
|
|
113 |
"CPEAccessoryModeMonitor.AccessoryMode< Mode: %d ", iAccessoryMode );
|
|
114 |
return iAccessoryMode;
|
|
115 |
}
|
|
116 |
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
// CPEAccessoryModeMonitor::Status
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
|
|
122 |
TBool CPEAccessoryModeMonitor::Status()
|
|
123 |
{
|
|
124 |
if ( !iAccSess )
|
|
125 |
{
|
|
126 |
AccessoryMode();
|
|
127 |
}
|
|
128 |
return iAudioOutputStatus;
|
|
129 |
}
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
// CPEAccessoryModeMonitor::DoCancel
|
|
132 |
//
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
void CPEAccessoryModeMonitor::DoCancel()
|
|
136 |
{
|
|
137 |
iMode.CancelNotifyAccessoryModeChanged();
|
|
138 |
}
|
|
139 |
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
// CPEAccessoryModeMonitor::RunL
|
|
142 |
// Receives event on accessory mode change.
|
|
143 |
//
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void CPEAccessoryModeMonitor::RunL()
|
|
147 |
{
|
|
148 |
TEFLOGSTRING2(KTAINT, "CPEAccessoryModeMonitor::RunL %d", iStatus.Int() );
|
|
149 |
|
|
150 |
switch ( iStatus.Int() )
|
|
151 |
{
|
|
152 |
case KErrNone:
|
|
153 |
{
|
|
154 |
iAccessoryMode = iPolAccessoryMode.iAccessoryMode;
|
|
155 |
iAudioOutputStatus = iPolAccessoryMode.iAudioOutputStatus;
|
|
156 |
// Issue request again if needed.
|
|
157 |
Start();
|
|
158 |
}
|
|
159 |
break;
|
|
160 |
case KErrCancel:
|
|
161 |
case KErrNotSupported:
|
|
162 |
break;
|
|
163 |
default:
|
|
164 |
// Issue request again if needed.
|
|
165 |
Start();
|
|
166 |
break;
|
|
167 |
}
|
|
168 |
}
|
|
169 |
|
|
170 |
|
|
171 |
// -----------------------------------------------------------------------------
|
|
172 |
// CPEAccessoryModeMonitor::Start
|
|
173 |
//
|
|
174 |
//
|
|
175 |
// -----------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
void CPEAccessoryModeMonitor::Start()
|
|
178 |
{
|
|
179 |
TEFLOGSTRING(KTAINT, "CPEAccessoryModeMonitor::Start" );
|
|
180 |
if ( !IsActive() )
|
|
181 |
{
|
|
182 |
iMode.NotifyAccessoryModeChanged( iStatus, iPolAccessoryMode );
|
|
183 |
SetActive();
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
// End of File
|