mmsengine/mmscodec/src/mmsencode.cpp
changeset 23 238255e8b033
parent 0 72b543305e3a
child 37 518b245aa84c
child 47 5b14749788d7
child 79 2981cb3aa489
equal deleted inserted replaced
5:4697dfb2d7ad 23:238255e8b033
   851     TMmsLogger::Log( _L("CMmsEncode::EncodeHeadersChunkedL:: start") );
   851     TMmsLogger::Log( _L("CMmsEncode::EncodeHeadersChunkedL:: start") );
   852 #endif /* _NO_MMSS_LOGGING_ */
   852 #endif /* _NO_MMSS_LOGGING_ */
   853     User::LeaveIfError( iEntryWrapper->SetCurrentEntry( iCurrentMessageId ) );
   853     User::LeaveIfError( iEntryWrapper->SetCurrentEntry( iCurrentMessageId ) );
   854     
   854     
   855     /* Korean req: 415-5434
   855     /* Korean req: 415-5434
   856      * Get the target encoding MIB enum from cenrep and encode MMS text objects using coresponding conversion plugins
   856      * Get the target encoding MIB enum from cenrep and encode MMS text objects using corresponding conversion plugins
   857      */
   857      */
   858     TInt temp;
   858     TInt temp;
   859     iTargetEncodingType = 0;
   859     iTargetEncodingType = 0;
   860     CRepository* repository = CRepository::NewLC( KUidMmsServerMtm );    
   860     CRepository* repository = CRepository::NewLC( KUidMmsServerMtm );    
   861     if ( repository->Get( KMmsEncodingType, temp ) == KErrNone )
   861     if ( repository->Get( KMmsEncodingType, temp ) == KErrNone )
   939     if ( iOnlyOneChunk )
   939     if ( iOnlyOneChunk )
   940         {
   940         {
   941 #ifndef _NO_MMSS_LOGGING_
   941 #ifndef _NO_MMSS_LOGGING_
   942         TMmsLogger::Log( _L("CMmsEncode::EncodeHeadersChunkedL:: only one chunk") );
   942         TMmsLogger::Log( _L("CMmsEncode::EncodeHeadersChunkedL:: only one chunk") );
   943 #endif /* _NO_MMSS_LOGGING_ */        // The message is small enough to be sent as one chunk
   943 #endif /* _NO_MMSS_LOGGING_ */        // The message is small enough to be sent as one chunk
   944         for ( i = 0; ( i < iNumberOfAttachments ) && ( iError == KErrNone ); i++ )
   944         for ( i = 0; ( i < iNumberOfAttachments ) && ( iError == KErrNone ); ++i )
   945             {
   945             {
   946             iCurrentAttachment = i;
   946             iCurrentAttachment = i;
   947             // encode attachments, too, as we have decided that our message
   947             // encode attachments, too, as we have decided that our message
   948             // is small enough to fit into the buffer as one chunk
   948             // is small enough to fit into the buffer as one chunk
   949             // DoEncodeAttachment always encodes iCurrentAttachment
   949             // DoEncodeAttachment always encodes iCurrentAttachment
   961         TMmsLogger::Log( _L("CMmsEncode::EncodeHeadersChunkedL:: Multiple chunks") );
   961         TMmsLogger::Log( _L("CMmsEncode::EncodeHeadersChunkedL:: Multiple chunks") );
   962 #endif /* _NO_MMSS_LOGGING_ */        // The message is small enough to be sent as one chunk
   962 #endif /* _NO_MMSS_LOGGING_ */        // The message is small enough to be sent as one chunk
   963         // chunked sending - but it should be possible to calculate data size
   963         // chunked sending - but it should be possible to calculate data size
   964         iOverallDataSize = iPosition; // This is the amount taken by headers
   964         iOverallDataSize = iPosition; // This is the amount taken by headers
   965         // The message is small enough to be sent as one chunk
   965         // The message is small enough to be sent as one chunk
   966         for ( i = 0; ( i < iNumberOfAttachments ) && ( iError == KErrNone ); i++ )
   966         for ( i = 0; ( i < iNumberOfAttachments ) && ( iError == KErrNone ); ++i )
   967             {
   967             {
   968             iCurrentAttachment = i;
   968             iCurrentAttachment = i;
   969             // encode attachments, too, as we have decided that our message
   969             // encode attachments, too, as we have decided that our message
   970             // is small enough to fit into the buffer as one chunk
   970             // is small enough to fit into the buffer as one chunk
   971             // DoEncodeAttachment always encodes iCurrentAttachment
   971             // DoEncodeAttachment always encodes iCurrentAttachment
  1257         CleanupStack::PopAndDestroy( tempContentType );
  1257         CleanupStack::PopAndDestroy( tempContentType );
  1258         aContentTypeString.Set( aAttachmentInfo.MimeType() );
  1258         aContentTypeString.Set( aAttachmentInfo.MimeType() );
  1259         }
  1259         }
  1260         
  1260         
  1261     TInt8 i;
  1261     TInt8 i;
  1262     for ( i = 0; i < KNumberContentTypes && aContentType < 0; i++ )
  1262     for ( i = 0; i < KNumberContentTypes && aContentType < 0; ++i )
  1263         {
  1263         {
  1264         if ( aContentTypeString.CompareF(
  1264         if ( aContentTypeString.CompareF(
  1265             TPtrC8( KContentTypeTable[i] ) ) == 0 )
  1265             TPtrC8( KContentTypeTable[i] ) ) == 0 )
  1266             {
  1266             {
  1267             aContentType = i;
  1267             aContentType = i;
  1292         // Extension media
  1292         // Extension media
  1293         aHeaderLength += aContentTypeString.Length();
  1293         aHeaderLength += aContentTypeString.Length();
  1294         aHeaderLength += 1; // terminating zero
  1294         aHeaderLength += 1; // terminating zero
  1295         }
  1295         }
  1296 
  1296 
  1297     // If we have paramters, we must calculate their length.
  1297     // If we have parameters, we must calculate their length.
  1298     if ( iMimeHeaders->MimeCharset() != 0 )
  1298     if ( iMimeHeaders->MimeCharset() != 0 )
  1299         {
  1299         {
  1300         // charset has well-known encoding
  1300         // charset has well-known encoding
  1301         aHeaderLength += 1;
  1301         aHeaderLength += 1;
  1302         if ( iMimeHeaders->MimeCharset() <= KMmsShortIntegerLimit127 )
  1302         if ( iMimeHeaders->MimeCharset() <= KMmsShortIntegerLimit127 )
  1380                 }
  1380                 }
  1381             }
  1381             }
  1382         }
  1382         }
  1383     if ( ( iMimeHeaders->ContentTypeParams().MdcaCount() % 2 ) == 1 )
  1383     if ( ( iMimeHeaders->ContentTypeParams().MdcaCount() % 2 ) == 1 )
  1384         {
  1384         {
  1385         // Odd number. Obviously last paramter has no value.
  1385         // Odd number. Obviously last parameter has no value.
  1386         // Add the "no value" token
  1386         // Add the "no value" token
  1387         aHeaderLength++;
  1387         aHeaderLength++;
  1388         }
  1388         }
  1389 
  1389 
  1390     // include name parameter to content-type
  1390     // include name parameter to content-type
  1497             {
  1497             {
  1498             // if version is <= 1.2, the filename must be us-ascii
  1498             // if version is <= 1.2, the filename must be us-ascii
  1499             // replace all illegal characters by underscore
  1499             // replace all illegal characters by underscore
  1500             buf8 = HBufC8::NewL( nameLength );
  1500             buf8 = HBufC8::NewL( nameLength );
  1501             CleanupStack::PushL( buf8 );
  1501             CleanupStack::PushL( buf8 );
  1502             for ( j = 0; j < nameLength; j++ )
  1502             for ( j = 0; j < nameLength; ++j )
  1503                 {
  1503                 {
  1504                 oneCharacter.Copy( originalName.Mid( j, 1 ) );
  1504                 oneCharacter.Copy( originalName.Mid( j, 1 ) );
  1505                 if ( !IsStringSafe( oneCharacter ) )
  1505                 if ( !IsStringSafe( oneCharacter ) )
  1506                     {
  1506                     {
  1507                     _LIT( KMmsUnderscore, "_" );
  1507                     _LIT( KMmsUnderscore, "_" );
  1620     // x-type parameters
  1620     // x-type parameters
  1621     // Must be stored as name/value pairs like content-type parameters
  1621     // Must be stored as name/value pairs like content-type parameters
  1622     // X-parameter[i] = parameter name
  1622     // X-parameter[i] = parameter name
  1623     // X-parameter[i+1] = parameter value
  1623     // X-parameter[i+1] = parameter value
  1624     
  1624     
  1625     for ( i = 0; i < iMimeHeaders->XTypeParams().MdcaCount(); i++ )
  1625     for ( i = 0; i < iMimeHeaders->XTypeParams().MdcaCount(); ++i )
  1626         {
  1626         {
  1627         // If we have corrupted parameters (length of name is zero)
  1627         // If we have corrupted parameters (length of name is zero)
  1628         // we skip the name/value pair.
  1628         // we skip the name/value pair.
  1629         // value may be zero, it will be encoded as just the terminating zero
  1629         // value may be zero, it will be encoded as just the terminating zero
  1630         if ( i%2 == 0 &&
  1630         if ( i%2 == 0 &&
  1642             aHeaderLength += iMimeHeaders->XTypeParams().MdcaPoint( i ).Length() + 1;
  1642             aHeaderLength += iMimeHeaders->XTypeParams().MdcaPoint( i ).Length() + 1;
  1643             }
  1643             }
  1644         }
  1644         }
  1645     if ( ( iMimeHeaders->XTypeParams().MdcaCount() % 2 ) == 1 )
  1645     if ( ( iMimeHeaders->XTypeParams().MdcaCount() % 2 ) == 1 )
  1646         {
  1646         {
  1647         // Odd number. Obviously last paramter has no value.
  1647         // Odd number. Obviously last parameter has no value.
  1648         // Add the "no value" token
  1648         // Add the "no value" token
  1649         aHeaderLength++;
  1649         aHeaderLength++;
  1650         }
  1650         }
  1651         
  1651         
  1652     // THESE ARE NOT IMPLEMENTED
  1652     // THESE ARE NOT IMPLEMENTED
  1736     // but maybe something else, too
  1736     // but maybe something else, too
  1737 
  1737 
  1738     temp = KWspCharset | KMms0x80; // encode as short integer
  1738     temp = KWspCharset | KMms0x80; // encode as short integer
  1739     EncodeOptionalInteger( temp, iMimeHeaders->MimeCharset() );
  1739     EncodeOptionalInteger( temp, iMimeHeaders->MimeCharset() );
  1740 
  1740 
  1741     // if we didn't find "Name" parameter among our paramters, we
  1741     // if we didn't find "Name" parameter among our parameters, we
  1742     // put it first.
  1742     // put it first.
  1743 
  1743 
  1744     // we need the name later anyway...
  1744     // we need the name later anyway...
  1745 
  1745 
  1746     if ( !aFoundName )
  1746     if ( !aFoundName )
  1751 
  1751 
  1752     // Then the rest of content type parameters, just text strings.
  1752     // Then the rest of content type parameters, just text strings.
  1753     
  1753     
  1754     TInt i = 0;
  1754     TInt i = 0;
  1755     
  1755     
  1756     for ( i = 0; i < iMimeHeaders->ContentTypeParams().MdcaCount(); i++ )
  1756     for ( i = 0; i < iMimeHeaders->ContentTypeParams().MdcaCount(); ++i )
  1757         {
  1757         {
  1758         // If we have corrupted parameters (length of name is zero)
  1758         // If we have corrupted parameters (length of name is zero)
  1759         // we skip the name/value pair.
  1759         // we skip the name/value pair.
  1760         // value may be zero, it will be encoded as just the terminating zero
  1760         // value may be zero, it will be encoded as just the terminating zero
  1761         if ( i%2 == 0 &&
  1761         if ( i%2 == 0 &&
  1794                 }
  1794                 }
  1795             }
  1795             }
  1796         }
  1796         }
  1797     if ( ( iMimeHeaders->ContentTypeParams().MdcaCount() % 2 ) == 1 )
  1797     if ( ( iMimeHeaders->ContentTypeParams().MdcaCount() % 2 ) == 1 )
  1798         {
  1798         {
  1799         // Odd number. Obviously last paramter has no value.
  1799         // Odd number. Obviously last parameter has no value.
  1800         // Add the "no value" token
  1800         // Add the "no value" token
  1801         iEncodeBuffer->Write( iPosition, &KMmsNull, 1 );
  1801         iEncodeBuffer->Write( iPosition, &KMmsNull, 1 );
  1802         iPosition++;
  1802         iPosition++;
  1803         }
  1803         }
  1804 
  1804 
  1841      // filename should be text-string, not quoted
  1841      // filename should be text-string, not quoted
  1842      EncodeHeaderAndTextString( temp, buf8->Des() );
  1842      EncodeHeaderAndTextString( temp, buf8->Des() );
  1843 #endif
  1843 #endif
  1844 
  1844 
  1845         // x-type parameters
  1845         // x-type parameters
  1846     for ( i = 0; i < iMimeHeaders->XTypeParams().MdcaCount(); i++ )
  1846     for ( i = 0; i < iMimeHeaders->XTypeParams().MdcaCount(); ++i )
  1847         {
  1847         {
  1848         // If we have corrupted parameters (length of name is zero)
  1848         // If we have corrupted parameters (length of name is zero)
  1849         // we skip the name/value pair.
  1849         // we skip the name/value pair.
  1850         // value may be zero, it will be encoded as just the terminating zero
  1850         // value may be zero, it will be encoded as just the terminating zero
  1851         if ( i%2 == 0 &&
  1851         if ( i%2 == 0 &&
  1868             EncodeTextString( iMimeHeaders->XTypeParams().MdcaPoint( i ) );
  1868             EncodeTextString( iMimeHeaders->XTypeParams().MdcaPoint( i ) );
  1869             }
  1869             }
  1870         }
  1870         }
  1871     if ( ( iMimeHeaders->XTypeParams().MdcaCount() % 2 ) == 1 )
  1871     if ( ( iMimeHeaders->XTypeParams().MdcaCount() % 2 ) == 1 )
  1872         {
  1872         {
  1873         // Odd number. Obviously last paramter has no value.
  1873         // Odd number. Obviously last parameter has no value.
  1874         // Add the "no value" token
  1874         // Add the "no value" token
  1875         iEncodeBuffer->Write( iPosition, &KMmsNull, 1 );
  1875         iEncodeBuffer->Write( iPosition, &KMmsNull, 1 );
  1876         iPosition++;
  1876         iPosition++;
  1877         }
  1877         }
  1878         
  1878         
  2310 
  2310 
  2311     // previously sent by array
  2311     // previously sent by array
  2312     TInt i;
  2312     TInt i;
  2313     TUint oldPosition;
  2313     TUint oldPosition;
  2314     TUint length;
  2314     TUint length;
  2315     for ( i = 0; i < iMmsHeaders->PreviouslySentList().Count(); i++ )
  2315     for ( i = 0; i < iMmsHeaders->PreviouslySentList().Count(); ++i )
  2316         {
  2316         {
  2317         oldPosition = iPosition;
  2317         oldPosition = iPosition;
  2318         length = 0;
  2318         length = 0;
  2319         // Encode once just to find out filed length
  2319         // Encode once just to find out filed length
  2320         EncodeInteger( iMmsHeaders->PreviouslySentList()[i]->Order() );
  2320         EncodeInteger( iMmsHeaders->PreviouslySentList()[i]->Order() );
  3199         iMmsHeaders->ReplyChargingId() );
  3199         iMmsHeaders->ReplyChargingId() );
  3200 
  3200 
  3201     TInt i;
  3201     TInt i;
  3202     TUint oldPosition;
  3202     TUint oldPosition;
  3203     TUint length;
  3203     TUint length;
  3204     for ( i = 0; i < iMmsHeaders->PreviouslySentList().Count(); i++ )
  3204     for ( i = 0; i < iMmsHeaders->PreviouslySentList().Count(); ++i )
  3205         {
  3205         {
  3206         oldPosition = iPosition;
  3206         oldPosition = iPosition;
  3207         length = 0;
  3207         length = 0;
  3208         // Encode once just to find out field length
  3208         // Encode once just to find out field length
  3209         EncodeInteger( iMmsHeaders->PreviouslySentList()[i]->Order() );
  3209         EncodeInteger( iMmsHeaders->PreviouslySentList()[i]->Order() );
  3313         {
  3313         {
  3314         TUint8 character;
  3314         TUint8 character;
  3315         // No need to check if we need a quote - if we are safe, we have 
  3315         // No need to check if we need a quote - if we are safe, we have 
  3316         // no characters >= 128.
  3316         // no characters >= 128.
  3317 
  3317 
  3318         for ( i = 0; i < aString.Length(); i++ )
  3318         for ( i = 0; i < aString.Length(); ++i )
  3319             {
  3319             {
  3320             character = TUint8( aString[i] & KMms0xFF );
  3320             character = TUint8( aString[i] & KMms0xFF );
  3321             iEncodeBuffer->Write( iPosition, &character, 1 );
  3321             iEncodeBuffer->Write( iPosition, &character, 1 );
  3322             iPosition++;
  3322             iPosition++;
  3323             }
  3323             }
  3409 
  3409 
  3410     TInt64 temp = aLongInteger;
  3410     TInt64 temp = aLongInteger;
  3411     TInt i = 0;
  3411     TInt i = 0;
  3412     TInt64 reminder = 0;
  3412     TInt64 reminder = 0;
  3413 
  3413 
  3414     for ( i = 7; i >= 0; i-- )
  3414     for ( i = 7; i >= 0; --i )
  3415         {
  3415         {
  3416         reminder = temp % 0x100;
  3416         reminder = temp % 0x100;
  3417         temp = temp / 0x100;
  3417         temp = temp / 0x100;
  3418         array[i] = TInt8 ( I64INT( reminder ) ) ;
  3418         array[i] = TInt8 ( I64INT( reminder ) ) ;
  3419         }
  3419         }
  3482         temp = temp << KMms8;
  3482         temp = temp << KMms8;
  3483         byte = TInt8( ( temp >> KMms24 ) & KMms0xFF );
  3483         byte = TInt8( ( temp >> KMms24 ) & KMms0xFF );
  3484         }
  3484         }
  3485 
  3485 
  3486     TUint i = 0;
  3486     TUint i = 0;
  3487     for ( i = 0; i < length; i++ )
  3487     for ( i = 0; i < length; ++i )
  3488         {
  3488         {
  3489         array[i] = TInt8( ( temp >> ( KMms8 * ( KMms3 - i ) ) ) & KMms0xFF );
  3489         array[i] = TInt8( ( temp >> ( KMms8 * ( KMms3 - i ) ) ) & KMms0xFF );
  3490         }
  3490         }
  3491 
  3491 
  3492     // write short length
  3492     // write short length
  3640         // All legal characters present in a phone number are ASCII
  3640         // All legal characters present in a phone number are ASCII
  3641 
  3641 
  3642         TInt i = 0;
  3642         TInt i = 0;
  3643         TUint8 character = 0;
  3643         TUint8 character = 0;
  3644         realAddressPointer = realAddress->Des();
  3644         realAddressPointer = realAddress->Des();
  3645         for ( i = 0; i < realAddress->Length(); i++ )
  3645         for ( i = 0; i < realAddress->Length(); ++i )
  3646             {
  3646             {
  3647             // The array index is safe because i is always < realAddress->Length().
  3647             // The array index is safe because i is always < realAddress->Length().
  3648             character = TUint8( realAddressPointer[i] & KMms0xFF );
  3648             character = TUint8( realAddressPointer[i] & KMms0xFF );
  3649             iEncodeBuffer->Write( iPosition, &character, 1 );
  3649             iEncodeBuffer->Write( iPosition, &character, 1 );
  3650             iPosition++;
  3650             iPosition++;
  3696     // No more than 5 bytes will be produced
  3696     // No more than 5 bytes will be produced
  3697     TUint8 buffer[KMms5];
  3697     TUint8 buffer[KMms5];
  3698     TUint temp = aInteger;
  3698     TUint temp = aInteger;
  3699     TInt i;
  3699     TInt i;
  3700 
  3700 
  3701     for ( i = 0; i < KMms5; i++ )            
  3701     for ( i = 0; i < KMms5; ++i )            
  3702         {
  3702         {
  3703         buffer[KMms4 - i] = TUint8( temp & KMms0x7F );
  3703         buffer[KMms4 - i] = TUint8( temp & KMms0x7F );
  3704         temp >>= KMms7;
  3704         temp >>= KMms7;
  3705         }
  3705         }
  3706 
  3706 
  3711         i++;
  3711         i++;
  3712         }
  3712         }
  3713     
  3713     
  3714     TInt j;
  3714     TInt j;
  3715 
  3715 
  3716     for ( j = i; j < KMms4; j++ )
  3716     for ( j = i; j < KMms4; ++j )
  3717         {
  3717         {
  3718         // buffer indexes are safe because the buffer has been defined long enough.
  3718         // buffer indexes are safe because the buffer has been defined long enough.
  3719         buffer[j] |= KMms0x80; // set Continue bit, but never to last
  3719         buffer[j] |= KMms0x80; // set Continue bit, but never to last
  3720         }
  3720         }
  3721 
  3721 
  3738     // No more than 5 bytes will be produced
  3738     // No more than 5 bytes will be produced
  3739     TUint8 buffer[KMms5];
  3739     TUint8 buffer[KMms5];
  3740     TUint temp = aInteger;
  3740     TUint temp = aInteger;
  3741     TInt i;
  3741     TInt i;
  3742 
  3742 
  3743     for (i = 0; i < KMms5; i++ )            
  3743     for (i = 0; i < KMms5; ++i )            
  3744         {
  3744         {
  3745         buffer[KMms4 - i] = TUint8( temp & KMms0x7F );
  3745         buffer[KMms4 - i] = TUint8( temp & KMms0x7F );
  3746         temp >>= KMms7;
  3746         temp >>= KMms7;
  3747         }
  3747         }
  3748 
  3748 
  3787             break;
  3787             break;
  3788         default:
  3788         default:
  3789             break;
  3789             break;
  3790         }
  3790         }
  3791 
  3791 
  3792     for ( i = 0; i < size; i++ )
  3792     for ( i = 0; i < size; ++i )
  3793         {
  3793         {
  3794         // check for fakes
  3794         // check for fakes
  3795         if ( aRecipientList[i].Length() > 0 )
  3795         if ( aRecipientList[i].Length() > 0 )
  3796             {
  3796             {
  3797             iEncodeBuffer->Write( iPosition, &recipientType, 1 );
  3797             iEncodeBuffer->Write( iPosition, &recipientType, 1 );
  3992     // Used for headers, which are short strings
  3992     // Used for headers, which are short strings
  3993 
  3993 
  3994     TInt i;
  3994     TInt i;
  3995     TBool safe = ETrue;
  3995     TBool safe = ETrue;
  3996 
  3996 
  3997     for ( i = 0; i < aString.Length() && safe; i++ )
  3997     for ( i = 0; i < aString.Length() && safe; ++i )
  3998         {
  3998         {
  3999         if ( aString[i] < KMmsLowestAscii || aString[i] >= KMmsHighestAscii )
  3999         if ( aString[i] < KMmsLowestAscii || aString[i] >= KMmsHighestAscii )
  4000             {
  4000             {
  4001             safe = EFalse;
  4001             safe = EFalse;
  4002             }
  4002             }
  4022     
  4022     
  4023     TInt i;
  4023     TInt i;
  4024     aNumNonSafe = 0;
  4024     aNumNonSafe = 0;
  4025     TBool safe = ETrue;
  4025     TBool safe = ETrue;
  4026 
  4026 
  4027     for ( i = 0; i < aString.Length()/* && safe*/; i++ )
  4027     for ( i = 0; i < aString.Length()/* && safe*/; ++i )
  4028         {
  4028         {
  4029         if ( aString[i] < KMmsLowestAscii || aString[i] >= KMmsHighestAscii )
  4029         if ( aString[i] < KMmsLowestAscii || aString[i] >= KMmsHighestAscii )
  4030             {
  4030             {
  4031             safe = EFalse;
  4031             safe = EFalse;
  4032             aNumNonSafe++;
  4032             aNumNonSafe++;
  4150         }
  4150         }
  4151     // Check if we have well-known media.
  4151     // Check if we have well-known media.
  4152     TInt8 rootContentType = -1;
  4152     TInt8 rootContentType = -1;
  4153 
  4153 
  4154     TInt8 i = 0;
  4154     TInt8 i = 0;
  4155     for ( i = 0; i < KNumberContentTypes && rootContentType < 0; i++ )
  4155     for ( i = 0; i < KNumberContentTypes && rootContentType < 0; ++i )
  4156         {
  4156         {
  4157         if ( contentTypeString.CompareF( TPtrC8( KContentTypeTable[i] ) ) == 0 )
  4157         if ( contentTypeString.CompareF( TPtrC8( KContentTypeTable[i] ) ) == 0 )
  4158             {
  4158             {
  4159             rootContentType = i;
  4159             rootContentType = i;
  4160             }
  4160             }
  4318     TInt i = 0;
  4318     TInt i = 0;
  4319     TInt length = 0;
  4319     TInt length = 0;
  4320 
  4320 
  4321     // caller must check that iMmsHeaders->ReadOnlyMMBoxMessageHeaders() is not NULL
  4321     // caller must check that iMmsHeaders->ReadOnlyMMBoxMessageHeaders() is not NULL
  4322     CMmsMMBoxMessageHeaders& temp = iMmsHeaders->MMBoxMessageHeadersL();
  4322     CMmsMMBoxMessageHeaders& temp = iMmsHeaders->MMBoxMessageHeadersL();
  4323     for ( i = 0; i < temp.KeywordArray().Count(); i++ )
  4323     for ( i = 0; i < temp.KeywordArray().Count(); ++i )
  4324         {
  4324         {
  4325         length = temp.KeywordArray()[i]->Keyword().Length();
  4325         length = temp.KeywordArray()[i]->Keyword().Length();
  4326         if ( length > 0 )
  4326         if ( length > 0 )
  4327             {
  4327             {
  4328             iEncodeBuffer->Write( iPosition, &KMmsAssignedMMFlags, 1 );
  4328             iEncodeBuffer->Write( iPosition, &KMmsAssignedMMFlags, 1 );
  4373 //
  4373 //
  4374 void CMmsEncode::EncodeAttributes( RArray<TUint>& aAttributeArray )
  4374 void CMmsEncode::EncodeAttributes( RArray<TUint>& aAttributeArray )
  4375     {
  4375     {
  4376     TInt i;
  4376     TInt i;
  4377 
  4377 
  4378     for ( i = 0; i < aAttributeArray.Count(); i++ )
  4378     for ( i = 0; i < aAttributeArray.Count(); ++i )
  4379         {
  4379         {
  4380         EncodeMandatoryByte( KMmsAssignedAttributes, aAttributeArray[i] );
  4380         EncodeMandatoryByte( KMmsAssignedAttributes, aAttributeArray[i] );
  4381         }
  4381         }
  4382     }
  4382     }
  4383 
  4383 
  4387 //
  4387 //
  4388 void CMmsEncode::EncodeMMBoxStates( RArray<TInt>& aStateArray )
  4388 void CMmsEncode::EncodeMMBoxStates( RArray<TInt>& aStateArray )
  4389     {
  4389     {
  4390     TInt i;
  4390     TInt i;
  4391 
  4391 
  4392     for ( i = 0; i < aStateArray.Count(); i++ )
  4392     for ( i = 0; i < aStateArray.Count(); ++i )
  4393         {
  4393         {
  4394         EncodeMandatoryByte( KMmsAssignedMMState, aStateArray[i] );
  4394         EncodeMandatoryByte( KMmsAssignedMMState, aStateArray[i] );
  4395         }
  4395         }
  4396     }
  4396     }
  4397 
  4397 
  4739             else
  4739             else
  4740                 {
  4740                 {
  4741                 TMmsLogger::Log( _L("CMmsEncode::PreProcessAttachmentData:: store commit success") );                
  4741                 TMmsLogger::Log( _L("CMmsEncode::PreProcessAttachmentData:: store commit success") );                
  4742                 }
  4742                 }
  4743 #endif /* _NO_MMSS_LOGGING_ */
  4743 #endif /* _NO_MMSS_LOGGING_ */
  4744             /*  attachmentInfo ownership is transfered to attachment manager
  4744             /*  attachmentInfo ownership is transferred to attachment manager
  4745              *  Hence, JUST pop attachmentInfo, DO NOT Destroy.
  4745              *  Hence, JUST pop attachmentInfo, DO NOT Destroy.
  4746              */
  4746              */
  4747             CleanupStack::Pop( attachmentInfo );
  4747             CleanupStack::Pop( attachmentInfo );
  4748             }
  4748             }
  4749         else
  4749         else
  4846     }
  4846     }
  4847     
  4847     
  4848 // ---------------------------------------------------------
  4848 // ---------------------------------------------------------
  4849 // CMmsEncode::ProcessAndConvertAttachmentDataL
  4849 // CMmsEncode::ProcessAndConvertAttachmentDataL
  4850 // converts of attachment data from source to target encoding type.
  4850 // converts of attachment data from source to target encoding type.
  4851 // |src charset buffer| --->coverted to ---> |unicode buffer| ---> converted to ---> |target charset|
  4851 // |src charset buffer| --->converted to ---> |unicode buffer| ---> converted to ---> |target charset|
  4852 // Returns false if data is already int target format, or plugins are missing, or file operation issues.
  4852 // Returns false if data is already int target format, or plugins are missing, or file operation issues.
  4853 // ---------------------------------------------------------
  4853 // ---------------------------------------------------------
  4854 TBool CMmsEncode::ProcessAndConvertAttachmentDataL( TUint aSrcCharSetMIBEnum,
  4854 TBool CMmsEncode::ProcessAndConvertAttachmentDataL( TUint aSrcCharSetMIBEnum,
  4855                                                     TUint aTargetCharSetMIBEnum, 
  4855                                                     TUint aTargetCharSetMIBEnum, 
  4856                                                     CMsvAttachment& aAttachmentInfo)
  4856                                                     CMsvAttachment& aAttachmentInfo)