|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CBTPRINTINGDEVICE_H |
|
20 #define CBTPRINTINGDEVICE_H |
|
21 |
|
22 #include "mprotprintingdevice.h" |
|
23 #include "mbtpcobserver.h" |
|
24 #include "imageprint.h" |
|
25 #include "btprotocolconsts.h" |
|
26 #include "crsbtdiscoverengine.h" |
|
27 #include "crsbtdevice.h" |
|
28 #include "cbtprintercontroller.h" |
|
29 #include "cprintjob.h" |
|
30 |
|
31 static const TUid KBtProtocolUid = { 0x01007779 }; |
|
32 |
|
33 /** |
|
34 * @brief CBtPrintingDevice implements MProtPrintingDevice. This makes the class the "published" class of the DLL it is in. |
|
35 */ |
|
36 class CBtPrintingDevice : public CActive, public MProtPrintingDevice, public MBtPCObserver |
|
37 { |
|
38 public: |
|
39 |
|
40 static MProtPrintingDevice* NewL(); |
|
41 |
|
42 // Default constructor and destructor. |
|
43 CBtPrintingDevice(); |
|
44 ~CBtPrintingDevice(); |
|
45 |
|
46 public: // From MProtPrintingDevice |
|
47 |
|
48 // General. |
|
49 void ConstructL(const TDesC& aDLLPath); |
|
50 TVersion Version(); |
|
51 TUint SupportedProtocols(); |
|
52 // Discovery. |
|
53 void StartDiscoveryL(MProtDiscoveryObserver& aObserver, TUint aProtocols = 0); |
|
54 TInt RemoveCachedDeviceL(TInt aDeviceID); |
|
55 void CancelDiscovery(TBool aDoCallBack = ETrue); |
|
56 // Print. |
|
57 TInt CreatePrintJobL(TInt aDeviceID, RPointerArray<TDesC>& aImages, MProtPrintEventObserver& aObserver); |
|
58 |
|
59 /** |
|
60 * @brief Submit a job previously created with CreatePrintJobL() |
|
61 */ |
|
62 void SubmitPrintJobL(); |
|
63 |
|
64 /** |
|
65 * @brief Cancels and ongoing print job. |
|
66 * |
|
67 * @return KErrNone if successful, KErrInvalidSequence if no printing job was previously submitted. |
|
68 */ |
|
69 TInt CancelPrintJob(); |
|
70 TInt ContinuePrintJobL(); |
|
71 TInt GetNumPrintPages(); |
|
72 TInt GetPrintJobStatus(); |
|
73 TInt GetPrinterStatus(TInt aDeviceID); |
|
74 // Capabilities. |
|
75 TInt GetDeviceCapabilityIDsL(TInt aDeviceID, RArray<TInt>& aCapabilityIDs); |
|
76 TInt GetDeviceCapabilityL(TInt aDeviceID, TInt aCapabilityID, TPrintCapability& aCapability); |
|
77 TInt GetJobSetting(TInt aCapabilityID, TInt& aValue); |
|
78 |
|
79 /** |
|
80 * @brief Sets the value of a single capability. |
|
81 * |
|
82 * Sets the value of a single capability. The value is passed as a TInt. |
|
83 * For Float capabilities it is the numerator. |
|
84 * |
|
85 * Changes in certain capability values can affect other capabilities, |
|
86 * such as a change in paper size changes the available templates. |
|
87 * When this occurs, the affected capabilities are returned in the |
|
88 * aAffectedCapability field. If there are any, the client should get |
|
89 * these capabilities again. |
|
90 * |
|
91 * @param[in] aCapabilityID Id of the capability to be setted. |
|
92 * @param[in] aValue Value to set the capability to. |
|
93 * @param[out] aAffectedCapability 0=None, else CapabilityID |
|
94 * |
|
95 * @return KErrNone if successful, KErrInvalidSequence if job is not active, |
|
96 * KErrInvalidData if setting request is invalid (either capability ID or value). |
|
97 * Otherwise another of the system-wide error codes. |
|
98 */ |
|
99 TInt SetJobSettingL(TInt aCapabilityID, TInt aValue, TInt& aAffectedCapability); |
|
100 |
|
101 // Preview. |
|
102 TInt GetNumPreviewPages(); |
|
103 |
|
104 /** |
|
105 * @brief Creates a CFbsBitmap object and fills it with the preview bitmap. |
|
106 * |
|
107 * @param[in] aTemplateID Layout Capability ID of the icon desired. |
|
108 * @param[out] aFsBitmapHandle |
|
109 * |
|
110 * @return KErrNone, or another of the system-wide error codes. |
|
111 */ |
|
112 TInt GetJobTemplateIconL(TInt aTemplateID, TInt& aFsBitmapHandle); |
|
113 |
|
114 /** |
|
115 * Creates a preview image in a CFbsBitmap object. PreviewImageEvent() is called on the PrintEventObserver. |
|
116 * |
|
117 * @param aPageNumber Currently unused |
|
118 * |
|
119 * @return KErrNone if successful, KErrInvalidData if the Preview Image could not be loaded, or another of the system-wide error codes. |
|
120 */ |
|
121 TInt CreatePreviewImage(TInt aPageNumber); |
|
122 |
|
123 void RegisterIdleObserver(MProtIdleObserver * /*aObserver*/) {}; |
|
124 |
|
125 void SetNumsOfCopiesL( const RArray<TInt>& aNumsOfCopies, TInt& aErr ); |
|
126 |
|
127 void CreateJobResponse( TInt aJobId, TInt aErrorCode ); |
|
128 |
|
129 void CancelJobResponse(TInt aErrorCode ); |
|
130 |
|
131 void GetPrinterStateResponse(TInt aState, |
|
132 TInt aStateReasons, |
|
133 TInt aOperationStatus, TInt aDeviceId); |
|
134 |
|
135 void GetEventResponse(TInt aJobId, |
|
136 TInt aJobState, |
|
137 TInt aPrinterState, |
|
138 TInt aStateReasons, |
|
139 TInt aOperationStatus); |
|
140 |
|
141 void GetJobAttributesResponse( TInt aJobState, |
|
142 const TDesC8& aJobName, |
|
143 const TDesC8& aOriginator, |
|
144 TInt aSheetsCompleted, |
|
145 TInt aPendingJobs, |
|
146 TInt aErrorCode ); |
|
147 |
|
148 void DeviceDiscovered( CRsBtDevice& aDevice ); |
|
149 void DeviceDisappeared( CRsBtDevice& aDevice ); |
|
150 void DiscoveryError(TInt aError); |
|
151 |
|
152 /* |
|
153 * Updates OPP printing progress bar. |
|
154 * */ |
|
155 void OPPSendProgress( TInt aProgress ); |
|
156 |
|
157 public: //own |
|
158 static TBool HandleTimeout(TAny *aWho); |
|
159 |
|
160 private: |
|
161 |
|
162 virtual void RunL(); |
|
163 virtual void DoCancel(); |
|
164 virtual TInt RunError(TInt aError); |
|
165 |
|
166 void GetUsedDevicesL(); |
|
167 |
|
168 void InitJobL(CRsBtDevice *aPrinter, RPointerArray<TDesC>& aImages); |
|
169 |
|
170 TBool InformObserver(TInt aUsedProtocol); |
|
171 |
|
172 void GetCapabilities(CRsBtDevice& aPrinter, TBool aForcedGet = EFalse); |
|
173 void GetDefaultCapabilities(RArray<TPrintCapability>& aCapabilities); |
|
174 |
|
175 void FoundDeviceL(CRsBtDevice& aDevice); |
|
176 void UpdateCacheList(); |
|
177 |
|
178 TBool DoHandleTimeout(); |
|
179 |
|
180 void ResetTimer(); |
|
181 void StartTimer(TTimeIntervalMicroSeconds32 aDelay, |
|
182 TTimeIntervalMicroSeconds32 anInterval, |
|
183 TCallBack aCallBack); |
|
184 |
|
185 CRsBtDevice* FindDevice(TInt aPrinterID); |
|
186 |
|
187 TInt AddBtDeviceL(CRsBtDevice& aDevice); |
|
188 |
|
189 void FinishPrinting(TInt aErrorCode); |
|
190 |
|
191 void ManagePrintingState(TInt aJobId, TInt aJobState, TInt aPrinterState, |
|
192 TInt aStateReasons, TInt aOperationStatus); |
|
193 |
|
194 void GetJobAttributesL(); |
|
195 void GetPrinterStateL(); |
|
196 void CancelJobL(); |
|
197 void Deactivate(); |
|
198 // updates the printing proggress if increased and resets the pending counter if so. |
|
199 TInt UpdateProggress(); |
|
200 void GetLocalBTNameL(TDes8& aName); |
|
201 void OPPJobRollBack(); |
|
202 |
|
203 private: |
|
204 |
|
205 enum TDeviceState |
|
206 { |
|
207 ENone, |
|
208 EReady, |
|
209 EGetPrinterState, |
|
210 EGetJobAttributes, |
|
211 EFinish, |
|
212 EDiscovering, |
|
213 EJobProgress, |
|
214 ECancelJob |
|
215 }; |
|
216 |
|
217 /// State operating. |
|
218 TDeviceState iState; |
|
219 |
|
220 /// Print job object. |
|
221 CPrintJob* iPrintingJob; |
|
222 |
|
223 CBtPrinterController* iPrinterController; |
|
224 CBtDeviceContainer* iDeviceContainer; |
|
225 |
|
226 /// Requested Protocols for Discovery |
|
227 TUint iRequestedProtocols; |
|
228 |
|
229 /// Print error. |
|
230 TInt iPrintError; |
|
231 /// Print error message code. |
|
232 TInt iPrintErrorMsgCode; |
|
233 |
|
234 TUint iPendingCount; |
|
235 |
|
236 CPeriodic* iPrinterTimer; |
|
237 |
|
238 TInt iProggress; |
|
239 |
|
240 // used BlueTooth profile |
|
241 TUint iUsedBtProfile; |
|
242 |
|
243 |
|
244 }; |
|
245 |
|
246 #endif // CBTPRINTINGDEVICE_H |
|
247 |
|
248 // End of File |