|
1 /* |
|
2 * Copyright (c) 2006, 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: This class defines and implements the API for UI engine. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef PICTBRIDGE_H |
|
20 #define PICTBRIDGE_H |
|
21 |
|
22 #include "dpsdefs.h" |
|
23 #include <rptp.h> |
|
24 |
|
25 class TDpsXmlString; |
|
26 class CDpsUsbNotifier; |
|
27 class TMDpsOperation; |
|
28 class TDpsEvents; |
|
29 class CDpsStateMachine; |
|
30 class TDpsConfigPrintReq; |
|
31 |
|
32 NONSHARABLE_CLASS(CDpsEngine) : public CBase |
|
33 { |
|
34 public: |
|
35 enum TConnectionStatus |
|
36 { |
|
37 ENotConnected = 1, |
|
38 // ptp printer is connected |
|
39 EPrinterConnected, |
|
40 // ptp printer is disconnected |
|
41 EPrinterDisconnected, |
|
42 // in ptp personality, but device other than printer connected |
|
43 EOtherConnected, |
|
44 // in personality other than ptp and device is connected |
|
45 EWrongPrintModeConnected |
|
46 }; |
|
47 |
|
48 public: |
|
49 /** |
|
50 * @since 3.2 |
|
51 * @lib pictbridge.lib |
|
52 * |
|
53 * The client should always call this function to get the Dps |
|
54 * engine object. |
|
55 * This function guarantees there is only one engine in the |
|
56 * thread, a singleton. |
|
57 * @return CDpsEngine* the only Dps Engine instance in a thread |
|
58 * |
|
59 */ |
|
60 IMPORT_C static CDpsEngine* GetEngineL(); |
|
61 |
|
62 /** |
|
63 * @since 3.2 |
|
64 * @lib pictbridge.lib |
|
65 * |
|
66 * Deletes the dps engine object. |
|
67 */ |
|
68 IMPORT_C void Delete(); |
|
69 |
|
70 /** |
|
71 * @since 3.2 |
|
72 * @lib pictbridge.lib |
|
73 * |
|
74 * Sets the personality to PTP. This must be the first call after |
|
75 * the client has got the CDpsEngine object and should only be |
|
76 * called once. |
|
77 * @param aStatus the asynchronous request and it has the connect |
|
78 * state after returned. The client can use this value to get the |
|
79 * current connect status. |
|
80 */ |
|
81 IMPORT_C void SetPrintMode(TRequestStatus& aStatus); |
|
82 |
|
83 /** |
|
84 * @since 3.2 |
|
85 * @lib pictbridge.lib |
|
86 * |
|
87 * Cancels the SetPrintMode request |
|
88 */ |
|
89 IMPORT_C void CancelPrintMode(); |
|
90 |
|
91 /** |
|
92 * @since 3.2 |
|
93 * @lib pictbridge.lib |
|
94 * |
|
95 * Registers connection notification. This function can inform |
|
96 * the connection and the disconnect, two states. Connection: the |
|
97 * personality has been set to PTP by SetPrintMode, but the cable |
|
98 * is not connected at the moment. The connection will be informed |
|
99 * by this function. |
|
100 * Disconnect: the user has unplugged the cable or changed |
|
101 * personality. |
|
102 * |
|
103 * @param aStatus the asynchronous request status and it has the |
|
104 * connect state after returned. |
|
105 */ |
|
106 IMPORT_C void ConnectStateNotify(TRequestStatus& aStatus); |
|
107 |
|
108 /** |
|
109 * @since 3.2 |
|
110 * @lib pictbridge.lib |
|
111 * |
|
112 * Registers Dps event notification. There are two events: jobStatus |
|
113 * and deviceStatus. This function is called immediately after |
|
114 * ConnecSatetNotify call. After this call, the client should issue |
|
115 * ConfigPrintService request to configure the printer. |
|
116 * @param aParam this parameter serves as out parameter. After |
|
117 * processing the event from the printer, Dps engine will put |
|
118 * the correct value to this parameter. As the result, the client |
|
119 * can get the event by accessing this parameter after this request |
|
120 * gets answered. So the client should have it as a class variable |
|
121 * @param aStatus the asynchronous status. |
|
122 */ |
|
123 IMPORT_C void DpsEventNotify(TDpsEvents& aParam, |
|
124 TRequestStatus& aStatus); |
|
125 |
|
126 /** |
|
127 * @since 3.2 |
|
128 * @lib pictbridge.lib |
|
129 * |
|
130 * Cancels Dps event notification. The client only needs to call |
|
131 * this to reset the state of the dps engine and it must be called |
|
132 * after CancelDpsRequest(). |
|
133 */ |
|
134 IMPORT_C void CancelDpsEventNotify(); |
|
135 |
|
136 /** |
|
137 * @since 3.2 |
|
138 * @lib pictbridge.lib |
|
139 * |
|
140 * Starts a Dps operation. |
|
141 * If this function returned with error, e.g. leaving, the client |
|
142 * should call CancelDpsRequest(), to cancel the pending request. |
|
143 * @param aRequest the Dps operation. It includes both request and |
|
144 * reply. The client should fill in the request parameter and the |
|
145 * Dps engine will fill in the reply paramter when this operation |
|
146 * is finished. The client should declare it as a class variable. |
|
147 * @param aStatus the asynchronous status |
|
148 */ |
|
149 IMPORT_C void DoDpsRequestL(TMDpsOperation* aRequest, |
|
150 TRequestStatus& aStatus); |
|
151 |
|
152 /** |
|
153 * @since 3.2 |
|
154 * @lib pictbridge.lib |
|
155 * |
|
156 * Cancels the dps operation. Calling this will reset the state of |
|
157 * the dps engine, either because of error happened or the client |
|
158 * wants to do this on purpose. In most cases, the client never need |
|
159 * to cancel the ongoing request because the request will end very |
|
160 * quick, normally within several million seconds. The client normally |
|
161 * waits until the request is finished, either succesfully or |
|
162 * failed indicated by timeout. |
|
163 */ |
|
164 IMPORT_C void CancelDpsRequest(); |
|
165 |
|
166 /** |
|
167 * @since 3.2 |
|
168 * @lib pictbridge.lib |
|
169 * |
|
170 * Reads the phone dps configuration from the resource file |
|
171 * @param aConfig the dps configuration is returned by this parameter |
|
172 */ |
|
173 IMPORT_C void GetDpsConfigL(TDpsConfigPrintReq& aConfig); |
|
174 |
|
175 /** |
|
176 * @since 3.2 |
|
177 * @lib pictbridge.lib |
|
178 * |
|
179 * Gets the folder where the printer configure file should be kept. |
|
180 * The print App needs a file to store the printer configure when it |
|
181 * first calls configPrintService Dps request. The print app can |
|
182 * quit at anytime while the ptpserver (stack) is still running. |
|
183 * Since the ptpstack is keeping the session with the printer, the |
|
184 * printer always does not excute the second onward |
|
185 * configPrintService request. As the result, the restarted print app |
|
186 * cannot get the printer configure. So there must be a file for |
|
187 * keeping this information and it will be deleted by ptpserver when |
|
188 * it quits, e.g. when the connection with the printer is lost. |
|
189 * @return TDesC& the folder descriptor |
|
190 */ |
|
191 IMPORT_C const TDesC& DpsFolder() const; |
|
192 |
|
193 /** |
|
194 * Gets the Dps event object |
|
195 * @return TDpsEvents* the pointer to the Dps event. |
|
196 */ |
|
197 TDpsEvents* Event() const; |
|
198 |
|
199 /** |
|
200 * Gets the ptp server reference |
|
201 * @return RPtp& the reference to ptp server. |
|
202 */ |
|
203 RPtp& Ptp(); |
|
204 |
|
205 /** |
|
206 * Gets the dps constant strings |
|
207 * @return TDpsGlobalData* the pointer to dps constant strings. |
|
208 */ |
|
209 TDpsXmlString* DpsParameters() const; |
|
210 |
|
211 /** |
|
212 * @return dps event notify AO status |
|
213 * |
|
214 */ |
|
215 TRequestStatus*& EventRequest(); |
|
216 |
|
217 /** |
|
218 * @return dps request AO status |
|
219 */ |
|
220 TRequestStatus*& OperationRequest(); |
|
221 |
|
222 /** |
|
223 * @return connection notify AO status |
|
224 */ |
|
225 TRequestStatus*& PrinterConnectRequest(); |
|
226 |
|
227 /** |
|
228 * Sets the Dps file folder. |
|
229 * @param aFolder the foler location, readed from Ptp server/stack |
|
230 */ |
|
231 void SetDpsFolder(const TDesC& aFolder); |
|
232 |
|
233 |
|
234 private: |
|
235 |
|
236 /** |
|
237 * Prohibits the destructor called by the client. To delete engine object |
|
238 * Delete() must be called |
|
239 */ |
|
240 ~CDpsEngine(); |
|
241 |
|
242 /** |
|
243 * Second phase constructor. Operations which might leave should |
|
244 * be called here |
|
245 */ |
|
246 void ConstructL(); |
|
247 |
|
248 private: |
|
249 // string constant, owned by this class |
|
250 TDpsXmlString* iDpsParameters; |
|
251 // dps engine state machine, owned by this class |
|
252 CDpsStateMachine *iDpsOperator; |
|
253 // dps operation AO request, owned by this class |
|
254 TRequestStatus* iDpsOperationRequest; |
|
255 // dps event AO request, owned by this class |
|
256 TRequestStatus* iDpsEventRequest; |
|
257 // printer connection/disconnection AO request, owned by this class |
|
258 TRequestStatus* iPrinterConnectRequest; |
|
259 |
|
260 // usb cable connection/disconnection notifier, owned by this class |
|
261 CDpsUsbNotifier *iUsbNotifier; |
|
262 |
|
263 // out parameter for events (NotifyJobStatus and |
|
264 // NotifyDeviceStauts), it is |
|
265 // passed from UI engine, not owned by this class |
|
266 TDpsEvents* iOutEvent; |
|
267 |
|
268 // Ptp Server session, owned by this class |
|
269 RPtp iPtp; |
|
270 // the folder where all dps releated files should be stored |
|
271 TFileName iDpsFolder; |
|
272 }; |
|
273 |
|
274 #endif |