|
1 /* |
|
2 * Copyright (c) 2002-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: BIO control for Ringing Tones. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CRINGINGTONEBIOCONTROL_H |
|
21 #define CRINGINGTONEBIOCONTROL_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <msgbiocontrol.h> // for CMsgBioControl |
|
25 #include <MMsgBioControlExtension.h> // MMsgBioControlExtension; |
|
26 #include <msgasynccontrolobserver.h> // observer interface for CMsgAudioControl |
|
27 #include <eikcmobs.h> // MEikCommandObserver |
|
28 |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CEikButtonGroupContainer; |
|
32 class CEikRichTextEditor; |
|
33 class CMsgAudioControl; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Bio control for Ringing Tones. |
|
39 */ |
|
40 class CRingingToneBioControl : |
|
41 public CMsgBioControl, |
|
42 public MEikCommandObserver, |
|
43 public MMsgAsyncControlObserver |
|
44 { |
|
45 |
|
46 public: // Constructor and destructor |
|
47 |
|
48 /** |
|
49 * Two-phased constructor |
|
50 * @param aObserver Reference to the Bio control observer. |
|
51 * @param aSession Reference to Message Server session. |
|
52 * @param aId Id of the message. |
|
53 * @param aEditorOrViewerMode Flags the new Bio control as editor or |
|
54 * viewer. |
|
55 * @param aFile filehandle. |
|
56 * @return The newly created object. |
|
57 */ |
|
58 IMPORT_C static CMsgBioControl* NewL( |
|
59 MMsgBioControlObserver& aObserver, |
|
60 CMsvSession* aSession, |
|
61 TMsvId aId, |
|
62 TMsgBioMode aEditorOrViewerMode, |
|
63 const RFile* aFile); |
|
64 |
|
65 /** |
|
66 * Destructor. |
|
67 */ |
|
68 ~CRingingToneBioControl(); |
|
69 |
|
70 public: // Functions from MEikCommandObserver |
|
71 |
|
72 /** |
|
73 * From MEikCommandObserver |
|
74 * Handle prosess command. |
|
75 * @param aCommandId command id. |
|
76 */ |
|
77 void ProcessCommandL( TInt aCommandId ); |
|
78 |
|
79 public: // Functions from MMsgBioControl |
|
80 |
|
81 /** |
|
82 * From MMsgBioControl Calculates and sets size for a Bio control |
|
83 * according to aSize. |
|
84 * The height of the Bio control may be less or more than requested by |
|
85 * aSize, but the width must be exactly the same. If width of the Bio |
|
86 * control is not the same as given by aSize, the width must be reset |
|
87 * back to requested one. |
|
88 * @param aSize Size A reference to the suggested size and new size.. |
|
89 */ |
|
90 void SetAndGetSizeL( TSize& aSize ); |
|
91 |
|
92 /** |
|
93 * From MMsgBioControl This is called by the container to allow the Bio |
|
94 * control to add a menu item. |
|
95 * @param aMenuPane Reference to the application's menu. |
|
96 */ |
|
97 void SetMenuCommandSetL( CEikMenuPane& aMenuPane ); |
|
98 |
|
99 /** |
|
100 * From MMsgBioControl Returns a rectangle slice of the bio controls |
|
101 * viewing area. It is used by the CMsgEditorView class for scrolling |
|
102 * the screen. |
|
103 * @return TRect to show viewing area |
|
104 */ |
|
105 TRect CurrentLineRect() const; |
|
106 |
|
107 /** |
|
108 * From MMsgBioControl Returns true if Focus change is possible. |
|
109 * @param aDirection The direction to be checked. |
|
110 * @return ETrue if it is possible and vice versa |
|
111 */ |
|
112 TBool IsFocusChangePossible( TMsgFocusDirection aDirection ) const; |
|
113 |
|
114 /** |
|
115 * From MMsgBioControl The container application obtains a header text |
|
116 * from the bio control. |
|
117 * @return The header text. |
|
118 */ |
|
119 HBufC* HeaderTextL() const; |
|
120 |
|
121 /** |
|
122 * From MMsgBioControl The command handler. |
|
123 * The Bio Control should only handle its own commands that it has set |
|
124 * using the function SetMenuCommandSetL(). |
|
125 * @param aCommand ID of command to be handled. |
|
126 * @return If the command is handled, it returns ETrue, and vice versa |
|
127 */ |
|
128 TBool HandleBioCommandL(TInt aCommand); |
|
129 |
|
130 /** |
|
131 * The application can get the option menu recommendations using this |
|
132 * function. The function comes from MMsgBioControl. This is the |
|
133 * default implementation which returns the flags |
|
134 * KMsgBioCallBackToSender and KMsgBioCreateContactCard. Bio Controls |
|
135 * should override this if it is not ok. |
|
136 * @return The option menu permission flags. If the flag is off it |
|
137 * means that the option menu command is not recommended with this |
|
138 * Bio Control. |
|
139 */ |
|
140 TUint32 OptionMenuPermissionsL() const; |
|
141 |
|
142 /** |
|
143 * Get the virtual height of the control's content. |
|
144 * @return virtual height in pixels. |
|
145 */ |
|
146 TInt VirtualHeight(); |
|
147 |
|
148 /** |
|
149 * Get the position of invisible cursor. |
|
150 * @return cursor position in pixels. |
|
151 */ |
|
152 TInt VirtualVisibleTop(); |
|
153 |
|
154 public: // Functions from CCoeControl |
|
155 |
|
156 /** |
|
157 * A CCoeControl virtual for handling key events. |
|
158 * @param aKeyEvent The key event. |
|
159 * @param aType TEventCode |
|
160 * @return EKeyWasConsumed or EKeyWasNotConsumed |
|
161 */ |
|
162 TKeyResponse OfferKeyEventL( |
|
163 const TKeyEvent& aKeyEvent, |
|
164 TEventCode aType ); |
|
165 |
|
166 /** |
|
167 * Returns a bio control's a context sensitive help. |
|
168 * @param aHelpContext Help context. |
|
169 */ |
|
170 void GetHelpContext(TCoeHelpContext& aHelpContext) const; |
|
171 |
|
172 public: //from MMsgAsyncControlObserver |
|
173 |
|
174 void MsgAsyncControlStateChanged( CMsgBaseControl& aControl, |
|
175 TMsgAsyncControlState aNewState, |
|
176 TMsgAsyncControlState aOldState ); |
|
177 |
|
178 void MsgAsyncControlResourceChanged( CMsgBaseControl& aControl, |
|
179 TInt aType ); |
|
180 |
|
181 |
|
182 |
|
183 protected: // Functions from CCoeControl |
|
184 |
|
185 /** |
|
186 * From CCoeControl Handles a change to the control's resources |
|
187 * of type aType which are shared across the environment, |
|
188 * e.g. color scheme change, or in this case, skin change. |
|
189 * @param aType Event type |
|
190 */ |
|
191 void HandleResourceChange( TInt aType ); |
|
192 |
|
193 /** |
|
194 * From CCoeControl Gives the number of sub controls. |
|
195 * @return Count of controls be included in this component |
|
196 */ |
|
197 TInt CountComponentControls() const; |
|
198 |
|
199 /** |
|
200 * From CCoeControl Returns a pointer to a certain sub control. |
|
201 * @param aIndex Index for control |
|
202 * @return Pointer to component in question. |
|
203 */ |
|
204 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
205 |
|
206 /** |
|
207 * From CCoeControl This is called by the CONE framework, and gives |
|
208 * this control a chance to manage the layout of its sub controls. |
|
209 */ |
|
210 void SizeChanged(); |
|
211 |
|
212 /** |
|
213 * From CCoeControl This is called when focus is lost or gained, and |
|
214 * is used for setting the focus of the list box. |
|
215 * @param aDrawNow |
|
216 */ |
|
217 void FocusChanged( TDrawNow aDrawNow ); |
|
218 |
|
219 /** |
|
220 * From CCoeControl Sets the container window for this control. The |
|
221 * container control uses this function to set the same window for |
|
222 * this control. |
|
223 * @param aContainer container |
|
224 */ |
|
225 void SetContainerWindowL( const CCoeControl& aContainer ); |
|
226 |
|
227 /** |
|
228 * Used to draw Ringing tone icon |
|
229 */ |
|
230 void Draw(const TRect& aRect) const; |
|
231 |
|
232 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
233 |
|
234 private: // Constructors |
|
235 |
|
236 /** |
|
237 * The constructor. |
|
238 * @param aObserver MMsgBioControlObserver |
|
239 * @param aSession CMsvSession, the Message Server session. |
|
240 * @param aId Id of the message in Message Server. |
|
241 * @param aEditorOrViewerMode Flags the control as being either editor |
|
242 * or viewer. |
|
243 * @param aFile file handle |
|
244 */ |
|
245 CRingingToneBioControl( |
|
246 MMsgBioControlObserver& aObserver, |
|
247 CMsvSession* aSession, |
|
248 TMsvId aId, |
|
249 TMsgBioMode aEditorOrViewerMode, |
|
250 const RFile* aFile); |
|
251 |
|
252 /** |
|
253 * By default Symbian OS constructor is private. |
|
254 */ |
|
255 void ConstructL(); |
|
256 |
|
257 private: //New functions |
|
258 |
|
259 /** |
|
260 * Loads a ringing tone. |
|
261 */ |
|
262 void OpenFileL(); |
|
263 |
|
264 /** |
|
265 * Plays ringin tone. Because support for playing OTA files are not |
|
266 * supported in WINS, command plays nothing |
|
267 */ |
|
268 void PlaybackL(); |
|
269 |
|
270 /** |
|
271 * Stops playing ringin tone. |
|
272 */ |
|
273 void StopPlayback(); |
|
274 |
|
275 /** |
|
276 * Creates richeditor for ringing tone title. |
|
277 */ |
|
278 void CreateRichEditorL(); |
|
279 |
|
280 /** |
|
281 * add song title as a item to aItemArray |
|
282 * @param aItemArray Array for listbox |
|
283 */ |
|
284 void AddSongTitleToArrayL(CDesCArray& aItemArray) const; |
|
285 |
|
286 /** |
|
287 * Seek if string contains back slash |
|
288 * @param aTitle Descriptor where to find back slash |
|
289 * @return ETrue if back slash was found, else EFalse |
|
290 */ |
|
291 TBool IsBackSlash(TDes& aTitle); |
|
292 |
|
293 /** |
|
294 * Seek if string consists solely single dot or double dot |
|
295 * @param aTitle Descriptor where to find dots |
|
296 * @return ETrue if only dots are found, else EFalse |
|
297 */ |
|
298 TBool IsOnlyDots(TDes& aTitle); |
|
299 |
|
300 /** |
|
301 * Finds out if file already exists |
|
302 * @param aTitle Filename without path or file extent |
|
303 * @return ETrue if file already exists, else EFalse |
|
304 */ |
|
305 TBool ExistsL(TDes& aTitle); |
|
306 |
|
307 /** |
|
308 * Finds out is the filename valid for saving |
|
309 * @param aTitle Filename without path or file extent |
|
310 * @param aNotes Flag to indicate if the notes are shown |
|
311 * @return ETrue if file name is valid, else EFalse |
|
312 */ |
|
313 TBool IsValidL(TDes& aTitle, TBool aNotes); |
|
314 |
|
315 /** |
|
316 * |
|
317 * @param aTitle Filename without path or file extent |
|
318 * @return EFalse if user pressed cancel, else ETrue |
|
319 */ |
|
320 TBool AskNameL(TDes& aTitle); |
|
321 |
|
322 /** |
|
323 * |
|
324 * @param aTitle Filename without path or file extent |
|
325 * @return EFalse if user pressed cancel, else ETrue |
|
326 */ |
|
327 TBool AskAndValidNameL(TDes& aTitle); |
|
328 |
|
329 /** |
|
330 * Add ringing tone to the file system |
|
331 */ |
|
332 TBool SaveToneL(TDes& aTitle); |
|
333 |
|
334 /** |
|
335 * Called when user like to add Tone to composer. |
|
336 */ |
|
337 void TrySaveToneL(); |
|
338 |
|
339 /** |
|
340 * Creates target path for saving tone to filesystem |
|
341 * @param aName File name to be added in path |
|
342 * @return Target path |
|
343 */ |
|
344 HBufC* CreatePathForSavingLC(const TDesC& aName); |
|
345 |
|
346 /** |
|
347 * User interactivity, ask if liked to rename saveable tone, |
|
348 * then ask the new name for tone. |
|
349 * @return true if the new name is available, otherwise false. |
|
350 */ |
|
351 TBool RenameQueryL(TDes& aTitle); |
|
352 |
|
353 /** |
|
354 * Set Default name with increments to the iSaveTitle |
|
355 */ |
|
356 void SetDefaultNameL(TDes& aName); |
|
357 |
|
358 /** |
|
359 * Help function to handle name query |
|
360 * @param aName ringing tone name |
|
361 * @return ETrue if it is OK, else EFalse |
|
362 */ |
|
363 TBool NameQueryL(TDes& aName); |
|
364 |
|
365 /** |
|
366 * Rip title form ringing tone format by using composer engine |
|
367 */ |
|
368 void TakeTitleL(); |
|
369 |
|
370 /** |
|
371 * Increments numbers after file name, e.g.Ringing Tone1->Ringing Tone2 |
|
372 * @param aFileName ringing tone name |
|
373 */ |
|
374 void IncrementFileNameL(TDes& aFileName); |
|
375 |
|
376 /** |
|
377 * Find out the target path |
|
378 * @return target path |
|
379 */ |
|
380 HBufC* TargetPathLC(); |
|
381 |
|
382 /** |
|
383 * Checks is the ringing tone message in valid format. Leaves with *** if not. |
|
384 */ |
|
385 void CheckMsgValidityL(); |
|
386 |
|
387 /** |
|
388 * Loads ringing tone icon bitmap and mask, and fills transparent area with white color and |
|
389 * saves the new bitmap to temp folder. |
|
390 */ |
|
391 void FillBitmapMaskL(); |
|
392 |
|
393 /** |
|
394 * Correts CEikRichTextEditor's Font and set the alignment to centered. |
|
395 */ |
|
396 void CorrectFormatToRichEditorL(); |
|
397 |
|
398 /** |
|
399 * An information note is popped. |
|
400 * @param aStringResource The string resource id. |
|
401 */ |
|
402 void InformationNoteL(TInt aStringResource); |
|
403 |
|
404 /** |
|
405 * Gets profile settings from shared data. |
|
406 */ |
|
407 void GetAndSetRingingToneVolumeL(); |
|
408 |
|
409 private: // Hidden away |
|
410 |
|
411 /** |
|
412 * C++ default constructor, hidden away from outsiders. |
|
413 */ |
|
414 CRingingToneBioControl(); |
|
415 |
|
416 /** |
|
417 * Copy-constructor is prohibited. |
|
418 */ |
|
419 CRingingToneBioControl(const CRingingToneBioControl& aSource); |
|
420 |
|
421 /** |
|
422 * Assignment operator is prohibited. |
|
423 */ |
|
424 const CRingingToneBioControl& operator=( |
|
425 const CRingingToneBioControl& aSource ); |
|
426 |
|
427 private: // data |
|
428 |
|
429 ///Ringing tone name |
|
430 HBufC* iToneTitle; |
|
431 |
|
432 /// control for showing Ringing tone name |
|
433 CEikRichTextEditor* iRichEditor; |
|
434 |
|
435 /* |
|
436 * Audio player |
|
437 * Owned |
|
438 */ |
|
439 CMsgAudioControl *iAudioControl; |
|
440 |
|
441 //audio control states |
|
442 TMsgAsyncControlState iPlayerState; |
|
443 |
|
444 //Object to handle softkeys in playtime |
|
445 CEikButtonGroupContainer *iStopCba; |
|
446 }; |
|
447 |
|
448 #endif //CRINGINGTONEBIOCONTROL_H |
|
449 |
|
450 // End of File |