|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // @file |
|
15 // @internalComponent |
|
16 // |
|
17 // |
|
18 |
|
19 #include <comms-infras/ss_msgintercept.h> |
|
20 #include <comms-infras/ss_log.h> |
|
21 #include <comms-infras/ss_logext.h> |
|
22 #include <inetprottextutils.h> |
|
23 #include <rmemchunk.h> |
|
24 |
|
25 #include "upnpservicescpr.h" |
|
26 #include "upnpservicescpractivities.h" |
|
27 #include "upnpsubconnevents.h" |
|
28 #include "upnpstatemachine.h" |
|
29 #include "upnpserverconstants.h" |
|
30 #include "upnplog.h" |
|
31 #include "upnpcpr.h" |
|
32 |
|
33 __FLOG_STMT(_LIT8(KComponent,"UPnPSPScpr");) |
|
34 |
|
35 |
|
36 using namespace ESock; |
|
37 |
|
38 |
|
39 CUPnPServiceSubConnectionProvider* CUPnPServiceSubConnectionProvider::NewL ( ESock::CSubConnectionProviderFactoryBase& aFactory ) |
|
40 { |
|
41 CUPnPServiceSubConnectionProvider* provider = new ( ELeave ) CUPnPServiceSubConnectionProvider ( aFactory, UPnPServiceSCprActivities::activityMap::Self ( ) ); |
|
42 CleanupStack::PushL ( provider ); |
|
43 provider->ConstructL( ); |
|
44 CleanupStack::Pop ( provider ); |
|
45 return provider; |
|
46 } |
|
47 |
|
48 CUPnPServiceSubConnectionProvider::~CUPnPServiceSubConnectionProvider ( ) |
|
49 { |
|
50 iDescUrl.Close ( ); |
|
51 iControlUrl.Close ( ); |
|
52 iEventUrl.Close ( ); |
|
53 iResponseBundle.Close (); |
|
54 |
|
55 delete iSubscribeInfoCont; |
|
56 delete iPublishInfo; |
|
57 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("Destroyed CUPnPServiceSubConnectionProvider"))); |
|
58 LOG_NODE_DESTROY ( KSubsysSPScpr, CUPnPServiceSubConnectionProvider ); |
|
59 } |
|
60 |
|
61 CUPnPServiceSubConnectionProvider::CUPnPServiceSubConnectionProvider ( ESock::CSubConnectionProviderFactoryBase& aFactory, const MeshMachine::TNodeActivityMap& aActivityMap ) |
|
62 : CUPnPSubConnectionProvider ( aFactory, aActivityMap ), iDevice ( EFalse ), iClosing ( EFalse ) |
|
63 { |
|
64 LOG_NODE_CREATE ( KSubsysSPScpr, CUPnPServiceSubConnectionProvider ); |
|
65 } |
|
66 |
|
67 void CUPnPServiceSubConnectionProvider::ConstructL ( ) |
|
68 { |
|
69 CCoreSubConnectionProvider::ConstructL ( ); |
|
70 iResponseBundle.CreateL (); |
|
71 iResponseBundle.Open (); |
|
72 |
|
73 iRequestBundle.CreateL (); |
|
74 |
|
75 iSubscribeInfoCont = CUPnPSubscribeInfoContainer::NewL ( ); |
|
76 // set intial event data |
|
77 iSubscribeInfoCont->SetEventDataL ( KNullDesC8 ( ) ); |
|
78 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("Created CUPnPServiceSubConnectionProvider"))); |
|
79 } |
|
80 |
|
81 void CUPnPServiceSubConnectionProvider::SetPublishInfo ( CUPnPPublishInfoElement* aPublishInfo ) |
|
82 { |
|
83 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::SetPublishInfo"))); |
|
84 iPublishInfo = aPublishInfo; |
|
85 } |
|
86 |
|
87 CUPnPPublishInfoElement* CUPnPServiceSubConnectionProvider::PublishInfo ( ) |
|
88 { |
|
89 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::PublishInfo"))); |
|
90 return iPublishInfo; |
|
91 } |
|
92 |
|
93 void CUPnPServiceSubConnectionProvider::SetKeyL ( const TDesC8& aKey ) |
|
94 { |
|
95 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::SetKeyL"))); |
|
96 iDescUrl.Close ( ); |
|
97 CreatePropertyUrlL ( aKey, iDescUrl ); |
|
98 } |
|
99 |
|
100 const TDesC8& CUPnPServiceSubConnectionProvider::Key ( ) |
|
101 { |
|
102 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::Key"))); |
|
103 return iDescUrl; |
|
104 } |
|
105 |
|
106 void CUPnPServiceSubConnectionProvider::SetEventUrlL ( const TDesC8& aEventUrl ) |
|
107 { |
|
108 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::SetEventUrlL"))); |
|
109 iEventUrl.Close ( ); |
|
110 CreatePropertyUrlL ( aEventUrl, iEventUrl ); |
|
111 } |
|
112 |
|
113 const TDesC8& CUPnPServiceSubConnectionProvider::EventUrl ( ) |
|
114 { |
|
115 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::EventUrl"))); |
|
116 return iEventUrl; |
|
117 } |
|
118 |
|
119 void CUPnPServiceSubConnectionProvider::SetControlUrlL ( const TDesC8& aControlUrl ) |
|
120 { |
|
121 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::SetControlUrlL"))); |
|
122 iControlUrl.Close ( ); |
|
123 CreatePropertyUrlL ( aControlUrl, iControlUrl ); |
|
124 } |
|
125 |
|
126 void CUPnPServiceSubConnectionProvider::CreatePropertyUrlL ( const TDesC8& aRelativeUrl, RBuf8& aTargetUrl ) |
|
127 { |
|
128 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::CreatePropertyUrlL"))); |
|
129 const TDesC8& rootLoc = ConnectionProvider ().RootDeviceLocation (); |
|
130 |
|
131 aTargetUrl.CreateMaxL ( rootLoc.Length ( ) + aRelativeUrl.Length ( ) ); |
|
132 aTargetUrl.Copy ( rootLoc ); |
|
133 aTargetUrl.Append ( aRelativeUrl ); |
|
134 } |
|
135 const TDesC8& CUPnPServiceSubConnectionProvider::ControlUrl ( ) |
|
136 { |
|
137 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::ControlUrl"))); |
|
138 return iControlUrl; |
|
139 } |
|
140 |
|
141 void CUPnPServiceSubConnectionProvider::SetDevice ( const TBool aIsDevice ) |
|
142 { |
|
143 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::SetDevice"))); |
|
144 iDevice = aIsDevice; |
|
145 } |
|
146 |
|
147 TBool CUPnPServiceSubConnectionProvider::IsDevice ( ) |
|
148 { |
|
149 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::IsDevice"))); |
|
150 return iDevice; |
|
151 } |
|
152 |
|
153 const TDesC8& CUPnPServiceSubConnectionProvider::SCPDData ( ) |
|
154 { |
|
155 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::SCPDData"))); |
|
156 return iPublishInfo->ServiceDescription( ); |
|
157 } |
|
158 |
|
159 CUPnPSubscribeInfoContainer* CUPnPServiceSubConnectionProvider::GetSubscribeInfoContainer ( ) |
|
160 { |
|
161 return iSubscribeInfoCont; |
|
162 } |
|
163 |
|
164 CUPnPServiceConnectionProvider& CUPnPServiceSubConnectionProvider::ConnectionProvider ( ) |
|
165 { |
|
166 CUPnPConnectionProvider& cprBase = BaseConnectionProvider(); |
|
167 return static_cast<CUPnPServiceConnectionProvider&>(cprBase); |
|
168 } |
|
169 |
|
170 void CUPnPServiceSubConnectionProvider::ReceivedL ( const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage ) |
|
171 { |
|
172 ESOCK_DEBUG_MESSAGE_INTERCEPT ( aSender, aMessage, aRecipient ); |
|
173 TNodeContext<CUPnPServiceSubConnectionProvider> ctx(*this, aMessage, aSender, aRecipient); |
|
174 CCoreSubConnectionProvider::ReceivedL ( aSender, aRecipient, aMessage ); |
|
175 User::LeaveIfError ( ctx.iReturn ); |
|
176 } |
|
177 |
|
178 void CUPnPServiceSubConnectionProvider::InitiateActivitiesL ( ) |
|
179 { |
|
180 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::InitiateActivitiesL"))); |
|
181 |
|
182 RParameterFamily paramFamily = iRequestBundle.GetFamilyAtIndex (0); |
|
183 switch ( paramFamily.Id( ) ) |
|
184 { |
|
185 case EUPnPClearParamSet: |
|
186 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::InitiateActivitiesL - TUPnPParamSetFamily::EUPnPClearParamSet"))); |
|
187 ClearResponseParamL ( ); |
|
188 break; |
|
189 |
|
190 case EUPnPServiceNotificationParamSet: |
|
191 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::InitiateActivitiesL - TUPnPParamSetFamily::EUPnPServiceNotificationParamSet"))); |
|
192 SendNotifyToRemoteClientsL ( paramFamily ); |
|
193 break; |
|
194 |
|
195 case EUPnPServiceRegisterParamSet: |
|
196 case EUPnPServiceRefreshParamSet: |
|
197 case EUPnPDeviceRegisterParamSetExt: |
|
198 InitiateRequestL ( paramFamily ); |
|
199 break; |
|
200 |
|
201 default: |
|
202 break; |
|
203 } |
|
204 //finally delete UPnP Clear Family |
|
205 iRequestBundle.DeleteFamilyAtIndex (0); |
|
206 } |
|
207 |
|
208 |
|
209 void CUPnPServiceSubConnectionProvider::InitiateRequestL ( RParameterFamily& aReqFamily ) |
|
210 { |
|
211 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::InitiateRequestL"))); |
|
212 switch ( aReqFamily.Id ( ) ) |
|
213 { |
|
214 case EUPnPServiceRegisterParamSet: |
|
215 { |
|
216 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::InitiateRequestL - TUPnPParamSetFamily::EUPnPServiceRegisterParamSet"))); |
|
217 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::InitiateRequestL - TUPnPParamSetFamily::EUPnPServiceRegisterParamSet - Posting message TUpnpMessage::TServiceRegistration"))); |
|
218 CSubConExtensionParameterSet* paramSet = static_cast<CSubConExtensionParameterSet*> ( aReqFamily.GetParameterSetAtIndex ( 0, RParameterFamily::ERequested ) ); |
|
219 TUpnpMessage::TServiceRegistration msg ( paramSet ); |
|
220 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( TUpnpMessage::EActivityServiceRegistration, NodeId () ) , msg ); |
|
221 aReqFamily.ClearParameterSetPointer( 0, RParameterFamily::ERequested ); |
|
222 } |
|
223 break; |
|
224 |
|
225 case EUPnPDeviceRegisterParamSetExt: |
|
226 { |
|
227 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::InitiateRequestL - TUPnPParamSetFamily::EUPnPDeviceRegisterParamSet"))); |
|
228 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::InitiateRequestL - TUPnPParamSetFamily::EUPnPDeviceRegisterParamSet - Posting message TUpnpMessage::TDeviceRegistration"))); |
|
229 CUPnPDeviceRegisterParamSetExt* paramSet = static_cast<CUPnPDeviceRegisterParamSetExt*> ( aReqFamily.GetParameterSetAtIndex ( 0, RParameterFamily::ERequested ) ); |
|
230 |
|
231 CUPnPDeviceRegisterParamSet* deviceParams = CopyWithIconInfoL ( paramSet ); |
|
232 |
|
233 TUpnpMessage::TDeviceRegistration msg ( deviceParams ); |
|
234 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( TUpnpMessage::EActivityDeviceRegistration, NodeId () ) , msg ); |
|
235 } |
|
236 break; |
|
237 |
|
238 case EUPnPServiceRefreshParamSet: |
|
239 { |
|
240 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::InitiateRequestL - TUPnPParamSetFamily::EUPnPServiceRefreshParamSet"))); |
|
241 if ( IsDevice ( ) ) |
|
242 { |
|
243 // Publish once for uuid:device-UUID |
|
244 DoPublishL ( iPublishInfo->Uuid( ), iPublishInfo->Uuid( ), iPublishInfo->CacheControl( ) ); |
|
245 } |
|
246 |
|
247 // Publish once for uuid:device-UUID::urn:domain-name-device:deviceType:v |
|
248 // (or) Publish once for uuid:device-UUID::urn:domain-name-service:serviceType:v |
|
249 DoPublishL ( iPublishInfo->SearchTarget( ), iPublishInfo->Usn( ), iPublishInfo->CacheControl( ) ); |
|
250 } |
|
251 break; |
|
252 |
|
253 default: |
|
254 break; |
|
255 } |
|
256 } |
|
257 |
|
258 void CUPnPServiceSubConnectionProvider::DoPublishL ( const TDesC8& aSearchTarget, const TDesC8& aUsn, TInt aMaxAge ) |
|
259 { |
|
260 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::DoPublishL"))); |
|
261 RMemoryAllocator allocator = ConnectionProvider().MemoryAllocator(); |
|
262 |
|
263 RMemChunk locationBuf; |
|
264 locationBuf.CreateL ( ConnectionProvider ().RootDeviceLocation (), allocator ); |
|
265 |
|
266 RMemChunk stBuf; |
|
267 stBuf.CreateL ( aSearchTarget, allocator ); |
|
268 TCleanupItem item ( &UPnPStateMachine::CUPnPUtils::CleanupMBufChain, &stBuf ); |
|
269 CleanupStack::PushL ( item ); |
|
270 |
|
271 RMemChunk usnBuf; |
|
272 usnBuf.CreateL ( aUsn, allocator ); |
|
273 |
|
274 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::DoPublishL - Posting message TUpnpMessage::TUPnPPublishAliveRequest"))); |
|
275 TSsdpInfo ssdpInfo ( aMaxAge, locationBuf, usnBuf, stBuf); |
|
276 RClientInterface::OpenPostMessageClose ( NodeId (), UdpClientFlow (), TUpnpMessage::TUPnPPublishAliveRequest ( ssdpInfo ).CRef () ); |
|
277 CleanupStack::Pop ( ); // item |
|
278 } |
|
279 |
|
280 |
|
281 // this will send notification to the clients |
|
282 void CUPnPServiceSubConnectionProvider::SendNotifyToRemoteClientsL ( RParameterFamily& aReqFamily ) |
|
283 { |
|
284 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::SendNotifyToRemoteClientsL"))); |
|
285 CUPnPServiceNotificationParamSet* paramSet = static_cast<CUPnPServiceNotificationParamSet* > (aReqFamily.GetParameterSetAtIndex ( 0, RParameterFamily::ERequested ) ); |
|
286 __ASSERT_DEBUG ( paramSet != NULL, User::Invariant ( ) ); |
|
287 |
|
288 // replace the existing data |
|
289 iSubscribeInfoCont->SetEventDataL( paramSet->Notification( ) ); |
|
290 // now send it to all the subscribers |
|
291 for ( TInt i =0; i < iSubscribeInfoCont->CountOfSubscribeInfoElementArray( ); i++ ) |
|
292 { |
|
293 CUPnPSubscribeInfoElement* element = iSubscribeInfoCont->AtSubscribeInfoElementArray( i ); |
|
294 TInt eventKey = element->EventKey( ); |
|
295 eventKey++; |
|
296 if(eventKey == 0) |
|
297 { |
|
298 eventKey++; //wrap around |
|
299 } |
|
300 element->SetEventKey(eventKey); |
|
301 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::SendNotifyToRemoteClientsL - Posting message TUpnpMessage::TNotifyRequest"))); |
|
302 // send the message to start the activty |
|
303 RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( TUpnpMessage::EActivityNotifyRequest, NodeId () ), TUpnpMessage::TNotifyRequest ( element ).CRef () ); |
|
304 } |
|
305 } |
|
306 |
|
307 void CUPnPServiceSubConnectionProvider::NotifySubConnectionL ( ) |
|
308 { |
|
309 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::NotifySubConnectionL"))); |
|
310 CUPnPSubConnEvent* subConnEvent = CUPnPSubConnEvent::NewL ( ); |
|
311 |
|
312 TCleanupItem item ( &CUPnPSubConnEvent::CleanupSubConnEvent, subConnEvent ); |
|
313 CleanupStack::PushL ( item ); |
|
314 |
|
315 subConnEvent->SetFamily ( EUPnPPublishResponseParamSet ); |
|
316 NotifyClientsL ( *subConnEvent ); |
|
317 CleanupStack::Pop ( ); // item |
|
318 } |
|
319 |
|
320 void CUPnPServiceSubConnectionProvider::ClearResponseParamL ( ) |
|
321 { |
|
322 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::ClearResponseParamL"))); |
|
323 iResponseBundle.Close (); // DEF126893 fix pending |
|
324 } |
|
325 |
|
326 void CUPnPServiceSubConnectionProvider::AddResponseParamSetL ( TUPnPEvent aEvent ) |
|
327 { |
|
328 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::AddResponseParamSetL"))); |
|
329 if ( !IsClosing ( ) ) |
|
330 { |
|
331 RParameterFamily responseFamily = iResponseBundle.CreateFamilyL ( EUPnPPublishResponseParamSet ); |
|
332 RParameterFamily family; |
|
333 CUPnPPublishResponseParamSet* responseSet = CUPnPPublishResponseParamSet::NewL ( family ); |
|
334 responseFamily.AddParameterSetL ( responseSet, RParameterFamily::ERequested ); |
|
335 |
|
336 if ( iPublishInfo ) |
|
337 responseSet->SetUriL( iPublishInfo->SearchTarget( ) ); |
|
338 responseSet->SetUPnPEvent( aEvent ); |
|
339 |
|
340 NotifySubConnectionL ( ); |
|
341 } |
|
342 } |
|
343 |
|
344 |
|
345 void CUPnPServiceSubConnectionProvider::DeprecateExpiredSubscriptions ( ) |
|
346 { |
|
347 LOG(ESockLogExternal::Printf(KSubsysSPScpr, KComponent, _L8("CUPnPServiceSubConnectionProvider::DeprecateExpiredSubscriptions"))); |
|
348 TInt duration; |
|
349 TUint count = iSubscribeInfoCont->CountOfSubscribeInfoElementArray( ); |
|
350 CUPnPSubscribeInfoElement* element = NULL; |
|
351 |
|
352 for ( TInt i = 0; i < count; i++ ) |
|
353 { |
|
354 element = iSubscribeInfoCont->AtSubscribeInfoElementArray( i ); |
|
355 duration = element->SubscriptionDuration( ); |
|
356 if ( --duration == 0 ) |
|
357 { |
|
358 // timer has expired so delete this entry |
|
359 iSubscribeInfoCont->DeleteSubscribeInfoElement( element ); |
|
360 } |
|
361 else |
|
362 { |
|
363 element->SetSubscriptionDuration( duration ); |
|
364 } |
|
365 } |
|
366 } |
|
367 |
|
368 CUPnPDeviceRegisterParamSet* CUPnPServiceSubConnectionProvider::CopyWithIconInfoL ( CUPnPDeviceRegisterParamSetExt* aDeviceParam ) |
|
369 { |
|
370 RParameterFamily family; |
|
371 CUPnPDeviceRegisterParamSet* newParamSet = CUPnPDeviceRegisterParamSet::NewL ( family ); |
|
372 newParamSet->SetUriL ( aDeviceParam->Uri () ); |
|
373 newParamSet->SetCacheControlData ( aDeviceParam->CacheControlData () ); |
|
374 newParamSet->SetParentDeviceUidL ( aDeviceParam->ParentDeviceUid () ); |
|
375 newParamSet->SetFriendlyNameL ( aDeviceParam->FriendlyName () ); |
|
376 newParamSet->SetManufacturerL ( aDeviceParam->Manufacturer () ); |
|
377 newParamSet->SetManufactureUrlL ( aDeviceParam->ManufacturerUrl () ); |
|
378 newParamSet->SetModelDescL ( aDeviceParam->ModelDesc () ); |
|
379 newParamSet->SetModelNameL ( aDeviceParam->ModelName () ); |
|
380 newParamSet->SetModelNumberL ( aDeviceParam->ModelNumber () ); |
|
381 newParamSet->SetModelUriL ( aDeviceParam->ModelUri () ); |
|
382 newParamSet->SetPresentationL ( aDeviceParam->PresentationUri () ); |
|
383 newParamSet->SetSerialNumberL ( aDeviceParam->SerialNumber () ); |
|
384 newParamSet->SetUDNL ( aDeviceParam->UDN () ); |
|
385 newParamSet->SetUPCL ( aDeviceParam->UPC () ); |
|
386 |
|
387 LoadIconListL ( aDeviceParam->IconData (), newParamSet ); |
|
388 |
|
389 return newParamSet; |
|
390 } |
|
391 |
|
392 void CUPnPServiceSubConnectionProvider::LoadIconListL ( const TDesC8& aIconData, CUPnPDeviceRegisterParamSet* aDeviceParamSet ) |
|
393 { |
|
394 TPtrC8 buffer ( aIconData ); |
|
395 TInt count = 0; |
|
396 ReadTInt ( buffer, count ); |
|
397 |
|
398 TInt size = 0; |
|
399 for ( TInt i = 0; i < count; i++ ) |
|
400 { |
|
401 CUPnPIconParams* icon = CUPnPIconParams::NewL (); |
|
402 CleanupStack::PushL ( icon ); |
|
403 |
|
404 ReadTInt ( buffer, size ); |
|
405 icon->SetMimeTypeL ( buffer.Left ( size ) ); |
|
406 buffer.Set ( buffer.Ptr () + size, buffer.Length () - size ); //update pointer |
|
407 |
|
408 ReadTInt ( buffer, size ); |
|
409 icon->SetUrlL ( buffer.Left ( size ) ); |
|
410 buffer.Set ( buffer.Ptr () + size, buffer.Length () - size ); //update pointer |
|
411 |
|
412 ReadTInt ( buffer, size ); |
|
413 icon->SetWidth ( size ); |
|
414 |
|
415 ReadTInt ( buffer, size ); |
|
416 icon->SetHeight ( size ); |
|
417 |
|
418 ReadTInt ( buffer, size ); |
|
419 icon->SetDepth ( size ); |
|
420 |
|
421 aDeviceParamSet->SetIconInfoL ( icon ); |
|
422 CleanupStack::Pop (); // icon |
|
423 } |
|
424 } |
|
425 |
|
426 void CUPnPServiceSubConnectionProvider::ReadTInt ( TPtrC8& aBuffer, TInt& aValue ) |
|
427 { |
|
428 TUint32 len = sizeof ( TUint32 ); |
|
429 TPtrC8 ptr ( aBuffer.Ptr (), len ); |
|
430 InetProtTextUtils::ConvertDescriptorToInt ( ptr, aValue ); |
|
431 aBuffer.Set ( aBuffer.Ptr () + len, aBuffer.Length () - len ); //update pointer |
|
432 } |
|
433 |