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