mobilemessaging/unieditor/application/inc/UniEditorProcessImageOperation.h
changeset 0 72b543305e3a
child 24 696bfeff199e
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006,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:   CUniEditorProcessImageOperation class definition.      
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __UNIEDITORPROCESSIMAGEOPERATION_H
       
    21 #define __UNIEDITORPROCESSIMAGEOPERATION_H
       
    22 
       
    23 // INCLUDES
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <msvapi.h>
       
    27 
       
    28 #include <uniobject.h>
       
    29 #include <uniimageprocessor.h>
       
    30 #include <cmsvattachment.h>
       
    31 
       
    32 #include "UniEditorOperation.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 
       
    36 class CMsgImageInfo; 
       
    37 class CMsgImageControl;
       
    38 class CUniEditorDocument;
       
    39 class MMsvAttachmentManager;
       
    40 class CMsvStore;
       
    41 
       
    42 // DATA TYPES
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 /**
       
    47 * CUniEditorProcessImageOperation
       
    48 *
       
    49 * @since 3.2
       
    50 */
       
    51 class CUniEditorProcessImageOperation : public CUniEditorOperation,
       
    52                                         public MUniImageProcessorCallback
       
    53     {
       
    54     public: // new operations
       
    55 
       
    56         /**
       
    57         * Factory method
       
    58         */
       
    59         static CUniEditorProcessImageOperation* NewL( 
       
    60             MUniEditorOperationObserver& aObserver,
       
    61             CUniEditorDocument& aDocument,
       
    62             RFs& aFs );
       
    63 
       
    64         /**
       
    65         * Start image process operation
       
    66         *
       
    67         * @param aImageInfo
       
    68         * @param aAttachmentId  Attachment id, if the image is already stored as an attachment
       
    69         *                       KMsvNullIndexEntryId, otherwise.
       
    70         * @param aMessageSize
       
    71         */
       
    72         void Process( CMsgImageInfo* aImageInfo, TMsvAttachmentId aAttachmentId, TInt aMessageSize );
       
    73 
       
    74         /**
       
    75         * Destructor
       
    76         */
       
    77         virtual ~CUniEditorProcessImageOperation();
       
    78 
       
    79         /**
       
    80         * Detaches image info object.
       
    81         */
       
    82         CMsgImageInfo* DetachImageInfo();
       
    83 
       
    84         /**
       
    85         * Detaches attachment id.
       
    86         */
       
    87         void DetachAttachmentId( TMsvAttachmentId& aAttachmentId );
       
    88 
       
    89     protected:
       
    90 
       
    91         /**
       
    92         * From CActive
       
    93         */
       
    94         void RunL();
       
    95 
       
    96         /**
       
    97         * From CActive
       
    98         */
       
    99         TInt RunError( TInt aError );
       
   100         
       
   101         /**
       
   102         * From CUniEditorOperation
       
   103         */
       
   104         void DoCancelCleanup();
       
   105         
       
   106         /**
       
   107         * From MUniImageProcessorCallback
       
   108         */
       
   109         void ImageProcessingReady( TSize aBitmapSize, TInt aFileSize, TBool aCompressed );
       
   110         
       
   111     private: // new operations
       
   112 
       
   113         /**
       
   114         * C++ constructor
       
   115         */
       
   116         CUniEditorProcessImageOperation( MUniEditorOperationObserver& aObserver,
       
   117                                          CUniEditorDocument& aDocument,
       
   118                                          RFs& aFs );
       
   119 
       
   120         /**
       
   121         * 2nd phase constructor.
       
   122         */
       
   123         void ConstructL();
       
   124 
       
   125         /**
       
   126         * Returns optimal send image size.
       
   127         */
       
   128         TSize ImageSendSize() const;
       
   129 
       
   130         /**
       
   131         * Checks whether some processing is needed for the image.
       
   132         * Stores the possible processing method to "iProcessMethod".
       
   133         *
       
   134         * @return EFalse if aborted by user,
       
   135         *         ETrue  otherwise
       
   136         */
       
   137         TBool CheckNeedToProcess();
       
   138 
       
   139         /**
       
   140         * Creates empty attachment.
       
   141         */
       
   142         void CreateEmptyAttachmentL();
       
   143 
       
   144         /**
       
   145         * Start check step.
       
   146         */
       
   147         void DoStartCheck();
       
   148 
       
   149         /**
       
   150         * Start process step.
       
   151         */
       
   152         void DoStartProcessL();
       
   153 
       
   154         /**
       
   155         * Start resolve step.
       
   156         */
       
   157         void DoStartResolveL();
       
   158 
       
   159         /**
       
   160         * Processing ready.
       
   161         */
       
   162         void DoReady();
       
   163 
       
   164         /**
       
   165         * Performs error handling without state change.
       
   166         */
       
   167         void DoErrorWithoutStateChange();
       
   168         
       
   169         /**
       
   170         * Opens file by file name. If it fails with KErrPermissionDenied,
       
   171         * file is searched from message store and opened from there        
       
   172         */
       
   173         RFile OpenFileForReadingL();
       
   174         
       
   175     private: // data
       
   176 
       
   177         enum TUniProcessStates
       
   178             {
       
   179             EUniProcessImgCheck,
       
   180             EUniProcessImgProcess,
       
   181             EUniProcessImgResolve,
       
   182             EUniProcessImgReady,
       
   183             EUniProcessImgError
       
   184             };
       
   185 
       
   186         enum TUniProcessMethods
       
   187             {
       
   188             EUniProcessImgMethodNone        = 0x0,
       
   189             EUniProcessImgMethodScale       = 0x1,
       
   190             EUniProcessImgMethodConvert     = 0x2,
       
   191             EUniProcessImgMethodCompress    = 0x4
       
   192             };
       
   193 
       
   194         CMsgImageInfo*              iImageInfo;
       
   195         TMsvAttachmentId            iAttachmentId;
       
   196         TInt                        iMessageSize;
       
   197 
       
   198         CMsgImageInfo*              iNewImageInfo;
       
   199         RFile                       iNewImageFile;
       
   200         TMsvAttachmentId            iNewAttaId;
       
   201         CMsvStore*                  iEditStore;
       
   202     
       
   203         CUniImageProcessor*         iImageProcessor;
       
   204 
       
   205         TInt                        iProcessMethod;
       
   206 
       
   207         TSize                       iScaleSize;
       
   208         TSize                       iScaleSizeResult;
       
   209         TDataType                   iTargetType;
       
   210         TBool                       iExactImageScaling;
       
   211     };
       
   212 
       
   213 #endif //__UNIEDITORPROCESSIMAGEOPERATION_H