24 // LOCAL CONSTANTS AND MACROS |
24 // LOCAL CONSTANTS AND MACROS |
25 |
25 |
26 _LIT( KMimeTextCalRequest, "text/calendar; method=REQUEST;" ); |
26 _LIT( KMimeTextCalRequest, "text/calendar; method=REQUEST;" ); |
27 _LIT( KMimeTextCalResponse, "text/calendar; method=RESPONSE;" ); |
27 _LIT( KMimeTextCalResponse, "text/calendar; method=RESPONSE;" ); |
28 _LIT( KMimeTextCalCancel, "text/calendar; method=CANCEL;" ); |
28 _LIT( KMimeTextCalCancel, "text/calendar; method=CANCEL;" ); |
|
29 _LIT( KFileExtensionICS, ".ics" ); |
29 |
30 |
30 _LIT8( KMethod, "method" ); |
31 _LIT8( KMethod, "method" ); |
31 _LIT8( KRequest, "REQUEST" ); |
32 _LIT8( KRequest, "REQUEST" ); |
32 _LIT8( KResponse, "RESPONSE" ); |
33 _LIT8( KResponse, "RESPONSE" ); |
33 _LIT8( KCancel, "CANCEL" ); |
34 _LIT8( KCancel, "CANCEL" ); |
34 |
35 |
35 // ================= MEMBER FUNCTIONS ======================= |
36 // ================= MEMBER FUNCTIONS ======================= |
36 |
37 |
37 // ---------------------------------------------------------------------------- |
38 // ---------------------------------------------------------------------------- |
38 // CCIpsPlgNewChildPartFromFileOperation::CCIpsPlgNewChildPartFromFileOperation |
39 // CIpsPlgNewChildPartFromFileOperation::CIpsPlgNewChildPartFromFileOperation |
39 // ---------------------------------------------------------------------------- |
40 // ---------------------------------------------------------------------------- |
40 // |
41 // |
41 CCIpsPlgNewChildPartFromFileOperation::CCIpsPlgNewChildPartFromFileOperation( |
42 CIpsPlgNewChildPartFromFileOperation::CIpsPlgNewChildPartFromFileOperation( |
42 CMsvSession& aMsvSession, |
43 CMsvSession& aMsvSession, |
43 TRequestStatus& aObserverRequestStatus, |
44 TRequestStatus& aObserverRequestStatus, |
44 const TFSMailMsgId& aMailBoxId, |
45 const TFSMailMsgId& aMailBoxId, |
45 const TFSMailMsgId& aMessageId, |
46 const TFSMailMsgId& aMessageId, |
46 MFSMailRequestObserver& aOperationObserver, |
47 MFSMailRequestObserver& aOperationObserver, |
47 const TInt aRequestId) |
48 const TInt aRequestId) |
48 : |
49 : |
49 CMsvOperation( |
50 CIpsPlgBaseOperation( |
50 aMsvSession, |
51 aMsvSession, |
51 CActive::EPriorityStandard, |
52 aObserverRequestStatus, |
52 aObserverRequestStatus), |
53 aRequestId, |
53 iMailBoxId(aMailBoxId), |
54 aMailBoxId), |
54 iMessageId(aMessageId), |
55 iMessageId(aMessageId), |
55 iOperationObserver(aOperationObserver), |
56 iOperationObserver(aOperationObserver) |
56 iRequestId(aRequestId) |
|
57 { |
57 { |
58 FUNC_LOG; |
58 FUNC_LOG; |
59 CActiveScheduler::Add( this ); |
59 CActiveScheduler::Add( this ); |
60 } |
60 } |
61 |
61 |
62 // ---------------------------------------------------------------------------- |
62 // ---------------------------------------------------------------------------- |
63 // CCIpsPlgNewChildPartFromFileOperation::NewL |
63 // CIpsPlgNewChildPartFromFileOperation::NewL |
64 // ---------------------------------------------------------------------------- |
64 // ---------------------------------------------------------------------------- |
65 // |
65 // |
66 CCIpsPlgNewChildPartFromFileOperation* CCIpsPlgNewChildPartFromFileOperation::NewL( |
66 CIpsPlgNewChildPartFromFileOperation* CIpsPlgNewChildPartFromFileOperation::NewL( |
67 CMsvSession& aMsvSession, |
67 CMsvSession& aMsvSession, |
68 TRequestStatus& aObserverRequestStatus, |
68 TRequestStatus& aObserverRequestStatus, |
69 const TFSMailMsgId& aMailBoxId, |
69 const TFSMailMsgId& aMailBoxId, |
70 const TFSMailMsgId& aMessageId, |
70 const TFSMailMsgId& aMessageId, |
71 const TDesC& aContentType, |
71 const TDesC& aContentType, |
88 CleanupStack::Pop( self ); |
88 CleanupStack::Pop( self ); |
89 return self; |
89 return self; |
90 } |
90 } |
91 |
91 |
92 // ---------------------------------------------------------------------------- |
92 // ---------------------------------------------------------------------------- |
93 // CCIpsPlgNewChildPartFromFileOperation::ConstructL |
93 // CIpsPlgNewChildPartFromFileOperation::ConstructL |
94 // ---------------------------------------------------------------------------- |
94 // ---------------------------------------------------------------------------- |
95 // |
95 // |
96 void CCIpsPlgNewChildPartFromFileOperation::ConstructL(CIpsPlgMsgMapper *aMsgMapper, |
96 void CIpsPlgNewChildPartFromFileOperation::ConstructL(CIpsPlgMsgMapper *aMsgMapper, |
97 const TDesC& aContentType, |
97 const TDesC& aContentType, |
98 const TDesC& aFilePath) |
98 const TDesC& aFilePath) |
99 { |
99 { |
100 FUNC_LOG; |
100 FUNC_LOG; |
101 iMsgMapper = aMsgMapper; |
101 iMsgMapper = aMsgMapper; |
102 iStatus = KRequestPending; |
|
103 iContentType = aContentType.AllocL(); |
102 iContentType = aContentType.AllocL(); |
104 iFilePath = aFilePath.AllocL(); |
103 iFilePath = aFilePath.AllocL(); |
105 |
104 |
106 // Start async request in RunL |
105 // Start from attachment manager initialization |
107 iStep = EStep1; // First step |
106 InitAttachmentManagerL(); |
108 SetActive(); |
107 } |
109 iStatus = KRequestPending; |
108 |
110 TRequestStatus* status = &iStatus; |
109 // ---------------------------------------------------------------------------- |
111 User::RequestComplete(status,KErrNone); |
110 // CIpsPlgNewChildPartFromFileOperation::~CIpsPlgNewChildPartFromFileOperation |
112 } |
111 // ---------------------------------------------------------------------------- |
113 |
112 // |
114 // ---------------------------------------------------------------------------- |
113 CIpsPlgNewChildPartFromFileOperation::~CIpsPlgNewChildPartFromFileOperation() |
115 // CCIpsPlgNewChildPartFromFileOperation::~CCIpsPlgNewChildPartFromFileOperation |
|
116 // ---------------------------------------------------------------------------- |
|
117 // |
|
118 CCIpsPlgNewChildPartFromFileOperation::~CCIpsPlgNewChildPartFromFileOperation() |
|
119 { |
114 { |
120 FUNC_LOG; |
115 FUNC_LOG; |
121 Cancel(); // Cancel any request, if outstanding |
116 Cancel(); // Cancel any request, if outstanding |
122 delete iOperation; |
117 delete iOperation; |
|
118 iOperation = NULL; |
123 delete iContentType; |
119 delete iContentType; |
|
120 iContentType = NULL; |
124 delete iFilePath; |
121 delete iFilePath; |
125 } |
122 iFilePath = NULL; |
126 |
123 } |
127 // ---------------------------------------------------------------------------- |
124 |
128 // CCIpsPlgNewChildPartFromFileOperation::DoCancel |
125 // ---------------------------------------------------------------------------- |
129 // ---------------------------------------------------------------------------- |
126 // CIpsPlgNewChildPartFromFileOperation::DoCancel |
130 // |
127 // ---------------------------------------------------------------------------- |
131 void CCIpsPlgNewChildPartFromFileOperation::DoCancel() |
128 // |
132 { |
129 void CIpsPlgNewChildPartFromFileOperation::DoCancel() |
133 FUNC_LOG; |
130 { |
|
131 FUNC_LOG; |
|
132 |
134 if (iOperation) |
133 if (iOperation) |
135 { |
134 { |
136 iOperation->Cancel(); |
135 iOperation->Cancel(); |
137 } |
136 } |
|
137 |
|
138 if (iMessage) |
|
139 { |
|
140 iMessage->AttachmentManager().CancelRequest(); |
|
141 iMessage->Cancel(); |
|
142 } |
|
143 |
138 TRequestStatus* status = &iObserverRequestStatus; |
144 TRequestStatus* status = &iObserverRequestStatus; |
139 if ( status && status->Int() == KRequestPending ) |
145 if ( status && status->Int() == KRequestPending ) |
140 { |
146 { |
141 SignalFSObserver( iStatus.Int(), NULL ); |
147 SignalFSObserver(iStatus.Int(),NULL); |
142 User::RequestComplete( status, iStatus.Int() ); |
148 User::RequestComplete( status, iStatus.Int() ); |
143 } |
149 } |
144 } |
150 } |
145 |
151 |
146 // ---------------------------------------------------------------------------- |
152 // ---------------------------------------------------------------------------- |
147 // CIpsPlgSosBasePlugin::GetMessageEntryL( ) |
153 // CIpsPlgSosBasePlugin::GetMessageEntryL( ) |
148 // Checks whether the requested message is already cached. If not, the cached |
154 // Checks whether the requested message is already cached. If not, the cached |
149 // objects are deleted and new objects are created. |
155 // objects are deleted and new objects are created. |
150 // ---------------------------------------------------------------------------- |
156 // ---------------------------------------------------------------------------- |
151 void CCIpsPlgNewChildPartFromFileOperation::GetMessageEntryL( |
157 void CIpsPlgNewChildPartFromFileOperation::GetMessageEntryL( |
152 TMsvId aId, |
158 TMsvId aId, |
153 CMsvEntry*& aMessageEntry, |
159 CMsvEntry*& aMessageEntry, |
154 CImEmailMessage*& aImEmailMessage ) |
160 CImEmailMessage*& aImEmailMessage ) |
155 { |
161 { |
156 FUNC_LOG; |
162 FUNC_LOG; |
170 } |
176 } |
171 |
177 |
172 // ---------------------------------------------------------------------------- |
178 // ---------------------------------------------------------------------------- |
173 // ---------------------------------------------------------------------------- |
179 // ---------------------------------------------------------------------------- |
174 // |
180 // |
175 void CCIpsPlgNewChildPartFromFileOperation::CleanCachedMessageEntries() |
181 void CIpsPlgNewChildPartFromFileOperation::CleanCachedMessageEntries() |
176 { |
182 { |
177 FUNC_LOG; |
183 FUNC_LOG; |
178 delete iCachedEmailMessage; |
184 delete iCachedEmailMessage; |
179 iCachedEmailMessage = NULL; |
185 iCachedEmailMessage = NULL; |
180 delete iCachedEntry; |
186 delete iCachedEntry; |
181 iCachedEntry = NULL; |
187 iCachedEntry = NULL; |
182 } |
188 } |
183 |
189 |
184 // ---------------------------------------------------------------------------- |
190 // ---------------------------------------------------------------------------- |
185 // CCIpsPlgNewChildPartFromFileOperation::RunL |
191 // CIpsPlgNewChildPartFromFileOperation::RunL |
186 // ---------------------------------------------------------------------------- |
192 // ---------------------------------------------------------------------------- |
187 // |
193 // |
188 void CCIpsPlgNewChildPartFromFileOperation::RunL() |
194 void CIpsPlgNewChildPartFromFileOperation::RunL() |
189 { |
195 { |
190 if( iStatus.Int() == KErrNone ) |
196 if( iStatus.Int() == KErrNone ) |
191 // divided to 4 steps, run asunchronously from 1 to 4 |
197 { |
192 switch (iStep) |
198 // Divided to 3 steps. Run asunchronously after InitAttachmentManagerL. |
193 { |
199 // PrepareMsvEntryL, PrepareStoreL and StoreMessagePartL respectively |
194 case EStep1: |
200 switch (iStep) |
|
201 { |
|
202 case EPrepareMsvEntry: |
|
203 PrepareMsvEntryL(); |
|
204 break; |
|
205 case EPrepareStore: |
|
206 PrepareStoreL(); |
|
207 break; |
|
208 case EStoreMessagePart: |
|
209 StoreMessagePartL(); |
|
210 break; |
|
211 } |
|
212 } |
|
213 else if (iStatus.Int() == KErrCancel) |
|
214 { |
|
215 // Do Nothing |
|
216 } |
|
217 else |
|
218 { |
|
219 User::Leave(iStatus.Int()); |
|
220 } |
|
221 } |
|
222 |
|
223 // ---------------------------------------------------------------------------- |
|
224 // CIpsPlgNewChildPartFromFileOperation::InitAttachmentManagerL |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void CIpsPlgNewChildPartFromFileOperation::InitAttachmentManagerL() |
|
228 { |
|
229 iEntry = NULL; |
|
230 iMessage = NULL; |
|
231 RFile file; |
|
232 TInt fileSize( 0 ); |
|
233 |
|
234 // Read attachment size |
|
235 User::LeaveIfError( |
|
236 file.Open( iMsvSession.FileSession(), iFilePath->Des(), EFileShareReadersOnly ) |
|
237 ); |
|
238 |
|
239 //in rare case that file has disappeared while sending |
|
240 //we just won't get the size for it |
|
241 file.Size( fileSize ); |
|
242 file.Close(); |
|
243 |
|
244 // Initialize CMsvAttachment instance for the attachment creation |
|
245 CMsvAttachment* info = CMsvAttachment::NewL( CMsvAttachment::EMsvFile ); |
|
246 CleanupStack::PushL( info ); |
|
247 |
|
248 info->SetAttachmentNameL( iFilePath->Des() ); |
|
249 info->SetSize( fileSize ); |
|
250 |
|
251 // Create/acquire Symbian message entry objects |
|
252 GetMessageEntryL( iMessageId.Id(), iEntry, iMessage ); |
|
253 |
|
254 // Start attachment creation |
|
255 iMessage->AttachmentManager().AddAttachmentL( |
|
256 iFilePath->Des(), info, iStatus ); |
|
257 CleanupStack::Pop( info ); // attachment manager takes ownership |
|
258 iStep = EPrepareMsvEntry; // Next step |
|
259 SetActive(); |
|
260 } |
|
261 |
|
262 // ---------------------------------------------------------------------------- |
|
263 // CIpsPlgNewChildPartFromFileOperation::PrepareMsvEntryL |
|
264 // ---------------------------------------------------------------------------- |
|
265 // |
|
266 void CIpsPlgNewChildPartFromFileOperation::PrepareMsvEntryL() |
|
267 { |
|
268 // Dig out the entry ID of the new attachment |
|
269 iMessage->GetAttachmentsListL( iEntry->Entry().Id( ), |
|
270 CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly ); |
|
271 TKeyArrayFix key( 0, ECmpTInt32 ); |
|
272 CMsvEntrySelection* attachmentIds = iMessage->Selection().CopyLC(); |
|
273 attachmentIds->Sort( key ); |
|
274 if ( !attachmentIds->Count() ) |
|
275 { |
|
276 User::Leave( KErrGeneral ); |
|
277 } |
|
278 iNewAttachmentId = (*attachmentIds)[ attachmentIds->Count()-1 ]; |
|
279 CleanupStack::PopAndDestroy( attachmentIds ); |
|
280 |
|
281 CMsvEntry* cAtta = iMsvSession.GetEntryL( iNewAttachmentId ); |
|
282 CleanupStack::PushL( cAtta ); |
|
283 |
|
284 // Set filename to iDetails |
|
285 TMsvEntry tEntry = cAtta->Entry(); |
|
286 tEntry.iDetails.Set(iFilePath->Des()); |
|
287 |
|
288 // Do async |
|
289 iOperation = cAtta->ChangeL( tEntry, iStatus ); |
|
290 CleanupStack::PopAndDestroy( cAtta ); |
|
291 iStep = EPrepareStore; // Next step |
|
292 SetActive(); |
|
293 } |
|
294 |
|
295 // ---------------------------------------------------------------------------- |
|
296 // CIpsPlgNewChildPartFromFileOperation::PrepareStoreL |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 void CIpsPlgNewChildPartFromFileOperation::PrepareStoreL() |
|
300 { |
|
301 CMsvEntry* cAtta = iMsvSession.GetEntryL( iNewAttachmentId ); |
|
302 CleanupStack::PushL( cAtta ); |
|
303 TBool parentToMultipartAlternative( EFalse ); |
|
304 if( cAtta->HasStoreL() ) |
|
305 { |
|
306 CMsvStore* store = cAtta->EditStoreL(); |
|
307 CleanupStack::PushL( store ); |
|
308 CImMimeHeader* mimeHeader = CImMimeHeader::NewLC(); |
|
309 |
|
310 if( store->IsPresentL( KUidMsgFileMimeHeader ) ) |
|
311 { |
|
312 mimeHeader->RestoreL( *store ); |
|
313 CDesC8Array& array = mimeHeader->ContentTypeParams(); |
|
314 array.AppendL( KMethod ); |
|
315 parentToMultipartAlternative = ETrue; |
|
316 |
|
317 if( iContentType->Des().Find( KMimeTextCalRequest ) != KErrNotFound ) |
|
318 { |
|
319 array.AppendL( KRequest ); |
|
320 } |
|
321 else if( iContentType->Des().Find( KMimeTextCalResponse ) != KErrNotFound ) |
195 { |
322 { |
196 iEntry = NULL; |
323 array.AppendL( KResponse ); |
197 iMessage = NULL; |
|
198 RFile file; |
|
199 TInt fileSize( 0 ); |
|
200 |
|
201 // Read attachment size |
|
202 TRAPD(err,file.Open( iMsvSession.FileSession(), iFilePath->Des(), EFileShareReadersOnly )); |
|
203 if (err != KErrNone) |
|
204 { |
|
205 RunError(err); |
|
206 } |
|
207 |
|
208 //in rare case that file has disappeared while sending |
|
209 //we just won't get the size for it |
|
210 file.Size( fileSize ); |
|
211 file.Close(); |
|
212 |
|
213 // Initialize CMsvAttachment instance for the attachment creation |
|
214 CMsvAttachment* info = CMsvAttachment::NewL( CMsvAttachment::EMsvFile ); |
|
215 CleanupStack::PushL( info ); |
|
216 |
|
217 info->SetAttachmentNameL( iFilePath->Des() ); |
|
218 info->SetSize( fileSize ); |
|
219 |
|
220 // Create/acquire Symbian message entry objects |
|
221 GetMessageEntryL( iMessageId.Id(), iEntry, iMessage ); |
|
222 |
|
223 // Start attachment creation |
|
224 iStatus = KRequestPending; |
|
225 iMessage->AttachmentManager().AddAttachmentL( |
|
226 iFilePath->Des(), info, iStatus ); |
|
227 CleanupStack::Pop( info ); // attachment manager takes ownership |
|
228 iStep = EStep2; // Next step |
|
229 SetActive(); |
|
230 break; |
|
231 } |
324 } |
232 case EStep2: |
325 else if( iContentType->Des().Find( KMimeTextCalCancel ) != KErrNotFound ) |
233 { |
326 { |
234 // Dig out the entry ID of the new attachment (unbelievable that |
327 array.AppendL( KCancel ); |
235 // there seems to be no better way to do this) |
|
236 iMessage->GetAttachmentsListL( iEntry->Entry().Id( ), |
|
237 CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly ); |
|
238 TKeyArrayFix key( 0, ECmpTInt32 ); |
|
239 CMsvEntrySelection* attachmentIds = iMessage->Selection().CopyLC(); |
|
240 attachmentIds->Sort( key ); |
|
241 if ( !attachmentIds->Count() ) |
|
242 { |
|
243 User::Leave( KErrGeneral ); |
|
244 } |
|
245 iNewAttachmentId = (*attachmentIds)[ attachmentIds->Count()-1 ]; |
|
246 CleanupStack::PopAndDestroy( attachmentIds ); |
|
247 |
|
248 CMsvEntry* cAtta = iMsvSession.GetEntryL( iNewAttachmentId ); |
|
249 CleanupStack::PushL( cAtta ); |
|
250 |
|
251 // Set filename to iDetails |
|
252 TMsvEntry tEntry = cAtta->Entry(); |
|
253 tEntry.iDetails.Set(iFilePath->Des()); |
|
254 |
|
255 // Do async |
|
256 iStatus = KRequestPending; |
|
257 cAtta->ChangeL( tEntry, iStatus ); |
|
258 CleanupStack::PopAndDestroy( cAtta ); |
|
259 iStep = EStep3; // Next step |
|
260 SetActive(); |
|
261 break; |
|
262 } |
328 } |
263 case EStep3: |
329 else |
264 { |
330 { |
265 CMsvEntry* cAtta = iMsvSession.GetEntryL( iNewAttachmentId ); |
331 parentToMultipartAlternative = EFalse; |
266 CleanupStack::PushL( cAtta ); |
|
267 TBool parentToMultipartAlternative( EFalse ); |
|
268 if( cAtta->HasStoreL() ) |
|
269 { |
|
270 CMsvStore* store = cAtta->EditStoreL(); |
|
271 CleanupStack::PushL( store ); |
|
272 CImMimeHeader* mimeHeader = CImMimeHeader::NewLC(); |
|
273 |
|
274 if( store->IsPresentL( KUidMsgFileMimeHeader ) ) |
|
275 { |
|
276 mimeHeader->RestoreL( *store ); |
|
277 CDesC8Array& array = mimeHeader->ContentTypeParams(); |
|
278 array.AppendL( KMethod ); |
|
279 parentToMultipartAlternative = ETrue; |
|
280 |
|
281 if( iContentType->Des().Find( KMimeTextCalRequest ) != KErrNotFound ) |
|
282 { |
|
283 array.AppendL( KRequest ); |
|
284 } |
|
285 else if( iContentType->Des().Find( KMimeTextCalResponse ) != KErrNotFound ) |
|
286 { |
|
287 array.AppendL( KResponse ); |
|
288 } |
|
289 else if( iContentType->Des().Find( KMimeTextCalCancel ) != KErrNotFound ) |
|
290 { |
|
291 array.AppendL( KCancel ); |
|
292 } |
|
293 else |
|
294 { |
|
295 parentToMultipartAlternative = EFalse; |
|
296 } |
|
297 mimeHeader->StoreWithoutCommitL( *store ); |
|
298 store->CommitL(); |
|
299 } |
|
300 |
|
301 CleanupStack::PopAndDestroy( 2, store ); |
|
302 } |
|
303 |
|
304 if( parentToMultipartAlternative && |
|
305 iFilePath->Find( _L(".ics")) != KErrNotFound ) |
|
306 { |
|
307 TMsvEntry tAttaEntry = cAtta->Entry(); |
|
308 TMsvId id = tAttaEntry.Parent(); |
|
309 CMsvEntry* cParent = iMsvSession.GetEntryL( id ); |
|
310 CleanupStack::PushL( cParent ); |
|
311 |
|
312 TMsvEmailEntry tEntry = cParent->Entry(); |
|
313 tEntry.SetMessageFolderType( EFolderTypeAlternative ); |
|
314 |
|
315 // Do async again if needed |
|
316 iStatus = KRequestPending; |
|
317 cParent->ChangeL( tEntry, iStatus ); |
|
318 CleanupStack::PopAndDestroy( cParent ); |
|
319 CleanupStack::PopAndDestroy( cAtta ); |
|
320 iStep = EStep4; // Next step |
|
321 SetActive(); |
|
322 break; |
|
323 } |
|
324 CleanupStack::PopAndDestroy( cAtta ); |
|
325 iStep = EStep4; // Next step |
|
326 // Continue to next step wihout break; |
|
327 } |
332 } |
328 case EStep4: |
333 mimeHeader->StoreWithoutCommitL( *store ); |
329 { |
334 store->CommitL(); |
330 // Delete the message entries to get all the changes to disk and |
335 } |
331 // possible store locks released |
336 |
332 CleanCachedMessageEntries(); |
337 CleanupStack::PopAndDestroy( 2, store ); |
333 |
338 } |
334 CFSMailMessagePart* result ( NULL ); |
339 |
335 // Create the FS message part object |
340 if( parentToMultipartAlternative && |
336 result = iMsgMapper->GetMessagePartL( iNewAttachmentId, iMailBoxId, |
341 iFilePath->Find( KFileExtensionICS ) != KErrNotFound ) |
337 iMessageId ); |
342 { |
338 |
343 TMsvEntry tAttaEntry = cAtta->Entry(); |
339 // Set attachment name |
344 TMsvId id = tAttaEntry.Parent(); |
340 result->SetAttachmentNameL(iFilePath->Des()); |
345 CMsvEntry* cParent = iMsvSession.GetEntryL( id ); |
341 |
346 CleanupStack::PushL( cParent ); |
342 // store message part |
347 |
343 result->SaveL(); |
348 TMsvEmailEntry tEntry = cParent->Entry(); |
344 |
349 tEntry.SetMessageFolderType( EFolderTypeAlternative ); |
345 // set flag |
350 |
346 result->SetFlag(EFSMsgFlag_Attachments); |
351 // Do async again if needed |
347 |
352 |
348 SignalFSObserver(iStatus.Int(),result); |
353 iOperation = cParent->ChangeL( tEntry, iStatus ); |
349 // nothing left to process, so complete the observer |
354 CleanupStack::PopAndDestroy( cParent ); |
350 TRequestStatus* status = &iObserverRequestStatus; |
355 CleanupStack::PopAndDestroy( cAtta ); |
351 User::RequestComplete( status, iStatus.Int() ); |
356 } |
352 break; |
357 else |
353 } |
358 { |
354 } |
359 CleanupStack::PopAndDestroy( cAtta ); |
355 } |
360 iStatus = KRequestPending; |
356 |
361 TRequestStatus* status = &iStatus; |
357 // ---------------------------------------------------------------------------- |
362 User::RequestComplete(status,KErrNone); |
358 // CCIpsPlgNewChildPartFromFileOperation::RunError |
363 } |
359 // ---------------------------------------------------------------------------- |
364 iStep = EStoreMessagePart; // Next step |
360 // |
365 SetActive(); |
361 TInt CCIpsPlgNewChildPartFromFileOperation::RunError(TInt aError) |
366 } |
|
367 |
|
368 // ---------------------------------------------------------------------------- |
|
369 // CIpsPlgNewChildPartFromFileOperation::StoreMessagePartL |
|
370 // ---------------------------------------------------------------------------- |
|
371 // |
|
372 void CIpsPlgNewChildPartFromFileOperation::StoreMessagePartL() |
|
373 { |
|
374 // Delete the message entries to get all the changes to disk and |
|
375 // possible store locks released |
|
376 CleanCachedMessageEntries(); |
|
377 |
|
378 CFSMailMessagePart* result ( NULL ); |
|
379 // Create the FS message part object |
|
380 result = iMsgMapper->GetMessagePartL( iNewAttachmentId, iFSMailboxId, |
|
381 iMessageId ); |
|
382 |
|
383 // Set attachment name |
|
384 result->SetAttachmentNameL(iFilePath->Des()); |
|
385 |
|
386 // store message part |
|
387 result->SaveL(); |
|
388 |
|
389 // set flag |
|
390 result->SetFlag(EFSMsgFlag_Attachments); |
|
391 |
|
392 SignalFSObserver(iStatus.Int(),result); |
|
393 // nothing left to process, so complete the observer |
|
394 TRequestStatus* status = &iObserverRequestStatus; |
|
395 User::RequestComplete( status, iStatus.Int() ); |
|
396 } |
|
397 |
|
398 // ---------------------------------------------------------------------------- |
|
399 // CIpsPlgNewChildPartFromFileOperation::RunError |
|
400 // ---------------------------------------------------------------------------- |
|
401 // |
|
402 TInt CIpsPlgNewChildPartFromFileOperation::RunError(TInt aError) |
362 { |
403 { |
363 FUNC_LOG; |
404 FUNC_LOG; |
364 SignalFSObserver( aError, NULL ); |
405 SignalFSObserver( aError, NULL ); |
365 |
406 |
366 TRequestStatus* status = &iObserverRequestStatus; |
407 TRequestStatus* status = &iObserverRequestStatus; |
367 User::RequestComplete( status, aError ); |
408 User::RequestComplete( status, aError ); |
368 return KErrNone; // RunError must return KErrNone to active sheduler. |
409 return KErrNone; // RunError must return KErrNone to active sheduler. |
369 } |
410 } |
370 |
411 |
371 // ---------------------------------------------------------------------------- |
412 // ---------------------------------------------------------------------------- |
372 // CCIpsPlgNewChildPartFromFileOperation::SignalFSObserver |
413 // CIpsPlgNewChildPartFromFileOperation::SignalFSObserver |
373 // ---------------------------------------------------------------------------- |
414 // ---------------------------------------------------------------------------- |
374 // |
415 // |
375 void CCIpsPlgNewChildPartFromFileOperation::SignalFSObserver( |
416 void CIpsPlgNewChildPartFromFileOperation::SignalFSObserver( |
376 TInt aStatus, CFSMailMessagePart* aMessagePart ) |
417 TInt aStatus, CFSMailMessagePart* aMessagePart ) |
377 { |
418 { |
378 FUNC_LOG; |
419 FUNC_LOG; |
379 TFSProgress result = |
|
380 { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone, aMessagePart }; |
|
381 |
|
382 if ( aStatus == KErrCancel ) |
420 if ( aStatus == KErrCancel ) |
383 { |
421 { |
384 result.iProgressStatus = TFSProgress::EFSStatus_RequestCancelled; |
422 iFSProgress.iProgressStatus = TFSProgress::EFSStatus_RequestCancelled; |
385 result.iError = KErrCancel; |
423 iFSProgress.iError = KErrCancel; |
|
424 iFSProgress.iParam = NULL; |
386 } |
425 } |
387 else |
426 else |
388 { |
427 { |
389 result.iProgressStatus = TFSProgress::EFSStatus_RequestComplete; |
428 iFSProgress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete; |
390 result.iError = aStatus; |
429 iFSProgress.iError = aStatus; |
391 } |
430 iFSProgress.iParam = aMessagePart; |
392 |
431 } |
393 TRAP_IGNORE( iOperationObserver.RequestResponseL( result, iRequestId ) ); |
432 |
394 } |
433 TRAP_IGNORE( iOperationObserver.RequestResponseL( iFSProgress, iFSRequestId ) ); |
395 |
434 } |
396 // ---------------------------------------------------------------------------- |
435 |
397 // CCIpsPlgNewChildPartFromFileOperation::ProgressL |
436 // ---------------------------------------------------------------------------- |
398 // ---------------------------------------------------------------------------- |
437 // CIpsPlgNewChildPartFromFileOperation::ProgressL |
399 // |
438 // ---------------------------------------------------------------------------- |
400 const TDesC8& CCIpsPlgNewChildPartFromFileOperation::ProgressL() |
439 // |
|
440 const TDesC8& CIpsPlgNewChildPartFromFileOperation::ProgressL() |
401 { |
441 { |
402 FUNC_LOG; |
442 FUNC_LOG; |
403 // Make sure that operation is active |
443 // Make sure that operation is active |
404 if ( IsActive() ) |
444 return (IsActive() && iOperation) ? |
405 { |
445 iOperation->ProgressL() : KNullDesC8; |
406 // Get progress |
446 } |
407 if ( iOperation ) |
447 |
408 { |
448 // --------------------------------------------------------------------------- |
409 return iOperation->ProgressL(); |
449 // CIpsPlgNewChildPartFromFileOperation::GetErrorProgressL |
410 } |
450 // --------------------------------------------------------------------------- |
411 } |
451 // |
412 return iBlank; |
452 const TDesC8& CIpsPlgNewChildPartFromFileOperation::GetErrorProgressL( TInt /*aError*/ ) |
|
453 { |
|
454 FUNC_LOG; |
|
455 return KNullDesC8; // error progress info not supported |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // CIpsPlgNewChildPartFromFileOperation::GetFSProgressL |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 TFSProgress CIpsPlgNewChildPartFromFileOperation::GetFSProgressL() const |
|
463 { |
|
464 FUNC_LOG; |
|
465 return iFSProgress; |
|
466 } |
|
467 |
|
468 // ---------------------------------------------------------------------------- |
|
469 // CIpsPlgNewChildPartFromFileOperation::IpsOpType |
|
470 // ---------------------------------------------------------------------------- |
|
471 TIpsOpType CIpsPlgNewChildPartFromFileOperation::IpsOpType() const |
|
472 { |
|
473 FUNC_LOG; |
|
474 return EIpsOpTypeNewChildPartFromFile; |
413 } |
475 } |
414 |
476 |
415 // End of File |
477 // End of File |
416 |
478 |
417 // </qmail> |
479 // </qmail> |