ImagePrint/ImagePrintEngine/DeviceProtocols/upnpprotocolfw2/inc/cupjobstate.h
branchRCL_3
changeset 20 159fc2f68139
parent 17 26673e532f65
child 21 d59c248c9d36
equal deleted inserted replaced
17:26673e532f65 20:159fc2f68139
     1 /*
       
     2 * Copyright (c) 2002-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:  Declares CUPJobState class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CUPJOBSTATE_H
       
    20 #define CUPJOBSTATE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "upconsts.h"
       
    25 
       
    26 /*
       
    27 * @class 		TUPJobEndState
       
    28 * @description	This class contains the state variables related to the end / abort state
       
    29 *				of the job that is active at printer.
       
    30 */
       
    31 NONSHARABLE_CLASS(TUPJobEndState)
       
    32 {
       
    33 	public:
       
    34 		inline TUPJobEndState(){Init();}
       
    35 
       
    36 		inline void Init()
       
    37 		{
       
    38 			iId.Set(KNullDesC8());
       
    39 			iJobName.Set(KNullDesC8());
       
    40 			iOriginator.Set(KNullDesC8());
       
    41 			iSheets = KErrNotFound;
       
    42 			iState = EStateUnknown;
       
    43 			iReason = ENoMessage;
       
    44 			iAbortState = EFalse;
       
    45 		}
       
    46 
       
    47 		TPtrC8 iId;
       
    48 		TPtrC8 iJobName;
       
    49 		TPtrC8 iOriginator;
       
    50 		TInt iSheets;
       
    51 		TUPnPState iState;
       
    52 		TInt iReason;
       
    53 		TBool iAbortState;
       
    54 };
       
    55 
       
    56 /*
       
    57 * @class 		CUPJobState
       
    58 * @description	This class collects and maintains the processing state of the job that is active at printer.
       
    59 */
       
    60 NONSHARABLE_CLASS(CUPJobState) : public CBase
       
    61 {
       
    62 	public:
       
    63 
       
    64 		/*
       
    65 		* @function		NewL
       
    66 		* @description	A method to create a new object.
       
    67 		*/
       
    68 		static CUPJobState* NewL();
       
    69 
       
    70 		/*
       
    71 		* @function		NewLC
       
    72 		* @description	A method to create a new object.
       
    73 		*/
       
    74 		static CUPJobState* NewLC();
       
    75 
       
    76 		/*
       
    77 		* @function		~CUPJobState
       
    78 		* @description	Destructor 
       
    79 		*/
       
    80 		~CUPJobState();
       
    81 
       
    82 		/*
       
    83 		* @function		Init
       
    84 		* @description	Initializes private members 
       
    85 		*/
       
    86 		void Init();
       
    87 
       
    88 		/*
       
    89 		* @function		State
       
    90 		* @description	Returns the stored state of the job 
       
    91 		* @return		TUPnPState
       
    92 		*/
       
    93 		TUPnPState State();
       
    94 
       
    95 		/*
       
    96 		* @function		SetActiveId
       
    97 		* @description	Sets the id for the active job at UPnPProtocol 
       
    98 		* @return		TUPnPState
       
    99 		*/
       
   100 		void SetActiveId(const TDesC8& aId);
       
   101 		
       
   102 		/*
       
   103 		* @function		ActiveId
       
   104 		* @description	Returns id of the job active at UPnPProtocol 
       
   105 		* @return		TUPnPState
       
   106 		*/
       
   107 		TPtrC8 ActiveId();
       
   108 
       
   109 		/*
       
   110 		* @function		SheetsCompleted
       
   111 		* @description	Returns the number of printed sheets of the job 
       
   112 		* @return		TInt
       
   113 		*/
       
   114 		TInt SheetsCompleted();
       
   115 
       
   116 		/*
       
   117 		* @function		Reason
       
   118 		* @description	Returns the reason code for the job state 
       
   119 		* @return		TInt
       
   120 		*/
       
   121 		TInt Reason();
       
   122 
       
   123 		/*
       
   124 		* @function		SetSheetsToPrint
       
   125 		* @description	Sets the number of the sheets about to print 
       
   126 		* @param		TInt
       
   127 		*/
       
   128 		void SetSheetsToPrint(TInt aSheets);
       
   129 		
       
   130 		/*
       
   131 		* @function		SheetsToPrint
       
   132 		* @description	Returns the number of the sheets about to print 
       
   133 		* @return		TInt
       
   134 		*/
       
   135 		TInt SheetsToPrint();
       
   136 		
       
   137 		/*
       
   138 		* @function		SetSheetsCompleted
       
   139 		* @description	Returns and updates the job state according to the printed sheets
       
   140 		* @param		TDesC8 Reference to the string value of printed sheets
       
   141 		*/
       
   142 		void SetSheetsCompleted(const TDesC8& aSheetsCompleted);
       
   143 
       
   144 		/*
       
   145 		* @function		Progress
       
   146 		* @description	Returns progress percentage of the job 
       
   147 		* @param		TInt Number of the sheets sent to printer
       
   148 		* @return		TInt
       
   149 		*/
       
   150 		TInt Progress(TInt aSheets);
       
   151 		
       
   152 		/*
       
   153 		* @function		Progress
       
   154 		* @description	Returns progress percentage of the job 
       
   155 		* @return		TInt
       
   156 		*/
       
   157 		TInt Progress();
       
   158 		
       
   159 		/*
       
   160 		* @function		UpdateJobState
       
   161 		* @description	Returns the state of the job after updated with given arguments 
       
   162 		* @param		TDesC8& Printer state
       
   163 		* @param		TDesC8& Reason for the printer state
       
   164 		* @param		TDesC8& List of job ids pending at the printer queue
       
   165 		* @param		TDesC8& Id of the currently handled job in printer
       
   166 		* @param		TDesC8& Number of the sheets completed at printer
       
   167 		* @return		TUPnPState
       
   168 		*/
       
   169 		TUPnPState UpdateJobState(const TDesC8& aPrinterState, const TDesC8& aReason, const TDesC8& aJobList, const TDesC8& aJobId, const TDesC8& aJobMediaSheetsCompleted);
       
   170 
       
   171 
       
   172 		/*
       
   173 		* @function		GetErrorValue
       
   174 		* @description	Maps the ImagePrint and device errors.
       
   175 		* @param		TDesC8 Reference to device returned error code
       
   176 		* @return		TInt Correspondent ImagePrint error code
       
   177 		*/
       
   178 		TInt GetErrorValue(const TDesC8& aError);
       
   179 
       
   180 		/*
       
   181 		* @function		PrinterStateUpdated
       
   182 		* @description	Returns the state of the job after printer state updated 
       
   183 		* @param		TDesC8& New printer state
       
   184 		* @return		TUPnPState
       
   185 		*/
       
   186 		TUPnPState PrinterStateUpdated( const TDesC8& aEvent );
       
   187 		
       
   188 		/*
       
   189 		* @function		PrinterStateReasonsUpdated
       
   190 		* @description	Returns the state of the job after printer state reason updated 
       
   191 		* @param		TDesC8& Reason for the printer state		
       
   192 		* @return		TUPnPState
       
   193 		*/
       
   194 		TUPnPState PrinterStateReasonsUpdated( const TDesC8& aEvent );
       
   195 		
       
   196 		/*
       
   197 		* @function		JobIdListUpdated
       
   198 		* @description	Returns the state of the job after job ID list updated 
       
   199 		* @param		TDesC8& List of job ids pending at the printer queue		
       
   200 		* @return		TUPnPState
       
   201 		*/
       
   202 		TUPnPState JobIdListUpdated( const TDesC8& aEvent );
       
   203 
       
   204 		/*
       
   205 		* @function		JobEndStateUpdatedL
       
   206 		* @description	Returns the state of the job after job end state updated 
       
   207 		* @param		TDesC8& The end state of last printed job. Format: 
       
   208 		*						<id>,<name>,<originator>,<completed sheets>,<state>
       
   209 		* @return		TUPnPState
       
   210 		*/
       
   211 		TUPnPState JobEndStateUpdatedL( const TDesC8& aEvent );
       
   212 
       
   213 		/*
       
   214 		* @function		JobMediaSheetsCompletedUpdated
       
   215 		* @description	Returns the state of the job after media sheets completed list updated 
       
   216 		* @param		TDesC8& Number of the printed sheets
       
   217 		* @return		TUPnPState
       
   218 		*/
       
   219 		TUPnPState JobMediaSheetsCompletedUpdated( const TDesC8& aEvent );
       
   220 
       
   221 		/*
       
   222 		* @function		JobMediaSheetsCompletedUpdated
       
   223 		* @description	Returns the state of the job after media sheets completed list updated 
       
   224 		* @param		TDesC8& ID of the current job
       
   225 		* @param		TDesC8& Number of the printed sheets
       
   226 		* @return		TUPnPState
       
   227 		*/
       
   228 		TUPnPState JobMediaSheetsCompletedUpdated(const TDesC8& aId, const TDesC8& aEvent );
       
   229 
       
   230 		/*
       
   231 		* @function		JobAbortStateUpdatedL
       
   232 		* @description	Returns the state of the job after job abort state updated 
       
   233 		* @param		TDesC8& The abort state of last aborted job. Format: 
       
   234 		*						<id>,<name>,<originator>,<completed sheets>,aborted,<reason>
       
   235 		* @return		TUPnPState
       
   236 		*/
       
   237 		TUPnPState JobAbortStateUpdatedL( const TDesC8& aEvent );
       
   238 
       
   239 		/*
       
   240 		* @function		ContentCompleteListUpdated
       
   241 		* @description	Returns the state of the job after content completed list updated 
       
   242 		* @param		TDesC8& Number of the sheets completedly received in printer
       
   243 		* @return		TUPnPState
       
   244 		*/
       
   245 		TUPnPState ContentCompleteListUpdated( const TDesC8& aEvent );
       
   246 
       
   247 
       
   248 	protected:
       
   249 
       
   250 		/*
       
   251 		* @function		ConstructL
       
   252 		* @description	Symbian second phase constructor 
       
   253 		*/
       
   254 		void ConstructL();
       
   255 
       
   256 		/*
       
   257 		* @function		State
       
   258 		* @description	updates job's state according to the given state.
       
   259 		* @param		TUPnPState State enumeration value
       
   260 		* @return		TUPnPState
       
   261 		*/
       
   262 		TUPnPState State(TUPnPState aState);
       
   263 
       
   264 		/*
       
   265 		* @function		SetState
       
   266 		* @description	Updates the stored state of the job 
       
   267 		* @param		TUPnPState state to update with
       
   268 		*/
       
   269 		void SetState(TUPnPState aState);
       
   270 		
       
   271 		/*
       
   272 		* @function		SetJobList
       
   273 		* @description	Returns and updates the job state according to the list of the jobs pending in printer.
       
   274 		* @param		TDesC8 Reference to list of jobs
       
   275 		* @return		TUPnPState
       
   276 		*/
       
   277 		TUPnPState SetJobList(const TDesC8& aJobIdList);
       
   278 		
       
   279 		/*
       
   280 		* @function		PendingJobId
       
   281 		* @description	Returns the position of active job in job list.
       
   282 		* @param		TDesC8 Reference to list of jobs
       
   283 		* @return		TInt
       
   284 		*/
       
   285 		TInt PendingJobId(const TDesC8& aJobIdList);
       
   286 
       
   287 		/*
       
   288 		* @function		SetId
       
   289 		* @description	Updates the printer returned job id if necessary.
       
   290 		* @param		TDesC8 Reference to printer returned id
       
   291 		*/
       
   292 		void SetId(const TDesC8& aId);
       
   293 
       
   294 		/*
       
   295 		* @function		InitErrorValues
       
   296 		* @description	Initializes the error values stored in map for device vs. ImagePrint errors 
       
   297 		*/
       
   298 		void InitErrorValues();
       
   299 
       
   300 		/*
       
   301 		* @function		SetReason
       
   302 		* @description	Sets the reason for job state.
       
   303 		* @param		TInt Error value for the reason
       
   304 		*/
       
   305 		void SetReason(TInt aReason);
       
   306 		
       
   307 		/*
       
   308 		* @function		ParseState
       
   309 		* @description	Maps the states received from the device to state enumerations.
       
   310 		* @param		TDesC8 Reference to state string
       
   311 		* @return		TInt Corresponding state enumeration
       
   312 		*/
       
   313 		TUPnPState ParseState(const TDesC8& aState);
       
   314 
       
   315 		/*
       
   316 		* @function		ParseJobEndStateL
       
   317 		* @description	Separates the elements of the job end and abort state for handling and returns
       
   318 		*				KErrNotFound if the end state is not for the active job
       
   319 		* @param		TDesC8& The end or abort state of last printed job. Formats: 
       
   320 		*						<id>,<name>,<originator>,<completed sheets>,<state>
       
   321 		*						<id>,<name>,<originator>,<completed sheets>,abort,<reason>
       
   322 		* @return		TInt KErrNotFound if the end state is not for the active job
       
   323 		*/
       
   324 		TInt ParseJobEndStateL(const TDesC8& aJobEndState);
       
   325 
       
   326 	private:
       
   327 
       
   328 		/*
       
   329 		* @function		CUPJobState
       
   330 		* @description	Default constructor.
       
   331 		*/
       
   332 		CUPJobState();
       
   333 
       
   334 	private:
       
   335 		// @var iActiveId		Id of the active job interested
       
   336 		TBuf8<KMaxIdLength> iActiveId;
       
   337 
       
   338 		// @var iId				Id of the job
       
   339 		TBuf8<KMaxIdLength> iId;
       
   340 
       
   341 		// @var iSheetsCompleted Number of the completed sheets for the job
       
   342 		TInt iSheetsCompleted;
       
   343 
       
   344 		// @var iReason			Reason string of the state
       
   345 		TInt iReason;
       
   346 
       
   347 		// @var iState			Overall state of the job
       
   348 		TUPnPState iState;
       
   349 
       
   350 		// @var iErrorValues	Error values mapping array
       
   351 		RArray<TMapError> iErrorValues;
       
   352 
       
   353 		// @var iEndState		job end state info container
       
   354 		TUPJobEndState iEndState;
       
   355 		
       
   356 		// @var iSheetsToPrint	Number of the pages to print
       
   357 		TInt iSheetsToPrint;
       
   358 
       
   359 };
       
   360 #endif // CUPJOBSTATE_H
       
   361 
       
   362 //  End of File