codhandler/codeng/src/MediaObject.cpp
changeset 0 dd21522fd290
child 37 cb62a4f66ebe
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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: 
       
    15 *      Implementation of class CMediaObjectData.   
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "MediaObject.h"
       
    24 #include "CodDefs.h"
       
    25 #include "CodUtil.h"
       
    26 #include <badesca.h>
       
    27 #include "FileExt.h"
       
    28 #include "CodStatus.h"
       
    29 #include "HeaderField.h"
       
    30 #include <ApmStd.h>
       
    31 
       
    32 
       
    33 // ================= MEMBER FUNCTIONS =======================
       
    34 
       
    35 // ---------------------------------------------------------
       
    36 // CMediaObjectData::NewL()
       
    37 // ---------------------------------------------------------
       
    38 //
       
    39 EXPORT_C CMediaObjectData* CMediaObjectData::NewL()
       
    40     {
       
    41     CMediaObjectData* data = new (ELeave) CMediaObjectData();
       
    42     CleanupStack::PushL( data );
       
    43     data->ConstructL();
       
    44     CleanupStack::Pop( data );
       
    45     return data;
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------
       
    49 // CMediaObjectData::~CMediaObjectData()
       
    50 // ---------------------------------------------------------
       
    51 //
       
    52 EXPORT_C CMediaObjectData::~CMediaObjectData()
       
    53     {
       
    54     delete iIcon;
       
    55     delete iPrice;
       
    56     delete iInfoUrl;
       
    57     delete iInstallNotify;
       
    58     delete iTypes;
       
    59     delete iUrl;
       
    60     delete iDescription;
       
    61     delete iName;
       
    62     delete iSourceUri;
       
    63     
       
    64     delete iFullName;
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------
       
    68 // CMediaObjectData::IsValid()
       
    69 // ---------------------------------------------------------
       
    70 //
       
    71 EXPORT_C TBool CMediaObjectData::IsValid() const
       
    72     {
       
    73     return ( iUrl->Length() && iSize > 0 && iTypes->MdcaCount() );
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------
       
    77 // CMediaObjectData::IsPostOrder()
       
    78 // ---------------------------------------------------------
       
    79 //
       
    80 EXPORT_C TBool CMediaObjectData::IsPostOrder() const
       
    81     {
       
    82     return iIsPostOrder;
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------
       
    86 // CMediaObjectData::Reset()
       
    87 // ---------------------------------------------------------
       
    88 //
       
    89 EXPORT_C void CMediaObjectData::Reset()
       
    90     {
       
    91     iName->Des().Zero();
       
    92     iDescription->Des().Zero();
       
    93     iUrl->Des().Zero();
       
    94     iSize = 0;
       
    95     iTypes->Reset();
       
    96     iInstallNotify->Des().Zero();
       
    97     iInfoUrl->Des().Zero();
       
    98     iPrice->Des().Zero();
       
    99     iIcon->Des().Zero();
       
   100     iSourceUri->Des().Zero();
       
   101     iProgressiveDl = EFalse;
       
   102 	iIsPostOrder = EFalse;
       
   103 	
       
   104 	iDownloadedSize = 0;
       
   105 	iState = EQueued;
       
   106 	iStatusCode = KHttp902UserCancelled;
       
   107 	iResult = KErrGeneral;
       
   108 	iFileName.SetLength( 0 );
       
   109 	iPausable = EFalse;
       
   110 	iUniqueFilenameSet = EFalse;
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------
       
   114 // CMediaObjectData::Name()
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 EXPORT_C TPtrC CMediaObjectData::Name() const
       
   118     {
       
   119     return *iName;
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------
       
   123 // CMediaObjectData::Description()
       
   124 // ---------------------------------------------------------
       
   125 //
       
   126 EXPORT_C TPtrC CMediaObjectData::Description() const
       
   127     {
       
   128     return *iDescription;
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------
       
   132 // CMediaObjectData::Url()
       
   133 // ---------------------------------------------------------
       
   134 //
       
   135 EXPORT_C TPtrC8 CMediaObjectData::Url() const
       
   136     {
       
   137     return *iUrl;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------
       
   141 // CMediaObjectData::Size()
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 EXPORT_C TInt CMediaObjectData::Size() const
       
   145     {
       
   146     return iSize;
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------
       
   150 // CMediaObjectData::DownloadedSize()
       
   151 // ---------------------------------------------------------
       
   152 //
       
   153 EXPORT_C TInt CMediaObjectData::DownloadedSize() const
       
   154     {
       
   155     return iDownloadedSize;
       
   156     }
       
   157 
       
   158 // ---------------------------------------------------------
       
   159 // CMediaObjectData::State()
       
   160 // ---------------------------------------------------------
       
   161 //
       
   162 EXPORT_C TMediaObjectState CMediaObjectData::State() const
       
   163     {
       
   164     return iState;
       
   165     }
       
   166     
       
   167 // ---------------------------------------------------------
       
   168 // CMediaObjectData::Types()
       
   169 // ---------------------------------------------------------
       
   170 //
       
   171 EXPORT_C TPtrC8 CMediaObjectData::Type() const
       
   172     {
       
   173     if ( iTypes->MdcaCount() )
       
   174         {
       
   175         return iTypes->MdcaPoint( 0 );
       
   176         }
       
   177     return TPtrC8( KNullDesC8 );
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------
       
   181 // CMediaObjectData::Types()
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 EXPORT_C const MDesC8Array& CMediaObjectData::Types() const
       
   185     {
       
   186     return *iTypes;
       
   187     }
       
   188 
       
   189 
       
   190 // ---------------------------------------------------------
       
   191 // CMediaObjectData::InstallNotify()
       
   192 // ---------------------------------------------------------
       
   193 //
       
   194 EXPORT_C TPtrC8 CMediaObjectData::InstallNotify() const
       
   195     {
       
   196     return *iInstallNotify;
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------
       
   200 // CMediaObjectData::InfoUrl
       
   201 // ---------------------------------------------------------
       
   202 //
       
   203 EXPORT_C TPtrC8 CMediaObjectData::InfoUrl() const
       
   204     {
       
   205     return *iInfoUrl;
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------
       
   209 // CMediaObjectData::Price()
       
   210 // ---------------------------------------------------------
       
   211 //
       
   212 EXPORT_C TPtrC CMediaObjectData::Price() const
       
   213     {
       
   214     return *iPrice;
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------
       
   218 // CMediaObjectData::Icon()
       
   219 // ---------------------------------------------------------
       
   220 //
       
   221 EXPORT_C TPtrC8 CMediaObjectData::Icon() const
       
   222     {
       
   223     return *iIcon;
       
   224     }
       
   225 
       
   226 // ---------------------------------------------------------
       
   227 // CMediaObjectData::SourceUri()
       
   228 // ---------------------------------------------------------
       
   229 //
       
   230 EXPORT_C TPtrC8 CMediaObjectData::SourceUri() const
       
   231     {
       
   232     return *iSourceUri;
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------
       
   236 // CMediaObjectData::ProgressiveDownload()
       
   237 // ---------------------------------------------------------
       
   238 //
       
   239 EXPORT_C TBool CMediaObjectData::ProgressiveDownload() const
       
   240 	{
       
   241     return iProgressiveDl;
       
   242 	}
       
   243 
       
   244 // ---------------------------------------------------------
       
   245 // CMediaObjectData::HasType()
       
   246 // ---------------------------------------------------------
       
   247 //
       
   248 TInt CMediaObjectData::HasType( const TDesC8& aType ) const
       
   249     {
       
   250     TInt i;
       
   251     return 0 == iTypes->Find( aType, i, ECmpNormal );
       
   252     }
       
   253 
       
   254 // ---------------------------------------------------------
       
   255 // CMediaObjectData::TypesCount()
       
   256 // ---------------------------------------------------------
       
   257 //
       
   258 TInt CMediaObjectData::TypesCount() const
       
   259     {
       
   260     return iTypes->MdcaCount();
       
   261     }
       
   262 
       
   263 // ---------------------------------------------------------
       
   264 // CMediaObjectData::FullName()
       
   265 // ---------------------------------------------------------
       
   266 //
       
   267 TPtrC CMediaObjectData::FullName() const
       
   268 	{
       
   269 	return *iFullName;
       
   270 	}
       
   271 
       
   272 // ---------------------------------------------------------
       
   273 // CMediaObjectData::Pausable()
       
   274 // ---------------------------------------------------------
       
   275 //
       
   276 TBool CMediaObjectData::Pausable() const
       
   277 	{
       
   278 	return iPausable;
       
   279 	}
       
   280 
       
   281 // ---------------------------------------------------------
       
   282 // CMediaObjectData::IsUniqueFilenameSet()
       
   283 // ---------------------------------------------------------
       
   284 //
       
   285 TBool CMediaObjectData::IsUniqueFilenameSet() const
       
   286 	{
       
   287 	return iUniqueFilenameSet;
       
   288 	}
       
   289 
       
   290 // ---------------------------------------------------------
       
   291 // CMediaObjectData::CMediaObjectData()
       
   292 // ---------------------------------------------------------
       
   293 //
       
   294 CMediaObjectData::CMediaObjectData()
       
   295     {
       
   296     }
       
   297 
       
   298 // ---------------------------------------------------------
       
   299 // CMediaObjectData::ConstructL()
       
   300 // ---------------------------------------------------------
       
   301 //
       
   302 void CMediaObjectData::ConstructL()
       
   303     {
       
   304     iName = HBufC::NewL( 0 );
       
   305     iDescription = HBufC::NewL( 0 );
       
   306     iUrl = HBufC8::NewL( 0 );
       
   307     iSize = 0;
       
   308     iTypes = new (ELeave) CDesC8ArrayFlat( KTypeGranularity );
       
   309     iInstallNotify = HBufC8::NewL( 0 );
       
   310     iInfoUrl = HBufC8::NewL( 0 );
       
   311     iPrice = HBufC::NewL( 0 );
       
   312     iIcon = HBufC8::NewL( 0 );
       
   313     iSourceUri = HBufC8::NewL( 0 );
       
   314     
       
   315     iDownloadedSize = 0;
       
   316 	iState = EQueued;
       
   317     iStatusCode = KHttp902UserCancelled;
       
   318     iResult = KErrGeneral;
       
   319     iFileName.SetLength( 0 );
       
   320     iPausable = EFalse;
       
   321     iUniqueFilenameSet = EFalse;
       
   322     iTempPath = KNullDesC;
       
   323     iRootPath = KNullDesC;
       
   324     }
       
   325 
       
   326 // ---------------------------------------------------------
       
   327 // CMediaObjectData::SetNameL()
       
   328 // ---------------------------------------------------------
       
   329 //
       
   330 TBool CMediaObjectData::SetNameL( const TDesC& aName )
       
   331     {
       
   332     return SetStringAttrL( iName, aName, COD_NAME_MAX_LEN );
       
   333     }
       
   334 
       
   335 // ---------------------------------------------------------
       
   336 // CMediaObjectData::SetDescriptionL()
       
   337 // ---------------------------------------------------------
       
   338 //
       
   339 TBool CMediaObjectData::SetDescriptionL( const TDesC& aDescription )
       
   340     {
       
   341     return SetStringAttrL
       
   342         ( iDescription, aDescription, COD_DESCRIPTION_MAX_LEN );
       
   343     }
       
   344 
       
   345 // ---------------------------------------------------------
       
   346 // CMediaObjectData::SetUrlL()
       
   347 // ---------------------------------------------------------
       
   348 //
       
   349 TBool CMediaObjectData::SetUrlL( const TDesC& aUrl )
       
   350     {
       
   351     return SetStringAttrL( iUrl, aUrl, COD_URL_MAX_LEN );
       
   352     }
       
   353 
       
   354 // ---------------------------------------------------------
       
   355 // CMediaObjectData::SetSize()
       
   356 // ---------------------------------------------------------
       
   357 //
       
   358 TBool CMediaObjectData::SetSize( TInt aSize )
       
   359     {
       
   360     if( aSize <= 0 )
       
   361         {
       
   362         return EFalse;
       
   363         }
       
   364     iSize = aSize;
       
   365     return ETrue;
       
   366     }
       
   367 
       
   368 // ---------------------------------------------------------
       
   369 // CMediaObjectData::SetDownloadedSize()
       
   370 // ---------------------------------------------------------
       
   371 //
       
   372 TBool CMediaObjectData::SetDownloadedSize( TInt aSize )
       
   373     {
       
   374     if( aSize < 0 )
       
   375         {
       
   376         return EFalse;
       
   377         }
       
   378     iDownloadedSize = aSize;
       
   379     return ETrue;
       
   380     }
       
   381     
       
   382 // ---------------------------------------------------------
       
   383 // CMediaObjectData::SetState()
       
   384 // ---------------------------------------------------------
       
   385 //
       
   386 void CMediaObjectData::SetState( TMediaObjectState aState )
       
   387     {
       
   388     iState = aState;
       
   389     }
       
   390         
       
   391 // ---------------------------------------------------------
       
   392 // CMediaObjectData::SetTypeL()
       
   393 // ---------------------------------------------------------
       
   394 //
       
   395 TBool CMediaObjectData::SetTypeL( const TDesC& aType )
       
   396     {
       
   397     // Backwards-compatible deprecated method.
       
   398     iTypes->Reset();    // Replace all, support only one type.
       
   399     return AddTypeL( aType );
       
   400     }
       
   401 
       
   402 // ---------------------------------------------------------
       
   403 // CMediaObjectData::AddTypeL()
       
   404 // ---------------------------------------------------------
       
   405 //
       
   406 TBool CMediaObjectData::AddTypeL( const TDesC& aType )
       
   407     {
       
   408     if ( aType.Length() > COD_TYPE_MAX_LEN || !aType.Length() )
       
   409         {
       
   410         return EFalse;
       
   411         }
       
   412     HBufC8* type8 = CodUtil::ConvertLC( aType );
       
   413     iTypes->AppendL( *type8 );
       
   414     CleanupStack::PopAndDestroy( type8 );
       
   415     return ETrue;
       
   416     }
       
   417 
       
   418 // ---------------------------------------------------------
       
   419 // CMediaObjectData::SetInstallNotifyL()
       
   420 // ---------------------------------------------------------
       
   421 //
       
   422 TBool CMediaObjectData::SetInstallNotifyL( const TDesC& aInstallNotify )
       
   423     {
       
   424     return SetStringAttrL
       
   425         ( iInstallNotify, aInstallNotify, COD_INSTALL_NOTIFY_MAX_LEN );
       
   426     }
       
   427 
       
   428 // ---------------------------------------------------------
       
   429 // CMediaObjectData::SetInfoUrlL()
       
   430 // ---------------------------------------------------------
       
   431 //
       
   432 TBool CMediaObjectData::SetInfoUrlL( const TDesC& aInfoUrl )
       
   433     {
       
   434     return SetStringAttrL( iInfoUrl, aInfoUrl, COD_INFO_URL_MAX_LEN );
       
   435     }
       
   436 
       
   437 // ---------------------------------------------------------
       
   438 // CMediaObjectData::SetPriceL()
       
   439 // ---------------------------------------------------------
       
   440 //
       
   441 TBool CMediaObjectData::SetPriceL( const TDesC& aPrice )
       
   442     {
       
   443     return SetStringAttrL( iPrice, aPrice, COD_PRICE_MAX_LEN );
       
   444     }
       
   445 
       
   446 // ---------------------------------------------------------
       
   447 // CMediaObjectData::SetIconL()
       
   448 // ---------------------------------------------------------
       
   449 //
       
   450 TBool CMediaObjectData::SetIconL( const TDesC& aIcon )
       
   451     {
       
   452     return SetStringAttrL( iIcon, aIcon, COD_ICON_MAX_LEN );
       
   453     }
       
   454 
       
   455 // ---------------------------------------------------------
       
   456 // CMediaObjectData::SetSourceUriL()
       
   457 // ---------------------------------------------------------
       
   458 //
       
   459 void CMediaObjectData::SetSourceUriL( const TDesC8& aSourceUri )
       
   460     {
       
   461     HBufC8* buf = aSourceUri.AllocL();
       
   462     delete iSourceUri;
       
   463     iSourceUri = buf;
       
   464     }
       
   465 
       
   466 // ---------------------------------------------------------
       
   467 // CMediaObjectData::SetProgressiveDownload()
       
   468 // ---------------------------------------------------------
       
   469 //
       
   470 void CMediaObjectData::SetProgressiveDownload( TBool aProgressiveDl )
       
   471     {
       
   472     iProgressiveDl = aProgressiveDl;
       
   473     }
       
   474 
       
   475 // ---------------------------------------------------------
       
   476 // CMediaObjectData::UniqueFilenameSet()
       
   477 // ---------------------------------------------------------
       
   478 //
       
   479 void CMediaObjectData::UniqueFilenameSet( TBool aUniqueFilenameSet )
       
   480     {
       
   481     iUniqueFilenameSet = aUniqueFilenameSet;
       
   482     }
       
   483 
       
   484 // ---------------------------------------------------------
       
   485 // CMediaObjectData::SetOrderIsPost()
       
   486 // ---------------------------------------------------------
       
   487 //
       
   488 void CMediaObjectData::SetOrderIsPost( TBool aIsPostOrder )
       
   489     {
       
   490     iIsPostOrder = aIsPostOrder;
       
   491     }
       
   492 
       
   493 // ---------------------------------------------------------
       
   494 // CMediaObjectData::SetStringAttrL()
       
   495 // ---------------------------------------------------------
       
   496 //
       
   497 TBool CMediaObjectData::SetStringAttrL
       
   498 ( HBufC*& aBuf, const TDesC& aString, TInt aMaxLength )
       
   499     {
       
   500     HBufC* buf;
       
   501     if ( aString.Length() > aMaxLength )
       
   502         {
       
   503         buf = aString.Mid(0,aMaxLength).AllocL();
       
   504         }
       
   505     else
       
   506         {
       
   507         buf = aString.AllocL();        
       
   508         }
       
   509   
       
   510     delete aBuf;
       
   511     aBuf = buf;
       
   512     return ETrue;
       
   513     }
       
   514 
       
   515 // ---------------------------------------------------------
       
   516 // CMediaObjectData::SetStringAttrL()
       
   517 // ---------------------------------------------------------
       
   518 //
       
   519 TBool CMediaObjectData::SetStringAttrL
       
   520 ( HBufC8*& aBuf, const TDesC& aString, TInt /*aMaxLength*/ )
       
   521     {
       
   522     HBufC8* buf = CodUtil::ConvertL( aString );
       
   523     delete aBuf;
       
   524     aBuf = buf;
       
   525     return ETrue;
       
   526     }
       
   527 
       
   528 // ---------------------------------------------------------
       
   529 // CMediaObjectData::StoreMediaInfoL()
       
   530 // ---------------------------------------------------------
       
   531 //
       
   532 void CMediaObjectData::StoreMediaInfoL( TPtr8& aBuf, const CArrayPtrFlat<CHeaderField>* aHeaders ) const
       
   533 	{
       
   534 	AppendBufL( aBuf, iName );
       
   535 	AppendBufL( aBuf, iUrl );
       
   536 	APPEND_BUF_INT( aBuf, iSize );
       
   537 	AppendBufL( aBuf, iPrice );
       
   538 	APPEND_BUF_INT( aBuf, iProgressiveDl );
       
   539 	AppendBufL( aBuf, iSourceUri );
       
   540 	AppendBufL( aBuf, iInstallNotify );
       
   541 	AppendContentTypesL( aBuf, iTypes );
       
   542 	
       
   543 	APPEND_BUF_INT( aBuf, iState );
       
   544     APPEND_BUF_INT( aBuf, iStatusCode );
       
   545     APPEND_BUF_INT( aBuf, iResult );
       
   546     APPEND_BUF_INT( aBuf, iPausable );    
       
   547     APPEND_BUF_INT( aBuf, iUniqueFilenameSet );
       
   548 
       
   549     AppendBufL( aBuf, iFullName );
       
   550 
       
   551     HBufC* buf1 = iTempPath.AllocLC();
       
   552 	AppendBufL(aBuf,buf1);
       
   553 	
       
   554 	HBufC* buf2 = iRootPath.AllocLC();
       
   555 	AppendBufL(aBuf,buf2);
       
   556 	
       
   557 	CleanupStack::PopAndDestroy(2,buf1);
       
   558 		
       
   559 	AppendHeadersL(aBuf, aHeaders );
       
   560 	}
       
   561 
       
   562 // ---------------------------------------------------------
       
   563 // CMediaObjectData::AppendHeadersL()
       
   564 // ---------------------------------------------------------
       
   565 //
       
   566 void CMediaObjectData::AppendHeadersL( TPtr8& aBuf,
       
   567                                     const CArrayPtrFlat<CHeaderField>* aHeaders ) const
       
   568     {
       
   569     
       
   570     if(!aHeaders)
       
   571         {
       
   572         TInt hdrCnt = 0;
       
   573         APPEND_BUF_INT( aBuf, hdrCnt );
       
   574         return;
       
   575         }
       
   576         
       
   577     TInt headers = aHeaders->Count();
       
   578     APPEND_BUF_INT( aBuf, headers );
       
   579 
       
   580     HBufC8* fieldName = NULL;
       
   581     HBufC8* fieldRawData = NULL;
       
   582 
       
   583     for( TInt i = 0; i < headers; ++i )
       
   584         {
       
   585         
       
   586         fieldName = (*aHeaders)[i]->FieldName();
       
   587         fieldRawData = (*aHeaders)[i]->FieldRawData();
       
   588         AppendBufL( aBuf, fieldName );
       
   589         AppendBufL( aBuf, fieldRawData );
       
   590         
       
   591         }
       
   592     return;    
       
   593     }     
       
   594 
       
   595 // ---------------------------------------------------------
       
   596 // CMediaObjectData::LoadHeadersL()
       
   597 // ---------------------------------------------------------
       
   598 //
       
   599 void CMediaObjectData::LoadHeadersL( RFile& aFile, CArrayPtrFlat<CHeaderField>*& aHeaders )
       
   600 	{
       
   601 
       
   602     if(!aHeaders)
       
   603         {
       
   604         return;
       
   605         }	
       
   606 
       
   607     TInt headers;
       
   608     READ_INT_L( aFile, headers );
       
   609 
       
   610     aHeaders->ResetAndDestroy();
       
   611 
       
   612     for( TInt i = 0; i < headers; ++i )
       
   613         {
       
   614         CHeaderField* field = CHeaderField::NewL();
       
   615         CleanupStack::PushL( field );
       
   616 
       
   617         field->LoadHeaderInfoL( aFile );
       
   618         aHeaders->AppendL( field );
       
   619 
       
   620         CleanupStack::Pop( field );
       
   621         }	
       
   622 	}
       
   623 
       
   624 // ---------------------------------------------------------
       
   625 // CMediaObjectData::LoadStorageInfoL()
       
   626 // ---------------------------------------------------------
       
   627 //	
       
   628 void CMediaObjectData::LoadMediaInfoL( RFile& aInFile, RFs &aFs, CArrayPtrFlat<CHeaderField>*& aHeaders )
       
   629 	{
       
   630     ReadHBufCL( aInFile, iName );
       
   631     ReadHBufCL( aInFile, iUrl );
       
   632     READ_INT_L( aInFile, iSize );
       
   633     ReadHBufCL( aInFile, iPrice );
       
   634     READ_INT_L( aInFile, iProgressiveDl );
       
   635     ReadHBufCL( aInFile, iSourceUri );
       
   636     ReadHBufCL( aInFile, iInstallNotify );
       
   637     LoadContentTypesL( aInFile, iTypes );
       
   638     
       
   639     READ_INT_L( aInFile, iState );
       
   640     READ_INT_L( aInFile, iStatusCode );
       
   641     READ_INT_L( aInFile, iResult );
       
   642     READ_INT_L( aInFile, iPausable );  
       
   643     READ_INT_L( aInFile, iUniqueFilenameSet );
       
   644     
       
   645     ReadHBufCL( aInFile,iFullName );
       
   646     
       
   647     HBufC* buf1 = NULL;
       
   648     HBufC* buf2 = NULL;	
       
   649     
       
   650     ReadHBufCL(aInFile,buf1);
       
   651     if( buf1->Compare( KNullDesC ))
       
   652         {
       
   653         iTempPath = *buf1;    
       
   654         }    
       
   655 
       
   656     ReadHBufCL(aInFile,buf2);
       
   657     if( buf2->Compare( KNullDesC ))
       
   658         {
       
   659         iRootPath = *buf2;    
       
   660         }      
       
   661     delete buf1;
       
   662     delete buf2;
       
   663           	  
       
   664     LoadHeadersL( aInFile, aHeaders );
       
   665     SetDownloadedFileSizeL( aFs );
       
   666 	}
       
   667 
       
   668 // ---------------------------------------------------------
       
   669 // CMediaObjectData::SetDownloadedFileSize()
       
   670 // ---------------------------------------------------------
       
   671 //	
       
   672 void CMediaObjectData::SetDownloadedFileSizeL( RFs &aFs )
       
   673     {    
       
   674     if( !iFullName )
       
   675         {
       
   676         return;
       
   677         }
       
   678         
       
   679     RFile mediaFile;
       
   680     CleanupClosePushL<RFile>( mediaFile );    
       
   681     TInt err = mediaFile.Open(aFs, 
       
   682                            *iFullName, 
       
   683                            EFileShareReadersOnly | 
       
   684                            EFileRead ) ;	
       
   685 
       
   686 	//KErrPathNotFound will occur when file is downloaded to MMC
       
   687 	//And MMC is removed when next time you launch Browser.
       
   688                   //Other possible errors,  KErrNotFound, KErrBadName
       
   689 	if( err )
       
   690 	    {
       
   691 	    CleanupStack::PopAndDestroy();
       
   692 	    return;
       
   693 	    }
       
   694 		
       
   695     err = mediaFile.Size( iDownloadedSize ) ;
       
   696     User::LeaveIfError ( err );
       
   697     CleanupStack::PopAndDestroy(); // mediaFile
       
   698     }
       
   699     
       
   700 // ---------------------------------------------------------
       
   701 // CMediaObjectData::AppendContentTypes()
       
   702 // ---------------------------------------------------------
       
   703 //	
       
   704 void CMediaObjectData::AppendContentTypesL( TPtr8& aBuf, CDesC8ArrayFlat* aTypes ) const
       
   705 	{
       
   706 	
       
   707 	TInt count = aTypes->MdcaCount();
       
   708 	APPEND_BUF_INT( aBuf,count );
       
   709 
       
   710 	for( TInt i =0 ; i < count ; i++ )
       
   711 		{
       
   712 		HBufC8* buf = HBufC8::NewL( COD_TYPE_MAX_LEN );
       
   713     	
       
   714     	CleanupStack::PushL( buf );
       
   715 
       
   716 		TPtr8 ptr= buf->Des();
       
   717 		ptr = aTypes->MdcaPoint( i );
       
   718 	 	AppendBufL( aBuf, buf );
       
   719 
       
   720 		CleanupStack::PopAndDestroy(/*buf*/);
       
   721 		}
       
   722 	}
       
   723 
       
   724 // ---------------------------------------------------------
       
   725 // CMediaObjectData::LoadContentTypes()
       
   726 // ---------------------------------------------------------
       
   727 //	
       
   728 void CMediaObjectData::LoadContentTypesL( RFile& aInFile, CDesC8ArrayFlat* aTypes )
       
   729 	{
       
   730 	TInt numTypes( 0 );
       
   731 	READ_INT_L( aInFile, numTypes );
       
   732   aTypes->Reset();
       
   733 	for( TInt i = 0 ; i < numTypes ; i++ )
       
   734 	    {
       
   735     	HBufC8* buf = NULL;
       
   736     	ReadHBufCL( aInFile, buf );
       
   737     	CleanupStack::PushL( buf );
       
   738     	aTypes->AppendL( *buf );
       
   739     	CleanupStack::PopAndDestroy(/*buf*/);
       
   740 	    }
       
   741 	}
       
   742 
       
   743 
       
   744 // ---------------------------------------------------------
       
   745 // CMediaObjectData::ReArrangeTypesL()
       
   746 // ---------------------------------------------------------
       
   747 //	
       
   748 void CMediaObjectData::ReArrangeTypesL( TInt aIndex )
       
   749     {
       
   750     const TDataType& type( iTypes->MdcaPoint( aIndex ) );
       
   751     iTypes->Delete(aIndex);
       
   752     iTypes->InsertL(0,type.Des8());	
       
   753     }