|
1 /* |
|
2 * Copyright (c) 2005-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: |
|
15 * Class which implements handling Side Volume Key events (SVK). |
|
16 * This class implements methods of MRemConCoreApiTargetObserver |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <remconcoreapitarget.h> |
|
24 #include <remconcoreapitargetobserver.h> |
|
25 #include <remconinterfaceselector.h> |
|
26 #include <aknconsts.h> // KAknStandardKeyboardRepeatRate |
|
27 |
|
28 #include "UniMmsSvkEvents.h" |
|
29 |
|
30 |
|
31 // CONSTANTS |
|
32 const TInt KVolumeFirstChangePeriod = KAknStandardKeyboardRepeatRate; |
|
33 const TInt KVolumeChangePeriod = KAknStandardKeyboardRepeatRate; |
|
34 const TInt KVolumeChangeUp = 1; |
|
35 const TInt KVolumeChangeDown = -1; |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 // ---------------------------------------------------------------------------- |
|
40 // CMmsSvkEvents |
|
41 // ---------------------------------------------------------------------------- |
|
42 // |
|
43 CMmsSvkEvents* CMmsSvkEvents::NewL( MMmsSvkEventsObserver& aObserver ) |
|
44 { |
|
45 CMmsSvkEvents* self = |
|
46 new ( ELeave ) CMmsSvkEvents( aObserver ); |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop( self ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ---------------------------------------------------------------------------- |
|
54 // CMmsSvkEvents |
|
55 // ---------------------------------------------------------------------------- |
|
56 // |
|
57 CMmsSvkEvents::CMmsSvkEvents( MMmsSvkEventsObserver& aObserver ) : |
|
58 iObserver( aObserver ) |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // CMmsSvkEvents::~CMmsSvkEvents |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 CMmsSvkEvents::~CMmsSvkEvents() |
|
68 { |
|
69 if ( iVolumeTimer ) |
|
70 { |
|
71 iVolumeTimer->Cancel(); |
|
72 delete iVolumeTimer; |
|
73 } |
|
74 |
|
75 delete iInterfaceSelector; |
|
76 iCoreTarget = NULL; // For LINT. Owned by iInterfaceSelector |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // ConstructL |
|
81 // ---------------------------------------------------------------------------- |
|
82 // |
|
83 void CMmsSvkEvents::ConstructL( ) |
|
84 { |
|
85 iInterfaceSelector = CRemConInterfaceSelector::NewL(); |
|
86 |
|
87 // owned by iInterfaceSelector |
|
88 iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this ); |
|
89 |
|
90 iInterfaceSelector->OpenTargetL(); |
|
91 |
|
92 // Remote control server command repeat timer. |
|
93 iVolumeTimer = CPeriodic::NewL( EPriorityNormal ); |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // CMmsSvkEvents::MrccatoCommand |
|
98 // Handles side volume key events. |
|
99 // ---------------------------------------------------------------------------- |
|
100 // |
|
101 void CMmsSvkEvents::MrccatoCommand( TRemConCoreApiOperationId aOperationId, |
|
102 TRemConCoreApiButtonAction aButtonAct ) |
|
103 { |
|
104 TRequestStatus stat; |
|
105 switch ( aOperationId ) |
|
106 { |
|
107 case ERemConCoreApiVolumeUp: // Volume Up |
|
108 { |
|
109 switch ( aButtonAct ) |
|
110 { |
|
111 case ERemConCoreApiButtonPress: |
|
112 { |
|
113 // Volume up hold down for 0,6 seconds |
|
114 DoChangeVolume( ); |
|
115 iVolumeTimer->Cancel(); |
|
116 iVolumeTimer->Start( KVolumeFirstChangePeriod, |
|
117 KVolumeChangePeriod, |
|
118 TCallBack( ChangeVolume, this ) ); |
|
119 break; |
|
120 } |
|
121 case ERemConCoreApiButtonRelease: |
|
122 { |
|
123 iVolumeTimer->Cancel(); |
|
124 break; |
|
125 } |
|
126 case ERemConCoreApiButtonClick: |
|
127 { |
|
128 // Volume up clicked |
|
129 iChange = KVolumeChangeUp; |
|
130 DoChangeVolume( ); |
|
131 break; |
|
132 } |
|
133 default: |
|
134 { |
|
135 // Never hits this |
|
136 break; |
|
137 } |
|
138 } |
|
139 iCoreTarget->VolumeUpResponse(stat, KErrNone); |
|
140 break; |
|
141 } |
|
142 case ERemConCoreApiVolumeDown: // Volume Down |
|
143 { |
|
144 switch ( aButtonAct ) |
|
145 { |
|
146 case ERemConCoreApiButtonPress: |
|
147 { |
|
148 // Volume down hold for 0,6 seconds |
|
149 DoChangeVolume( ); |
|
150 iVolumeTimer->Cancel(); |
|
151 iVolumeTimer->Start( KVolumeFirstChangePeriod, |
|
152 KVolumeChangePeriod, |
|
153 TCallBack( ChangeVolume, this ) ); |
|
154 break; |
|
155 } |
|
156 case ERemConCoreApiButtonRelease: |
|
157 { |
|
158 iVolumeTimer->Cancel(); |
|
159 break; |
|
160 } |
|
161 case ERemConCoreApiButtonClick: |
|
162 { |
|
163 // Volume down clicked |
|
164 iChange = KVolumeChangeDown; |
|
165 DoChangeVolume( ); |
|
166 break; |
|
167 } |
|
168 default: |
|
169 { |
|
170 // Never hits this |
|
171 break; |
|
172 } |
|
173 } |
|
174 iCoreTarget->VolumeDownResponse(stat, KErrNone); |
|
175 break; |
|
176 } |
|
177 default : |
|
178 { |
|
179 iCoreTarget->SendResponse( stat, aOperationId, KErrNone ); |
|
180 break; |
|
181 } |
|
182 } |
|
183 |
|
184 User::WaitForRequest( stat ); |
|
185 } |
|
186 |
|
187 // ---------------------------------------------------------------------------- |
|
188 // ChangeVolumeL |
|
189 // |
|
190 // ---------------------------------------------------------------------------- |
|
191 // |
|
192 void CMmsSvkEvents::DoChangeVolume( ) |
|
193 { |
|
194 TRAP_IGNORE( iObserver.MmsSvkChangeVolumeL( iChange ) ); |
|
195 } |
|
196 |
|
197 // ---------------------------------------------------------------------------- |
|
198 // ChangeVolume |
|
199 // |
|
200 // ---------------------------------------------------------------------------- |
|
201 // |
|
202 TInt CMmsSvkEvents::ChangeVolume( TAny* aObject ) |
|
203 { |
|
204 // cast, and call non-static function |
|
205 static_cast<CMmsSvkEvents*>( aObject )->DoChangeVolume( ); |
|
206 return KErrNone; |
|
207 } |
|
208 |
|
209 // End of File |