|
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: Contains the CPBPrintingDevice class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBPRINTINGDEVICE_H |
|
20 #define CPBPRINTINGDEVICE_H |
|
21 |
|
22 #include <fbs.h> |
|
23 #include <e32hashtab.h> |
|
24 |
|
25 #include "mprotprintingdevice.h" |
|
26 #include "mpbobserver.h" |
|
27 #include "printmessagecodes.h" |
|
28 #include "printcapabilitycodes.h" |
|
29 |
|
30 class CDpsEngine; |
|
31 class CPBConnect; |
|
32 class RWriteStream; |
|
33 |
|
34 enum TPBProtocolState |
|
35 { |
|
36 EPBUninitialized = 0, |
|
37 EPBDiscovery, |
|
38 EPBReady, |
|
39 EPBJobReady, |
|
40 EPBSubmittingJob, |
|
41 EPBPrinting, |
|
42 EPBCancelling, |
|
43 }; |
|
44 |
|
45 enum TPBJobSettingIndex |
|
46 { |
|
47 EPBSettingPaperSize = 0, |
|
48 EPBSettingQuality = 1, |
|
49 EPBSettingLayout = 2 |
|
50 }; |
|
51 |
|
52 /** |
|
53 * @brief CPBPrintingDevice implements MProtPrintingDevice. This makes the class the "published" class of the DLL it is in. |
|
54 */ |
|
55 class CPBPrintingDevice : public CActive, public MProtPrintingDevice, public MPBObserver |
|
56 { |
|
57 public: |
|
58 static MProtPrintingDevice* NewL(); |
|
59 |
|
60 // Default constructor and destructor. |
|
61 CPBPrintingDevice(); |
|
62 ~CPBPrintingDevice(); |
|
63 |
|
64 public: // From MProtPrintingDevice |
|
65 |
|
66 // General. |
|
67 void ConstructL(const TDesC& aDLLPath); |
|
68 TVersion Version(); |
|
69 TUint SupportedProtocols(); |
|
70 // Discovery. |
|
71 void StartDiscoveryL( MProtDiscoveryObserver& aObserver, TUint aProtocols = 0 ); |
|
72 TInt RemoveCachedDeviceL( TInt aDeviceID ); |
|
73 void CancelDiscovery( TBool aDoCallBack = ETrue ); |
|
74 // Print. |
|
75 TInt CreatePrintJobL( TInt aDeviceID, RPointerArray<TDesC>& aImages, MProtPrintEventObserver& aObserver ); |
|
76 void SubmitPrintJobL(); |
|
77 TInt CancelPrintJob(); |
|
78 TInt ContinuePrintJobL(); |
|
79 TInt GetNumPrintPages(); |
|
80 TInt GetPrintJobStatus(); |
|
81 TInt GetPrinterStatus( TInt aDeviceID ); |
|
82 // Capabilities. |
|
83 TInt GetDeviceCapabilityIDsL( TInt aDeviceID, RArray<TInt>& aCapabilityIDs ); |
|
84 TInt GetDeviceCapabilityL( TInt aDeviceID, TInt aCapabilityID, TPrintCapability& aCapability ); |
|
85 TInt GetJobSetting( TInt aCapabilityID, TInt& aValue ); |
|
86 TInt SetJobSettingL( TInt aCapabilityID, TInt aValue, TInt& aAffectedCapability ); |
|
87 // Preview. |
|
88 TInt GetNumPreviewPages(); |
|
89 TInt GetJobTemplateIconL( TInt aTemplateID, TInt& aFsBitmapHandle ); |
|
90 TInt CreatePreviewImage( TInt aPageNumber ); |
|
91 |
|
92 void RegisterIdleObserver( MProtIdleObserver *aObserver ); |
|
93 |
|
94 void SetNumsOfCopiesL( const RArray<TInt>& aNumsOfCopies, TInt& aErr ); |
|
95 |
|
96 public: // from MPBObserver |
|
97 void ConnectionNotifyL( TInt aStatus ); |
|
98 void JobNotify( const TDpsGetJobStatus& aStatus ); |
|
99 void PrinterNotify( const TDpsGetPrinterStatus& aStatus ); |
|
100 |
|
101 protected: // from CActive |
|
102 void DoCancel(); |
|
103 void RunL(); |
|
104 TInt RunError( TInt aError ); |
|
105 |
|
106 private: |
|
107 void HandlePapersizesResponseL( TPrintCapability& aCapability ); |
|
108 void HandleQualitiesResponseL( TPrintCapability& aCapability ); |
|
109 void HandleLayoutsResponseL( TPrintCapability& aCapability ); |
|
110 TInt GetPapersizeJobSetting( TInt& aValue ); |
|
111 TInt GetQualityJobSetting( TInt& aValue ); |
|
112 TInt GetLayoutJobSetting( TInt& aValue ); |
|
113 TPrintMessageCodes DpsJobError( const TDpsJobEndReason& aReason ); |
|
114 void HandlePaperError ( const TDpsJobEndReason& aReason, TPrintMessageCodes& aErr ); |
|
115 void HandleInkError ( const TDpsJobEndReason& aReason, TPrintMessageCodes& aErr ); |
|
116 void HandleHwError ( const TDpsJobEndReason& aReason, TPrintMessageCodes& aErr ); |
|
117 void HandleFileError ( const TDpsJobEndReason& aReason, TPrintMessageCodes& aErr ); |
|
118 TBool HasCapability( TPrintCapability& aCapability, TPrintCapabilityOptions aOption ); |
|
119 void SaveConfigInfoL(); |
|
120 void ReadConfigInfoL(); |
|
121 void ExternalizeL( RWriteStream& aStream ) const; |
|
122 |
|
123 private: // data |
|
124 CDpsEngine* iDpsEngine; |
|
125 CPBConnect* iConnect; |
|
126 CActiveSchedulerWait iWait; |
|
127 TBool iPrinterConnected; |
|
128 TPBProtocolState iState; |
|
129 MProtIdleObserver* iIdleObserver; |
|
130 RHashMap<TInt, TInt> iCapToDps; |
|
131 TDpsGetCapability iCap; |
|
132 TDpsStartJob iStart; |
|
133 TDpsAbortJob iAbort; |
|
134 TDpsContinueJob iContinue; |
|
135 TDpsGetPrinterStatus iPrinterS; |
|
136 TDpsGetJobStatus iJobS; |
|
137 TDpsConfigPrintService iConfigS; |
|
138 HBufC* iCongFileName; |
|
139 TPrinter iPrinter; |
|
140 TUint iCancelRetry; |
|
141 TInt iPrintingStateComplete; |
|
142 TUint iUserSelectedPaperSize; |
|
143 TBool iDisconnectPrinter; |
|
144 TBool iNewJobOK; |
|
145 }; |
|
146 |
|
147 #endif // CPBPRINTINGDEVICE_H |
|
148 |
|
149 // End of File |