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 #include "cimageprint.h" |
|
20 #include "cidleguard.h" |
|
21 #include "cdiscoveryguard.h" |
|
22 #include "cjobguard.h" |
|
23 #include "clog.h" |
|
24 |
|
25 const static TInt KImagePrintVersionMajor = 0; |
|
26 const static TInt KImagePrintVersionMinor = 0; |
|
27 const static TInt KImagePrintVersionBuild = 231; |
|
28 |
|
29 /********************** |
|
30 Public member functions |
|
31 **********************/ |
|
32 |
|
33 CImagePrint::CImagePrint () |
|
34 { |
|
35 } |
|
36 |
|
37 /// Destructor. |
|
38 CImagePrint::~CImagePrint () |
|
39 { |
|
40 LOG("CImagePrint::~CImagePrint BEGIN"); |
|
41 delete iDiscoveryGuard; |
|
42 delete iIdleGuard; |
|
43 delete iJobGuard; |
|
44 CCoeEnv::Static()->RemoveForegroundObserver( *this ); |
|
45 iClient.Close(); |
|
46 LOG("CImagePrint::~CImagePrint END"); |
|
47 } |
|
48 |
|
49 /** |
|
50 * @brief Initialize the server. |
|
51 */ |
|
52 void CImagePrint::ConnectL() |
|
53 { |
|
54 if( iClient.Handle() == KNullHandle ) |
|
55 { |
|
56 User::LeaveIfError( iClient.ConnectL() ); |
|
57 iIdleGuard = CIdleGuard::NewL( iClient ); |
|
58 iDiscoveryGuard = CDiscoveryGuard::NewL( iClient ); |
|
59 iJobGuard = CJobGuard::NewL( iClient ); |
|
60 User::LeaveIfError( iClient.ReserveEngine() ); |
|
61 iClient.SetForeground( ETrue ); //For aiw cases |
|
62 CCoeEnv::Static()->AddForegroundObserverL( *this ); |
|
63 } |
|
64 } |
|
65 |
|
66 /** |
|
67 * @brief Shutdown the server. |
|
68 */ |
|
69 void CImagePrint::Close() |
|
70 { |
|
71 iClient.ReleaseEngine(); |
|
72 } |
|
73 |
|
74 /** |
|
75 * @brief Returns the current version of the Image Print Server |
|
76 * @return The current version of the Image Print Server |
|
77 */ |
|
78 TVersion CImagePrint::Version() |
|
79 { |
|
80 return TVersion(KImagePrintVersionMajor, KImagePrintVersionMinor, KImagePrintVersionBuild); // Julian Day, August 18. |
|
81 } |
|
82 |
|
83 /** |
|
84 * @brief Starts the discovery process. |
|
85 * |
|
86 * Starts printer discovery on specified printer plug-ins. This is an asynchronous call that will use the |
|
87 * supplied MPrinterDiscoveryObserver to signal the client when Printers are found and upon error or successful completion. |
|
88 * |
|
89 * @param aObserver The discovery observer. |
|
90 * @param aProtocols Used to indicate what protocols to search for. 0 = all, 1 = BPP, 2 = BIP, 4 = OPP_Printer, 8 = DPOF, 16 = PB, 32 = OPP_PC |
|
91 * @return Any standard Symbian error code. |
|
92 * @sa KImagePrint_PrinterProtocol_BPP @sa KImagePrint_PrinterProtocol_BIP @sa KImagePrint_PrinterProtocol_OPP_Printer |
|
93 * @sa KImagePrint_PrinterProtocol_DPOF @sa KImagePrint_PrinterProtocol_PictBridge @sa KImagePrint_PrinterProtocol_OPP_PC |
|
94 */ |
|
95 TInt CImagePrint::StartDiscoveryL(MPrinterDiscoveryObserver& aObserver, TUint aProtocols) |
|
96 { |
|
97 return iDiscoveryGuard->Guard( aObserver, aProtocols ); |
|
98 } |
|
99 |
|
100 /** |
|
101 * Cancels printer discovery on all printer plug-ins. This is an asynchronous call |
|
102 * that will use the MPrinterDiscoveryObserver previously supplied by |
|
103 * CImagePrint::StartDiscoveryL to signal the client upon error or successful completion. |
|
104 * @brief Cancels the discovery process. |
|
105 * @return \c KErrNone if cancel was successfully submitted, otherwise another of the system-wide error codes. |
|
106 */ |
|
107 TInt CImagePrint::CancelDiscovery() |
|
108 { |
|
109 return iClient.CancelDiscovery(); |
|
110 } |
|
111 |
|
112 /** |
|
113 * Creates a print job using the default settings and template. All job information beyond the images and Printer are set to the defaults of the printer. |
|
114 * If the Printer Discovery process is ongoing when \c CreatePrintJobL is received, Printer Discovery is terminated, without sending a notification event to the Client. |
|
115 * @brief Creates a print job in the specified printer. |
|
116 * @param[in] aPrinterID The exposed ID of the printer where the client wishes to create the print job. |
|
117 * @param aImages Array containing the full names of the files to print. |
|
118 * @param aObserver The print event observer. |
|
119 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
120 * @note Only one print job can be active at a time. The Print Job must be created before any |
|
121 * print job related functions are called. These functions include changing settings, preview, job submission, canceling, or getting status. |
|
122 */ |
|
123 TInt CImagePrint::CreatePrintJobL(TInt aPrinterID, RPointerArray<TDesC>& aImages, MPrintEventObserver& aObserver) |
|
124 { |
|
125 return iJobGuard->Guard(aPrinterID, aImages, aObserver); |
|
126 } |
|
127 |
|
128 /** |
|
129 * @brief Submits a print job already created. |
|
130 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
131 * @note The actual job execution is asynchronous so this function returns immediately. If successful, notification of job status and job completion is received by the client through the MPrintEventObserver. |
|
132 */ |
|
133 TInt CImagePrint::SubmitPrintJobL() |
|
134 { |
|
135 return iClient.SubmitPrintJob(); |
|
136 } |
|
137 |
|
138 /** |
|
139 * @brief Cancels the print job. |
|
140 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
141 * @note This is an asynchronous command. MPrintEventObserver::PrintJobProgressEvent will be called with the status of TPrintJobProgressEventStatus::EDone when the cancellation is completed. |
|
142 * @note The notification can potentially be received by the client before this command returns to the client. |
|
143 */ |
|
144 TInt CImagePrint::CancelPrintJob() |
|
145 { |
|
146 LOG("CImagePrint::CancelPrintJob"); |
|
147 return iClient.CancelPrintJob(); |
|
148 } |
|
149 |
|
150 /** |
|
151 * @brief Continues printing and / or submitting a print job. Implementation may vary from protocol to protocol. |
|
152 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
153 */ |
|
154 TInt CImagePrint::ContinuePrintJobL() |
|
155 { |
|
156 return iClient.ContinuePrintJob(); |
|
157 } |
|
158 |
|
159 /** |
|
160 * @brief Gets the number of pages to be printed. |
|
161 * @return Number of pages to print. |
|
162 */ |
|
163 TInt CImagePrint::GetNumPrintPages() |
|
164 { |
|
165 return iClient.GetNumPrintPages(); |
|
166 } |
|
167 |
|
168 /** |
|
169 * @brief Gets the status of the printing job created. |
|
170 * @return Printing job status. |
|
171 */ |
|
172 TInt CImagePrint::GetJobStatus() |
|
173 { |
|
174 return iClient.GetJobStatus(); |
|
175 } |
|
176 |
|
177 /** |
|
178 * @brief Gets the status of the printer. |
|
179 * @param[in] aPrinterID The exposed ID of the printer the client wants to know about. |
|
180 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
181 */ |
|
182 TInt CImagePrint::GetPrinterStatus( TInt aPrinterID ) |
|
183 { |
|
184 return iClient.GetPrinterStatus( aPrinterID ); |
|
185 } |
|
186 |
|
187 /** |
|
188 * @brief Gets the IDs of the capabilities supported by the printer specified. |
|
189 * @param[in] aPrinterID The exposed ID of the printer the client wants to know about. |
|
190 * @param[out] aCapabilityIDs Array containing the ID's of the capabilities of the specified printer. |
|
191 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
192 */ |
|
193 TInt CImagePrint::GetPrinterCapabilityIDsL(TInt aPrinterID, RArray<TInt>& aCapabilityIDs) |
|
194 { |
|
195 return iClient.GetPrinterCapabilityIDs(aPrinterID, aCapabilityIDs); |
|
196 } |
|
197 |
|
198 /** |
|
199 * @brief Gets the detail of a certain capability of a certain printer. |
|
200 * @param[in] aPrinterID The exposed ID of the printer the client wants to know about. |
|
201 * @param[in] aCapabilityID ID of the capability of interest. |
|
202 * @param[out] aCapability Capability information. |
|
203 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
204 */ |
|
205 TInt CImagePrint::GetPrinterCapabilityL(TInt aPrinterID, TInt aCapabilityID, TPrintCapability& aCapability) |
|
206 { |
|
207 return iClient.GetPrinterCapability(aPrinterID, aCapabilityID, aCapability); |
|
208 } |
|
209 |
|
210 /** |
|
211 * @brief Gets a setting configured for the created print job. |
|
212 * @param[in] aCapabilityID ID of the capability of interest. |
|
213 * @param[out] aValue Capability value. |
|
214 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
215 */ |
|
216 TInt CImagePrint::GetJobSetting(TInt aCapabilityID, TInt& aValue) |
|
217 { |
|
218 return iClient.GetJobSetting(aCapabilityID, aValue); |
|
219 } |
|
220 |
|
221 /** |
|
222 * @brief Sets a print job setting. |
|
223 * @param[in] aCapabilityID ID of the capability of interest. |
|
224 * @param[in] aValue New capability value. |
|
225 * @param[out] aAffectedCapability ID of any affected capability. |
|
226 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
227 */ |
|
228 TInt CImagePrint::SetJobSettingL(TInt aCapabilityID, TInt aValue, TInt& aAffectedCapability) |
|
229 { |
|
230 return iClient.SetJobSetting(aCapabilityID, aValue, aAffectedCapability); |
|
231 } |
|
232 |
|
233 /** |
|
234 * @brief Gets the number of pages in the preview. |
|
235 * @return Number of pages in the preview. |
|
236 */ |
|
237 TInt CImagePrint::GetNumPreviewPages() |
|
238 { |
|
239 return iClient.GetNumPreviewPages(); |
|
240 } |
|
241 |
|
242 /** |
|
243 * @brief Gets the icon representing a given layout or template. |
|
244 * @param[in] aTemplateID ID of the template / layout of interest. |
|
245 * @param[out] aFbsBitmapHandle Handle to the appropriate bitmap. |
|
246 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
247 */ |
|
248 TInt CImagePrint::GetJobTemplateIconL(TInt /*aTemplateID*/, TInt& /*aFbsBitmapHandle*/) |
|
249 { |
|
250 return KErrNotSupported; |
|
251 } |
|
252 |
|
253 /** |
|
254 * @brief Gets number of copies for each image. |
|
255 * @param[out] aArray contains number of copies for each image. |
|
256 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
257 */ |
|
258 TInt CImagePrint::GetNumberOfCopies( RArray<TInt>& /*aArray*/ ) |
|
259 { |
|
260 return KErrNotSupported; |
|
261 } |
|
262 |
|
263 /** |
|
264 * @brief Sets number of copies for each image. |
|
265 * @param[in] aArray contains number of copies for each image. |
|
266 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
267 */ |
|
268 TInt CImagePrint::SetNumberOfCopies( const RArray<TInt>& aArray ) |
|
269 { |
|
270 return iClient.SetNumberOfCopies( aArray ); |
|
271 } |
|
272 |
|
273 /** |
|
274 * @brief Creates a preview image. |
|
275 * @param[in] aPageNumber Page number to create preview image of. |
|
276 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData. |
|
277 */ |
|
278 TInt CImagePrint::CreatePreviewImage(TInt /*aPageNumber*/) |
|
279 { |
|
280 return KErrNotSupported; |
|
281 } |
|
282 |
|
283 /** |
|
284 * @brief Removes a specified cached printer. |
|
285 * @param[in] aPrinterID The exposed ID of the printer the client wants to remove. |
|
286 * @return Any standard Symbian error code or KErrInvalidSequence / KErrInvalidData.k |
|
287 */ |
|
288 TInt CImagePrint::RemoveCachedPrinterL(TInt aPrinterID) |
|
289 { |
|
290 return iClient.RemoveCachedPrinter( aPrinterID ); |
|
291 } |
|
292 |
|
293 /** |
|
294 * @brief Returns the Protocols supported by the DLL. It can be any of the KImagePrint_PrinterProtocol* constants. |
|
295 * @return An OR'ed value with the supported protocols information. |
|
296 * @sa KImagePrint_PrinterProtocol_BPP @sa KImagePrint_PrinterProtocol_BIP @sa KImagePrint_PrinterProtocol_OPP |
|
297 * @sa KImagePrint_PrinterProtocol_DPOF @sa KImagePrint_PrinterProtocol_PictBridge |
|
298 */ |
|
299 TUint CImagePrint::SupportedProtocols() |
|
300 { |
|
301 return iClient.SupportedProtocols(); |
|
302 } |
|
303 |
|
304 /** |
|
305 * @brief Registers the IdleObserver to send idle event notifications |
|
306 * @param A pointer to an object implementing MIdleObserver interface that will be notified of events |
|
307 * @note In order to stop sending notifications, send NULL as the parameter. |
|
308 */ |
|
309 void CImagePrint::RegisterIdleObserver(MIdleObserver *aObserver) |
|
310 { |
|
311 iIdleGuard->Guard( aObserver ); |
|
312 } |
|
313 |
|
314 void CImagePrint::HandleGainingForeground() |
|
315 { |
|
316 iClient.SetForeground( ETrue ); |
|
317 } |
|
318 |
|
319 void CImagePrint::HandleLosingForeground() |
|
320 { |
|
321 iClient.SetForeground( EFalse ); |
|
322 } |
|
323 |
|
324 // End of File |
|