1 /* |
|
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 "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 class gives interface for playing IM message alert |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CIMALERTMANAGER_H |
|
19 #define CIMALERTMANAGER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include "mimalertnotifierkeyobserver.h" |
|
23 #include <apgcli.h> |
|
24 #include <mdaaudiosampleplayer.h> |
|
25 #include <mdaaudiotoneplayer.h> |
|
26 #include <bldvariant.hrh> |
|
27 |
|
28 #include <centralrepository.h> |
|
29 #include <cenrepnotifyhandler.h> |
|
30 #include <barsc.h> |
|
31 #include <Profile.hrh> |
|
32 #include <e32base.h> |
|
33 |
|
34 #include "mimalertinterface.h" |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class CFLDRingingTonePlayer; |
|
38 class MProfileEngine; |
|
39 class MIMAlertManagerObserver; |
|
40 class MIMAlertNotifierInterface; |
|
41 class MProfile; |
|
42 class CHWRMVibra; |
|
43 class MVIMPSTSettingsStore; |
|
44 class Ctestinstantmsgalert; //For Test code |
|
45 |
|
46 #include "mimalertinterface.h" |
|
47 |
|
48 const TInt KIMVibraDuration = 1000; // in milliseconds |
|
49 |
|
50 /** |
|
51 * This class gives interface to play |
|
52 * simple sounds |
|
53 * |
|
54 * @lib chat.app |
|
55 * @since 1.2 |
|
56 */ |
|
57 class CIMAlertManager |
|
58 : public CBase, |
|
59 public MMdaAudioPlayerCallback, |
|
60 public MIMAlertNotifierKeyObserver, |
|
61 public MMdaAudioToneObserver, |
|
62 public MCenRepNotifyHandlerCallback, |
|
63 public MIMAlertInterface |
|
64 { |
|
65 protected: // Enumerations |
|
66 |
|
67 enum TAudioPlayerStatus |
|
68 { |
|
69 EAudioPlayerNotCreated, |
|
70 EAudioPlayerInitializing, |
|
71 EAudioPlayerReady, |
|
72 EAudioPlayerPlaying, |
|
73 EAudioPlayerInitialized |
|
74 }; |
|
75 |
|
76 public: // Constructors and destructor |
|
77 |
|
78 /** |
|
79 * Two-phased constructor. |
|
80 * param aServiceId, service id to get the tone to be played. |
|
81 */ |
|
82 IMPORT_C static CIMAlertManager* NewL(); |
|
83 |
|
84 /** |
|
85 * Destructor. |
|
86 */ |
|
87 virtual ~CIMAlertManager(); |
|
88 |
|
89 public: // New functions |
|
90 |
|
91 /** |
|
92 * Starts playing the tone that has been set |
|
93 * @since 1.2 |
|
94 */ |
|
95 IMPORT_C void PlayL(TUint32 aServiceId); |
|
96 |
|
97 /** |
|
98 * Stops playing |
|
99 * @since 1.2 |
|
100 */ |
|
101 IMPORT_C void Stop(); |
|
102 |
|
103 /** |
|
104 * Set the volume level on which the sound is played |
|
105 * If this method is not called, player uses the setting |
|
106 * in active profile. |
|
107 * @param aVolume The volume level |
|
108 */ |
|
109 IMPORT_C void SetVolume( TInt aVolume ); |
|
110 |
|
111 /** |
|
112 * Sets the ringing type |
|
113 * If this method is not called, player uses the setting |
|
114 * in active profile. |
|
115 * @param aRingingType The ringing type (see enum TProfileRingingType) |
|
116 */ |
|
117 IMPORT_C void SetRingingType( TProfileRingingType aRingingType ); |
|
118 |
|
119 /** |
|
120 * Sets vibrating alert on or off. |
|
121 * If this method is not called, player uses the |
|
122 * setting in active profile. |
|
123 * @param aVibra True: Vibra is on. False: Vibra is off. |
|
124 */ |
|
125 IMPORT_C void SetVibra( TBool aVibra ); |
|
126 |
|
127 /** |
|
128 * Adds observer, which is informed when playing is completed |
|
129 * @param aObserver observing object |
|
130 */ |
|
131 IMPORT_C void AddObserverL( const MIMAlertManagerObserver* aObserver ); |
|
132 |
|
133 /** |
|
134 * Removes observer |
|
135 * @param aObserver observing object |
|
136 */ |
|
137 IMPORT_C void RemoveObserver( const MIMAlertManagerObserver* aObserver ); |
|
138 |
|
139 private: // constructors |
|
140 |
|
141 /** |
|
142 * C++ default constructor. |
|
143 * @see CIMAlertManager::NewL |
|
144 */ |
|
145 CIMAlertManager(); |
|
146 |
|
147 /** |
|
148 * By default Symbian 2nd phase constructor is private. |
|
149 */ |
|
150 void ConstructL(); |
|
151 |
|
152 private: |
|
153 /** |
|
154 * Does the actual sound playing |
|
155 * @since 2.1 |
|
156 */ |
|
157 void DoPlayL(TUint32 aServiceId); |
|
158 |
|
159 /** |
|
160 * Starts playing the sound file |
|
161 * @param aFileName The file to be processed |
|
162 */ |
|
163 void ProcessFileL( const TDesC& aFileName ); |
|
164 |
|
165 /** When audioplayer is ready, set its ringing type |
|
166 * @param aRingingType The ringing type (see enum TRingingTypes) |
|
167 */ |
|
168 void DoSetRingingType( TInt aRingingType ); |
|
169 |
|
170 /** |
|
171 * Converts volume from 1 to 10 to audio driver understandable value. |
|
172 * @param aVolume Volume level to be converted. |
|
173 * @return Returns converted volume level |
|
174 */ |
|
175 TInt ConvertVolume( TInt aVolume ); |
|
176 |
|
177 /** |
|
178 * Passess error to current activescheluder if |
|
179 * error = KErrNoMemory or KErrDiskFull |
|
180 */ |
|
181 void HandleError( TInt aError ); |
|
182 |
|
183 /** |
|
184 * Gets tone file name from SAP settings |
|
185 * @param aToneFileName After the call this will |
|
186 * contain the tone file name |
|
187 */ |
|
188 void GetToneFileNameL( TDes& aToneFileName ,TUint32 aServiceId); |
|
189 |
|
190 private: // Methods derived from MMdaAudioPlayerCallback |
|
191 |
|
192 /** |
|
193 * Derived from MMdaAudioPlayerCallback |
|
194 * This method is called when the audio player initialisation is ready |
|
195 * @see MMdaAudioPlayerCallback |
|
196 */ |
|
197 void MapcInitComplete( TInt aError, |
|
198 const TTimeIntervalMicroSeconds& aDuration ); |
|
199 |
|
200 /** |
|
201 * Derived from MMdaAudioPlayerCallback |
|
202 * This method is called when the audio player has finished playing |
|
203 * @see MMdaAudioPlayerCallback |
|
204 */ |
|
205 void MapcPlayComplete( TInt aError ); |
|
206 |
|
207 private: // Methods derived from MMdaAudioToneObserver |
|
208 |
|
209 /** |
|
210 * Derived from MMdaAudioToneObserver |
|
211 * This method is called when the tone player initialisation is ready |
|
212 * @see MMdaAudioToneObserver |
|
213 */ |
|
214 virtual void MatoPrepareComplete( TInt aError ); |
|
215 |
|
216 /** |
|
217 * Derived from MMdaAudioToneObserver |
|
218 * This method is called when the tone player has finished playing |
|
219 * @see MMdaAudioToneObserver |
|
220 */ |
|
221 virtual void MatoPlayComplete( TInt aError ); |
|
222 |
|
223 private: // Methods derived from MIMAlertNotifierKeyObserver |
|
224 |
|
225 /** |
|
226 * Derived from MIMAlertNotifierKeyObserver |
|
227 * Receive a notification from publish and subscribe keys |
|
228 */ |
|
229 void HandleKeyChange( TUpdatedKey& aUpdatedValues ); |
|
230 |
|
231 private: // Methods derived from MCenRepNotifyHandlerCallback |
|
232 /** |
|
233 * Derived from MCenRepNotifyHandlerCallback |
|
234 * Receive a notification from central repository server |
|
235 */ |
|
236 void HandleNotifyInt(TUint32 aId, TInt aNewValue); |
|
237 |
|
238 private: // Data |
|
239 |
|
240 |
|
241 // Doesn't own. Profile API if silent then there is no sounds |
|
242 MProfileEngine* iProfileApi; |
|
243 |
|
244 // Used to play other audio files than ringing tones. Owned. |
|
245 CMdaAudioPlayerUtility* iAudioPlayer; |
|
246 TAudioPlayerStatus iAudioPlayerStatus; |
|
247 |
|
248 // Used to play ringing tones. Owned |
|
249 CMdaAudioToneUtility* iTonePlayer; |
|
250 TAudioPlayerStatus iTonePlayerStatus; |
|
251 |
|
252 // Used for follow if user stops audio playing, |
|
253 // also for profile changes in volume level and vibrating alert |
|
254 CCenRepNotifyHandler* iRingingVolumeNotifyHandler; |
|
255 CCenRepNotifyHandler* iRingingTypeNotifyHandler; |
|
256 CCenRepNotifyHandler* iVibraNotifyHandler; |
|
257 |
|
258 CRepository* iProfilesRepository; |
|
259 CRepository* iVibraRepository; |
|
260 |
|
261 // Used to follow tone quit key |
|
262 MIMAlertNotifierInterface* iNotifierAPI; |
|
263 |
|
264 // ringing settings |
|
265 TInt iRingingVolume; |
|
266 TInt iRingingType; |
|
267 TBool iVibra; |
|
268 |
|
269 // Used when checking audio file type |
|
270 RApaLsSession iApaSession; |
|
271 |
|
272 // Audiomanager observers |
|
273 RPointerArray<MIMAlertManagerObserver> iObservers; |
|
274 |
|
275 // Used to keep track if current sound is default sound. |
|
276 TBool iIsPlayingDefaultIMSound; |
|
277 |
|
278 // Tone file name |
|
279 HBufC* iToneFileName; |
|
280 |
|
281 // File session for file operations |
|
282 RFs iFs; |
|
283 |
|
284 // currently active profile (ownership transferred) |
|
285 MProfile* iActiveProfile; |
|
286 |
|
287 // owned, vibra API |
|
288 CHWRMVibra* iVibrator; |
|
289 |
|
290 // ETrue if Always Online is active, invoked from IM Launcher |
|
291 TBool iIMLauncherInvoked; |
|
292 |
|
293 // Beep once ringing tone |
|
294 HBufC* iBeepRingingTone; |
|
295 |
|
296 // owns. Access to central repository |
|
297 CRepository* iCenRep; |
|
298 |
|
299 // ETrue if IMPSCUI Session Id should be preserved upon exit |
|
300 TBool iPreserveSessionIdInExit; |
|
301 |
|
302 //service id |
|
303 TUint32 iServiceId; |
|
304 |
|
305 MVIMPSTSettingsStore* iSettingsStore; |
|
306 //for test cases |
|
307 friend class Ctestinstantmsgalert; |
|
308 }; |
|
309 |
|
310 #endif // CIMALERTMANAGER_H |
|
311 |
|
312 // End of File |
|