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 CPrinterControlPoint class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPRINTERCONTROLPOINT_H |
|
20 #define CPRINTERCONTROLPOINT_H |
|
21 |
|
22 #include <upnpcontrolpoint.h> |
|
23 |
|
24 #include "mpcpobserver.h" |
|
25 #include "cjobstateevents.h" |
|
26 #include "upconsts.h" |
|
27 |
|
28 class CUpnpDevice; |
|
29 class CUpnpAction; |
|
30 class CUpnpHttpMessage; |
|
31 |
|
32 enum TPrintService |
|
33 { |
|
34 EServiceNone = 0, |
|
35 EPrintBasic, |
|
36 EPrintEnhanced |
|
37 }; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * @brief Declares the CPrinterControlPoint |
|
43 * |
|
44 * Prior using the CPrinterControlPoint class, client application has to create |
|
45 * the network connection for the selected IAP. If connection is not up and |
|
46 * running, the CDispatcherEngine class construction will fail. |
|
47 * |
|
48 * The Printer Control Point starts XHTML folder sharing and printer search when it's constructed. |
|
49 * |
|
50 * See UPnP Print Design document for instuctions. |
|
51 * |
|
52 * @since Series60 2.0 |
|
53 */ |
|
54 class CPrinterControlPoint : public CUpnpControlPoint//, public MUPnPSecurityObserver |
|
55 { |
|
56 public: // Constructors and destructors |
|
57 |
|
58 /** |
|
59 * Create a CPrinterControlPoint object using two phase construction. |
|
60 * @param aPCPObserver |
|
61 * @param aFriendlyName Specifies the friendly name of the control point. |
|
62 * @param aIapId IAP to use. |
|
63 * @result pointer to created CPrinterControlPoint object. |
|
64 */ |
|
65 IMPORT_C static CPrinterControlPoint* NewL( MPCPObserver& aPCPObserver); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 IMPORT_C ~CPrinterControlPoint(); |
|
71 |
|
72 public: // From MUPnPSecurityObserver |
|
73 /** |
|
74 * Function informs when file sharing is ready |
|
75 * @since Series 60 3.0 |
|
76 */ |
|
77 |
|
78 public: |
|
79 |
|
80 /** |
|
81 * Create a print job to the printer. The XHTML-print files must be in folder defined by KUPnPDataPath. |
|
82 * @since Series60 3.0 |
|
83 * @param aPrinter Printer to be used. |
|
84 * @param aPrintFile XHTML-Print file's name WITHOUT path (NOTE: path for files defined in KUPnPDataPath) |
|
85 * @param aCopies Number of copies of the document to be printed for the job. |
|
86 * @param aSides Specifies how pages are to be imposed upon the sides of a selected medium for the job. |
|
87 * @param aNumberUp Indicates the number of pages to impose upon a single side. |
|
88 * @param aOrientationRequest Indicates the desired orientation for printed pages. |
|
89 * @param aMediaSize Identifies the medium size name and dimensions. |
|
90 * @param aMediaType Identtifies the medium type. |
|
91 * @param aPrintQuality Specifies the print quality requested for the job. |
|
92 * @param aPrintBasic Specifies the service to use for printing. |
|
93 */ |
|
94 IMPORT_C TInt CreateJobL( CUpnpDevice* aPrinter, |
|
95 const TDesC8& aPrintFile, |
|
96 const TDesC8& aUserName, |
|
97 const TDesC8& aCopies, |
|
98 const TDesC8& aSides, |
|
99 const TDesC8& aNumberUp, |
|
100 const TDesC8& aOrientationRequest, |
|
101 const TDesC8& aMediaSize, |
|
102 const TDesC8& aMediaType, |
|
103 const TDesC8& aPrintQuality, |
|
104 TBool aPrintBasic = EFalse ); |
|
105 |
|
106 /** |
|
107 * Cancel a specified print job. Leaves if printer is invalid. |
|
108 * @since Series60 3.0 |
|
109 * @param aPrinter Printer to be used. |
|
110 * @param aJobId Print job ID of cancelled job. |
|
111 */ |
|
112 IMPORT_C void CancelJobL( CUpnpDevice* aPrinter, const TDesC8& aJobId ); |
|
113 |
|
114 /** |
|
115 * Cancel a specified print job. Leaves if printer is invalid. |
|
116 * @since Series60 3.0 |
|
117 * @param aSessionId Print job ID of cancelled job. |
|
118 */ |
|
119 IMPORT_C void CancelJobL( const TInt aSessionId ); |
|
120 |
|
121 /** |
|
122 * This function is used to query printer attributes. |
|
123 * @since Series60 3.0 |
|
124 * @param aPrinter Printer to be used. |
|
125 */ |
|
126 IMPORT_C void GetPrinterAttributesL( CUpnpDevice* aPrinter ); |
|
127 |
|
128 /** |
|
129 * This function is used to query job attributes of specified print job. |
|
130 * @since Series60 3. |
|
131 * @param aPrinter Printer to be used. |
|
132 * @param aJobId Print job ID. |
|
133 */ |
|
134 IMPORT_C void GetJobAttributesL( CUpnpDevice* aPrinter, const TDesC8& aJobId ); |
|
135 |
|
136 /** |
|
137 * This function is used to query margin information from printers supporting PrintEnhanced:1. |
|
138 * If printer supports only PrintBasic:1, a function leaves with KErrNotSupported. |
|
139 * |
|
140 * @since Series60 3.0 |
|
141 * @param aPrinter Printer to be used. |
|
142 * @param aMediaSize |
|
143 * @param aMediaType |
|
144 */ |
|
145 IMPORT_C void GetMarginsL( CUpnpDevice* aPrinter, const TDesC8& aMediaSize, const TDesC8& aMediaType ); |
|
146 |
|
147 /** |
|
148 * Allows a client to determine a valid combinations of MediaType and MediaSize that the printer supports. |
|
149 * Action is supported only in PrintEnhanced:1. |
|
150 * If printer supports only PrintBasic:1, a function leaves with KErrNotSupported. |
|
151 * |
|
152 * @since Series60 3.0 |
|
153 * @param aPrinter Printer to be used. |
|
154 * @param aMediaSize |
|
155 * @param aMediaType |
|
156 */ |
|
157 IMPORT_C void GetMediaListL( CUpnpDevice* aPrinter, const TDesC8& aMediaSize, const TDesC8& aMediaType ); |
|
158 |
|
159 |
|
160 /** |
|
161 * Informs the control point that printing has finished and the event unsubscription can be done. |
|
162 * @since Series60 3. |
|
163 * @param aPrinter Printer to be used. |
|
164 * @param aJobId Print job ID. |
|
165 */ |
|
166 IMPORT_C void PrintingFinishedL( CUpnpDevice* aPrinter ); |
|
167 |
|
168 |
|
169 // From CControlPoint |
|
170 |
|
171 /** |
|
172 * StateUpdatedL |
|
173 * @since Series60 3.0 |
|
174 * @param aService the service state updated |
|
175 */ |
|
176 IMPORT_C void StateUpdatedL( CUpnpService* aService ); |
|
177 |
|
178 /** |
|
179 * DeviceDiscoveredL |
|
180 * @since Series60 3.0 |
|
181 * @param aDevice the device found |
|
182 */ |
|
183 IMPORT_C void DeviceDiscoveredL( CUpnpDevice* aDevice ); |
|
184 |
|
185 /** |
|
186 * DeviceDisappearedL |
|
187 * @since Series60 3.0 |
|
188 * @param aDevice |
|
189 */ |
|
190 IMPORT_C void DeviceDisappearedL( CUpnpDevice* aDevice ); |
|
191 |
|
192 /** |
|
193 * ActionResponseReceivedL |
|
194 * @since Series60 3.0 |
|
195 * @param aAction the action received |
|
196 */ |
|
197 IMPORT_C void ActionResponseReceivedL( CUpnpAction* aAction ); |
|
198 |
|
199 /** |
|
200 * HttpResponseReceivedL |
|
201 * @since Series60 3.0 |
|
202 * @param aMessage the HTTP response message |
|
203 */ |
|
204 IMPORT_C void HttpResponseReceivedL( CUpnpHttpMessage* aMessage ); |
|
205 |
|
206 private: |
|
207 |
|
208 /** |
|
209 * First phase of the two phased construction. |
|
210 * @param aPCPObserver |
|
211 * @param aFriendlyName Specifies the friendly name of the control point. |
|
212 */ |
|
213 CPrinterControlPoint( MPCPObserver& aPCPOBserver ); |
|
214 |
|
215 /** |
|
216 * Runs base classes ConstructL, starts XHTML folder sharing and starts |
|
217 * printer search. |
|
218 * |
|
219 */ |
|
220 void ConstructL( ); |
|
221 |
|
222 /** |
|
223 * Get service from specified device. |
|
224 * @since Series60 3.0 |
|
225 * @param aPrinter Printer to be used. |
|
226 * @param aService Service type |
|
227 * @return Pointer to the resolved service |
|
228 */ |
|
229 CUpnpService* GetServiceFromDevice( CUpnpDevice* aPrinter, TPrintService& aService ); |
|
230 |
|
231 /* |
|
232 * Function for parsing remote host address from Data Sink URL |
|
233 * @param aDataSinkUrl |
|
234 * @return Address |
|
235 */ |
|
236 const TPtrC8 DataSinkUrlAddress( const TDesC8& aDataSinkUrl ); |
|
237 |
|
238 /* |
|
239 * Function for parsing path from Data Sink URL |
|
240 * @param aDataSinkUrl |
|
241 * @return Path |
|
242 */ |
|
243 const TPtrC8 DataSinkUrlPath( const TDesC8& aDataSinkUrl ); |
|
244 |
|
245 /* |
|
246 * Function for parsing port from Data Sink URL |
|
247 * @param aDataSinkUrl |
|
248 * @return Port number |
|
249 */ |
|
250 TInt DataSinkUrlPort( const TDesC8& aDataSinkUrl ); |
|
251 |
|
252 /* |
|
253 * Sends the CancelJob action to the printer |
|
254 * @param aService Print service, from where the action will be created |
|
255 * @param aJobId Id of the job to be cancelled |
|
256 */ |
|
257 void DoCancelJobL(CUpnpService& aService, const TDesC8& aJobId); |
|
258 |
|
259 |
|
260 /* |
|
261 * Function for removing tags (if exists) from actions received from UPnP |
|
262 * @param aString Descriptor to remove tags |
|
263 * @return Pointer to the descriptor without tags |
|
264 */ |
|
265 TPtrC8 RemoveTags( const TDesC8& aString); |
|
266 |
|
267 /* |
|
268 * Function for writing the log of job state events |
|
269 * @param aService |
|
270 */ |
|
271 void JobStateLog(CUpnpService* aService); |
|
272 |
|
273 |
|
274 private: // Data |
|
275 |
|
276 //@var iPCPObserver PCP observer for callbacks, not owned |
|
277 MPCPObserver& iPCPObserver; |
|
278 |
|
279 //@var iCancelledJobSIDs Contains session ids for jobs to be cancelled |
|
280 RArray<TInt> iCancelledJobSIDs; |
|
281 |
|
282 //@var iJobStateEvents Job state event maintainer |
|
283 CJobStateEvents* iJobStateEvents; |
|
284 |
|
285 }; |
|
286 |
|
287 #endif // CPRINTERCONTROLPOINT_H |
|
288 |
|
289 // End Of File |
|