|
1 /* |
|
2 * Copyright (c) 2005-2008 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: Upnp framework's common utility functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 // System |
|
21 #include <e32std.h> |
|
22 #include <upnpstring.h> |
|
23 #include <apmrec.h> |
|
24 #include <apgcli.h> |
|
25 #include <WlanCdbCols.h> // WLAN_SERVICE |
|
26 #include <caf/content.h> // CAF (WM-DRM check) |
|
27 #include <caf/agent.h> // CAF (WM-DRM check) |
|
28 #include <commdb.h> |
|
29 #include <in_sock.h> |
|
30 #include <pathinfo.h> |
|
31 |
|
32 // upnp stack api |
|
33 #include <upnpcontainerlist.h> |
|
34 #include <upnpcontainer.h> |
|
35 #include <upnpitem.h> |
|
36 #include <upnpdevice.h> |
|
37 |
|
38 // upnpframework / avcontroller helper api |
|
39 #include <upnpconstantdefs.h> |
|
40 |
|
41 // utilities internal |
|
42 #include "upnpfileutilitytypes.h" |
|
43 #include "upnpcommonutils.h" |
|
44 |
|
45 _LIT( KComponentLogfile, "upnputilities.txt"); |
|
46 #include "upnplog.h" |
|
47 |
|
48 // CONSTANTS |
|
49 _LIT8( KMimeAudio, "audio" ); |
|
50 _LIT8( KMimeVideo, "video" ); |
|
51 _LIT8( KMimeImage, "image" ); |
|
52 _LIT8( KMimePlaylist, "audio/mpegurl" ); |
|
53 |
|
54 _LIT16( KXHtml16, ".XHTML" ); |
|
55 _LIT16( KHtml16, ".HTML" ); |
|
56 _LIT16( KXml16, ".XML" ); |
|
57 _LIT16( KTxt16, ".TXT" ); |
|
58 _LIT16( KJpeg16, ".JPEG" ); |
|
59 _LIT16( KJpg16, ".JPG" ); |
|
60 _LIT16( KGif16, ".GIF" ); |
|
61 _LIT16( KPng16, ".PNG" ); |
|
62 _LIT16( KMpeg16, ".MPEG" ); |
|
63 _LIT16( KMpg16, ".MPG" ); |
|
64 _LIT16( KMpeg416, ".MPEG4" ); |
|
65 _LIT16( KAvi16, ".AVI" ); |
|
66 _LIT16( KMp316, ".MP3" ); |
|
67 _LIT16( KAac16, ".AAC" ); |
|
68 _LIT16( KWma16, ".WMA" ); |
|
69 _LIT8( KXHtml, "application/vnd.pwg-xhtml-print" ); |
|
70 _LIT8( KHtml, "text/html" ); |
|
71 _LIT8( KXml, "text/xml" ); |
|
72 _LIT8( KTxt, "text/plain" ); |
|
73 _LIT8( KJpg, "image/jpeg" ); |
|
74 _LIT8( KGif, "image/gif" ); |
|
75 _LIT8( KPng, "image/png" ); |
|
76 _LIT8( KMpeg, "video/mpeg" ); |
|
77 _LIT8( KMpeg4, "video/mpeg4" ); |
|
78 _LIT8( KMp3, "audio/mpeg" ); |
|
79 _LIT8( KAac, "audio/aac" ); |
|
80 _LIT8( KWma, "audio/x-ms-wma" ); |
|
81 _LIT8( KAvi, "video/x-msvideo" ); |
|
82 |
|
83 |
|
84 _LIT( KLineFeed, "\r\n"); |
|
85 _LIT8( KHttpDes, "http://" ); |
|
86 _LIT( KTemp, "upnpfwtemp"); |
|
87 |
|
88 _LIT8( KUnderScore, "_" ); |
|
89 _LIT8( KStar, "*" ); |
|
90 _LIT8( KColon, ":"); |
|
91 _LIT8( KKorp, "<" ); |
|
92 _LIT8( KProk, ">" ); |
|
93 _LIT8( KQuotation, "\"" ); |
|
94 _LIT8( KDoubleBackSlash, "\\" ); |
|
95 _LIT8( KSlash, "/" ); |
|
96 _LIT8( KQuestionMark, "?" ); |
|
97 _LIT8( KPipe, "|" ); |
|
98 _LIT8( KTab, "\t" ); |
|
99 _LIT8( KSpace, " " ); |
|
100 |
|
101 const TInt KPlaceHolderLength = 28; |
|
102 const TInt KBufferLength = 256; |
|
103 const TInt KBufferLengthSmall = 10; |
|
104 const TInt KCodeSemicolon = 58; |
|
105 const TInt KMask = 0xFF; |
|
106 const TInt KCodeDot = 46; |
|
107 |
|
108 |
|
109 _LIT( KUpnpDateString,"%F%Y-%M-%D"); |
|
110 const TInt KMaxDateStringLength = 30; |
|
111 |
|
112 |
|
113 |
|
114 _LIT8( KAudioSupport, "audio/" ); |
|
115 _LIT8( KImageSupport, "image/" ); |
|
116 _LIT8( KVideoSupport, "video/" ); |
|
117 |
|
118 _LIT8( KImageJpeg, "=JPEG_" ); |
|
119 _LIT8( KImagePng, "=PNG_" ); |
|
120 |
|
121 _LIT8( KAudioAc3, "=AC3" ); |
|
122 _LIT8( KAudioAmr, "=AMR_" ); |
|
123 _LIT8( KAudioAtra, "=ATRAC3plus" ); |
|
124 _LIT8( KAudioLpcm, "=LPCM" ); |
|
125 _LIT8( KAudioMp3, "=MP3" ); |
|
126 _LIT8( KAudioAac, "=AAC_" ); |
|
127 _LIT8( KAudioHeaac, "=HEAAC_" ); |
|
128 _LIT8( KAudioBsac, "=BSAC_" ); |
|
129 _LIT8( KAudioWmab, "=WMABASE" ); |
|
130 _LIT8( KAudioWmaf, "=WMAFULL" ); |
|
131 |
|
132 _LIT8( KAudioWmap, "=WMAPRO" ); |
|
133 _LIT8( KVideoMpeg, "=MPEG" ); |
|
134 _LIT8( KVideoAvc, "=AVC_" ); |
|
135 _LIT8( KVideoWmvm, "=WMVMED_" ); |
|
136 _LIT8( KVideoVmvh, "=WMVHIGH_" ); |
|
137 _LIT8( KVideoWmvh, "=WMVHM_" ); |
|
138 _LIT8( KVideoWmvspll, "=WMVSPLL_" ); |
|
139 _LIT8( KVideoWmvspml, "=WMVSPML_" ); |
|
140 // ============================ LOCAL FUNCTIONS ============================= |
|
141 |
|
142 // -------------------------------------------------------------------------- |
|
143 // UPnPCommonUtils::MemoryCardStateL |
|
144 //--------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C TBool UPnPCommonUtils::MemoryCardStateL() |
|
147 { |
|
148 TDriveInfo driveInfo; |
|
149 |
|
150 TBool status = EFalse; |
|
151 RFs fileServer; |
|
152 User::LeaveIfError( fileServer.Connect() ); |
|
153 CleanupClosePushL( fileServer ); |
|
154 TInt error = fileServer.Drive( driveInfo, EDriveE ); |
|
155 CleanupStack::PopAndDestroy( &fileServer ); |
|
156 |
|
157 //check if memory card is present |
|
158 if ( error == KErrNone && driveInfo.iType == EMediaHardDisk ) |
|
159 { |
|
160 status = ETrue; |
|
161 } |
|
162 |
|
163 return status; |
|
164 } |
|
165 |
|
166 // -------------------------------------------------------------------------- |
|
167 // UPnPCommonUtils::ResolveMimeTypeL |
|
168 // Resolves the MIME type of a file. Leaves in error cases. |
|
169 // -------------------------------------------------------------------------- |
|
170 EXPORT_C HBufC8* UPnPCommonUtils::ResolveMimeTypeL( const TDesC& aFileName ) |
|
171 { |
|
172 HBufC8* mimetype = NULL; |
|
173 |
|
174 mimetype = GetMimeTypeByExtensionL( aFileName ); |
|
175 |
|
176 // If the mime type was not recognized by the extension, try the |
|
177 // platform mime type recognizer |
|
178 if( !mimetype ) |
|
179 { |
|
180 // finding server |
|
181 RApaLsSession sess; |
|
182 TInt error = sess.Connect(); |
|
183 |
|
184 // We have FS, File and RApaLs open |
|
185 if ( error == KErrNone ) |
|
186 { |
|
187 CleanupClosePushL( sess ); |
|
188 |
|
189 TUid id = TUid::Uid( 0 ); |
|
190 TDataType type; |
|
191 |
|
192 error = sess.AppForDocument( aFileName, id, type ); |
|
193 |
|
194 if( error == KErrNone ) |
|
195 { |
|
196 mimetype = HBufC8::NewL( type.Des8().Length() + |
|
197 KLineFeed().Length() ); |
|
198 mimetype->Des().Append( type.Des8() ); |
|
199 mimetype->Des().Append( KLineFeed() ); |
|
200 } |
|
201 |
|
202 // Clean up |
|
203 CleanupStack::PopAndDestroy( &sess ); |
|
204 } |
|
205 } |
|
206 |
|
207 return mimetype; |
|
208 } |
|
209 |
|
210 // -------------------------------------------------------------------------- |
|
211 // UPnPCommonUtils::GetMimeTypeByExtensionL |
|
212 // Resolves the type of a file. Leaves in error cases. |
|
213 // -------------------------------------------------------------------------- |
|
214 EXPORT_C HBufC8* UPnPCommonUtils::GetMimeTypeByExtensionL( |
|
215 const TDesC& aFileName ) |
|
216 { |
|
217 HBufC8* mimetype = NULL; |
|
218 HBufC* tempFilename = aFileName.AllocL(); |
|
219 CleanupStack::PushL( tempFilename ); |
|
220 |
|
221 // Convert letters to upper case |
|
222 tempFilename->Des().UpperCase(); |
|
223 |
|
224 TParse parse; |
|
225 parse.Set( tempFilename->Des(), NULL, NULL ); |
|
226 TBufC<KMaxName> ext( parse.Ext() ); |
|
227 |
|
228 CleanupStack::PopAndDestroy( tempFilename ); |
|
229 tempFilename = NULL; |
|
230 |
|
231 // FindC and length calculation is used, |
|
232 // because compareC does not work for undefined reason |
|
233 |
|
234 if ( ext.FindC( KHtml16 ) == 0 && |
|
235 ext.Length() == KHtml16().Length() ) |
|
236 { |
|
237 mimetype = HBufC8::NewLC( KHtml().Length() ); |
|
238 mimetype->Des().Zero(); |
|
239 mimetype->Des().Append( KHtml() ); |
|
240 } |
|
241 else if ( ext.FindC( KXml16 ) == 0 && |
|
242 ext.Length() == KXml16().Length() ) |
|
243 { |
|
244 mimetype = HBufC8::NewLC( KXml().Length() ); |
|
245 mimetype->Des().Zero(); |
|
246 mimetype->Des().Append( KXml() ); |
|
247 } |
|
248 else if ( ext.FindC( KTxt16 ) == 0 && |
|
249 ext.Length() == KTxt16().Length() ) |
|
250 { |
|
251 mimetype = HBufC8::NewLC( KTxt().Length() ); |
|
252 mimetype->Des().Zero(); |
|
253 mimetype->Des().Append( KTxt() ); |
|
254 } |
|
255 else if ( ( ext.FindC( KJpg16 ) == 0 && |
|
256 ext.Length() == KJpg16().Length() ) || |
|
257 ( ext.FindC( KJpeg16 ) == 0 && |
|
258 ext.Length() == KJpeg16().Length() ) ) |
|
259 { |
|
260 mimetype = HBufC8::NewLC( KJpg().Length() ); |
|
261 mimetype->Des().Zero(); |
|
262 mimetype->Des().Append( KJpg() ); |
|
263 } |
|
264 else if ( ext.FindC( KGif16 ) == 0 && |
|
265 ext.Length() == KGif16().Length() ) |
|
266 { |
|
267 mimetype = HBufC8::NewLC( KGif().Length() ); |
|
268 mimetype->Des().Zero(); |
|
269 mimetype->Des().Append( KGif() ); |
|
270 } |
|
271 else if ( ext.FindC( KPng16 ) == 0 && |
|
272 ext.Length() == KPng16().Length() ) |
|
273 { |
|
274 mimetype = HBufC8::NewLC( KPng().Length() ); |
|
275 mimetype->Des().Zero(); |
|
276 mimetype->Des().Append( KPng() ); |
|
277 } |
|
278 else if ( ( ext.FindC( KMpg16 ) == 0 && |
|
279 ext.Length() == KMpg16().Length() ) || |
|
280 ( ext.FindC( KMpeg16 ) == 0 && |
|
281 ext.Length() == KMpeg16().Length() ) ) |
|
282 { |
|
283 mimetype = HBufC8::NewLC( KMpeg().Length() ); |
|
284 mimetype->Des().Zero(); |
|
285 mimetype->Des().Append( KMpeg() ); |
|
286 } |
|
287 else if ( ( ext.FindC( KMpeg416 ) == 0 && |
|
288 ext.Length() == KMpeg416().Length() ) ) |
|
289 { |
|
290 mimetype = HBufC8::NewLC( KMpeg4().Length() ); |
|
291 mimetype->Des().Zero(); |
|
292 mimetype->Des().Append( KMpeg4() ); |
|
293 } |
|
294 else if ( ext.FindC( KAvi16 ) == 0 && |
|
295 ext.Length() == KAvi16().Length() ) |
|
296 { |
|
297 mimetype = HBufC8::NewLC( KAvi().Length() ); |
|
298 mimetype->Des().Zero(); |
|
299 mimetype->Des().Append( KAvi() ); |
|
300 } |
|
301 else if ( ext.FindC( KMp316 ) == 0 && |
|
302 ext.Length() == KMp316().Length() ) |
|
303 { |
|
304 mimetype = HBufC8::NewLC( KMp3().Length() ); |
|
305 mimetype->Des().Zero(); |
|
306 mimetype->Des().Append( KMp3() ); |
|
307 } |
|
308 else if ( ext.FindC( KXHtml16 ) == 0 && |
|
309 ext.Length() == KXHtml16().Length() ) |
|
310 { |
|
311 mimetype = HBufC8::NewLC( KXHtml().Length() ); |
|
312 mimetype->Des().Zero(); |
|
313 mimetype->Des().Append( KXHtml() ); |
|
314 } |
|
315 else if ( ext.FindC( KAac16 ) == 0 && |
|
316 ext.Length() == KAac16().Length() ) |
|
317 { |
|
318 mimetype = HBufC8::NewLC( KAac().Length() ); |
|
319 mimetype->Des().Zero(); |
|
320 mimetype->Des().Append( KAac() ); |
|
321 } |
|
322 else if ( ext.FindC( KWma16 ) == 0 && |
|
323 ext.Length() == KWma16().Length() ) |
|
324 { |
|
325 mimetype = HBufC8::NewLC( KWma().Length() ); |
|
326 mimetype->Des().Zero(); |
|
327 mimetype->Des().Append( KWma() ); |
|
328 } |
|
329 else |
|
330 { |
|
331 // Mime type not recognized. Return NULL. |
|
332 } |
|
333 |
|
334 if( mimetype ) |
|
335 { |
|
336 CleanupStack::Pop( mimetype ); |
|
337 } |
|
338 |
|
339 return mimetype; |
|
340 } |
|
341 |
|
342 // -------------------------------------------------------------------------- |
|
343 // UPnPCommonUtils::ResolveFileTypeL |
|
344 // Resolves the MIME type of a file. Leaves in error cases. |
|
345 // -------------------------------------------------------------------------- |
|
346 EXPORT_C TUPnPItemType UPnPCommonUtils::ResolveFileTypeL( |
|
347 const TDesC& aFileName ) |
|
348 { |
|
349 TUPnPItemType returnValue = ETypeOther; |
|
350 |
|
351 if( aFileName != KNullDesC ) |
|
352 { |
|
353 |
|
354 HBufC8* mimetype = NULL; |
|
355 mimetype = ResolveMimeTypeL( aFileName ); |
|
356 if( mimetype ) |
|
357 { |
|
358 CleanupStack::PushL( mimetype ); |
|
359 |
|
360 if( mimetype->Des().Find( KMimeImage() ) >= 0 ) |
|
361 { |
|
362 returnValue = ETypeImage; |
|
363 } |
|
364 else if( mimetype->Des().Find( KMimePlaylist() ) >= 0 ) |
|
365 { |
|
366 returnValue = ETypePlaylist; |
|
367 } |
|
368 else if( mimetype->Des().Find( KMimeAudio() ) >= 0 ) |
|
369 { |
|
370 returnValue = ETypeAudio; |
|
371 } |
|
372 else if( mimetype->Des().Find( KMimeVideo() ) >= 0 ) |
|
373 { |
|
374 returnValue = ETypeVideo; |
|
375 } |
|
376 else |
|
377 { |
|
378 returnValue = ETypeOther; |
|
379 } |
|
380 |
|
381 // Clean up |
|
382 CleanupStack::PopAndDestroy( mimetype ); |
|
383 mimetype = NULL; |
|
384 } |
|
385 else |
|
386 { |
|
387 returnValue = ETypeOther; |
|
388 } |
|
389 } |
|
390 else |
|
391 { |
|
392 User::Leave( KErrArgument ); |
|
393 } |
|
394 |
|
395 return returnValue; |
|
396 } |
|
397 |
|
398 //--------------------------------------------------------------------------- |
|
399 // UPnPCommonUtils::ReplacePlaceHolderInURIL |
|
400 // Replaces IP address and port number placeholders of the RES element's URI |
|
401 // string of the given item. |
|
402 //--------------------------------------------------------------------------- |
|
403 // |
|
404 EXPORT_C void UPnPCommonUtils::ReplacePlaceHolderInURIL( |
|
405 CUpnpItem& aItem, |
|
406 const TInetAddr& aAddress ) |
|
407 { |
|
408 __LOG( "UPnPCommonUtils::ReplacePlaceHolderInURIL" ); |
|
409 |
|
410 const RUPnPElementsArray& elms = aItem.GetElements(); |
|
411 |
|
412 TInt count = elms.Count(); |
|
413 TInt i = 0; |
|
414 for( ; i < count; i++) |
|
415 { |
|
416 if( elms[ i ]->Name() == KElementRes ) |
|
417 { |
|
418 TPtrC8 ptrC( elms[ i ]->Value() ); |
|
419 |
|
420 HBufC8* addrBuf = HBufC8::NewLC( KBufferLength ); |
|
421 addrBuf->Des().Append( KHttpDes ); |
|
422 TBuf8<KBufferLengthSmall> buf; |
|
423 TChar separator( KCodeSemicolon ); |
|
424 TChar dot( KCodeDot ); |
|
425 TUint32 addr = aAddress.Address(); |
|
426 buf.Num( addr >> 24 ); // First part of the ip address |
|
427 addrBuf->Des().Append( buf ); |
|
428 addrBuf->Des().Append( dot ); |
|
429 buf.Num( ( addr >> 16 ) & KMask ); // Second part of ip address |
|
430 addrBuf->Des().Append( buf ); |
|
431 addrBuf->Des().Append( dot ); |
|
432 buf.Num( ( addr >> 8 ) & KMask ); // Third part of the ip address |
|
433 addrBuf->Des().Append( buf ); |
|
434 addrBuf->Des().Append( dot ); |
|
435 buf.Num( addr & KMask ); // last part of the ip address |
|
436 addrBuf->Des().Append( buf ); |
|
437 addrBuf->Des().Append( separator ); |
|
438 |
|
439 buf.Num( aAddress.Port() ); // port number |
|
440 addrBuf->Des().Append( buf ); |
|
441 |
|
442 // Append rest of the uri |
|
443 addrBuf->Des().Append( ptrC.Mid( KPlaceHolderLength ) ); |
|
444 |
|
445 __LOG8( *addrBuf ); |
|
446 |
|
447 elms[ i ]->SetValueL( *addrBuf ); |
|
448 |
|
449 CleanupStack::PopAndDestroy( addrBuf ); |
|
450 i = count; |
|
451 } |
|
452 } |
|
453 } |
|
454 |
|
455 //--------------------------------------------------------------------------- |
|
456 // UPnPCommonUtils::ReplaceIllegalFilenameCharactersL |
|
457 // Replaces the illegal filename characters from the given filename string |
|
458 // and returns a new fixed filename string. 8bit version. |
|
459 //--------------------------------------------------------------------------- |
|
460 // |
|
461 EXPORT_C HBufC8* UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( |
|
462 const TDesC8& aFileName ) |
|
463 { |
|
464 // Note that this implementation is a bit slow since it goes through the |
|
465 // descriptor many times. Only one iteration would be optimal solution. |
|
466 HBufC8* buf = HBufC8::NewLC( aFileName.Length() ); |
|
467 TPtr8 ptr = buf->Des(); |
|
468 ptr.Copy( aFileName ); |
|
469 |
|
470 UpnpString::StringReplaceInPlaceL( ptr, |
|
471 KProk(), |
|
472 KUnderScore() ); |
|
473 UpnpString::StringReplaceInPlaceL( ptr, |
|
474 KKorp(), |
|
475 KUnderScore() ); |
|
476 UpnpString::StringReplaceInPlaceL( ptr, |
|
477 KQuotation(), |
|
478 KUnderScore() ); |
|
479 UpnpString::StringReplaceInPlaceL( ptr, |
|
480 KDoubleBackSlash(), |
|
481 KUnderScore() ); |
|
482 UpnpString::StringReplaceInPlaceL( ptr, |
|
483 KSlash(), |
|
484 KUnderScore() ); |
|
485 UpnpString::StringReplaceInPlaceL( ptr, |
|
486 KStar(), |
|
487 KUnderScore() ); |
|
488 UpnpString::StringReplaceInPlaceL( ptr, |
|
489 KPipe(), |
|
490 KUnderScore() ); |
|
491 UpnpString::StringReplaceInPlaceL( ptr, |
|
492 KColon(), |
|
493 KUnderScore() ); |
|
494 UpnpString::StringReplaceInPlaceL( ptr, |
|
495 KQuestionMark(), |
|
496 KUnderScore() ); |
|
497 UpnpString::StringReplaceInPlaceL( ptr, |
|
498 KTab(), |
|
499 KUnderScore() ); |
|
500 CleanupStack::Pop(); // Can't pop by name, name invalid now |
|
501 return buf; |
|
502 } |
|
503 |
|
504 //--------------------------------------------------------------------------- |
|
505 // UPnPCommonUtils::ReplaceIllegalFilenameCharactersL |
|
506 // Replaces the illegal filename characters from the given filename string |
|
507 // and returns a new fixed filename string. 16bit version. |
|
508 //--------------------------------------------------------------------------- |
|
509 // |
|
510 EXPORT_C HBufC* UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( |
|
511 const TDesC& aFilename ) |
|
512 { |
|
513 HBufC8* convertedParam = NULL; |
|
514 convertedParam = UpnpString::FromUnicodeL( aFilename ); |
|
515 CleanupStack::PushL( convertedParam ); |
|
516 |
|
517 HBufC8* replacedFilename8 = NULL; |
|
518 replacedFilename8 = ReplaceIllegalFilenameCharactersL( *convertedParam ); |
|
519 CleanupStack::PushL( replacedFilename8 ); |
|
520 |
|
521 HBufC* replacedFilename16 = NULL; |
|
522 replacedFilename16 = UpnpString::ToUnicodeL( *replacedFilename8 ); |
|
523 |
|
524 // Clean up |
|
525 CleanupStack::PopAndDestroy( replacedFilename8 ); |
|
526 CleanupStack::PopAndDestroy( convertedParam ); |
|
527 |
|
528 return replacedFilename16; |
|
529 } |
|
530 |
|
531 //--------------------------------------------------------------------------- |
|
532 // UPnPCommonUtils::IsPlaylistContainerL |
|
533 // Checks if the given CUpnpObject is a playlist container. |
|
534 //--------------------------------------------------------------------------- |
|
535 // |
|
536 EXPORT_C TBool UPnPCommonUtils::IsPlaylistContainerL( |
|
537 const CUpnpObject& aContainer ) |
|
538 { |
|
539 TBool returnValue = EFalse; |
|
540 if( aContainer.ObjectType() != EUPnPContainer || |
|
541 aContainer.ObjectClass() == KNullDesC8 ) |
|
542 { |
|
543 User::Leave( KErrArgument ); |
|
544 } |
|
545 else |
|
546 { |
|
547 if( aContainer.ObjectClass().CompareF( KClassPlaylist() ) == 0 ) |
|
548 { |
|
549 returnValue = ETrue; |
|
550 } |
|
551 } |
|
552 return returnValue; |
|
553 } |
|
554 |
|
555 // -------------------------------------------------------------------------- |
|
556 // UPnPCommonUtils::FindContainerByTitle |
|
557 // Finds container from CUpnpContainerList by title field |
|
558 // -------------------------------------------------------------------------- |
|
559 // |
|
560 EXPORT_C CUpnpContainer* UPnPCommonUtils::FindContainerByTitle( |
|
561 const CUpnpContainerList& aList, const TDesC8& aTitle ) |
|
562 { |
|
563 TBool notFound( ETrue ); |
|
564 TInt index( 0 ); |
|
565 CUpnpContainer* tmp( NULL ); |
|
566 |
|
567 while ( index < aList.ObjectCount() && notFound ) |
|
568 { |
|
569 tmp = static_cast< CUpnpContainer* > |
|
570 ( aList[ index ] ); |
|
571 if ( tmp->Title().Compare( aTitle ) == 0 ) |
|
572 { |
|
573 notFound = EFalse; |
|
574 } |
|
575 else |
|
576 { |
|
577 tmp = NULL; |
|
578 } |
|
579 index++; |
|
580 } |
|
581 return tmp; |
|
582 } |
|
583 |
|
584 // -------------------------------------------------------------------------- |
|
585 // UPnPCommonUtils::IntToDesC8LC |
|
586 // Returns IntValue for aObject |
|
587 // -------------------------------------------------------------------------- |
|
588 // |
|
589 EXPORT_C HBufC8* UPnPCommonUtils::IntToDesC8LC( |
|
590 const TInt& aObject ) |
|
591 { |
|
592 HBufC8* buf = HBufC8::NewLC(12); |
|
593 TPtr8 ptrBuf = buf->Des(); |
|
594 |
|
595 ptrBuf.Num(aObject); |
|
596 |
|
597 return buf; |
|
598 } |
|
599 |
|
600 // -------------------------------------------------------------------------- |
|
601 // UPnPCommonUtils::DesC8ToInt |
|
602 // Returns IntValue for aObject |
|
603 // -------------------------------------------------------------------------- |
|
604 // |
|
605 EXPORT_C TInt UPnPCommonUtils::DesC8ToInt( |
|
606 const TDesC8& aObject ) |
|
607 { |
|
608 TLex8 lex( aObject ); |
|
609 |
|
610 TInt lValue( KErrArgument ); |
|
611 |
|
612 lex.Val( lValue ); |
|
613 return lValue; |
|
614 } |
|
615 |
|
616 // -------------------------------------------------------------------------- |
|
617 // UPnPCommonUtils::TTimeToUPnPDateL |
|
618 // see upnpcommonutils.h |
|
619 // -------------------------------------------------------------------------- |
|
620 EXPORT_C HBufC* UPnPCommonUtils::TTimeToUPnPDateL( TTime aTime ) |
|
621 { |
|
622 TBuf<KMaxDateStringLength> date; |
|
623 aTime.FormatL( date, KUpnpDateString ); |
|
624 |
|
625 return date.AllocL(); |
|
626 } |
|
627 |
|
628 // -------------------------------------------------------------------------- |
|
629 // UPnPCommonUtils::RenameFileL |
|
630 // see upnpcommonutils.h |
|
631 // -------------------------------------------------------------------------- |
|
632 EXPORT_C HBufC* UPnPCommonUtils::RenameFileL( const TDesC& aFilePath ) |
|
633 { |
|
634 |
|
635 //get the file extension include '.',e.g .jpg |
|
636 TInt dot = aFilePath.LocateReverse( KCodeDot ); |
|
637 HBufC* extension = NULL; |
|
638 if( dot > 0 ) //if there is extension |
|
639 { |
|
640 extension = aFilePath.Right( aFilePath.Length() - dot ).AllocL(); |
|
641 CleanupStack::PushL( extension ); |
|
642 } |
|
643 else //if there is no extension |
|
644 { |
|
645 dot = aFilePath.Length(); |
|
646 } |
|
647 // get the file path without extension: http://1.2.3//test |
|
648 HBufC* leftString = aFilePath.Left( dot ).AllocL(); |
|
649 CleanupStack::PushL( leftString ); |
|
650 |
|
651 //rename it: http:://1.2.3//test_upnptemp.jpg |
|
652 HBufC* name_upnpfwtemp = NULL; |
|
653 if( extension ) |
|
654 { |
|
655 name_upnpfwtemp = HBufC::NewL( leftString->Length() + |
|
656 KTemp().Length() + |
|
657 extension->Length() ); |
|
658 } |
|
659 else |
|
660 { |
|
661 name_upnpfwtemp = HBufC::NewL( leftString->Length() + |
|
662 KTemp().Length() ); |
|
663 } |
|
664 |
|
665 name_upnpfwtemp->Des().Append( *leftString ); |
|
666 name_upnpfwtemp->Des().Append( KTemp() ); |
|
667 |
|
668 if( extension ) |
|
669 { |
|
670 name_upnpfwtemp->Des().Append( *extension ); |
|
671 } |
|
672 |
|
673 |
|
674 CleanupStack::PopAndDestroy( leftString ); |
|
675 |
|
676 if( extension ) |
|
677 { |
|
678 CleanupStack::PopAndDestroy( extension ); |
|
679 } |
|
680 |
|
681 |
|
682 CleanupStack::PushL( name_upnpfwtemp ); |
|
683 |
|
684 // try to rename the file |
|
685 RFs fsSession; |
|
686 User::LeaveIfError( fsSession.Connect() ); // connect session |
|
687 CleanupClosePushL( fsSession ); |
|
688 |
|
689 TInt error = fsSession.Rename( aFilePath, *name_upnpfwtemp ); |
|
690 |
|
691 CleanupStack::PopAndDestroy( &fsSession ); |
|
692 CleanupStack::Pop( name_upnpfwtemp ); |
|
693 |
|
694 if( KErrNone == error ) |
|
695 { |
|
696 return name_upnpfwtemp; //transfer ownership |
|
697 } |
|
698 else |
|
699 { |
|
700 delete name_upnpfwtemp; |
|
701 return NULL; |
|
702 } |
|
703 |
|
704 } |
|
705 |
|
706 // -------------------------------------------------------------------------- |
|
707 // UPnPCommonUtils::DeleteTempFilesL |
|
708 // see upnpcommonutils.h |
|
709 // -------------------------------------------------------------------------- |
|
710 EXPORT_C void UPnPCommonUtils::DeleteTempFilesL() |
|
711 { |
|
712 __LOG("UPnPCommonUtils::\ |
|
713 DeleteTempFilesL begin"); |
|
714 |
|
715 RFs fs; |
|
716 User::LeaveIfError( fs.Connect() ); // connect session |
|
717 CleanupClosePushL( fs ); |
|
718 |
|
719 CFileMan* fileMan = CFileMan::NewL( fs ); |
|
720 CleanupStack::PushL( fileMan ); |
|
721 _LIT( KAnyChar, "*"); |
|
722 _LIT( KAnyExtension, "*.*"); |
|
723 _LIT( KUpnpUploadTempDirectory, "Download\\Media\\temp\\" ); |
|
724 |
|
725 // clean phone memory |
|
726 HBufC* path = HBufC::NewLC( KMaxFileName ); |
|
727 TPtrC mcDrive( PathInfo::MemoryCardRootPath() ); |
|
728 path->Des().Append( mcDrive ); |
|
729 path->Des().Append( KUpnpUploadDirectory ); |
|
730 path->Des().Append( KAnyChar ); |
|
731 path->Des().Append( KTemp ); |
|
732 path->Des().Append( KAnyExtension ); |
|
733 fileMan->Delete( *path ); |
|
734 |
|
735 path->Des().Zero(); |
|
736 path->Des().Append( mcDrive ); |
|
737 path->Des().Append( KUpnpUploadTempDirectory ); |
|
738 path->Des().Append( KAnyExtension ); |
|
739 fileMan->Delete( *path ); |
|
740 CleanupStack::PopAndDestroy( path ); |
|
741 |
|
742 // clean memory card |
|
743 path = HBufC::NewLC( KMaxFileName ); |
|
744 TPtrC phoneDrive( PathInfo::PhoneMemoryRootPath() ); |
|
745 path->Des().Append( phoneDrive ); |
|
746 path->Des().Append( KUpnpUploadDirectory ); |
|
747 path->Des().Append( KAnyChar ); |
|
748 path->Des().Append( KTemp ); |
|
749 path->Des().Append( KAnyExtension ); |
|
750 fileMan->Delete( *path ); |
|
751 |
|
752 path->Des().Zero(); |
|
753 path->Des().Append( phoneDrive ); |
|
754 path->Des().Append( KUpnpUploadTempDirectory ); |
|
755 path->Des().Append( KAnyExtension ); |
|
756 fileMan->Delete( *path ); |
|
757 CleanupStack::PopAndDestroy( path ); |
|
758 |
|
759 CleanupStack::PopAndDestroy( fileMan ); |
|
760 CleanupStack::PopAndDestroy( &fs ); |
|
761 |
|
762 __LOG("UPnPCommonUtils::\ |
|
763 DeleteTempFilesL end"); |
|
764 } |
|
765 |
|
766 // -------------------------------------------------------------------------- |
|
767 // UPnPCommonUtils::IsImageSupported |
|
768 // see upnpcommonutils.h |
|
769 // -------------------------------------------------------------------------- |
|
770 EXPORT_C TBool UPnPCommonUtils::IsImageSupported( const TDesC8& aProtocolInfo ) |
|
771 { |
|
772 // simple check |
|
773 if( aProtocolInfo.Find( KImageSupport ) >= 0 ) |
|
774 { |
|
775 return ETrue; |
|
776 } |
|
777 |
|
778 |
|
779 // check mime types |
|
780 if( aProtocolInfo.FindC( KImageJpeg ) > 0 ) |
|
781 { |
|
782 return ETrue; |
|
783 } |
|
784 |
|
785 if( aProtocolInfo.FindC( KImagePng ) > 0 ) |
|
786 { |
|
787 return ETrue; |
|
788 } |
|
789 |
|
790 return EFalse; |
|
791 } |
|
792 |
|
793 |
|
794 // -------------------------------------------------------------------------- |
|
795 // UPnPCommonUtils::IsAudioSupported |
|
796 // see upnpcommonutils.h |
|
797 // -------------------------------------------------------------------------- |
|
798 EXPORT_C TBool UPnPCommonUtils::IsAudioSupported( const TDesC8& aProtocolInfo ) |
|
799 { |
|
800 // simple check |
|
801 if( aProtocolInfo.Find( KAudioSupport ) >= 0 ) |
|
802 { |
|
803 return ETrue; |
|
804 } |
|
805 |
|
806 |
|
807 // check mime types |
|
808 if( aProtocolInfo.FindC( KAudioAc3 ) > 0 ) |
|
809 { |
|
810 return ETrue; |
|
811 } |
|
812 |
|
813 if( aProtocolInfo.FindC( KAudioAmr ) > 0 ) |
|
814 { |
|
815 return ETrue; |
|
816 } |
|
817 |
|
818 if( aProtocolInfo.FindC( KAudioAtra ) > 0 ) |
|
819 { |
|
820 return ETrue; |
|
821 } |
|
822 |
|
823 if( aProtocolInfo.FindC( KAudioLpcm ) > 0 ) |
|
824 { |
|
825 return ETrue; |
|
826 } |
|
827 |
|
828 if( aProtocolInfo.FindC( KAudioMp3 ) > 0 ) |
|
829 { |
|
830 return ETrue; |
|
831 } |
|
832 |
|
833 if( aProtocolInfo.FindC( KAudioAac ) > 0 ) |
|
834 { |
|
835 return ETrue; |
|
836 } |
|
837 |
|
838 if( aProtocolInfo.FindC( KAudioHeaac ) > 0 ) |
|
839 { |
|
840 return ETrue; |
|
841 } |
|
842 |
|
843 if( aProtocolInfo.FindC( KAudioBsac ) > 0 ) |
|
844 { |
|
845 return ETrue; |
|
846 } |
|
847 |
|
848 if( aProtocolInfo.FindC( KAudioWmab ) > 0 ) |
|
849 { |
|
850 return ETrue; |
|
851 } |
|
852 |
|
853 if( aProtocolInfo.FindC( KAudioWmaf ) > 0 ) |
|
854 { |
|
855 return ETrue; |
|
856 } |
|
857 |
|
858 if( aProtocolInfo.FindC( KAudioWmap ) > 0 ) |
|
859 { |
|
860 return ETrue; |
|
861 } |
|
862 |
|
863 |
|
864 return EFalse; |
|
865 } |
|
866 |
|
867 |
|
868 |
|
869 |
|
870 // -------------------------------------------------------------------------- |
|
871 // UPnPCommonUtils::IsVideoSupported |
|
872 // see upnpcommonutils.h |
|
873 // -------------------------------------------------------------------------- |
|
874 EXPORT_C TBool UPnPCommonUtils::IsVideoSupported( const TDesC8& aProtocolInfo ) |
|
875 { |
|
876 // simple check |
|
877 if( aProtocolInfo.Find( KVideoSupport ) >= 0 ) |
|
878 { |
|
879 return ETrue; |
|
880 } |
|
881 |
|
882 |
|
883 // check mime types |
|
884 if( aProtocolInfo.FindC( KVideoMpeg ) > 0 ) |
|
885 { |
|
886 return ETrue; |
|
887 } |
|
888 |
|
889 if( aProtocolInfo.FindC( KVideoAvc ) > 0 ) |
|
890 { |
|
891 return ETrue; |
|
892 } |
|
893 |
|
894 if( aProtocolInfo.FindC( KVideoWmvm ) > 0 ) |
|
895 { |
|
896 return ETrue; |
|
897 } |
|
898 |
|
899 if( aProtocolInfo.FindC( KVideoVmvh ) > 0 ) |
|
900 { |
|
901 return ETrue; |
|
902 } |
|
903 |
|
904 if( aProtocolInfo.FindC( KVideoWmvh ) > 0 ) |
|
905 { |
|
906 return ETrue; |
|
907 } |
|
908 |
|
909 if( aProtocolInfo.FindC( KVideoWmvspll ) > 0 ) |
|
910 { |
|
911 return ETrue; |
|
912 } |
|
913 |
|
914 if( aProtocolInfo.FindC( KVideoWmvspml ) > 0 ) |
|
915 { |
|
916 return ETrue; |
|
917 } |
|
918 |
|
919 return EFalse; |
|
920 } |
|
921 |
|
922 // -------------------------------------------------------------------------- |
|
923 // UPnPCommonUtils::FileExtensionByMimeTypeL |
|
924 // See upnpfileutility.h |
|
925 //--------------------------------------------------------------------------- |
|
926 // |
|
927 EXPORT_C HBufC* UPnPCommonUtils::FileExtensionByMimeTypeL( |
|
928 const TDesC8& aMimeType ) |
|
929 { |
|
930 HBufC* fileExt = NULL; |
|
931 |
|
932 // XHTML |
|
933 if( aMimeType.CompareC( KXHtmlMime ) == 0 ) |
|
934 { |
|
935 fileExt = KXHtmlExt().AllocL(); |
|
936 } |
|
937 // HTML |
|
938 else if( aMimeType.CompareC( KHtmlMime ) == 0 ) |
|
939 { |
|
940 fileExt = KHtmlExt().AllocL(); |
|
941 } |
|
942 // XML |
|
943 else if( aMimeType.CompareC( KXmlMime1 ) == 0 || |
|
944 aMimeType.CompareC( KXmlMime2 ) == 0 || |
|
945 aMimeType.CompareC( KXmlMime3 ) == 0 ) |
|
946 { |
|
947 fileExt = KXmlExt().AllocL(); |
|
948 } |
|
949 // TXT |
|
950 else if( aMimeType.CompareC( KTxtMime ) == 0 || |
|
951 aMimeType.CompareC( KTxtMime2 ) == 0 || |
|
952 aMimeType.CompareC( KTxtMime3 ) == 0 || |
|
953 aMimeType.CompareC( KTxtMime4 ) == 0 || |
|
954 aMimeType.CompareC( KTxtMime5 ) == 0 || |
|
955 aMimeType.CompareC( KTxtMime6 ) == 0 ) |
|
956 { |
|
957 fileExt = KTxtExt().AllocL(); |
|
958 } |
|
959 // JPEG |
|
960 else if( aMimeType.CompareC( KJpegMime ) == 0 ) |
|
961 { |
|
962 fileExt = KJpegExt().AllocL(); |
|
963 } |
|
964 // JPG |
|
965 else if( aMimeType.CompareC( KJpegMime2 ) == 0 || |
|
966 aMimeType.CompareC( KJpegMime3 ) == 0 || |
|
967 aMimeType.CompareC( KJpegMime4 ) == 0 || |
|
968 aMimeType.CompareC( KJpegMime5 ) == 0 ) |
|
969 { |
|
970 fileExt = KJpgExt().AllocL(); |
|
971 } |
|
972 // GIF |
|
973 else if( aMimeType.CompareC( KGifMime ) == 0 || |
|
974 aMimeType.CompareC( KGifMime2 ) == 0 || |
|
975 aMimeType.CompareC( KGifMime3 ) == 0 ) |
|
976 { |
|
977 fileExt = KGifExt().AllocL(); |
|
978 } |
|
979 // PNG |
|
980 else if( aMimeType.CompareC( KPngMime ) == 0 || |
|
981 aMimeType.CompareC( KPngMime2 ) == 0 || |
|
982 aMimeType.CompareC( KPngMime3 ) == 0 ) |
|
983 { |
|
984 fileExt = KPngExt().AllocL(); |
|
985 } |
|
986 // MPG |
|
987 else if( aMimeType.CompareC( KMpgMime1 ) == 0 || |
|
988 aMimeType.CompareC( KMpgMime2 ) == 0 || |
|
989 aMimeType.CompareC( KMpgMime3 ) == 0 || |
|
990 aMimeType.CompareC( KMpgMime4 ) == 0 || |
|
991 aMimeType.CompareC( KMpgMime5 ) == 0 || |
|
992 aMimeType.CompareC( KMpgMime6 ) == 0 || |
|
993 aMimeType.CompareC( KMpgMime7 ) == 0 || |
|
994 aMimeType.CompareC( KMpgMime10 ) == 0 ) |
|
995 { |
|
996 fileExt = KMpgExt1().AllocL(); |
|
997 } |
|
998 // MPEG4 |
|
999 else if( aMimeType.CompareC( KMpeg4Mime ) == 0 ) |
|
1000 { |
|
1001 fileExt = KMpeg4Ext().AllocL(); |
|
1002 } |
|
1003 // MP4 |
|
1004 else if( aMimeType.CompareC( KMp4Mime ) == 0 || |
|
1005 aMimeType.CompareC( KMp4Mime2 ) == 0 || |
|
1006 aMimeType.CompareC( KMp4Mime3 ) == 0 ) |
|
1007 { |
|
1008 fileExt = KMp4Ext().AllocL(); |
|
1009 } |
|
1010 // AVI |
|
1011 else if( aMimeType.CompareC( KAviMime1 ) == 0 || |
|
1012 aMimeType.CompareC( KAviMime2 ) == 0 || |
|
1013 aMimeType.CompareC( KAviMime3 ) == 0 || |
|
1014 aMimeType.CompareC( KAviMime4 ) == 0 || |
|
1015 aMimeType.CompareC( KAviMime5 ) == 0 || |
|
1016 aMimeType.CompareC( KAviMime6 ) == 0 || |
|
1017 aMimeType.CompareC( KAviMime7 ) == 0 || |
|
1018 aMimeType.CompareC( KAviMime8 ) == 0 || |
|
1019 aMimeType.CompareC( KAviMime9 ) == 0 ) |
|
1020 { |
|
1021 fileExt = KAviExt().AllocL(); |
|
1022 } |
|
1023 // MP3 |
|
1024 else if( aMimeType.CompareC( KMp3Mime1 ) == 0 || |
|
1025 aMimeType.CompareC( KMp3Mime2 ) == 0 || |
|
1026 aMimeType.CompareC( KMp3Mime3 ) == 0 || |
|
1027 aMimeType.CompareC( KMp3Mime4 ) == 0 || |
|
1028 aMimeType.CompareC( KMp3Mime5 ) == 0 || |
|
1029 aMimeType.CompareC( KMp3Mime6 ) == 0 || |
|
1030 aMimeType.CompareC( KMp3Mime7 ) == 0 || |
|
1031 aMimeType.CompareC( KMp3Mime8 ) == 0 || |
|
1032 aMimeType.CompareC( KMp3Mime9 ) == 0 || |
|
1033 aMimeType.CompareC( KMp3Mime10 ) == 0 ) |
|
1034 { |
|
1035 fileExt = KMp3Ext().AllocL(); |
|
1036 } |
|
1037 // AAC |
|
1038 else if( aMimeType.CompareC( KAacMime ) == 0 || |
|
1039 aMimeType.CompareC( KAacMime2 ) == 0 || |
|
1040 aMimeType.CompareC( KAacMime3 ) == 0 || |
|
1041 aMimeType.CompareC( KAacMime4 ) == 0 ) |
|
1042 { |
|
1043 fileExt = KAacExt().AllocL(); |
|
1044 } |
|
1045 //M4a |
|
1046 else if( aMimeType.CompareC( KM4aMime ) == 0 ) |
|
1047 { |
|
1048 fileExt = KM4aExt().AllocL(); |
|
1049 } |
|
1050 // WMA |
|
1051 else if( aMimeType.CompareC( KWmaMime ) == 0 || |
|
1052 aMimeType.CompareC( KWmaMime2 ) == 0 ) |
|
1053 { |
|
1054 fileExt = KWmaExt().AllocL(); |
|
1055 } |
|
1056 // BMP |
|
1057 else if( aMimeType.CompareC( KBmpMime ) == 0 || |
|
1058 aMimeType.CompareC( KBmpMime2 ) == 0 || |
|
1059 aMimeType.CompareC( KBmpMime3 ) == 0 || |
|
1060 aMimeType.CompareC( KBmpMime4 ) == 0 || |
|
1061 aMimeType.CompareC( KBmpMime5 ) == 0 || |
|
1062 aMimeType.CompareC( KBmpMime6 ) == 0 || |
|
1063 aMimeType.CompareC( KBmpMime7 ) == 0 || |
|
1064 aMimeType.CompareC( KBmpMime8 ) == 0 || |
|
1065 aMimeType.CompareC( KBmpMime9 ) == 0 ) |
|
1066 { |
|
1067 fileExt = KBmpExt().AllocL(); |
|
1068 } |
|
1069 // 3GP |
|
1070 else if( aMimeType.CompareC( KAudio3gpp ) == 0 || |
|
1071 aMimeType.CompareC( KVideo3gpp ) == 0 ) |
|
1072 { |
|
1073 fileExt = K3gpExt().AllocL(); |
|
1074 } |
|
1075 // AMR |
|
1076 else if( aMimeType.CompareC( KAudioAMR ) == 0 ) |
|
1077 { |
|
1078 fileExt = KAmrExt().AllocL(); |
|
1079 } |
|
1080 // WAV |
|
1081 else if( aMimeType.CompareC( KAudioWav ) == 0 || |
|
1082 aMimeType.CompareC( KAudioXWav ) == 0 || |
|
1083 aMimeType.FindC( KAudioL16 ) != KErrNotFound ) |
|
1084 { |
|
1085 fileExt = KWavExt().AllocL(); |
|
1086 } |
|
1087 // Real audio |
|
1088 else if ( aMimeType.CompareC( KRAMime8 ) == 0 ) |
|
1089 { |
|
1090 fileExt = KRAExt().AllocL(); |
|
1091 } |
|
1092 // TTS |
|
1093 else if( aMimeType.CompareC( KVideoTts ) == 0 ) |
|
1094 { |
|
1095 fileExt = KTtsExt().AllocL(); |
|
1096 } |
|
1097 // WMV |
|
1098 else if( aMimeType.CompareC( KWmvMime ) == 0 ) |
|
1099 { |
|
1100 fileExt = KWmvExt().AllocL(); |
|
1101 } |
|
1102 return fileExt; |
|
1103 } |
|
1104 |
|
1105 //--------------------------------------------------------------------------- |
|
1106 // UPnPCommonUtils::FixListboxItemTextL |
|
1107 // Removes the tab character of the given text |
|
1108 // and returns a new fixed text string. 8bit version. |
|
1109 //--------------------------------------------------------------------------- |
|
1110 // |
|
1111 EXPORT_C HBufC8* UPnPCommonUtils::FixListboxItemTextL( const TDesC8& aText ) |
|
1112 { |
|
1113 HBufC8* fixedText = HBufC8::NewLC( aText.Length() ); |
|
1114 TPtr8 ptr = fixedText->Des(); |
|
1115 ptr.Copy( aText ); |
|
1116 |
|
1117 UpnpString::StringReplaceInPlaceL( ptr, |
|
1118 KTab(), |
|
1119 KSpace() ); |
|
1120 CleanupStack::Pop(); // Can't pop by name, name invalid now |
|
1121 return fixedText; |
|
1122 } |
|
1123 |
|
1124 // End of File |