meetingrequest/mrgui/mrfieldbuilderplugin/inc/cmrattachmentcommandhandler.h
branchRCL_3
changeset 12 4ce476e64c59
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
       
     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:  MR Attachment field for editor and viewer
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMRATTACHMENTCOMMANDHANDLER_H
       
    20 #define CMRATTACHMENTCOMMANDHANDLER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <bamdesca.h>
       
    24 
       
    25 #include "esmrdef.h"
       
    26 #include "mcalremoteattachmentoperationobserver.h"
       
    27 
       
    28 // Forward declarations
       
    29 class CCalEntry;
       
    30 class CESMRRichTextLink;
       
    31 class CCalRemoteAttachmentApi;
       
    32 class CCalRemoteAttachmentInfo;
       
    33 class CDocumentHandler;
       
    34 class MESMRFieldEventQueue;
       
    35 class CMRAttachmentCommand;
       
    36 
       
    37 /**
       
    38  * CMRAttachmentCommandHandler is responsible for handling attachment
       
    39  * related commands.
       
    40  */
       
    41 NONSHARABLE_CLASS( CMRAttachmentCommandHandler ):
       
    42         public CBase,
       
    43         public MCalRemoteAttachmentOperationObserver
       
    44 
       
    45     {
       
    46 public: // Construction and destructions
       
    47 
       
    48     /**
       
    49      * Creates and initializes new CMRAttachmentCommandHandler object.
       
    50      * Ownership is transferred to caller.
       
    51      * @param aEntry Reference to calendar entry
       
    52      */
       
    53     static CMRAttachmentCommandHandler* NewL(
       
    54             CCalEntry& aEntry,
       
    55             MESMRFieldEventQueue& aEventQueue );
       
    56 
       
    57     /**
       
    58      * C++ destructor
       
    59      */
       
    60     ~CMRAttachmentCommandHandler();
       
    61 
       
    62 public: // Interface
       
    63 
       
    64     /**
       
    65      * Handles attachment related command for currently selected
       
    66      * attachment link.
       
    67      * @param aCommandId Defines the command to be executed
       
    68      * @param aSelectedLink Reference to selected link.
       
    69      */
       
    70     void HandleAttachmentCommandL(
       
    71             TInt aCommandId,
       
    72             const CESMRRichTextLink& aSelectedLink );
       
    73 
       
    74     /**
       
    75      * Tests whether curerntly selected link is remote or not.
       
    76      * @param aSelectedLink Reference to selected link.
       
    77      * @return ETrue, if currently selected link is remote attachment
       
    78      */
       
    79     TBool IsRemoteAttachmentL(
       
    80             const CESMRRichTextLink& aSelectedLink );
       
    81 
       
    82     /**
       
    83      * Sets remote attachment API information for the command handler.
       
    84      * @param aRemoteaAttaApi Reference to remote attachment API
       
    85      * @param aAttachmentInfo Reference to attachment information structure
       
    86      */
       
    87     void SetRemoteAttachmentInformationL(
       
    88             CCalRemoteAttachmentApi& aRemoteAttaApi,
       
    89             CCalRemoteAttachmentInfo& aAttachmentInfo );
       
    90 
       
    91     /**
       
    92      * Handles remote attachment command.
       
    93      * @param aCommandId Defines the command to be executed
       
    94      * @param aSelectedLink Reference to selected link.
       
    95      */
       
    96     void HandleRemoteAttachmentCommandL(
       
    97             TInt aCommandId,
       
    98             const CESMRRichTextLink& aSelectedLink );
       
    99 
       
   100     /**
       
   101      * Fetches reference to remote operations
       
   102      * @return REference to download operation list.
       
   103      */
       
   104     RPointerArray<MCalRemoteAttachmentOperation>& RemoteOperations();
       
   105 
       
   106     /**
       
   107      * Returns the current command id in progress.
       
   108      * @return current command id or 0
       
   109      */
       
   110     TInt CurrentCommandInProgress() const;
       
   111 
       
   112 private: // From MCalRemoteAttachmentOperationObserver
       
   113     void Progress(
       
   114              MCalRemoteAttachmentOperation* aOperation,
       
   115              TInt aPercentageCompleted );
       
   116     void OperationCompleted(
       
   117             MCalRemoteAttachmentOperation* aOperation,
       
   118             RFile& aAttachment );
       
   119     void OperationError(
       
   120             MCalRemoteAttachmentOperation* aOperation,
       
   121             TInt aErrorCode );
       
   122 
       
   123 private: // Implementation
       
   124     CMRAttachmentCommandHandler(
       
   125             CCalEntry& aEntry,
       
   126             MESMRFieldEventQueue& aEventQueue );
       
   127     void ConstructL();
       
   128     TInt ResolveAttachmentIndexL(
       
   129             const TDesC& aAttachmentLabel );
       
   130     TInt CommandIndex( const TDesC& aAttachmentLabel );
       
   131     TInt RemoteAttachmentIndexL(
       
   132             const TDesC& aAttachmentLabel );
       
   133     void HandleOperationCompletedL(
       
   134             MCalRemoteAttachmentOperation* aOperation,
       
   135             RFile& aAttachment );
       
   136     void HandleAttachmentCommandInternalL(
       
   137                 TInt aCommandId,
       
   138                 TInt aAttachmentIndex );
       
   139     void UpdateLocalAttachmentL(
       
   140             const TDesC& aAttachmentLabel,
       
   141             RFile& aAttachment,
       
   142             TInt aAttachmentIndex );
       
   143     void NotifyProgressL(
       
   144             const TDesC& aAttachmentLabel,
       
   145             TInt aPercentageCompleted );
       
   146     void HandleRemoteAttachmentCommandInternalL(
       
   147             TInt aCommandId,
       
   148             const TDesC& aRemoteAttachmentLabel );
       
   149     void HideDownloadIndicatorL();
       
   150     void ExecuteCommandL(
       
   151             TInt aCommandId,
       
   152             CMRAttachmentCommand& aCommand,
       
   153             TInt aAttachmentIndex );
       
   154     void SaveAllAttachmentsL();
       
   155     void SaveNextRemoteAttachmentL();
       
   156 
       
   157 private: // Data
       
   158     /// Ref: Reference to calendar entry
       
   159     CCalEntry& iEntry;
       
   160     /// Ref: Remote attachment API
       
   161     CCalRemoteAttachmentApi* iRemoteAttachmentApi;
       
   162     /// Ref: Remote attachment info
       
   163     CCalRemoteAttachmentInfo* iAttachmentInfo;
       
   164     /// Own: Download operation
       
   165     RPointerArray<MCalRemoteAttachmentOperation> iDownloadOperations;
       
   166     /// Own: Remote command in progress
       
   167     TInt iCommandInProgress;
       
   168     /// Own: Document handler
       
   169     CDocumentHandler* iDocHandler;
       
   170     /// Ref: Event queue
       
   171     MESMRFieldEventQueue& iEventQueue;
       
   172     };
       
   173 
       
   174 #endif // CMRATTACHMENTCOMMANDHANDLER_H
       
   175 
       
   176 // EOF