|
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: DOS Server Monitor Class is used to monitor Audio Accessorries, |
|
15 * and encapsulate the interfaces with DOS Server. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include "voiceprogressdialog.h" |
|
23 #include "playbackvoicecommanddialog.h" |
|
24 #include "headsetbuttonmonitor.h" |
|
25 |
|
26 #include "rubydebug.h" |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CHeadsetButtonMonitor::CVoiceTagHeadsetButtonMonitor |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CHeadsetButtonMonitor::CHeadsetButtonMonitor() |
|
35 { |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CHeadsetButtonMonitor::~CHeadsetButtonMonitor |
|
40 // Destructor |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CHeadsetButtonMonitor::~CHeadsetButtonMonitor() |
|
44 { |
|
45 |
|
46 // Cancel the outstanding listening |
|
47 CancelMonitor(); |
|
48 |
|
49 // Close the connection to Dos Server |
|
50 iDosServerSession.Close(); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CHeadsetButtonMonitor::ConstructL |
|
55 // Two-phased constructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CHeadsetButtonMonitor::ConstructL() |
|
59 { |
|
60 RUBY_DEBUG_BLOCKL( "CHeadsetButtonMonitor::ConstructL" ); |
|
61 |
|
62 User::LeaveIfError( iDosServerSession.Connect() ); |
|
63 } |
|
64 |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CHeadsetButtonMonitor::NewLC |
|
68 // Two-phased constructor. |
|
69 // This is for new CVoiceTagHeadsetButtonMonitor |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CHeadsetButtonMonitor* CHeadsetButtonMonitor::NewLC() |
|
73 { |
|
74 RUBY_DEBUG_BLOCKL( "CHeadsetButtonMonitor::NewLC" ); |
|
75 |
|
76 CHeadsetButtonMonitor* self = new ( ELeave ) CHeadsetButtonMonitor(); |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 return self; |
|
80 } |
|
81 |
|
82 |
|
83 /// ----------------------------------------------------------------------------- |
|
84 // HeadsetButtonMonitor::NewL |
|
85 // Two-phased constructor. |
|
86 // This is for a new DosServer Monitor |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 CHeadsetButtonMonitor* CHeadsetButtonMonitor::NewL() |
|
90 { |
|
91 RUBY_DEBUG_BLOCKL( "CHeadsetButtonMonitor::NewL" ); |
|
92 |
|
93 CHeadsetButtonMonitor* self = NewLC(); |
|
94 CleanupStack::Pop(); |
|
95 return self; |
|
96 } |
|
97 |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CHeadsetButtonMonitor::RegisterForMonitor |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 TInt CHeadsetButtonMonitor::ActivateMonitorL() |
|
104 { |
|
105 RUBY_DEBUG_BLOCKL( "CHeadsetButtonMonitor::ActivateMonitorL" ); |
|
106 |
|
107 // send Dos Server the new listening list |
|
108 StartListeningL( KHeadsetButtonChanged, sizeof( EPSButtonState ), EOnlyLast ); |
|
109 |
|
110 return KErrNone; |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CHeadsetButtonMonitor::DeregisterForMonitor |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 TInt CHeadsetButtonMonitor::DeActivateMonitor() |
|
119 { |
|
120 // No more registered event. Stop the event listening |
|
121 Stop(); |
|
122 return KErrNone; |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CHeadsetButtonMonitor::CancelMonitor |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CHeadsetButtonMonitor::CancelMonitor() |
|
130 { |
|
131 // Stop the event listening |
|
132 Stop(); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CHeadsetButtonMonitor::HeadsetButtonChangedL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CHeadsetButtonMonitor::HeadsetButtonChangedL( EPSButtonState /*aState*/ ) |
|
140 { |
|
141 // Nothing |
|
142 } |
|
143 |
|
144 // ---------------------------------------------------------------------------- |
|
145 // CHeadsetButtonMonitor::HandleButtonDown |
|
146 // ---------------------------------------------------------------------------- |
|
147 // |
|
148 void CHeadsetButtonMonitor::HandleButtonDown() |
|
149 { |
|
150 iButtonDown = ETrue; |
|
151 } |
|
152 |
|
153 // ---------------------------------------------------------------------------- |
|
154 // CHeadsetButtonMonitor::HandleButtonUp |
|
155 // ---------------------------------------------------------------------------- |
|
156 // |
|
157 void CHeadsetButtonMonitor::HandleButtonUp() |
|
158 { |
|
159 // Check iObserver for safety, also made sure we received a button down |
|
160 if( ( iPlaybackObserver ) && ( iButtonDown ) ) |
|
161 { |
|
162 CancelMonitor(); // Stop the monitoring |
|
163 iPlaybackObserver->HandleShortKeypress(); |
|
164 } |
|
165 else if ( ( iProgressObserver ) && ( iButtonDown ) ) |
|
166 { |
|
167 CancelMonitor(); // Stop the monitoring |
|
168 iProgressObserver->HandleShortKeypress(); |
|
169 } |
|
170 |
|
171 iButtonDown = EFalse; |
|
172 } |
|
173 |
|
174 |
|
175 // ---------------------------------------------------------------------------- |
|
176 // CHeadsetButtonMonitor::HandleButtonDownLong |
|
177 // ---------------------------------------------------------------------------- |
|
178 // |
|
179 void CHeadsetButtonMonitor::HandleButtonDownLong() |
|
180 { |
|
181 // Check iObserver for safety, also made sure we received a button down |
|
182 if ( ( iPlaybackObserver ) && ( iButtonDown ) ) |
|
183 { |
|
184 CancelMonitor(); // stop the monitoring |
|
185 iPlaybackObserver->HandleLongKeypress(); |
|
186 } |
|
187 else if ( ( iProgressObserver ) && ( iButtonDown ) ) |
|
188 { |
|
189 CancelMonitor(); // stop the monitoring |
|
190 iProgressObserver->HandleLongKeypress(); |
|
191 } |
|
192 |
|
193 iButtonDown = EFalse; |
|
194 } |
|
195 |
|
196 |
|
197 // ---------------------------------------------------------------------------- |
|
198 // CHeadsetButtonMonitor::Register |
|
199 // ---------------------------------------------------------------------------- |
|
200 // |
|
201 void CHeadsetButtonMonitor::Register( CVoiceProgressDialog* aProgressObserver, |
|
202 CPlaybackVoiceCommandDialog* aPlaybackObserver ) |
|
203 { |
|
204 if ( aProgressObserver ) |
|
205 { |
|
206 iProgressObserver = aProgressObserver; |
|
207 } |
|
208 if ( aPlaybackObserver ) |
|
209 { |
|
210 iPlaybackObserver = aPlaybackObserver; |
|
211 } |
|
212 } |
|
213 |
|
214 // ---------------------------------------------------------------------------- |
|
215 // CHeadsetButtonMonitor::DeRegister |
|
216 // ---------------------------------------------------------------------------- |
|
217 // |
|
218 void CHeadsetButtonMonitor::DeRegister( CVoiceProgressDialog* /*aProgressObserver*/, |
|
219 CPlaybackVoiceCommandDialog* /*aPlaybackObserver*/ ) |
|
220 { |
|
221 iProgressObserver = NULL; |
|
222 iPlaybackObserver = NULL; |
|
223 } |
|
224 |
|
225 |
|
226 // End of File |