|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Resolver for downloading remote items |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 // System |
|
25 #include <pathinfo.h> |
|
26 #include <bautils.h> |
|
27 |
|
28 // upnp stack api's |
|
29 #include <upnpobject.h> |
|
30 #include <upnpitem.h> |
|
31 #include <upnpelement.h> |
|
32 #include <upnpattribute.h> // for getting resource protocol info |
|
33 #include <upnpdlnaprotocolinfo.h> // for resolving object mimetype |
|
34 |
|
35 // upnpframework / avcontroller api |
|
36 #include "upnpavcontroller.h" // avcontrol services |
|
37 #include "upnpavdevice.h" // avcontroller device class |
|
38 #include "upnpavbrowsingsession.h" // avcontrol browsing session |
|
39 #include "upnpfiledownloadsession.h" // avcontrol download session |
|
40 |
|
41 // upnpframework / avcontroller helper api |
|
42 #include "upnpconstantdefs.h" // for element names |
|
43 #include "upnpitemutility.h" // for FindAttributeByName |
|
44 #include "upnpresourceselector.h" // MUPnPResourceSelector |
|
45 #include "upnpitemresolverobserver.h" // observer for this class |
|
46 #include "upnpdlnautility.h" // IsSupportedDlnaProfile |
|
47 |
|
48 // upnpframework / internal api's |
|
49 #include "upnpcommonutils.h" // for FileExtensionByMimeTypeL |
|
50 #include "upnpsettingsengine.h" // get selected download location |
|
51 |
|
52 // avcontroller helper internal |
|
53 #include "upnpremoteitemresolver.h" // remote item resolver impl. |
|
54 #include "upnpdownloaditemresolver.h" // download item resolver impl. |
|
55 |
|
56 _LIT( KComponentLogfile, "upnpavcontrollerhelper.txt"); |
|
57 #include "upnplog.h" |
|
58 |
|
59 // CONSTANTS |
|
60 _LIT( KTempPrefix, "upnpfwtemp"); |
|
61 |
|
62 // METHODS |
|
63 |
|
64 // -------------------------------------------------------------------------- |
|
65 // CUPnPDownloadItemResolver::NewL |
|
66 //--------------------------------------------------------------------------- |
|
67 CUPnPDownloadItemResolver* CUPnPDownloadItemResolver::NewL( |
|
68 const TDesC8& aItemId, |
|
69 MUPnPAVController& aAvController, |
|
70 MUPnPAVBrowsingSession& aHostSession, |
|
71 MUPnPResourceSelector& aSelector, |
|
72 const TDesC8& aBrowseFilter ) |
|
73 { |
|
74 CUPnPDownloadItemResolver* self = new (ELeave) CUPnPDownloadItemResolver( |
|
75 aItemId, aAvController, aHostSession, aSelector, aBrowseFilter ); |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL( |
|
78 aItemId, aAvController, aHostSession, aSelector, aBrowseFilter ); |
|
79 CleanupStack::Pop( self ); |
|
80 return self; |
|
81 } |
|
82 |
|
83 |
|
84 // -------------------------------------------------------------------------- |
|
85 // CUPnPDownloadItemResolver::CUPnPDownloadItemResolver |
|
86 //--------------------------------------------------------------------------- |
|
87 CUPnPDownloadItemResolver::CUPnPDownloadItemResolver( |
|
88 const TDesC8& /*aItemId*/, |
|
89 MUPnPAVController& aAvController, |
|
90 MUPnPAVBrowsingSession& /*aHostSession*/, |
|
91 MUPnPResourceSelector& aSelector, |
|
92 const TDesC8& /*aBrowseFilter*/ ) |
|
93 : iAvController( aAvController ), |
|
94 iState( EStateIdle ),iSelector(aSelector) |
|
95 { |
|
96 |
|
97 } |
|
98 |
|
99 // -------------------------------------------------------------------------- |
|
100 // CUPnPDownloadItemResolver::ConstructL |
|
101 //--------------------------------------------------------------------------- |
|
102 void CUPnPDownloadItemResolver::ConstructL( |
|
103 const TDesC8& aItemId, |
|
104 MUPnPAVController& /*aAvController*/, |
|
105 MUPnPAVBrowsingSession& aHostSession, |
|
106 MUPnPResourceSelector& aSelector, |
|
107 const TDesC8& aBrowseFilter ) |
|
108 { |
|
109 iRemoteResolver = CUPnPRemoteItemResolver::NewL( |
|
110 aItemId, aHostSession, aSelector, aBrowseFilter ); |
|
111 iRemoteDevice = CUpnpAVDevice::NewL( aHostSession.Device() ); |
|
112 iSettingsEngine = CUPnPSettingsEngine::NewL(); |
|
113 |
|
114 // Open File Server session |
|
115 User::LeaveIfError( iFsSession.Connect() ); |
|
116 User::LeaveIfError( iFsSession.ShareProtected() ); |
|
117 } |
|
118 |
|
119 // -------------------------------------------------------------------------- |
|
120 // CUPnPDownloadItemResolver::~CUPnPDownloadItemResolver |
|
121 //--------------------------------------------------------------------------- |
|
122 CUPnPDownloadItemResolver::~CUPnPDownloadItemResolver() |
|
123 { |
|
124 Cleanup(); |
|
125 delete iRemoteResolver; |
|
126 iRemoteResolver = 0; |
|
127 delete iRemoteDevice; |
|
128 iRemoteDevice= 0; |
|
129 delete iSettingsEngine; |
|
130 iSettingsEngine = 0; |
|
131 } |
|
132 |
|
133 // -------------------------------------------------------------------------- |
|
134 // CUPnPDownloadItemResolver::ResolveL |
|
135 //--------------------------------------------------------------------------- |
|
136 void CUPnPDownloadItemResolver::ResolveL( |
|
137 MUPnPItemResolverObserver& aObserver ) |
|
138 { |
|
139 __LOG( "DownloadItemResolver:Resolve()" ); |
|
140 __ASSERTD( iState == EStateIdle, __FILE__, __LINE__ ); |
|
141 |
|
142 // change state |
|
143 iObserver = &aObserver; |
|
144 |
|
145 // first resolve the item |
|
146 iRemoteResolver->ResolveL( *this ); |
|
147 iState = EStateResolving; |
|
148 } |
|
149 |
|
150 // -------------------------------------------------------------------------- |
|
151 // CUPnPDownloadItemResolver::ResolveComplete |
|
152 //--------------------------------------------------------------------------- |
|
153 void CUPnPDownloadItemResolver::ResolveComplete( |
|
154 const MUPnPItemResolver& /*aResolver*/, TInt aError ) |
|
155 { |
|
156 __LOG1( "DownloadItemResolver:ResolveComplete(%d)", aError ); |
|
157 __ASSERTD( iState == EStateResolving, __FILE__, __LINE__ ); |
|
158 |
|
159 if ( aError == KErrNone ) |
|
160 { |
|
161 TRAP( aError, |
|
162 const CUpnpElement& res = |
|
163 iSelector.SelectResourceL( iRemoteResolver->Item() ); |
|
164 IsLocallySupportedL( res ); |
|
165 ); |
|
166 if( aError ) |
|
167 { |
|
168 Complete( aError ); |
|
169 } |
|
170 else |
|
171 { |
|
172 TRAPD( err, InitiateDownloadL() ); |
|
173 if ( err != KErrNone ) |
|
174 { |
|
175 Complete( err ); |
|
176 } |
|
177 } |
|
178 } |
|
179 else |
|
180 { |
|
181 Complete( aError ); |
|
182 } |
|
183 |
|
184 } |
|
185 |
|
186 // -------------------------------------------------------------------------- |
|
187 // CUPnPDownloadItemResolver::InitiateDownloadL |
|
188 //--------------------------------------------------------------------------- |
|
189 void CUPnPDownloadItemResolver::InitiateDownloadL() |
|
190 { |
|
191 __LOG( "CUPnPDownloadItemResolver::InitiateDownloadL"); |
|
192 // start a download session if not already started |
|
193 if( !iDownloadSession ) |
|
194 { |
|
195 iDownloadSession = |
|
196 &iAvController.StartDownloadSessionL( *iRemoteDevice ); |
|
197 } |
|
198 iDownloadSession->SetObserver( *this ); |
|
199 |
|
200 // Get selected download location. |
|
201 HBufC* copyLocation = GetSelectedDownloadLocationL(); |
|
202 CleanupStack::PushL( copyLocation ); |
|
203 _LIT(KTempFolder, "temp\\"); |
|
204 // Create temp file name |
|
205 HBufC* tempFileName = CreateTmpFileNameL(); |
|
206 CleanupStack::PushL( tempFileName ); |
|
207 |
|
208 // Create and save full file path. |
|
209 if( iLocalFile ) |
|
210 { |
|
211 // delete if already allocated. |
|
212 delete iLocalFile; |
|
213 iLocalFile = 0; |
|
214 } |
|
215 |
|
216 iLocalFile = HBufC::NewL( copyLocation->Length() + |
|
217 KTempFolder().Length() ); |
|
218 iLocalFile->Des().Append( *copyLocation ); |
|
219 iLocalFile->Des().Append( KTempFolder ); |
|
220 //check the existence of the target folder |
|
221 if( !BaflUtils::FolderExists( iFsSession, *iLocalFile ) ) |
|
222 { |
|
223 User::LeaveIfError( iFsSession.MkDirAll( *iLocalFile ) ); |
|
224 } |
|
225 |
|
226 User::LeaveIfError( iFsSession.SetAtt( *iLocalFile, |
|
227 KEntryAttHidden, |
|
228 KEntryAttNormal ) ); |
|
229 |
|
230 iLocalFile = iLocalFile->ReAllocL( |
|
231 iLocalFile->Length() + tempFileName->Length() ); |
|
232 |
|
233 iLocalFile->Des().Append( *tempFileName ); |
|
234 |
|
235 // write the file path into the item |
|
236 CUpnpElement& writableRes = |
|
237 const_cast<CUpnpElement&>( iRemoteResolver->Resource() ); |
|
238 writableRes.SetFilePathL( *iLocalFile ); |
|
239 CleanupStack::PopAndDestroy( tempFileName ); |
|
240 CleanupStack::PopAndDestroy( copyLocation ); |
|
241 |
|
242 // Create local target file for dowload item |
|
243 TInt err = CreateRFile( *iLocalFile ); |
|
244 |
|
245 if( err == KErrNone ) |
|
246 { |
|
247 __LOG( "StartDownloading..."); |
|
248 // initiate download |
|
249 |
|
250 iDownloadSession->StartDownloadL( writableRes, |
|
251 iRemoteResolver->Item(), |
|
252 iFile, |
|
253 (TInt)this ); |
|
254 |
|
255 iState = EStateDownloading; |
|
256 } |
|
257 else // Create download target failed! |
|
258 { |
|
259 __LOG( "Create download target failed!"); |
|
260 User::Leave( err ); |
|
261 } |
|
262 __LOG( "CUPnPDownloadItemResolver::InitiateDownloadL -End"); |
|
263 } |
|
264 |
|
265 // -------------------------------------------------------------------------- |
|
266 // CUPnPDownloadItemResolver::TransferStarted |
|
267 //--------------------------------------------------------------------------- |
|
268 void CUPnPDownloadItemResolver::TransferStarted( TInt /*aKey*/, |
|
269 TInt /*aStatus*/ ) |
|
270 { |
|
271 __LOG( "DownloadItemResolver:TransferStarted"); |
|
272 } |
|
273 |
|
274 // -------------------------------------------------------------------------- |
|
275 // CUPnPDownloadItemResolver::TransferCompleted |
|
276 //--------------------------------------------------------------------------- |
|
277 void CUPnPDownloadItemResolver::TransferCompleted( TInt /*aKey*/, |
|
278 TInt aStatus, const TDesC& /*aFilePath*/ ) |
|
279 { |
|
280 __LOG1( "DownloadItemResolver:TransferCompleted(%d)", aStatus ); |
|
281 iFile.Close(); |
|
282 Complete( aStatus ); |
|
283 } |
|
284 |
|
285 // -------------------------------------------------------------------------- |
|
286 // CUPnPDownloadItemResolver::TransferProgress |
|
287 //--------------------------------------------------------------------------- |
|
288 void CUPnPDownloadItemResolver::TransferProgress( TInt /*aKey*/, |
|
289 TInt /*aBytes*/, TInt /*aTotalBytes*/ ) |
|
290 { |
|
291 __LOG( "DownloadItemResolver:TransferProgress"); |
|
292 } |
|
293 |
|
294 // -------------------------------------------------------------------------- |
|
295 // CUPnPDownloadItemResolver::MediaServerDisappeared |
|
296 //--------------------------------------------------------------------------- |
|
297 void CUPnPDownloadItemResolver::MediaServerDisappeared( |
|
298 TUPnPDeviceDisconnectedReason /*aReason*/ ) |
|
299 { |
|
300 __LOG( "DownloadItemResolver:MediaServerDisappeared" ); |
|
301 Complete( KErrDisconnected ); |
|
302 } |
|
303 |
|
304 // -------------------------------------------------------------------------- |
|
305 // CUPnPDownloadItemResolver::Item |
|
306 //--------------------------------------------------------------------------- |
|
307 const CUpnpItem& CUPnPDownloadItemResolver::Item() const |
|
308 { |
|
309 __ASSERTD( iState == EStateReady, __FILE__, __LINE__ ); |
|
310 |
|
311 return iRemoteResolver->Item(); |
|
312 } |
|
313 |
|
314 |
|
315 // -------------------------------------------------------------------------- |
|
316 // CUPnPDownloadItemResolver::Resource |
|
317 //--------------------------------------------------------------------------- |
|
318 const CUpnpElement& CUPnPDownloadItemResolver::Resource() const |
|
319 { |
|
320 __ASSERTD( iState == EStateReady, __FILE__, __LINE__ ); |
|
321 |
|
322 return iRemoteResolver->Resource(); |
|
323 } |
|
324 |
|
325 // -------------------------------------------------------------------------- |
|
326 // CUPnPDownloadItemResolver::DeleteTempFilesL |
|
327 // -------------------------------------------------------------------------- |
|
328 EXPORT_C void CUPnPDownloadItemResolver::DeleteTempDownloadFilesL() |
|
329 { |
|
330 __LOG("CUPnPDownloadItemResolver::DeleteTempDownloadFilesL begin"); |
|
331 |
|
332 RFs fs; |
|
333 User::LeaveIfError( fs.Connect() ); |
|
334 CleanupClosePushL( fs ); |
|
335 |
|
336 CFileMan* fileMan = CFileMan::NewL( fs ); |
|
337 CleanupStack::PushL( fileMan ); |
|
338 _LIT( KAnyChar, "*"); |
|
339 _LIT( KAnyExtension, "*.*"); |
|
340 _LIT( KUpnpUploadTempDirectory, "temp\\" ); |
|
341 |
|
342 // clean selected download directory |
|
343 HBufC* path = HBufC::NewLC( KMaxFileName ); |
|
344 CUPnPSettingsEngine* settingsEngine = CUPnPSettingsEngine::NewL(); |
|
345 CleanupStack::PushL( settingsEngine ); |
|
346 HBufC* copyLocation = HBufC::NewL( KMaxFileName ); |
|
347 CleanupStack::PushL( copyLocation ); |
|
348 TBool copyLocationIsPhoneMemory = 0; // not used in this case |
|
349 TPtr copyLocationPtr( copyLocation->Des() ); |
|
350 settingsEngine->GetCopyLocationL( copyLocationPtr, |
|
351 copyLocationIsPhoneMemory ); |
|
352 path->Des().Append( *copyLocation ); |
|
353 path->Des().Append( KAnyChar ); |
|
354 path->Des().Append( KTempPrefix ); |
|
355 path->Des().Append( KAnyExtension ); |
|
356 fileMan->Delete( *path ); |
|
357 |
|
358 path->Des().Zero(); |
|
359 path->Des().Append( *copyLocation ); |
|
360 path->Des().Append( KUpnpUploadTempDirectory ); |
|
361 path->Des().Append( KAnyExtension ); |
|
362 fileMan->Delete( *path ); |
|
363 |
|
364 CleanupStack::PopAndDestroy( copyLocation ); |
|
365 CleanupStack::PopAndDestroy( settingsEngine ); |
|
366 CleanupStack::PopAndDestroy( path ); |
|
367 |
|
368 CleanupStack::PopAndDestroy( fileMan ); |
|
369 CleanupStack::PopAndDestroy( &fs ); |
|
370 |
|
371 __LOG("CUPnPDownloadItemResolver::DeleteTempDownloadFilesL End"); |
|
372 } |
|
373 |
|
374 // -------------------------------------------------------------------------- |
|
375 // CUPnPDownloadItemResolver::Complete |
|
376 //--------------------------------------------------------------------------- |
|
377 void CUPnPDownloadItemResolver::Complete( TInt aError ) |
|
378 { |
|
379 __ASSERTD( iState == EStateResolving || iState == EStateDownloading, |
|
380 __FILE__, __LINE__ ); |
|
381 |
|
382 if ( iDownloadSession != 0 ) |
|
383 { |
|
384 iAvController.StopDownloadSession( *iDownloadSession ); |
|
385 iDownloadSession = 0; |
|
386 } |
|
387 |
|
388 MUPnPItemResolverObserver& observer = *iObserver; |
|
389 iObserver = 0; |
|
390 if ( aError == KErrNone ) |
|
391 { |
|
392 iState = EStateReady; |
|
393 } |
|
394 else |
|
395 { |
|
396 iState = EStateIdle; |
|
397 Cleanup(); |
|
398 } |
|
399 |
|
400 observer.ResolveComplete( *this, aError ); |
|
401 } |
|
402 |
|
403 // -------------------------------------------------------------------------- |
|
404 // CUPnPDownloadItemResolver::Cleanup |
|
405 //--------------------------------------------------------------------------- |
|
406 void CUPnPDownloadItemResolver::Cleanup() |
|
407 { |
|
408 iObserver = 0; |
|
409 iFile.Close(); |
|
410 |
|
411 if ( iDownloadSession != 0 ) |
|
412 { |
|
413 iAvController.StopDownloadSession( *iDownloadSession ); |
|
414 iDownloadSession = 0; |
|
415 } |
|
416 |
|
417 if ( iLocalFile ) |
|
418 { |
|
419 // delete the local file |
|
420 iFsSession.Delete( iLocalFile->Des() ); |
|
421 __LOG1( "DownloadItemResolver: deleted local file(%d)", iLocalFile ); |
|
422 delete iLocalFile; |
|
423 iLocalFile = 0; |
|
424 } |
|
425 |
|
426 iFsSession.Close(); |
|
427 |
|
428 iState = EStateIdle; |
|
429 } |
|
430 |
|
431 // -------------------------------------------------------------------------- |
|
432 // CUPnPDownloadItemResolver::CreateTmpFileNameL |
|
433 //--------------------------------------------------------------------------- |
|
434 HBufC* CUPnPDownloadItemResolver::CreateTmpFileNameL() |
|
435 { |
|
436 __LOG( "DownloadItemResolver::CreateTmpFileName" ); |
|
437 __ASSERTD( iState == EStateResolving, __FILE__, __LINE__ ); |
|
438 |
|
439 HBufC* tempfilename = NULL; |
|
440 HBufC* fileExt = NULL; |
|
441 |
|
442 // Get file extension |
|
443 const CUpnpAttribute* attr = UPnPItemUtility |
|
444 ::FindAttributeByName( iRemoteResolver->Resource(), |
|
445 KAttributeProtocolInfo ); |
|
446 if ( attr != 0 ) |
|
447 { |
|
448 CUpnpDlnaProtocolInfo* pInfo = |
|
449 CUpnpDlnaProtocolInfo::NewL( attr->Value() ); |
|
450 CleanupStack::PushL( pInfo ); |
|
451 fileExt = UPnPCommonUtils::FileExtensionByMimeTypeL( |
|
452 pInfo->ThirdField() ); |
|
453 CleanupStack::PopAndDestroy( pInfo ); |
|
454 pInfo = NULL; |
|
455 } |
|
456 |
|
457 // If file extension exist create whole file name. |
|
458 if( fileExt ) |
|
459 { |
|
460 CleanupStack::PushL( fileExt ); |
|
461 tempfilename = HBufC::NewL( |
|
462 KTempPrefix().Length() + |
|
463 iRemoteResolver->Item().Id().Length() + |
|
464 fileExt->Length() ); |
|
465 CleanupStack::PushL( tempfilename ); |
|
466 // Add prefix |
|
467 tempfilename->Des().Append( KTempPrefix ); |
|
468 // Add item name. Convert 8 to 16 and replace illeagal characters. |
|
469 HBufC8* tmpItemName8 = |
|
470 UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( |
|
471 iRemoteResolver->Item().Id() ); |
|
472 CleanupStack::PushL( tmpItemName8 ); |
|
473 HBufC* itemname = HBufC::NewL( tmpItemName8->Length() ); |
|
474 CleanupStack::PushL( itemname ); |
|
475 itemname->Des().Copy( *tmpItemName8 ); |
|
476 tempfilename->Des().Append( *itemname ); |
|
477 CleanupStack::PopAndDestroy( itemname ); |
|
478 CleanupStack::PopAndDestroy( tmpItemName8 ); |
|
479 // Add file extension |
|
480 tempfilename->Des().Append( *fileExt ); |
|
481 |
|
482 CleanupStack::Pop( tempfilename ); |
|
483 CleanupStack::PopAndDestroy( fileExt ); |
|
484 } |
|
485 else // Create without file extension |
|
486 { |
|
487 tempfilename = HBufC::NewL( |
|
488 KTempPrefix().Length() + iRemoteResolver->Item().Id().Length() ); |
|
489 CleanupStack::PushL( tempfilename ); |
|
490 // Add prefix |
|
491 tempfilename->Des().Append( KTempPrefix ); |
|
492 // Add item name. Convert 8 to 16 and replace illeagal characters. |
|
493 HBufC8* tmpItemName8 = |
|
494 UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( |
|
495 iRemoteResolver->Item().Id() ); |
|
496 CleanupStack::PushL( tmpItemName8 ); |
|
497 HBufC* itemname = HBufC::NewL( tmpItemName8->Length() ); |
|
498 CleanupStack::PushL( itemname ); |
|
499 itemname->Des().Copy( *tmpItemName8 ); |
|
500 tempfilename->Des().Append( *itemname ); |
|
501 CleanupStack::PopAndDestroy( itemname ); |
|
502 CleanupStack::PopAndDestroy( tmpItemName8 ); |
|
503 |
|
504 CleanupStack::Pop( tempfilename ); |
|
505 } |
|
506 |
|
507 return tempfilename; //transfer ownership |
|
508 } |
|
509 |
|
510 // -------------------------------------------------------------------------- |
|
511 // CUPnPDownloadItemResolver::GetSelectedDownloadLocationL |
|
512 //--------------------------------------------------------------------------- |
|
513 HBufC* CUPnPDownloadItemResolver::GetSelectedDownloadLocationL() |
|
514 { |
|
515 __LOG( "DownloadItemResolver::GetSelectedDownloadLocationL" ); |
|
516 |
|
517 HBufC* copyLocation = HBufC::NewL( KMaxFileName ); |
|
518 CleanupStack::PushL( copyLocation ); |
|
519 TBool copyLocationIsPhoneMemory = 0; |
|
520 TPtr copyLocationPtr( copyLocation->Des() ); |
|
521 TRAPD( error, iSettingsEngine->GetCopyLocationL( |
|
522 copyLocationPtr, copyLocationIsPhoneMemory ) ) |
|
523 |
|
524 // Something wrong in getting copy location. Default to |
|
525 // phone memory. |
|
526 if( error != KErrNone ) |
|
527 { |
|
528 TPtrC phoneDrive( PathInfo::PhoneMemoryRootPath() ); |
|
529 copyLocation->Des().Append( phoneDrive ); |
|
530 } |
|
531 |
|
532 CleanupStack::Pop( copyLocation ); |
|
533 return copyLocation; |
|
534 } |
|
535 |
|
536 // ----------------------------------------------------------------------------- |
|
537 // CUPnPDownloadItemResolver::CreateRFile |
|
538 // ----------------------------------------------------------------------------- |
|
539 // |
|
540 TInt CUPnPDownloadItemResolver::CreateRFile( const TDesC& aFilePath ) |
|
541 { |
|
542 __LOG( "DownloadItemResolver::CreateRFile" ); |
|
543 iFile.Close(); |
|
544 |
|
545 // In some special case, the function Replace() will fail |
|
546 // with error -14(KErrInUse) by using 'EFileWrite' mode. |
|
547 // Maybe some other handler does not close the file. |
|
548 TInt err = iFile.Replace( |
|
549 iFsSession, |
|
550 aFilePath, |
|
551 EFileShareReadersOrWriters ); |
|
552 |
|
553 if( KErrPathNotFound == err ) |
|
554 { |
|
555 __LOG( "Directory not available -> create new" ); |
|
556 iFsSession.MkDirAll( aFilePath ); |
|
557 err = iFile.Create( iFsSession, aFilePath, EFileWrite ); |
|
558 } |
|
559 return err; |
|
560 } |
|
561 |
|
562 // -------------------------------------------------------------------------- |
|
563 // CUPnPDownloadItemResolver::IsLocallySupportedL() |
|
564 // Check if the audio is DLNA supported in remote to local playback |
|
565 // -------------------------------------------------------------------------- |
|
566 // |
|
567 void CUPnPDownloadItemResolver::IsLocallySupportedL( const CUpnpElement& aRes ) |
|
568 { |
|
569 const CUpnpAttribute* attr = |
|
570 &UPnPItemUtility::FindAttributeByNameL( |
|
571 aRes, KAttributeProtocolInfo ); |
|
572 // parse protocol info |
|
573 CUpnpDlnaProtocolInfo* pInfo = NULL; |
|
574 pInfo = CUpnpDlnaProtocolInfo::NewL( attr->Value() ); |
|
575 |
|
576 //if DLNA compliant item |
|
577 if ( pInfo->PnParameter() != KNullDesC8() ) |
|
578 { |
|
579 if( !UPnPDlnaUtility::IsSupportedDlnaProfile( |
|
580 pInfo->PnParameter() ) ) |
|
581 { |
|
582 User::Leave(KErrNotSupported); |
|
583 } |
|
584 } |
|
585 else //if not, check MIME type |
|
586 { |
|
587 if( !UPnPDlnaUtility::IsSupportedMimeType( pInfo->ThirdField() ) ) |
|
588 { |
|
589 User::Leave(KErrNotSupported); |
|
590 } |
|
591 |
|
592 } |
|
593 } |
|
594 |
|
595 |
|
596 |