imageeditor/imageeditorApp/inc/ImageEditorImageController.h
changeset 1 edfc90759b9f
equal deleted inserted replaced
0:57d4cdd99204 1:edfc90759b9f
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description: 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef IMAGEEDITORIMAGECONTROLLER_H
       
    22 #define IMAGEEDITORIMAGECONTROLLER_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <fbs.h>
       
    27 
       
    28 #include "ImageControllerObserver.h"
       
    29 
       
    30 
       
    31 //  FORWARD DECLARATIONS
       
    32 class CImageEditorPluginManager;
       
    33 class CImageEditorImageHandler;
       
    34 
       
    35 /*	CLASS: CImageController
       
    36 *
       
    37 *	CImageController is an active object controlling asynchronous saving
       
    38 *	and loading of images. Also, synchronous methods for renaming and deleting
       
    39 *	images can be found.
       
    40 */
       
    41 class CImageController : public CActive
       
    42 {
       
    43 
       
    44 public:
       
    45 
       
    46 /** @name Methods:*/
       
    47 //@{
       
    48 
       
    49 	/** NewL factory method, pops cleanupstack
       
    50 	*
       
    51 	*	@param aObserver - CImageController observer instance, ownership not changed
       
    52 	*	@param aManager - CImageEditorPluginManager instance
       
    53 	*	@return pointer to created CImageController object
       
    54 	*/
       
    55 	static CImageController * NewL (
       
    56 		MImageControllerObserver *		aObserver,
       
    57 		CImageEditorPluginManager *		aManager
       
    58 		);
       
    59 
       
    60 	/** Destructor
       
    61 	*
       
    62 	*	@param -
       
    63 	*	@return -
       
    64 	*/
       
    65 	virtual ~CImageController ();
       
    66 
       
    67 	/** LoadImage
       
    68 	*
       
    69 	*	Loads image.
       
    70 	*
       
    71 	*	@param aFileName - name of the image file to be loaded
       
    72 	*	@return -
       
    73 	*/
       
    74 	void LoadImageL (const TDesC & aFileName);
       
    75 
       
    76 	/** SaveImage
       
    77 	*
       
    78 	*	Saves image 
       
    79 	*
       
    80 	*	@param aFileName - saved image name
       
    81 	*	@param aProgressCount - On return, contains the number of blocks to progress
       
    82 	*	@return -
       
    83 	*/
       
    84 	void SaveImageL (const TDesC & aFileName);
       
    85 
       
    86     /** RenameImage
       
    87 	*
       
    88 	*	Renames image. 
       
    89 	*
       
    90 	*	@param aFileNameSrc - source image name
       
    91 	*	@param aFileNameDst - destination image name
       
    92 	*	@return KErrNone if no errors, system wide error otherwise
       
    93 	*/
       
    94 	TInt  RenameImage (
       
    95 		const TDesC	&		aFileNameSrc,
       
    96 		const TDesC	&		aFileNameDst
       
    97 		) const;
       
    98 
       
    99 	/** DeleteImage
       
   100 	*
       
   101 	*	Deletes image. 
       
   102 	*
       
   103 	*	@param aFileName - image name to be deleted
       
   104 	*	@return KErrNone if no errors, system wide error otherwise
       
   105 	*/
       
   106 	TInt DeleteImage (const TDesC & aFileName) const;
       
   107 
       
   108 	/** CreatePreviewBitmapL 
       
   109 	*
       
   110 	*	Creates the preview bitmap.
       
   111 	*
       
   112 	*	@param -
       
   113 	*	@return -
       
   114 	*/
       
   115 	void CreatePreviewBitmapL ();
       
   116 
       
   117     /** DeletePreviewBitmap 
       
   118 	*
       
   119 	*	Deletes the preview bitmap.
       
   120 	*
       
   121 	*	@param -
       
   122 	*	@return -
       
   123 	*/
       
   124 	void DeletePreviewBitmap ();
       
   125 
       
   126     /** CancelOperation
       
   127 	*
       
   128 	*	Cancels loading, saving or processing operation.
       
   129 	*	This does not call the AO's Cancel(), but rather waits for the nexts RunL()
       
   130 	*	to finish, and finishes after that.
       
   131 	*	
       
   132 	*	@param aOperation - the on-going operation
       
   133 	*	@return -
       
   134 	*/
       
   135 	void CancelOperation(TBool aForce = EFalse);
       
   136 
       
   137 
       
   138 //@}
       
   139 
       
   140 protected:
       
   141 
       
   142 /** @name Methods:*/
       
   143 //@{
       
   144 
       
   145 	/** DoCancel
       
   146 	*
       
   147 	*	Implements cancellation of outstanding request. This method is 
       
   148 	*	called from Cancel() of active object. Cancels asynchronous request
       
   149 	*	and returns. DOES NOT WAIT THE REQUEST TO COMPLETE.
       
   150 	*
       
   151 	*	@param -
       
   152 	*	@return -
       
   153 	*	@see CActive
       
   154 	*/
       
   155 	virtual void DoCancel();
       
   156 
       
   157 	/** RunL
       
   158 	*
       
   159 	*	Active object's request completion handler. 
       
   160 	*
       
   161 	*	Active scheduler selects this class based on class priority and
       
   162 	*	marks the status completed before calling this method. This method
       
   163 	*	should handle the completion as fast as possible and return or issue
       
   164 	*	another request.
       
   165 	*
       
   166 	*	@param -
       
   167 	*	@return -
       
   168 	*	@see CActive
       
   169 	*/
       
   170 	virtual void RunL ();
       
   171 
       
   172 
       
   173 //@}
       
   174 
       
   175 /** @name Members:*/
       
   176 //@{
       
   177 
       
   178 //@}
       
   179 
       
   180 private:
       
   181 
       
   182 /** @name Methods:*/
       
   183 //@{
       
   184 
       
   185 	/** Default constructor
       
   186 	*
       
   187 	*	@param -
       
   188 	*	@return -
       
   189 	*/
       
   190 	CImageController ();
       
   191 
       
   192 	/** Second phase constructor, may leave
       
   193 	*
       
   194 	*	@param aObserver - CImageController observer instance, ownership not changed
       
   195 	*	@param aManager - CImageEditorPluginManager instance
       
   196 	*	@return -
       
   197 	*/
       
   198 	void ConstructL (
       
   199 		MImageControllerObserver *		aObserver,
       
   200 		CImageEditorPluginManager *		aManager
       
   201 		);
       
   202 
       
   203 	/** CompleteRequest
       
   204 	*
       
   205 	*	Force RunL
       
   206 	*
       
   207 	*	@param -
       
   208 	*	@return -
       
   209 	*/
       
   210     void CompleteRequest();
       
   211 
       
   212 	/** CalculateProgressInterval
       
   213 	*
       
   214 	*	The saving operation typically consists of thousands of blocks. 
       
   215 	*	It makes no sense to update the progress bar that often.
       
   216 	*
       
   217 	*	@param -
       
   218 	*	@return -
       
   219 	*/
       
   220     void CalculateProgressInterval (TInt aBlockCount);
       
   221 //@}
       
   222 
       
   223 /** @name Members:*/
       
   224 //@{
       
   225 	/// Image Handler
       
   226 	CImageEditorImageHandler *	iImageHandler;
       
   227 	
       
   228     /// Plug-in Manager
       
   229 	CImageEditorPluginManager *	iManager;
       
   230 
       
   231 	/// CImageController observer instance
       
   232 	MImageControllerObserver *	iObserver;
       
   233 
       
   234     /// Preview bitmap
       
   235 	CFbsBitmap *				iPreview;
       
   236 
       
   237     /// Jpeg Image
       
   238     TBool                       iJpegImage;
       
   239 
       
   240     /// JPEG quality
       
   241     TInt                        iQuality;
       
   242 
       
   243     /// Last operation
       
   244 	MImageControllerObserver::TOperationCode	iOperation;
       
   245 
       
   246     /// Progress bar update interval (number of blocks)
       
   247     TInt                        iProgressBarInterval;
       
   248 
       
   249 	//	Current save progress in percentage
       
   250     TInt                        iSavedPercentage;
       
   251 
       
   252 	//	Previous save progress in percentage
       
   253 	TInt						iSavedPercentageOld;
       
   254 
       
   255     /// Is operation cancelled
       
   256     TBool                       iIsCancelled;
       
   257 
       
   258 //@}
       
   259 
       
   260 };
       
   261 
       
   262 
       
   263 #endif