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 CUPPrinterContainer class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CUPPRINTERCONTAINER_H |
|
20 #define CUPPRINTERCONTAINER_H |
|
21 |
|
22 #include <upnpdevice.h> |
|
23 #include <f32file.h> |
|
24 |
|
25 #include "tprinter.h" |
|
26 #include "cupprinter.h" |
|
27 #include "imageprint.h" |
|
28 |
|
29 /* |
|
30 * @class CUPPrinterContainer |
|
31 * @description This class contains an array of discovered devices |
|
32 * and methods for handling it. It also converts CDevice objects to |
|
33 * TPrinter, where TPrinter's id is the index |
|
34 */ |
|
35 |
|
36 NONSHARABLE_CLASS(CUPPrinterContainer) : public CBase |
|
37 { |
|
38 public: |
|
39 /* |
|
40 * @function NewL |
|
41 * @description Constructs the CUPPrinterContainer object |
|
42 */ |
|
43 static CUPPrinterContainer* NewL(); |
|
44 |
|
45 /* |
|
46 * @function Destructor |
|
47 * @description Releases the resources allocated by this object |
|
48 */ |
|
49 ~CUPPrinterContainer(); |
|
50 |
|
51 /* |
|
52 * @function PrinterCount |
|
53 * @description Returns the number of printers in iPrinters. |
|
54 * @return TInt |
|
55 */ |
|
56 TInt PrinterCount(); |
|
57 |
|
58 /* |
|
59 * @function AddPrinterL |
|
60 * @description Adds a device to the device array. Called when |
|
61 * a device is discovered. |
|
62 * @param CDevice*& Reference to the pointer of the device |
|
63 * @param TInt& The new id will be set to this value |
|
64 * @return TInt Printer id of the added device |
|
65 */ |
|
66 void AddPrinterL(CUpnpDevice& aDevice, TInt& aId); |
|
67 |
|
68 /* |
|
69 * @function RemovePrinter |
|
70 * @description Removes a printer from the array. Called when |
|
71 * a device is disappeared. |
|
72 * @param CDevice& aDevice |
|
73 * @return TInt Symbian error code |
|
74 */ |
|
75 TInt RemovePrinter(CUpnpDevice& aDevice); |
|
76 |
|
77 /* |
|
78 * @function RemovePrinter |
|
79 * @description Removes a printer from the array. Called when |
|
80 * a device is disappeared. |
|
81 * @param TInt aIndex |
|
82 * @return TInt Symbian error code |
|
83 */ |
|
84 TInt RemovePrinter(TInt aIndex); |
|
85 |
|
86 /* |
|
87 * @function PrinterIndex |
|
88 * @description Returns the index number of the device in discovered |
|
89 * printers array. If printer is not found -1 is returned. |
|
90 * This function compares the Uuid's of the CDevices. |
|
91 * @param CDevice |
|
92 * @return TInt |
|
93 */ |
|
94 TInt PrinterIndex(CUpnpDevice& aDevice); |
|
95 |
|
96 /* |
|
97 * @function PrinterIndex |
|
98 * @description Returns the index number of the device in discovered |
|
99 * printers array. If printer is not found -1 is returned. |
|
100 * This function searches for matching CUPPrinter id's. |
|
101 * @param CDevice* |
|
102 * @return TInt |
|
103 */ |
|
104 TInt PrinterIndex(TInt aPrinterId); |
|
105 |
|
106 /* |
|
107 * @function PrinterDisappeared |
|
108 * @description Sets a printer as disappeared in printer array. |
|
109 * @param CDevice |
|
110 */ |
|
111 void PrinterDisappeared(CUpnpDevice& aDevice); |
|
112 |
|
113 /* |
|
114 * @function SyncPrinterArray |
|
115 * @description Removes disappeared devices from iPrinters array. |
|
116 */ |
|
117 void SyncPrinterArray(); |
|
118 |
|
119 /* |
|
120 * @function ReadCacheL |
|
121 * @description Reads printer information from cache file into printer array |
|
122 */ |
|
123 void ReadCacheL(); |
|
124 |
|
125 /* |
|
126 * @function UpdateCacheL |
|
127 * @description Updates the cache file with available printers |
|
128 */ |
|
129 void UpdateCacheL(); |
|
130 |
|
131 /* |
|
132 * @function CacheCurrentL |
|
133 * @description Updates the current device in cache file |
|
134 */ |
|
135 void CacheCurrentL(); |
|
136 |
|
137 /* |
|
138 * @function RemoveCachedDeviceL |
|
139 * @description Removes the given device in cache file |
|
140 * @param TInt Id of the device to remove |
|
141 */ |
|
142 TInt RemoveCachedDeviceL(TInt aDeviceID); |
|
143 |
|
144 /* |
|
145 * @function UpdateCacheL |
|
146 * @description Updates the cache file with available printers |
|
147 * @param TInt Id of the device to add in cache |
|
148 */ |
|
149 void UpdateCacheL(TInt aDeviceID); |
|
150 |
|
151 /* |
|
152 * @function ToTPrinter |
|
153 * @description Returns a printer object as TPrinter by index. |
|
154 * @param CDevice*& aDevice |
|
155 * @return TPrinter |
|
156 */ |
|
157 TPrinter ToTPrinter(CUpnpDevice& aDevice); |
|
158 |
|
159 /* |
|
160 * @function ToTPrinter |
|
161 * @description Returns a printer object as TPrinter by index. |
|
162 * @param TInt aIndex |
|
163 * @return TPrinter |
|
164 */ |
|
165 TPrinter ToTPrinter(TInt aIndex); |
|
166 |
|
167 |
|
168 /* |
|
169 * @function GetDisappearedPrinters |
|
170 * @description Initializes a pointer array with pointers to all disappeared printers |
|
171 * @param RPointerArray Out param |
|
172 */ |
|
173 void GetDisappearedPrinters(RPointerArray<CUPPrinter>& aArray); |
|
174 |
|
175 /* |
|
176 * @function Printer |
|
177 * @description Returns a pointer to CUPPrinter in printer array. |
|
178 * @param CDevice& aDevice |
|
179 * @return CUPPrinter* |
|
180 */ |
|
181 CUPPrinter* Printer(CUpnpDevice& aDevice); |
|
182 |
|
183 /* |
|
184 * @function Printer |
|
185 * @description Returns a pointer to CUPPrinter in printer array. |
|
186 * @param TInt aId |
|
187 * @return CUPPrinter* |
|
188 */ |
|
189 CUPPrinter* Printer(TInt aId); |
|
190 |
|
191 protected: |
|
192 |
|
193 |
|
194 private: |
|
195 /* |
|
196 * @function Constructor |
|
197 * @description C++ constructor |
|
198 */ |
|
199 CUPPrinterContainer(); |
|
200 |
|
201 |
|
202 /* |
|
203 * @function ConstructL |
|
204 * @description Construction's second phase |
|
205 */ |
|
206 void ConstructL(); |
|
207 |
|
208 /* |
|
209 * @function ToCDevice |
|
210 * @description Returns a pointer to CUPPrinter's CDevice in printer array. |
|
211 * @param TInt aIndex |
|
212 * @return CDevice* |
|
213 */ |
|
214 CUpnpDevice* ToCDevice(TInt aIndex); |
|
215 |
|
216 /* |
|
217 * @function GenerateId |
|
218 * @description Generated an unique id number for a printer |
|
219 * @return TInt Generated Id number |
|
220 */ |
|
221 TInt GenerateId(); |
|
222 |
|
223 /* |
|
224 * @function AddCachedPrinterL |
|
225 * @description Adds a cached printer to printer array |
|
226 * @param TInt aId |
|
227 * @param TDesC& aUPnPUId |
|
228 * @param TDesC& aDisplayName |
|
229 */ |
|
230 void AddCachedPrinterL(TInt aId, TDesC8& aUPnPUId, TDesC8& aDisplayName, const TInt aVendor); |
|
231 |
|
232 /* |
|
233 * @function ReadCacheFileL |
|
234 * @description Reads the cached printers in iCacheBuffer |
|
235 * NOTE: Creates the iCacheBuffer |
|
236 */ |
|
237 void ReadCacheFileL(); |
|
238 |
|
239 /* |
|
240 * @function FindCachedPrinterL |
|
241 * @description Returns requested printer data from the cache file and the start |
|
242 * and end position of the printer data in file |
|
243 * @param TInt ID of the printer to find |
|
244 * @param TInt& Start position of the data in file |
|
245 * @param TInt& End position of the data in file |
|
246 * @return TPtrC8 Printer data in buffer pointer |
|
247 */ |
|
248 TPtrC8 FindCachedPrinterL(TInt aId, TInt& aStartPos, TInt& aEndPos); |
|
249 |
|
250 /* |
|
251 * @function AddCachedPrinterL |
|
252 * @description Adds a cached printer to printer array |
|
253 * @param TInt aId |
|
254 * @param TDesC& aUPnPUId |
|
255 * @param TDesC& aDisplayName |
|
256 */ |
|
257 CUPPrinter* PrinterByIndex(TInt aIndex); |
|
258 |
|
259 |
|
260 private: |
|
261 // @var iPrinterArray Discovered devices |
|
262 RPointerArray<CUPPrinter> iPrinters; |
|
263 |
|
264 // @var iFsSession File server session |
|
265 RFs iFsSession; |
|
266 |
|
267 |
|
268 //@var iIdCounter Temprary id generation solution |
|
269 TInt iIdCounter; |
|
270 |
|
271 //@var iCacheBuffer The content of the cached file. |
|
272 HBufC8* iCacheBuffer; |
|
273 }; |
|
274 |
|
275 #endif // CUPPRINTERCONTAINER_H |
|
276 |
|
277 // End of File |
|