emailuis/emailui/inc/FreestyleEmailUiUtilities.h
branchRCL_3
changeset 25 3533d4323edc
child 26 968773a0b6ef
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 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:  General utilities for FS Email UI
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __FREESTYLEMAILUI_UTILITIES_H_
       
    20 #define __FREESTYLEMAILUI_UTILITIES_H_
       
    21 
       
    22 #include <e32base.h>	// CTimer
       
    23 #include <e32cmn.h>
       
    24 #include <hlplch.h>
       
    25 #include <msvstd.h>
       
    26 
       
    27 #include <AknQueryDialog.h>
       
    28 
       
    29 //<cmail>
       
    30 #include "mesmricalviewercallback.h"
       
    31 #include "fsccontactactionmenudefines.h"
       
    32 //</cmail>
       
    33 #include <DocumentHandler.h>
       
    34 //<cmail>
       
    35 #include "AknServerApp.h"
       
    36 //</cmail>
       
    37 
       
    38 #include "FreestyleEmailExportedUtilities.h"
       
    39 #include "FreestyleEmailUiConstants.h"
       
    40 #include "FreestyleEmailUiTextureManager.h"
       
    41 #include "FreestyleEmailUiContactHandler.h"
       
    42 
       
    43 
       
    44 class CGulIcon;
       
    45 class CFSMailBox;
       
    46 class CFSMailMessage;
       
    47 class CFSMailClient;
       
    48 class CMsvSession;
       
    49 class TPbkContactItemField;
       
    50 class CPbkContactItem;
       
    51 class CFscContactActionMenu;
       
    52 class CFscContactActionService;
       
    53 class CAlfTexture;
       
    54 class CFreestyleEmailUiTextureManager;
       
    55 class CFSMailMessagePart;
       
    56 class CFSMailAddress;
       
    57 class CFSMailFolder;
       
    58 class MAknServerAppExitObserver;
       
    59 class CFSEmailUiGenericTimer;
       
    60 class CAknGlobalNote;
       
    61 class CAknWaitDialog;
       
    62 // <cmail>
       
    63 class CESMRIcalViewer;
       
    64 // </cmail>
       
    65 
       
    66 const TInt KActionMenuItemNormalPriority = 10;
       
    67 const TInt KGenericTimerDefaultInterval = 1000;
       
    68 
       
    69 typedef RArray<TActionMenuCustomItemId> RFsEActionMenuIdList;
       
    70 
       
    71 
       
    72 enum TFollowUpNewState
       
    73 	{
       
    74 	EFollowUp = 0, // don't change, as these are the in the order they are in popup selection list
       
    75 	EFollowUpComplete = 1, // don't change
       
    76 	EFollowUpClear = 2, // don't change
       
    77 	EFollowUpNoChanges = 3
       
    78 	};
       
    79 
       
    80 enum TMessageSizeClass
       
    81     {
       
    82     ETiny = KKilo,
       
    83     ESmall = 10*KKilo,
       
    84     EMedium = 100*KKilo,
       
    85     ELarge = 500*KKilo,
       
    86     EVeryLarge = KMega,
       
    87     EHuge = 5*KMega,
       
    88     EColossal = KMaxTInt
       
    89     };
       
    90 
       
    91 class TFsEmailUiUtility
       
    92     {
       
    93 public:
       
    94     // Clean up any static variables of the class
       
    95     static void DeleteStaticData();
       
    96     
       
    97     static void LaunchHelpL( const TDesC& aContext );
       
    98     static CFSMailBox* GetMceDefaultMailboxL( CFSMailClient& aClient, CMsvSession& aMsvSession );
       
    99 
       
   100     static CFSMailBox* GetMailboxForMtmIdL( CFSMailClient& aClient, CMsvSession& aMsvSession, TMsvId aMtmId );
       
   101 
       
   102     static TBool IsRemoteLookupSupported( CFSMailBox& aMailBox );
       
   103 		
       
   104     static void CopyToClipboardL( const TDesC& aBuf );
       
   105 
       
   106     static TInt ShowConfirmationQueryL( TInt aResourceStringId, const TDesC& aResourceParameter = KNullDesC );
       
   107     static TInt ShowConfirmationQueryL( const TDesC& aPromptText );
       
   108 
       
   109     static void ShowErrorNoteL( TInt aResourceStringId, TBool aWaitingDialog = EFalse );
       
   110     static void ShowInfoNoteL( TInt aResourceStringId, TBool aWaitingDialog = EFalse );
       
   111 	
       
   112     static void ShowGlobalErrorNoteL( TInt aResourceStringId );
       
   113     static void ShowGlobalInfoNoteL( TInt aResourceStringId );
       
   114     static void ShowDiscreetInfoNoteL( TInt aResourceStringId );
       
   115     static void ShowDiscreetInfoNoteL( const TDesC& aNoteText );    
       
   116      
       
   117     /**
       
   118     * Creates and shows a local wait note. Caller must pass a member variable pointer
       
   119     * which will hold the created wait note instance. This must NOT be an automatic variable.
       
   120     */
       
   121     static void ShowWaitNoteL( CAknWaitDialog*& aDialog, TInt aTextResourceId, 
       
   122             TBool aAllowCancel, TBool aVisibilityDelayOff = EFalse );
       
   123     
       
   124     /**
       
   125     * Launches a global wait note with no CBA buttons and text from given resource.
       
   126     * A cleanup item is pushed to CleanupStack and the wait note is dismissed
       
   127     * when the PopAndDestroy() is called for it.
       
   128     * 
       
   129     * @param   aTextResourceId Resource ID of the text string to be shown in the note
       
   130     * @return  ID of the opened wait note
       
   131     */
       
   132     static TInt ShowGlobalWaitNoteLC( TInt aTextResourceId );
       
   133     static void CloseGlobalWaitNote( TAny* aNoteIdPointer );
       
   134     
       
   135     /**
       
   136     * Shows file selection dialog.
       
   137     *
       
   138     * @param aFileName Contains the selected file name on return if user
       
   139     *                  selected a file.
       
   140     * @return ETrue if user selected file, EFalse otherwise.
       
   141     */
       
   142     static TBool ShowSelectFileDialogL( TDes& aFileName );
       
   143 
       
   144     static TBool ShowSaveFolderDialogL( TDes& aFileName );
       
   145  
       
   146     /** 
       
   147     * Displays overwrite query if needed
       
   148     * 
       
   149     * @param aFilePath Path to where the file is to be saved
       
   150     * @param aAttachmentPart Message part of the attachment to be saved
       
   151     * @return ETrue if OK to save the file to a given path, EFalse if not
       
   152     */	
       
   153 	static TBool OkToSaveFileL( const TDesC& aFilePath, CFSMailMessagePart& aAttachmentPart );
       
   154 
       
   155 	static void ShowFilesSavedToFolderNoteL( TInt aCount );
       
   156 	
       
   157     static void ShowCreateMessageQueryL( const TDesC& aAddressData, TBool aSendingToEmail = EFalse );
       
   158     
       
   159     static TInt CountRecepients( CFSMailMessage* aMsgPtr );
       
   160 
       
   161     static TInt CountRecipientsSmart( CFreestyleEmailUiAppUi& aAppUi, CFSMailMessage* aMsgPtr );
       
   162 
       
   163     static TBool IsMessageBodyLargeL( CFSMailMessage* aMessage );
       
   164     
       
   165     /** 
       
   166      * Opens the given file for viewing using document handler.
       
   167      * 
       
   168      * @param aFileToOpen File to be opened for viewing. The file handle is
       
   169      *      closed after viewing.
       
   170      */
       
   171     static void OpenFileL( RFile& aFileToOpen, TBool aAllowSave  );
       
   172 
       
   173     /**
       
   174      * Opens the given file for viewing using document handler.
       
   175      *
       
   176      * @param aFileTope File to be opened for viewing. The file handle is
       
   177      *      closed after the viewing.
       
   178      * @param TDataType MIME type of the file.
       
   179      */
       
   180     static void OpenFileL( RFile& aFileToOpen, TDataType& aDataType, TBool aAllowSave );
       
   181 
       
   182     /**
       
   183      * Opens the given attachment for viewing.
       
   184      * 
       
   185      * @param aAttachmentPart The message part data that identifies the
       
   186      *      attachment to be opened.
       
   187      */
       
   188     static void OpenAttachmentL( const TPartData& aAttachmentPart );
       
   189 
       
   190     /**
       
   191     * Opens the given file for viewing using document handler.
       
   192     *
       
   193     * @param aFileTope File to be opened for viewing. The file handle is
       
   194     *      closed after the viewing.
       
   195     * @param TDataType MIME type of the file.
       
   196     * @param aAllowSave Flag to control availability of Save option in file viewer app.
       
   197     *                   When ETrue, the viewer app may show Save in options menu and/or when
       
   198     *                   closing the viewer.
       
   199     */
       
   200     static void OpenAttachmentL( CFSMailMessagePart& aAttachmentPart, TBool aAllowSave = ETrue );
       
   201 
       
   202     /**
       
   203      * SetMessageFollowupFlagL
       
   204      * 
       
   205      * @param aShowFlagCompleted Whether to show the completed flag.
       
   206      *                           When false we are in the editor view.
       
   207      */
       
   208   	static TFollowUpNewState SetMessageFollowupFlagL( CFSMailMessage& aMsg, TBool aShowFlagCompleted = ETrue ); 
       
   209     static void SetMessageFollowupStateL( CFSMailMessage& aMsg, TFollowUpNewState aNewFollowUpState ); 
       
   210     static TBool RunFollowUpListDialogL( TFollowUpNewState& aSelectedOption, TBool aShowFlagCompleted = ETrue );
       
   211 	
       
   212 	static TFileType GetFileType( const TDesC& aFileName, const TDesC& aMimeType );
       
   213 	
       
   214 	static CAlfTexture& GetAttachmentIcon( TFileType aAttachmentType, CFreestyleEmailUiTextureManager& aTextureManager );
       
   215 	static TFSEmailUiTextures GetAttachmentIconTextureId( TFileType aAttachmentType );
       
   216 	
       
   217     static CAlfTexture& GetMsgIcon( CFSMailMessage* aMsgPtr, CFreestyleEmailUiTextureManager& aTextureManager );
       
   218     static TFSEmailUiTextures GetMsgIconTextureId( CFSMailMessage* aMsgPtr );
       
   219 		
       
   220     static void MoveMessageToDraftsL( CFSMailBox& aMailBox, CFSMailMessage& aMsg );
       
   221 		
       
   222     static TBool IsMessagePartFullyFetched( const CFSMailMessagePart& aPart );
       
   223 
       
   224     static TBool IsMessageStructureKnown( const CFSMailMessagePart& aPart );
       
   225 		
       
   226     static void CreatePlainTextPartL( CFSMailMessage& aMsg, CFSMailMessagePart*& aPart );
       
   227 		
       
   228     static TBool IsCompleteOrCancelEvent( TFSProgress aEvent );
       
   229 		
       
   230     static TBool HasUnfetchedAttachmentsL( CFSMailMessage& aMsg );
       
   231 		
       
   232     static TBool IsFollowUpSupported( const CFSMailBox& aMailBox );
       
   233 		
       
   234     // Set new email message icon on/off
       
   235     static void ToggleEmailIconL( TBool aIconOn );
       
   236 	static void ToggleEmailIconL( TBool aIconOn, const TFSMailMsgId& aMailBox );
       
   237     
       
   238     static HBufC* DateTextFromMsgLC( const CFSMailMessage* aMessage,  TBool aAddYearNumer = ETrue );
       
   239     static HBufC* TimeTextFromMsgLC( const CFSMailMessage* aMessage );
       
   240     static HBufC* WeekDayTextFromMsgLC( const CFSMailMessage* aMessage, TBool aUseToday, TBool aUseYesterday,
       
   241                                         TBool& aWasToday, TBool& aWasYesterday );
       
   242     static HBufC* CreateSizeDescLC( TInt aSizeInBytes, 
       
   243                                     TBool aShowSizeInBytes = EFalse );
       
   244     static HBufC* ListMsgTimeTextFromMsgLC( const CFSMailMessage* aMessage, TBool aDividersInUse );
       
   245     static TInt CompareMailAddressesL( CFSMailAddress* aAddr1, CFSMailAddress* aAddr2 );
       
   246     static HBufC* CreateCompareNameForAddressLC( const CFSMailAddress& aAddress );
       
   247     static TInt CompareMailSubjectsL( const CFSMailMessage* aMessage1, const CFSMailMessage* aMessage2 );
       
   248     static HBufC* CreateSubjectWithoutLocalisedPrefixLC( const CFSMailMessage* aMessage, TBool aSuppressNotAvailableText = EFalse );
       
   249     static HBufC* CreateSubjectTextLC( const CFSMailMessage* aMessage );
       
   250     static HBufC* CreateBodyTextLC( const CFSMailMessage* aMessage );
       
   251     static void FilterListItemTextL( TDes& aText );
       
   252     static TMessageSizeClass MessageSizeClass( const CFSMailMessage& aMessage );
       
   253         
       
   254     static HBufC* ConvertHtmlToTxtL( const TDesC& aHtml );
       
   255 		
       
   256     static void DisplayMsgsMovedNoteL( TInt aMsgCount, 
       
   257                                        const TFSMailMsgId aDestinationFolderId,
       
   258                                        TBool aIsWaitingNote );
       
   259 
       
   260     static TBool IsOfflineModeL();
       
   261 			
       
   262     /**
       
   263     * Shows mailbox creation query:
       
   264     * "No e-mail mailboxes defined. Create a mailbox?"
       
   265     *
       
   266     * @return ETrue if user answered "Yes", EFalse if user answered "No"
       
   267     */
       
   268     static TBool DisplayCreateMailboxQueryL();
       
   269     
       
   270 //	static CAlfTexture& GetAttachmentIconL( TFileType aAttachmentType, CFreestyleEmailUiTextureManager& aTextureManager );
       
   271 //	static TFSEmailUiTextures GetAttachmentIconTextureIdL( TFileType aAttachmentType );
       
   272 
       
   273     // Brings Freestyle Email UI application to foreground if it's not already
       
   274     static void BringFsEmailToForeground();
       
   275   
       
   276     // Formats display name
       
   277 	static void StripDisplayName( HBufC& aDisplayName );
       
   278 
       
   279     // Creates a displayname of firstname and lastname components
       
   280     static HBufC* CreateDisplayNameLC( const TDesC& aFirstname, const TDesC& aLastname );
       
   281 
       
   282     // Creates a displayname of firstname, lastname, emailfield components
       
   283     static HBufC* CreateDisplayNameLC( const TDesC& aFirstname, const TDesC& aLastname, const TDesC& aEmailField );
       
   284     
       
   285     /**
       
   286      * Determines if the descriptor is a Chinese word
       
   287      */
       
   288     static TBool IsChineseWord( const TDesC& aWord );
       
   289     
       
   290     // Get the icon file name including the drive letter and full path
       
   291     static void GetFullIconFileNameL( TDes& aFileName );
       
   292     
       
   293     // Check if given file names have the same file extension (omitting the character case)
       
   294     static TBool DoFileExtensionsMatchL( const TDesC& aFileName1, const TDesC& aFileName2 );
       
   295     
       
   296     /**
       
   297      * Makes a copy of given file to the temp directory of FsEmailUI. 
       
   298      * Caller is reponsible of closing the returned file handle.
       
   299      */
       
   300     static RFile CopyFileToTempDirL( const RFile& aSourceFile, const TDesC& aTargetFileName );
       
   301     
       
   302     // Deletes all files from our temporary directory
       
   303     static void EraseTempDir();
       
   304     
       
   305     // Checks if FSMailServer is running. If not, then launches it.
       
   306     static void EnsureFsMailServerIsRunning( RWsSession& aWsSession );
       
   307     
       
   308     //
       
   309     static void SetDownloadSave( TBool aValue );    
       
   310     //
       
   311     static void SetSaveSelect( TBool aValue );      
       
   312 private:
       
   313     static TFSEmailUiTextures GetReadMsgIcon( CFSMailMessage* aMsgPtr );
       
   314     static TFSEmailUiTextures GetUnreadMsgIcon( CFSMailMessage* aMsgPtr );
       
   315     // <cmail>
       
   316     static TBool IsMrCancellationMsgL( CFSMailMessage* aMsgPtr );
       
   317     // </cmail>
       
   318       		
       
   319     /**
       
   320      * Get EmailUI temp directory path. Creates the directory if it does not exist.
       
   321      * Caller must supply large enough descriptor. Maximum path length in Symbian is 256 characters.
       
   322      */
       
   323     static void GetTempPathL( RFs& aFs, TDes& aPath );    
       
   324 
       
   325     /**
       
   326      * Show "save to folder" or "select file" dialog.
       
   327      * @param   aType       Dialog type as defined in enumeration TCommonDialogType
       
   328      * @param   aFileName   Output argument for the selected file/folder name
       
   329      * @return  ETrue       if file/folder selected (i.e. dialog not cancelled)
       
   330      */
       
   331     static TBool ShowFileDialogL( TInt aType, TDes& aFileName );
       
   332 
       
   333     // Checks if FSMailServer is running. If not, then launches it.
       
   334     static void EnsureFsMailServerIsRunningL( RWsSession& aWsSession );
       
   335 
       
   336 private: // static data
       
   337     static CAknGlobalNote* iGlobalWaitNote;
       
   338     static CAknWaitDialog* iOpeningWaitNote;
       
   339     static TBool iSaveSelect;
       
   340     static TBool iDownloadSave;
       
   341     
       
   342     // <cmail>
       
   343     // A separate MR viewer instance for checking the MR method type.
       
   344     // The instance owned by AppUi can't be used for this because that instance
       
   345     // may be in use at time we need to check the method.
       
   346     static CESMRIcalViewer* iMrViewer;
       
   347     
       
   348     class CMrViewerEmptyCallback : public CBase, public MESMRIcalViewerCallback
       
   349         {
       
   350         virtual void ProcessAsyncCommandL( TESMRIcalViewerOperationType, const CFSMailMessage&, MESMRIcalViewerObserver* ) {}
       
   351         virtual void ProcessSyncCommandL( TESMRIcalViewerOperationType, const CFSMailMessage& ) {}
       
   352         virtual TBool CanProcessCommand( TESMRIcalViewerOperationType ) const { return EFalse; }
       
   353         };
       
   354     static CMrViewerEmptyCallback* iMrViewerCallback;
       
   355     // </cmail>
       
   356     };
       
   357 
       
   358 /**
       
   359 *  Action menu handler
       
   360 *
       
   361 *  Is constructed in CFreestyleEmailUiAppUi when application is launched.
       
   362 *  After that the static functions can be used to operate with action menu.
       
   363 *
       
   364 */
       
   365 class CFSEmailUiActionMenu : public CBase
       
   366     {
       
   367 	friend class CFreestyleEmailUiAppUi;
       
   368 public:
       
   369     /**
       
   370     * Get pointer to the action menu, can be used if built-in methods are
       
   371     * not enough. Ownership is not transferred.
       
   372     *
       
   373     * @return Action menu pointer
       
   374     */
       
   375     static CFscContactActionMenu* GetActionMenu();
       
   376 		
       
   377     /**
       
   378     * Remove all items from action menu
       
   379     */
       
   380     static void RemoveAllL();
       
   381 		
       
   382     /**
       
   383     * Add one email specific custom item by id
       
   384     *
       
   385     * @param aItemId Item id of the item to be added
       
   386     */
       
   387     static void AddCustomItemL( TActionMenuCustomItemId aItemId );
       
   388 		
       
   389     /**
       
   390     * Add several email specific custom items by list of ids
       
   391     *
       
   392     * @param aItemList List of item ids to be added
       
   393     */
       
   394     static void AddCustomItemsL( RFsEActionMenuIdList aItemList );
       
   395 
       
   396 	// <cmail>
       
   397     /**
       
   398     * Execute previously constructed action menu
       
   399     *
       
   400     * @param aPosition Vertical position where menu is to be openned
       
   401     * @param aIndex Index of focused/highlighted item when menu is opened
       
   402     * @return Id of the selected item
       
   403     */
       
   404     static TActionMenuCustomItemId ExecuteL( TFscContactActionMenuPosition aPosition = EFscCenter,
       
   405                                              TInt aIndex = 0, MFsActionMenuPositionGiver* aPositionGiver = 0 );
       
   406     /**
       
   407     * Remove all old items, add new items from the aItemList and then
       
   408     * execute the action menu
       
   409     *
       
   410     * @param aItemList List of item ids to be added
       
   411     * @param aPosition Vertical position where menu is to be openned
       
   412     * @param aIndex Index of focused/highlighted item when menu is opened
       
   413     * @return Id of the selected item
       
   414     */
       
   415     // 
       
   416     static TActionMenuCustomItemId ExecuteL( RFsEActionMenuIdList aItemList,
       
   417                                              TFscContactActionMenuPosition aPosition = EFscCenter,
       
   418                                              TInt aIndex = 0, MFsActionMenuPositionGiver* aPositionGiver = 0 );
       
   419 	
       
   420     /**
       
   421     * Dismiss menu
       
   422     *   Menu gets closed if it was visible when the method was called. 
       
   423     *   Otherwise method call does not do anything
       
   424     *
       
   425     * @param aSlide If ETrue menu slides away from the screen. 
       
   426     *   Otherwise it disappears instantly
       
   427     */
       
   428 	static void Dismiss( TBool aSlide );
       
   429     // </cmail> 
       
   430 		
       
   431     /**
       
   432     * Create icon by bitmap and mask
       
   433     *
       
   434     * @param aBitmapId Icon bitmap
       
   435     * @param aMaskId Icon mask
       
   436     * @return Created icon object
       
   437     */
       
   438     static CGulIcon* CreateIconL( TInt aBitmapId, TInt aMaskId );
       
   439 
       
   440 protected:
       
   441     static CFSEmailUiActionMenu* NewL( CFreestyleEmailUiAppUi* aAppUi );
       
   442     ~CFSEmailUiActionMenu();
       
   443 
       
   444 private:
       
   445     CFSEmailUiActionMenu( CFreestyleEmailUiAppUi* aAppUi );
       
   446     void ConstructL();
       
   447         
       
   448     static TActionMenuCustomItemId ResolveSelectedCustomItemIdL();
       
   449     static void CreateIconsL();
       
   450         
       
   451 private:
       
   452     CFscContactActionService* iService;   
       
   453     static CFscContactActionMenu* iActionMenu;
       
   454     static TFileName iIconFilePath;
       
   455     static RPointerArray<CGulIcon> iIconArray;
       
   456     CFreestyleEmailUiAppUi* iAppUi;
       
   457 	};
       
   458 
       
   459 /**
       
   460 *  Generic timer's callback
       
   461 *
       
   462 *  Classes inherited from this one can be used as a callback for the generic
       
   463 *  timer. TimerEvent() is called when the timer elapses.
       
   464 *
       
   465 */
       
   466 class MFSEmailUiGenericTimerCallback
       
   467     {
       
   468 public:
       
   469     /**
       
   470      * @param   aTriggeredTimer The timer which launched this event.
       
   471      */
       
   472     virtual void TimerEventL( CFSEmailUiGenericTimer* aTriggeredTimer ) = 0;
       
   473     };
       
   474 
       
   475 /**
       
   476 *  Generic timer
       
   477 *
       
   478 *  Caller gives MFSEmailUiGenericTimerCallback inherited pointer as a
       
   479 *  parameter, and that pointer is used as a callback when the timer elapses.
       
   480 *  Timer interval is given as a parameter for the Start function. If interval
       
   481 *  not given, or it is less than zero, default interval of 1 second is used.
       
   482 *
       
   483 */
       
   484 class CFSEmailUiGenericTimer : public CTimer
       
   485     {
       
   486 public:
       
   487     
       
   488     /**
       
   489     * Symbian two-pahse constructor.
       
   490     *
       
   491     * @param aCallback Callback class
       
   492     * @param aPriority Timers priority, EPriorityStandard by default
       
   493     */
       
   494     static CFSEmailUiGenericTimer* NewL(
       
   495         MFSEmailUiGenericTimerCallback* aCallback,
       
   496         const TInt aPriority = CActive::EPriorityStandard );
       
   497 
       
   498     /**
       
   499     * Symbian two-pahse constructor.
       
   500     *
       
   501     * @param aCallback Callback class
       
   502     * @param aPriority Timers priority, EPriorityStandard by default
       
   503     */
       
   504     static CFSEmailUiGenericTimer* NewLC(
       
   505         MFSEmailUiGenericTimerCallback* aCallback,
       
   506         const TInt aPriority = CActive::EPriorityStandard );
       
   507         
       
   508     /**
       
   509     * Destructor.
       
   510     */
       
   511     ~CFSEmailUiGenericTimer();
       
   512         
       
   513     /**
       
   514     * Starts the timer with specified interval, or with the default value.
       
   515     *
       
   516     * NOTE: Give time in milliseconds (not microseconds)!
       
   517     *
       
   518     * @param aInterval Timer interval as milliseconds
       
   519     */
       
   520     void Start( TInt aInterval = KGenericTimerDefaultInterval );
       
   521 
       
   522     /**
       
   523     * Stops the timer.
       
   524     */
       
   525     void Stop();
       
   526 
       
   527     /**
       
   528     * CActive object's RunL
       
   529     */
       
   530     void RunL();
       
   531         
       
   532 protected:
       
   533     /**
       
   534     * Constructor.
       
   535     */
       
   536     CFSEmailUiGenericTimer( MFSEmailUiGenericTimerCallback* aCallback,
       
   537                             const TInt aPriority );
       
   538 		
       
   539 private:
       
   540     /**
       
   541     * 2nd phase constructor.
       
   542     */
       
   543     void ConstructL();
       
   544 
       
   545 private:
       
   546     /* Pointer to callback class */
       
   547     MFSEmailUiGenericTimerCallback* iCallback;
       
   548     };
       
   549 
       
   550 
       
   551 /**
       
   552  * File handle shutter.
       
   553  * 
       
   554  * Instance of file handle shutter can be set to handle the closing of an open
       
   555  * file handle on embedded viewer application exit.
       
   556  */
       
   557 class CFsEmailFileHandleShutter : public CBase,
       
   558     public MAknServerAppExitObserver
       
   559     {
       
   560 public:
       
   561 
       
   562     /**
       
   563      * Two-phased constuctor. Creates an instance of CFsEmailFileHandleShutter
       
   564      * which is set to observe embedded application close events delegated
       
   565      * by the given document handler.
       
   566      * 
       
   567      * @param Reference to document handler instance, which the file handle
       
   568      *      shutter is set to observe. 
       
   569      */
       
   570     static CFsEmailFileHandleShutter* NewL(
       
   571         CDocumentHandler& aDocumentHandler );
       
   572 
       
   573     /**
       
   574      * Destructor.
       
   575      */
       
   576     ~CFsEmailFileHandleShutter();
       
   577 
       
   578     /**
       
   579      * Sets the file handle that is to be closed when viewer app exits.
       
   580      *
       
   581      * @param aFile The file handle.
       
   582      */
       
   583     void SetFile( RFile aFile );
       
   584 
       
   585 // from base class MAknServerAppExitObserver
       
   586 
       
   587     /**
       
   588      * Handle the exit of a connected server app.
       
   589      * 
       
   590      * @param aReason The reason that the server application exited.
       
   591      * This will either be an error code, or the command id that caused the
       
   592      * server app to exit.
       
   593      */
       
   594     void HandleServerAppExit( TInt aReason );
       
   595 
       
   596 private:
       
   597 
       
   598     /** Default constructor. */
       
   599     CFsEmailFileHandleShutter();
       
   600 
       
   601     /** Second phase constructor. */
       
   602     void ConstructL( CDocumentHandler& aDocumentHandler );
       
   603 
       
   604 private: // data
       
   605 
       
   606     TBool iHandleOpen;
       
   607     RFile iFileHandle;
       
   608 
       
   609     };
       
   610 
       
   611 class CFSEmailUiCallDialog : public CAknQueryDialog
       
   612     {
       
   613 public:
       
   614     TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType);
       
   615     };
       
   616 
       
   617 #endif /*__FREESTYLEMAILUI_UTILITIES_H_*/