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