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 CUPPrinter class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <upnpmediaserversettings.h> |
|
20 |
|
21 #include "cupprinter.h" |
|
22 #include "cuplogger.h" |
|
23 #include "tprintcapability.h" |
|
24 |
|
25 // Public functions |
|
26 //-------------------------------------------------------------------------------------------- |
|
27 // |
|
28 // CUPPrinter::~CUPPrinter |
|
29 // |
|
30 //-------------------------------------------------------------------------------------------- |
|
31 CUPPrinter::~CUPPrinter() |
|
32 { |
|
33 if ( iUId ) |
|
34 { |
|
35 delete iUId; |
|
36 } |
|
37 |
|
38 if ( iDisplayName ) |
|
39 { |
|
40 delete iDisplayName; |
|
41 } |
|
42 } |
|
43 |
|
44 |
|
45 //-------------------------------------------------------------------------------------------- |
|
46 // |
|
47 // CUPPrinter::NewL |
|
48 // |
|
49 //-------------------------------------------------------------------------------------------- |
|
50 CUPPrinter* CUPPrinter::NewL(CUpnpDevice& aDevice, TInt aId) |
|
51 { |
|
52 CUPPrinter* self = new (ELeave) CUPPrinter(); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(&aDevice, aId, aDevice.Uuid(), aDevice.DescriptionProperty(UpnpMediaServerSettings::KModelName()), TPrinter::EVendorNone); |
|
55 CleanupStack::Pop(); // self |
|
56 return self; |
|
57 } |
|
58 |
|
59 //-------------------------------------------------------------------------------------------- |
|
60 // |
|
61 // CUPPrinter::NewL |
|
62 // |
|
63 //-------------------------------------------------------------------------------------------- |
|
64 CUPPrinter* CUPPrinter::NewL(const TInt aId, const TDesC8& aUId, const TDesC8& aDisplayName, const TInt aVendor) |
|
65 { |
|
66 CUPPrinter* self = new (ELeave) CUPPrinter(); |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL(NULL, aId, aUId, aDisplayName, aVendor); |
|
69 CleanupStack::Pop(); // self |
|
70 return self; |
|
71 } |
|
72 |
|
73 |
|
74 //-------------------------------------------------------------------------------------------- |
|
75 // |
|
76 // CUPPrinter::Device |
|
77 // |
|
78 //-------------------------------------------------------------------------------------------- |
|
79 CUpnpDevice* CUPPrinter::Device() |
|
80 { |
|
81 return iDevice; |
|
82 } |
|
83 |
|
84 //-------------------------------------------------------------------------------------------- |
|
85 // |
|
86 // CUPPrinter::SetCached |
|
87 // |
|
88 //-------------------------------------------------------------------------------------------- |
|
89 void CUPPrinter::SetCached(TBool aCached) |
|
90 { |
|
91 iCached = aCached; |
|
92 } |
|
93 |
|
94 //-------------------------------------------------------------------------------------------- |
|
95 // |
|
96 // CUPPrinter::Cached |
|
97 // |
|
98 //-------------------------------------------------------------------------------------------- |
|
99 TBool CUPPrinter::Cached() |
|
100 { |
|
101 return iCached; |
|
102 } |
|
103 |
|
104 //-------------------------------------------------------------------------------------------- |
|
105 // |
|
106 // CUPPrinter::Vendor |
|
107 // |
|
108 //-------------------------------------------------------------------------------------------- |
|
109 TPrinter::TPrinterVendor CUPPrinter::Vendor() |
|
110 { |
|
111 return iVendor; |
|
112 } |
|
113 |
|
114 //-------------------------------------------------------------------------------------------- |
|
115 // |
|
116 // CUPPrinter::SetVendor |
|
117 // |
|
118 //-------------------------------------------------------------------------------------------- |
|
119 void CUPPrinter::SetVendor(const TDesC8& aManufacturer) |
|
120 { |
|
121 LOG("[CUPPrinter::SetVendor]\t Begin"); |
|
122 iVendor = TPrinter::EVendorNone; |
|
123 // At the moment this functionality is not used, but no Vendor is set. |
|
124 LOG("[CUPPrinter::SetVendor]\t End"); |
|
125 } |
|
126 |
|
127 //-------------------------------------------------------------------------------------------- |
|
128 // |
|
129 // CUPPrinter::ToTPrinter |
|
130 // |
|
131 //-------------------------------------------------------------------------------------------- |
|
132 TPrinter CUPPrinter::ToTPrinter() |
|
133 { |
|
134 TInt cached(0); |
|
135 TPrinter printer; |
|
136 printer.iPrinterID = iId; |
|
137 printer.iDisplayName.Copy(iDisplayName->Des()); |
|
138 printer.iVendor = Vendor(); |
|
139 // cast boolean value to integer |
|
140 cached = Cached(); |
|
141 printer.iProperties = cached | TPrinter::SupportsPreview; |
|
142 printer.iProtocol = KImagePrint_PrinterProtocol_UPnP; |
|
143 |
|
144 LOG1("[CUPPrinter::ToTPrinter]\t printer.iVendor = %d", printer.iVendor) |
|
145 |
|
146 return printer; |
|
147 } |
|
148 |
|
149 //-------------------------------------------------------------------------------------------- |
|
150 // |
|
151 // CUPPrinter::Id |
|
152 // |
|
153 //-------------------------------------------------------------------------------------------- |
|
154 TInt CUPPrinter::Id() |
|
155 { |
|
156 return iId; |
|
157 } |
|
158 |
|
159 //-------------------------------------------------------------------------------------------- |
|
160 // |
|
161 // CUPPrinter::UId |
|
162 // |
|
163 //-------------------------------------------------------------------------------------------- |
|
164 TPtrC8 CUPPrinter::UId() |
|
165 { |
|
166 if ( iUId ) |
|
167 { |
|
168 return TPtrC8( iUId->Des() ); |
|
169 } |
|
170 else |
|
171 { |
|
172 return TPtrC8( KNullDesC8 ); |
|
173 } |
|
174 |
|
175 } |
|
176 |
|
177 //-------------------------------------------------------------------------------------------- |
|
178 // |
|
179 // CUPPrinter::DisplayName |
|
180 // |
|
181 //-------------------------------------------------------------------------------------------- |
|
182 TPtrC8 CUPPrinter::DisplayName() |
|
183 { |
|
184 if ( iDisplayName ) |
|
185 { |
|
186 return TPtrC8( iDisplayName->Des() ); |
|
187 } |
|
188 else |
|
189 { |
|
190 return TPtrC8( KNullDesC8 ); |
|
191 } |
|
192 |
|
193 } |
|
194 |
|
195 |
|
196 //-------------------------------------------------------------------------------------------- |
|
197 // |
|
198 // CUPPrinter::IsDisappeared |
|
199 // |
|
200 //-------------------------------------------------------------------------------------------- |
|
201 TBool CUPPrinter::IsDisappeared() |
|
202 { |
|
203 return iDisappeared; |
|
204 } |
|
205 |
|
206 |
|
207 //-------------------------------------------------------------------------------------------- |
|
208 // |
|
209 // CUPPrinter::SetDisappeared |
|
210 // |
|
211 //-------------------------------------------------------------------------------------------- |
|
212 void CUPPrinter::SetDisappeared(TBool aDisappeared) |
|
213 { |
|
214 iDisappeared = aDisappeared; |
|
215 |
|
216 if (iDisappeared) |
|
217 { |
|
218 iDevice = NULL; |
|
219 } |
|
220 } |
|
221 |
|
222 |
|
223 //-------------------------------------------------------------------------------------------- |
|
224 // |
|
225 // CUPPrinter::SetDevice |
|
226 // |
|
227 //-------------------------------------------------------------------------------------------- |
|
228 void CUPPrinter::SetDevice(CUpnpDevice* aDevice) |
|
229 { |
|
230 iDevice = aDevice; |
|
231 |
|
232 if (!aDevice) |
|
233 return; |
|
234 |
|
235 // Update display name |
|
236 delete iDisplayName; |
|
237 iDisplayName = NULL; |
|
238 |
|
239 iDisplayName = aDevice->DescriptionProperty(UpnpMediaServerSettings::KModelName()).Alloc(); |
|
240 } |
|
241 |
|
242 // Protected functions |
|
243 |
|
244 //-------------------------------------------------------------------------------------------- |
|
245 // |
|
246 // CUPPrinter::ConstructL( |
|
247 // |
|
248 //-------------------------------------------------------------------------------------------- |
|
249 void CUPPrinter::ConstructL(CUpnpDevice* aDevice, const TInt aId, const TDesC8& aUId, const TDesC8& aDisplayName, const TInt aVendor) |
|
250 { |
|
251 iId = aId; |
|
252 iUId = aUId.AllocL(); |
|
253 iDisplayName = aDisplayName.AllocL(); |
|
254 iVendor = (TPrinter::TPrinterVendor)aVendor; |
|
255 |
|
256 if (aDevice) |
|
257 { |
|
258 // Discovered device |
|
259 iDevice = aDevice; |
|
260 iDisappeared = EFalse; |
|
261 |
|
262 SetVendor(iDevice->DescriptionProperty(UpnpMediaServerSettings::KManufacturer())); |
|
263 } |
|
264 else |
|
265 { |
|
266 // Cached device |
|
267 iDisappeared = ETrue; |
|
268 } |
|
269 |
|
270 iCached = EFalse; |
|
271 } |
|
272 |
|
273 // Private functions |
|
274 //-------------------------------------------------------------------------------------------- |
|
275 // |
|
276 // CUPPrinter::CUPPrinter |
|
277 // |
|
278 //-------------------------------------------------------------------------------------------- |
|
279 CUPPrinter::CUPPrinter() |
|
280 { |
|
281 } |
|
282 |
|
283 // End of File |
|