|
1 /* |
|
2 * Copyright (c) 2002-2007 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: EikSrv keysound server. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __EIKKEYSOUNDSERVER_H__ |
|
19 #define __EIKKEYSOUNDSERVER_H__ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <mdaaudiosampleplayer.h> |
|
23 #include <mdaaudiotoneplayer.h> |
|
24 #include <mdaaudiosampleeditor.h> |
|
25 #include "eikkeysoundmap.h" |
|
26 #include "eikkeysound.h" |
|
27 #include <coecntrl.h> |
|
28 #include <cenrepnotifyhandler.h> |
|
29 #include "EikSrvUiConfig.hrh" |
|
30 |
|
31 #include <ataudioeventapi.h> |
|
32 #include <mateventcompleteobserver.h> |
|
33 |
|
34 class CATAudioEventAPI; |
|
35 class CEikSoundInfo; |
|
36 class CAknToneSoundInfo; |
|
37 class CAknFileSoundInfo; |
|
38 class CAknSequenceSoundInfo; |
|
39 class TAknSoundID; |
|
40 class CAknEikAudioToneObserver; |
|
41 |
|
42 // For debugging purposes. Traces for EikKeySoundServer are enabled or disabled. |
|
43 #if defined(_DEBUG) && defined(EIKKSS_ENABLE_TRACES) |
|
44 #define LOGTEXT(AAA) RDebug::Print(AAA) |
|
45 #define LOGTEXT1(AAA,BBB) RDebug::Print(AAA,BBB) |
|
46 #define LOGTEXT2(AAA,BBB,CCC) RDebug::Print(AAA,BBB,CCC) |
|
47 #define LOGTEXT3(AAA,BBB,CCC,DDD) RDebug::Print(AAA,BBB,CCC,DDD) |
|
48 #else |
|
49 #define LOGTEXT(AAA) |
|
50 #define LOGTEXT1(AAA,BBB) |
|
51 #define LOGTEXT2(AAA,BBB,CCC) |
|
52 #define LOGTEXT3(AAA,BBB,CCC,DDD) |
|
53 #endif |
|
54 |
|
55 // Anim Dll capture control. |
|
56 class CAknAnimKeySoundControl : public CCoeControl |
|
57 { |
|
58 public: |
|
59 CAknAnimKeySoundControl(); |
|
60 void ConstructL(RWindowGroup* aParent); |
|
61 }; |
|
62 |
|
63 |
|
64 // Anim Dll Interface. |
|
65 NONSHARABLE_CLASS(RAknAnimKeySound) : public RAnim |
|
66 { |
|
67 public: |
|
68 RAknAnimKeySound(RAnimDll &aAnimDll); |
|
69 void ConstructL(RWindowGroup* aParent); |
|
70 void Close(); |
|
71 private: |
|
72 CAknAnimKeySoundControl* iKeySoundControl; |
|
73 }; |
|
74 |
|
75 |
|
76 // Storage for a single sound. Base class. |
|
77 NONSHARABLE_CLASS(CEikSoundInfo) : public CBase |
|
78 { |
|
79 public: |
|
80 enum TVolumeSetting |
|
81 { |
|
82 EKeypadVolumeOff = 0, |
|
83 EKeypadVolumeQuiet, |
|
84 EKeypadVolumeMedium, |
|
85 EKeypadVolumeLoud, |
|
86 ESoundVolume0 = EKeypadVolumeOff, |
|
87 ESoundVolume1 = EKeypadVolumeOff + 1, |
|
88 ESoundVolume2 = EKeypadVolumeOff + 2, |
|
89 ESoundVolume3 = EKeypadVolumeOff + 3, |
|
90 ESoundVolume4 = EKeypadVolumeOff + 4, |
|
91 ESoundVolume5 = EKeypadVolumeOff + 5, |
|
92 ESoundVolume6 = EKeypadVolumeOff + 6, |
|
93 ESoundVolume7 = EKeypadVolumeOff + 7, |
|
94 ESoundVolume8 = EKeypadVolumeOff + 8, |
|
95 ESoundVolume9 = EKeypadVolumeOff + 9 |
|
96 }; |
|
97 public: |
|
98 CEikSoundInfo(TInt aPriority, TInt aPreference); |
|
99 virtual ~CEikSoundInfo(); |
|
100 virtual void PlayL() = 0; |
|
101 virtual void Stop() = 0; |
|
102 virtual void SetVolume(TVolumeSetting aVolume) = 0; |
|
103 TInt Preference(); |
|
104 TVolumeSetting Volume(); |
|
105 virtual void DoPlay() = 0; |
|
106 protected: |
|
107 TInt iPriority; |
|
108 TInt iPreference; |
|
109 TVolumeSetting iVolume; |
|
110 }; |
|
111 |
|
112 |
|
113 // Key sound server |
|
114 NONSHARABLE_CLASS(CEikKeySoundServer) : |
|
115 public CServer2, |
|
116 public MCenRepNotifyHandlerCallback, |
|
117 public MATEventCompleteObserver |
|
118 { |
|
119 public: |
|
120 static TInt LaunchServer(TThreadId& aThreadId); |
|
121 static CEikKeySoundServer* NewLC(); |
|
122 ~CEikKeySoundServer(); |
|
123 |
|
124 // Methods called from session |
|
125 void InitL(const RMessage2& aMessage); |
|
126 void PlaySid(TInt aSid, TBool aPlaySelf); |
|
127 void StopSid(TInt aSid); |
|
128 void SetVolumeForPreferenceType(TInt aPreference, CEikSoundInfo::TVolumeSetting aVolume); |
|
129 |
|
130 void SetDisabledScanCode( TInt aScanCode ); |
|
131 TInt DisabledScanCode(); |
|
132 |
|
133 // From MCenRepNotifyHandlerCallback |
|
134 void HandleNotifyInt(TUint32 aId, TInt aNewValue); |
|
135 |
|
136 inline TBool ContextLocked() |
|
137 { |
|
138 return iContextLocked; |
|
139 } |
|
140 inline void SetContextLocked(TBool aLock) |
|
141 { |
|
142 iContextLocked = aLock; |
|
143 } |
|
144 |
|
145 //Method for AT Audio Server callback |
|
146 void Complete( TInt aError, TAudioThemeEvent aEvent); |
|
147 private: |
|
148 CEikKeySoundServer(); |
|
149 void ConstructL(); |
|
150 // from CServer2 |
|
151 virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
152 |
|
153 public: |
|
154 TBool iInit; |
|
155 CArrayPtrFlat<CEikSoundInfo>* iSoundList; |
|
156 CArrayFixFlat<TAknSoundID>* iSidList; |
|
157 CEikKeySoundMap* iDefaultSoundMap; |
|
158 CEikKeySoundStack* iCurrentSoundStack; |
|
159 CEikSoundInfo::TVolumeSetting iKeypadVolume; |
|
160 CCenRepNotifyHandler* iProfilesNotifyHandler; |
|
161 CRepository* iProfilesRepository; |
|
162 TBool iContextLocked; |
|
163 |
|
164 TInt iDisabledScanCode; |
|
165 |
|
166 CCenRepNotifyHandler *iWarningToneEnableHandler; |
|
167 TInt iWarningToneEnabled; |
|
168 |
|
169 CATAudioEventAPI* iATSoundServerAPI; |
|
170 }; |
|
171 |
|
172 |
|
173 // Key sound session |
|
174 NONSHARABLE_CLASS(CEikKeySoundSession) : public CSession2 |
|
175 { |
|
176 public: |
|
177 static CEikKeySoundSession* NewL(CEikKeySoundServer* aServer); |
|
178 ~CEikKeySoundSession(); |
|
179 void DispatchMessageL(const RMessage2& aMessage); |
|
180 // from CShareableSession |
|
181 virtual void ServiceL(const RMessage2& aMessage); |
|
182 private: |
|
183 CEikKeySoundSession(CEikKeySoundServer* aServer); |
|
184 void ConstructL(); |
|
185 void AddSoundIdBufferL(const RMessage2& aMessage); |
|
186 void RemoveSids(TInt aUid); |
|
187 void AddToneSidL(const TAknSoundID& aSoundID, CAknToneSoundInfo* aSoundInfo); |
|
188 void AddFileSidL(const TAknSoundID& aSoundID, CAknFileSoundInfo* aSoundInfo, |
|
189 const TDesC& aFileName); |
|
190 void AddSequenceSidL(const TAknSoundID& aSoundID, CAknSequenceSoundInfo* aSoundInfo); |
|
191 void PushContextL(const RMessage2& aMessage); |
|
192 void PopContext(); |
|
193 private: |
|
194 CEikKeySoundServer* iServer; |
|
195 CEikKeySoundStack* iSoundStack; |
|
196 TInt iClientUid; |
|
197 TBool iOwnsDefaultSounds; |
|
198 TBool iHasLockedContext; |
|
199 }; |
|
200 |
|
201 |
|
202 // Specialized base class for synthetized sounds (tones and sequences). |
|
203 NONSHARABLE_CLASS(CAknSynthSoundInfo) : public CEikSoundInfo |
|
204 { |
|
205 public: |
|
206 CAknSynthSoundInfo(TInt aPriority, TInt aPreference); |
|
207 virtual ~CAknSynthSoundInfo(); |
|
208 void InitL(); |
|
209 virtual void PlayL(); |
|
210 virtual void Stop(); |
|
211 virtual void SetVolume(TVolumeSetting aVolume); |
|
212 virtual void DoPlay(); |
|
213 private: |
|
214 virtual void Prepare(); |
|
215 void DoSetVolume(CMdaAudioToneUtility* aTonePlayer); |
|
216 protected: |
|
217 CAknEikAudioToneObserver* iToneObserver; |
|
218 CMdaAudioToneUtility* iTonePlayer; |
|
219 TBool iPlayedStatically; |
|
220 }; |
|
221 |
|
222 |
|
223 // Tone sound info. |
|
224 NONSHARABLE_CLASS(CAknToneSoundInfo) : public CAknSynthSoundInfo |
|
225 { |
|
226 public: |
|
227 CAknToneSoundInfo(TInt aPriority, TInt aPreference); |
|
228 virtual ~CAknToneSoundInfo(); |
|
229 private: |
|
230 virtual void Prepare(); |
|
231 public: |
|
232 TInt iFrequency; |
|
233 TTimeIntervalMicroSeconds iMs; |
|
234 }; |
|
235 |
|
236 |
|
237 // Sequence sound info. |
|
238 NONSHARABLE_CLASS(CAknSequenceSoundInfo) : public CAknSynthSoundInfo |
|
239 { |
|
240 public: |
|
241 CAknSequenceSoundInfo(TInt aPriority, TInt aPreference); |
|
242 virtual ~CAknSequenceSoundInfo(); |
|
243 void ReadSequenceL(RReadStream& aStream); |
|
244 private: |
|
245 virtual void Prepare(); |
|
246 public: |
|
247 HBufC8* iSequence; |
|
248 }; |
|
249 |
|
250 |
|
251 // File sound info. |
|
252 NONSHARABLE_CLASS(CAknFileSoundInfo) : |
|
253 public CEikSoundInfo, |
|
254 public MMdaAudioPlayerCallback, |
|
255 public MMdaObjectStateChangeObserver |
|
256 { |
|
257 public: |
|
258 CAknFileSoundInfo(TInt aPriority, TInt aPreference); |
|
259 virtual ~CAknFileSoundInfo(); |
|
260 void InitL(const TDesC& aFileName, CMdaServer* aMdaServer); |
|
261 virtual void PlayL(); |
|
262 virtual void Stop(); |
|
263 virtual void SetVolume(TVolumeSetting aVolume); |
|
264 // From MMdaAudioPlayerCallback |
|
265 virtual void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration); |
|
266 virtual void MapcPlayComplete(TInt aError); |
|
267 virtual void DoPlay(); |
|
268 private: |
|
269 void LoadAudioDataL(RFs& aFs, const TDesC& aFileName, TDes8& aDes); |
|
270 void DoSetVolume(CMdaAudioPlayerUtility* aAudioPlayer); |
|
271 |
|
272 // From MMdaObjectStateChangeObserver |
|
273 virtual void MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState, TInt aCurrentState, |
|
274 TInt aErrorCode); |
|
275 public: |
|
276 CMdaAudioPlayerUtility* iAudioPlayer; |
|
277 HBufC8* iAudioData; |
|
278 private: |
|
279 TBool iPlaying; |
|
280 TBool iPrepared; |
|
281 CMdaServer* iMdaServer; |
|
282 }; |
|
283 |
|
284 |
|
285 class TAknSoundID |
|
286 { |
|
287 public: |
|
288 TInt iAppUid; |
|
289 TUint iSid; |
|
290 CEikSoundInfo* iSoundInfo; // reference only |
|
291 }; |
|
292 |
|
293 |
|
294 class TAknSoundMessageInfo |
|
295 { |
|
296 public: |
|
297 TInt iSid; |
|
298 TUint8 iFile; |
|
299 TInt iFrequency; |
|
300 TInt iMs; |
|
301 }; |
|
302 |
|
303 #endif |