15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "emailtrace.h" |
18 #include "emailtrace.h" |
19 #include "ipsplgheaders.h" |
19 #include "ipsplgheaders.h" |
20 #include "FreestyleEmailUiConstants.h" |
20 |
21 |
21 // <qmail> FreestyleEmailUiConstants include removed |
22 #define FREESTYLE_EMAIL_UI_SID 0x2001E277 |
22 |
|
23 // <qmail> |
|
24 #include "ipsplgsosbaseplugin.hrh" |
|
25 #include "ipsplgmailstoreroperation.h" |
|
26 #include "ipsplgmessagepartstoreroperation.h" |
|
27 #include "BasePlugin.h" |
|
28 //<Qmail> |
|
29 #include "ipssosextendedsettingsmanager.h" |
|
30 #include "ipssettingkeys.h" |
|
31 //</Qmail> |
|
32 //</qmail> |
|
33 |
|
34 #define FREESTYLE_EMAIL_UI_SID 0x200255BA |
23 |
35 |
24 const TInt KOpGranularity = 2; |
36 const TInt KOpGranularity = 2; |
25 |
37 |
26 _LIT( KMimeTextCalRequest, "text/calendar; method=REQUEST;" ); |
38 // <qmail> remove unused literals |
27 _LIT( KMimeTextCalResponse, "text/calendar; method=RESPONSE;" ); |
|
28 _LIT( KMimeTextCalCancel, "text/calendar; method=CANCEL;" ); |
|
29 _LIT8( KMethod, "method" ); |
|
30 _LIT8( KRequest, "REQUEST" ); |
|
31 _LIT8( KResponse, "RESPONSE" ); |
|
32 _LIT8( KCancel, "CANCEL" ); |
|
33 _LIT( KLineFeed, "\r\n"); |
|
34 |
39 |
35 #ifdef __WINS__ |
40 #ifdef __WINS__ |
36 _LIT( KEmulatorIMEI, "123456789012345" ); |
41 _LIT( KEmulatorIMEI, "123456789012345" ); |
37 #endif // __WINS__ |
42 #endif // __WINS__ |
38 |
43 |
39 // ---------------------------------------------------------------------------- |
44 //<Qmail> |
40 // ---------------------------------------------------------------------------- |
45 // ---------------------------------------------------------------------------- |
41 // |
46 // ---------------------------------------------------------------------------- |
|
47 void CIpsPlgSosBasePlugin::ActiveFolderChanged( |
|
48 const TFSMailMsgId& aActiveMailboxId, |
|
49 const TFSMailMsgId& aActiveFolderId) |
|
50 { |
|
51 TRAP_IGNORE( HandleActiveFolderChangeL(aActiveMailboxId,aActiveFolderId) ); |
|
52 } |
|
53 |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // ---------------------------------------------------------------------------- |
|
57 CEmailExtension* CIpsPlgSosBasePlugin::ExtensionL( const TUid& aInterfaceUid ) |
|
58 { |
|
59 if(aInterfaceUid != KEmailMailboxStateExtensionUid) |
|
60 { |
|
61 User::Leave(KErrNotSupported); |
|
62 } |
|
63 |
|
64 return iStateExtension; |
|
65 } |
|
66 //</Qmail> |
|
67 // ---------------------------------------------------------------------------- |
|
68 // ---------------------------------------------------------------------------- |
|
69 // <qmail> iSettingsApi removed |
42 CIpsPlgSosBasePlugin::CIpsPlgSosBasePlugin( const TUint aFSPluginId ) : |
70 CIpsPlgSosBasePlugin::CIpsPlgSosBasePlugin( const TUint aFSPluginId ) : |
43 iFSPluginId( aFSPluginId ), |
71 iFSPluginId( aFSPluginId ), |
44 iSession( NULL ), |
72 iSession( NULL ), |
45 iMsgMapper( NULL ), |
73 iMsgMapper( NULL ), |
46 iOperations( KOpGranularity ), |
74 iOperations( KOpGranularity ), |
48 iSmtpService( NULL ), |
76 iSmtpService( NULL ), |
49 iCachedEntry( NULL ), |
77 iCachedEntry( NULL ), |
50 iCachedEmailMessage( NULL ), |
78 iCachedEmailMessage( NULL ), |
51 iMruList( NULL ), |
79 iMruList( NULL ), |
52 iSearch( NULL ), |
80 iSearch( NULL ), |
53 iSettingsApi( NULL ), |
|
54 iEventHandler( NULL ), |
81 iEventHandler( NULL ), |
55 iSessionOk( ETrue ), |
82 iSessionOk( ETrue ), |
56 iBrandingId( NULL ), |
83 iBrandingId( NULL ), |
57 iIsUnderUiProcess( EFalse ) |
84 iIsUnderUiProcess( EFalse ) |
58 { |
85 { |
59 FUNC_LOG; |
86 FUNC_LOG; |
60 } |
87 } |
61 |
88 |
62 // ---------------------------------------------------------------------------- |
89 // ---------------------------------------------------------------------------- |
63 // ---------------------------------------------------------------------------- |
90 // ---------------------------------------------------------------------------- |
64 // |
91 // <qmail> iSettingsApi, iWait removed |
65 CIpsPlgSosBasePlugin::~CIpsPlgSosBasePlugin() |
92 CIpsPlgSosBasePlugin::~CIpsPlgSosBasePlugin() |
66 { |
93 { |
67 FUNC_LOG; |
94 FUNC_LOG; |
68 if ( iMsvOpDeleteMessage ) |
|
69 { |
|
70 iMsvOpDeleteMessage->Cancel(); |
|
71 } |
|
72 |
|
73 if ( iWaitDeleteMessage ) |
|
74 { |
|
75 iWaitDeleteMessage->Cancel(); |
|
76 } |
|
77 |
|
78 delete iMsvOpDeleteMessage; |
|
79 iMsvOpDeleteMessage = NULL; |
|
80 delete iWaitDeleteMessage; |
|
81 iWaitDeleteMessage = NULL; |
|
82 delete icEntry; |
|
83 icEntry = NULL; |
|
84 if ( iWait.IsStarted() ) |
|
85 { |
|
86 iWait.AsyncStop(); |
|
87 } |
|
88 |
|
89 iOperations.ResetAndDestroy(); |
95 iOperations.ResetAndDestroy(); |
90 iActivitytimers.ResetAndDestroy(); |
96 iActivitytimers.ResetAndDestroy(); |
91 iOperations.Close(); |
97 iOperations.Close(); |
92 iActivitytimers.Close(); |
98 iActivitytimers.Close(); |
93 delete iSmtpService; |
99 delete iSmtpService; |
94 delete iMruList; |
100 delete iMruList; |
95 if ( iEventHandler ) |
101 if ( iEventHandler ) |
96 { |
102 { |
97 iEventHandler->UnRegisterPropertyObserver( iSyncStateHandler ); |
103 iEventHandler->UnRegisterPropertyObserver( iSyncStateHandler ); |
98 } |
104 } |
|
105 delete iStateExtension; |
99 delete iEventHandler; |
106 delete iEventHandler; |
100 delete iCachedEntry; |
107 delete iCachedEntry; |
101 delete iCachedEmailMessage; |
108 delete iCachedEmailMessage; |
102 delete iMsgMapper; |
109 delete iMsgMapper; |
103 delete iSearch; |
110 delete iSearch; |
104 delete iSettingsApi; |
|
105 delete iSyncStateHandler; |
111 delete iSyncStateHandler; |
106 delete iSession; |
112 delete iSession; |
107 delete iBrandingId; |
113 delete iBrandingId; |
108 } |
114 } |
109 |
115 |
110 // ---------------------------------------------------------------------------- |
116 // ---------------------------------------------------------------------------- |
111 // ---------------------------------------------------------------------------- |
117 // ---------------------------------------------------------------------------- |
112 void CIpsPlgSosBasePlugin::BaseConstructL() |
118 void CIpsPlgSosBasePlugin::BaseConstructL() |
113 { |
119 { |
114 FUNC_LOG; |
120 FUNC_LOG; |
|
121 iStateExtension = CIpsStateExtension::NewL(*this); |
115 iEventHandler = CIpsPlgEventHandler::NewL( *this ); |
122 iEventHandler = CIpsPlgEventHandler::NewL( *this ); |
116 iSession = CMsvSession::OpenAsyncL( *iEventHandler ); |
123 iSession = CMsvSession::OpenAsyncL( *iEventHandler ); |
117 iMsgMapper = CIpsPlgMsgMapper::NewL( *iSession, *this ); |
124 iMsgMapper = CIpsPlgMsgMapper::NewL( *iSession, *this ); |
118 iSmtpService = CIpsPlgSmtpService::NewL( *iSession, *this ); |
125 iSmtpService = CIpsPlgSmtpService::NewL( *iSession, *this ); |
119 iMruList = CIpsPlgMruList::NewL( ); |
126 iMruList = CIpsPlgMruList::NewL( ); |
120 iSearch = CIpsPlgSearch::NewL( *iSession, *this ); |
127 iSearch = CIpsPlgSearch::NewL( *iSession, *this ); |
121 iSettingsApi = CIpsSetDataApi::NewL( *iSession ); |
128 // <qmail> iSettingsApi removed |
122 iSettingsApi->GetIMEIFromThePhoneL( iIMEI ); |
|
123 iSyncStateHandler = CIpsPlgSyncStateHandler::NewL( |
129 iSyncStateHandler = CIpsPlgSyncStateHandler::NewL( |
124 *iSession, *this, iOperations ); |
130 *iSession, *this, iOperations ); |
125 iEventHandler->RegisterPropertyObserverL( iSyncStateHandler ); |
131 iEventHandler->RegisterPropertyObserverL( iSyncStateHandler ); |
126 |
132 |
127 RProcess process; |
133 RProcess process; |
836 } |
823 } |
837 |
824 |
838 // ---------------------------------------------------------------------------- |
825 // ---------------------------------------------------------------------------- |
839 // ---------------------------------------------------------------------------- |
826 // ---------------------------------------------------------------------------- |
840 CFSMailMessage* CIpsPlgSosBasePlugin::CreateMessageToSendL( |
827 CFSMailMessage* CIpsPlgSosBasePlugin::CreateMessageToSendL( |
841 const TFSMailMsgId& aMailBoxId ) |
828 const TFSMailMsgId& /*aMailBoxId*/ ) |
842 { |
829 { |
843 FUNC_LOG; |
830 // <qmail> not used any more |
844 CFSMailMessage* msg = iSmtpService->CreateNewSmtpMessageL( aMailBoxId ); |
831 User::Leave(KErrFSMailPluginNotSupported); |
845 return msg; |
832 return NULL; // prevents compiler warning |
846 } |
833 } |
847 |
834 |
|
835 // <qmail> |
|
836 // ---------------------------------------------------------------------------- |
|
837 // ---------------------------------------------------------------------------- |
|
838 void CIpsPlgSosBasePlugin::CreateMessageToSendL( const TFSMailMsgId& aMailBoxId, |
|
839 MFSMailRequestObserver& aOperationObserver, |
|
840 const TInt aRequestId ) |
|
841 { |
|
842 FUNC_LOG; |
|
843 // asynchronous message creation is started here to enable canceling of the operation |
|
844 TMsvPartList partList( KMsvMessagePartBody ); |
|
845 |
|
846 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this); |
|
847 |
|
848 //<qmail> removed mboxEntry from parameters + changed iSmtpService to pointer |
|
849 |
|
850 CIpsPlgCreateMessageOperation* op = CIpsPlgCreateMessageOperation::NewL( |
|
851 *iSmtpService, |
|
852 *iSession, |
|
853 watcher->iStatus, |
|
854 partList, |
|
855 aMailBoxId, |
|
856 aOperationObserver, |
|
857 aRequestId ); |
|
858 //</qmail> |
|
859 watcher->SetOperation( op ); |
|
860 |
|
861 iOperations.AppendL( watcher ); |
|
862 CleanupStack::Pop( watcher ); |
|
863 } |
|
864 // </qmail> |
|
865 |
848 // ---------------------------------------------------------------------------- |
866 // ---------------------------------------------------------------------------- |
849 // ---------------------------------------------------------------------------- |
867 // ---------------------------------------------------------------------------- |
850 CFSMailMessage* CIpsPlgSosBasePlugin::CreateForwardMessageL( |
868 CFSMailMessage* CIpsPlgSosBasePlugin::CreateForwardMessageL( |
|
869 const TFSMailMsgId& /*aMailBoxId*/, |
|
870 const TFSMailMsgId& /*aOriginalMessageId*/, |
|
871 const TDesC& /*aHeaderDescriptor*/ ) |
|
872 { |
|
873 // <qmail> not used any more |
|
874 User::Leave(KErrFSMailPluginNotSupported); |
|
875 return NULL; // prevents compiler warning |
|
876 } |
|
877 |
|
878 // <qmail> |
|
879 // ---------------------------------------------------------------------------- |
|
880 // ---------------------------------------------------------------------------- |
|
881 void CIpsPlgSosBasePlugin::CreateForwardMessageL( |
851 const TFSMailMsgId& aMailBoxId, |
882 const TFSMailMsgId& aMailBoxId, |
852 const TFSMailMsgId& aOriginalMessageId, |
883 const TFSMailMsgId& aOriginalMessageId, |
853 const TDesC& aHeaderDescriptor ) |
884 MFSMailRequestObserver& aOperationObserver, |
854 { |
885 const TInt aRequestId, |
855 FUNC_LOG; |
886 const TDesC& /*aHeaderDescriptor*/ ) |
856 CFSMailMessage* msg = iSmtpService->CreateForwardSmtpMessageL( |
887 { |
857 aMailBoxId, aOriginalMessageId ); |
888 FUNC_LOG; |
858 |
889 // asynchronous message creation is started here to enable canceling of the operation |
859 if ( aHeaderDescriptor != KNullDesC ) |
890 |
860 { |
891 // 1. part of function checs that body text and all |
861 // Ignoring trap as it is better to provide something in case of the |
892 // attachments are fetched |
862 // below fix method fails than nothing. |
893 TMsvEntry orgMsg; |
863 TRAP_IGNORE( FixReplyForwardHeaderL( |
894 TMsvId service; |
864 msg, |
895 User::LeaveIfError( iSession->GetEntry( |
865 aMailBoxId, |
896 aOriginalMessageId.Id(), service, orgMsg ) ); |
866 aOriginalMessageId, |
897 |
867 aHeaderDescriptor ) ); |
898 if ( orgMsg.Id() == KMsvNullIndexEntryIdValue ) |
868 } |
899 { |
869 |
900 User::Leave(KErrNotFound); |
870 return msg; |
901 } |
871 } |
902 |
872 |
903 if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) && |
873 // ---------------------------------------------------------------------------- |
904 ( orgMsg.iMtm == KSenduiMtmSmtpUid ) ) |
874 // ---------------------------------------------------------------------------- |
905 { |
875 CFSMailMessage* CIpsPlgSosBasePlugin::CreateReplyMessageL( |
906 iSmtpService->ChangeServiceIdL( orgMsg ); |
|
907 } |
|
908 |
|
909 TMsvPartList partList( KMsvMessagePartBody | KMsvMessagePartAttachments ); |
|
910 |
|
911 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this); |
|
912 |
|
913 //<qmail> changed iSmtpService to pointer |
|
914 CIpsPlgCreateForwardMessageOperation* op = CIpsPlgCreateForwardMessageOperation::NewL( |
|
915 *iSmtpService, |
|
916 *iSession, |
|
917 watcher->iStatus, |
|
918 partList, |
|
919 aMailBoxId, |
|
920 orgMsg.Id(), |
|
921 aOperationObserver, |
|
922 aRequestId ); |
|
923 //</qmail> |
|
924 watcher->SetOperation( op ); |
|
925 |
|
926 iOperations.AppendL( watcher ); |
|
927 CleanupStack::Pop( watcher ); |
|
928 } |
|
929 // </qmail> |
|
930 |
|
931 // ---------------------------------------------------------------------------- |
|
932 // ---------------------------------------------------------------------------- |
|
933 CFSMailMessage* CIpsPlgSosBasePlugin::CreateReplyMessageL( |
|
934 const TFSMailMsgId& /*aMailBoxId*/, |
|
935 const TFSMailMsgId& /*aOriginalMessageId*/, |
|
936 const TBool /*aReplyToAll*/, |
|
937 const TDesC& /*aHeaderDescriptor*/ ) |
|
938 { |
|
939 // <qmail> not used any more |
|
940 User::Leave(KErrFSMailPluginNotSupported); |
|
941 return NULL; // prevents compiler warning |
|
942 } |
|
943 |
|
944 // <qmail> |
|
945 // ---------------------------------------------------------------------------- |
|
946 // ---------------------------------------------------------------------------- |
|
947 void CIpsPlgSosBasePlugin::CreateReplyMessageL( |
876 const TFSMailMsgId& aMailBoxId, |
948 const TFSMailMsgId& aMailBoxId, |
877 const TFSMailMsgId& aOriginalMessageId, |
949 const TFSMailMsgId& aOriginalMessageId, |
878 const TBool aReplyToAll, |
950 const TBool aReplyToAll, |
879 const TDesC& aHeaderDescriptor ) |
951 MFSMailRequestObserver& aOperationObserver, |
880 { |
952 const TInt aRequestId, |
881 FUNC_LOG; |
953 const TDesC& /* aHeaderDescriptor */ ) |
882 CFSMailMessage* msg = iSmtpService->CreateReplySmtpMessageL( |
954 { |
883 aMailBoxId, aOriginalMessageId, aReplyToAll ); |
955 FUNC_LOG; |
884 |
956 // asynchronous message creation is started here to enable canceling of the operation |
885 if ( aHeaderDescriptor != KNullDesC ) |
957 |
886 { |
958 // find orginal message header and check that body is fetched |
887 // Ignoring trap as it is better to provide something in case of the |
959 TMsvEntry orgMsg; |
888 // below fix method fails than nothing. |
960 TMsvId service; |
889 TRAP_IGNORE( FixReplyForwardHeaderL( |
961 User::LeaveIfError( |
890 msg, |
962 iSession->GetEntry( aOriginalMessageId.Id(), service, orgMsg ) ); |
891 aMailBoxId, |
963 |
892 aOriginalMessageId, |
964 if ( orgMsg.Id() == KMsvNullIndexEntryIdValue ) |
893 aHeaderDescriptor ) ); |
965 { |
894 } |
966 User::Leave(KErrNotFound); |
895 |
967 } |
896 return msg; |
968 |
897 } |
969 if ( ( orgMsg.Parent() == KMsvSentEntryIdValue ) && |
898 |
970 ( orgMsg.iMtm == KSenduiMtmSmtpUid ) ) |
899 // ---------------------------------------------------------------------------- |
971 { |
900 // ---------------------------------------------------------------------------- |
972 iSmtpService->ChangeServiceIdL( orgMsg ); |
901 // |
973 } |
902 void CIpsPlgSosBasePlugin::StoreMessageL( |
974 |
|
975 // partList flags control e.g. what kind of recipient set is created |
|
976 TMsvPartList partList = KMsvMessagePartBody | KMsvMessagePartDescription |
|
977 | KMsvMessagePartOriginator; |
|
978 if( aReplyToAll ) |
|
979 { |
|
980 partList |= KMsvMessagePartRecipient; |
|
981 } |
|
982 |
|
983 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this); |
|
984 |
|
985 //<qmail> changed iSmtpService to pointer |
|
986 CIpsPlgCreateReplyMessageOperation* op = CIpsPlgCreateReplyMessageOperation::NewL( |
|
987 *iSmtpService, |
|
988 *iSession, |
|
989 watcher->iStatus, |
|
990 partList, |
|
991 aMailBoxId, |
|
992 orgMsg.Id(), |
|
993 aOperationObserver, |
|
994 aRequestId ); |
|
995 //</qmail> |
|
996 watcher->SetOperation( op ); |
|
997 |
|
998 iOperations.AppendL( watcher ); |
|
999 CleanupStack::Pop( watcher ); |
|
1000 } |
|
1001 // </qmail> |
|
1002 |
|
1003 // ---------------------------------------------------------------------------- |
|
1004 // ---------------------------------------------------------------------------- |
|
1005 // |
|
1006 void CIpsPlgSosBasePlugin::StoreMessageL( |
903 const TFSMailMsgId& aMailBoxId, |
1007 const TFSMailMsgId& aMailBoxId, |
904 CFSMailMessage& aMessage ) |
1008 CFSMailMessage& aMessage ) |
905 { |
1009 { |
906 FUNC_LOG; |
1010 FUNC_LOG; |
907 TInt status( KErrNone); |
1011 TInt status( KErrNone); |
1005 } |
1138 } |
1006 |
1139 |
1007 // ---------------------------------------------------------------------------- |
1140 // ---------------------------------------------------------------------------- |
1008 // ---------------------------------------------------------------------------- |
1141 // ---------------------------------------------------------------------------- |
1009 CFSMailMessagePart* CIpsPlgSosBasePlugin::NewChildPartFromFileL( |
1142 CFSMailMessagePart* CIpsPlgSosBasePlugin::NewChildPartFromFileL( |
|
1143 const TFSMailMsgId& /*aMailBoxId*/, |
|
1144 const TFSMailMsgId& /*aParentFolderId*/, |
|
1145 const TFSMailMsgId& /*aMessageId*/, |
|
1146 const TFSMailMsgId& /*aParentPartId*/, |
|
1147 const TDesC& /*aContentType*/, |
|
1148 const TDesC& /*aFilePath*/ ) |
|
1149 { |
|
1150 // <qmail> not used any more |
|
1151 User::Leave(KErrFSMailPluginNotSupported); |
|
1152 return NULL; // prevents compiler warning |
|
1153 } |
|
1154 |
|
1155 // <qmail> |
|
1156 // ---------------------------------------------------------------------------- |
|
1157 // ---------------------------------------------------------------------------- |
|
1158 void CIpsPlgSosBasePlugin::NewChildPartFromFileL( |
1010 const TFSMailMsgId& aMailBoxId, |
1159 const TFSMailMsgId& aMailBoxId, |
1011 const TFSMailMsgId& /* aParentFolderId */, |
1160 const TFSMailMsgId& /* aParentFolderId */, |
1012 const TFSMailMsgId& aMessageId, |
1161 const TFSMailMsgId& aMessageId, |
1013 const TFSMailMsgId& /* aParentPartId */, |
1162 const TFSMailMsgId& /* aParentPartId */, |
1014 const TDesC& aContentType, |
1163 const TDesC& aContentType, |
1015 const TDesC& aFilePath ) |
1164 const TDesC& aFilePath, |
1016 { |
1165 MFSMailRequestObserver& aOperationObserver, |
1017 FUNC_LOG; |
1166 const TInt aRequestId ) |
1018 CFSMailMessagePart* result ( NULL ); |
1167 { |
1019 CMsvEntry* cEntry( NULL ); |
1168 FUNC_LOG; |
1020 CImEmailMessage* message( NULL ); |
1169 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this); |
1021 RFile file; |
1170 |
1022 TInt fileSize( 0 ); |
1171 CIpsPlgNewChildPartFromFileOperation* op = CIpsPlgNewChildPartFromFileOperation::NewL( |
1023 TBool parentToMultipartAlternative( EFalse ); |
1172 *iSession, |
1024 |
1173 watcher->iStatus, |
1025 // Read attachment size |
1174 aMailBoxId, |
1026 User::LeaveIfError( file.Open( iSession->FileSession(), aFilePath, EFileShareReadersOnly ) ); |
1175 aMessageId, |
1027 |
1176 aContentType, |
1028 //in rare case that file has disappeared while sending |
1177 aFilePath, |
1029 //we just won't get the size for it |
1178 aOperationObserver, |
1030 file.Size( fileSize ); |
1179 aRequestId, |
1031 file.Close(); |
1180 iMsgMapper); |
1032 |
1181 watcher->SetOperation( op ); |
1033 // Take ownership of message entry objects since thanks to |
1182 |
1034 // "clever" use of active scheduler waits we can re-enter |
1183 iOperations.AppendL( watcher ); |
1035 // this function leading to crashes if somebody clears the cache |
1184 CleanupStack::Pop( watcher ); |
1036 // while this iteration still needs them |
1185 } |
1037 TakeMessageEntryLC( aMessageId.Id(), cEntry, message ); |
1186 // </qmail> |
1038 |
1187 |
1039 // Operation waiter needed to implement synchronous operation |
1188 // ---------------------------------------------------------------------------- |
1040 // on the top of async API |
1189 // ---------------------------------------------------------------------------- |
1041 CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewL(); |
|
1042 CleanupStack::PushL( waiter ); |
|
1043 |
|
1044 // Initialize CMsvAttachment instance for the attachment creation |
|
1045 CMsvAttachment* info = CMsvAttachment::NewL( CMsvAttachment::EMsvFile ); |
|
1046 CleanupStack::PushL( info ); |
|
1047 info->SetAttachmentNameL( aFilePath ); |
|
1048 info->SetSize( fileSize ); |
|
1049 |
|
1050 // Start attachment creation |
|
1051 message->AttachmentManager().AddAttachmentL( |
|
1052 aFilePath, info, waiter->iStatus ); |
|
1053 CleanupStack::Pop( info ); // attachment manager takes ownership |
|
1054 |
|
1055 waiter->Start(); |
|
1056 CleanupStack::PopAndDestroy( waiter ); |
|
1057 |
|
1058 // Return message entry objects back to cache |
|
1059 CleanupStack::Pop( 2 ); // cEntry, message |
|
1060 ReturnMessageEntry( cEntry, message ); |
|
1061 |
|
1062 // Dig out the entry ID of the new attachment (unbelievable that |
|
1063 // there seems to be no better way to do this) |
|
1064 message->GetAttachmentsListL( cEntry->Entry().Id( ), |
|
1065 CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly ); |
|
1066 TKeyArrayFix key( 0, ECmpTInt32 ); |
|
1067 CMsvEntrySelection* attachmentIds = message->Selection().CopyLC(); |
|
1068 attachmentIds->Sort( key ); |
|
1069 if ( !attachmentIds->Count() ) |
|
1070 { |
|
1071 User::Leave( KErrGeneral ); |
|
1072 } |
|
1073 TMsvId newAttachmentId = (*attachmentIds)[ attachmentIds->Count()-1 ]; |
|
1074 CleanupStack::PopAndDestroy( attachmentIds ); |
|
1075 |
|
1076 CMsvEntry* cAtta = iSession->GetEntryL( newAttachmentId ); |
|
1077 CleanupStack::PushL( cAtta ); |
|
1078 |
|
1079 // Set filename to iDetails |
|
1080 TMsvEntry tEntry = cAtta->Entry(); |
|
1081 tEntry.iDetails.Set( aFilePath ); |
|
1082 cAtta->ChangeL( tEntry ); |
|
1083 |
|
1084 if( cAtta->HasStoreL() ) |
|
1085 { |
|
1086 CMsvStore* store = cAtta->EditStoreL(); |
|
1087 CleanupStack::PushL( store ); |
|
1088 CImMimeHeader* mimeHeader = CImMimeHeader::NewLC(); |
|
1089 |
|
1090 if( store->IsPresentL( KUidMsgFileMimeHeader ) ) |
|
1091 { |
|
1092 mimeHeader->RestoreL( *store ); |
|
1093 CDesC8Array& array = mimeHeader->ContentTypeParams(); |
|
1094 array.AppendL( KMethod ); |
|
1095 parentToMultipartAlternative = ETrue; |
|
1096 |
|
1097 if( aContentType.Find( KMimeTextCalRequest ) != KErrNotFound ) |
|
1098 { |
|
1099 array.AppendL( KRequest ); |
|
1100 } |
|
1101 else if( aContentType.Find( KMimeTextCalResponse ) != KErrNotFound ) |
|
1102 { |
|
1103 array.AppendL( KResponse ); |
|
1104 } |
|
1105 else if( aContentType.Find( KMimeTextCalCancel ) != KErrNotFound ) |
|
1106 { |
|
1107 array.AppendL( KCancel ); |
|
1108 } |
|
1109 else |
|
1110 { |
|
1111 parentToMultipartAlternative = EFalse; |
|
1112 } |
|
1113 mimeHeader->StoreWithoutCommitL( *store ); |
|
1114 store->CommitL(); |
|
1115 } |
|
1116 |
|
1117 CleanupStack::PopAndDestroy( 2, store ); |
|
1118 } |
|
1119 |
|
1120 if( parentToMultipartAlternative && |
|
1121 aFilePath.Find( _L(".ics")) != KErrNotFound ) |
|
1122 { |
|
1123 TMsvEntry tAttaEntry = cAtta->Entry(); |
|
1124 TMsvId id = tAttaEntry.Parent(); |
|
1125 CMsvEntry* cParent = iSession->GetEntryL( id ); |
|
1126 CleanupStack::PushL( cParent ); |
|
1127 |
|
1128 TMsvEmailEntry tEntry = cParent->Entry(); |
|
1129 tEntry.SetMessageFolderType( EFolderTypeAlternative ); |
|
1130 cParent->ChangeL( tEntry ); |
|
1131 |
|
1132 CleanupStack::PopAndDestroy( cParent ); |
|
1133 } |
|
1134 CleanupStack::PopAndDestroy( cAtta ); |
|
1135 |
|
1136 // Delete the message entries to get all the changes to disk and |
|
1137 // possible store locks released |
|
1138 CleanCachedMessageEntries(); |
|
1139 |
|
1140 // Create the FS message part object |
|
1141 result = iMsgMapper->GetMessagePartL( newAttachmentId, aMailBoxId, |
|
1142 aMessageId ); |
|
1143 |
|
1144 return result; |
|
1145 } |
|
1146 |
|
1147 // ---------------------------------------------------------------------------- |
|
1148 // ---------------------------------------------------------------------------- |
|
1149 CFSMailMessagePart* CIpsPlgSosBasePlugin::NewChildPartFromFileL( |
1190 CFSMailMessagePart* CIpsPlgSosBasePlugin::NewChildPartFromFileL( |
1150 const TFSMailMsgId& aMailBoxId, |
1191 const TFSMailMsgId& /*aMailBoxId*/, |
1151 const TFSMailMsgId& /* aParentFolderId */, |
1192 const TFSMailMsgId& /*aParentFolderId*/, |
1152 const TFSMailMsgId& aMessageId, |
1193 const TFSMailMsgId& /*aMessageId*/, |
1153 const TFSMailMsgId& /* aParentPartId */, |
1194 const TFSMailMsgId& /*aParentPartId*/, |
1154 const TDesC& aContentType, |
1195 const TDesC& /*aContentType*/, |
1155 RFile& aFile ) |
1196 RFile& /*aFile*/ ) |
1156 { |
1197 { |
1157 FUNC_LOG; |
1198 // <qmail> not used any more |
1158 |
1199 User::Leave(KErrFSMailPluginNotSupported); |
1159 // Initialize helper variables |
1200 return NULL; // prevents compiler warning |
1160 CFSMailMessagePart* result ( NULL ); |
|
1161 CMsvEntry* cEntry( NULL ); |
|
1162 CImEmailMessage* message( NULL ); |
|
1163 TInt fileSize( 0 ); |
|
1164 TBuf<KMaxFileName> fileName; |
|
1165 |
|
1166 // Take ownership of message entry objects since thanks to |
|
1167 // "clever" use of active scheduler waits we can re-enter |
|
1168 // this function leading to crashes if somebody clears the cache |
|
1169 // while this iteration still needs them |
|
1170 TakeMessageEntryLC( aMessageId.Id(), cEntry, message ); |
|
1171 |
|
1172 // Operation waiter needed to implement synchronous operation |
|
1173 // on the top of async API |
|
1174 CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewL(); |
|
1175 CleanupStack::PushL( waiter ); |
|
1176 |
|
1177 // Initialize CMsvAttachment instance for the attachment creation |
|
1178 CMsvAttachment* info = CMsvAttachment::NewL( CMsvAttachment::EMsvFile ); |
|
1179 CleanupStack::PushL( info ); |
|
1180 |
|
1181 // Read attachment size |
|
1182 User::LeaveIfError( aFile.Size( fileSize ) ); |
|
1183 info->SetSize( fileSize ); |
|
1184 |
|
1185 // Read attachment filename |
|
1186 User::LeaveIfError( aFile.FullName( fileName ) ); |
|
1187 info->SetAttachmentNameL( fileName ); |
|
1188 |
|
1189 message->AttachmentManager().AddAttachmentL( aFile, info, waiter->iStatus ); |
|
1190 CleanupStack::Pop( info ); // attachment manager takes ownership |
|
1191 |
|
1192 waiter->Start(); |
|
1193 CleanupStack::PopAndDestroy( waiter ); |
|
1194 |
|
1195 // Return message entry objects back to cache |
|
1196 CleanupStack::Pop( 2 ); // cEntry, message |
|
1197 ReturnMessageEntry( cEntry, message ); |
|
1198 |
|
1199 // Dig out the entry ID of the new attachment |
|
1200 message->GetAttachmentsListL( cEntry->Entry().Id( ), |
|
1201 CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly ); |
|
1202 TKeyArrayFix key( 0, ECmpTInt32 ); |
|
1203 CMsvEntrySelection* attachmentIds = message->Selection().CopyLC(); |
|
1204 attachmentIds->Sort( key ); |
|
1205 if ( !attachmentIds->Count() ) |
|
1206 { |
|
1207 User::Leave( KErrGeneral ); |
|
1208 } |
|
1209 TMsvId newAttachmentId = (*attachmentIds)[ attachmentIds->Count()-1 ]; |
|
1210 CleanupStack::PopAndDestroy( attachmentIds ); |
|
1211 |
|
1212 // Meeting request related handling |
|
1213 TBool parentToMultipartAlternative( EFalse ); |
|
1214 CMsvEntry* cAtta = iSession->GetEntryL( newAttachmentId ); |
|
1215 CleanupStack::PushL( cAtta ); |
|
1216 |
|
1217 // Set filename to iDetails |
|
1218 TMsvEntry tEntry = cAtta->Entry(); |
|
1219 tEntry.iDetails.Set( fileName ); |
|
1220 cAtta->ChangeL( tEntry ); |
|
1221 |
|
1222 if( cAtta->HasStoreL() ) |
|
1223 { |
|
1224 CMsvStore* store = cAtta->EditStoreL(); |
|
1225 CleanupStack::PushL( store ); |
|
1226 CImMimeHeader* mimeHeader = CImMimeHeader::NewLC(); |
|
1227 |
|
1228 if( store->IsPresentL( KUidMsgFileMimeHeader ) ) |
|
1229 { |
|
1230 mimeHeader->RestoreL( *store ); |
|
1231 CDesC8Array& array = mimeHeader->ContentTypeParams(); |
|
1232 array.AppendL( KMethod ); |
|
1233 parentToMultipartAlternative = ETrue; |
|
1234 |
|
1235 if( aContentType.Find( KMimeTextCalRequest ) != KErrNotFound ) |
|
1236 { |
|
1237 array.AppendL( KRequest ); |
|
1238 } |
|
1239 else if( aContentType.Find( KMimeTextCalResponse ) != KErrNotFound ) |
|
1240 { |
|
1241 array.AppendL( KResponse ); |
|
1242 } |
|
1243 else if( aContentType.Find( KMimeTextCalCancel ) != KErrNotFound ) |
|
1244 { |
|
1245 array.AppendL( KCancel ); |
|
1246 } |
|
1247 else |
|
1248 { |
|
1249 parentToMultipartAlternative = EFalse; |
|
1250 } |
|
1251 mimeHeader->StoreWithoutCommitL( *store ); |
|
1252 store->CommitL(); |
|
1253 } |
|
1254 CleanupStack::PopAndDestroy( 2, store ); |
|
1255 } |
|
1256 if( parentToMultipartAlternative && fileName.Find( _L(".ics")) != KErrNotFound ) |
|
1257 { |
|
1258 TMsvEntry tAttaEntry = cAtta->Entry(); |
|
1259 TMsvId id = tAttaEntry.Parent(); |
|
1260 CMsvEntry* cParent = iSession->GetEntryL( id ); |
|
1261 CleanupStack::PushL( cParent ); |
|
1262 |
|
1263 TMsvEmailEntry tEntry = cParent->Entry(); |
|
1264 tEntry.SetMessageFolderType( EFolderTypeAlternative ); |
|
1265 cParent->ChangeL( tEntry ); |
|
1266 |
|
1267 CleanupStack::PopAndDestroy( cParent ); |
|
1268 } |
|
1269 CleanupStack::PopAndDestroy( cAtta ); |
|
1270 |
|
1271 // Delete the message entries to get all the changes to disk and |
|
1272 // possible store locks released |
|
1273 CleanCachedMessageEntries(); |
|
1274 |
|
1275 // Create the FS message part object and return it |
|
1276 result = iMsgMapper->GetMessagePartL( newAttachmentId, aMailBoxId, |
|
1277 aMessageId ); |
|
1278 return result; |
|
1279 } |
1201 } |
1280 |
1202 |
1281 // ---------------------------------------------------------------------------- |
1203 // ---------------------------------------------------------------------------- |
1282 // ---------------------------------------------------------------------------- |
1204 // ---------------------------------------------------------------------------- |
1283 CFSMailMessagePart* CIpsPlgSosBasePlugin::CopyMessageAsChildPartL( |
1205 CFSMailMessagePart* CIpsPlgSosBasePlugin::CopyMessageAsChildPartL( |
1295 // Supports currently deletion of attachments and multipart structures |
1217 // Supports currently deletion of attachments and multipart structures |
1296 // which are represented as folders in Symbian store) |
1218 // which are represented as folders in Symbian store) |
1297 // ---------------------------------------------------------------------------- |
1219 // ---------------------------------------------------------------------------- |
1298 // |
1220 // |
1299 void CIpsPlgSosBasePlugin::RemoveChildPartL( |
1221 void CIpsPlgSosBasePlugin::RemoveChildPartL( |
|
1222 const TFSMailMsgId& /*aMailBoxId*/, |
|
1223 const TFSMailMsgId& /*aParentFolderId*/, |
|
1224 const TFSMailMsgId& /*aMessageId*/, |
|
1225 const TFSMailMsgId& /*aParentPartId*/, |
|
1226 const TFSMailMsgId& /*aPartId*/) |
|
1227 { |
|
1228 // <qmail> not used any more |
|
1229 User::Leave(KErrFSMailPluginNotSupported); |
|
1230 } |
|
1231 |
|
1232 // <qmail> |
|
1233 // ---------------------------------------------------------------------------- |
|
1234 // Supports currently deletion of attachments and multipart structures |
|
1235 // which are represented as folders in Symbian store) |
|
1236 // ---------------------------------------------------------------------------- |
|
1237 // |
|
1238 void CIpsPlgSosBasePlugin::RemoveChildPartL( |
1300 const TFSMailMsgId& /* aMailBoxId */, |
1239 const TFSMailMsgId& /* aMailBoxId */, |
1301 const TFSMailMsgId& /* aParentFolderId */, |
1240 const TFSMailMsgId& /* aParentFolderId */, |
1302 const TFSMailMsgId& aMessageId, |
1241 const TFSMailMsgId& aMessageId, |
1303 const TFSMailMsgId& /* aParentPartId */, |
1242 const TFSMailMsgId& /* aParentPartId */, |
1304 const TFSMailMsgId& aPartId) |
1243 const TFSMailMsgId& aPartId, |
1305 { |
1244 MFSMailRequestObserver& aOperationObserver, |
1306 FUNC_LOG; |
1245 const TInt aRequestId ) |
1307 TInt status( KErrNone ); |
1246 { |
1308 CMsvEntry* cEntry( NULL ); |
1247 FUNC_LOG; |
1309 TMsvEntry tEntry; |
1248 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC(*this); |
1310 TMsvId serviceId; |
1249 |
1311 status = iSession->GetEntry( aPartId.Id(), serviceId, tEntry ); |
1250 CIpsPlgRemoveChildPartOperation* op = CIpsPlgRemoveChildPartOperation::NewL( |
1312 |
1251 *iSession, |
1313 if ( ( status == KErrNone ) && |
1252 watcher->iStatus, |
1314 ( tEntry.iType == KUidMsvAttachmentEntry ) ) |
1253 aMessageId, |
1315 { |
1254 aPartId, |
1316 CImEmailMessage* message( NULL ); |
1255 aOperationObserver, |
1317 |
1256 aRequestId); |
1318 // We trust that the message ID really refers to a message |
1257 watcher->SetOperation( op ); |
1319 |
1258 |
1320 // Take ownership of message entry objects since thanks to |
1259 iOperations.AppendL( watcher ); |
1321 // "clever" use of active scheduler waits we can re-enter |
1260 CleanupStack::Pop( watcher ); |
1322 // this function leading to crashes if somebody clears the cache |
1261 |
1323 // while this iteration still needs them |
1262 } |
1324 TakeMessageEntryLC( aMessageId.Id(), cEntry, message ); |
1263 // </qmail> |
1325 |
|
1326 MMsvAttachmentManager& attachmentMgr( message->AttachmentManager() ); |
|
1327 |
|
1328 CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewL(); |
|
1329 CleanupStack::PushL( waiter ); |
|
1330 |
|
1331 attachmentMgr.RemoveAttachmentL( |
|
1332 (TMsvAttachmentId) aPartId.Id(), waiter->iStatus ); |
|
1333 |
|
1334 waiter->Start(); |
|
1335 CleanupStack::PopAndDestroy( waiter ); |
|
1336 |
|
1337 // Return message entry objects to cache |
|
1338 CleanupStack::Pop( 2 ); // cEntry, message |
|
1339 ReturnMessageEntry( cEntry, message ); |
|
1340 } |
|
1341 else if ( ( status == KErrNone ) && |
|
1342 ( tEntry.iType == KUidMsvFolderEntry ) ) |
|
1343 { |
|
1344 cEntry = iSession->GetEntryL( tEntry.Parent() ); |
|
1345 CleanupStack::PushL( cEntry ); |
|
1346 cEntry->DeleteL( tEntry.Id() ); |
|
1347 CleanupStack::PopAndDestroy( cEntry ); |
|
1348 } |
|
1349 } |
|
1350 |
1264 |
1351 // ---------------------------------------------------------------------------- |
1265 // ---------------------------------------------------------------------------- |
1352 // The implementation supoorts the atachment and body parts at the moment. |
1266 // The implementation supoorts the atachment and body parts at the moment. |
1353 // ---------------------------------------------------------------------------- |
1267 // ---------------------------------------------------------------------------- |
1354 // |
1268 // |
1508 // ---------------------------------------------------------------------------- |
1435 // ---------------------------------------------------------------------------- |
1509 void CIpsPlgSosBasePlugin::SetContentL( |
1436 void CIpsPlgSosBasePlugin::SetContentL( |
1510 const TDesC& aBuffer, |
1437 const TDesC& aBuffer, |
1511 const TFSMailMsgId& /* aMailBoxId */, |
1438 const TFSMailMsgId& /* aMailBoxId */, |
1512 const TFSMailMsgId& /* aParentFolderId */, |
1439 const TFSMailMsgId& /* aParentFolderId */, |
1513 const TFSMailMsgId& aMessageId, |
1440 const TFSMailMsgId& /* aMessageId */, |
1514 const TFSMailMsgId& aMessagePartId ) |
1441 const TFSMailMsgId& aMessagePartId ) |
1515 { |
1442 { |
1516 FUNC_LOG; |
1443 FUNC_LOG; |
1517 CMsvEntry* cEntry( NULL ); |
1444 |
1518 CImEmailMessage* message( NULL ); |
1445 //<qmail> Rewritten in Qmail: CIpsPlgOperationWait is no longer used |
1519 |
1446 // Notice that SetContentL sets only the content of text/plain message part: |
1520 // Take ownership of message entry objects since thanks to |
1447 // text/html part can be modified directly using GetMessagePartFileL |
1521 // "clever" use of active scheduler waits we can re-enter |
1448 CMsvEntry* cEntry( NULL ); |
1522 // this function leading to crashes if somebody clears the cache |
1449 CMsvStore* store = NULL; |
1523 // while this iteration still needs them |
1450 |
1524 TakeMessageEntryLC( aMessageId.Id(), cEntry, message ); |
1451 // following code should fill text/plain content |
1525 |
1452 cEntry = iSession->GetEntryL( aMessagePartId.Id() ); |
1526 if ( message ) |
1453 CleanupStack::PushL( cEntry ); |
1527 { |
1454 TBool hasStore = cEntry->HasStoreL(); |
1528 |
1455 if ( hasStore ) { |
1529 message->GetBodyTextEntryIdL( |
1456 store = cEntry->EditStoreL(); |
1530 cEntry->Entry().Id(), CImEmailMessage::EThisMessageOnly ); |
1457 CleanupStack::PushL(store); |
1531 if ( message->Selection().Count() > 0 ) |
1458 CParaFormatLayer* globalParaLayer = CParaFormatLayer::NewL(); |
1532 { |
1459 CleanupStack::PushL(globalParaLayer); |
1533 TMsvId dummy; |
1460 CCharFormatLayer* globalCharLayer = CCharFormatLayer::NewL(); |
1534 TMsvEmailEntry newEmailMsg; |
1461 CleanupStack::PushL(globalCharLayer); |
1535 iSession->GetEntry( aMessageId.Id(), dummy, newEmailMsg ); |
1462 CRichText* text = CRichText::NewL( globalParaLayer, globalCharLayer ); |
1536 TMsvId parent = newEmailMsg.Parent(); |
1463 CleanupStack::PushL( text ); |
1537 |
1464 // insert text |
1538 if ( message->Selection()[0] == aMessagePartId.Id() || |
1465 text->InsertL(0, aBuffer ); |
1539 newEmailMsg.ICalendar() ) |
1466 store->StoreBodyTextL(*text); |
1540 { |
1467 store->CommitL(); |
1541 CIpsPlgOperationWait* wait = CIpsPlgOperationWait::NewLC( ); |
1468 CleanupStack::PopAndDestroy( 4, store ); |
1542 CParaFormatLayer* globalParaLayer = CParaFormatLayer::NewL(); |
1469 } |
1543 CleanupStack::PushL(globalParaLayer); |
1470 CleanupStack::PopAndDestroy(cEntry); |
1544 CCharFormatLayer* globalCharLayer = CCharFormatLayer::NewL(); |
1471 //</qmail> |
1545 CleanupStack::PushL(globalCharLayer); |
|
1546 CRichText* text = CRichText::NewL( globalParaLayer, globalCharLayer ); |
|
1547 CleanupStack::PushL( text ); |
|
1548 // insert text |
|
1549 text->InsertL(0, aBuffer ); |
|
1550 // synchronously |
|
1551 message->StoreBodyTextL( |
|
1552 cEntry->Entry().Id(), *text ,wait->iStatus ); |
|
1553 wait->Start(); |
|
1554 CleanupStack::PopAndDestroy( 4, wait ); |
|
1555 } |
|
1556 } |
|
1557 } |
|
1558 |
|
1559 // Return message entry objects to cache |
|
1560 CleanupStack::Pop( 2 ); // cEntry, message |
|
1561 ReturnMessageEntry( cEntry, message ); |
|
1562 } |
1472 } |
1563 |
1473 |
1564 // ---------------------------------------------------------------------------- |
1474 // ---------------------------------------------------------------------------- |
1565 // ---------------------------------------------------------------------------- |
1475 // ---------------------------------------------------------------------------- |
1566 void CIpsPlgSosBasePlugin::RemovePartContentL( |
1476 void CIpsPlgSosBasePlugin::RemovePartContentL( |
1567 const TFSMailMsgId& /* aMailBoxId */, |
1477 const TFSMailMsgId& /*aMailBoxId*/, |
1568 const TFSMailMsgId& /* aParentFolderId */, |
1478 const TFSMailMsgId& /*aParentFolderId*/, |
1569 const TFSMailMsgId& /* aMessageId */, |
1479 const TFSMailMsgId& /*aMessageId*/, |
1570 const RArray<TFSMailMsgId>& aPartIds ) |
1480 const RArray<TFSMailMsgId>& /*aPartIds*/ ) |
1571 { |
1481 { |
1572 TInt count( aPartIds.Count() ); |
1482 // <qmail> |
1573 |
1483 User::Leave( KErrFSMailPluginNotSupported ); |
1574 for( TInt i(0); i < count; i++ ) |
1484 // </qmail> |
1575 { |
|
1576 CMsvEntry* cEntry = iSession->GetEntryL( aPartIds[i].Id() ); |
|
1577 CleanupStack::PushL( cEntry ); |
|
1578 CMsvStore* store = NULL; |
|
1579 TBool hasStore = cEntry->HasStoreL(); |
|
1580 if ( hasStore ) |
|
1581 { |
|
1582 store = cEntry->EditStoreL(); |
|
1583 } |
|
1584 |
|
1585 if ( !store || !hasStore ) |
|
1586 { |
|
1587 User::Leave( KErrNotFound ); |
|
1588 } |
|
1589 CleanupStack::PushL( store ); |
|
1590 MMsvAttachmentManager& attachmentMgr = store->AttachmentManagerL(); |
|
1591 |
|
1592 // It is assumed that the attachment file is always in the index 0 |
|
1593 if ( attachmentMgr.AttachmentCount() ) |
|
1594 { |
|
1595 // delete attachment file |
|
1596 CIpsPlgOperationWait* waiter = CIpsPlgOperationWait::NewLC(); |
|
1597 attachmentMgr.RemoveAttachmentL( 0, waiter->iStatus ); |
|
1598 waiter->Start(); |
|
1599 CleanupStack::PopAndDestroy( waiter ); |
|
1600 store->CommitL(); |
|
1601 |
|
1602 // clear complete flag |
|
1603 TMsvEntry tEntry( cEntry->Entry() ); |
|
1604 tEntry.SetComplete( EFalse ); |
|
1605 |
|
1606 waiter = CIpsPlgOperationWait::NewLC(); |
|
1607 CMsvOperation* ops = cEntry->ChangeL( tEntry, waiter->iStatus ); |
|
1608 CleanupStack::PushL( ops ); |
|
1609 waiter->Start(); |
|
1610 CleanupStack::PopAndDestroy( 2, waiter ); |
|
1611 } |
|
1612 else |
|
1613 { |
|
1614 User::Leave( KErrNotFound ); |
|
1615 } |
|
1616 CleanupStack::PopAndDestroy( store ); |
|
1617 CleanupStack::PopAndDestroy( cEntry ); |
|
1618 } |
|
1619 } |
1485 } |
1620 |
1486 |
1621 // ---------------------------------------------------------------------------- |
1487 // ---------------------------------------------------------------------------- |
1622 // ---------------------------------------------------------------------------- |
1488 // ---------------------------------------------------------------------------- |
1623 void CIpsPlgSosBasePlugin::SetPartContentFromFileL( |
1489 void CIpsPlgSosBasePlugin::SetPartContentFromFileL( |
1650 void CIpsPlgSosBasePlugin::SendL(TFSMailMsgId aMessageId ) |
1537 void CIpsPlgSosBasePlugin::SendL(TFSMailMsgId aMessageId ) |
1651 { |
1538 { |
1652 FUNC_LOG; |
1539 FUNC_LOG; |
1653 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this); |
1540 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this); |
1654 CleanupStack::PushL(watcher); |
1541 CleanupStack::PushL(watcher); |
|
1542 // <qmail> |
1655 CIpsPlgSmtpOperation* op = CIpsPlgSmtpOperation::NewLC( |
1543 CIpsPlgSmtpOperation* op = CIpsPlgSmtpOperation::NewLC( |
1656 *iSession, CActive::EPriorityStandard, watcher->iStatus, ETrue ); |
1544 *iSession, watcher->iStatus ); |
|
1545 // </qmail> |
1657 op->SetEventHandler(iEventHandler); |
1546 op->SetEventHandler(iEventHandler); |
1658 watcher->SetOperation(op); |
1547 watcher->SetOperation(op); |
1659 CleanupStack::Pop( op ); // op added as member of watcher |
1548 CleanupStack::Pop( op ); // op added as member of watcher |
1660 op->StartSendL( aMessageId.Id() ); |
1549 op->StartSendL( aMessageId.Id() ); |
1661 iOperations.AppendL(watcher); |
1550 iOperations.AppendL(watcher); |
1662 CleanupStack::Pop( watcher ); |
1551 CleanupStack::Pop( watcher ); |
1663 } |
1552 } |
1664 |
1553 |
1665 // ---------------------------------------------------------------------------- |
1554 |
1666 // ---------------------------------------------------------------------------- |
1555 // ---------------------------------------------------------------------------- |
1667 void CIpsPlgSosBasePlugin::SendMessageL( CFSMailMessage& aMessage ) |
1556 // ---------------------------------------------------------------------------- |
1668 { |
1557 void CIpsPlgSosBasePlugin::SendMessageL( CFSMailMessage& /*aMessage*/ ) |
1669 FUNC_LOG; |
1558 { |
|
1559 FUNC_LOG; |
|
1560 // <qmail> |
|
1561 User::Leave( KErrFSMailPluginNotSupported ); |
|
1562 // </qmail> |
|
1563 } |
|
1564 |
|
1565 // <qmail> |
|
1566 // ---------------------------------------------------------------------------- |
|
1567 // ---------------------------------------------------------------------------- |
|
1568 void CIpsPlgSosBasePlugin::SendMessageL( |
|
1569 CFSMailMessage& aMessage, |
|
1570 MFSMailRequestObserver& aOperationObserver, |
|
1571 const TInt aRequestId ) |
|
1572 { |
|
1573 FUNC_LOG; |
|
1574 // <qmail> Not activated yet |
1670 // is EFSMsgFlag_CalendarMsg enabled, |
1575 // is EFSMsgFlag_CalendarMsg enabled, |
1671 // then move send to back ground process |
1576 // then move send to back ground process |
1672 if ( aMessage.GetFlags() & EFSMsgFlag_CalendarMsg ) |
1577 //if ( aMessage.GetFlags() & EFSMsgFlag_CalendarMsg ) |
1673 { |
1578 // { |
1674 iEventHandler->SetNewPropertyEvent( |
1579 // iEventHandler->SetNewPropertyEvent( |
1675 aMessage.GetMessageId().Id(), |
1580 // aMessage.GetMessageId().Id(), |
1676 KIPSSosSmtpEmptyOutboxNow, KErrNone ); |
1581 // KIPSSosSmtpEmptyOutboxNow, KErrNone ); |
1677 } |
1582 // } |
1678 else |
1583 //else |
1679 { |
1584 // { |
1680 SendL( aMessage.GetMessageId() ); |
1585 CIpsPlgSingleOpWatcher* watcher = |
1681 } |
1586 CIpsPlgSingleOpWatcher::NewLC(*this); |
1682 } |
1587 |
|
1588 // <qmail> priority parameter has been removed |
|
1589 CIpsPlgSmtpOperation* op = CIpsPlgSmtpOperation::NewL( |
|
1590 *iSession, |
|
1591 watcher->iStatus, |
|
1592 &aOperationObserver, |
|
1593 aRequestId ); |
|
1594 watcher->SetOperation(op); // ownership is transferred |
|
1595 op->StartSendL( aMessage.GetMessageId().Id() ); |
|
1596 iOperations.AppendL(watcher); |
|
1597 CleanupStack::Pop( watcher ); |
|
1598 // } |
|
1599 // </qmail> |
|
1600 } |
|
1601 // </qmail> |
1683 |
1602 |
1684 // ---------------------------------------------------------------------------- |
1603 // ---------------------------------------------------------------------------- |
1685 // ---------------------------------------------------------------------------- |
1604 // ---------------------------------------------------------------------------- |
1686 TFSProgress CIpsPlgSosBasePlugin::StatusL( TInt aRequestId ) |
1605 TFSProgress CIpsPlgSosBasePlugin::StatusL( TInt aRequestId ) |
1687 { |
1606 { |
1772 // ---------------------------------------------------------------------------- |
1691 // ---------------------------------------------------------------------------- |
1773 // ---------------------------------------------------------------------------- |
1692 // ---------------------------------------------------------------------------- |
1774 void CIpsPlgSosBasePlugin::DeleteMessagesByUidL( |
1693 void CIpsPlgSosBasePlugin::DeleteMessagesByUidL( |
1775 const TFSMailMsgId& /*aMailBoxId*/, |
1694 const TFSMailMsgId& /*aMailBoxId*/, |
1776 const TFSMailMsgId& /*aFolderId*/, |
1695 const TFSMailMsgId& /*aFolderId*/, |
1777 const RArray<TFSMailMsgId>& aMessages ) |
1696 const RArray<TFSMailMsgId>& aMessages ) |
1778 { |
1697 { |
1779 FUNC_LOG; |
1698 FUNC_LOG; |
1780 CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection; |
1699 CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection; |
1781 CleanupStack::PushL(sel); |
1700 CleanupStack::PushL(sel); |
1782 |
1701 |
1783 TInt count = aMessages.Count(); |
1702 TInt count = aMessages.Count(); |
1784 TMsvEntry tEntry; |
1703 TMsvEntry tEntry; |
1785 TMsvId service; |
1704 TMsvId service; |
1786 |
1705 |
1787 TMsvEntry parentEntry; |
1706 for(TInt i=0; i<count; i++) |
1788 |
1707 { |
1789 // simulation of canceling deletion operation |
1708 iSession->GetEntry( aMessages[i].Id(), service, tEntry ); |
1790 if ( !count ) |
1709 //make sure that only messages get deleted. |
1791 { |
1710 if( tEntry.iType == KUidMsvMessageEntry ) |
1792 if ( iMsvOpDeleteMessage ) |
1711 { |
1793 { |
1712 // <qmail> |
1794 iMsvOpDeleteMessage->Cancel(); |
1713 sel->AppendL( tEntry.Id() ); |
1795 } |
1714 // </qmail> |
|
1715 } |
|
1716 } |
1796 |
1717 |
1797 if ( iWaitDeleteMessage ) |
1718 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this ); |
1798 { |
1719 CleanupStack::PushL( watcher ); |
1799 iWaitDeleteMessage->Cancel(); |
1720 //<qmail> |
1800 } |
1721 CMsvOperation* op = CIpsPlgDeleteOperation::NewL( *iSession, |
|
1722 watcher->iStatus, sel ); |
|
1723 //</qmail> |
|
1724 watcher->SetOperation( op ); |
|
1725 iOperations.AppendL( watcher ); |
|
1726 CleanupStack::Pop( watcher ); |
|
1727 //<qmail> |
|
1728 CleanupStack::Pop( sel ); |
|
1729 //</qmail> |
|
1730 } |
|
1731 |
|
1732 // <qmail> |
|
1733 // ---------------------------------------------------------------------------- |
|
1734 // ---------------------------------------------------------------------------- |
|
1735 void CIpsPlgSosBasePlugin::DeleteMessagesByUidL( |
|
1736 const TFSMailMsgId& /*aMailBoxId*/, |
|
1737 const TFSMailMsgId& /*aFolderId*/, |
|
1738 const RArray<TFSMailMsgId>& aMessages, |
|
1739 MFSMailRequestObserver& aOperationObserver, |
|
1740 const TInt aRequestId) |
|
1741 { |
|
1742 FUNC_LOG; |
|
1743 CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection; |
|
1744 CleanupStack::PushL(sel); |
|
1745 |
|
1746 TInt count = aMessages.Count(); |
|
1747 TMsvEntry tEntry; |
|
1748 TMsvId service; |
|
1749 |
|
1750 for(TInt i=0; i<count; i++) |
|
1751 { |
|
1752 iSession->GetEntry( aMessages[i].Id(), service, tEntry ); |
|
1753 //make sure that only messages get deleted. |
|
1754 if( tEntry.iType == KUidMsvMessageEntry ) |
|
1755 { |
|
1756 sel->AppendL( tEntry.Id() ); |
|
1757 } |
|
1758 } |
1801 |
1759 |
1802 delete iMsvOpDeleteMessage; |
1760 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL( *this ); |
1803 iMsvOpDeleteMessage = NULL; |
1761 CleanupStack::PushL( watcher ); |
1804 delete iWaitDeleteMessage; |
1762 CMsvOperation* op = CIpsPlgDeleteOperation::NewL( *iSession, |
1805 iWaitDeleteMessage = NULL; |
1763 watcher->iStatus, sel, aOperationObserver, aRequestId ); |
1806 delete icEntry; |
1764 watcher->SetOperation( op ); |
1807 icEntry = NULL; |
1765 iOperations.AppendL( watcher ); |
1808 } |
1766 CleanupStack::Pop( watcher ); |
1809 else |
1767 CleanupStack::Pop( sel ); |
1810 { |
1768 } |
1811 for( TInt i = 0; i < count; i++ ) |
1769 // </qmail> |
1812 { |
|
1813 iSession->GetEntry( aMessages[i].Id(), service, tEntry ); |
|
1814 |
|
1815 //make sure that only messages get deleted. |
|
1816 if( tEntry.iType == KUidMsvMessageEntry ) |
|
1817 { |
|
1818 if(iMsvOpDeleteMessage) |
|
1819 { |
|
1820 iMsvOpDeleteMessage->Cancel(); |
|
1821 delete iMsvOpDeleteMessage; |
|
1822 iMsvOpDeleteMessage = NULL; |
|
1823 } |
|
1824 |
|
1825 if ( iWaitDeleteMessage ) |
|
1826 { |
|
1827 iWaitDeleteMessage->Cancel(); |
|
1828 delete iWaitDeleteMessage; |
|
1829 iWaitDeleteMessage = NULL; |
|
1830 } |
|
1831 |
|
1832 delete icEntry; |
|
1833 icEntry = NULL; |
|
1834 |
|
1835 iSession->GetEntry( tEntry.Parent( ), service, parentEntry ); |
|
1836 |
|
1837 icEntry = CMsvEntry::NewL( |
|
1838 *iSession, tEntry.Id(), TMsvSelectionOrdering() ); |
|
1839 |
|
1840 |
|
1841 // priority slightly increased not to pause the function longer than needed |
|
1842 iWaitDeleteMessage = CIpsPlgOperationWait::NewL( CActive::EPriorityStandard+1 ); |
|
1843 // Sets bit 32 of iMtmData1, used when msg deleted in Offline |
|
1844 // and status hasn't updated to server (client entry still exists) |
|
1845 tEntry.SetLocallyDeleted( ETrue ); |
|
1846 |
|
1847 iMsvOpDeleteMessage = icEntry->ChangeL( tEntry, |
|
1848 iWaitDeleteMessage->iStatus ); |
|
1849 |
|
1850 iWaitDeleteMessage->Start(); |
|
1851 |
|
1852 sel->AppendL( tEntry.Id() ); |
|
1853 } |
|
1854 } |
|
1855 |
|
1856 CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewLC( *this ); |
|
1857 |
|
1858 CMsvOperation* op = CIpsPlgDeleteRemote::NewL( *iSession, |
|
1859 watcher->iStatus, *sel ); |
|
1860 watcher->SetOperation( op ); |
|
1861 |
|
1862 // make draft deletion synchronous so that empty drafts are not left after application close |
|
1863 if ( parentEntry.Id() == KMsvDraftEntryIdValue && count == 1 ) |
|
1864 { |
|
1865 iWait.Start(); |
|
1866 CleanupStack::PopAndDestroy( watcher ); |
|
1867 } |
|
1868 else |
|
1869 { |
|
1870 iOperations.AppendL( watcher ); |
|
1871 CleanupStack::Pop( watcher ); |
|
1872 } |
|
1873 } |
|
1874 |
|
1875 CleanupStack::PopAndDestroy( sel ); |
|
1876 } |
|
1877 |
1770 |
1878 // ---------------------------------------------------------------------------- |
1771 // ---------------------------------------------------------------------------- |
1879 // ---------------------------------------------------------------------------- |
1772 // ---------------------------------------------------------------------------- |
1880 void CIpsPlgSosBasePlugin::SubscribeMailboxEventsL( |
1773 void CIpsPlgSosBasePlugin::SubscribeMailboxEventsL( |
1881 const TFSMailMsgId& aMailboxId, |
1774 const TFSMailMsgId& aMailboxId, |
1882 MFSMailEventObserver& aObserver) |
1775 MFSMailEventObserver& aObserver) |
1883 { |
1776 { |
1884 FUNC_LOG; |
1777 FUNC_LOG; |
1885 TUint32 key = iSettingsApi->CreateCenRepKeyL( // faulty CS warning |
1778 // <qmail> |
1886 aMailboxId.Id(), |
1779 TUint32 key(0); |
1887 MtmId(), |
1780 // </qmail> |
1888 CIpsSetDataStorer::EIpsSetDataLastModifiedH ); |
|
1889 |
1781 |
1890 iEventHandler->SubscribeMailboxEventsL( aMailboxId, aObserver, key ); |
1782 iEventHandler->SubscribeMailboxEventsL( aMailboxId, aObserver, key ); |
1891 } |
1783 } |
1892 |
1784 |
1893 // ---------------------------------------------------------------------------- |
1785 // ---------------------------------------------------------------------------- |
1953 } |
1847 } |
1954 |
1848 |
1955 // ---------------------------------------------------------------------------- |
1849 // ---------------------------------------------------------------------------- |
1956 // method sets authentication popup data |
1850 // method sets authentication popup data |
1957 // ---------------------------------------------------------------------------- |
1851 // ---------------------------------------------------------------------------- |
1958 void CIpsPlgSosBasePlugin::SetCredentialsL( const TFSMailMsgId& aMailBoxId, |
1852 // |
1959 const TDesC& /*aUsername*/, const TDesC& aPassword ) |
1853 void CIpsPlgSosBasePlugin::SetCredentialsL( const TFSMailMsgId& /*aMailBoxId*/, |
1960 { |
1854 const TDesC& /*aUsername*/, const TDesC& /*aPassword*/ ) |
1961 FUNC_LOG; |
1855 { |
1962 TBool cancelled = EFalse; |
1856 // <qmail> not used; should be removed |
1963 |
1857 // FUNC_LOG; |
1964 if ( aPassword.Length() > 0 ) |
1858 // TBool cancelled = EFalse; |
1965 { |
1859 // |
1966 //Set new password and signal (possible) ongoing connect operation |
1860 // if ( aPassword.Length() > 0 ) |
1967 CIpsSetDataApi* api = CIpsSetDataApi::NewL( *iSession ); |
1861 // { |
1968 CleanupStack::PushL( api ); |
1862 // //Set new password and signal (possible) ongoing connect operation |
1969 |
1863 // //CIpsSetDataApi* api = CIpsSetDataApi::NewL( *iSession ); |
1970 CMsvEntry* cEntry = iSession->GetEntryL( aMailBoxId.Id() ); |
1864 // //CleanupStack::PushL( api ); |
1971 CleanupStack::PushL( cEntry ); |
1865 // |
1972 |
1866 // //CMsvEntry* cEntry = iSession->GetEntryL( aMailBoxId.Id() ); |
1973 RProcess process; |
1867 // //CleanupStack::PushL( cEntry ); |
1974 // only email server can set outgoing password |
1868 // |
1975 if ( process.SecureId() == FREESTYLE_FSSERVER_SID ) |
1869 // //api->SetNewPasswordL( *cEntry, aPassword ); |
1976 { |
1870 // |
1977 if ( !iEventHandler->IncomingPass() ) |
1871 // //CleanupStack::PopAndDestroy( 2, api );//cEntry, api |
1978 { |
1872 // |
1979 CMsvEntry* cTmp = iSession->GetEntryL( cEntry->Entry().iRelatedId ); |
1873 // //now signal through eventhandler that credientials have been set |
1980 CleanupStack::PopAndDestroy( 1, cEntry ); |
1874 // } |
1981 CleanupStack::PushL( cTmp ); |
1875 // else |
1982 cEntry = cTmp; |
1876 // { |
1983 } |
1877 // cancelled = ETrue; |
1984 } |
1878 // } |
1985 |
1879 // iEventHandler->SignalCredientialsSetL( aMailBoxId.Id(), cancelled ); |
1986 api->SetNewPasswordL( *cEntry, aPassword ); |
1880 // </qmail> |
1987 |
|
1988 CleanupStack::PopAndDestroy( 2, api );//cEntry, api |
|
1989 |
|
1990 //now signal through eventhandler that credientials have been set |
|
1991 } |
|
1992 else |
|
1993 { |
|
1994 cancelled = ETrue; |
|
1995 } |
|
1996 iEventHandler->SignalCredientialsSetL( aMailBoxId.Id(), cancelled ); |
|
1997 } |
1881 } |
1998 |
1882 |
1999 // ---------------------------------------------------------------------------- |
1883 // ---------------------------------------------------------------------------- |
2000 // CIpsPlgSosBasePlugin::GetMessageEntryL( ) |
1884 // CIpsPlgSosBasePlugin::GetMessageEntryL( ) |
2001 // Checks whether the requested message is already cached. If not, the cached |
1885 // Checks whether the requested message is already cached. If not, the cached |