|
1 /* |
|
2 * Copyright (c) 2005 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: PostcardAppUi declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef POSTCARDAPPUI_H |
|
21 #define POSTCARDAPPUI_H |
|
22 |
|
23 // ========== INCLUDE FILES ================================ |
|
24 |
|
25 #include <MsgEditorAppUi.h> // CMsgEditorAppUi |
|
26 #include <MsgEditor.hrh> //zoom |
|
27 #include <MsgEditorSettingCacheUpdatePlugin.h>//zoom |
|
28 |
|
29 #include <MMGFetchVerifier.h> // MMGFetchVerifier |
|
30 #include <MsgAttachmentUtils.h> // fetchtype |
|
31 |
|
32 #include "PostcardDocument.h" // TPostcardMsgType |
|
33 #include "PostcardOperationObserver.h" // MPostcardOperationObserver |
|
34 #include "PostcardQueryWaiter.h" // PostcardQueryWaiter |
|
35 #ifdef RD_SCALABLE_UI_V2 |
|
36 #include "PostcardPointerObserver.h" // MPocaPointerEventObserver |
|
37 #endif |
|
38 |
|
39 |
|
40 // ========== CONSTANTS ==================================== |
|
41 |
|
42 const TInt KPostcardAmountOfFreeDiskSpaceNeeded = 2000; |
|
43 |
|
44 // ========== MACROS ======================================= |
|
45 |
|
46 // ========== DATA TYPES =================================== |
|
47 |
|
48 // ========== FUNCTION PROTOTYPES ========================== |
|
49 |
|
50 // ========== FORWARD DECLARATIONS ========================= |
|
51 |
|
52 class CAknNavigationControlContainer; |
|
53 class CAknTitlePane; |
|
54 class CAknInputBlock; |
|
55 class CAknWaitDialog; |
|
56 class CAknGlobalMsgQuery; |
|
57 class CEikMenuBar; |
|
58 class CEikMenuPane; |
|
59 |
|
60 class CIdle; |
|
61 class CPlainText; |
|
62 class CContactCard; |
|
63 class CFbsBitmap; |
|
64 class CGulIcon; |
|
65 |
|
66 class CMsgImageInfo; |
|
67 |
|
68 class CPostcardOperation; |
|
69 class CPostcardController; |
|
70 class CPostcardCenRep; |
|
71 |
|
72 // ========== CLASS DECLARATION ============================ |
|
73 |
|
74 /** |
|
75 * Postcard AppUi module |
|
76 * |
|
77 */ |
|
78 class CPostcardAppUi : |
|
79 public CMsgEditorAppUi, |
|
80 public MMGFetchVerifier, |
|
81 public MPostcardOperationObserver, |
|
82 #ifdef RD_SCALABLE_UI_V2 |
|
83 public MPocaPointerEventObserver, |
|
84 #endif // RD_SCALABLE_UI_V2 |
|
85 public MPostcardQueryWaiterCallback |
|
86 { |
|
87 |
|
88 public: |
|
89 |
|
90 /** |
|
91 * Constructor. |
|
92 */ |
|
93 CPostcardAppUi(); |
|
94 |
|
95 /** |
|
96 * 2nd phase constructor. |
|
97 */ |
|
98 void ConstructL(); |
|
99 |
|
100 /** |
|
101 * Destructor. |
|
102 */ |
|
103 ~CPostcardAppUi(); |
|
104 |
|
105 /** |
|
106 * Route key events to view. |
|
107 * @param aKeyEvent key event |
|
108 * @param aType event type |
|
109 * @return response |
|
110 * from CCoeAppUi |
|
111 */ |
|
112 TKeyResponse HandleKeyEventL( |
|
113 const TKeyEvent& aKeyEvent, TEventCode aType); |
|
114 |
|
115 /** |
|
116 * From CEikAppUi |
|
117 */ |
|
118 void HandleCommandL( TInt aCommand ); |
|
119 |
|
120 /** |
|
121 * From MEikMenuObserver |
|
122 */ |
|
123 void DynInitMenuPaneL( TInt aMenuId, CEikMenuPane* aMenuPane ); |
|
124 |
|
125 |
|
126 private: |
|
127 |
|
128 /** |
|
129 * Inits the main menu options |
|
130 * @param aMenuPane |
|
131 */ |
|
132 void DynInitMainMenuL( CEikMenuPane* aMenuPane ); |
|
133 |
|
134 /** |
|
135 * Inits the Insert submenu options |
|
136 * @param aMenuPane |
|
137 */ |
|
138 void DynInitInsertSubMenuL( CEikMenuPane* aMenuPane ); |
|
139 |
|
140 /** |
|
141 * Inits the context menu options |
|
142 * @param aMenuPane |
|
143 */ |
|
144 void DynInitContextMenuL( CEikMenuPane* aMenuPane ); |
|
145 |
|
146 /** |
|
147 * Checks if option aMenuItem is invisible |
|
148 * @param aMenuitem |
|
149 * @return ETrue if invisible |
|
150 */ |
|
151 TBool IsMainMenuOptionInvisible( TInt aMenuItem ); |
|
152 |
|
153 /** |
|
154 * Creates a media info object from given file and |
|
155 * performs a preliminary check whether it is ok to |
|
156 * insert the given media file. |
|
157 * |
|
158 * The media info object is created to "iImageInfo" |
|
159 * member variable. |
|
160 * |
|
161 * @param aFileName Media file to be checked |
|
162 * @return ETrue if media info object was created |
|
163 * EFalse otherwise |
|
164 */ |
|
165 TBool CreateMediaInfoForInsertL( const TDesC& aFileName ); |
|
166 |
|
167 /** |
|
168 * Handles selection key press. Either opens text/greeting dialog or open context menu |
|
169 */ |
|
170 void DoSelectionKeyL(); |
|
171 |
|
172 public: |
|
173 |
|
174 /** |
|
175 * Launches help application |
|
176 * @param aContext launches the aContext help page from Postcard manual |
|
177 */ |
|
178 void LaunchHelpL( const TDesC& aContext ); |
|
179 |
|
180 /** |
|
181 * Accessor |
|
182 * Get reference to file session |
|
183 * @return Reference to file session |
|
184 */ |
|
185 RFs& FsSession() const; |
|
186 |
|
187 /** |
|
188 * Tries to exit the application. |
|
189 */ |
|
190 void DoExternalExit( ); |
|
191 |
|
192 /** |
|
193 * Callback for CIdle |
|
194 */ |
|
195 static TInt DelayedExit( TAny* aThis ); |
|
196 |
|
197 /** |
|
198 * From MMGFetchVerifier |
|
199 */ |
|
200 TBool VerifySelectionL( const MDesCArray* aSelectedFiles ); |
|
201 |
|
202 /** |
|
203 * From MMsgEditorLauncher |
|
204 */ |
|
205 void LaunchViewL(); |
|
206 |
|
207 /** |
|
208 * From CMsgEditorAppUi |
|
209 */ |
|
210 void DoMsgSaveExitL(); |
|
211 |
|
212 /** |
|
213 * From MPostcardOperationObserver |
|
214 * Checks the result of the event and shows possible error note. |
|
215 * Calls right function to finalize launch, save or image insertion. |
|
216 */ |
|
217 void PostcardOperationEvent( |
|
218 TPostcardOperationType aOperation, |
|
219 TPostcardOperationEvent aEvent ); |
|
220 |
|
221 /** |
|
222 * From MPostcardQueryWaiterCallback |
|
223 * If aResult is ok, starts the sending operation (save operation with right flag). |
|
224 * Otherwise just deletes the query and returns. |
|
225 */ |
|
226 void QueryWaiterCallbackL( TInt aResult ); |
|
227 |
|
228 /** |
|
229 * From MPostcardQueryWaiterCallback |
|
230 * Called when QueryWaiterCallbackL() leaves. Should perform cleanup. |
|
231 * After the callback, the leave is propagated to active scheduler. |
|
232 */ |
|
233 void QueryWaiterCallbackError(); |
|
234 |
|
235 /** |
|
236 * Returns application menubar. |
|
237 * @return pointer to menubar. |
|
238 */ |
|
239 CEikMenuBar* MenuBar() const; |
|
240 |
|
241 /** |
|
242 * Asks the controller to reread the coordinates from the laf |
|
243 */ |
|
244 void HandleResourceChangeL( TInt aType ); |
|
245 |
|
246 /** |
|
247 * Starts CIdle to call ExternalExit |
|
248 */ |
|
249 void DoDelayedExit( TInt aDelayTime ); |
|
250 |
|
251 /** |
|
252 * Save message and exits |
|
253 */ |
|
254 void ExitAndSaveL(); |
|
255 |
|
256 /** |
|
257 * Shows "closing message" list query. The options |
|
258 * in the query are "Save to draft" and "Delete message". |
|
259 * Should be called when "Close" softkey is pressed in |
|
260 * non-empty message. |
|
261 * |
|
262 * @return EMsgCloseCancel, if the query is cancelled |
|
263 * EMsgCloseSave, if "Save to drafts" is selected |
|
264 * EMsgCloseDelete, if "Delete message" is selected |
|
265 */ |
|
266 TInt ShowCloseQueryL(); |
|
267 |
|
268 /** |
|
269 * Takes the ownership of the aIcon and also passes the icon to controller |
|
270 */ |
|
271 void SetImage( CGulIcon* aIcon ); |
|
272 |
|
273 /** |
|
274 * Takes the ownership of the aItem. |
|
275 * Takes the right fields from aItem and writes them into a bitmap |
|
276 * Passes the bitmap to controller. |
|
277 */ |
|
278 void SetRecipientL( CContactCard& aItem ); |
|
279 |
|
280 /** |
|
281 * Takes the ownership of the aPlainText. |
|
282 * Writes the text into a bitmap. |
|
283 * Passes the bitmap to controller. |
|
284 */ |
|
285 void SetTextL( CPlainText& aPlainText ); |
|
286 |
|
287 /** |
|
288 * Get maximum text length allowed for edit control |
|
289 */ |
|
290 TInt MaxTextLength( TInt aControlId ); |
|
291 |
|
292 /** |
|
293 * Return reference to cenrep parameters |
|
294 */ |
|
295 const CPostcardCenRep& CenRep(); |
|
296 |
|
297 /** |
|
298 * Gets the local zoom level |
|
299 */ |
|
300 void GetZoomLevelL( TInt& aZoomLevel ); |
|
301 |
|
302 /** |
|
303 * Handles the changing of the local zoom by calling CMsgEditorAppUi::HandleLocalZoomChangeL |
|
304 * @param aNewZoom is the new zoom level |
|
305 */ |
|
306 void HandleLocalZoomChangeL( TMsgCommonCommands aNewZoom ); |
|
307 |
|
308 |
|
309 protected: |
|
310 |
|
311 /** |
|
312 * Active scheduler start for saving. |
|
313 */ |
|
314 void BeginActiveWait(); |
|
315 |
|
316 /** |
|
317 * Active scheduler stop for saving. |
|
318 */ |
|
319 void EndActiveWait(); |
|
320 |
|
321 #ifdef RD_SCALABLE_UI_V2 |
|
322 private: // from MPocaPointerEventObserver |
|
323 void PocaPointerEventL( TPocaPointerEvent aEvent, TPocaPointerEventType aEventType ); |
|
324 #endif // RD_SCALABLE_UI_V2 |
|
325 |
|
326 private: |
|
327 |
|
328 /** |
|
329 * Called when open operation finishes. Removes wait note. |
|
330 * Updates navipane, checks if greeting or address fields are too long. |
|
331 * Focuses the right object. |
|
332 */ |
|
333 void CompleteLaunchViewL( ); |
|
334 |
|
335 /** |
|
336 * Checks whether there is enough disk space to save message or image. |
|
337 */ |
|
338 TBool CanSaveMessageL( TInt aAmount = KPostcardAmountOfFreeDiskSpaceNeeded ); |
|
339 |
|
340 /** |
|
341 * Checks message content and start the sending query |
|
342 */ |
|
343 void DoSendL(); |
|
344 |
|
345 /** |
|
346 * Starts the saving operation. |
|
347 */ |
|
348 void DoSaveL(); |
|
349 |
|
350 /** |
|
351 * Shows the save query if necessary and calls DoSave if needed |
|
352 */ |
|
353 void DoBackSaveL(); |
|
354 |
|
355 /** |
|
356 * Deletes image if it's focused |
|
357 */ |
|
358 void DoBackspaceL( ); |
|
359 |
|
360 /** |
|
361 * Calls MTMUI's Forward feature to forward the postcard to someone else |
|
362 */ |
|
363 void DoForwardMessageL( ); |
|
364 |
|
365 /** |
|
366 * Opens the address dialog. |
|
367 * param aKeyEvent - if set, SimulateKeyEvent is called for it in the dialog |
|
368 * param aFirstFocused - if set, focuses the given field when dialog started |
|
369 */ |
|
370 void DoEditAddressL( TKeyEvent aKeyEvent = TKeyEvent(), |
|
371 TInt aFirstFocused = -1 ); |
|
372 |
|
373 /** |
|
374 * Opens the greeting text dialog |
|
375 * param aKeyEvent - if set, SimulateKeyEvent is called for it in the dialog |
|
376 */ |
|
377 void DoEditGreetingL( TKeyEvent aKeyEvent = TKeyEvent( ) ); |
|
378 |
|
379 /** |
|
380 * Updates TMsvEntry and calls DoShowMessageInfoL |
|
381 */ |
|
382 void DoUpdateEntryAndShowMessageInfoL( ); |
|
383 |
|
384 /** |
|
385 * Calls MsgAttachmentUtils::FetchFileL to fetch file aFetchType |
|
386 */ |
|
387 TBool FetchFileL( MsgAttachmentUtils::TMsgAttachmentFetchType aFetchType ); |
|
388 |
|
389 /** |
|
390 * Call FetchFileL with right parameter |
|
391 * @param aFetchType: EImage or ENewImage |
|
392 */ |
|
393 void DoInsertImageL( |
|
394 MsgAttachmentUtils::TMsgAttachmentFetchType aFetchType ); |
|
395 |
|
396 /** |
|
397 * Calls NextMessageL if next/prev message is available |
|
398 */ |
|
399 TKeyResponse NavigateBetweenMessagesL( TBool aNextMessage ); |
|
400 |
|
401 public: // These are functions that also address and greeting dialogs use |
|
402 |
|
403 /** |
|
404 * Creates and shows an information note with text string aResourceId |
|
405 */ |
|
406 void ShowInformationNoteL( TInt aResourceID, TBool aWaiting ); |
|
407 |
|
408 /** |
|
409 * Creates and shows an information note with text string aText |
|
410 */ |
|
411 void ShowInformationNoteL( const TDesC& aText, TBool aWaiting ); |
|
412 |
|
413 /** |
|
414 * Calls global error UI to show an information note with text string aResourceId. |
|
415 */ |
|
416 void ShowGlobalInformationNoteL( TInt aResourceId, TBool aWaiting ); |
|
417 |
|
418 /** |
|
419 * Creates and shows a confirmation query. |
|
420 * First loads the string aResourceId from the resource file. |
|
421 * Then calls the other ShowConfirmationQuery to show the query. |
|
422 */ |
|
423 TInt ShowConfirmationQueryL( TInt aResourceId, TBool aOnlyOK=EFalse ) const; |
|
424 |
|
425 /** |
|
426 * Creates and shows a confirmation query. |
|
427 * Creates a query dialog with text aText. If aOnlyOK is true, the softkeys |
|
428 * are OK-Empty. Otherwise they are Yes-No. |
|
429 * Returns the value returned by the dialog. |
|
430 */ |
|
431 TInt ShowConfirmationQueryL( const TDesC& aText, TBool aOnlyOK=EFalse ) const; |
|
432 |
|
433 |
|
434 /** |
|
435 * Puts a wait note on the screen with text aResourceId |
|
436 * Stays on the screen until RemoveWaitNote is called |
|
437 * param aNoTimeout - if true, note is shown immediately |
|
438 * result true if the dialog was successfully shown |
|
439 */ |
|
440 TBool ShowWaitNoteL( TInt aResourceId, TBool aNoTimeout ); |
|
441 |
|
442 /** |
|
443 * Removes possible current wait note from the screen. |
|
444 */ |
|
445 void RemoveWaitNote(); |
|
446 |
|
447 /** |
|
448 * Reads and returns the mandatory fields' byte from the resource |
|
449 */ |
|
450 TInt MandatoryAddressFields( ); |
|
451 |
|
452 /** |
|
453 * Reads string aResourceId from the resource file and leaves in the callstack |
|
454 * return the read string |
|
455 */ |
|
456 HBufC* ReadFromResourceLC( TInt& aResourceId ); |
|
457 |
|
458 /** |
|
459 * Calls MTMUI to show the message info in the screen. |
|
460 */ |
|
461 void DoShowMessageInfoL(); |
|
462 |
|
463 /** |
|
464 * Called by Text editor dialog to ask if the recipient field has any data |
|
465 * Returns ETrue if iContact has any data. |
|
466 */ |
|
467 TBool ContactHasData( ); |
|
468 |
|
469 private: |
|
470 |
|
471 /** |
|
472 * Returns true if there's no image, no text nor recipient address |
|
473 */ |
|
474 TBool IsMessageEmpty( ); |
|
475 |
|
476 /** |
|
477 * Returns a reference to the document class |
|
478 */ |
|
479 CPostcardDocument& Document(); |
|
480 |
|
481 /** |
|
482 * Creates a set of address strings by using iContact |
|
483 * and passes the strings into CreateTransparentIconL. |
|
484 * Passes the returned transparent bitmap to Controller class. |
|
485 */ |
|
486 void RefreshRecipientBitmapL( ); |
|
487 |
|
488 /** |
|
489 * Refreshes the lines how the greeting and recipients focus lines are drawn |
|
490 */ |
|
491 void RefreshFocusLinesL( ); |
|
492 |
|
493 /** |
|
494 * Uses iGreeting as source text. |
|
495 * Writes the text into a transparent bitmap and passes it into controller |
|
496 */ |
|
497 void CreateGreetingBitmapL( ); |
|
498 |
|
499 /** |
|
500 * Creates a transparent icon with text aText written into it. |
|
501 */ |
|
502 CGulIcon* CreateTransparentIconL( const TDesC& aText ); |
|
503 |
|
504 /** |
|
505 * Creates a transparent icon with text aStrings line by line written into it. |
|
506 */ |
|
507 CGulIcon* CreateTransparentIconL( const MDesCArray& aStrings ); |
|
508 |
|
509 /** |
|
510 * Creates an empty bitmap of size aSize. |
|
511 * Used by the functions above. |
|
512 */ |
|
513 CFbsBitmap* CreateEmptyBitmapLC( const TSize& aSize ); |
|
514 |
|
515 /** |
|
516 * Returns ETrue if aContact's any field has any data |
|
517 */ |
|
518 TBool ContactHasData( const CContactCard& aContact ); |
|
519 |
|
520 /** |
|
521 * Reads the max lenghts of each field from resources. |
|
522 * Returns EFalse if either greeting text or any of the address fields |
|
523 * are too long. |
|
524 */ |
|
525 TBool CheckLengthsL( ); |
|
526 |
|
527 /** |
|
528 * Creates and returns the string that is shown in the send confirmation query |
|
529 * after user has chosen to send the postcard. |
|
530 */ |
|
531 HBufC* CreateAddressStringForSendConfirmLC( ); |
|
532 |
|
533 /** |
|
534 * Set main view middle softkey label according to the postcard side |
|
535 * viewed and mode (viewer / edit). |
|
536 */ |
|
537 void SetMiddleSoftkeyL(); |
|
538 |
|
539 /** |
|
540 * Creates and sets application icon to title pane. |
|
541 */ |
|
542 void CreateAndSetTitleIconL(); |
|
543 |
|
544 /** |
|
545 * Sets application icon to title pane. |
|
546 */ |
|
547 void SetTitleIconL(); |
|
548 |
|
549 /** |
|
550 * Checks if phone is in offline mode or not |
|
551 * |
|
552 * @return ETrue if phone is in offline mode |
|
553 * Otherwise EFalse. |
|
554 */ |
|
555 TBool IsPhoneOfflineL() const; |
|
556 |
|
557 private: |
|
558 |
|
559 enum TPostcardFlags |
|
560 { |
|
561 EPostcardGreetingActive = 1, // Is Greeting dialog open |
|
562 EPostcardRecipientActive = 2, // Is Address dialog open |
|
563 EPostcardCamcorder = 4, // Is Camcorder supported |
|
564 EPostcardEditMessageActive = 8, // Is Edit message active |
|
565 EPostcardHelp = 16, // Is Help supported |
|
566 EPostcardExitCalledFromDialog = 32,// Is exit called from text or address dialogs |
|
567 EPostcardRunAppShutterAtExit = 64, |
|
568 EPostcardLaunchSuccessful = 128, |
|
569 EPostcardClosing = 256, |
|
570 EPostcardFeatureOffline = 512 // Is offline supported |
|
571 }; |
|
572 |
|
573 enum TPostcardFocusArea |
|
574 { |
|
575 EPostcardFocusAreaGreeting = 0, |
|
576 EPostcardFocusAreaAddress, |
|
577 EPostcardFocusAreaLast |
|
578 }; |
|
579 |
|
580 enum TPostcardCloseQueryOptions |
|
581 { |
|
582 EPostcardCloseCancel, |
|
583 EPostcardCloseSave, |
|
584 EPostcardCloseDelete |
|
585 }; |
|
586 |
|
587 TInt iPocaFlags; // postcard flags |
|
588 TInt iResourceFile; // Offset of resource file |
|
589 TInt iBaseResourceFile; // Offset of editor base res file |
|
590 |
|
591 CAknNavigationControlContainer* iNaviPane; |
|
592 CAknTitlePane* iTitlePane; |
|
593 CGulIcon* iAppIcon; |
|
594 |
|
595 CMsgImageInfo* iImageInfo; // media info created by verify selection |
|
596 |
|
597 CPostcardOperation* iOperation; // current postcard operation |
|
598 CAknInputBlock* iAbsorber; // For absorbing keypresses |
|
599 CPeriodic* iIdle; // For making external exit |
|
600 CPostcardController* iController; // Postcard controller class |
|
601 |
|
602 // Global message query |
|
603 CAknGlobalMsgQuery* iMessageQuery; // Message query for confirming send operation |
|
604 HBufC* iSendText; // query text used by MsgQuery |
|
605 |
|
606 CAknWaitDialog* iWaitDialog; // wait dialog to be shown on screen |
|
607 TPostcardMsgType iMsgType; // type of postcard that is open |
|
608 CGulIcon* iImage; // image that user has inserted |
|
609 CPlainText* iGreeting; // greeting text that user has entered |
|
610 TInt iGreetingLength;// length of greeting text (excluding end separator) |
|
611 CContactCard* iContact; // recipient address that user has entered |
|
612 |
|
613 TInt iMskResource; // current middle softkey resource ID |
|
614 CPostcardCenRep* iCenRep; // central repository interface |
|
615 |
|
616 CActiveSchedulerWait iWait; |
|
617 }; |
|
618 |
|
619 #endif |
|
620 |
|
621 // End of File |