mobilemessaging/postcard/postcardinc/PostcardOperationInsertImage.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005 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 *       CPostcardOperationInsertImage, asynchronous operation for inserting image
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __POSTCARDOPERATIONINSERTIMAGE_H
       
    23 #define __POSTCARDOPERATIONINSERTIMAGE_H
       
    24 
       
    25 // INCLUDES
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <e32std.h>
       
    29 #include <f32file.h>
       
    30 
       
    31 #include <uniimageprocessor.h>
       
    32 
       
    33 #include <MIHLViewerObserver.h>
       
    34 
       
    35 #include "PostcardOperation.h"
       
    36 
       
    37 // CONSTANTS
       
    38 
       
    39 // MACROS
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class CMsgMediaInfo;
       
    43 class MIHLFileImage;
       
    44 class MIHLBitmap;
       
    45 class MIHLImageViewer;
       
    46 
       
    47 // DATA TYPES
       
    48 
       
    49 // FUNCTION PROTOTYPES
       
    50 
       
    51 // CLASS DECLARATION
       
    52 
       
    53 /**
       
    54 * CPostcardOperationInsertImage 
       
    55 *
       
    56 * @lib postcardeditor.exe
       
    57 * @since 3.0
       
    58 */
       
    59 class CPostcardOperationInsertImage : public CPostcardOperation,
       
    60                                       public MUniImageProcessorCallback,
       
    61                                       public MIHLViewerObserver
       
    62     {
       
    63     
       
    64     public:  // New methods
       
    65 
       
    66         /**
       
    67         * Factory method that creates this object.
       
    68         * @since    3.0
       
    69         * @param aInfo - info object of the inserted image -> operation takes the ownership
       
    70         * @return   Pointer to instance
       
    71         */
       
    72         static CPostcardOperationInsertImage* NewL(
       
    73             MPostcardOperationObserver& aObserver,
       
    74             CPostcardDocument& aDocument,
       
    75             CPostcardAppUi& aAppUi,
       
    76             CMsgImageInfo* aInfo,
       
    77             RFs& aFs );
       
    78 
       
    79         /**
       
    80         * Destructor
       
    81         */
       
    82         virtual ~CPostcardOperationInsertImage( );
       
    83 
       
    84         /**
       
    85         * Just initializes the iLaunchStep and completes
       
    86         */
       
    87 		void Start( TInt aArgument );
       
    88 
       
    89 	public: // From ImageProcessor
       
    90 	
       
    91 		/*
       
    92 		* If process was not succesfull -> sets error and completes with it,
       
    93 		* Otherwise start scaling to screen
       
    94 		*/ 
       
    95 	    void ImageProcessingReady( TSize aBitmapSize, TInt aFileSize, TBool aCompressed );
       
    96 
       
    97    protected: // From MIHLViewerObserver
       
    98         
       
    99 		/**
       
   100         * From MIHLViewerObserver Notifies client when image handler content has changed.
       
   101 		* Leave situation is handled in ViewerError() callback.
       
   102 		*
       
   103 		* Creates a duplicate of iDestinationBitmap, creates a CGulIcon of it and
       
   104 		* passes it to AppUi class
       
   105         * @return void
       
   106 		*/
       
   107 		void ViewerBitmapChangedL();
       
   108 
       
   109         /**
       
   110         * From MIHLViewerObserver Notifies client if error occurs in viewer.
       
   111         * 
       
   112         * @param aError     IN  System wide error code.
       
   113         *
       
   114         * @return void
       
   115 		*/
       
   116 		void ViewerError( TInt aError );
       
   117 
       
   118     private:
       
   119 
       
   120         /**
       
   121         * Called by RunL.
       
   122         * Calls different functions according to iLaunchStep
       
   123         */
       
   124         void DoLaunchStepL( );
       
   125 
       
   126         /**
       
   127         * Removes possible old image.
       
   128         * Starts creating new attachment
       
   129         */
       
   130         void DoCreateAttaL( );
       
   131 
       
   132         /**
       
   133         * This functions starts the image process
       
   134         */
       
   135 		void DoStartProcessImageL( );
       
   136 
       
   137         /**
       
   138         * Sets the mimetypes and content location.
       
   139         * Stores headers
       
   140         */
       
   141         void DoFinalizeSaveL( );
       
   142 
       
   143         /**
       
   144         * Starts the scaling process by using ImageHandler Library (scaling to bitmap, not file)
       
   145         */
       
   146         void DoCreateBitmapL( );
       
   147 
       
   148         /**
       
   149         * Renames the attachment.
       
   150         * Called when the image needs no other special handling than just renaming.
       
   151         */
       
   152 		void DoRenameAttaL( );
       
   153 
       
   154         /**
       
   155         * Returns ETrue if compression is needed for the image
       
   156         */
       
   157         TBool NeedsCompress( );
       
   158         
       
   159         /**
       
   160         * From CActive
       
   161         */
       
   162         void DoCancel( );
       
   163 
       
   164         /**
       
   165         * From CActive
       
   166         */
       
   167         void RunL( );
       
   168     
       
   169         /**
       
   170         * From CActive
       
   171         */
       
   172         TInt RunError( TInt aError );
       
   173 
       
   174     protected: 
       
   175 
       
   176         /**
       
   177         * Constructor.
       
   178         */
       
   179         CPostcardOperationInsertImage(
       
   180             MPostcardOperationObserver& aObserver,
       
   181             CPostcardDocument& aDocument,
       
   182             CPostcardAppUi& aAppUi,
       
   183             CMsgImageInfo* aInfo,
       
   184             RFs& aFs );
       
   185 
       
   186         /**
       
   187         * 2nd phase constructor.
       
   188         */
       
   189         void ConstructL( );
       
   190 
       
   191     protected: // data
       
   192 
       
   193 		/**
       
   194 		* Every operation starts with EPostcardInsertImageCreateAtta
       
   195 		*
       
   196 		* If image is only converted/scaled, this is needed:
       
   197 		*	EPostcardInsertImageConvert (callback ScalingReady)
       
   198 		*
       
   199 		* If image is only compressed, this is needed:
       
   200 		*	EPostcardInsertImageCompress
       
   201 		*
       
   202 		* If image is first scaled and then compressed
       
   203 		*	EPostcardInsertImageConvert (callback ScalingReady)
       
   204 		*	EPostcardInsertImageCreateAttaAfterConvertForCompress
       
   205 		*	EPostcardInsertImageCompress (callback CompressionReady)
       
   206 		*	EPostcardInsertImageDeleteTempAtta
       
   207 		*
       
   208 		* If image is not specifically processed, this is needed:
       
   209 		*	EPostcardInsertImageRename
       
   210 		*
       
   211 		* In the end EPostcardInsertImageFinalizeSave where the changes are commited.
       
   212 		* And EPostcardInsertImageCreateBitmap creates the bitmap to be shown in the screen
       
   213 		*
       
   214 		*/
       
   215 
       
   216         enum TPostcardInsertImageState
       
   217             {
       
   218             EPostcardInsertImageInitializing = 0,
       
   219             EPostcardInsertImageCheckAttas,
       
   220             EPostcardInsertImageCreateAtta,
       
   221             EPostcardInsertProcessImage,
       
   222 			EPostcardInsertImageRename,
       
   223             EPostcardInsertImageFinalizeSave,
       
   224             EPostcardInsertImageCreateBitmap,
       
   225             EPostcardInsertImageFinished,
       
   226             EPostcardInsertImageError
       
   227             };
       
   228 
       
   229         enum TPostcardInsertImageFlags
       
   230             {
       
   231             EPostcardInsertImageConvertingImage = 1,
       
   232             EPostcardInsertImageRequestActive = 2
       
   233             };
       
   234 
       
   235         CMsgImageInfo*      iInfo;		// ImageInfo given when this instance is constructed
       
   236 
       
   237 		RFile*				iCompressFile; // RFile created when the file is being compressed/processed
       
   238 		CMsvAttachment*		iScaleAtta;		// Attachment file for scaled file
       
   239 		CMsvAttachment*		iCompressAtta;	// Attachment file for compressed file
       
   240 		CMsvAttachment*		iNoOpAtta;		// Attachment file for images that need no special handling
       
   241 
       
   242 		CUniImageProcessor*	iImageProcessor;	// Image processor
       
   243 
       
   244         MIHLFileImage*      iSourceImage;       // source image for scaling to bitmap
       
   245         MIHLBitmap*         iDestinationBitmap; // scaled MIHL bitmap
       
   246         MIHLImageViewer*    iImageHandler;      // image handler for scaling
       
   247 
       
   248         TInt                iFlags;
       
   249     };
       
   250 
       
   251 #endif // __PostcardOperationInsertImage_H