|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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 main application class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CUPNPDEVICELIBRARYELEMENT_H |
|
20 #define C_CUPNPDEVICELIBRARYELEMENT_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <cdbcols.h> |
|
25 #include <badesca.h> |
|
26 #include "upnptimeoutelement.h" |
|
27 #include "upnpcommonstructs.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CUpnpSsdpMessage; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * This class has two main functionalities: |
|
36 * 1. Timeout from CUpnpTimeoutElement |
|
37 * 2. Buffers to store the data about a UPnP device |
|
38 * |
|
39 * @since Series60 2.0 |
|
40 */ |
|
41 class CUpnpDeviceLibraryElement : public CUpnpTimeoutElement |
|
42 { |
|
43 public: // Constructors and destructor |
|
44 |
|
45 /** |
|
46 * Two-phased constructor. |
|
47 * @param aParent The parent of the element (e.g. device library) |
|
48 * to handle timeout callbacks |
|
49 * @return A new CUpnpDeviceLibraryElement instance |
|
50 */ |
|
51 IMPORT_C static CUpnpDeviceLibraryElement* NewL( |
|
52 MUpnpTimeoutElementParent& aParent); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 IMPORT_C virtual ~CUpnpDeviceLibraryElement(); |
|
58 |
|
59 public: // New functions |
|
60 |
|
61 /** |
|
62 * Add data of a SSDP message to the device library |
|
63 * @since Series60 2.0 |
|
64 * @param aMessage A SSDP message |
|
65 * @param aUpdateId Reference to current update id. If required \ |
|
66 the value of this update id is changed when device is added to \ |
|
67 device library. |
|
68 * @return ETrue if device changed |
|
69 */ |
|
70 IMPORT_C TBool AddInfoL( CUpnpSsdpMessage* aMessage, TInt& aUpdateId ); |
|
71 |
|
72 /** |
|
73 * Add data got from local device to the device library. |
|
74 * @since Series60 2.0 |
|
75 * @param aIndex A indexing structure for the data buffer |
|
76 * @param aBuffer A buffer containing the actual data |
|
77 * @param aAddr Address of the device that is to be added. |
|
78 */ |
|
79 IMPORT_C void AddInfoL( const TUpnpAddLocalDevice* aIndex, |
|
80 const TDesC8& aBuffer, |
|
81 const TInetAddr& aAddr ); |
|
82 |
|
83 /** |
|
84 * Add data got from local device to the device library. |
|
85 * @since Series60 2.0 |
|
86 * @param aIndex A indexing structure for the data buffer |
|
87 * @param aBuffer A buffer containing the actual data |
|
88 */ |
|
89 IMPORT_C void AddInfoL( const TUpnpAddLocalDevice* aIndex, |
|
90 const TDesC8& aBuffer); |
|
91 |
|
92 public: |
|
93 |
|
94 /** |
|
95 * Sets iAdvertised to ETrue. |
|
96 * @since Series60 3.2 |
|
97 */ |
|
98 void Advertising(); |
|
99 |
|
100 /** |
|
101 * Sets iAdvertised to EFalse. |
|
102 * @since S60 5.1 |
|
103 */ |
|
104 void AdvertisingFinished(); |
|
105 |
|
106 /** |
|
107 * Is advertised. |
|
108 * @since Series60 3.2 |
|
109 * @return TBool |
|
110 */ |
|
111 TBool Advertised(); |
|
112 |
|
113 /** |
|
114 * Set root device. |
|
115 * @since Series60 2.0 |
|
116 * @param aRootDevice root device |
|
117 */ |
|
118 void SetRootDevice( TBool aRootDevice ); |
|
119 |
|
120 /** |
|
121 * Return local. |
|
122 * @since Series60 2.0 |
|
123 * @return TBool |
|
124 */ |
|
125 IMPORT_C TBool Local() const; |
|
126 |
|
127 /** |
|
128 * Set local. |
|
129 * @since Series60 2.0 |
|
130 * @param aLocal if local or not |
|
131 */ |
|
132 void SetLocal( TBool aLocal ); |
|
133 |
|
134 /** |
|
135 * Is alive. |
|
136 * @since Series60 2.0 |
|
137 * @return TBool |
|
138 */ |
|
139 IMPORT_C TBool Alive() const; |
|
140 |
|
141 /** |
|
142 * SetAlive. |
|
143 * @since Series60 2.0 |
|
144 */ |
|
145 IMPORT_C void SetAlive(TBool aAlive); |
|
146 |
|
147 /** |
|
148 * Should be filtered. |
|
149 * @since Series60 3.2 |
|
150 * @return TBool |
|
151 */ |
|
152 TBool Filter() const; |
|
153 |
|
154 /** |
|
155 * SetFilter. |
|
156 * @since Series60 2.0 |
|
157 */ |
|
158 void SetFilter(TBool aFilter); |
|
159 |
|
160 /** |
|
161 * Idicate if device cache-control time expired. |
|
162 * @since Series60 3.2 |
|
163 * @return ETrue if expired, otherwise EFalse |
|
164 */ |
|
165 TBool Expired() const; |
|
166 |
|
167 /** |
|
168 * Setter. |
|
169 * @since Series60 3.2 |
|
170 */ |
|
171 void SetExpired( TBool aExpired ); |
|
172 |
|
173 /** |
|
174 * Set update id. |
|
175 * @since Series60 2.0 |
|
176 * @param aUpdateId update ID |
|
177 */ |
|
178 IMPORT_C void SetUpdateId( TInt aUpdateId ); |
|
179 |
|
180 /** |
|
181 * Return update ID. |
|
182 * @since Series60 2.0 |
|
183 * @return TInt update ID |
|
184 */ |
|
185 IMPORT_C TInt UpdateId() const; |
|
186 |
|
187 /** |
|
188 * ?member_description. |
|
189 * @since Series60 2.0 |
|
190 * @return ?description |
|
191 */ |
|
192 IMPORT_C TUpnpDevice* AsTDeviceL() const; |
|
193 |
|
194 /** |
|
195 * Returns true, if the element describes a root device. |
|
196 * @since Series60 2.0 |
|
197 * @return ETrue, if root device; EFalse otherwise |
|
198 */ |
|
199 IMPORT_C TBool IsRootDevice() const; |
|
200 |
|
201 /** |
|
202 * Returns the UUID of this element. |
|
203 * @since Series60 2.0 |
|
204 * @return Descriptor containing the UUID. |
|
205 */ |
|
206 IMPORT_C TDesC8& UUID(); |
|
207 |
|
208 /** |
|
209 * Returns the description URL of this element. |
|
210 * @since Series60 2.0 |
|
211 * @return Descriptor containing the description URL. |
|
212 */ |
|
213 IMPORT_C TDesC8& DescriptionUrl(); |
|
214 |
|
215 /** |
|
216 * Returns the domain of this element. |
|
217 * @since Series60 2.0 |
|
218 * @return Descriptor containing the domain. |
|
219 */ |
|
220 IMPORT_C TDesC8& Domain(); |
|
221 |
|
222 /** |
|
223 * Returns the device type of this element. |
|
224 * @since Series60 2.0 |
|
225 * @return Descriptor containing the device type. |
|
226 */ |
|
227 IMPORT_C TDesC8& DeviceType(); |
|
228 |
|
229 /** |
|
230 * Returns an array containing the service types of the services |
|
231 * of this element. |
|
232 * @since Series60 2.0 |
|
233 * @return Descriptor array containing the service types. |
|
234 */ |
|
235 IMPORT_C CDesC8Array& ServiceList(); |
|
236 |
|
237 private: |
|
238 |
|
239 /** |
|
240 * C++ default constructor. |
|
241 * @param aParent The parent of the element (e.g. device library) |
|
242 * to handle timeout callbacks |
|
243 */ |
|
244 CUpnpDeviceLibraryElement( MUpnpTimeoutElementParent& aParent ); |
|
245 |
|
246 /** |
|
247 * By default Symbian 2nd phase constructor is private. |
|
248 */ |
|
249 void ConstructL(); |
|
250 |
|
251 private: |
|
252 |
|
253 /** |
|
254 * Sets the UUID of a device to aUUID. |
|
255 * @since Series60 2.0 |
|
256 * @param aUUID UUID value that is to be set for this element. |
|
257 */ |
|
258 void SetUuidL( const TDesC8& aUUID ); |
|
259 |
|
260 /** |
|
261 * Sets the url to this device's description file. |
|
262 * @since Series60 2.0 |
|
263 * @param aDescriptionURL New value of description url. |
|
264 */ |
|
265 void SetDescriptionUrlL( const TDesC8& aDescriptionURL ); |
|
266 |
|
267 /** |
|
268 * Sets the url to this device's description file. |
|
269 * @param aDescriptionURL New value of description url. |
|
270 * @param aAddr Address of the device. |
|
271 * @param aPort Port of the device. |
|
272 */ |
|
273 void SetDescriptionUrlL( const TDesC8& aDescriptionURL, |
|
274 const TInetAddr& aAddr, |
|
275 const TDesC8& aPort ); |
|
276 |
|
277 /** |
|
278 * Sets the domain value for this element. |
|
279 * @since Series60 2.0 |
|
280 * @param aDomain New value for Domain. |
|
281 */ |
|
282 void SetDomainL( const TDesC8& aDomain ); |
|
283 |
|
284 /** |
|
285 * Sets the device's type (for example MediaServer:1). |
|
286 * @since Series60 2.0 |
|
287 * @param aDeviceType New value for device type. |
|
288 */ |
|
289 void SetDeviceTypeL( const TDesC8& aDeviceType ); |
|
290 |
|
291 /** |
|
292 * Adds a service to this element. Service type is aServiceType |
|
293 * (ConnectionManager:1 for example). |
|
294 * @since Series60 2.0 |
|
295 * @param aServiceType Name of service that is to be added. |
|
296 */ |
|
297 void AddServiceTypeL( const TDesC8& aServiceType ); |
|
298 |
|
299 /** |
|
300 * Add data (only from Notification Type Header) of a SSDP message to the device library |
|
301 * @param aMessage A SSDP message |
|
302 * @return ETrue if device changed |
|
303 */ |
|
304 TBool AddInfoFromNotificationTypeHeaderL( CUpnpSsdpMessage* aMessage); |
|
305 |
|
306 /** |
|
307 * Check if a aDescriptor has prefix aPrefix |
|
308 * @param aDescriptor |
|
309 * @param aPrefix |
|
310 * @return TBool |
|
311 */ |
|
312 static TBool HasPrefix( const TDesC8& aDescriptor, const TDesC8& aPrefix ); |
|
313 |
|
314 protected: |
|
315 TInt iUpdateId; |
|
316 private: |
|
317 TBool iAlive; |
|
318 TBool iFilter; |
|
319 TBool iLocal; |
|
320 TBool iExpired; |
|
321 TBool iRootDevice; |
|
322 HBufC8* iUUID; |
|
323 HBufC8* iDeviceType; |
|
324 HBufC8* iDomain; |
|
325 HBufC8* iDescriptionURL; |
|
326 CDesC8ArrayFlat* iServiceList; |
|
327 TBool iAdvertised; |
|
328 }; |
|
329 |
|
330 #endif // C_CUPNPDEVICELIBRARYELEMENT_H |
|
331 |
|
332 // End of File |