calendarui/controller/inc/calenattachmentui.h
changeset 0 f979ecb2b13e
child 28 96907930389d
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CALENATTACHMENTUI_H
       
    19 #define CALENATTACHMENTUI_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <MMGFetchVerifier.h>
       
    23 #include <MAknFileSelectionObserver.h>
       
    24 #include <AknWaitNoteWrapper.h>
       
    25 #include <ConeResLoader.h>
       
    26 #include <calencommandhandler.h>
       
    27 #include <calencommands.hrh>
       
    28 #include <calennotificationhandler.h>
       
    29 
       
    30 #include "calenattachmentutils.h"
       
    31 #include "calenattachmentmodel.h"
       
    32 
       
    33 class CCalenController;
       
    34 class MCalenCommandHandler;
       
    35 class CCalenViewAttachmentsDialog;
       
    36 class TContentProtection;
       
    37 
       
    38 #include <AknServerApp.h>
       
    39 /**
       
    40  * Handles attachment related commands
       
    41  */
       
    42 class CCalenAttachmentUi : public CBase,
       
    43                            public MCalenCommandHandler,
       
    44                            public MCalenNotificationHandler,
       
    45                            public MMGFetchVerifier,
       
    46                            public MAknFileSelectionObserver,
       
    47                            public MCalenAttachmentModelObserver,
       
    48                            public MProgressDialogCallback
       
    49     {
       
    50     public:
       
    51         
       
    52         /**
       
    53          * First phase constructor
       
    54          * 
       
    55          * @param aController A reference to calencontroller
       
    56          * @return pointer to CCalenAttachmentUi
       
    57          */
       
    58         static CCalenAttachmentUi* NewL( CCalenController& aController );
       
    59         
       
    60         /**
       
    61          * Virtual destructor
       
    62          */
       
    63         virtual ~CCalenAttachmentUi();
       
    64 
       
    65     private:
       
    66         
       
    67         /**
       
    68          * C++ constructor, non-leaving
       
    69          * 
       
    70          * @param aController A reference to the calencontroller
       
    71          */
       
    72         CCalenAttachmentUi(CCalenController& aController);
       
    73         
       
    74         /**
       
    75          * 2nd phase constructor
       
    76          */
       
    77         void ConstructL();
       
    78         
       
    79         void CheckDRMStatus(const TDesC& aFileName,TBool& aProtection);
       
    80         
       
    81     public:
       
    82         
       
    83         /**
       
    84          * From MCalenCommandHandler
       
    85          * Handles the attachement commands
       
    86          * 
       
    87          * @param aCommand Command to be handled
       
    88          * @return returns whether command is successfully handled or not
       
    89          */
       
    90         TBool HandleCommandL(const TCalenCommand& aCommand);
       
    91         
       
    92         /**
       
    93          * From MCalenCommandHandler.
       
    94          * Allows extending this API without breaking BC.
       
    95          * 
       
    96          * @param aExtensionUid specifies
       
    97          * @return extension of the requested type
       
    98          */
       
    99         TAny* CalenCommandHandlerExtensionL( TUid aExtensionUid );
       
   100         
       
   101         /** 
       
   102          * From MCalenNotificationHandler
       
   103          * Handle notifications
       
   104          * 
       
   105          * @param aNotification Nofication to be handled
       
   106          */
       
   107         void HandleNotification(const TCalenNotification aNotification );
       
   108         
       
   109         /**
       
   110          * From MMGFetchVerifier
       
   111          * Interface for verifying fetch file selection
       
   112          * 
       
   113          * @param aSelectedFiles Holds the list of selected files
       
   114          * @return TBool returns whether file is selected or not
       
   115          */
       
   116         TBool VerifySelectionL(const MDesCArray* aSelectedFiles);
       
   117         
       
   118         /**
       
   119          * From MAknFileSelectionObserver
       
   120          * Get's called when user selects an file.
       
   121          * 
       
   122          * @param aDriveAndPath Drive and full path of the file.
       
   123          * @param aEntry An entry containing all information of selected item.
       
   124          * @return Returns ETrue if it is ok to exit from dialog.
       
   125          */
       
   126         TBool OkToExitL( const TDesC& aDriveAndPath, const TEntry& aEntry );
       
   127         
       
   128         /**
       
   129          * From MCalenAttachmentModelObserver
       
   130          * This function that is called when attachment model adds or removes
       
   131          * attachments from its list.
       
   132          *
       
   133          * @param aCommand TCalenAttachmentCommand whether attachment is added
       
   134          *                 or removed 
       
   135          * @param attachmentIndex index of the attachment info
       
   136         */
       
   137         void NotifyChanges( TCalenAttachmentCommand aCommand ,
       
   138                           TInt aAttachmentIndex );
       
   139         
       
   140         /**
       
   141          * From MCalenAttachmentModelObserver
       
   142          * This function that is called when attachment model needs to
       
   143          * get access to an attachment file
       
   144          * 
       
   145          * @param aIndex index of the attachment file
       
   146          * @return returns the file handle
       
   147          */
       
   148         RFile GetAttachmentFileL(TInt aIndex);
       
   149         
       
   150         /**
       
   151          * From MProgressDialogCallback
       
   152          * 
       
   153          * called when dialog is dismissed
       
   154          */
       
   155         void DialogDismissedL( TInt aButtonId );
       
   156 
       
   157     private:
       
   158         
       
   159         /**
       
   160          * Used to fetch the attachment
       
   161          *
       
   162          * @param aFetchType, EImage,ENote,EAudio,EVideo
       
   163          * @return TBool returns ETrue if file is fetched successfully
       
   164          * otherwise returns EFalse
       
   165          */
       
   166         TBool FetchFileL( 
       
   167                 CCalenAttachmentUtils::TCalenAttachmentFileType aFetchType);
       
   168         
       
   169         /**
       
   170          * Handles ECalenAddAttachment command 
       
   171          */
       
   172         void HandleAddAttachmentL();
       
   173         
       
   174         /**
       
   175          * Check for esisting attachments from the calentry     
       
   176          */
       
   177         void CheckForExistingAttachmentsL();
       
   178         
       
   179         /**
       
   180          * Copy fetched files from gallery/notes in to temporary folder
       
   181          * 
       
   182          * @param aTempPath 
       
   183          * @param aSourceFilePath
       
   184          */
       
   185         void CopyFetchedFilesL( TFileName& aTempPath, const TDesC& aSourceFilePath);
       
   186        
       
   187         /**
       
   188          * Add an attachment based on the file path
       
   189          * 
       
   190          * @param aSourcepath path of the file being attached
       
   191          */
       
   192         void AddAttachmentL(const TDesC& aSourceFilePath);
       
   193         
       
   194         /**
       
   195          * Remove the attachment from the calendar entry
       
   196 
       
   197          * @param aAttachmentIndex index of the attachment to be rmeoved 
       
   198          */
       
   199         void RemoveAttachmentFromEntryL(TInt aAttachmentIndex);
       
   200         
       
   201         /**
       
   202          * Add attachments to the calendar entry
       
   203          */
       
   204         void AddAttachmentsToEntryL();
       
   205         
       
   206         /** 
       
   207          * Handle notifications
       
   208          * 
       
   209          * @param aNotification Nofication to be handled
       
   210          */
       
   211         void DoHandleNotificationL(const TCalenNotification aNotification );
       
   212         
       
   213         /**
       
   214          * Handles ECalenViewAttachmentList command 
       
   215          */
       
   216         void DoAttachmentL();
       
   217         
       
   218         /**
       
   219          * Show wait note
       
   220          */
       
   221         void ShowWaitNoteL( TBool aCanCancel );
       
   222         
       
   223         /**
       
   224          * Compares the names of attachment being alredy added to editor, and 
       
   225          * the other one which user is trying to add now.
       
   226          */
       
   227         TBool IsDuplicateNameL(const TDesC& aSelectedFile);
       
   228         
       
   229         /**
       
   230          * Compares the binary data for the text files.
       
   231          */
       
   232         TBool CompareContentOfTextFiles(const TDesC& aSelectedFile,const TDesC& aAlreadyAttachedFile);
       
   233         
       
   234         /**
       
   235          * Remove the temporary file after attaching the attachtment to tht entry.
       
   236          */
       
   237         void RemoveTemporaryFiles();
       
   238         
       
   239     private:
       
   240         
       
   241         // reference to the calencontroller
       
   242         CCalenController& iController;
       
   243         CCalenAttachmentModel* iAttachmentModel;
       
   244         //own: attachment dilalog title
       
   245         HBufC* iTitle;
       
   246         //Not owned
       
   247         CCalenViewAttachmentsDialog* iAttachmentdlg;
       
   248         
       
   249         // Internal Flag
       
   250         TBool iAttachmentLoadingOn;
       
   251         
       
   252         // Own: Wait dialog
       
   253         CAknWaitDialog* iWaitDialog;
       
   254         
       
   255         TInt iSelectedCommand;         //command used to differntiate between the type of attachment user is trying to add. 
       
   256         TBool iAddAttachmentFromViewer;//shows attachment got added from attachment list view.
       
   257         TBool iShowToolbar;            //To update the toolbar visiblity.
       
   258         TBool iViewerActive;           //To avoid the problem of status pane change.
       
   259         TBool iSFound;                 //To check wether name is duplicated or not.
       
   260         TBool iAttachmentAlreadyExists;
       
   261         TBool iAttachmentInfoIntialized;
       
   262     };
       
   263 
       
   264 #endif // CALENATTACHMENTUI_H