252 FLOG(_L("[OBEXUTILS]\t FinaliseMessageL() new ")); |
252 FLOG(_L("[OBEXUTILS]\t FinaliseMessageL() new ")); |
253 |
253 |
254 // Save the size of all the attachment & make visible. |
254 // Save the size of all the attachment & make visible. |
255 TMsvEntry parentTEntry = aParentEntry->Entry(); |
255 TMsvEntry parentTEntry = aParentEntry->Entry(); |
256 parentTEntry.iDate = GetCurrentTime(); |
256 parentTEntry.iDate = GetCurrentTime(); |
257 parentTEntry.iSize = aFileEntry.iSize; |
257 parentTEntry.iSize = aFileEntry.iSize; |
258 parentTEntry.SetUnread(EFalse); |
|
259 // Saved OK. Make the entry visible and flag it as complete. |
258 // Saved OK. Make the entry visible and flag it as complete. |
260 parentTEntry.SetVisible(ETrue); // visible |
259 parentTEntry.SetVisible(ETrue); // visible |
|
260 parentTEntry.SetUnread(ETrue); |
261 parentTEntry.SetInPreparation(EFalse); // complete |
261 parentTEntry.SetInPreparation(EFalse); // complete |
262 parentTEntry.iDescription.Set(aFileNameParser.Name()); // "Subject" |
262 parentTEntry.iDescription.Set(aFileNameParser.FullName()); // "Subject" |
263 aParentEntry->ChangeL(parentTEntry); // commit changes |
263 aParentEntry->ChangeL(parentTEntry); // commit changes |
264 aStore->CommitL(); |
264 aStore->CommitL(); |
265 |
265 |
266 FLOG(_L("[OBEXUTILS]\t FinaliseMessageL() new completed ")); |
266 FLOG(_L("[OBEXUTILS]\t FinaliseMessageL() new completed ")); |
267 } |
267 } |
943 // CObexUtilsMessageHandler::AddEntryToInboxL |
943 // CObexUtilsMessageHandler::AddEntryToInboxL |
944 // ----------------------------------------------------------------------------- |
944 // ----------------------------------------------------------------------------- |
945 // |
945 // |
946 EXPORT_C void TObexUtilsMessageHandler::AddEntryToInboxL( |
946 EXPORT_C void TObexUtilsMessageHandler::AddEntryToInboxL( |
947 TMsvId& aMsvIdParent, |
947 TMsvId& aMsvIdParent, |
948 TFileName& aFullName, |
948 TFileName& aFullName) |
949 RArray<TMsvId>* aMsvIdArray) |
|
950 { |
949 { |
951 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() ")); |
950 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() ")); |
952 |
951 |
953 CDummySessionObserver* sessionObs; |
952 CDummySessionObserver* sessionObs; |
954 CMsvSession* msvSession; |
953 CMsvSession* msvSession; |
955 CreateMsvSessionLC(sessionObs, msvSession); |
954 CreateMsvSessionLC(sessionObs, msvSession); |
956 // 1st, 2nd push |
955 // 1st, 2nd push |
957 |
956 |
958 CMsvEntry* parentEntry = msvSession->GetEntryL(aMsvIdParent); |
957 CMsvEntry* parentEntry = msvSession->GetEntryL(aMsvIdParent); |
959 CleanupStack::PushL(parentEntry); // 3th push |
958 CleanupStack::PushL(parentEntry); // 3th push |
960 |
959 |
961 CMsvEntry* attachEntry = msvSession->GetEntryL(((*parentEntry)[0]).Id()); |
960 CMsvEntry* attachEntry = msvSession->GetEntryL(((*parentEntry)[0]).Id()); |
962 CleanupStack::PushL(attachEntry); // 4th push |
961 CleanupStack::PushL(attachEntry); // 4th push |
963 |
962 |
964 CMsvStore* store = attachEntry->EditStoreL(); |
963 CMsvStore* store = attachEntry->EditStoreL(); |
965 CleanupStack::PushL( store ); // 5th push |
964 CleanupStack::PushL( store ); // 5th push |
966 |
965 |
967 CObexutilsEntryhandler* entryHandler = CObexutilsEntryhandler::NewL(); |
966 CObexutilsEntryhandler* entryHandler = CObexutilsEntryhandler::NewL(); |
968 CleanupStack::PushL(entryHandler); // 6th push |
967 CleanupStack::PushL(entryHandler); // 6th push |
969 |
968 |
970 CMsvAttachment* attachInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile); |
969 CMsvAttachment* attachInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile); |
971 CleanupStack::PushL(attachInfo); // 7th push |
970 CleanupStack::PushL(attachInfo); // 7th push |
972 |
971 |
973 // Create attachment Info |
972 // Create attachment Info |
974 // |
973 // |
975 RFs& fsSess = msvSession->FileSession(); |
974 RFs& fsSess = msvSession->FileSession(); |
976 |
975 |
977 TParse fileNameParser; |
976 TParse fileNameParser; |
978 User::LeaveIfError(fileNameParser.Set(aFullName, NULL, NULL)); |
977 User::LeaveIfError(fileNameParser.Set(aFullName, NULL, NULL)); |
979 attachInfo->SetAttachmentNameL(fileNameParser.NameAndExt()); |
978 attachInfo->SetAttachmentNameL( fileNameParser.FullName()); |
980 |
979 |
981 TEntry fileEntry; |
980 TEntry fileEntry; |
982 User::LeaveIfError(fsSess.Entry( fileNameParser.FullName(), fileEntry) ); |
981 User::LeaveIfError(fsSess.Entry( fileNameParser.FullName(), fileEntry) ); |
983 attachInfo->SetSize(fileEntry.iSize); |
982 attachInfo->SetSize(fileEntry.iSize); |
984 |
983 |
985 // check if it's the bio message |
984 // check if it's the bio message |
986 |
985 |
987 TUid bioMsgId; // SaveMimeAndGetBioLC modifies this |
986 TUid bioMsgId; // SaveMimeAndGetBioLC modifies this |
988 CBIODatabase* bioDB = SaveMimeAndGetBioLC( aFullName, fsSess, attachInfo, bioMsgId ); |
987 CBIODatabase* bioDB = SaveMimeAndGetBioLC( aFullName, fsSess, attachInfo, bioMsgId ); |
989 // 8th push |
988 // 8th push |
990 if (bioDB) // bio message |
989 if (bioDB) // bio message |
991 { |
990 { |
992 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() BIO")); |
991 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() BIO")); |
993 |
992 |
994 RFile file; |
993 RFile file; |
995 User::LeaveIfError(file.Open(fsSess,aFullName,EFileRead)); |
994 User::LeaveIfError(file.Open(fsSess,aFullName,EFileRead)); |
996 TReceivedData receivedData; |
995 TReceivedData receivedData; |
997 receivedData.bytesReceived = fileEntry.iSize; |
996 receivedData.bytesReceived = fileEntry.iSize; |
998 receivedData.recTime = fileEntry.iModified; |
997 receivedData.recTime = fileEntry.iModified; |
999 receivedData.msgName = fileNameParser.Name(); |
998 receivedData.msgName = fileNameParser.Name(); |
1000 |
999 |
1001 StoreAndUpdateBioMessageL( bioDB, bioMsgId, parentEntry, file ); |
1000 StoreAndUpdateBioMessageL( bioDB, bioMsgId, parentEntry, file ); |
1002 FinaliseMessageL(parentEntry, receivedData, store, ETrue); |
1001 FinaliseMessageL(parentEntry, receivedData, store, ETrue); |
1003 TMsvId attachId = attachEntry->EntryId(); |
1002 TMsvId attachId = attachEntry->EntryId(); |
1004 file.Close(); |
1003 file.Close(); |
1005 fsSess.Delete(aFullName); |
1004 fsSess.Delete(aFullName); |
1006 CleanupStack::PopAndDestroy(5); // bioDB, attachInfo, linkHandler, |
1005 CleanupStack::PopAndDestroy(5); // bioDB, attachInfo, linkHandler, |
1007 // store, attachEntry |
1006 // store, attachEntry |
1008 |
1007 |
1009 // PopAndDestroying here because open store locks the entry, |
1008 // PopAndDestroying here because open store locks the entry, |
1010 // it can be deleted only after destroying the store pointer |
1009 // it can be deleted only after destroying the store pointer |
1011 parentEntry->DeleteL(attachId); // invalidate unused attachment |
1010 parentEntry->DeleteL(attachId); // invalidate unused attachment |
1012 CleanupStack::PopAndDestroy(3); // parentEntry, msvSession, sessionObs |
1011 CleanupStack::PopAndDestroy(3); // parentEntry, msvSession, sessionObs |
1013 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() BIO completed")); |
1012 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() BIO completed")); |
1020 entryHandler->AddEntryAttachment(aFullName, attachInfo, store); |
1019 entryHandler->AddEntryAttachment(aFullName, attachInfo, store); |
1021 CleanupStack::Pop(attachInfo); // attachInfo, Pass ownership to store |
1020 CleanupStack::Pop(attachInfo); // attachInfo, Pass ownership to store |
1022 CleanupStack::PopAndDestroy(entryHandler); // entryHandler |
1021 CleanupStack::PopAndDestroy(entryHandler); // entryHandler |
1023 FinaliseMessageL(parentEntry, store,fileEntry, fileNameParser); |
1022 FinaliseMessageL(parentEntry, store,fileEntry, fileNameParser); |
1024 CleanupStack::PopAndDestroy(5); // linkHandler, attachInfo, store, attachEntry, |
1023 CleanupStack::PopAndDestroy(5); // linkHandler, attachInfo, store, attachEntry, |
1025 // parentEntry, msvSession, sessionObs |
1024 // parentEntry, msvSession, sessionObs |
1026 |
|
1027 // File Link is created in INBOX successfully, |
|
1028 // We add MsvId to array. |
|
1029 // |
|
1030 aMsvIdArray->Append(aMsvIdParent); |
|
1031 |
|
1032 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() completed ")); |
1025 FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() completed ")); |
1033 } |
1026 } |
1034 |
1027 } |
|
1028 |
|
1029 // ----------------------------------------------------------------------------- |
|
1030 // CObexUtilsMessageHandler::AddEntryToInboxL |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // |
|
1033 EXPORT_C void TObexUtilsMessageHandler::AddEntryToInboxL( |
|
1034 TMsvId& aMsvIdParent, |
|
1035 TFileName& aFullName, |
|
1036 RArray<TMsvId>* aMsvIdArray) |
|
1037 { |
|
1038 AddEntryToInboxL(aMsvIdParent, aFullName); |
|
1039 aMsvIdArray->Append(aMsvIdParent); |
1035 } |
1040 } |
1036 |
1041 |
1037 // ----------------------------------------------------------------------------- |
1042 // ----------------------------------------------------------------------------- |
1038 // CObexUtilsMessageHandler::UpdateEntryAttachmentL |
1043 // CObexUtilsMessageHandler::UpdateEntryAttachmentL |
1039 // ----------------------------------------------------------------------------- |
1044 // ----------------------------------------------------------------------------- |