|
1 /* |
|
2 * Copyright (c) 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: server impl. of session against media server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 // System |
|
25 #include <utf.h> |
|
26 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
27 #include <centralrepository.h> |
|
28 |
|
29 // upnp stack api |
|
30 #include <upnpstring.h> |
|
31 #include <upnpdevice.h> |
|
32 #include <upnpcontainer.h> |
|
33 #include <upnpservice.h> |
|
34 #include <upnpitem.h> |
|
35 #include <upnpelement.h> |
|
36 #include <upnpmediaserversettings.h> |
|
37 #include <upnpmediaserverclient.h> |
|
38 #include <upnpmediaservernotifier.h> |
|
39 #include <upnpfiletransferevent.h> |
|
40 |
|
41 #include <upnpavcontrolpoint.h> |
|
42 |
|
43 // upnpframework / avcontroller api |
|
44 #include "upnpavrenderingsessionobserver.h" |
|
45 |
|
46 // upnpframework / avcontroller helper api |
|
47 #include "upnpconstantdefs.h" // for upnp-specific stuff |
|
48 #include "upnpfileutility.h" |
|
49 #include "upnpitemutility.h" |
|
50 |
|
51 // upnpframework / xml parser api |
|
52 #include "upnpxmlparser.h" |
|
53 |
|
54 // upnpframework / internal api's |
|
55 #include "upnpcontentservercrkeys.h" |
|
56 #include "upnpcommonutils.h" |
|
57 #include "upnpcdsreselementutility.h" |
|
58 #include "upnpmetadatafetcher.h" |
|
59 |
|
60 // avcontroller internal |
|
61 #include "upnpfilesharingactive.h" |
|
62 #include "upnpavdispatcher.h" |
|
63 #include "upnpavbrowserequest.h" |
|
64 #include "upnpavrequest.h" |
|
65 #include "upnpaverrorhandler.h" |
|
66 #include "upnpavdeviceextended.h" |
|
67 #include "upnpdevicerepository.h" |
|
68 #include "upnpavbrowserespparams.h" |
|
69 #include "upnpavcontrollerserver.h" |
|
70 #include "upnpbrowsingsession.h" |
|
71 |
|
72 // CONSTANTS |
|
73 _LIT8( KDirectChildren, "BrowseDirectChildren" ); |
|
74 _LIT8( KMetaData, "BrowseMetadata" ); |
|
75 _LIT8( KImportUri, "importUri" ); |
|
76 _LIT8( KCreateClass, "upnp:createClass" ); |
|
77 _LIT8( KBrowseMetadata, "BrowseMetadata" ); |
|
78 const TInt KDefaultInstanceId = 0; |
|
79 const TInt KExpectedCount = 1; |
|
80 |
|
81 _LIT( KComponentLogfile, "upnpavcontrollerserver.txt"); |
|
82 #include "upnplog.h" |
|
83 |
|
84 |
|
85 // ======== MEMBER FUNCTIONS ======== |
|
86 |
|
87 // -------------------------------------------------------------------------- |
|
88 // CUPnPBrowsingSession::NewL |
|
89 // See upnpbrowsingsession.h |
|
90 // -------------------------------------------------------------------------- |
|
91 CUPnPBrowsingSession* CUPnPBrowsingSession::NewL |
|
92 ( |
|
93 RUpnpMediaServerClient& aClient, |
|
94 CUpnpAVControllerServer& aServer, |
|
95 TInt aSessionId, |
|
96 const TDesC8& aUuid |
|
97 ) |
|
98 { |
|
99 CUPnPBrowsingSession* self = new (ELeave) CUPnPBrowsingSession( |
|
100 aClient, aServer, aSessionId ); |
|
101 CleanupStack::PushL( self ); |
|
102 |
|
103 self->ConstructL( aUuid ); |
|
104 CleanupStack::Pop( self ); |
|
105 return self; |
|
106 } |
|
107 |
|
108 // -------------------------------------------------------------------------- |
|
109 // CUPnPBrowsingSession::CUPnPBrowsingSession |
|
110 // See upnpbrowsingsession.h |
|
111 // -------------------------------------------------------------------------- |
|
112 CUPnPBrowsingSession::CUPnPBrowsingSession |
|
113 ( |
|
114 RUpnpMediaServerClient& aClient, |
|
115 CUpnpAVControllerServer& aServer, |
|
116 TInt aSessionId |
|
117 ): |
|
118 iMediaServer( aClient ), |
|
119 iServer( aServer ), |
|
120 iSessionId( aSessionId ), |
|
121 |
|
122 iInstanceId( KDefaultInstanceId ), |
|
123 iIPSessionId( KErrNotFound ), |
|
124 |
|
125 iTransferId( KErrNotFound ), |
|
126 |
|
127 iTransferEventReceived( EFalse ), |
|
128 iInternalState( ENone ), |
|
129 iCopyState( EIdle ) |
|
130 { |
|
131 } |
|
132 |
|
133 // -------------------------------------------------------------------------- |
|
134 // CUPnPBrowsingSession::~CUPnPBrowsingSession |
|
135 // See upnpbrowsingsession.h |
|
136 // -------------------------------------------------------------------------- |
|
137 CUPnPBrowsingSession::~CUPnPBrowsingSession() |
|
138 { |
|
139 iIPSessionId = KErrNotFound; |
|
140 |
|
141 delete iDevice; |
|
142 delete iRespBuf; |
|
143 delete iRespBuf2; |
|
144 |
|
145 delete iImportURI; |
|
146 delete iSourceURI; |
|
147 |
|
148 delete iItemId; |
|
149 |
|
150 delete iContainerId; |
|
151 |
|
152 delete iSharedItem; |
|
153 |
|
154 delete iMediaServerNotifier; |
|
155 |
|
156 delete iFileSharing; |
|
157 |
|
158 delete iLocalMediaServerUuid; |
|
159 |
|
160 delete iOriginalLocation; |
|
161 |
|
162 delete iFilePath; |
|
163 |
|
164 delete iMSSettings; |
|
165 delete iAppSettings; |
|
166 |
|
167 delete iActionMessage; |
|
168 delete iDeviceMessage; |
|
169 } |
|
170 |
|
171 // -------------------------------------------------------------------------- |
|
172 // CUPnPBrowsingSession::ConstructL |
|
173 // See upnpbrowsingsession.h |
|
174 // -------------------------------------------------------------------------- |
|
175 void CUPnPBrowsingSession::ConstructL( const TDesC8& aUuid ) |
|
176 { |
|
177 __LOG( "CUPnPBrowsingSession::ConstructL" ); |
|
178 |
|
179 iMediaServerNotifier = CUpnpMediaServerNotifier::NewL( this ); |
|
180 iFileSharing = CUPnPFileSharingActive::NewL(); |
|
181 |
|
182 // Get the local Media Server Uuid, if available |
|
183 const RPointerArray<CUpnpAVDeviceExtended>& devList = |
|
184 iServer.DeviceRepository().DeviceList(); |
|
185 TInt count = devList.Count(); |
|
186 TInt i; |
|
187 for( i = 0; i < count; i++ ) |
|
188 { |
|
189 if( devList[ i ]->Local() ) |
|
190 { |
|
191 __ASSERTD( !iLocalMediaServerUuid, __FILE__, __LINE__ ); |
|
192 iLocalMediaServerUuid = devList[i]->Uuid().AllocL(); |
|
193 } |
|
194 if( devList[ i ]->Uuid() == aUuid ) |
|
195 { |
|
196 __ASSERTD( !iDevice, __FILE__, __LINE__ ); |
|
197 iDevice = CUpnpAVDeviceExtended::NewL( *devList[ i ] ); |
|
198 } |
|
199 } |
|
200 if( !iDevice ) |
|
201 { |
|
202 if( aUuid == KNullDesC8 ) // Fix to enable AV Controller helper usage |
|
203 { |
|
204 iDevice = CUpnpAVDeviceExtended::NewL(); |
|
205 } |
|
206 else |
|
207 { |
|
208 User::Leave( KErrNotFound ); |
|
209 } |
|
210 } |
|
211 |
|
212 iMSSettings = CUpnpMediaServerSettings::NewL(); |
|
213 iAppSettings = CRepository::NewL( KCrUidUpnpContentserver ); |
|
214 } |
|
215 |
|
216 // -------------------------------------------------------------------------- |
|
217 // CUPnPBrowsingSession::RcSetVolumeResponse |
|
218 // See upnpbrowsingsession.h |
|
219 // -------------------------------------------------------------------------- |
|
220 void CUPnPBrowsingSession::RcSetVolumeResponse( |
|
221 const TDesC8& /*aUuid*/, |
|
222 TInt /*aSessionId*/, |
|
223 TInt /*aErr*/, |
|
224 const TDesC8& /*aInstance*/, |
|
225 const TDesC8& /*aChannel*/, |
|
226 const TDesC8& /*aDesiredVolume*/ ) |
|
227 { |
|
228 // No implementation required |
|
229 } |
|
230 |
|
231 // -------------------------------------------------------------------------- |
|
232 // CUPnPBrowsingSession::RcVolumeResponse |
|
233 // See upnpbrowsingsession.h |
|
234 // -------------------------------------------------------------------------- |
|
235 void CUPnPBrowsingSession::RcVolumeResponse( |
|
236 const TDesC8& /*aUuid*/, |
|
237 TInt /*aSessionId*/, |
|
238 TInt /*aErr*/, |
|
239 const TDesC8& /*aInstance*/, |
|
240 const TDesC8& /*aChannel*/, |
|
241 const TDesC8& /*aCurrentVolume*/) |
|
242 { |
|
243 // No implementation required |
|
244 } |
|
245 |
|
246 // -------------------------------------------------------------------------- |
|
247 // CUPnPBrowsingSession::RcSetMuteResponse |
|
248 // See upnpbrowsingsession.h |
|
249 // -------------------------------------------------------------------------- |
|
250 void CUPnPBrowsingSession::RcSetMuteResponse( |
|
251 const TDesC8& /*aUuid*/, |
|
252 TInt /*aSessionId*/, |
|
253 TInt /*aErr*/, |
|
254 const TDesC8& /*aInstance*/, |
|
255 const TDesC8& /*aChannel*/, |
|
256 const TDesC8& /*aDesiredMute*/ ) |
|
257 { |
|
258 // No implementation required |
|
259 } |
|
260 |
|
261 // -------------------------------------------------------------------------- |
|
262 // CUPnPBrowsingSession::RcMuteResponse |
|
263 // See upnpbrowsingsession.h |
|
264 // -------------------------------------------------------------------------- |
|
265 void CUPnPBrowsingSession::RcMuteResponse( |
|
266 const TDesC8& /*aUuid*/, |
|
267 TInt /*aSessionId*/, |
|
268 TInt /*aErr*/, |
|
269 const TDesC8& /*aInstance*/, |
|
270 const TDesC8& /*aChannel*/, |
|
271 const TDesC8& /*aCurrentMute*/ ) |
|
272 { |
|
273 // No implementation required |
|
274 } |
|
275 |
|
276 |
|
277 // -------------------------------------------------------------------------- |
|
278 // CUPnPBrowsingSession::AvtSetTransportUriResponse |
|
279 // See upnpbrowsingsession.h |
|
280 // -------------------------------------------------------------------------- |
|
281 void CUPnPBrowsingSession::AvtSetTransportUriResponse( |
|
282 const TDesC8& /*aUuid*/, |
|
283 TInt /*aSessionId*/, |
|
284 TInt /*aErr*/, |
|
285 const TDesC8& /*aInstanceId*/, |
|
286 const TDesC8& /*aCurrentUri*/, |
|
287 const TDesC8& /*aCurrentUriMetaData*/) |
|
288 { |
|
289 // No implementation required |
|
290 } |
|
291 |
|
292 // -------------------------------------------------------------------------- |
|
293 // CUPnPBrowsingSession::AvtSetNextTransportUriResponse |
|
294 // See upnpbrowsingsession.h |
|
295 // -------------------------------------------------------------------------- |
|
296 void CUPnPBrowsingSession::AvtSetNextTransportUriResponse( |
|
297 const TDesC8& /*aUuid*/, |
|
298 TInt /*aSessionId*/, |
|
299 TInt /*aErr*/, |
|
300 const TDesC8& /*aInstanceId*/, |
|
301 const TDesC8& /*aNextUri*/, |
|
302 const TDesC8& /*aNextUriMetaData*/) |
|
303 { |
|
304 // No implementation required |
|
305 } |
|
306 |
|
307 // -------------------------------------------------------------------------- |
|
308 // CUPnPBrowsingSession::AvtMediaInfoResponse |
|
309 // See upnpbrowsingsession.h |
|
310 // -------------------------------------------------------------------------- |
|
311 void CUPnPBrowsingSession::AvtMediaInfoResponse( |
|
312 const TDesC8& /*aUuid*/, |
|
313 TInt /*aSessionId*/, |
|
314 TInt /*aErr*/, |
|
315 const TDesC8& /*aInstanceId*/, |
|
316 const TDesC8& /*aNrTracks*/, |
|
317 const TDesC8& /*aMediaDuration*/, |
|
318 const TDesC8& /*aCurrentUri*/, |
|
319 const TDesC8& /*aCurrentUriMetaData*/, |
|
320 const TDesC8& /*aNextUri*/, |
|
321 const TDesC8& /*aNextUriMetaData*/, |
|
322 const TDesC8& /*aPlayMedium*/, |
|
323 const TDesC8& /*aRecordMedium*/, |
|
324 const TDesC8& /*aWriteStatus*/) |
|
325 { |
|
326 // No implementation required |
|
327 } |
|
328 |
|
329 // -------------------------------------------------------------------------- |
|
330 // CUPnPBrowsingSession::AvtGetTransportInfoResponse |
|
331 // See upnpbrowsingsession.h |
|
332 // -------------------------------------------------------------------------- |
|
333 void CUPnPBrowsingSession::AvtGetTransportInfoResponse( |
|
334 const TDesC8& /*aUuid*/, |
|
335 TInt /*aSessionId*/, |
|
336 TInt /*aErr*/, |
|
337 const TDesC8& /*aInstanceId*/, |
|
338 const TDesC8& /*aCurrenTransportState*/, |
|
339 const TDesC8& /*aCurrentTransportStatus*/, |
|
340 const TDesC8& /*aCurrentSpeed*/) |
|
341 { |
|
342 // No implementation required |
|
343 } |
|
344 |
|
345 // -------------------------------------------------------------------------- |
|
346 // CUPnPBrowsingSession::AvtPositionInfoResponse |
|
347 // See upnpbrowsingsession.h |
|
348 // -------------------------------------------------------------------------- |
|
349 void CUPnPBrowsingSession::AvtPositionInfoResponse( |
|
350 const TDesC8& /*aUuid*/, |
|
351 TInt /*aSessionId*/, |
|
352 TInt /*aErr*/, |
|
353 const TDesC8& /*aInstanceId*/, |
|
354 const TDesC8& /*aTrack*/, |
|
355 const TDesC8& /*aTrackDuration*/, |
|
356 const TDesC8& /*aTrackMetaData*/, |
|
357 const TDesC8& /*aTrackURI*/, |
|
358 const TDesC8& /*aRelTime*/, |
|
359 const TDesC8& /*aAbsTime*/, |
|
360 const TDesC8& /*aRelCount*/, |
|
361 const TDesC8& /*aAbsCount*/) |
|
362 { |
|
363 // No implementation required |
|
364 } |
|
365 |
|
366 // -------------------------------------------------------------------------- |
|
367 // CUPnPBrowsingSession::AvtDeviceCapabilitiesResponse |
|
368 // See upnpbrowsingsession.h |
|
369 // -------------------------------------------------------------------------- |
|
370 void CUPnPBrowsingSession::AvtDeviceCapabilitiesResponse( |
|
371 const TDesC8& /*aUuid*/, |
|
372 TInt /*aSessionId*/, |
|
373 TInt /*aErr*/, |
|
374 const TDesC8& /*aInstanceId*/, |
|
375 const TDesC8& /*aPlayMedia*/, |
|
376 const TDesC8& /*aRecMedia*/, |
|
377 const TDesC8& /*aRecQualityMode*/) |
|
378 { |
|
379 // No implementation required |
|
380 } |
|
381 |
|
382 // -------------------------------------------------------------------------- |
|
383 // CUPnPBrowsingSession::AvtTransportSettingsResponse |
|
384 // See upnpbrowsingsession.h |
|
385 // -------------------------------------------------------------------------- |
|
386 void CUPnPBrowsingSession::AvtTransportSettingsResponse( |
|
387 const TDesC8& /*aUuid*/, |
|
388 TInt /*aSessionId*/, |
|
389 TInt /*aErr*/, |
|
390 const TDesC8& /*aInstanceId*/, |
|
391 const TDesC8& /*aPlayMode*/, |
|
392 const TDesC8& /*aRecQualityMode*/) |
|
393 { |
|
394 // No implementation required |
|
395 } |
|
396 |
|
397 // -------------------------------------------------------------------------- |
|
398 // CUPnPBrowsingSession::AvtStopResponse |
|
399 // See upnpbrowsingsession.h |
|
400 // -------------------------------------------------------------------------- |
|
401 void CUPnPBrowsingSession::AvtStopResponse( |
|
402 const TDesC8& /*aUuid*/, |
|
403 TInt /*aSessionId*/, |
|
404 TInt /*aErr*/, |
|
405 const TDesC8& /*aInstanceId*/) |
|
406 { |
|
407 // No implementation required |
|
408 } |
|
409 |
|
410 // -------------------------------------------------------------------------- |
|
411 // CUPnPBrowsingSession::AvtPlayResponse |
|
412 // See upnpbrowsingsession.h |
|
413 // -------------------------------------------------------------------------- |
|
414 void CUPnPBrowsingSession::AvtPlayResponse( |
|
415 const TDesC8& /*aUuid*/, |
|
416 TInt /*aSessionId*/, |
|
417 TInt /*aErr*/, |
|
418 const TDesC8& /*aInstanceId*/, |
|
419 const TDesC8& /*aSpeed*/) |
|
420 { |
|
421 // No implementation required |
|
422 } |
|
423 |
|
424 // -------------------------------------------------------------------------- |
|
425 // CUPnPBrowsingSession::AvtPauseResponse |
|
426 // See upnpbrowsingsession.h |
|
427 // -------------------------------------------------------------------------- |
|
428 void CUPnPBrowsingSession::AvtPauseResponse( |
|
429 const TDesC8& /*aUuid*/, |
|
430 TInt /*aSessionId*/, |
|
431 TInt /*aErr*/, |
|
432 const TDesC8& /*aInstanceId*/) |
|
433 { |
|
434 // No implementation required |
|
435 } |
|
436 |
|
437 // -------------------------------------------------------------------------- |
|
438 // CUPnPBrowsingSession::AvtRecordResponse |
|
439 // See upnpbrowsingsession.h |
|
440 // -------------------------------------------------------------------------- |
|
441 void CUPnPBrowsingSession::AvtRecordResponse( |
|
442 const TDesC8& /*aUuid*/, |
|
443 TInt /*aSessionId*/, |
|
444 TInt /*aErr*/, |
|
445 const TDesC8& /*aInstanceId*/) |
|
446 { |
|
447 // No implementation required |
|
448 } |
|
449 |
|
450 // -------------------------------------------------------------------------- |
|
451 // CUPnPBrowsingSession::AvtSeekResponse |
|
452 // See upnpbrowsingsession.h |
|
453 // -------------------------------------------------------------------------- |
|
454 void CUPnPBrowsingSession::AvtSeekResponse( |
|
455 const TDesC8& /*aUuid*/, |
|
456 TInt /*aSessionId*/, |
|
457 TInt /*aErr*/, |
|
458 const TDesC8& /*aInstanceId*/, |
|
459 const TDesC8& /*aUnit*/, |
|
460 const TDesC8& /*aTarget*/) |
|
461 { |
|
462 // No implementation required |
|
463 } |
|
464 |
|
465 // -------------------------------------------------------------------------- |
|
466 // CUPnPBrowsingSession::AvtNextResponse |
|
467 // See upnpbrowsingsession.h |
|
468 // -------------------------------------------------------------------------- |
|
469 void CUPnPBrowsingSession::AvtNextResponse( |
|
470 const TDesC8& /*aUuid*/, |
|
471 TInt /*aSessionId*/, |
|
472 TInt /*aErr*/, |
|
473 const TDesC8& /*aInstanceId*/) |
|
474 { |
|
475 // No implementation required |
|
476 } |
|
477 |
|
478 // -------------------------------------------------------------------------- |
|
479 // CUPnPBrowsingSession::AvtPreviousResponse |
|
480 // See upnpbrowsingsession.h |
|
481 // -------------------------------------------------------------------------- |
|
482 void CUPnPBrowsingSession::AvtPreviousResponse( |
|
483 const TDesC8& /*aUuid*/, |
|
484 TInt /*aSessionId*/, |
|
485 TInt /*aErr*/, |
|
486 const TDesC8& /*aInstanceId*/) |
|
487 { |
|
488 // No implementation required |
|
489 } |
|
490 |
|
491 // -------------------------------------------------------------------------- |
|
492 // CUPnPBrowsingSession::AvtSetPlayModeResponse |
|
493 // See upnpbrowsingsession.h |
|
494 // -------------------------------------------------------------------------- |
|
495 void CUPnPBrowsingSession::AvtSetPlayModeResponse( |
|
496 const TDesC8& /*aUuid*/, |
|
497 TInt /*aSessionId*/, |
|
498 TInt /*aErr*/, |
|
499 const TDesC8& /*aInstanceId*/, |
|
500 const TDesC8& /*aNewPlayMode*/) |
|
501 { |
|
502 // No implementation required |
|
503 } |
|
504 |
|
505 // -------------------------------------------------------------------------- |
|
506 // CUPnPBrowsingSession::AvtSetRecordModeResponse |
|
507 // See upnpbrowsingsession.h |
|
508 // -------------------------------------------------------------------------- |
|
509 void CUPnPBrowsingSession::AvtSetRecordModeResponse( |
|
510 const TDesC8& /*aUuid*/, |
|
511 TInt /*aSessionId*/, |
|
512 TInt /*aErr*/, |
|
513 const TDesC8& /*aInstanceId*/, |
|
514 const TDesC8& /*aNewRecordQuality*/) |
|
515 { |
|
516 // No implementation required |
|
517 } |
|
518 |
|
519 // -------------------------------------------------------------------------- |
|
520 // CUPnPBrowsingSession::CdsSearchCapabilitiesResponse |
|
521 // See upnpbrowsingsession.h |
|
522 // -------------------------------------------------------------------------- |
|
523 void CUPnPBrowsingSession::CdsSearchCapabilitiesResponse( |
|
524 const TDesC8& /*aUuid*/, |
|
525 TInt aSessionId, |
|
526 TInt aErr, |
|
527 const TDesC8& aSearchCaps) |
|
528 { |
|
529 __LOG1( "CUPnPBrowsingSession::CdsSearchCapabilitiesResponse: %d", |
|
530 aErr ); |
|
531 |
|
532 __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ ); |
|
533 |
|
534 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
535 iIPSessionId = KErrNotFound; |
|
536 //iActionPending = EFalse; |
|
537 |
|
538 if( iActionMessage ) |
|
539 { |
|
540 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
541 EUPnPContentDirectoryError ); |
|
542 |
|
543 if( aErr == KErrNone ) |
|
544 { |
|
545 if( aSearchCaps != KNullDesC8 ) |
|
546 { |
|
547 delete iRespBuf; iRespBuf = NULL; |
|
548 iRespBuf = aSearchCaps.Alloc(); |
|
549 if( iRespBuf ) |
|
550 { |
|
551 TPckg<TInt> resp1( aSearchCaps.Length() ); |
|
552 iActionMessage->Write( 1, resp1 ); |
|
553 } |
|
554 else |
|
555 { |
|
556 TPckg<TInt> resp1( 0 ); |
|
557 iActionMessage->Write( 1, resp1 ); |
|
558 } |
|
559 |
|
560 iActionMessage->Complete( |
|
561 EAVControllerGetSearchCapabilitiesSizeCompleted ); |
|
562 delete iActionMessage; iActionMessage = NULL; |
|
563 } |
|
564 else |
|
565 { |
|
566 TPckg<TInt> resp1( 0 ); |
|
567 iActionMessage->Write( 1, resp1 ); |
|
568 |
|
569 iActionMessage->Complete( |
|
570 EAVControllerGetSearchCapabilitiesSizeCompleted ); |
|
571 delete iActionMessage; iActionMessage = NULL; |
|
572 } |
|
573 } |
|
574 else |
|
575 { |
|
576 iActionMessage->Complete( aErr ); |
|
577 delete iActionMessage; iActionMessage = NULL; |
|
578 } |
|
579 } |
|
580 else |
|
581 { |
|
582 __LOG( "CdsSearchCapabilitiesResponse - no msg" ); |
|
583 } |
|
584 } |
|
585 |
|
586 // -------------------------------------------------------------------------- |
|
587 // CUPnPBrowsingSession::CdsSortCapabilitiesResponse |
|
588 // See upnpbrowsingsession.h |
|
589 // -------------------------------------------------------------------------- |
|
590 void CUPnPBrowsingSession::CdsSortCapabilitiesResponse( |
|
591 const TDesC8& /*aUuid*/, |
|
592 TInt /*aSessionId*/, |
|
593 TInt /*aErr*/, |
|
594 const TDesC8& /*aSortCaps*/) |
|
595 { |
|
596 // No implementation required |
|
597 } |
|
598 |
|
599 // -------------------------------------------------------------------------- |
|
600 // CUPnPBrowsingSession::CdsSystemUpdateIdResponse |
|
601 // See upnpbrowsingsession.h |
|
602 // -------------------------------------------------------------------------- |
|
603 void CUPnPBrowsingSession::CdsSystemUpdateIdResponse( |
|
604 const TDesC8& /*aUuid*/, |
|
605 TInt /*aSessionId*/, |
|
606 TInt /*aErr*/, |
|
607 TInt /*aSystemUpdateId*/) |
|
608 { |
|
609 // No implementation required |
|
610 } |
|
611 |
|
612 // -------------------------------------------------------------------------- |
|
613 // CUPnPBrowsingSession::CdsBrowseResponse |
|
614 // See upnpbrowsingsession.h |
|
615 // -------------------------------------------------------------------------- |
|
616 void CUPnPBrowsingSession::CdsBrowseResponse( |
|
617 const TDesC8& aUuid, |
|
618 TInt aSessionId, |
|
619 TInt aErr, |
|
620 const TDesC8& /*aObjectID*/, |
|
621 const TDesC8& aBrowseFlag, |
|
622 const TDesC8& /*aFilter*/, |
|
623 TInt /*aIndex*/, |
|
624 TInt /*aRequest*/, |
|
625 const TDesC8& /*aSortCriteria*/, |
|
626 const TDesC8& aResult, |
|
627 TInt aReturned, |
|
628 TInt aMatches, |
|
629 const TDesC8& aUpdateID ) |
|
630 { |
|
631 __LOG1( "CUPnPBrowsingSession::CdsBrowseResponse: %d", aErr ); |
|
632 |
|
633 __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ ); |
|
634 |
|
635 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
636 iIPSessionId = KErrNotFound; |
|
637 |
|
638 if( iActionMessage ) |
|
639 { |
|
640 if ( aBrowseFlag.CompareF( KBrowseMetadata ) == 0 && aReturned == 0 |
|
641 && aErr != KErrCouldNotConnect && aErr != KErrHostUnreach ) |
|
642 { |
|
643 aErr = ENoSuchObject; //the file not exist; |
|
644 } |
|
645 |
|
646 if ( aErr != KErrCouldNotConnect && aErr != KErrHostUnreach ) |
|
647 { |
|
648 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
649 EUPnPContentDirectoryError ); |
|
650 __LOG1( "CUPnPBrowsingSession::CdsBrowseResponse:001 %d", aErr ); |
|
651 } |
|
652 |
|
653 if( aErr == KErrNone ) |
|
654 { |
|
655 if( aResult != KNullDesC8 ) |
|
656 { |
|
657 |
|
658 if( iInternalState == ECopyToPhone ) |
|
659 { |
|
660 TRAP( aErr, SendCreateObjectActionL( |
|
661 *iLocalMediaServerUuid, KContainerIdAny, aResult ) ); |
|
662 if( aErr ) |
|
663 { |
|
664 iInternalState = ENone; |
|
665 iActionMessage->Complete( aErr ); |
|
666 delete iActionMessage; iActionMessage = NULL; |
|
667 } |
|
668 } |
|
669 else if( iInternalState == ECopyLocal ) |
|
670 { |
|
671 TRAP( aErr, CheckAndSendCreateObjectActionL( aResult ) ); |
|
672 if( aErr ) |
|
673 { |
|
674 iInternalState = ENone; |
|
675 iActionMessage->Complete( aErr ); |
|
676 delete iActionMessage; iActionMessage = NULL; |
|
677 } |
|
678 } |
|
679 else if( iInternalState == EDestroyObject ) |
|
680 { |
|
681 TRAP( aErr, CheckAndSendDestroyObjectActionL( aResult) ); |
|
682 if( aErr ) |
|
683 { |
|
684 iInternalState = ENone; |
|
685 iActionMessage->Complete( aErr ); |
|
686 delete iActionMessage; iActionMessage = NULL; |
|
687 } |
|
688 } |
|
689 else // Browse |
|
690 { |
|
691 delete iRespBuf; iRespBuf = NULL; |
|
692 delete iRespBuf2; iRespBuf2 = NULL; |
|
693 iRespBuf = aResult.Alloc(); |
|
694 iRespBuf2 = aUpdateID.Alloc(); |
|
695 |
|
696 if( iRespBuf && iRespBuf2 ) |
|
697 { |
|
698 TUpnpAVBrowseRespParams params; |
|
699 TPckg<TUpnpAVBrowseRespParams> resp2( params ); |
|
700 params.iMatches = aReturned ; |
|
701 params.iTotalCount = aMatches; |
|
702 params.iResponseSize = aResult.Length(); |
|
703 params.iUpdateIdSize = aUpdateID.Length(); |
|
704 iActionMessage->Write( 2, resp2 ); |
|
705 iActionMessage->Complete( |
|
706 EAVControllerGetBrowseResponseSizeCompleted ); |
|
707 } |
|
708 else |
|
709 { |
|
710 delete iRespBuf; iRespBuf = NULL; |
|
711 delete iRespBuf2; iRespBuf2 = NULL; |
|
712 iActionMessage->Complete( KErrNoMemory ); |
|
713 } |
|
714 iInternalState = ENone; |
|
715 delete iActionMessage; iActionMessage = NULL; |
|
716 } |
|
717 } |
|
718 else |
|
719 { |
|
720 if( iInternalState == EBrowse ) |
|
721 { |
|
722 TUpnpAVBrowseRespParams params; |
|
723 TPckg<TUpnpAVBrowseRespParams> resp2( params ); |
|
724 params.iMatches = 0; |
|
725 params.iTotalCount = 0; |
|
726 params.iResponseSize = 0; |
|
727 params.iUpdateIdSize = 0; |
|
728 iActionMessage->Write( 2, resp2 ); |
|
729 |
|
730 iInternalState = ENone; |
|
731 iActionMessage->Complete( |
|
732 EAVControllerGetBrowseResponseSizeCompleted ); |
|
733 delete iActionMessage; iActionMessage = NULL; |
|
734 } |
|
735 else |
|
736 { |
|
737 iInternalState = ENone; |
|
738 iActionMessage->Complete( aErr ); |
|
739 delete iActionMessage; iActionMessage = NULL; |
|
740 } |
|
741 } |
|
742 } |
|
743 else |
|
744 { |
|
745 iInternalState = ENone; |
|
746 iActionMessage->Complete( aErr ); |
|
747 delete iActionMessage; iActionMessage = NULL; |
|
748 if ( KErrCouldNotConnect == aErr || KErrHostUnreach == aErr ) |
|
749 { |
|
750 iServer.DeviceDisappearedL( aUuid ); |
|
751 } |
|
752 } |
|
753 } |
|
754 else |
|
755 { |
|
756 __LOG( "CdsBrowseResponse - no msg" ); |
|
757 } |
|
758 |
|
759 } |
|
760 |
|
761 // -------------------------------------------------------------------------- |
|
762 // CUPnPBrowsingSession::CdsSearchResponse |
|
763 // See upnpbrowsingsession.h |
|
764 // -------------------------------------------------------------------------- |
|
765 void CUPnPBrowsingSession::CdsSearchResponse( |
|
766 const TDesC8& /*aUuid*/, |
|
767 TInt aSessionId, |
|
768 TInt aErr, |
|
769 const TDesC8& /*aContainerId*/, |
|
770 const TDesC8& /*aSearchCriteria*/, |
|
771 const TDesC8& /*aFilter*/, |
|
772 TInt /*aIndex*/, |
|
773 TInt /*aRequest*/, |
|
774 const TDesC8& /*aSortCriteria*/, |
|
775 const TDesC8& aResult, |
|
776 TInt aReturned, |
|
777 TInt aMatches, |
|
778 const TDesC8& aUpdateID ) |
|
779 { |
|
780 __LOG1( "CUPnPBrowsingSession::CdsSearchResponse: %d", aErr ); |
|
781 |
|
782 __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ ); |
|
783 |
|
784 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
785 //iActionPending = EFalse; |
|
786 iIPSessionId = KErrNotFound; |
|
787 |
|
788 if( iActionMessage ) |
|
789 { |
|
790 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
791 EUPnPContentDirectoryError ); |
|
792 |
|
793 if( aErr == KErrNone ) |
|
794 { |
|
795 if( aResult != KNullDesC8 ) |
|
796 { |
|
797 delete iRespBuf; iRespBuf = NULL; |
|
798 delete iRespBuf2; iRespBuf2 = NULL; |
|
799 iRespBuf = aResult.Alloc(); |
|
800 iRespBuf2 = aUpdateID.Alloc(); |
|
801 |
|
802 if( iRespBuf && iRespBuf2 ) |
|
803 { |
|
804 TUpnpAVBrowseRespParams params; |
|
805 TPckg<TUpnpAVBrowseRespParams> resp2( params ); |
|
806 params.iMatches = aReturned ; |
|
807 params.iTotalCount = aMatches; |
|
808 params.iResponseSize = aResult.Length(); |
|
809 params.iUpdateIdSize = aUpdateID.Length(); |
|
810 iActionMessage->Write( 2, resp2 ); |
|
811 iActionMessage->Complete( |
|
812 EAVControllerGetSearchResponseSizeCompleted ); |
|
813 } |
|
814 else |
|
815 { |
|
816 delete iRespBuf; iRespBuf = NULL; |
|
817 delete iRespBuf2; iRespBuf2 = NULL; |
|
818 iActionMessage->Complete( KErrNoMemory ); |
|
819 } |
|
820 delete iActionMessage; iActionMessage = NULL; |
|
821 } |
|
822 else |
|
823 { |
|
824 TUpnpAVBrowseRespParams params; |
|
825 TPckg<TUpnpAVBrowseRespParams> resp2( params ); |
|
826 params.iMatches = 0; |
|
827 params.iTotalCount = 0; |
|
828 params.iResponseSize = 0; |
|
829 params.iUpdateIdSize = 0; |
|
830 iActionMessage->Write( 2, resp2 ); |
|
831 |
|
832 iActionMessage->Complete( |
|
833 EAVControllerGetSearchResponseSizeCompleted ); |
|
834 delete iActionMessage; iActionMessage = NULL; |
|
835 } |
|
836 } |
|
837 else |
|
838 { |
|
839 iActionMessage->Complete( aErr ); |
|
840 delete iActionMessage; iActionMessage = NULL; |
|
841 } |
|
842 } |
|
843 else |
|
844 { |
|
845 __LOG( "CdsSearchResponse - no msg" ); |
|
846 } |
|
847 } |
|
848 |
|
849 // -------------------------------------------------------------------------- |
|
850 // CUPnPBrowsingSession::CdsDestroyObjectResponse |
|
851 // See upnpbrowsingsession.h |
|
852 // -------------------------------------------------------------------------- |
|
853 void CUPnPBrowsingSession::CdsDestroyObjectResponse( |
|
854 const TDesC8& /*aUuid*/, |
|
855 TInt aSessionId, |
|
856 TInt aErr, |
|
857 const TDesC8& /*aObjectId*/ ) |
|
858 { |
|
859 __LOG1( "CUPnPBrowsingSession::CdsDestroyObjectResponse: %d", aErr ); |
|
860 |
|
861 __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ ); |
|
862 |
|
863 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
864 iIPSessionId = KErrNotFound; |
|
865 |
|
866 iInternalState = ENone; |
|
867 |
|
868 if( iActionMessage ) |
|
869 { |
|
870 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
871 EUPnPContentDirectoryError ); |
|
872 |
|
873 if( aErr == KErrNone ) |
|
874 { |
|
875 iActionMessage->Complete( EAVControllerDeleteObjectCompleted ); |
|
876 delete iActionMessage; iActionMessage = NULL; |
|
877 } |
|
878 else |
|
879 { |
|
880 iActionMessage->Complete( aErr ); |
|
881 delete iActionMessage; iActionMessage = NULL; |
|
882 } |
|
883 } |
|
884 else |
|
885 { |
|
886 __LOG( "CdsDestroyObjectResponse - no msg" ); |
|
887 } |
|
888 } |
|
889 |
|
890 // -------------------------------------------------------------------------- |
|
891 // CUPnPBrowsingSession::CdsUpdateObjectResponse |
|
892 // See upnpbrowsingsession.h |
|
893 // -------------------------------------------------------------------------- |
|
894 void CUPnPBrowsingSession::CdsUpdateObjectResponse( |
|
895 const TDesC8& /*aUuid*/, |
|
896 TInt /*aSessionId*/, |
|
897 TInt /*aErr*/, |
|
898 const TDesC8& /*aObjectId*/, |
|
899 const TDesC8& /*aCurrentTagValue*/, |
|
900 const TDesC8& /*aNewTagValue*/ ) |
|
901 { |
|
902 // No implementation required |
|
903 } |
|
904 |
|
905 // -------------------------------------------------------------------------- |
|
906 // CUPnPBrowsingSession::CdsImportResponse |
|
907 // See upnpbrowsingsession.h |
|
908 // -------------------------------------------------------------------------- |
|
909 void CUPnPBrowsingSession::CdsImportResponse( |
|
910 const TDesC8& /*aUuid*/, |
|
911 TInt aSessionId, |
|
912 TInt aErr, |
|
913 const TDesC8& /*aSourceURI*/, |
|
914 const TDesC8& /*aDestinationURI*/, |
|
915 const TDesC8& aTransferId ) |
|
916 { |
|
917 __LOG1( "CUPnPBrowsingSession::CdsImportResponse: %d", aErr ); |
|
918 |
|
919 __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ ); |
|
920 |
|
921 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
922 iIPSessionId = KErrNotFound; |
|
923 |
|
924 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
925 EUPnPContentDirectoryError ); |
|
926 |
|
927 if( aErr == KErrNone ) |
|
928 { |
|
929 |
|
930 TLex8 lex( aTransferId ); |
|
931 aErr = lex.Val( iTransferId ); |
|
932 |
|
933 CopyFinished( aErr, EFalse ); |
|
934 } |
|
935 else |
|
936 { |
|
937 CopyFinished( aErr, EFalse ); |
|
938 } |
|
939 } |
|
940 |
|
941 // -------------------------------------------------------------------------- |
|
942 // CUPnPBrowsingSession::CdsExportResponse |
|
943 // See upnpbrowsingsession.h |
|
944 // -------------------------------------------------------------------------- |
|
945 void CUPnPBrowsingSession::CdsExportResponse( |
|
946 const TDesC8& /*aUuid*/, |
|
947 TInt aSessionId, |
|
948 TInt aErr, |
|
949 const TDesC8& /*aSourceURI*/, |
|
950 const TDesC8& /*aDestinationURI*/, |
|
951 const TDesC8& aTransferId ) |
|
952 { |
|
953 __LOG1( "CUPnPBrowsingSession::CdsExportResponse: %d", aErr ); |
|
954 |
|
955 __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ ); |
|
956 |
|
957 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
958 iIPSessionId = KErrNotFound; |
|
959 |
|
960 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
961 EUPnPContentDirectoryError ); |
|
962 |
|
963 if( aErr == KErrNone ) |
|
964 { |
|
965 TLex8 lex( aTransferId ); |
|
966 aErr = lex.Val( iTransferId ); |
|
967 |
|
968 CopyFinished( aErr, EFalse ); |
|
969 } |
|
970 else |
|
971 { |
|
972 |
|
973 CopyFinished( aErr, EFalse ); |
|
974 } |
|
975 } |
|
976 |
|
977 // -------------------------------------------------------------------------- |
|
978 // CUPnPBrowsingSession::CdsStopTransferResponse |
|
979 // See upnpbrowsingsession.h |
|
980 // -------------------------------------------------------------------------- |
|
981 void CUPnPBrowsingSession::CdsStopTransferResponse( |
|
982 const TDesC8& /*aUuid*/, |
|
983 TInt /*aSessionId*/, |
|
984 TInt /*aErr*/, |
|
985 const TDesC8& /*aTransferId*/ ) |
|
986 { |
|
987 // No implementation required |
|
988 } |
|
989 |
|
990 // -------------------------------------------------------------------------- |
|
991 // CUPnPBrowsingSession::CdsCTransferProgressResponse |
|
992 // See upnpbrowsingsession.h |
|
993 // -------------------------------------------------------------------------- |
|
994 void CUPnPBrowsingSession::CdsCTransferProgressResponse( |
|
995 const TDesC8& /*aUuid*/, |
|
996 TInt /*aSessionId*/, |
|
997 TInt /*aErr*/, |
|
998 const TDesC8& /*aTransferId*/, |
|
999 const TDesC8& /*aTransferStatus*/, |
|
1000 const TDesC8& /*aTransferLength*/, |
|
1001 const TDesC8& /*aTransferTotal*/ ) |
|
1002 { |
|
1003 // No implementation required |
|
1004 } |
|
1005 |
|
1006 // -------------------------------------------------------------------------- |
|
1007 // CUPnPBrowsingSession::CdsDeleteResourceResponse |
|
1008 // See upnpbrowsingsession.h |
|
1009 // -------------------------------------------------------------------------- |
|
1010 void CUPnPBrowsingSession::CdsDeleteResourceResponse( |
|
1011 const TDesC8& /*aUuid*/, |
|
1012 TInt /*aSessionId*/, |
|
1013 TInt /*aErr*/, |
|
1014 const TDesC8& /*aResourceUri*/ ) |
|
1015 { |
|
1016 // No implementation required |
|
1017 } |
|
1018 |
|
1019 // -------------------------------------------------------------------------- |
|
1020 // CUPnPBrowsingSession::CdsCreateReferenceResponse |
|
1021 // See upnpbrowsingsession.h |
|
1022 // -------------------------------------------------------------------------- |
|
1023 void CUPnPBrowsingSession::CdsCreateReferenceResponse( |
|
1024 const TDesC8& /*aUuid*/, |
|
1025 TInt /*aSessionId*/, |
|
1026 TInt /*aErr*/, |
|
1027 const TDesC8& /*aContainerId*/, |
|
1028 const TDesC8& /*aObjectId*/, |
|
1029 const TDesC8& /*aNewId*/ ) |
|
1030 { |
|
1031 // No implementation required |
|
1032 } |
|
1033 |
|
1034 // -------------------------------------------------------------------------- |
|
1035 // CUPnPBrowsingSession::CdsCreateObjectResponse |
|
1036 // See upnpbrowsingsession.h |
|
1037 // -------------------------------------------------------------------------- |
|
1038 void CUPnPBrowsingSession::CdsCreateObjectResponse( |
|
1039 const TDesC8& /*aUuid*/, |
|
1040 TInt aSessionId, |
|
1041 TInt aErr, |
|
1042 const TDesC8& /*aContainerID*/, |
|
1043 const TDesC8& /*aElements*/, |
|
1044 const TDesC8& aObjectID, |
|
1045 const TDesC8& aResult ) |
|
1046 { |
|
1047 __LOG1( "CUPnPBrowsingSession::CdsCreateObjectResponse: %d" , aErr ); |
|
1048 |
|
1049 __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ ); |
|
1050 |
|
1051 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
1052 //iActionPending = EFalse; |
|
1053 iIPSessionId = KErrNotFound; |
|
1054 |
|
1055 aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr, |
|
1056 EUPnPContentDirectoryError ); |
|
1057 |
|
1058 if( aErr == KErrNone ) |
|
1059 { |
|
1060 if( iInternalState == ECopyLocal || |
|
1061 iInternalState == ECopyToPhone ) |
|
1062 { |
|
1063 delete iImportURI; iImportURI = NULL; |
|
1064 TRAP( aErr, iImportURI = ParseCreateObjectResponseL( aResult ) ); |
|
1065 if( aErr == KErrNone ) |
|
1066 { |
|
1067 if( iSourceURI ) |
|
1068 { |
|
1069 if( iInternalState == ECopyLocal ) |
|
1070 { |
|
1071 // Export from the local Media Server to the |
|
1072 // Remote Media Server |
|
1073 delete iItemId; |
|
1074 iItemId = aObjectID.Alloc(); // Null ok at this point |
|
1075 |
|
1076 TRAP( aErr, SendExportActionL() ); |
|
1077 if( aErr ) |
|
1078 { |
|
1079 CopyFinished( aErr, EFalse ); |
|
1080 } |
|
1081 } |
|
1082 else // iInternalState == ECopyToPhone |
|
1083 { |
|
1084 TRAP( aErr, SendImportActionL() ); |
|
1085 if( aErr ) |
|
1086 { |
|
1087 CopyFinished( aErr, EFalse ); |
|
1088 } |
|
1089 } |
|
1090 } |
|
1091 else |
|
1092 { |
|
1093 CopyFinished( KErrGeneral, EFalse ); |
|
1094 } |
|
1095 } |
|
1096 else |
|
1097 { |
|
1098 CopyFinished( aErr, EFalse ); |
|
1099 } |
|
1100 } |
|
1101 else // Create container |
|
1102 { |
|
1103 if( iActionMessage ) |
|
1104 { |
|
1105 HBufC8* objectID = HBufC8::New( aObjectID.Length() ); |
|
1106 if( objectID ) |
|
1107 { |
|
1108 objectID->Des().Copy( aObjectID ); |
|
1109 iActionMessage->Write( 1, *objectID ); |
|
1110 iActionMessage->Complete( |
|
1111 EAVControllerCreateContainerCompleted ); |
|
1112 delete objectID; |
|
1113 } |
|
1114 else |
|
1115 { |
|
1116 iActionMessage->Write( 1, KNullDesC8 ); |
|
1117 iActionMessage->Complete( KErrNoMemory ); |
|
1118 } |
|
1119 delete iActionMessage; iActionMessage = NULL; |
|
1120 } |
|
1121 iInternalState = ENone; |
|
1122 } |
|
1123 } |
|
1124 else |
|
1125 { |
|
1126 if( iInternalState == ECopyLocal || |
|
1127 iInternalState == ECopyToPhone ) |
|
1128 { |
|
1129 CopyFinished( aErr, EFalse ); |
|
1130 } |
|
1131 else |
|
1132 { |
|
1133 // Create container failed |
|
1134 iInternalState = ENone; |
|
1135 iActionMessage->Complete( aErr ); |
|
1136 delete iActionMessage; iActionMessage = NULL; |
|
1137 } |
|
1138 } |
|
1139 } |
|
1140 |
|
1141 // -------------------------------------------------------------------------- |
|
1142 // CUPnPBrowsingSession::CmProtocolInfoResponse |
|
1143 // See upnpbrowsingsession.h |
|
1144 // -------------------------------------------------------------------------- |
|
1145 void CUPnPBrowsingSession::CmProtocolInfoResponse( |
|
1146 const TDesC8& /*aUuid*/, |
|
1147 TInt /*aSessionId*/, |
|
1148 TInt /*aErr*/, |
|
1149 const TDesC8& /*aSource*/, |
|
1150 const TDesC8& /*aSink*/ ) |
|
1151 { |
|
1152 // No implementation required |
|
1153 } |
|
1154 |
|
1155 // -------------------------------------------------------------------------- |
|
1156 // CUPnPBrowsingSession::CmPrepareResponse |
|
1157 // See upnpbrowsingsession.h |
|
1158 // -------------------------------------------------------------------------- |
|
1159 void CUPnPBrowsingSession::CmPrepareResponse( |
|
1160 const TDesC8& /*aUuid*/, |
|
1161 TInt /*aSessionId*/, |
|
1162 TInt /*aErr*/, |
|
1163 const TDesC8& /*aRemoteProtocolInfo*/, |
|
1164 const TDesC8& /*aPeerConnectionManager*/, |
|
1165 const TDesC8& /*aPeerConnectionId*/, |
|
1166 const TDesC8& /*aDirection*/, |
|
1167 TInt /*aConnection*/, |
|
1168 TInt /*aTransport*/, |
|
1169 TInt /*aRsc*/ ) |
|
1170 { |
|
1171 // No implementation required |
|
1172 } |
|
1173 |
|
1174 // -------------------------------------------------------------------------- |
|
1175 // CUPnPBrowsingSession::CmComplete |
|
1176 // See upnpbrowsingsession.h |
|
1177 // -------------------------------------------------------------------------- |
|
1178 void CUPnPBrowsingSession::CmComplete( |
|
1179 const TDesC8& /*aUuid*/, |
|
1180 TInt /*aSessionId*/, |
|
1181 TInt /*aErr*/, |
|
1182 TInt /*aConnection*/ ) |
|
1183 { |
|
1184 // No implementation required |
|
1185 } |
|
1186 |
|
1187 // -------------------------------------------------------------------------- |
|
1188 // CUPnPBrowsingSession::CmCurrentConnections |
|
1189 // See upnpbrowsingsession.h |
|
1190 // -------------------------------------------------------------------------- |
|
1191 void CUPnPBrowsingSession::CmCurrentConnections( |
|
1192 const TDesC8& /*aUuid*/, |
|
1193 TInt /*aSessionId*/, |
|
1194 TInt /*aErr*/, |
|
1195 const TDesC8& /*aConnections*/) |
|
1196 { |
|
1197 // No implementation required |
|
1198 } |
|
1199 |
|
1200 // -------------------------------------------------------------------------- |
|
1201 // CUPnPBrowsingSession::CmCurrentInfo |
|
1202 // See upnpbrowsingsession.h |
|
1203 // -------------------------------------------------------------------------- |
|
1204 void CUPnPBrowsingSession::CmCurrentInfo( |
|
1205 const TDesC8& /*aUuid*/, |
|
1206 TInt /*aSessionId*/, |
|
1207 TInt /*aErr*/, |
|
1208 TInt /*rscId*/, |
|
1209 TInt /*transportId*/, |
|
1210 const TDesC8& /*aProtocolInfo*/, |
|
1211 const TDesC8& /*aPeerConnectionManager*/, |
|
1212 TInt /*peerId*/, |
|
1213 const TDesC8& /*aDirection*/, |
|
1214 const TDesC8& /*aStatus*/ ) |
|
1215 { |
|
1216 // No implementation required |
|
1217 } |
|
1218 |
|
1219 // -------------------------------------------------------------------------- |
|
1220 // CUPnPBrowsingSession::CdsUpdateEvent |
|
1221 // See upnpbrowsingsession.h |
|
1222 // -------------------------------------------------------------------------- |
|
1223 void CUPnPBrowsingSession::CdsUpdateEvent( |
|
1224 const TDesC8& /*aUuid*/, |
|
1225 TInt /*aSystemUpdateId*/ |
|
1226 ) |
|
1227 { |
|
1228 // No implementation required |
|
1229 } |
|
1230 |
|
1231 // -------------------------------------------------------------------------- |
|
1232 // CUPnPBrowsingSession::CdsContainerEvent |
|
1233 // See upnpbrowsingsession.h |
|
1234 // -------------------------------------------------------------------------- |
|
1235 void CUPnPBrowsingSession::CdsContainerEvent( |
|
1236 const TDesC8& /*aUuid*/, |
|
1237 const TDesC8& /*aConteinerIds*/ |
|
1238 ) |
|
1239 { |
|
1240 // No implementation required |
|
1241 } |
|
1242 |
|
1243 // -------------------------------------------------------------------------- |
|
1244 // CUPnPBrowsingSession::CdsTransferEvent |
|
1245 // See upnpbrowsingsession.h |
|
1246 // -------------------------------------------------------------------------- |
|
1247 void CUPnPBrowsingSession::CdsTransferEvent( |
|
1248 const TDesC8& /*aUuid*/, |
|
1249 const TDesC8& /*aTransferIds*/ |
|
1250 ) |
|
1251 { |
|
1252 // No implementation required |
|
1253 } |
|
1254 |
|
1255 // -------------------------------------------------------------------------- |
|
1256 // CUPnPBrowsingSession::RcLastChangeEvent |
|
1257 // See upnpbrowsingsession.h |
|
1258 // -------------------------------------------------------------------------- |
|
1259 void CUPnPBrowsingSession::RcLastChangeEvent( |
|
1260 const TDesC8& /*aUuid*/, |
|
1261 const TDesC8& /*aLastChange*/ |
|
1262 ) |
|
1263 { |
|
1264 // No implementation required |
|
1265 } |
|
1266 |
|
1267 // -------------------------------------------------------------------------- |
|
1268 // CUPnPBrowsingSession::AvtLastChangeEvent |
|
1269 // See upnpbrowsingsession.h |
|
1270 // -------------------------------------------------------------------------- |
|
1271 void CUPnPBrowsingSession::AvtLastChangeEvent( |
|
1272 const TDesC8& /*aUuid*/, |
|
1273 const TDesC8& /*aLastChange*/ |
|
1274 ) |
|
1275 { |
|
1276 // No implementation required |
|
1277 } |
|
1278 |
|
1279 // -------------------------------------------------------------------------- |
|
1280 // CUPnPBrowsingSession::CmSourceEvent |
|
1281 // See upnpbrowsingsession.h |
|
1282 // -------------------------------------------------------------------------- |
|
1283 void CUPnPBrowsingSession::CmSourceEvent( |
|
1284 const TDesC8& /*aUuid*/, |
|
1285 const TDesC8& /*aSource*/ |
|
1286 ) |
|
1287 { |
|
1288 // No implementation required |
|
1289 } |
|
1290 |
|
1291 // -------------------------------------------------------------------------- |
|
1292 // CUPnPBrowsingSession::CmSinkEvent |
|
1293 // See upnpbrowsingsession.h |
|
1294 // -------------------------------------------------------------------------- |
|
1295 void CUPnPBrowsingSession::CmSinkEvent( |
|
1296 const TDesC8& /*aUuid*/, |
|
1297 const TDesC8& /*aSink*/ |
|
1298 ) |
|
1299 { |
|
1300 // No implementation required |
|
1301 } |
|
1302 |
|
1303 // -------------------------------------------------------------------------- |
|
1304 // CUPnPBrowsingSession::CmConnectionsEvent |
|
1305 // See upnpbrowsingsession.h |
|
1306 // -------------------------------------------------------------------------- |
|
1307 void CUPnPBrowsingSession::CmConnectionsEvent( |
|
1308 const TDesC8& /*aUuid*/, |
|
1309 const TDesC8& /*aConnections*/ |
|
1310 ) |
|
1311 { |
|
1312 // No implementation required |
|
1313 } |
|
1314 |
|
1315 // -------------------------------------------------------------------------- |
|
1316 // CUPnPBrowsingSession::HttpResponseL |
|
1317 // See upnpbrowsingsession.h |
|
1318 // -------------------------------------------------------------------------- |
|
1319 void CUPnPBrowsingSession::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ ) |
|
1320 { |
|
1321 // No implementation required |
|
1322 } |
|
1323 |
|
1324 // -------------------------------------------------------------------------- |
|
1325 // CUPnPBrowsingSession::DeviceDiscoveredL |
|
1326 // See upnpbrowsingsession.h |
|
1327 // -------------------------------------------------------------------------- |
|
1328 void CUPnPBrowsingSession::DeviceDiscoveredL( CUpnpDevice* /*aDevice*/ ) |
|
1329 { |
|
1330 // No implementation required |
|
1331 } |
|
1332 |
|
1333 // -------------------------------------------------------------------------- |
|
1334 // CUPnPBrowsingSession::DeviceDisappearedL |
|
1335 // See upnpbrowsingsession.h |
|
1336 // -------------------------------------------------------------------------- |
|
1337 void CUPnPBrowsingSession::DeviceDisappearedL( CUpnpDevice* /*aDevice*/ ) |
|
1338 { |
|
1339 // No implementation required |
|
1340 } |
|
1341 |
|
1342 // -------------------------------------------------------------------------- |
|
1343 // CUPnPBrowsingSession::FileTransferEvent |
|
1344 // See upnpbrowsingsession.h |
|
1345 // -------------------------------------------------------------------------- |
|
1346 void CUPnPBrowsingSession::FileTransferEvent( |
|
1347 CUpnpFileTransferEvent *aEvent ) |
|
1348 { |
|
1349 __ASSERTD( aEvent, __FILE__, __LINE__ ); |
|
1350 |
|
1351 __LOG1( "CUPnPBrowsingSession::FileTransferEvent, %d", |
|
1352 aEvent->ErrorCode() ); |
|
1353 |
|
1354 TInt err = UPnPAVErrorHandler::ConvertToSymbianErrorCode( |
|
1355 aEvent->ErrorCode(), EUPnPContentDirectoryError ); |
|
1356 |
|
1357 if( aEvent->TransferId() == iTransferId ) |
|
1358 { |
|
1359 iTransferId = KErrNotFound; |
|
1360 if( iInternalState == ECopyLocal ) |
|
1361 { |
|
1362 if( iActionMessage ) |
|
1363 { |
|
1364 CopyFinished( err, ETrue ); |
|
1365 } |
|
1366 else |
|
1367 { |
|
1368 // Msg not received, set the flag instead |
|
1369 iAsyncErr = err; |
|
1370 iTransferEventReceived = ETrue; |
|
1371 } |
|
1372 } |
|
1373 else if( iInternalState == ECopyToPhone ) |
|
1374 { |
|
1375 TRAPD( err, HandleCopyToPhoneEventL( *aEvent, err ) ); |
|
1376 if ( err ) |
|
1377 { |
|
1378 __LOG1( "CUPnPBrowsingSession::FileTransferEvent, %d", |
|
1379 err ); |
|
1380 } |
|
1381 } |
|
1382 } |
|
1383 |
|
1384 delete aEvent; |
|
1385 } |
|
1386 |
|
1387 // -------------------------------------------------------------------------- |
|
1388 // CUPnPBrowsingSession::HandleCopyToPhoneEventL |
|
1389 // Handle CopyToPhoneEvent,and all leave function will move |
|
1390 // to this function |
|
1391 // -------------------------------------------------------------------------- |
|
1392 void CUPnPBrowsingSession::HandleCopyToPhoneEventL( |
|
1393 CUpnpFileTransferEvent& aEvent, |
|
1394 TInt aError ) |
|
1395 { |
|
1396 HBufC8* filepath = HBufC8::NewL( KMaxPath ); |
|
1397 CleanupStack::PushL( filepath ); |
|
1398 |
|
1399 HBufC8* eventpath = CnvUtfConverter::ConvertFromUnicodeToUtf8L( |
|
1400 aEvent.FilePath() ); |
|
1401 filepath->Des().Copy( *eventpath ); |
|
1402 delete eventpath; |
|
1403 eventpath = NULL; |
|
1404 |
|
1405 if ( iActionMessage ) |
|
1406 { |
|
1407 TInt res = iActionMessage->Write( 1, *filepath ); |
|
1408 if ( res ) |
|
1409 { |
|
1410 __LOG1( "CUPnPBrowsingSession::HandleCopyToPhoneEventL, %d", |
|
1411 res ); |
|
1412 } |
|
1413 // clean up |
|
1414 CleanupStack::PopAndDestroy( filepath ); |
|
1415 } |
|
1416 else |
|
1417 { |
|
1418 iFilePath = filepath; |
|
1419 |
|
1420 // clean up |
|
1421 CleanupStack::Pop( filepath ); |
|
1422 } |
|
1423 |
|
1424 if ( iActionMessage ) |
|
1425 { |
|
1426 CopyFinished( aError, ETrue ); |
|
1427 } |
|
1428 else |
|
1429 { |
|
1430 // Msg not received yet, set the flag instead |
|
1431 iAsyncErr = aError; |
|
1432 iTransferEventReceived = ETrue; |
|
1433 } |
|
1434 |
|
1435 } |
|
1436 |
|
1437 // -------------------------------------------------------------------------- |
|
1438 // CUPnPBrowsingSession::NotifierError |
|
1439 // See upnpbrowsingsession.h |
|
1440 // -------------------------------------------------------------------------- |
|
1441 void CUPnPBrowsingSession::NotifierError( TInt aError ) |
|
1442 { |
|
1443 __LOG( "CUPnPBrowsingSession::NotifierError" ); |
|
1444 |
|
1445 if( iActionMessage ) |
|
1446 { |
|
1447 if( iInternalState == ECopyLocal || |
|
1448 iInternalState == ECopyToPhone ) |
|
1449 { |
|
1450 CopyFinished( aError, ETrue ); |
|
1451 } |
|
1452 } |
|
1453 else |
|
1454 { |
|
1455 // Msg not received yet, set the flag instead |
|
1456 iAsyncErr = aError; |
|
1457 iTransferEventReceived = ETrue; |
|
1458 } |
|
1459 } |
|
1460 |
|
1461 // -------------------------------------------------------------------------- |
|
1462 // CUPnPBrowsingSession::DeviceDisappearedL |
|
1463 // See upnpbrowsingsession.h |
|
1464 // -------------------------------------------------------------------------- |
|
1465 void CUPnPBrowsingSession::DeviceDisappearedL( |
|
1466 CUpnpAVDeviceExtended& aDevice ) |
|
1467 { |
|
1468 __LOG( "CUPnPBrowsingSession::DeviceDisappearedL" ); |
|
1469 |
|
1470 if( aDevice.Local() ) |
|
1471 { |
|
1472 delete iLocalMediaServerUuid; iLocalMediaServerUuid = NULL; |
|
1473 } |
|
1474 else if( iDeviceMessage ) // Target device |
|
1475 { |
|
1476 iDeviceMessage->Complete( KErrNone ); |
|
1477 delete iDeviceMessage; iDeviceMessage = NULL; |
|
1478 } |
|
1479 } |
|
1480 |
|
1481 // -------------------------------------------------------------------------- |
|
1482 // CUPnPBrowsingSession::SetLocalMSUuidL |
|
1483 // See upnpbrowsingsession.h |
|
1484 // -------------------------------------------------------------------------- |
|
1485 void CUPnPBrowsingSession::SetLocalMSUuidL( const TDesC8& aUuid ) |
|
1486 { |
|
1487 HBufC8* tmp = aUuid.AllocL(); |
|
1488 delete iLocalMediaServerUuid; |
|
1489 iLocalMediaServerUuid = tmp; |
|
1490 } |
|
1491 |
|
1492 // -------------------------------------------------------------------------- |
|
1493 // CUPnPBrowsingSession::SessionId |
|
1494 // See upnpbrowsingsession.h |
|
1495 // -------------------------------------------------------------------------- |
|
1496 TInt CUPnPBrowsingSession::SessionId() const |
|
1497 { |
|
1498 return iSessionId; |
|
1499 } |
|
1500 |
|
1501 // -------------------------------------------------------------------------- |
|
1502 // CUPnPBrowsingSession::Uuid |
|
1503 // See upnpbrowsingsession.h |
|
1504 // -------------------------------------------------------------------------- |
|
1505 const TDesC8& CUPnPBrowsingSession::Uuid() const |
|
1506 { |
|
1507 if( iDevice ) |
|
1508 { |
|
1509 return iDevice->Uuid(); |
|
1510 } |
|
1511 else |
|
1512 { |
|
1513 return KNullDesC8; |
|
1514 } |
|
1515 } |
|
1516 |
|
1517 // -------------------------------------------------------------------------- |
|
1518 // CUPnPBrowsingSession::GetBrowseResponseSizeL |
|
1519 // See upnpbrowsingsession.h |
|
1520 // -------------------------------------------------------------------------- |
|
1521 void CUPnPBrowsingSession::GetBrowseResponseSizeL( |
|
1522 const RMessage2& aMessage ) |
|
1523 { |
|
1524 __LOG( "CUPnPBrowsingSession::GetBrowseResponseSizeL" ); |
|
1525 |
|
1526 __ASSERTD( !iActionMessage, __FILE__, __LINE__ ); |
|
1527 |
|
1528 ResetL(); |
|
1529 |
|
1530 CUpnpAVBrowseRequest* tmpRequest = CUpnpAVBrowseRequest::NewLC(); |
|
1531 |
|
1532 ReadBrowseReqFromMessageL( aMessage, 1, tmpRequest ); |
|
1533 |
|
1534 if( tmpRequest->BrowseFlag() == MUPnPAVBrowsingSession::EDirectChildren ) |
|
1535 { |
|
1536 iIPSessionId = iServer.ControlPoint().CdsBrowseActionL( |
|
1537 iDevice->Uuid(), |
|
1538 tmpRequest->Id(), |
|
1539 KDirectChildren, |
|
1540 tmpRequest->Filter(), |
|
1541 tmpRequest->StartIndex(), |
|
1542 tmpRequest->RequestedCount(), |
|
1543 tmpRequest->SortCriteria() ); |
|
1544 } |
|
1545 else |
|
1546 { |
|
1547 iIPSessionId = iServer.ControlPoint().CdsBrowseActionL( |
|
1548 iDevice->Uuid(), |
|
1549 tmpRequest->Id(), |
|
1550 KMetaData, |
|
1551 tmpRequest->Filter(), |
|
1552 tmpRequest->StartIndex(), |
|
1553 tmpRequest->RequestedCount(), |
|
1554 tmpRequest->SortCriteria() ); |
|
1555 } |
|
1556 |
|
1557 |
|
1558 CleanupStack::PopAndDestroy( tmpRequest ); |
|
1559 |
|
1560 if( iIPSessionId > 0 ) |
|
1561 { |
|
1562 // Register |
|
1563 iInternalState = EBrowse; |
|
1564 iServer.Dispatcher().RegisterL( iIPSessionId, *this ); |
|
1565 } |
|
1566 else |
|
1567 { |
|
1568 User::Leave( iIPSessionId ); |
|
1569 } |
|
1570 |
|
1571 iActionMessage = new (ELeave) RMessage2( aMessage ); |
|
1572 } |
|
1573 |
|
1574 |
|
1575 // -------------------------------------------------------------------------- |
|
1576 // CUPnPBrowsingSession::CancelGetBrowseResponseSizeL |
|
1577 // See upnpbrowsingsession.h |
|
1578 // -------------------------------------------------------------------------- |
|
1579 void CUPnPBrowsingSession::CancelGetBrowseResponseSizeL() |
|
1580 { |
|
1581 __LOG( "CUPnPBrowsingSession::CancelGetBrowseResponseSizeL" ); |
|
1582 |
|
1583 if( iActionMessage ) |
|
1584 { |
|
1585 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
1586 iActionMessage->Complete( KErrCancel ); |
|
1587 delete iActionMessage; iActionMessage = NULL; |
|
1588 } |
|
1589 } |
|
1590 |
|
1591 |
|
1592 // -------------------------------------------------------------------------- |
|
1593 // CUPnPBrowsingSession::GetBrowseResponseL |
|
1594 // See upnpbrowsingsession.h |
|
1595 // -------------------------------------------------------------------------- |
|
1596 void CUPnPBrowsingSession::GetBrowseResponseL( const RMessage2& aMessage ) |
|
1597 { |
|
1598 __LOG( "CUPnPBrowsingSession::GetBrowseResponseL" ); |
|
1599 |
|
1600 __ASSERTD( !iActionMessage, __FILE__, __LINE__ ); |
|
1601 |
|
1602 iIPSessionId = KErrNotFound; |
|
1603 if( iRespBuf && iRespBuf2 ) |
|
1604 { |
|
1605 aMessage.WriteL( 1, *iRespBuf ); |
|
1606 aMessage.WriteL( 2, *iRespBuf2 ); |
|
1607 delete iRespBuf; iRespBuf = NULL; |
|
1608 delete iRespBuf2; iRespBuf2 = NULL; |
|
1609 aMessage.Complete( EAVControllerGetBrowseResponseCompleted ); |
|
1610 } |
|
1611 else |
|
1612 { |
|
1613 //Memory allocaton failed |
|
1614 delete iRespBuf; iRespBuf = NULL; |
|
1615 delete iRespBuf2; iRespBuf2 = NULL; |
|
1616 User::Leave( KErrNoMemory ); |
|
1617 } |
|
1618 } |
|
1619 |
|
1620 // -------------------------------------------------------------------------- |
|
1621 // CUPnPBrowsingSession::GetSearchResponseSizeL |
|
1622 // See upnpbrowsingsession.h |
|
1623 // -------------------------------------------------------------------------- |
|
1624 void CUPnPBrowsingSession::GetSearchResponseSizeL( |
|
1625 const RMessage2& aMessage ) |
|
1626 { |
|
1627 __LOG( "CUPnPBrowsingSession::GetSearchResponseSizeL" ); |
|
1628 |
|
1629 __ASSERTD( !iActionMessage, __FILE__, __LINE__ ); |
|
1630 |
|
1631 ResetL(); |
|
1632 |
|
1633 |
|
1634 CUpnpAVBrowseRequest* tmpRequest = CUpnpAVBrowseRequest::NewLC(); |
|
1635 |
|
1636 ReadBrowseReqFromMessageL( aMessage, 1, tmpRequest ); |
|
1637 |
|
1638 iIPSessionId = iServer.ControlPoint().CdsSearchActionL( |
|
1639 iDevice->Uuid(), |
|
1640 tmpRequest->Id(), |
|
1641 tmpRequest->SearchCriteria(), |
|
1642 tmpRequest->Filter(), |
|
1643 tmpRequest->StartIndex(), |
|
1644 tmpRequest->RequestedCount(), |
|
1645 tmpRequest->SortCriteria() ); |
|
1646 |
|
1647 CleanupStack::PopAndDestroy( tmpRequest ); |
|
1648 |
|
1649 if( iIPSessionId > 0 ) |
|
1650 { |
|
1651 // Register |
|
1652 iServer.Dispatcher().RegisterL( iIPSessionId, *this ); |
|
1653 } |
|
1654 else |
|
1655 { |
|
1656 User::Leave( iIPSessionId ); |
|
1657 } |
|
1658 iActionMessage = new (ELeave) RMessage2( aMessage ); |
|
1659 } |
|
1660 |
|
1661 // -------------------------------------------------------------------------- |
|
1662 // CUPnPBrowsingSession::CancelGetSearchResponseSizeL |
|
1663 // See upnpbrowsingsession.h |
|
1664 // -------------------------------------------------------------------------- |
|
1665 void CUPnPBrowsingSession::CancelGetSearchResponseSizeL() |
|
1666 { |
|
1667 __LOG( "CUPnPBrowsingSession::CancelGetSearchResponseSizeL" ); |
|
1668 |
|
1669 if( iActionMessage ) |
|
1670 { |
|
1671 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
1672 iActionMessage->Complete( KErrCancel ); |
|
1673 delete iActionMessage; iActionMessage = NULL; |
|
1674 } |
|
1675 |
|
1676 } |
|
1677 |
|
1678 // -------------------------------------------------------------------------- |
|
1679 // CUPnPBrowsingSession::GetSearchResponseL |
|
1680 // See upnpbrowsingsession.h |
|
1681 // -------------------------------------------------------------------------- |
|
1682 void CUPnPBrowsingSession::GetSearchResponseL( const RMessage2& aMessage ) |
|
1683 { |
|
1684 __LOG( "CUPnPBrowsingSession::GetSearchResponseL" ); |
|
1685 |
|
1686 __ASSERTD( !iActionMessage, __FILE__, __LINE__ ); |
|
1687 |
|
1688 iIPSessionId = KErrNotFound; |
|
1689 if( iRespBuf && iRespBuf2 ) |
|
1690 { |
|
1691 aMessage.WriteL( 1, *iRespBuf ); |
|
1692 aMessage.WriteL( 2, *iRespBuf2 ); |
|
1693 delete iRespBuf; iRespBuf = NULL; |
|
1694 delete iRespBuf2; iRespBuf2 = NULL; |
|
1695 aMessage.Complete( EAVControllerGetSearchResponseCompleted ); |
|
1696 } |
|
1697 else |
|
1698 { |
|
1699 //Memory allocaton failed |
|
1700 delete iRespBuf; iRespBuf = NULL; |
|
1701 delete iRespBuf2; iRespBuf2 = NULL; |
|
1702 User::Leave( KErrNoMemory ); |
|
1703 } |
|
1704 } |
|
1705 |
|
1706 // -------------------------------------------------------------------------- |
|
1707 // CUPnPBrowsingSession::GetSearchCapabitiesSizeL |
|
1708 // See upnpbrowsingsession.h |
|
1709 // -------------------------------------------------------------------------- |
|
1710 void CUPnPBrowsingSession::GetSearchCapabitiesSizeL( |
|
1711 const RMessage2& aMessage ) |
|
1712 { |
|
1713 __LOG( "CUPnPBrowsingSession::GetSearchCapabitiesSizeL" ); |
|
1714 |
|
1715 __ASSERTD( !iActionMessage, __FILE__, __LINE__ ); |
|
1716 |
|
1717 ResetL(); |
|
1718 |
|
1719 iIPSessionId = iServer.ControlPoint().CdsSearchCapabilitiesActionL( |
|
1720 iDevice->Uuid() ); |
|
1721 |
|
1722 if( iIPSessionId > 0 ) |
|
1723 { |
|
1724 // Register |
|
1725 iServer.Dispatcher().RegisterL( iIPSessionId, *this ); |
|
1726 } |
|
1727 else |
|
1728 { |
|
1729 User::Leave( iIPSessionId ); |
|
1730 } |
|
1731 iActionMessage = new (ELeave) RMessage2( aMessage ); |
|
1732 } |
|
1733 |
|
1734 // -------------------------------------------------------------------------- |
|
1735 // CUPnPBrowsingSession::CancelGetSearchCapabitiesSizeL |
|
1736 // See upnpbrowsingsession.h |
|
1737 // -------------------------------------------------------------------------- |
|
1738 void CUPnPBrowsingSession::CancelGetSearchCapabitiesSizeL() |
|
1739 { |
|
1740 __LOG( "CUPnPBrowsingSession::CancelGetSearchCapabitiesSizeL" ); |
|
1741 |
|
1742 if( iActionMessage ) |
|
1743 { |
|
1744 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
1745 iActionMessage->Complete( KErrCancel ); |
|
1746 delete iActionMessage; iActionMessage = NULL; |
|
1747 } |
|
1748 } |
|
1749 |
|
1750 // -------------------------------------------------------------------------- |
|
1751 // CUPnPBrowsingSession::GetSearchCapabitiesL |
|
1752 // See upnpbrowsingsession.h |
|
1753 // -------------------------------------------------------------------------- |
|
1754 void CUPnPBrowsingSession::GetSearchCapabitiesL( const RMessage2& aMessage ) |
|
1755 { |
|
1756 __LOG( "CUPnPBrowsingSession::GetSearchCapabitiesL" ); |
|
1757 |
|
1758 iIPSessionId = KErrNotFound; |
|
1759 |
|
1760 aMessage.WriteL( 1, *iRespBuf ); |
|
1761 aMessage.Complete( EAVControllerGetSearchCapabilitiesCompleted ); |
|
1762 } |
|
1763 |
|
1764 // -------------------------------------------------------------------------- |
|
1765 // CUPnPBrowsingSession::CreateContainerL |
|
1766 // See upnpbrowsingsession.h |
|
1767 // -------------------------------------------------------------------------- |
|
1768 void CUPnPBrowsingSession::CreateContainerL( const RMessage2& aMessage ) |
|
1769 { |
|
1770 __LOG( "CUPnPBrowsingSession::CreateContainerL" ); |
|
1771 |
|
1772 __ASSERTD( !iActionMessage, __FILE__, __LINE__ ); |
|
1773 |
|
1774 ResetL(); |
|
1775 |
|
1776 // Title |
|
1777 TInt len = aMessage.GetDesMaxLength( 1 ); |
|
1778 HBufC8* tempTitle = HBufC8::NewLC( len ); |
|
1779 TPtr8 ptr( tempTitle->Des() ); |
|
1780 aMessage.ReadL( 1, ptr ); |
|
1781 |
|
1782 // Container ID |
|
1783 len = aMessage.GetDesMaxLength( 2 ); |
|
1784 HBufC8* tempId = HBufC8::NewLC( len ); |
|
1785 ptr.Set( tempId->Des() ); |
|
1786 aMessage.ReadL( 2, ptr ); |
|
1787 |
|
1788 if( iDevice->DlnaCompatible() && !iDevice->CreateChildContainer() |
|
1789 && *tempId != KContainerIdAny ) |
|
1790 { |
|
1791 // The device is DLNA compatible and does not support creation |
|
1792 // of a child container |
|
1793 User::Leave( KErrNotSupported ); |
|
1794 } |
|
1795 |
|
1796 // Container type |
|
1797 MUPnPAVBrowsingSession::TContainerType type = |
|
1798 (MUPnPAVBrowsingSession::TContainerType)aMessage.Int3(); |
|
1799 |
|
1800 // Create a container object |
|
1801 CUpnpContainer* tmpContainer = CUpnpContainer::NewL(); |
|
1802 CleanupStack::PushL( tmpContainer ); |
|
1803 |
|
1804 // Set the title and the parent ID |
|
1805 tmpContainer->SetTitleL( *tempTitle ); |
|
1806 tmpContainer->SetParentIdL( *tempId ); |
|
1807 |
|
1808 // Set the object type |
|
1809 if( type == MUPnPAVBrowsingSession::EPlaylistContainer ) |
|
1810 { |
|
1811 tmpContainer->SetObjectClassL( KClassPlaylist() ); |
|
1812 } |
|
1813 else |
|
1814 { |
|
1815 tmpContainer->SetObjectClassL( KClassStorage() ); |
|
1816 } |
|
1817 |
|
1818 HBufC8* xmlDoc = CUPnPXMLParser::ContainerToXmlLC( *tmpContainer ); |
|
1819 |
|
1820 iIPSessionId = iServer.ControlPoint().CdsCreateObjectActionL( |
|
1821 iDevice->Uuid(), *tempId, *xmlDoc ); |
|
1822 |
|
1823 |
|
1824 CleanupStack::PopAndDestroy( xmlDoc ); |
|
1825 CleanupStack::PopAndDestroy( tmpContainer ); |
|
1826 CleanupStack::PopAndDestroy( tempId ); |
|
1827 CleanupStack::PopAndDestroy( tempTitle ); |
|
1828 |
|
1829 if( iIPSessionId > 0 ) |
|
1830 { |
|
1831 // Register |
|
1832 iServer.Dispatcher().RegisterL( iIPSessionId, *this ); |
|
1833 iInternalState = ECreateContainer; |
|
1834 } |
|
1835 else |
|
1836 { |
|
1837 User::Leave( iIPSessionId ); |
|
1838 } |
|
1839 iActionMessage = new (ELeave) RMessage2( aMessage ); |
|
1840 } |
|
1841 |
|
1842 // -------------------------------------------------------------------------- |
|
1843 // CUPnPBrowsingSession::CancelCreateContainerL |
|
1844 // See upnpbrowsingsession.h |
|
1845 // -------------------------------------------------------------------------- |
|
1846 void CUPnPBrowsingSession::CancelCreateContainerL() |
|
1847 { |
|
1848 __LOG( "CUPnPBrowsingSession::CancelCreateContainerL" ); |
|
1849 |
|
1850 if( iActionMessage ) |
|
1851 { |
|
1852 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
1853 iActionMessage->Complete( KErrCancel ); |
|
1854 delete iActionMessage; iActionMessage = NULL; |
|
1855 } |
|
1856 } |
|
1857 |
|
1858 // -------------------------------------------------------------------------- |
|
1859 // CUPnPBrowsingSession::DeleteObjectL |
|
1860 // See upnpbrowsingsession.h |
|
1861 // -------------------------------------------------------------------------- |
|
1862 void CUPnPBrowsingSession::DeleteObjectL( const RMessage2& aMessage ) |
|
1863 { |
|
1864 __LOG( "CUPnPBrowsingSession::DeleteObjectL" ); |
|
1865 |
|
1866 __ASSERTD( !iActionMessage, __FILE__, __LINE__ ); |
|
1867 |
|
1868 ResetL(); |
|
1869 |
|
1870 TInt len = aMessage.GetDesMaxLength( 1 ); |
|
1871 HBufC8* tempId = HBufC8::NewLC( len ); |
|
1872 TPtr8 ptr( tempId->Des() ); |
|
1873 aMessage.ReadL( 1, ptr ); |
|
1874 |
|
1875 CleanupStack::Pop( tempId ); |
|
1876 delete iItemId; |
|
1877 iItemId = tempId; |
|
1878 |
|
1879 |
|
1880 iIPSessionId = iServer.ControlPoint().CdsBrowseActionL( |
|
1881 iDevice->Uuid(), *iItemId, KMetaData, KFilterCommon, 0, 1, |
|
1882 KNullDesC8 ); |
|
1883 |
|
1884 if( iIPSessionId > 0 ) |
|
1885 { |
|
1886 // Register |
|
1887 iInternalState = EDestroyObject; |
|
1888 iServer.Dispatcher().RegisterL( iIPSessionId, *this ); |
|
1889 } |
|
1890 else |
|
1891 { |
|
1892 User::Leave( iIPSessionId ); |
|
1893 } |
|
1894 iActionMessage = new (ELeave) RMessage2( aMessage ); |
|
1895 } |
|
1896 |
|
1897 // -------------------------------------------------------------------------- |
|
1898 // CUPnPBrowsingSession::CancelDeleteObjectL |
|
1899 // See upnpbrowsingsession.h |
|
1900 // -------------------------------------------------------------------------- |
|
1901 void CUPnPBrowsingSession::CancelDeleteObjectL() |
|
1902 { |
|
1903 __LOG( "CUPnPBrowsingSession::CancelDeleteObjectL" ); |
|
1904 |
|
1905 if( iActionMessage ) |
|
1906 { |
|
1907 iServer.Dispatcher().UnRegister( iIPSessionId ); |
|
1908 iActionMessage->Complete( KErrCancel ); |
|
1909 delete iActionMessage; iActionMessage = NULL; |
|
1910 } |
|
1911 } |
|
1912 |
|
1913 // -------------------------------------------------------------------------- |
|
1914 // CUPnPBrowsingSession::DeviceDisappearedRequestL |
|
1915 // See upnpbrowsingsession.h |
|
1916 // -------------------------------------------------------------------------- |
|
1917 void CUPnPBrowsingSession::DeviceDisappearedRequestL( |
|
1918 const RMessage2& aMessage ) |
|
1919 { |
|
1920 __LOG( "CUPnPBrowsingSession::DeviceDisappearedRequestL" ); |
|
1921 |
|
1922 __ASSERTD( !iDeviceMessage, __FILE__, __LINE__ ); |
|
1923 |
|
1924 iDeviceMessage = new (ELeave) RMessage2( aMessage ); |
|
1925 } |
|
1926 |
|
1927 // -------------------------------------------------------------------------- |
|
1928 // CUPnPBrowsingSession::CancelDeviceDisappearedRequestL |
|
1929 // See upnpbrowsingsession.h |
|
1930 // -------------------------------------------------------------------------- |
|
1931 void CUPnPBrowsingSession::CancelDeviceDisappearedRequestL() |
|
1932 { |
|
1933 __LOG( "CUPnPBrowsingSession::CancelDeviceDisappearedRequestL" ); |
|
1934 |
|
1935 if( iDeviceMessage ) |
|
1936 { |
|
1937 iDeviceMessage->Complete( KErrCancel ); |
|
1938 delete iDeviceMessage; iDeviceMessage = NULL; |
|
1939 } |
|
1940 } |
|
1941 |
|
1942 // -------------------------------------------------------------------------- |
|
1943 // CUPnPBrowsingSession::ParseCreateObjectResponseL |
|
1944 // See upnpbrowsingsession.h |
|
1945 // -------------------------------------------------------------------------- |
|
1946 HBufC8* CUPnPBrowsingSession::ParseCreateObjectResponseL( |
|
1947 const TDesC8& aResponse ) |
|
1948 { |
|
1949 __LOG( "CUPnPBrowsingSession::ParseCreateObjectResponseL" ); |
|
1950 |
|
1951 HBufC8* importURI = NULL; |
|
1952 |
|
1953 CUPnPXMLParser* parser = CUPnPXMLParser::NewL(); |
|
1954 CleanupStack::PushL( parser ); |
|
1955 |
|
1956 RPointerArray<CUpnpObject> array; |
|
1957 CleanupResetAndDestroyPushL( array ); |
|
1958 |
|
1959 parser->ParseResultDataL( array, aResponse ); |
|
1960 |
|
1961 if( array.Count() == KExpectedCount ) |
|
1962 { |
|
1963 if( array[ 0 ]->ObjectType() == EUPnPItem ) |
|
1964 { |
|
1965 HBufC8* tmp = array[ 0 ]->Id().AllocL(); |
|
1966 delete iItemId; |
|
1967 iItemId = tmp; |
|
1968 |
|
1969 if( array[ 0 ]->ObjectClass().Find( KClassAudio ) |
|
1970 != KErrNotFound ) |
|
1971 { |
|
1972 iMusic = ETrue; |
|
1973 } |
|
1974 |
|
1975 // Get the res-elements |
|
1976 RUPnPElementsArray elArray; |
|
1977 CleanupClosePushL( elArray ); |
|
1978 UPnPItemUtility::GetResElements( *array[ 0 ], elArray ); |
|
1979 |
|
1980 // Find the import uri |
|
1981 for( TInt i = 0; i < elArray.Count(); i++ ) |
|
1982 { |
|
1983 const CUpnpAttribute* attribute = NULL; |
|
1984 TRAPD( err, attribute = |
|
1985 &UPnPItemUtility::FindAttributeByNameL( |
|
1986 *elArray[ i ], KImportUri ) ); |
|
1987 if( err == KErrNone ) |
|
1988 { |
|
1989 // import uri found! |
|
1990 i = elArray.Count(); |
|
1991 importURI = attribute->Value().AllocL(); |
|
1992 } |
|
1993 } |
|
1994 |
|
1995 CleanupStack::PopAndDestroy( &elArray ); |
|
1996 } |
|
1997 else |
|
1998 { |
|
1999 User::Leave( KErrGeneral ); |
|
2000 } |
|
2001 } |
|
2002 else |
|
2003 { |
|
2004 User::Leave( KErrGeneral ); |
|
2005 } |
|
2006 |
|
2007 CleanupStack::PopAndDestroy( &array ); |
|
2008 CleanupStack::PopAndDestroy( parser ); |
|
2009 |
|
2010 if( !importURI ) |
|
2011 { |
|
2012 User::Leave( KErrGeneral ); |
|
2013 } |
|
2014 |
|
2015 if( !UpnpCdsResElementUtility::IsUriAbsolute( *importURI ) ) |
|
2016 { |
|
2017 // Import uri is not absolute |
|
2018 delete importURI; importURI = NULL; |
|
2019 User::Leave( KErrGeneral ); |
|
2020 } |
|
2021 |
|
2022 return importURI; |
|
2023 } |
|
2024 |
|
2025 // -------------------------------------------------------------------------- |
|
2026 // CUPnPBrowsingSession::CheckIsCreateObjectSupportedL |
|
2027 // See upnpbrowsingsession.h |
|
2028 // -------------------------------------------------------------------------- |
|
2029 void CUPnPBrowsingSession::CheckIsCreateObjectSupportedL( |
|
2030 const TDesC8& aResponse ) |
|
2031 { |
|
2032 __LOG( "CUPnPBrowsingSession::CheckIsCreateObjectSupportedL" ); |
|
2033 |
|
2034 CUPnPXMLParser* parser = CUPnPXMLParser::NewL(); |
|
2035 CleanupStack::PushL( parser ); |
|
2036 |
|
2037 RPointerArray<CUpnpObject> array; |
|
2038 CleanupResetAndDestroyPushL( array ); |
|
2039 |
|
2040 parser->ParseResultDataL( array, aResponse ); |
|
2041 |
|
2042 if( array.Count() == KExpectedCount ) |
|
2043 { |
|
2044 if( array[ 0 ]->ObjectType() == EUPnPContainer ) |
|
2045 { |
|
2046 // Try to get upnp:createClass elements |
|
2047 const CUpnpElement* elem = UPnPItemUtility::FindElementByName( |
|
2048 *array[ 0 ], KCreateClass ); |
|
2049 |
|
2050 if ( !elem ) |
|
2051 { |
|
2052 // No createClass elements, copy not supported |
|
2053 User::Leave( KErrNotSupported ); |
|
2054 } |
|
2055 |
|
2056 RUPnPElementsArray resultArray; |
|
2057 CleanupClosePushL( resultArray ); |
|
2058 UPnPItemUtility::GetResElements( *array[ 0 ], resultArray ); |
|
2059 TInt count = resultArray.Count(); |
|
2060 |
|
2061 for( TInt i = 0; i < count; i++ ) |
|
2062 { |
|
2063 if( iSharedItem->ObjectClass().Find( KClassAudio ) != |
|
2064 KErrNotFound ) |
|
2065 { |
|
2066 // We are going to create a music item, check that the |
|
2067 // target container supports that |
|
2068 if( resultArray[ i ]->Value().Find( KClassAudio ) == |
|
2069 KErrNotFound ) |
|
2070 { |
|
2071 User::Leave( KErrNotSupported ); |
|
2072 } |
|
2073 } |
|
2074 else if( iSharedItem->ObjectClass().Find( KClassImage ) != |
|
2075 KErrNotFound ) |
|
2076 { |
|
2077 // We are going to create an image item, check that the |
|
2078 // target container supports that |
|
2079 if( resultArray[ i ]->Value().Find( KClassImage ) == |
|
2080 KErrNotFound ) |
|
2081 { |
|
2082 User::Leave( KErrNotSupported ); |
|
2083 } |
|
2084 } |
|
2085 else if( iSharedItem->ObjectClass().Find( KClassVideo ) != |
|
2086 KErrNotFound ) |
|
2087 { |
|
2088 // We are going to create a video item, check that the |
|
2089 // target container supports that |
|
2090 if( resultArray[ i ]->Value().Find( KClassVideo ) == |
|
2091 KErrNotFound ) |
|
2092 { |
|
2093 User::Leave( KErrNotSupported ); |
|
2094 } |
|
2095 } |
|
2096 else |
|
2097 { |
|
2098 // Unknown object class, leave |
|
2099 User::Leave( KErrNotSupported ); |
|
2100 } |
|
2101 } |
|
2102 CleanupStack::PopAndDestroy( &resultArray ); |
|
2103 } |
|
2104 else |
|
2105 { |
|
2106 User::Leave( KErrNotSupported ); |
|
2107 } |
|
2108 } |
|
2109 else |
|
2110 { |
|
2111 User::Leave( KErrGeneral ); |
|
2112 } |
|
2113 CleanupStack::PopAndDestroy( &array ); |
|
2114 CleanupStack::PopAndDestroy( parser ); |
|
2115 } |
|
2116 |
|
2117 // -------------------------------------------------------------------------- |
|
2118 // CUPnPBrowsingSession::CheckAndSendDestroyObjectActionL |
|
2119 // See upnpbrowsingsession.h |
|
2120 // -------------------------------------------------------------------------- |
|
2121 void CUPnPBrowsingSession::CheckAndSendDestroyObjectActionL( |
|
2122 const TDesC8& aResponse ) |
|
2123 { |
|
2124 __LOG( "CUPnPBrowsingSession::CheckAndSendDestroyObjectActionL" ); |
|
2125 |
|
2126 CUPnPXMLParser* parser = CUPnPXMLParser::NewL(); |
|
2127 CleanupStack::PushL( parser ); |
|
2128 |
|
2129 RPointerArray<CUpnpObject> array; |
|
2130 CleanupResetAndDestroyPushL( array ); |
|
2131 |
|
2132 parser->ParseResultDataL( array, aResponse ); |
|
2133 |
|
2134 if( array.Count() == KExpectedCount ) |
|
2135 { |
|
2136 if( array[ 0 ]->Restricted() ) |
|
2137 { |
|
2138 User::Leave( KErrArgument ); |
|
2139 } |
|
2140 else |
|
2141 { |
|
2142 // Not restricted, ok to destroy |
|
2143 TInt sessionId = iServer.ControlPoint().CdsDestroyObjectActionL( |
|
2144 iDevice->Uuid(), *iItemId ); |
|
2145 if( sessionId > 0 ) |
|
2146 { |
|
2147 iServer.Dispatcher().RegisterL( sessionId, *this ); |
|
2148 iIPSessionId = sessionId; |
|
2149 } |
|
2150 else |
|
2151 { |
|
2152 User::Leave( sessionId ); |
|
2153 } |
|
2154 } |
|
2155 } |
|
2156 else |
|
2157 { |
|
2158 User::Leave( KErrGeneral ); |
|
2159 } |
|
2160 CleanupStack::PopAndDestroy( &array ); |
|
2161 CleanupStack::PopAndDestroy( parser ); |
|
2162 } |
|
2163 |
|
2164 // -------------------------------------------------------------------------- |
|
2165 // CUPnPBrowsingSession::CheckAndSendCreateObjectActionL |
|
2166 // See upnpbrowsingsession.h |
|
2167 // -------------------------------------------------------------------------- |
|
2168 void CUPnPBrowsingSession::CheckAndSendCreateObjectActionL( |
|
2169 const TDesC8& aResponse ) |
|
2170 { |
|
2171 __LOG( "CUPnPBrowsingSession::CheckAndSendCreateObjectActionL" ); |
|
2172 |
|
2173 CheckIsCreateObjectSupportedL( aResponse ); |
|
2174 |
|
2175 HBufC8* xmlDoc = CUPnPXMLParser::XmlForCreateObjectLC( *iSharedItem ); |
|
2176 SendCreateObjectActionL( iDevice->Uuid(), *iContainerId, *xmlDoc ); |
|
2177 CleanupStack::PopAndDestroy( xmlDoc ); |
|
2178 } |
|
2179 |
|
2180 // -------------------------------------------------------------------------- |
|
2181 // CUPnPBrowsingSession::SendCreateObjectActionL |
|
2182 // See upnpbrowsingsession.h |
|
2183 // -------------------------------------------------------------------------- |
|
2184 void CUPnPBrowsingSession::SendCreateObjectActionL( const TDesC8& aUUid, |
|
2185 const TDesC8& aContainerId, const TDesC8& aResponse ) |
|
2186 { |
|
2187 __LOG( "CUPnPBrowsingSession::SendCreateObjectActionL" ); |
|
2188 |
|
2189 TInt sessionId = iServer.ControlPoint().CdsCreateObjectActionL( aUUid, |
|
2190 aContainerId, aResponse ); |
|
2191 |
|
2192 if( sessionId > 0 ) |
|
2193 { |
|
2194 iServer.Dispatcher().RegisterL( sessionId, *this ); |
|
2195 iIPSessionId = sessionId; |
|
2196 } |
|
2197 else |
|
2198 { |
|
2199 User::Leave( sessionId ); |
|
2200 } |
|
2201 } |
|
2202 |
|
2203 // -------------------------------------------------------------------------- |
|
2204 // CUPnPBrowsingSession::SendExportActionL |
|
2205 // See upnpbrowsingsession.h |
|
2206 // -------------------------------------------------------------------------- |
|
2207 void CUPnPBrowsingSession::SendExportActionL() |
|
2208 { |
|
2209 __LOG( "CUPnPBrowsingSession::SendExportActionL" ); |
|
2210 //__LOG8( *iSourceURI ); |
|
2211 //__LOG8( *iImportURI ); |
|
2212 |
|
2213 HBufC8* tempSourceUri = UpnpString::EncodeXmlStringL( |
|
2214 iSourceURI ); |
|
2215 delete iSourceURI; |
|
2216 iSourceURI = tempSourceUri; |
|
2217 tempSourceUri = NULL; |
|
2218 |
|
2219 TInt sessionId = iServer.ControlPoint().CdsExportResourceActionL( |
|
2220 *iLocalMediaServerUuid, *iSourceURI, *iImportURI ); |
|
2221 if( sessionId > 0 ) |
|
2222 { |
|
2223 iServer.Dispatcher().RegisterL( sessionId, *this ); |
|
2224 iIPSessionId = sessionId; |
|
2225 } |
|
2226 else |
|
2227 { |
|
2228 User::Leave( sessionId ); |
|
2229 } |
|
2230 } |
|
2231 |
|
2232 // -------------------------------------------------------------------------- |
|
2233 // CUPnPBrowsingSession::SendImportActionL |
|
2234 // See upnpbrowsingsession.h |
|
2235 // -------------------------------------------------------------------------- |
|
2236 void CUPnPBrowsingSession::SendImportActionL() |
|
2237 { |
|
2238 __LOG( "CUPnPBrowsingSession::SendImportActionL" ); |
|
2239 //__LOG8( *iSourceURI ); |
|
2240 //__LOG8( *iImportURI ); |
|
2241 |
|
2242 HBufC8* tempSourceUri = UpnpString::EncodeXmlStringL( |
|
2243 iSourceURI ); |
|
2244 delete iSourceURI; |
|
2245 iSourceURI = tempSourceUri; |
|
2246 tempSourceUri = NULL; |
|
2247 |
|
2248 TInt sessionId = iServer.ControlPoint().CdsImportResourceActionL( |
|
2249 *iLocalMediaServerUuid, *iSourceURI, *iImportURI ); |
|
2250 if( sessionId > 0 ) |
|
2251 { |
|
2252 iServer.Dispatcher().RegisterL( sessionId, *this ); |
|
2253 iIPSessionId = sessionId; |
|
2254 } |
|
2255 else |
|
2256 { |
|
2257 User::Leave( sessionId ); |
|
2258 } |
|
2259 } |
|
2260 |
|
2261 |
|
2262 // -------------------------------------------------------------------------- |
|
2263 // CUPnPBrowsingSession::CopyFinished |
|
2264 // See upnpbrowsingsession.h |
|
2265 // -------------------------------------------------------------------------- |
|
2266 void CUPnPBrowsingSession::CopyFinished( TInt aError, TBool aFinished ) |
|
2267 { |
|
2268 __LOG( "CUPnPBrowsingSession::CopyFinished" ); |
|
2269 |
|
2270 if( iInternalState == ECopyLocal ) // Local to remote copy |
|
2271 { |
|
2272 if( aError == KErrNone ) |
|
2273 { |
|
2274 if( aFinished ) |
|
2275 { |
|
2276 // Local to remote copy completed successfully! |
|
2277 |
|
2278 if( iSharedItem ) |
|
2279 { |
|
2280 // Remove shared item |
|
2281 TRAP_IGNORE( iFileSharing->UnShareItemL( |
|
2282 iSharedItem->Id() ) ); |
|
2283 delete iSharedItem; iSharedItem = NULL; |
|
2284 } |
|
2285 |
|
2286 iInternalState = ENone; |
|
2287 if( iActionMessage ) |
|
2288 { |
|
2289 iActionMessage->Complete( |
|
2290 EAVControllerCopyLocalItemFinishCompleted ); |
|
2291 delete iActionMessage; iActionMessage = NULL; |
|
2292 } |
|
2293 } |
|
2294 else |
|
2295 { |
|
2296 // First phase of copy completed (export action succeeded) |
|
2297 if( iActionMessage ) |
|
2298 { |
|
2299 iActionMessage->Complete( |
|
2300 EAVControllerCopyLocalItemStartCompleted ); |
|
2301 delete iActionMessage; iActionMessage = NULL; |
|
2302 } |
|
2303 } |
|
2304 } |
|
2305 else // Error occured, cleanup. |
|
2306 { |
|
2307 if( iSharedItem ) |
|
2308 { |
|
2309 // Remove shared item |
|
2310 TRAP_IGNORE( iFileSharing->UnShareItemL( |
|
2311 iSharedItem->Id() ) ); |
|
2312 } |
|
2313 delete iSharedItem; iSharedItem = NULL; |
|
2314 if( iItemId ) |
|
2315 { |
|
2316 // Destroy object from the remote media server |
|
2317 TRAP_IGNORE( iServer.ControlPoint().CdsDestroyObjectActionL( |
|
2318 iDevice->Uuid(), *iItemId ) ); |
|
2319 delete iItemId; iItemId = NULL; |
|
2320 } |
|
2321 |
|
2322 iInternalState = ENone; |
|
2323 if( iActionMessage ) |
|
2324 { |
|
2325 iActionMessage->Complete( aError ); |
|
2326 delete iActionMessage; iActionMessage = NULL; |
|
2327 } |
|
2328 |
|
2329 } |
|
2330 } |
|
2331 else if( iInternalState == ECopyToPhone ) // Remote to local copy |
|
2332 { |
|
2333 if( aError == KErrNone ) |
|
2334 { |
|
2335 if( aFinished ) |
|
2336 { |
|
2337 // Remote to local copy successful, check sharing status |
|
2338 CheckSharingStatus(); |
|
2339 |
|
2340 // Restore original download settings |
|
2341 RestoreDownloadSettings(); // ignore error |
|
2342 |
|
2343 iInternalState = ENone; |
|
2344 if( iActionMessage ) |
|
2345 { |
|
2346 iActionMessage->Complete( |
|
2347 EAVControllerCopyToPhoneFinishCompleted ); |
|
2348 delete iActionMessage; iActionMessage = NULL; |
|
2349 } |
|
2350 } |
|
2351 else |
|
2352 { |
|
2353 // First phase of copy completed (import action succeeded) |
|
2354 if( iActionMessage ) |
|
2355 { |
|
2356 iActionMessage->Complete( |
|
2357 EAVControllerCopyToPhoneStartCompleted ); |
|
2358 delete iActionMessage; iActionMessage = NULL; |
|
2359 } |
|
2360 } |
|
2361 } |
|
2362 else // Error occured, cleanup. |
|
2363 { |
|
2364 // Restore original download settings |
|
2365 RestoreDownloadSettings(); // ignore error |
|
2366 |
|
2367 if( iItemId ) |
|
2368 { |
|
2369 // Destroy object from the local media server |
|
2370 TRAP_IGNORE( iServer.ControlPoint().CdsDestroyObjectActionL( |
|
2371 *iLocalMediaServerUuid, *iItemId ) ); |
|
2372 delete iItemId; iItemId = NULL; |
|
2373 } |
|
2374 |
|
2375 iInternalState = ENone; |
|
2376 if( iActionMessage ) |
|
2377 { |
|
2378 iActionMessage->Complete( aError ); |
|
2379 delete iActionMessage; iActionMessage = NULL; |
|
2380 } |
|
2381 } |
|
2382 } |
|
2383 else |
|
2384 { |
|
2385 __PANICD( __FILE__, __LINE__ ); |
|
2386 } |
|
2387 } |
|
2388 |
|
2389 // -------------------------------------------------------------------------- |
|
2390 // CUPnPBrowsingSession::ResetL |
|
2391 // See upnpbrowsingsession.h |
|
2392 // -------------------------------------------------------------------------- |
|
2393 void CUPnPBrowsingSession::ResetL() |
|
2394 { |
|
2395 __LOG( "CUPnPBrowsingSession::ResetL" ); |
|
2396 |
|
2397 iIPSessionId = KErrNotFound; |
|
2398 |
|
2399 if( !iServer.DeviceRepository().IsWlanActive() ) |
|
2400 { |
|
2401 __LOG( "Reset - disconnected" ); |
|
2402 User::Leave( KErrDisconnected ); |
|
2403 } |
|
2404 } |
|
2405 |
|
2406 // -------------------------------------------------------------------------- |
|
2407 // CUPnPBrowsingSession::ReadObjFromMessageL |
|
2408 // See upnpbrowsingsession.h |
|
2409 // -------------------------------------------------------------------------- |
|
2410 void CUPnPBrowsingSession::ReadObjFromMessageL( const RMessage2& aMessage, |
|
2411 TInt aSlot, CUpnpObject* aObj ) |
|
2412 { |
|
2413 // create buffer |
|
2414 TInt len = aMessage.GetDesMaxLength( aSlot ); |
|
2415 HBufC8* buf = HBufC8::NewLC( len ); |
|
2416 TPtr8 ptr( buf->Des() ); |
|
2417 User::LeaveIfError( aMessage.Read( aSlot, ptr ) ); |
|
2418 |
|
2419 // read stream |
|
2420 RDesReadStream stream( *buf ); |
|
2421 CleanupClosePushL( stream ); |
|
2422 |
|
2423 // internalize object |
|
2424 stream >> *aObj; |
|
2425 |
|
2426 // clean up |
|
2427 CleanupStack::PopAndDestroy( &stream ); |
|
2428 CleanupStack::PopAndDestroy( buf ); |
|
2429 } |
|
2430 |
|
2431 // -------------------------------------------------------------------------- |
|
2432 // CUPnPBrowsingSession::ReadReqFromMessageL |
|
2433 // See upnpbrowsingsession.h |
|
2434 // -------------------------------------------------------------------------- |
|
2435 void CUPnPBrowsingSession::ReadReqFromMessageL( const RMessage2& aMessage, |
|
2436 TInt aSlot, CUpnpAVRequest* aReq ) |
|
2437 { |
|
2438 // create buffer |
|
2439 TInt len = aMessage.GetDesMaxLength( aSlot ); |
|
2440 HBufC8* buf = HBufC8::NewLC( len ); |
|
2441 TPtr8 ptr( buf->Des() ); |
|
2442 User::LeaveIfError( aMessage.Read( aSlot, ptr ) ); |
|
2443 |
|
2444 // read stream |
|
2445 RDesReadStream stream( *buf ); |
|
2446 CleanupClosePushL( stream ); |
|
2447 |
|
2448 // internalize object |
|
2449 stream >> *aReq; |
|
2450 |
|
2451 // clean up |
|
2452 CleanupStack::PopAndDestroy( &stream ); |
|
2453 CleanupStack::PopAndDestroy( buf ); |
|
2454 } |
|
2455 |
|
2456 // -------------------------------------------------------------------------- |
|
2457 // CUPnPBrowsingSession::ReadBrowseReqFromMessageL |
|
2458 // See upnpbrowsingsession.h |
|
2459 // -------------------------------------------------------------------------- |
|
2460 void CUPnPBrowsingSession::ReadBrowseReqFromMessageL( |
|
2461 const RMessage2& aMessage, TInt aSlot, CUpnpAVBrowseRequest* aReq ) |
|
2462 { |
|
2463 // create buffer |
|
2464 TInt len = aMessage.GetDesMaxLength( aSlot ); |
|
2465 HBufC8* buf = HBufC8::NewLC( len ); |
|
2466 TPtr8 ptr( buf->Des() ); |
|
2467 User::LeaveIfError( aMessage.Read( aSlot, ptr ) ); |
|
2468 |
|
2469 // read stream |
|
2470 RDesReadStream stream( *buf ); |
|
2471 CleanupClosePushL( stream ); |
|
2472 |
|
2473 // internalize object |
|
2474 stream >> *aReq; |
|
2475 |
|
2476 // clean up |
|
2477 CleanupStack::PopAndDestroy( &stream ); |
|
2478 CleanupStack::PopAndDestroy( buf ); |
|
2479 } |
|
2480 |
|
2481 // -------------------------------------------------------------------------- |
|
2482 // CUPnPBrowsingSession::ReadBufFromMessageLC |
|
2483 // See upnpbrowsingsession.h |
|
2484 // -------------------------------------------------------------------------- |
|
2485 HBufC8* CUPnPBrowsingSession::ReadBufFromMessageLC( |
|
2486 const RMessage2& aMessage, TInt aSlot ) |
|
2487 { |
|
2488 // create buffer |
|
2489 TInt len = aMessage.GetDesMaxLength( aSlot ); |
|
2490 HBufC8* buf = HBufC8::NewLC( len ); |
|
2491 TPtr8 ptr( buf->Des() ); |
|
2492 User::LeaveIfError( aMessage.Read( aSlot, ptr ) ); |
|
2493 return buf; |
|
2494 } |
|
2495 |
|
2496 // -------------------------------------------------------------------------- |
|
2497 // CUPnPBrowsingSession::SetDownloadSettingsL |
|
2498 // See upnpbrowsingsession.h |
|
2499 // -------------------------------------------------------------------------- |
|
2500 void CUPnPBrowsingSession::SetDownloadSettingsL( |
|
2501 MUPnPAVBrowsingSession::TMemoryType aType ) |
|
2502 { |
|
2503 if( aType == MUPnPAVBrowsingSession::EDefault ) |
|
2504 { |
|
2505 // Downloading to default location is the only supported target |
|
2506 } |
|
2507 else |
|
2508 { |
|
2509 User::Leave( KErrNotSupported ); |
|
2510 } |
|
2511 |
|
2512 // EMemoryCard, ERAMDrive or EPhone are not supported, but the code is |
|
2513 // left in place for possible future use |
|
2514 /* |
|
2515 // Read the original download location and store it |
|
2516 HBufC8* buf = iMSSettings->GetL( |
|
2517 UpnpMediaServerSettings::EUploadDirectory ); |
|
2518 delete iOriginalLocation; |
|
2519 iOriginalLocation = buf; |
|
2520 |
|
2521 // Set the new download location |
|
2522 if( aType == MUPnPAVBrowsingSession::EMemoryCard ) |
|
2523 { |
|
2524 User::LeaveIfError( iMSSettings->SetL( |
|
2525 UpnpMediaServerSettings::EUploadDirectory, |
|
2526 KDownloadMemoryCard ) ); |
|
2527 } |
|
2528 else if( aType == MUPnPAVBrowsingSession::ERAMDrive ) |
|
2529 { |
|
2530 User::LeaveIfError( iMSSettings->SetL( |
|
2531 UpnpMediaServerSettings::EUploadDirectory, |
|
2532 KDownloadRAMDrive ) ); |
|
2533 } |
|
2534 else if( aType == MUPnPAVBrowsingSession::EPhone ) |
|
2535 { |
|
2536 User::LeaveIfError( iMSSettings->SetL( |
|
2537 UpnpMediaServerSettings::EUploadDirectory, |
|
2538 KDownloadPhoneMemory ) ); |
|
2539 } |
|
2540 else |
|
2541 { |
|
2542 // Default, no change needed |
|
2543 } |
|
2544 */ |
|
2545 } |
|
2546 |
|
2547 // -------------------------------------------------------------------------- |
|
2548 // CUPnPBrowsingSession::RestoreDownloadSettings |
|
2549 // See upnpbrowsingsession.h |
|
2550 // -------------------------------------------------------------------------- |
|
2551 TInt CUPnPBrowsingSession::RestoreDownloadSettings() |
|
2552 { |
|
2553 // Restore the download settings |
|
2554 TInt err = KErrNone; |
|
2555 |
|
2556 if( iOriginalLocation && iShareFlag != |
|
2557 MUPnPAVBrowsingSession::EDefault ) |
|
2558 { |
|
2559 TRAP( err, err = iMSSettings->SetL( |
|
2560 UpnpMediaServerSettings::EUploadDirectory, |
|
2561 *iOriginalLocation ) ); |
|
2562 } |
|
2563 else |
|
2564 { |
|
2565 err = KErrGeneral; |
|
2566 } |
|
2567 |
|
2568 return err; |
|
2569 } |
|
2570 |
|
2571 // -------------------------------------------------------------------------- |
|
2572 // CUPnPBrowsingSession::CheckSharingStatus |
|
2573 // See upnpbrowsingsession.h |
|
2574 // -------------------------------------------------------------------------- |
|
2575 TInt CUPnPBrowsingSession::CheckSharingStatus() |
|
2576 { |
|
2577 TInt err = KErrNone; |
|
2578 |
|
2579 if( iShareFlag == MUPnPAVBrowsingSession::EFileIsNotShared ) |
|
2580 { |
|
2581 // Unshare the item |
|
2582 if( iItemId ) |
|
2583 { |
|
2584 TRAP( err, iFileSharing->UnShareItemL( *iItemId ) ); |
|
2585 delete iItemId; iItemId = NULL; |
|
2586 } |
|
2587 } |
|
2588 else if( MUPnPAVBrowsingSession::EShareBySettings ) |
|
2589 { |
|
2590 // Check settings to determine should we keep the item shared or not |
|
2591 TInt share = 0; |
|
2592 if( iMusic ) // It's a music item |
|
2593 { |
|
2594 err = iAppSettings->Get( KUPnPAppShareAllMusicFiles, share ); |
|
2595 } |
|
2596 else // Image or video item |
|
2597 { |
|
2598 err = iAppSettings->Get( KUPnPAppShareAllVisualFiles, share ); |
|
2599 } |
|
2600 |
|
2601 if( err == KErrNone && !share ) |
|
2602 { |
|
2603 if( iItemId ) |
|
2604 { |
|
2605 TRAP( err, iFileSharing->UnShareItemL( *iItemId ) ); |
|
2606 delete iItemId; iItemId = NULL; |
|
2607 } |
|
2608 } |
|
2609 } |
|
2610 else |
|
2611 { |
|
2612 // File is shared already, do nothing |
|
2613 } |
|
2614 |
|
2615 return err; |
|
2616 } |
|
2617 |
|
2618 // End of file |