ImagePrint/ImagePrintEngine/ImagePrintServer/inc/cimageprintbody.h
branchRCL_3
changeset 21 d59c248c9d36
parent 0 d11fb78c4374
equal deleted inserted replaced
20:159fc2f68139 21:d59c248c9d36
       
     1 /*
       
     2 * Copyright (c) 2004-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:  Contains the CImagePrintBody class definition.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CIMAGEPRINTBODY_H
       
    20 #define CIMAGEPRINTBODY_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "imageprint.h"
       
    25 #include "cprotocolsloader.h"
       
    26 #include "cimageprintscheduler.h"
       
    27 #include "mprotprintingdevice.h"
       
    28 
       
    29 /**
       
    30  *
       
    31  *	This class is in charge of discoverying devices across the protocols available, of creating
       
    32  *	a print job in the right printer and right protocol, etc. It can be considered a controller. 
       
    33  *	Implements the MProtPrintingDevice observers (MProtDiscoveryObserver, MProtPrintEventObserver) so it can act
       
    34  *	accordingly when the protocols report or need something.
       
    35  */
       
    36 class CImagePrintBody : public CBase, public MProtDiscoveryObserver, public MProtPrintEventObserver, public MProtIdleObserver
       
    37 	{
       
    38 	public:
       
    39 	
       
    40 		/**
       
    41          *	2-phase constructor
       
    42          *
       
    43          *	@return new object      
       
    44          */
       
    45 		static CImagePrintBody* NewL();
       
    46 		
       
    47 		/**
       
    48          *	Destructor         
       
    49          */
       
    50 		~CImagePrintBody();
       
    51 
       
    52 		/**
       
    53          *	Start discovery for one or several protocols
       
    54          *
       
    55          *	@param aObserver observer for notifications about discovery events
       
    56          *	@param aProtocols OR:ed protocol ids
       
    57          *	@return error code     
       
    58          */
       
    59 		TInt StartDiscovery(MPrinterDiscoveryObserver& aObserver, TUint aProtocols = 0);
       
    60 		
       
    61 		/**
       
    62          *	Cancel discovery        
       
    63          */
       
    64 		void CancelDiscovery();
       
    65 		
       
    66 		/**
       
    67          *	Creates print job
       
    68          *
       
    69          *	@param aPrinterID printer id
       
    70          *	@param aImages array of image file names to be printed
       
    71          *	@param aObserver observer for notifications about print job events
       
    72          *	@return error code     
       
    73          */
       
    74 		TInt CreatePrintJobL(TInt aPrinterID, RPointerArray<TDesC>& aImages, MPrintEventObserver& aObserver);
       
    75 		
       
    76 		/**
       
    77          *	Start actual printing of previously created print job
       
    78          */
       
    79 		void SubmitPrintJobL();
       
    80 		
       
    81 		/**
       
    82          *	Cancel print job
       
    83          *
       
    84          *	@return error code      
       
    85          */
       
    86 		TInt CancelPrintJob();
       
    87 		
       
    88 		/**
       
    89          *	Continue print job
       
    90          *
       
    91          *	@return error code      
       
    92          */
       
    93 		TInt ContinuePrintJobL();
       
    94 		
       
    95 		/**
       
    96          *	Print pages amount getter
       
    97          *
       
    98          *	@return amount of print pages with current settings for current print job    
       
    99          */
       
   100 		TInt GetNumPrintPages();
       
   101 		
       
   102 		/**
       
   103          *	Job status getter
       
   104          *
       
   105          *	@return job status code    
       
   106          */
       
   107 		TInt GetJobStatus();
       
   108 		
       
   109 		/**
       
   110          *	Printer status getter
       
   111          *
       
   112          *	@param aPrinterID printer id
       
   113          *	@return printer status code    
       
   114          */
       
   115 		TInt GetPrinterStatus(TInt aPrinterID);
       
   116 		
       
   117 		/**
       
   118          *	Printer capability id getter
       
   119          *
       
   120          *	@param aPrinterID printer id
       
   121          *	@param aCapabilityIDs place holder for capability ids supported by printer
       
   122          *	@return error code    
       
   123          */
       
   124 		TInt GetPrinterCapabilityIDsL(TInt aPrinterID, RArray<TInt>& aCapabilityIDs);
       
   125 		
       
   126 		/**
       
   127          *	Printer capability getter
       
   128          *
       
   129          *	@param aPrinterID printer id
       
   130          *	@param aCapabilityID capability id
       
   131          *	@param aCapability place holder for capability
       
   132          *	@return error code    
       
   133          */
       
   134 		TInt GetPrinterCapabilityL(TInt aPrinterID, TInt aCapabilityID, TPrintCapability& aCapability);
       
   135 		
       
   136 		/**
       
   137          *	Printer setting getter
       
   138          *
       
   139          *	@param aCapabilityID capability id
       
   140          *	@param aValue place holder for capability value
       
   141          *	@return error code    
       
   142          */
       
   143 		TInt GetJobSetting(TInt aCapabilityID, TInt& aValue);
       
   144 		
       
   145 		/**
       
   146          *	Printer setting setter
       
   147          *
       
   148          *	@param aCapabilityID capability id
       
   149          *	@param aValue capability value
       
   150          *	@param aAffectedCapability affected capability id
       
   151          *	@return error code    
       
   152          */
       
   153 		TInt SetJobSettingL(TInt aCapabilityID, TInt aValue, TInt& aAffectedCapability);
       
   154 		
       
   155 		/**
       
   156          *	Preview pages amount getter for current protocol
       
   157          *
       
   158          *	@return preview pages amount      
       
   159          */
       
   160 		TInt GetNumPreviewPages();
       
   161 		
       
   162 		/**
       
   163          *	Template icon getter
       
   164          *
       
   165          *	@param aTemplateID template id
       
   166          *	@param aFbsBitmapHandle place holder for template bitmap handle
       
   167          *	@return error code    
       
   168          */
       
   169 		TInt GetJobTemplateIconL(TInt aTemplateID, TInt& aFbsBitmapHandle);
       
   170 		
       
   171 		/**
       
   172          *Creates a preview image
       
   173          *
       
   174          *	@param aPageNumber Page number to create preview image of
       
   175          *	@return error code    
       
   176          */
       
   177 		TInt CreatePreviewImage(TInt aPageNumber);
       
   178 		
       
   179 		/**
       
   180          *	Remove cached printer
       
   181          *
       
   182          *	@param aPrinterID printer id
       
   183          *	@return error code    
       
   184          */
       
   185 		TInt RemoveCachedPrinterL(TInt aPrinterID);
       
   186 		
       
   187 		/**
       
   188          *	Supported protocols getter
       
   189          *
       
   190          *	@return OR:ed protocol ids      
       
   191          */
       
   192 		TUint SupportedProtocols();
       
   193 		
       
   194 		/**
       
   195          *	Register observer for idle events receiving
       
   196          *
       
   197          *	@param aObserver observer      
       
   198          */
       
   199 		void RegisterIdleObserver(MIdleObserver* aObserver);
       
   200 		
       
   201 		/**
       
   202          *	Number of copies setter for current print job
       
   203          *
       
   204          *	@param aNumsOfCopies number of copies array
       
   205          *	@param aErr place holder for error code      
       
   206          */
       
   207 		void SetNumsOfCopiesL(const RArray<TInt>& aNumsOfCopies, TInt& aErr);
       
   208 		
       
   209 		/**
       
   210          *	Handle session disconnection
       
   211          *
       
   212          *	@param aIdleObserver idle observer object of that session
       
   213          *	@param aDiscoveryObserver discovery observer object of that session     
       
   214          *	@param aEventObserver print job observer object of that session
       
   215          */
       
   216 		void HandleSessionDisconnect( const MIdleObserver* aIdleObserver,
       
   217 									const MPrinterDiscoveryObserver* aDiscoveryObserver,
       
   218 									const MPrintEventObserver* aEventObserver );
       
   219 
       
   220 	private: // from MProtDiscoveryObserver			
       
   221 		void FoundDeviceL(TPrinter& aDeviceInfo);
       
   222 		void DiscoveryStatusL(TInt aStatus, TInt aErrorCode, TInt aErrorStringCode);
       
   223 		void RemoveDeviceL(TPrinter& aDeviceInfo);
       
   224 
       
   225 	private: // from MProtPrintEventObserver			
       
   226 		void PrintJobProgressEvent(TInt aStatus, TInt aPercent, TInt aJobStateCode);
       
   227 		void PrintJobErrorEvent(TInt aErrorCode, TInt aErrorStringCode);
       
   228 		void PrinterStatusEvent(TInt aErrorCode, TInt aErrorStringCode);
       
   229 		void PreviewImageEvent(TInt aFsBitmapHandle);
       
   230 		void ShowMessageL(TInt aMsgLine1Code, TInt aMsgLine2Code);
       
   231 		TBool AskYesNoQuestionL(TInt aMsgLine1Code, TInt aMsgLine2Code);
       
   232 		const TDesC& AskForInputL(TInt aMsgLine1Code, TInt aMsgLine2Code);
       
   233 
       
   234 	private: // from MProtIdleObserver			
       
   235 		void StatusEvent(const TEvent &aEvent, TInt aError, TInt aMsgCode);
       
   236 	
       
   237 	private:
       
   238 		CImagePrintBody();
       
   239 		void ConstructL();
       
   240 		TInt FindInternalDeviceReference(TInt aExternalDeviceID, TInt& aInternalDeviceID, MProtPrintingDevice*& aProtToUse);
       
   241 		TInt ValidateImagesL(const RPointerArray<HBufC>& aImageList, TInt &aInvalidCount);
       
   242 		CImagePrintScheduler& ActiveScheduler() const;
       
   243 		void TryNextDiscovery();
       
   244 		static TInt TryNextDiscoveryL(TAny* aObj);
       
   245 		void DoTryNextDiscoveryL();
       
   246 
       
   247 	private:
       
   248 		/// Class loader and manager.
       
   249 		CProtocolsLoader* iClassLoader;
       
   250 		/// Pointer to store the current protocol in use for discovery.
       
   251 		MProtPrintingDevice* iCurrentProtocol;
       
   252 		/// Pointer to store the current protocol in use for creating a print job.
       
   253 		MProtPrintingDevice* iCurrentPrintJobProtocol;
       
   254 		/// ImagePrint Observer.
       
   255 		MPrinterDiscoveryObserver* iPrinterDiscoveryObserver;
       
   256 		/// ImagePrint Observer.
       
   257 		MPrintEventObserver* iPrinterPrintEventObserver;
       
   258 		/// ImagePrint Idle Observer.
       
   259 		MIdleObserver* iPrinterIdleObserver;							
       
   260 		/// Used to store the requested protocols.
       
   261 		TUint iProtocolsRequested;
       
   262 		/// Array of the image filenames to print.
       
   263 		RPointerArray<HBufC> iImageFileNames;
       
   264 		/// Enables async discovery
       
   265 		CIdle* iIdleDiscovery;
       
   266 		
       
   267 		TBool iDiscoveryCancelled;
       
   268 	};
       
   269 
       
   270 #endif // CIMAGEPRINTBODY_H
       
   271 
       
   272 //  End of File