testexecfw/useremul/inc/ImageCapture.h
changeset 0 3e07fef1e154
equal deleted inserted replaced
-1:000000000000 0:3e07fef1e154
       
     1 /*------------------------------------------------------------------
       
     2  -
       
     3  * Software Name : UserEmulator
       
     4  * Version       : v4.2.1309
       
     5  * 
       
     6  * Copyright (c) 2009 France Telecom. All rights reserved.
       
     7  * This software is distributed under the License 
       
     8  * "Eclipse Public License - v 1.0" the text of which is available
       
     9  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    10  *
       
    11  * Initial Contributors:
       
    12  * France Telecom 
       
    13  *
       
    14  * Contributors:
       
    15  *------------------------------------------------------------------
       
    16  -
       
    17  * File Name: ImageCapture.h
       
    18  * 
       
    19  * Created: 13/08/2009
       
    20  * Author(s): Marcell Kiss, Reshma Sandeep Das
       
    21  *   
       
    22  * Description:
       
    23  * Active object implementation for Image capture
       
    24  *------------------------------------------------------------------
       
    25  -
       
    26  *
       
    27  */
       
    28 #ifndef IMAGECAPTURE_H_
       
    29 #define IMAGECAPTURE_H_
       
    30 
       
    31 //System Includes
       
    32 #include <e32base.h>
       
    33 #include <ImageConversion.h>
       
    34 
       
    35 //User Includes
       
    36 #include "Settings.h"
       
    37 
       
    38 /**
       
    39  * MScreenshotObserver, an observer to CImageCapture class.
       
    40  */
       
    41 class MScreenshotObserver
       
    42 {
       
    43 public:
       
    44 	/**
       
    45 	 * Function that gets called to perform the next action after saving an image
       
    46 	 * @param aInterval duration after which the next action is performed 
       
    47 	 */
       
    48     virtual void PerformNextAction(TInt aInterval) = 0;
       
    49 };
       
    50 
       
    51 /**
       
    52  * CImageCapture
       
    53  * Class that handles image capturing functionality
       
    54  */
       
    55 class CImageCapture : public CActive
       
    56 {
       
    57 public:
       
    58 	/**
       
    59 	 * States of the Image capture active object
       
    60 	 */
       
    61 	enum TScreenShotStatus
       
    62 	{
       
    63 		EIdle,
       
    64 		EWaiting,
       
    65 		ECapturing,
       
    66 		ESaveComplete
       
    67 	};
       
    68 	
       
    69    /**
       
    70 	* Static constructor.	 
       
    71 	* @param aSettings A reference to the CSettings class
       
    72 	* @param aObserver A reference to the MScreenshotObserver class
       
    73 	* @param aEikonEnv A refernce to the CEikionEnv class	
       
    74 	* @return CImageCapture* A pointer to the newly alocated CImageCapture class.
       
    75 	*                          NULL, if the class cannot be created
       
    76 	*/
       
    77 	static CImageCapture* NewL(CSettings& aSettings,MScreenshotObserver& aObserver, CEikonEnv* aEikonEnv);
       
    78    /**
       
    79 	* Static constructor. On return the instance is left to the CleanupStack
       
    80 	* @param aSettings A reference to the CSettings class
       
    81 	* @param aObserver A reference to the MScreenshotObserver class
       
    82 	* @param aEikonEnv A refernce to the CEikionEnv class	
       
    83 	* @return CImageCapture* A pointer to the newly alocated CImageCapture class.
       
    84 	*                          NULL, if the class cannot be created
       
    85 	*/
       
    86 	static CImageCapture* NewLC(CSettings& aSettings,MScreenshotObserver& aObserver, CEikonEnv* aEikonEnv);
       
    87 		
       
    88 	/**
       
    89 	 * Destructor
       
    90 	 */
       
    91 	~CImageCapture();
       
    92      
       
    93 	/**
       
    94 	 * Function to start capturing images. This function waits until the 
       
    95 	 * application UID passed matches with the foreground running application UID
       
    96 	 * If NULL UID is passed, the Image capturer will not wait and continues the 
       
    97 	 * image saving operation  
       
    98 	 * @param aName file path
       
    99 	 * @param aXmlFileName name of the script file
       
   100 	 * @param aAppUid application UID
       
   101 	 */
       
   102      void CaptureL(const TDesC& aName, const TDesC& aXmlFileName, TUid aAppUid);
       
   103 
       
   104 private:
       
   105    /**
       
   106 	* Constructor
       
   107 	* @param aSettings A reference to the CSettings class
       
   108 	* @param aObserver A reference to the MScreenshotObserver class
       
   109 	* @param aEikonEnv A refernce to the CEikionEnv class	
       
   110 	*/
       
   111 	CImageCapture(CSettings& aSettings,MScreenshotObserver& aObserver, CEikonEnv* aEikonEnv);
       
   112 	
       
   113 	/**
       
   114 	 * ConstructL
       
   115 	 */
       
   116 	void ConstructL();
       
   117 	
       
   118 	/**
       
   119 	 * Function to start capturing images.
       
   120 	 * 
       
   121 	 */
       
   122 	void DoCaptureL();
       
   123 	
       
   124 	/**
       
   125 	 * Function that saves images
       
   126 	 * aName Screenshot name
       
   127 	 */
       
   128 	void DoSaveL(const TDesC& aName);
       
   129 	/**
       
   130 	 * Gets the file name. This function checks if the filename
       
   131 	 * already exists on the phone or not. This function prevents 
       
   132 	 * the capturer overriding the existing file. 
       
   133 	 * aName Screenshot name
       
   134 	 */	
       
   135     HBufC* GetNextFileNameLC(const TDesC& aName) const;
       
   136 	    
       
   137    /**
       
   138 	* Fires an event.
       
   139 	* @param aStatus Image Capture Active objects status
       
   140 	*/
       
   141 	void Fire(TScreenShotStatus aStatus);
       
   142 
       
   143    /**
       
   144 	* Fires capture event after aTime.
       
   145 	* @param aTime time interval
       
   146 	*/
       
   147 	void FireCapture(TTimeIntervalMicroSeconds32 aTime);
       
   148 
       
   149 private: //From CActive
       
   150    /**
       
   151 	* Cancels any outstanding request.
       
   152 	*/
       
   153 	void DoCancel();
       
   154 	
       
   155    /**
       
   156 	* Handles the completion of the active request.
       
   157 	*/
       
   158 	void RunL();
       
   159  
       
   160 private:        
       
   161    /**
       
   162 	* Handle to the CImageEncoder class
       
   163 	*/ 
       
   164 	CImageEncoder*       iImageEncoder;
       
   165    /**
       
   166 	* Handle to the CFbsBitmap class
       
   167 	*/ 
       
   168 	CFbsBitmap* 	     iBitmap;
       
   169    /**
       
   170 	* Handle to the CSettings class
       
   171 	*/
       
   172 	CSettings&           iSettings;
       
   173    /**
       
   174 	* Enumeration with different 
       
   175 	* states of the Image capture active object
       
   176 	*/
       
   177 	TScreenShotStatus    iScreenShotStatus;
       
   178    /**
       
   179 	* Timer handle 
       
   180 	*/
       
   181 	RTimer               iTimer;
       
   182    /**
       
   183 	* Screenshot file name
       
   184 	*/	
       
   185 	TBuf<KPATHLEN>       iFileName;
       
   186    /**
       
   187 	* XML script name
       
   188 	*/
       
   189 	TBuf8<KPATHLEN>		 iXmlFileName;
       
   190    /**
       
   191 	* Application UID
       
   192 	*/	
       
   193 	TUid                 iAppUid;
       
   194    /**
       
   195 	* Handle to CEikonEnv class
       
   196 	*/
       
   197 	CEikonEnv* 			 iEEnv;
       
   198    /**
       
   199 	* Reference to the MScreenshotObserver class
       
   200 	*/	
       
   201 	MScreenshotObserver& iObserver;
       
   202 };
       
   203 
       
   204 #endif /*IMAGECAPTURE_H_*/