mmsengine/mmscodec/src/mmsdecode.cpp
branchRCL_3
changeset 27 7fdbb852d323
parent 26 ebe688cedc25
equal deleted inserted replaced
26:ebe688cedc25 27:7fdbb852d323
   677             MMsvAttachmentManager& attaMan = iStore->AttachmentManagerL();
   677             MMsvAttachmentManager& attaMan = iStore->AttachmentManagerL();
   678             MMsvAttachmentManagerSync& attaManSync = iStore->AttachmentManagerExtensionsL();
   678             MMsvAttachmentManagerSync& attaManSync = iStore->AttachmentManagerExtensionsL();
   679             TInt count = attaMan.AttachmentCount();
   679             TInt count = attaMan.AttachmentCount();
   680             TInt i;
   680             TInt i;
   681             // delete all old attachments as we are starting from the beginning
   681             // delete all old attachments as we are starting from the beginning
   682             for ( i = count - 1; i >= 0; --i )
   682             for ( i = count - 1; i >= 0; i-- )
   683                {
   683                {
   684                attaManSync.RemoveAttachmentL( i );
   684                attaManSync.RemoveAttachmentL( i );
   685                }
   685                }
   686             iStore->CommitL();   
   686             iStore->CommitL();   
   687             });
   687             });
   786 // ---------------------------------------------------------
   786 // ---------------------------------------------------------
   787 //
   787 //
   788 void CMmsDecode::SelectNextState()
   788 void CMmsDecode::SelectNextState()
   789     {
   789     {
   790 
   790 
   791     // If appropriate, the functions called within the switch statement
   791     // If appropiate, the functions called within the switch statement
   792     // will make us active again. If all is done, the asynchronous request
   792     // will make us active again. If all is done, the asynchronous request
   793     // will complete
   793     // will complete
   794 
   794 
   795     switch ( iState )
   795     switch ( iState )
   796         {
   796         {
  1299             // we only keep the first part from multipart/report
  1299             // we only keep the first part from multipart/report
  1300             MMsvAttachmentManager& attaMan = iStore->AttachmentManagerL();
  1300             MMsvAttachmentManager& attaMan = iStore->AttachmentManagerL();
  1301             MMsvAttachmentManagerSync& attaManSync = iStore->AttachmentManagerExtensionsL();
  1301             MMsvAttachmentManagerSync& attaManSync = iStore->AttachmentManagerExtensionsL();
  1302             TInt count = attaMan.AttachmentCount();
  1302             TInt count = attaMan.AttachmentCount();
  1303             TInt i;
  1303             TInt i;
  1304             for ( i = count - 1; i > 0; --i )
  1304             for ( i = count - 1; i > 0; i-- )
  1305                 {
  1305                 {
  1306                 attaManSync.RemoveAttachmentL( i );
  1306                 attaManSync.RemoveAttachmentL( i );
  1307                 }
  1307                 }
  1308             }
  1308             }
  1309         });
  1309         });
  1780 #ifndef _NO_MMSS_LOGGING_
  1780 #ifndef _NO_MMSS_LOGGING_
  1781     // this may produce a long log - but only if the message is weird
  1781     // this may produce a long log - but only if the message is weird
  1782     TUint i;
  1782     TUint i;
  1783     TUint8 byte;
  1783     TUint8 byte;
  1784     TBuf<1> character;
  1784     TBuf<1> character;
  1785     for ( i = iPosition; i < iPosition + length && i < iLength; ++i )
  1785     for ( i = iPosition; i < iPosition + length && i < iLength; i++ )
  1786         {
  1786         {
  1787         iDecodeBuffer->Read(i, &byte, 1);
  1787         iDecodeBuffer->Read(i, &byte, 1);
  1788         TUint16 word = byte;
  1788         TUint16 word = byte;
  1789         if ( byte >= KMms0x20 && byte < KMms0x7F )
  1789         if ( byte >= KMms0x20 && byte < KMms0x7F )
  1790             {
  1790             {
  2509         }
  2509         }
  2510 
  2510 
  2511     TUint i;
  2511     TUint i;
  2512     TUint length;
  2512     TUint length;
  2513     length = byte;
  2513     length = byte;
  2514     for ( i = 0;  i < length && iPosition < iLength; ++i)
  2514     for ( i = 0;  i < length && iPosition < iLength; i++)
  2515         {
  2515         {
  2516         integer <<= KMmsBitsInByte;
  2516         integer <<= KMmsBitsInByte;
  2517         iDecodeBuffer->Read(iPosition, &byte, 1);
  2517         iDecodeBuffer->Read(iPosition, &byte, 1);
  2518         iPosition++;
  2518         iPosition++;
  2519         integer += byte;
  2519         integer += byte;
  2561 
  2561 
  2562     TUint i;
  2562     TUint i;
  2563     TUint length;
  2563     TUint length;
  2564     length = byte;
  2564     length = byte;
  2565 
  2565 
  2566     for ( i = 0;  i < length && iPosition < iLength; ++i)
  2566     for ( i = 0;  i < length && iPosition < iLength; i++)
  2567         {
  2567         {
  2568         veryLongInteger <<= KMmsBitsInByte;
  2568         veryLongInteger <<= KMmsBitsInByte;
  2569         iDecodeBuffer->Read(iPosition, &byte, 1);
  2569         iDecodeBuffer->Read(iPosition, &byte, 1);
  2570         iPosition++;
  2570         iPosition++;
  2571         veryLongInteger += TUint( byte );
  2571         veryLongInteger += TUint( byte );
  3654     // To handle X-headers and Java apllication id parameters,
  3654     // To handle X-headers and Java apllication id parameters,
  3655     // the text string is offered to caller.
  3655     // the text string is offered to caller.
  3656     // The header has been set to KMmsTextHeader to indicate that the field value
  3656     // The header has been set to KMmsTextHeader to indicate that the field value
  3657     // is still available.
  3657     // is still available.
  3658 
  3658 
       
  3659     if ( ( header < 0 ) && ( iPosition < iLength ) )
       
  3660         {
       
  3661         SkipFieldValue();
       
  3662         }
  3659 
  3663 
  3660     return header;
  3664     return header;
  3661     }
  3665     }
  3662 
  3666 
  3663 // ---------------------------------------------------------
  3667 // ---------------------------------------------------------
  3790     // we may have a multipart structure or a single monoblock data body
  3794     // we may have a multipart structure or a single monoblock data body
  3791     // we handle both here.
  3795     // we handle both here.
  3792     // The momoblock structure probably won't work correctly in chunked mode
  3796     // The momoblock structure probably won't work correctly in chunked mode
  3793     // but it is not supposed to be supported anyway.
  3797     // but it is not supposed to be supported anyway.
  3794     
  3798     
  3795     // Before this function is called in the chunked mode we have checked
  3799     // Before this funtion is called in the chunked mode we have checked
  3796     // that we have enough data to cover all the headers (the length of the
  3800     // that we have enough data to cover all the headers (the length of the
  3797     // headers is given in the beginning)
  3801     // headers is given in the beginning)
  3798     
  3802     
  3799     if ( iMultipartType != 0 )
  3803     if ( iMultipartType != 0 )
  3800         {
  3804         {
  4380                 else
  4384                 else
  4381                     {
  4385                     {
  4382                     CBufFlat* shortBuffer = CBufFlat::NewL( KMms2 );
  4386                     CBufFlat* shortBuffer = CBufFlat::NewL( KMms2 );
  4383                     CleanupStack::PushL( shortBuffer );
  4387                     CleanupStack::PushL( shortBuffer );
  4384                     shortBuffer->ResizeL( KMms2 );
  4388                     shortBuffer->ResizeL( KMms2 );
  4385                     // no need to put it into cleanupstack... we don't leave before we delete it
  4389                     // no need to put it into cleanupstack... we dont't leave before we delete it
  4386                     TUint8 byte;
  4390                     TUint8 byte;
  4387                     // put little-endian BOM to buffer
  4391                     // put little-endian BOM to buffer
  4388                     byte = 0xFF;
  4392                     byte = 0xFF;
  4389                     shortBuffer->Write( 0, &byte, 1 );
  4393                     shortBuffer->Write( 0, &byte, 1 );
  4390                     byte = 0xFE;
  4394                     byte = 0xFE;
  4598     // amr part in addition to possible one smil
  4602     // amr part in addition to possible one smil
  4599     
  4603     
  4600     if ( iSmilCount <= 1 && iAudioCount == 1 &&
  4604     if ( iSmilCount <= 1 && iAudioCount == 1 &&
  4601        ( iAttaNumber == iSmilCount + iAudioCount ) )
  4605        ( iAttaNumber == iSmilCount + iAudioCount ) )
  4602         {
  4606         {
  4603          if(!CheckDRMContent())
  4607          if(!CheckDRMContentL())
  4604              {
  4608              {
  4605                 TBool audioSupported = EFalse;
  4609                 TBool audioSupported = EFalse;
  4606                 TRAP_IGNORE(
  4610                 TRAP_IGNORE(
  4607                     {
  4611                     {
  4608                     FeatureManager::InitializeLibL();
  4612                     FeatureManager::InitializeLibL();
  4648 
  4652 
  4649 // ---------------------------------------------------------
  4653 // ---------------------------------------------------------
  4650 // CMmsDecode::CheckDRMContent
  4654 // CMmsDecode::CheckDRMContent
  4651 // ---------------------------------------------------------
  4655 // ---------------------------------------------------------
  4652 //
  4656 //
  4653 TBool CMmsDecode::CheckDRMContent()
  4657 TBool CMmsDecode::CheckDRMContentL()
  4654     {
  4658     {
  4655     CFileProtectionResolver* resolver = CFileProtectionResolver::NewLC( iFs);
  4659     CFileProtectionResolver* resolver = CFileProtectionResolver::NewLC( iFs);
  4656 
  4660 
  4657     CMsvStore* store = iEntryWrapper->ReadStoreL();
  4661     CMsvStore* store = iEntryWrapper->ReadStoreL();
  4658     CleanupStack::PushL( store );
  4662     CleanupStack::PushL( store );
  4660     
  4664     
  4661     TInt attaCount = attaManager.AttachmentCount();
  4665     TInt attaCount = attaManager.AttachmentCount();
  4662     TInt flCount = 0;
  4666     TInt flCount = 0;
  4663     TInt sdCount = 0;
  4667     TInt sdCount = 0;
  4664 
  4668 
  4665     for ( TInt i = 0; i < attaCount; ++i )
  4669     for ( TInt i = 0; i < attaCount; i++ )
  4666         {
  4670         {
  4667         CMsvAttachment* info = attaManager.GetAttachmentInfoL( i );
  4671         CMsvAttachment* info = attaManager.GetAttachmentInfoL( i );
  4668         CleanupStack::PushL( info );
  4672         CleanupStack::PushL( info );
  4669         TDataType dataType( info->MimeType() );
  4673         TDataType dataType( info->MimeType() );
  4670         if(dataType.Des8().Match(KmmsSmilMimeType) != KErrNotFound)
  4674         if(dataType.Des8().Match(KmmsSmilMimeType) != KErrNotFound)
  4931     // Very simple check to see if string is "safe" ASCII
  4935     // Very simple check to see if string is "safe" ASCII
  4932     // Used for headers, which are short strings
  4936     // Used for headers, which are short strings
  4933 
  4937 
  4934     TInt i;
  4938     TInt i;
  4935     TBool safe = ETrue;
  4939     TBool safe = ETrue;
  4936     for ( i = 0; i < aString.Length() && safe; ++i )
  4940     for ( i = 0; i < aString.Length() && safe; i++ )
  4937         {
  4941         {
  4938         if ( aString[i] < KMmsLowestAscii || aString[i] >= KMmsHighestAscii )
  4942         if ( aString[i] < KMmsLowestAscii || aString[i] >= KMmsHighestAscii )
  4939             {
  4943             {
  4940             safe = EFalse;
  4944             safe = EFalse;
  4941             }
  4945             }