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