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 TBtMapper class definition. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TBTMAPPER_H |
|
20 #define TBTMAPPER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <libc/stdlib.h> |
|
24 |
|
25 #include "printmessagecodes.h" |
|
26 #include "printcapabilitycodes.h" |
|
27 |
|
28 enum TBtPrintState |
|
29 { |
|
30 EBtStateUnknown = 0, //@brief job state not known |
|
31 EBtStateIdle, //@brief printer state idle |
|
32 EBtStateProcessing, //@brief printer processing |
|
33 EBtStateStopped, //@brief printer or job state stopped |
|
34 EBtStatePrinting, //@brief printing job |
|
35 EBtStateWaiting, //@brief job is waiting |
|
36 EBtStateCompleted, //@brief job ready |
|
37 EBtStateAborted, //@brief job aborted for some error |
|
38 EBtStateCancelled, //@brief job cancelled |
|
39 EBtStateSending //@brief sending job. Internal state to indicate the data is about transmissed. |
|
40 }; |
|
41 |
|
42 _LIT8(KBtStateUnknown, "unknown"); |
|
43 _LIT8(KBtStateIdle, "idle"); |
|
44 _LIT8(KBtStateProcessing, "processing"); |
|
45 _LIT8(KBtStateStopped, "stopped"); |
|
46 _LIT8(KBtStatePrinting, "printing"); |
|
47 _LIT8(KBtStateWaiting, "waiting"); |
|
48 _LIT8(KBtStateCompleted, "completed"); |
|
49 _LIT8(KBtStateAborted, "aborted"); |
|
50 _LIT8(KBtStateCancelled, "cancelled"); |
|
51 |
|
52 _LIT8(KPrintReasonNone, "none"); |
|
53 _LIT8(KPrintReasonAttentionRequired, "attention-required"); |
|
54 _LIT8(KPrintReasonMediaJam, "media-jam"); |
|
55 _LIT8(KPrintReasonPaused, "paused"); |
|
56 _LIT8(KPrintReasonDoorOpen, "door-open"); |
|
57 _LIT8(KPrintReasonMediaLow, "media-low"); |
|
58 _LIT8(KPrintReasonMediaEmpty, "media-empty"); |
|
59 _LIT8(KPrintReasonOutputAreaAlmostFull, "output-area-almost-full"); |
|
60 _LIT8(KPrintReasonOutputAreaFull, "output-area-full"); |
|
61 _LIT8(KPrintReasonMarkerSupplyLow, "marker-supply-low"); |
|
62 _LIT8(KPrintReasonMarkerSupplyEmpty, "marker-supply-empty"); |
|
63 _LIT8(KPrintReasonMarkerFailure, "marker-failure"); |
|
64 _LIT8(KPrintReasonMediaChangeRequest, "media-change-request"); |
|
65 _LIT8(KPrintReasonVendorDefined, "vendor-defined"); |
|
66 _LIT8(KPrintReasonHwError, "hardware-error"); |
|
67 _LIT8(KPrintReasonUriNotFound, "external-access-uri-not-found"); |
|
68 _LIT8(KPrintReasonObjectFailure, "external-access-object-failure"); |
|
69 _LIT8(KPrintReasonFormatError, "external-access-doc-format-error"); |
|
70 _LIT8(KPrintReasonHttpError, "external-access-http-error"); |
|
71 _LIT8(KPrintReasonCopies, "copies"); |
|
72 _LIT8(KPrintReasonSides, "sides"); |
|
73 _LIT8(KPrintReasonNumberUp, "number-up"); |
|
74 _LIT8(KPrintReasonOrientationRequested, "orientation-requested"); |
|
75 _LIT8(KPrintReasonMediaSize, "media-size"); |
|
76 _LIT8(KPrintReasonMediaType, "media-type"); |
|
77 _LIT8(KPrintReasonPrintQuality, "print-quality"); |
|
78 _LIT8(KPrintReasonTextLayout, "text-layout"); |
|
79 _LIT8(KPrintReasonImageLayout, "image-layout"); |
|
80 _LIT8(KPrintReasonImageOrientation, "image-orientation"); |
|
81 _LIT8(KPrintReasonPdlFidelity, "pdl-fidelity"); |
|
82 _LIT8(KPrintReasonFontFamily, "font-family"); |
|
83 _LIT8(KPrintReasonFontSize, "font-size"); |
|
84 |
|
85 |
|
86 // Paper size |
|
87 // According to the "ftp://ftp.pwg.org/pub/pwg/standards/pwg5101.1.pdf", |
|
88 // only the size of paper is defined |
|
89 _LIT8(KPaperSizeMax, "custom_max_"); //custom_max_[nn]x[nn][mm|in] |
|
90 _LIT8(KPaperSizeMin, "custom_min_"); //custom_min_[nn]x[nn][mm|in] |
|
91 _LIT8(KPaperSizeA6, "_105x148mm"); //iso_a6_105x148mm |
|
92 _LIT8(KPaperSizeA4, "_210x297mm"); //iso_a4_210x297mm |
|
93 _LIT8(KPaperSize5x7, "_5x7in"); //na_5x7_5x7in |
|
94 _LIT8(KPaperSize4x6, "_4x6in"); //na_index-4x6_4x6in |
|
95 _LIT8(KPaperSizeLetter, "_8.5x11in"); //na_letter_8.5x11in |
|
96 |
|
97 // Quality |
|
98 _LIT8(KQualityDraft, "draft"); |
|
99 _LIT8(KQualityNormal, "normal"); |
|
100 _LIT8(KQualityHigh, "high"); |
|
101 |
|
102 _LIT8(KHexPrefix, "0x"); |
|
103 |
|
104 /** |
|
105 * @brief A printer abstraction. |
|
106 * |
|
107 * Class representing the basic properties of a printing device. |
|
108 * Published as part of the ImagePrint Server API. |
|
109 */ |
|
110 class TBtMapper |
|
111 { |
|
112 public: |
|
113 |
|
114 inline static TInt32 HexToInt(const TDesC8& aString) |
|
115 { |
|
116 TInt len(0); |
|
117 if( KErrNotFound < aString.Find(KHexPrefix())) |
|
118 len = KHexPrefix().Length(); |
|
119 |
|
120 TPtrC8 str = aString.Right(aString.Length()-len); |
|
121 |
|
122 TLex8 lex(str); |
|
123 TUint32 val = KErrNotFound; |
|
124 lex.Val(val, EHex); |
|
125 LOG82("[TBtMapper::OperationStatus]\t %S: %d", &aString, val); |
|
126 return val; |
|
127 } |
|
128 |
|
129 inline static TInt32 HexToInt(const TDesC& aString) |
|
130 { |
|
131 TBuf8<0x100> str; |
|
132 str.Copy(aString); |
|
133 return HexToInt(str); |
|
134 } |
|
135 |
|
136 inline static TInt32 Int(const TDesC8& aString) |
|
137 { |
|
138 TLex8 lex(aString); |
|
139 TInt32 value = KErrNotFound; |
|
140 lex.Val(value); |
|
141 return value; |
|
142 } |
|
143 |
|
144 inline static TInt32 Int(const TDesC& aString) |
|
145 { |
|
146 TLex lex(aString); |
|
147 TInt32 value = KErrNotFound; |
|
148 lex.Val(value); |
|
149 return value; |
|
150 } |
|
151 |
|
152 inline static TUint32 Uint(const TDesC8& aString) |
|
153 { |
|
154 TUint32 value = Int(aString); |
|
155 return value; |
|
156 } |
|
157 |
|
158 inline static TUint32 Uint(const TDesC& aString) |
|
159 { |
|
160 TUint32 value = Int(aString); |
|
161 return value; |
|
162 } |
|
163 |
|
164 inline static TInt State(const TDesC8& aStrState) |
|
165 { |
|
166 if(0 == aStrState.Compare(KBtStateUnknown)) //job |
|
167 return EBtStateUnknown; |
|
168 if(0 == aStrState.Compare(KBtStateIdle)) // printer |
|
169 return EBtStateIdle; |
|
170 if(0 == aStrState.Compare(KBtStateProcessing)) // printer |
|
171 return EBtStateProcessing; |
|
172 if(0 == aStrState.Compare(KBtStateStopped)) //job, printer |
|
173 return EBtStateStopped; |
|
174 if(0 == aStrState.Compare(KBtStatePrinting)) //job |
|
175 return EBtStatePrinting; |
|
176 if(0 == aStrState.Compare(KBtStateWaiting)) //job |
|
177 return EBtStateWaiting; |
|
178 if(0 == aStrState.Compare(KBtStateCompleted)) //job |
|
179 return EBtStateCompleted; |
|
180 if(0 == aStrState.Compare(KBtStateAborted)) //job |
|
181 return EBtStateAborted; |
|
182 if(0 == aStrState.Compare(KBtStateCancelled)) //job |
|
183 return EBtStateCancelled; |
|
184 |
|
185 return EBtStateUnknown; |
|
186 } |
|
187 |
|
188 inline static TInt PrintError(const TDesC8& aCode) |
|
189 { |
|
190 if(0 == aCode.Compare(KPrintReasonNone)) |
|
191 return ENoMessage; |
|
192 if(0 == aCode.Compare(KPrintReasonAttentionRequired)) |
|
193 return EPrintReasonAttentionRequired; |
|
194 if(0 == aCode.Compare(KPrintReasonMediaJam)) |
|
195 return EPbStatusErrorReasonPaperJam; |
|
196 if(0 == aCode.Compare(KPrintReasonPaused)) |
|
197 return EPrintReasonPaused; |
|
198 if(0 == aCode.Compare(KPrintReasonDoorOpen)) |
|
199 return EPbStatusErrorReasonHardwareCoverOpen; |
|
200 if(0 == aCode.Compare(KPrintReasonMediaLow)) |
|
201 return EPbStatusErrorReasonPaperNearlyEmpty; |
|
202 if(0 == aCode.Compare(KPrintReasonMediaEmpty)) |
|
203 return EPbStatusErrorReasonPaperEmpty; |
|
204 if(0 == aCode.Compare(KPrintReasonOutputAreaAlmostFull)) |
|
205 return EPrintReasonOutputAreaAlmostFull; |
|
206 if(0 == aCode.Compare(KPrintReasonOutputAreaFull)) |
|
207 return EPrintReasonOutputAreaFull; |
|
208 if(0 == aCode.Compare(KPrintReasonMarkerSupplyLow)) |
|
209 return EPrintReasonMarkerSupplyLow; |
|
210 if(0 == aCode.Compare(KPrintReasonMarkerSupplyEmpty)) |
|
211 return EPrintReasonMarkerSupplyEmpty; |
|
212 if(0 == aCode.Compare(KPrintReasonMarkerFailure)) |
|
213 return EPrintReasonMarkerFailure; |
|
214 if(0 == aCode.Compare(KPrintReasonMediaChangeRequest)) |
|
215 return EPbStatusErrorReasonPaperMedia; |
|
216 if(0 == aCode.Compare(KPrintReasonVendorDefined)) |
|
217 return EPbCheckPrinter; |
|
218 |
|
219 return EPbCheckPrinter; |
|
220 }; |
|
221 |
|
222 inline static TInt HttpError(TInt /*aCode*/) |
|
223 { |
|
224 return EPbCheckPrinter; |
|
225 }; |
|
226 |
|
227 inline static TInt OperationStatus(const TDesC8& aCode) |
|
228 { |
|
229 return HexToInt(aCode); |
|
230 } |
|
231 |
|
232 inline static void Layout(const TDesC8& aCode, RArray<TInt>& aArray) |
|
233 { |
|
234 TInt layout; |
|
235 switch(Int(aCode)) |
|
236 { |
|
237 case 16: |
|
238 layout = EPrintCapabLayout16Up; |
|
239 aArray.Append(layout); |
|
240 case 12: |
|
241 layout = EPrintCapabLayout12Up; |
|
242 aArray.Append(layout); |
|
243 case 9: |
|
244 layout = EPrintCapabLayout9Up; |
|
245 aArray.Append(layout); |
|
246 case 6: |
|
247 layout = EPrintCapabLayout6Up; |
|
248 aArray.Append(layout); |
|
249 case 4: |
|
250 layout = EPrintCapabLayout4Up; |
|
251 aArray.Append(layout); |
|
252 case 2: |
|
253 layout = EPrintCapabLayout2Up; |
|
254 aArray.Append(layout); |
|
255 case 1: |
|
256 layout = EPrintCapabLayout1UpBorder; |
|
257 aArray.Append(layout); |
|
258 default: |
|
259 layout = EPrintCapabLayout1UpBorderless; |
|
260 aArray.Append(layout); |
|
261 break; |
|
262 |
|
263 } |
|
264 }; |
|
265 |
|
266 inline static TInt Size(const TDesC8& aCode) |
|
267 { |
|
268 if(0 <= aCode.Find(KPaperSize4x6)) |
|
269 return EPrintCapabPaperSize4x6;//default |
|
270 if(0 <= aCode.Find(KPaperSizeA4)) |
|
271 return EPrintCapabPaperSizeA4; |
|
272 if(0 <= aCode.Find(KPaperSizeA6)) |
|
273 return EPrintCapabPaperSizeA6; |
|
274 if(0 <= aCode.Find(KPaperSize5x7)) |
|
275 return EPrintCapabPaperSize5x7; |
|
276 if(0 <= aCode.Find(KPaperSizeLetter)) |
|
277 return EPrintCapabPaperSizeLetter; |
|
278 return KErrNotSupported; |
|
279 }; |
|
280 |
|
281 inline static TInt Quality(const TDesC8& aCode) |
|
282 { |
|
283 if(0 <= aCode.Find(KQualityDraft)) |
|
284 return EPrintCapabQualityDraft; |
|
285 if(0 <= aCode.Find(KQualityNormal)) |
|
286 return EPrintCapabQualityNormal; |
|
287 if(0 <= aCode.Find(KQualityHigh)) |
|
288 return EPrintCapabQualityFine; |
|
289 return EPrintCapabQualityDefault; |
|
290 }; |
|
291 |
|
292 inline static TInt TripletValue(const TDesC8& aParams, TInt& aPos, TUint& aTag) |
|
293 { |
|
294 // get tag |
|
295 aTag = aParams[aPos]; |
|
296 ++aPos; |
|
297 |
|
298 //get len |
|
299 TInt len = aParams[aPos]; |
|
300 ++aPos; |
|
301 |
|
302 TInt value = 0; |
|
303 TInt shift = (len-1)*8; |
|
304 while(0 <= shift) |
|
305 { |
|
306 value |= (aParams[aPos] << shift); |
|
307 ++aPos; |
|
308 shift -= 8; |
|
309 } |
|
310 |
|
311 return value; |
|
312 }; |
|
313 |
|
314 }; |
|
315 |
|
316 #endif // TBTMAPPER_H |
|
317 |
|
318 // End of File |
|