ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp
branchRCL_3
changeset 24 d189ee25cf9d
parent 23 dcf0eedfc1a3
child 25 3533d4323edc
equal deleted inserted replaced
23:dcf0eedfc1a3 24:d189ee25cf9d
   305     FUNC_LOG;
   305     FUNC_LOG;
   306     TInt msgFlags = aMessage.GetFlags();
   306     TInt msgFlags = aMessage.GetFlags();
   307     TBool modified ( EFalse );
   307     TBool modified ( EFalse );
   308     TBool unread( aEmlEntry.Unread() );
   308     TBool unread( aEmlEntry.Unread() );
   309 
   309 
   310     if ( !LogicalXor( unread, msgFlags & EFSMsgFlag_Read ) )
   310 // <qmail>
       
   311     if ( LogicalXor( unread, msgFlags & EFSMsgFlag_Read ) ||
       
   312          LogicalXor( unread, msgFlags & EFSMsgFlag_Read_Locally ))
       
   313 // </qmail>
   311         {
   314         {
   312         aEmlEntry.SetUnread( !unread );
   315         aEmlEntry.SetUnread( !unread );
   313         modified = ETrue;
   316         modified = ETrue;
   314         }
   317         }
   315 
   318 
   357 
   360 
   358 
   361 
   359     // EFSMsgFlag_Answered: supported only with IMAP4 (see below)
   362     // EFSMsgFlag_Answered: supported only with IMAP4 (see below)
   360 
   363 
   361     // EFSMsgFlag_Forwarded: no counterpart in Symbian message in S60 3.1
   364     // EFSMsgFlag_Forwarded: no counterpart in Symbian message in S60 3.1
   362     if ( LogicalXor( aEmlEntry.Forwarded(), msgFlags & EFSMsgFlag_Forwarded ) )
       
   363         {
       
   364         aEmlEntry.SetForwarded( !aEmlEntry.Forwarded() );
       
   365         modified = ETrue;
       
   366         }
       
   367 
   365 
   368     // EFSMsgFlag_OnlyToMe: no counterpart in Symbian message
   366     // EFSMsgFlag_OnlyToMe: no counterpart in Symbian message
   369 
   367 
   370     // EFSMsgFlag_RemoteDeleted: no counterpart in Symbian message
   368     // EFSMsgFlag_RemoteDeleted: no counterpart in Symbian message
   371 
   369 
   408     CMsvEntry* cEntry = iSession.GetEntryL( aEntryId );
   406     CMsvEntry* cEntry = iSession.GetEntryL( aEntryId );
   409     CleanupStack::PushL( cEntry );
   407     CleanupStack::PushL( cEntry );
   410 
   408 
   411     TMsvEmailEntry tEntry( cEntry->Entry() );
   409     TMsvEmailEntry tEntry( cEntry->Entry() );
   412     TBool isModified = ChangeTEntryFlagsL( tEntry, aMessage );
   410     TBool isModified = ChangeTEntryFlagsL( tEntry, aMessage );
   413 
   411     // <qmail>
   414     if ( isModified )
   412     if ( isModified )
   415         {
   413         {
   416         CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewLC();
   414         cEntry->ChangeL( tEntry );
   417         CMsvOperation* ops = cEntry->ChangeL( tEntry, waiter->iStatus );
       
   418         CleanupStack::PushL( ops );
       
   419         waiter->Start();
       
   420         CleanupStack::PopAndDestroy( 2, waiter );
       
   421         }
   415         }
   422 
   416 
   423     CleanupStack::PopAndDestroy( cEntry );
   417     CleanupStack::PopAndDestroy( cEntry );
       
   418     // </qmail>
   424     }
   419     }
   425 
   420 
   426 // ---------------------------------------------------------------------------
   421 // ---------------------------------------------------------------------------
   427 // ---------------------------------------------------------------------------
   422 // ---------------------------------------------------------------------------
   428 CMsvOperation* CIpsPlgMsgMapper::UpdateMessageFlagsAsyncL(
   423 CMsvOperation* CIpsPlgMsgMapper::UpdateMessageFlagsAsyncL(
   716                         	}
   711                         	}
   717 						else
   712 						else
   718 							{
   713 							{
   719 							// Only text/calendar part included as attachment
   714 							// Only text/calendar part included as attachment
   720 							aMsg.ResetFlag( EFSMsgFlag_Attachments );
   715 							aMsg.ResetFlag( EFSMsgFlag_Attachments );
   721 							//Set Attachment flag for CMsvEntry (needed for sorting)
   716 							// <qmail> remove call to SetAttachmentFlagL(), because shouln't be needed any more
   722 							TRAP_IGNORE( SetAttachmentFlagL( aEntry, EFalse ) );
       
   723 							}
   717 							}
   724                 		}
   718                 		}
   725                 	delete cEntry;
   719                 	delete cEntry;
   726                 	cEntry = NULL;
   720                 	cEntry = NULL;
   727                 	}
   721                 	}
   752 
   746 
   753     // EFSMsgFlag_Answered: supported only with IMAP4 messages (see below)
   747     // EFSMsgFlag_Answered: supported only with IMAP4 messages (see below)
   754     aMsg.ResetFlag( EFSMsgFlag_Answered );
   748     aMsg.ResetFlag( EFSMsgFlag_Answered );
   755 
   749 
   756     // EFSMsgFlag_Forwarded: not supported in S60 3.1
   750     // EFSMsgFlag_Forwarded: not supported in S60 3.1
   757     if ( aEntry.Forwarded() )
   751     aMsg.ResetFlag( EFSMsgFlag_Forwarded );
   758         {
       
   759         aMsg.SetFlag( EFSMsgFlag_Forwarded );
       
   760         }
       
   761     else
       
   762         {
       
   763         aMsg.ResetFlag( EFSMsgFlag_Forwarded );
       
   764         }
       
   765 
   752 
   766     // EFSMsgFlag_OnlyToMe: like EFSMsgFlag_Multiple
   753     // EFSMsgFlag_OnlyToMe: like EFSMsgFlag_Multiple
   767 
   754 
   768     // EFSMsgFlag_RemoteDeleted: no reasonable use in IPS
   755     // EFSMsgFlag_RemoteDeleted: no reasonable use in IPS
   769 
   756 
   953 
   940 
   954 // ---------------------------------------------------------------------------
   941 // ---------------------------------------------------------------------------
   955 // ---------------------------------------------------------------------------
   942 // ---------------------------------------------------------------------------
   956 // <cmail>
   943 // <cmail>
   957 TInt CIpsPlgMsgMapper::ConvertBodyPartMimeType(
   944 TInt CIpsPlgMsgMapper::ConvertBodyPartMimeType(
   958     const TUid& aEntryType,
   945     const TMsvEmailEntry& aEntry,
   959     TDes& aMimeType )
   946     TDes& aMimeType )
   960     {
   947     {
   961     FUNC_LOG;
   948     FUNC_LOG;
   962     TInt result( KErrNone );
   949     TInt result( KErrNone );
   963 
   950 
   964     switch ( aEntryType.iUid )
   951     switch ( aEntry.iType.iUid )
   965     {
   952     {
   966     case KUidMsvEmailTextEntryValue:
   953     case KUidMsvEmailTextEntryValue:
   967         {
   954         {
       
   955         if( aEntry.ICalendar() )
       
   956             {
       
   957             aMimeType.Append( KFSMailContentTypeTextCalendar );
       
   958             }
       
   959         else
       
   960             {
   968             aMimeType.Append( KMimeTypeTextPlain );
   961             aMimeType.Append( KMimeTypeTextPlain );
       
   962             }
   969         break;
   963         break;
   970         }
   964         }
   971     case KUidMsvEmailHtmlEntryValue:
   965     case KUidMsvEmailHtmlEntryValue:
   972         {
   966         {
   973             aMimeType.Append( KMimeTypeTextHtml );
   967             aMimeType.Append( KMimeTypeTextHtml );
  1096         else
  1090         else
  1097             {
  1091             {
  1098             childPart = GetMessagePartL( (*cEntry)[0].Id(), aMailBoxId, aMessageId );
  1092             childPart = GetMessagePartL( (*cEntry)[0].Id(), aMailBoxId, aMessageId );
  1099             if( childPart )
  1093             if( childPart )
  1100                 {
  1094                 {
  1101                 aParts.Append( childPart );
  1095                 aParts.AppendL( childPart );
  1102                 }
  1096                 }
  1103             }
  1097             }
  1104         }
  1098         }
  1105     CleanupStack::PopAndDestroy( cEntry );
  1099     CleanupStack::PopAndDestroy( cEntry );
  1106     }
  1100     }
  1158             }
  1152             }
  1159 
  1153 
  1160         // Insert the new child part to the result array
  1154         // Insert the new child part to the result array
  1161         if ( childPart )
  1155         if ( childPart )
  1162             {
  1156             {
  1163             aParts.Insert( childPart, position );
  1157             aParts.InsertL( childPart, position );
  1164             childPart = NULL;
  1158             childPart = NULL;
  1165             }
  1159             }
  1166         }
  1160         }
  1167     CleanupStack::PopAndDestroy( cEntry );
  1161     CleanupStack::PopAndDestroy( cEntry );
  1168     }
  1162     }
  1175     const TFSMailMsgId& aMessageId )
  1169     const TFSMailMsgId& aMessageId )
  1176     {
  1170     {
  1177     FUNC_LOG;
  1171     FUNC_LOG;
  1178     CFSMailMessagePart* result( NULL );
  1172     CFSMailMessagePart* result( NULL );
  1179     TInt status;
  1173     TInt status;
  1180 // <cmail>
       
  1181     HBufC* buf = HBufC::NewLC( KMaxContentTypeLength );
  1174     HBufC* buf = HBufC::NewLC( KMaxContentTypeLength );
  1182     TPtr contentType = buf->Des();
  1175     TPtr contentType = buf->Des();
  1183 
  1176 
  1184     status = ConvertBodyPartMimeType( aEntry.iType, contentType );
  1177     status = ConvertBodyPartMimeType( aEntry, contentType );
       
  1178     
  1185     __ASSERT_DEBUG( ( status == KErrNone ),
  1179     __ASSERT_DEBUG( ( status == KErrNone ),
  1186         User::Panic( KIpsPlgPanicCategory, EIpsPlgInvalidEntry ) );
  1180         User::Panic( KIpsPlgPanicCategory, EIpsPlgInvalidEntry ) );
  1187     if ( status == KErrNone )
  1181     if ( status == KErrNone )
  1188         {
  1182         {
  1189         result = CFSMailMessagePart::NewLC(
  1183         result = CFSMailMessagePart::NewLC(
  1192         // If mimetype is 'text/html' add charset parameter
  1186         // If mimetype is 'text/html' add charset parameter
  1193         if ( aEntry.iType.iUid == KUidMsvEmailHtmlEntryValue )
  1187         if ( aEntry.iType.iUid == KUidMsvEmailHtmlEntryValue )
  1194             {
  1188             {
  1195             GetCharsetParameterL( aEntry, contentType );
  1189             GetCharsetParameterL( aEntry, contentType );
  1196             }
  1190             }
  1197 // </cmail>
       
  1198         result->SetContentType( contentType );
  1191         result->SetContentType( contentType );
  1199         result->SetMailBoxId( aMailBoxId );
  1192         result->SetMailBoxId( aMailBoxId );
  1200 
  1193 
  1201         // Size
  1194         // Size
  1202         result->SetContentSize( aEntry.iSize );
  1195         result->SetContentSize( aEntry.iSize );
  1519 
  1512 
  1520 
  1513 
  1521 // ---------------------------------------------------------------------------
  1514 // ---------------------------------------------------------------------------
  1522 // ---------------------------------------------------------------------------
  1515 // ---------------------------------------------------------------------------
  1523 // <cmail>
  1516 // <cmail>
  1524 void CIpsPlgMsgMapper::SetAttachmentFlagL( const TMsvEmailEntry& aEntry,
  1517 void CIpsPlgMsgMapper::SetAttachmentFlagL( const TMsvEmailEntry& /*aEntry*/,
  1525 										   TBool aHasAttachment )
  1518 										   TBool /*aHasAttachment*/ )
  1526 	{
  1519 	{
  1527 	FUNC_LOG;
  1520 	FUNC_LOG;
  1528 	CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() );
  1521 	// <qmail> commented out, causing freeze in message list
       
  1522 	/*CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() );
  1529 	CleanupStack::PushL( cEntry );
  1523 	CleanupStack::PushL( cEntry );
  1530 	// Only text/calendar part included as attachment
  1524 	// Only text/calendar part included as attachment
  1531 	TMsvEmailEntry entryToBeChanged( aEntry );
  1525 	TMsvEmailEntry entryToBeChanged( aEntry );
  1532 	entryToBeChanged.SetAttachment( aHasAttachment );
  1526 	entryToBeChanged.SetAttachment( aHasAttachment );
  1533 	CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewLC();
  1527 
  1534 	CMsvOperation* ops = cEntry->ChangeL( entryToBeChanged, waiter->iStatus );
  1528 	cEntry->ChangeL( entryToBeChanged );
  1535 	CleanupStack::PushL( ops );
  1529 	CleanupStack::PopAndDestroy( cEntry );*/
  1536 	waiter->Start();
  1530 // </qmail>
  1537 	CleanupStack::PopAndDestroy( 3, cEntry );
       
  1538 	}
  1531 	}
  1539 // </cmail>
       
  1540 
       
  1541 // <cmail>
       
  1542 // ---------------------------------------------------------------------------
  1532 // ---------------------------------------------------------------------------
  1543 // ---------------------------------------------------------------------------
  1533 // ---------------------------------------------------------------------------
  1544 void CIpsPlgMsgMapper::GetCharsetParameterL(
  1534 void CIpsPlgMsgMapper::GetCharsetParameterL(
  1545     const TMsvEmailEntry& aEntry, TDes& aContentType )
  1535     const TMsvEmailEntry& aEntry, TDes& aContentType )
  1546     {
  1536     {
  1556             {
  1546             {
  1557             CImMimeHeader* mimeHeader = CImMimeHeader::NewLC();
  1547             CImMimeHeader* mimeHeader = CImMimeHeader::NewLC();
  1558             mimeHeader->RestoreL( *store );
  1548             mimeHeader->RestoreL( *store );
  1559 
  1549 
  1560             TInt count = mimeHeader->ContentTypeParams().MdcaCount();
  1550             TInt count = mimeHeader->ContentTypeParams().MdcaCount();
  1561             INFO_1("# of CT params: %d", count);
  1551             //INFO_1("# of CT params: %d", count);
  1562             for ( TInt i = 0; i < count; i++ )
  1552             for ( TInt i = 0; i < count; i++ )
  1563                 {
  1553                 {
  1564                 TPtrC8 key8 = mimeHeader->ContentTypeParams().MdcaPoint( i );
  1554                 TPtrC8 key8 = mimeHeader->ContentTypeParams().MdcaPoint( i );
  1565                 INFO_1("%S", &key8);
  1555                 //INFO_1("%S", &key8);
  1566                 TPtr16 keyUppercase16 = HBufC::NewLC( key8.Length() )->Des();
  1556                 TPtr16 keyUppercase16 = HBufC::NewLC( key8.Length() )->Des();
  1567                 keyUppercase16.Copy( key8 );
  1557                 keyUppercase16.Copy( key8 );
  1568                 keyUppercase16.UpperCase();
  1558                 keyUppercase16.UpperCase();
  1569                 if ( keyUppercase16.Compare( KCharsetTag ) == 0 &&
  1559                 if ( keyUppercase16.Compare( KCharsetTag ) == 0 &&
  1570                      count >= i+1 ) // prevent possible indexing over array limits
  1560                      count >= i+1 ) // prevent possible indexing over array limits