mmsengine/mmscodec/src/mmsencode.cpp
branchRCL_3
changeset 26 ebe688cedc25
parent 12 caea42e26caa
child 27 7fdbb852d323
--- a/mmsengine/mmscodec/src/mmsencode.cpp	Thu Aug 19 09:51:11 2010 +0300
+++ b/mmsengine/mmscodec/src/mmsencode.cpp	Tue Aug 31 15:11:31 2010 +0300
@@ -22,6 +22,7 @@
 
 // INCLUDE FILES
 #include    <e32std.h>
+#include    <e32hal.h>
 #include    <apparc.h>
 #include    <s32mem.h>
 #include    <msventry.h>
@@ -853,7 +854,7 @@
     User::LeaveIfError( iEntryWrapper->SetCurrentEntry( iCurrentMessageId ) );
     
     /* Korean req: 415-5434
-     * Get the target encoding MIB enum from cenrep and encode MMS text objects using coresponding conversion plugins
+     * Get the target encoding MIB enum from cenrep and encode MMS text objects using corresponding conversion plugins
      */
     TInt temp;
     iTargetEncodingType = 0;
@@ -869,8 +870,9 @@
 
     if( iTargetEncodingType != 0 )
         {
+        TRAPD( err, PreProcessAttachmentDataL() );
+
 #ifndef _NO_MMSS_LOGGING_
-        TRAPD( err, PreProcessAttachmentDataL() );
     /* if any error, korean specific encoding failed, But this should not stop from sending MMS using
      * existing default encoding. Hence just log the error and continue in any case
      */
@@ -878,8 +880,6 @@
             {
             TMmsLogger::Log( _L("CMmsEncode::EncodeHeadersChunkedL:: PreProcessAttachmentDataL error: %d"), err );
             }
-#else
-				TRAP_IGNORE( PreProcessAttachmentDataL() );            
 #endif /* _NO_MMSS_LOGGING_ */
         }
     
@@ -942,7 +942,7 @@
 #ifndef _NO_MMSS_LOGGING_
         TMmsLogger::Log( _L("CMmsEncode::EncodeHeadersChunkedL:: only one chunk") );
 #endif /* _NO_MMSS_LOGGING_ */        // The message is small enough to be sent as one chunk
