diff -r b0aebde9b1fb -r 9e2a905b887f btobexprofiles/obexreceiveservices/btmsgviewer/src/btmsgviewerutils.cpp --- a/btobexprofiles/obexreceiveservices/btmsgviewer/src/btmsgviewerutils.cpp Mon Jul 12 19:25:26 2010 +0300 +++ b/btobexprofiles/obexreceiveservices/btmsgviewer/src/btmsgviewerutils.cpp Fri Jul 23 15:57:13 2010 +0300 @@ -16,9 +16,12 @@ */ #include +#include #include "btmsgviewerutils.h" +const TInt32 KUidMsgTypeBtTInt32 = 0x10009ED5; + CBtMsgViewerUtils* CBtMsgViewerUtils::NewL() { CBtMsgViewerUtils* me = new (ELeave) CBtMsgViewerUtils(); @@ -42,8 +45,9 @@ { if ( iMsvSession ) { - delete iMsvSession; + delete iMsvSession; } + delete iMimeType; } HBufC* CBtMsgViewerUtils::GetMessagePath(TInt aMessageId, TInt aError) @@ -62,28 +66,55 @@ void CBtMsgViewerUtils::GetMessagePathL(TPtr aMsgPath, const TInt aMessageId) { CMsvEntry* messageEntry = iMsvSession->GetEntryL(aMessageId); - CleanupStack::PushL(messageEntry); - - CMsvEntry* attachmentEntry = iMsvSession->GetEntryL((*messageEntry)[0].Id()); - CleanupStack::PushL(attachmentEntry); - - CMsvStore* store = attachmentEntry->EditStoreL(); - CleanupStack::PushL(store); + CleanupStack::PushL(messageEntry); //1st push - //get file handle for the attachment & the complete path of the file - RFile attachmentFile; - attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); - attachmentFile.FullName(aMsgPath); - attachmentFile.Close(); - - //mark attachment as Read - TMsvEntry attachEntry = attachmentEntry->Entry(); - attachEntry.SetUnread(EFalse); - attachmentEntry->ChangeL(attachEntry); - - CleanupStack::PopAndDestroy(store); - CleanupStack::PopAndDestroy(attachmentEntry); - CleanupStack::PopAndDestroy(messageEntry); + TMsvEntry entry = messageEntry->Entry(); + if(entry.MtmData1() == KUidMsgTypeBtTInt32) + { + CMsvStore* store = messageEntry->ReadStoreL(); + CleanupStack::PushL(store); //2nd push + + //get file handle for the attachment & the complete path of the file + RFile attachmentFile; + attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); + CleanupClosePushL(attachmentFile); //3rd push + User::LeaveIfError(attachmentFile.FullName(aMsgPath)); + CleanupStack::PopAndDestroy(&attachmentFile); + StoreMessageMimeTypeL(aMsgPath); + + //mark attachment as Read + TMsvEntry attachEntry = messageEntry->Entry(); + attachEntry.SetUnread(EFalse); + messageEntry->ChangeL(attachEntry); + + CleanupStack::PopAndDestroy(store); + CleanupStack::PopAndDestroy(messageEntry); + } + else + { + CMsvEntry* attachmentEntry = iMsvSession->GetEntryL((*messageEntry)[0].Id()); + CleanupStack::PushL(attachmentEntry); //2nd push + + CMsvStore* store = attachmentEntry->ReadStoreL(); + CleanupStack::PushL(store); //3rd push + + //get file handle for the attachment & the complete path of the file + RFile attachmentFile; + attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); + CleanupClosePushL(attachmentFile); + User::LeaveIfError(attachmentFile.FullName(aMsgPath)); + CleanupStack::PopAndDestroy(&attachmentFile); + StoreMessageMimeTypeL(aMsgPath); + + //mark attachment as Read + TMsvEntry attachEntry = attachmentEntry->Entry(); + attachEntry.SetUnread(EFalse); + attachmentEntry->ChangeL(attachEntry); + + CleanupStack::PopAndDestroy(store); + CleanupStack::PopAndDestroy(attachmentEntry); + CleanupStack::PopAndDestroy(messageEntry); + } } void CBtMsgViewerUtils::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, @@ -95,5 +126,41 @@ (void) aArg3; } +void CBtMsgViewerUtils::StoreMessageMimeTypeL(TPtr aMsgPath) + { + RFs rfs; + RFile file; + + User::LeaveIfError(rfs.Connect()); + + User::LeaveIfError(rfs.ShareProtected()); + + User::LeaveIfError(file.Open(rfs, aMsgPath, EFileShareReadersOrWriters | EFileRead)); + + TDataRecognitionResult dataType; + RApaLsSession apaSession; + + if(apaSession.Connect() == KErrNone) + { + if (apaSession.RecognizeData(file, dataType) == KErrNone) + { + if(iMimeType) + { + delete iMimeType; + iMimeType = NULL; + } + + iMimeType = dataType.iDataType.Des8().AllocL(); + + rfs.Close(); + apaSession.Close(); + } + } + rfs.Close(); + } +HBufC8* CBtMsgViewerUtils::GetMimeType() + { + return iMimeType; + }