-        for ( i = 0; ( i < iNumberOfAttachments ) && ( iError == KErrNone ); i++ )
+        for ( i = 0; ( i < iNumberOfAttachments ) && ( iError == KErrNone ); ++i )
             {
             iCurrentAttachment = i;
             // encode attachments, too, as we have decided that our message
@@ -964,7 +964,7 @@
         // chunked sending - but it should be possible to calculate data size
         iOverallDataSize = iPosition; // This is the amount taken by headers
         // The message is small enough to be sent as one chunk
-        for ( i = 0; ( i < iNumberOfAttachments ) && ( iError == KErrNone ); i++ )
+        for ( i = 0; ( i < iNumberOfAttachments ) && ( iError == KErrNone ); ++i )
             {
             iCurrentAttachment = i;
             // encode attachments, too, as we have decided that our message
@@ -1260,7 +1260,7 @@
         }
         
     TInt8 i;
-    for ( i = 0; i < KNumberContentTypes && aContentType < 0; i++ )
+    for ( i = 0; i < KNumberContentTypes && aContentType < 0; ++i )
         {
         if ( aContentTypeString.CompareF(
             TPtrC8( KContentTypeTable[i] ) ) == 0 )
@@ -1295,7 +1295,7 @@
         aHeaderLength += 1; // terminating zero
         }
 
-    // If we have paramters, we must calculate their length.
+    // If we have parameters, we must calculate their length.
     if ( iMimeHeaders->MimeCharset() != 0 )
         {
         // charset has well-known encoding
@@ -1383,7 +1383,7 @@
         }
     if ( ( iMimeHeaders->ContentTypeParams().MdcaCount() % 2 ) == 1 )
         {
-        // Odd number. Obviously last paramter has no value.
+        // Odd number. Obviously last parameter has no value.
         // Add the "no value" token
         aHeaderLength++;
         }
@@ -1500,7 +1500,7 @@
             // replace all illegal characters by underscore
             buf8 = HBufC8::NewL( nameLength );
             CleanupStack::PushL( buf8 );
-            for ( j = 0; j < nameLength; j++ )
+            for ( j = 0; j < nameLength; ++j )
                 {
                 oneCharacter.Copy( originalName.Mid( j, 1 ) );
                 if ( !IsStringSafe( oneCharacter ) )
@@ -1623,7 +1623,7 @@
     // X-parameter[i] = parameter name
     // X-parameter[i+1] = parameter value
     
-    for ( i = 0; i < iMimeHeaders->XTypeParams().MdcaCount(); i++ )
+    for ( i = 0; i < iMimeHeaders->XTypeParams().MdcaCount(); ++i )
         {
         // If we have corrupted parameters (length of name is zero)
         // we skip the name/value pair.
@@ -1645,7 +1645,7 @@
         }
     if ( ( iMimeHeaders->XTypeParams().MdcaCount() % 2 ) == 1 )
         {
-        // Odd number. Obviously last paramter has no value.
+        // Odd number. Obviously last parameter has no value.
         // Add the "no value" token
         aHeaderLength++;
         }
@@ -1739,7 +1739,7 @@
     temp = KWspCharset | KMms0x80; // encode as short integer
     EncodeOptionalInteger( temp, iMimeHeaders->MimeCharset() );
 
-    // if we didn't find "Name" parameter among our paramters, we
+    // if we didn't find "Name" parameter among our parameters, we
     // put it first.
 
     // we need the name later anyway...
@@ -1754,7 +1754,7 @@
     
     TInt i = 0;
     
-    for ( i = 0; i < iMimeHeaders->ContentTypeParams().MdcaCount(); i++ )
+    for ( i = 0; i < iMimeHeaders->ContentTypeParams().MdcaCount(); ++i )
         {
         // If we have corrupted parameters (length of name is zero)
         // we skip the name/value pair.
@@ -1797,7 +1797,7 @@
         }
     if ( ( iMimeHeaders->ContentTypeParams().MdcaCount() % 2 ) == 1 )
         {
-        // Odd number. Obviously last paramter has no value.
+        // Odd number. Obviously last parameter has no value.
         // Add the "no value" token
         iEncodeBuffer->Write( iPosition, &KMmsNull, 1 );
         iPosition++;
@@ -1844,7 +1844,7 @@
 #endif
 
         // x-type parameters
-    for ( i = 0; i < iMimeHeaders->XTypeParams().MdcaCount(); i++ )
+    for ( i = 0; i < iMimeHeaders->XTypeParams().MdcaCount(); ++i )
         {
         // If we have corrupted parameters (length of name is zero)
         // we skip the name/value pair.
@@ -1871,7 +1871,7 @@
         }
     if ( ( iMimeHeaders->XTypeParams().MdcaCount() % 2 ) == 1 )
         {
-        // Odd number. Obviously last paramter has no value.
+        // Odd number. Obviously last parameter has no value.
         // Add the "no value" token
         iEncodeBuffer->Write( iPosition, &KMmsNull, 1 );
         iPosition++;
@@ -2313,7 +2313,7 @@
     TInt i;
     TUint oldPosition;
     TUint length;
-    for ( i = 0; i < iMmsHeaders->PreviouslySentList().Count(); i++ )
+    for ( i = 0; i < iMmsHeaders->PreviouslySentList().Count(); ++i )
         {
         oldPosition = iPosition;
         length = 0;
@@ -3202,7 +3202,7 @@
     TInt i;
     TUint oldPosition;
     TUint length;
-    for ( i = 0; i < iMmsHeaders->PreviouslySentList().Count(); i++ )
+    for ( i = 0; i < iMmsHeaders->PreviouslySentList().Count(); ++i )
         {
         oldPosition = iPosition;
         length = 0;
@@ -3316,7 +3316,7 @@
         // No need to check if we need a quote - if we are safe, we have 
         // no characters >= 128.
 
-        for ( i = 0; i < aString.Length(); i++ )
+        for ( i = 0; i < aString.Length(); ++i )
             {
             character = TUint8( aString[i] & KMms0xFF );
             iEncodeBuffer->Write( iPosition, &character, 1 );
@@ -3412,7 +3412,7 @@
     TInt i = 0;
     TInt64 reminder = 0;
 
-    for ( i = 7; i >= 0; i-- )
+    for ( i = 7; i >= 0; --i )
         {
         reminder = temp % 0x100;
         temp = temp / 0x100;
@@ -3485,7 +3485,7 @@
         }
 
     TUint i = 0;
-    for ( i = 0; i < length; i++ )
+    for ( i = 0; i < length; ++i )
         {
         array[i] = TInt8( ( temp >> ( KMms8 * ( KMms3 - i ) ) ) & KMms0xFF );
         }
@@ -3643,7 +3643,7 @@
         TInt i = 0;
         TUint8 character = 0;
         realAddressPointer = realAddress->Des();
-        for ( i = 0; i < realAddress->Length(); i++ )
+        for ( i = 0; i < realAddress->Length(); ++i )
             {
             // The array index is safe because i is always < realAddress->Length().
             character = TUint8( realAddressPointer[i] & KMms0xFF );
@@ -3699,7 +3699,7 @@
     TUint temp = aInteger;
     TInt i;
 
-    for ( i = 0; i < KMms5; i++ )            
+    for ( i = 0; i < KMms5; ++i )            
         {
         buffer[KMms4 - i] = TUint8( temp & KMms0x7F );
         temp >>= KMms7;
@@ -3714,7 +3714,7 @@
     
     TInt j;
 
-    for ( j = i; j < KMms4; j++ )
+    for ( j = i; j < KMms4; ++j )
         {
         // buffer indexes are safe because the buffer has been defined long enough.
         buffer[j] |= KMms0x80; // set Continue bit, but never to last
@@ -3741,7 +3741,7 @@
     TUint temp = aInteger;
     TInt i;
 
-    for (i = 0; i < KMms5; i++ )            
+    for (i = 0; i < KMms5; ++i )            
         {
         buffer[KMms4 - i] = TUint8( temp & KMms0x7F );
         temp >>= KMms7;
@@ -3790,7 +3790,7 @@
             break;
         }
 
-    for ( i = 0; i < size; i++ )
+    for ( i = 0; i < size; ++i )
         {
         // check for fakes
         if ( aRecipientList[i].Length() > 0 )
@@ -3995,7 +3995,7 @@
     TInt i;
     TBool safe = ETrue;
 
-    for ( i = 0; i < aString.Length() && safe; i++ )
+    for ( i = 0; i < aString.Length() && safe; ++i )
         {
         if ( aString[i] < KMmsLowestAscii || aString[i] >= KMmsHighestAscii )
             {
@@ -4025,7 +4025,7 @@
     aNumNonSafe = 0;
     TBool safe = ETrue;
 
-    for ( i = 0; i < aString.Length()/* && safe*/; i++ )
+    for ( i = 0; i < aString.Length()/* && safe*/; ++i )
         {
         if ( aString[i] < KMmsLowestAscii || aString[i] >= KMmsHighestAscii )
             {
@@ -4153,7 +4153,7 @@
     TInt8 rootContentType = -1;
 
     TInt8 i = 0;
-    for ( i = 0; i < KNumberContentTypes && rootContentType < 0; i++ )
+    for ( i = 0; i < KNumberContentTypes && rootContentType < 0; ++i )
         {
         if ( contentTypeString.CompareF( TPtrC8( KContentTypeTable[i] ) ) == 0 )
             {
@@ -4321,7 +4321,7 @@
 
     // caller must check that iMmsHeaders->ReadOnlyMMBoxMessageHeaders() is not NULL
     CMmsMMBoxMessageHeaders& temp = iMmsHeaders->MMBoxMessageHeadersL();
-    for ( i = 0; i < temp.KeywordArray().Count(); i++ )
+    for ( i = 0; i < temp.KeywordArray().Count(); ++i )
         {
         length = temp.KeywordArray()[i]->Keyword().Length();
         if ( length > 0 )
@@ -4376,7 +4376,7 @@
     {
     TInt i;
 
-    for ( i = 0; i < aAttributeArray.Count(); i++ )
+    for ( i = 0; i < aAttributeArray.Count(); ++i )
         {
         EncodeMandatoryByte( KMmsAssignedAttributes, aAttributeArray[i] );
         }
@@ -4390,7 +4390,7 @@
     {
     TInt i;
 
-    for ( i = 0; i < aStateArray.Count(); i++ )
+    for ( i = 0; i < aStateArray.Count(); ++i )
         {
         EncodeMandatoryByte( KMmsAssignedMMState, aStateArray[i] );
         }
@@ -4727,9 +4727,12 @@
 
         if( retVal )
             {
+            TRAPD( 
+                    err,
+                    attachManagerSync.ModifyAttachmentInfoL(attachmentInfo);
+                    editStore->CommitL();
+                  );
 #ifndef _NO_MMSS_LOGGING_
-            TRAPD( err,attachManagerSync.ModifyAttachmentInfoL(attachmentInfo);
-                    editStore->CommitL(););
             if(err != KErrNone)
                 {
                 TMmsLogger::Log( _L("CMmsEncode::PreProcessAttachmentData:: store commit error: %d"), err );
@@ -4738,11 +4741,8 @@
                 {
                 TMmsLogger::Log( _L("CMmsEncode::PreProcessAttachmentData:: store commit success") );                
                 }
-#else
-				    TRAP_IGNORE( attachManagerSync.ModifyAttachmentInfoL(attachmentInfo);
-                    editStore->CommitL(););	                
 #endif /* _NO_MMSS_LOGGING_ */
-            /*  attachmentInfo ownership is transfered to attachment manager
+            /*  attachmentInfo ownership is transferred to attachment manager
              *  Hence, JUST pop attachmentInfo, DO NOT Destroy.
              */
             CleanupStack::Pop( attachmentInfo );
@@ -4849,7 +4849,7 @@
 // ---------------------------------------------------------
 // CMmsEncode::ProcessAndConvertAttachmentDataL
 // converts of attachment data from source to target encoding type.
-// |src charset buffer| --->coverted to ---> |unicode buffer| ---> converted to ---> |target charset|
+// |src charset buffer| --->converted to ---> |unicode buffer| ---> converted to ---> |target charset|
 // Returns false if data is already int target format, or plugins are missing, or file operation issues.
 // ---------------------------------------------------------
 TBool CMmsEncode::ProcessAndConvertAttachmentDataL( TUint aSrcCharSetMIBEnum,