|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * CImap4MtmUi - IMAP4 MTM UI |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // Standard includes |
|
21 // |
|
22 #include <eikenv.h>//CEikonEnv |
|
23 #include <StringLoader.h> |
|
24 #include <avkon.mbg> |
|
25 |
|
26 // |
|
27 // Messaging includes |
|
28 // |
|
29 #include <mtmuidef.hrh> |
|
30 #include <mtclreg.h> |
|
31 #include <mtuireg.h> |
|
32 #include <eikproc.h> |
|
33 #include <MuiuMsgEditorLauncher.h> |
|
34 #include <etel.h> // KErrEtelBusyDetected |
|
35 #include <bldvariant.hrh> |
|
36 #include <etelpckt.h> |
|
37 #include <muiuflagger.h> // CMuiuFlags |
|
38 |
|
39 #include <ErrorUI.h> // CErrorUI |
|
40 #include <mtmdef.h> |
|
41 #include <smtcmtm.h> |
|
42 #include <miuthdr.h> |
|
43 #include <MuiuMsvProgressReporterOperation.h> |
|
44 #include "PROGTYPE.H" |
|
45 #include "MsvEmailConnectionProgressProvider.h" |
|
46 |
|
47 // Specific includes |
|
48 // |
|
49 #include "impicmds.h" |
|
50 #include "ImumPanic.h" |
|
51 #include <imum.rsg> |
|
52 #include "IMAPPRGR.H" |
|
53 #include "Imap4MtmUi.h" |
|
54 #include <imapset.h> |
|
55 #include <impcmtm.h> |
|
56 #include "EmailUtils.H" |
|
57 #include "EmailFeatureUtils.h" |
|
58 #include "Imap4ConnectedOp.h" |
|
59 #include "Imap4FetchOp.h" |
|
60 #include "Imap4SizeAndFetchOp.h" |
|
61 #include "Imap4FetchAttachmentOp.h" |
|
62 #include "Imap4CopyMoveLocalOp.h" |
|
63 #include "Imap4ConnectedDeleteOp.h" |
|
64 #include "ImumDeleteMessagesLocally.h" |
|
65 #include "ImumDeleteMessagesFromServer.h" |
|
66 #include "RefreshImapFolderList.h" |
|
67 #include <Muiumsginfo.h> |
|
68 #include <Muiumsginfo.hrh> |
|
69 #include "ImumMtmLogging.h" |
|
70 #include "ImumDisconnectOperation.h" |
|
71 #include "ImumEditOperation.h" |
|
72 #include "ImumFetchAndEditOperation.h" |
|
73 #include "EmailEditorViewerUids.h" |
|
74 #include "MsvConnectionValidation.h" |
|
75 #include "IMSSettingsNoteUi.h" |
|
76 #include <ImumInternalApi.h> // CImumInternalApi |
|
77 #include <ImumInHealthServices.h> |
|
78 #include "ImumListQueryDialog.h" |
|
79 |
|
80 #include <aknnotewrappers.h> // CAknNoteDialog |
|
81 #include <MuiuOperationWait.h> |
|
82 // Constants |
|
83 const TInt KImumEntriesDoneReplaceIndex = 0; |
|
84 const TInt KImumTotalEntriesReplaceIndex = 1; |
|
85 const TInt KImumProgressBufferLengthSafe = CBaseMtmUi::EProgressStringMaxLen - 10; // 10 is enough to fill message numbers |
|
86 _LIT(KImpuMtmUiResourceFile, "imum.rsc"); |
|
87 const TUint KForwardSlash = '/'; |
|
88 const TUint KBackSlash = '\\'; |
|
89 const TInt KImumDeleteMessagesLocally = 0; |
|
90 const TInt KImumMessageInfoBuffer = 32; |
|
91 const TInt KImumMessagePriorityBufferLength = 32; |
|
92 const TInt KImumApproxMailFetchSize = 1000; |
|
93 const TInt KErrDndNameNotFound = -5120; |
|
94 _LIT( KEmptySpace, " " ); |
|
95 |
|
96 enum TImap4MtmUiOperations |
|
97 { |
|
98 EImap4MtmUiEditing=EUiProgTypeEditing |
|
99 }; |
|
100 |
|
101 // ---------------------------------------------------------------------------- |
|
102 // CImap4MtmUi::NewIMPUMtmUiL() |
|
103 // ---------------------------------------------------------------------------- |
|
104 // |
|
105 EXPORT_C CBaseMtmUi* NewIMPUMtmUiL( |
|
106 CBaseMtm& aMtm, |
|
107 CRegisteredMtmDll& aRegisteredDll ) |
|
108 { |
|
109 return CImap4MtmUi::NewL(aMtm, aRegisteredDll); |
|
110 } |
|
111 |
|
112 // ---------------------------------------------------------------------------- |
|
113 // CImap4MtmUi::NewL() |
|
114 // ---------------------------------------------------------------------------- |
|
115 // |
|
116 CImap4MtmUi* CImap4MtmUi::NewL( |
|
117 CBaseMtm& aBaseMtm, |
|
118 CRegisteredMtmDll& aRegisteredMtmDll ) |
|
119 { |
|
120 IMUM_STATIC_CONTEXT( CImap4MtmUi::NewL, 0, mtm, KImumMtmLog ); |
|
121 IMUM_IN(); |
|
122 |
|
123 CImap4MtmUi* self=new(ELeave) CImap4MtmUi(aBaseMtm, aRegisteredMtmDll); |
|
124 CleanupStack::PushL(self); |
|
125 self->ConstructL(); |
|
126 CleanupStack::Pop(); |
|
127 IMUM_OUT(); |
|
128 return self; |
|
129 } |
|
130 |
|
131 // ---------------------------------------------------------------------------- |
|
132 // CImap4MtmUi::CImap4MtmUi() |
|
133 // ---------------------------------------------------------------------------- |
|
134 // |
|
135 CImap4MtmUi::CImap4MtmUi(CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll) |
|
136 : |
|
137 CImumMtmBaseMtmUi( aBaseMtm, aRegisteredMtmDll ) |
|
138 { |
|
139 IMUM_CONTEXT( CImap4MtmUi::CImap4MtmUi, 0, KImumMtmLog ); |
|
140 IMUM_IN(); |
|
141 |
|
142 IMUM_OUT(); |
|
143 } |
|
144 |
|
145 // ---------------------------------------------------------------------------- |
|
146 // CImap4MtmUi::ConstructL() |
|
147 // ---------------------------------------------------------------------------- |
|
148 // |
|
149 void CImap4MtmUi::ConstructL() |
|
150 { |
|
151 IMUM_CONTEXT( CImap4MtmUi::ConstructL, 0, KImumMtmLog ); |
|
152 IMUM_IN(); |
|
153 |
|
154 CImumMtmBaseMtmUi::ConstructL(); |
|
155 iEntry = CMsvEntry::NewL( |
|
156 Session(), KMsvRootIndexEntryId, |
|
157 TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) ); |
|
158 iEikonEnv->ReadResourceL( iInboxName, R_INBOX_NAME ); |
|
159 |
|
160 IMUM_OUT(); |
|
161 } |
|
162 |
|
163 // ---------------------------------------------------------------------------- |
|
164 // CImap4MtmUi::~CImap4MtmUi() |
|
165 // ---------------------------------------------------------------------------- |
|
166 // |
|
167 CImap4MtmUi::~CImap4MtmUi() |
|
168 { |
|
169 IMUM_CONTEXT( CImap4MtmUi::~CImap4MtmUi, 0, KImumMtmLog ); |
|
170 IMUM_IN(); |
|
171 |
|
172 delete iEditorFilename; |
|
173 delete iViewerFilename; |
|
174 delete iEntry; |
|
175 |
|
176 IMUM_OUT(); |
|
177 } |
|
178 |
|
179 // ---------------------------------------------------------------------------- |
|
180 // CImap4MtmUi::GetEditorFileNameL() |
|
181 // ---------------------------------------------------------------------------- |
|
182 // |
|
183 HBufC* CImap4MtmUi::GetEditorFileNameL() |
|
184 { |
|
185 IMUM_CONTEXT( CImap4MtmUi::GetEditorFileNameL, 0, KImumMtmLog ); |
|
186 IMUM_IN(); |
|
187 |
|
188 if(!iEditorFilename) |
|
189 { |
|
190 iEditorFilename = MsvUiEditorUtilities::ResolveAppFileNameL(KUidMsgInternetMailEditor); |
|
191 } |
|
192 IMUM_OUT(); |
|
193 return iEditorFilename; |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // CImap4MtmUi::GetViewerFileNameL() |
|
198 // ---------------------------------------------------------------------------- |
|
199 // |
|
200 HBufC* CImap4MtmUi::GetViewerFileNameL() |
|
201 { |
|
202 IMUM_CONTEXT( CImap4MtmUi::GetViewerFileNameL, 0, KImumMtmLog ); |
|
203 IMUM_IN(); |
|
204 |
|
205 if(!iViewerFilename) |
|
206 { |
|
207 iViewerFilename = MsvUiEditorUtilities::ResolveAppFileNameL(KUidMsgInternetMailViewer); |
|
208 } |
|
209 IMUM_OUT(); |
|
210 return iViewerFilename; |
|
211 } |
|
212 |
|
213 // ---------------------------------------------------------------------------- |
|
214 // CImap4MtmUi::CreateL() |
|
215 // ---------------------------------------------------------------------------- |
|
216 // |
|
217 CMsvOperation* CImap4MtmUi::CreateL( |
|
218 const TMsvEntry& /*aEntry*/, |
|
219 CMsvEntry& /*aParent*/, |
|
220 TRequestStatus& /*aStatus*/ ) |
|
221 { |
|
222 IMUM_CONTEXT( CImap4MtmUi::CreateL, 0, KImumMtmLog ); |
|
223 IMUM_IN(); |
|
224 |
|
225 User::Leave(KErrNotSupported); |
|
226 IMUM_OUT(); |
|
227 return NULL; |
|
228 } |
|
229 |
|
230 // ---------------------------------------------------------------------------- |
|
231 // CImap4MtmUi::OpenL() |
|
232 // ---------------------------------------------------------------------------- |
|
233 // |
|
234 CMsvOperation* CImap4MtmUi::OpenL( TRequestStatus& aStatus ) |
|
235 { |
|
236 IMUM_CONTEXT( CImap4MtmUi::OpenL, 0, KImumMtmLog ); |
|
237 IMUM_IN(); |
|
238 |
|
239 const TMsvEntry& contextEntry=BaseMtm().Entry().Entry(); |
|
240 CheckEntryL(contextEntry); |
|
241 if (contextEntry.iType == KUidMsvMessageEntry || contextEntry.iType == KUidMsvFolderEntry) |
|
242 return EditL(aStatus); |
|
243 else if (contextEntry.iType != KUidMsvServiceEntry) |
|
244 User::Leave(KErrNotSupported); |
|
245 // |
|
246 // --- Trying to open a service --- |
|
247 |
|
248 const TMsvId owningService=BaseMtm().Entry().OwningService(); |
|
249 const TInt serviceState=ServiceState(owningService); |
|
250 if(!ServiceIsLoaded(serviceState) || ServiceIsDisconnected(serviceState)) |
|
251 { |
|
252 CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection; |
|
253 CleanupStack::PushL(sel); |
|
254 sel->AppendL(contextEntry.Id()); |
|
255 // Use the UI side connection wrapping operation |
|
256 TBuf8<1> dummyParams; |
|
257 |
|
258 CMsvOperation* op=InvokeAsyncFunctionL( |
|
259 KImpiMTMConnectAndSyncCompleteAfterDisconnection, |
|
260 *sel, aStatus, dummyParams); |
|
261 CleanupStack::PopAndDestroy();//selection |
|
262 IMUM_OUT(); |
|
263 return op; |
|
264 } |
|
265 else |
|
266 { |
|
267 IMUM_OUT(); |
|
268 // Can't connect if we're not disconnected |
|
269 return CompletedImap4OperationL(owningService, aStatus); |
|
270 } |
|
271 } |
|
272 |
|
273 // ---------------------------------------------------------------------------- |
|
274 // CImap4MtmUi::OpenL() |
|
275 // ---------------------------------------------------------------------------- |
|
276 // |
|
277 CMsvOperation* CImap4MtmUi::OpenL( |
|
278 TRequestStatus& aStatus, |
|
279 const CMsvEntrySelection& aSelection ) |
|
280 { |
|
281 IMUM_CONTEXT( CImap4MtmUi::OpenL, 0, KImumMtmLog ); |
|
282 IMUM_IN(); |
|
283 |
|
284 CheckSelectionL(aSelection); |
|
285 IMUM_OUT(); |
|
286 // |
|
287 // --- Edit the message selection --- |
|
288 return EditL(aStatus, aSelection); |
|
289 } |
|
290 |
|
291 // ---------------------------------------------------------------------------- |
|
292 // CImap4MtmUi::CloseL() |
|
293 // ---------------------------------------------------------------------------- |
|
294 // |
|
295 CMsvOperation* CImap4MtmUi::CloseL( TRequestStatus& aStatus ) |
|
296 { |
|
297 IMUM_CONTEXT( CImap4MtmUi::CloseL, 0, KImumMtmLog ); |
|
298 IMUM_IN(); |
|
299 |
|
300 const TMsvEntry& contextEntry=BaseMtm().Entry().Entry(); |
|
301 CheckEntryL(contextEntry); |
|
302 // --- Check that current context is a service, all other entry types cannot be closed --- |
|
303 if (contextEntry.iType!=KUidMsvServiceEntry) |
|
304 User::Leave(KErrNotSupported); |
|
305 |
|
306 const TMsvId owningServiceId=BaseMtm().Entry().OwningService(); |
|
307 TInt serviceState=ServiceState(owningServiceId); |
|
308 CMsvOperation* op=NULL; |
|
309 if ( !ServiceIsDisconnected(serviceState) && !ServiceIsDisconnecting(serviceState) ) |
|
310 { |
|
311 // Not disconnected or disconnecting, so try to close service |
|
312 CMsvProgressReporterOperation* reporter = |
|
313 CMsvProgressReporterOperation::NewL( |
|
314 ETrue, |
|
315 ETrue, |
|
316 Session(), |
|
317 aStatus, |
|
318 EMbmAvkonQgn_note_progress ); |
|
319 CleanupStack::PushL(reporter); |
|
320 op = CImumDisconnectOperation::NewL(*iMailboxApi, reporter->RequestStatus(), *reporter, contextEntry.Id(), KIMAP4MTMDisconnect, KUidMsgTypeIMAP4); |
|
321 reporter->SetOperationL(op); // Takes immediate ownership |
|
322 CleanupStack::Pop(); // reporter |
|
323 op = reporter; |
|
324 } |
|
325 IMUM_OUT(); |
|
326 return op?op:CompletedImap4OperationL(owningServiceId, aStatus); |
|
327 } |
|
328 |
|
329 // ---------------------------------------------------------------------------- |
|
330 // CImap4MtmUi::CloseL() |
|
331 // ---------------------------------------------------------------------------- |
|
332 // |
|
333 CMsvOperation* CImap4MtmUi::CloseL( |
|
334 TRequestStatus& /*aStatus*/, |
|
335 const CMsvEntrySelection& /*aSelection*/ ) |
|
336 { |
|
337 IMUM_CONTEXT( CImap4MtmUi::CloseL, 0, KImumMtmLog ); |
|
338 IMUM_IN(); |
|
339 |
|
340 // --- Multiple close is not supported --- |
|
341 User::Leave(KErrNotSupported); |
|
342 IMUM_OUT(); |
|
343 return NULL; |
|
344 } |
|
345 |
|
346 // ---------------------------------------------------------------------------- |
|
347 // CImap4MtmUi::WithinIMAPInboxL() |
|
348 // ---------------------------------------------------------------------------- |
|
349 // |
|
350 TBool CImap4MtmUi::WithinIMAPInboxL( TMsvId aEntryId ) |
|
351 { |
|
352 IMUM_CONTEXT( CImap4MtmUi::WithinIMAPInboxL, 0, KImumMtmLog ); |
|
353 IMUM_IN(); |
|
354 |
|
355 if (aEntryId==KMsvRootIndexEntryId) |
|
356 return EFalse; |
|
357 TBool withinInbox=EFalse; |
|
358 |
|
359 CMsvEntry* myEntry=Session().GetEntryL(aEntryId); |
|
360 CleanupStack::PushL(myEntry); |
|
361 |
|
362 if (!(myEntry->OwningService()==KMsvLocalServiceIndexEntryId)) |
|
363 // We're not under the local service |
|
364 while (!withinInbox && myEntry->Entry().iType!=KUidMsvServiceEntry) |
|
365 { |
|
366 withinInbox = ( ( myEntry->Entry().iType==KUidMsvFolderEntry ) && |
|
367 ( myEntry->Entry().iDetails.CompareF(iInboxName) == 0 ) ); |
|
368 myEntry->SetEntryL(myEntry->Entry().Parent()); |
|
369 } |
|
370 |
|
371 CleanupStack::PopAndDestroy(); // myEntry |
|
372 IMUM_OUT(); |
|
373 return withinInbox; |
|
374 } |
|
375 |
|
376 // ---------------------------------------------------------------------------- |
|
377 // CImap4MtmUi::CompletedImap4OperationL() |
|
378 // ---------------------------------------------------------------------------- |
|
379 // |
|
380 CMsvOperation* CImap4MtmUi::CompletedImap4OperationL( |
|
381 TMsvId aServiceId, |
|
382 TRequestStatus& aStatus) |
|
383 { |
|
384 IMUM_CONTEXT( CImap4MtmUi::CompletedImap4OperationL, 0, KImumMtmLog ); |
|
385 IMUM_IN(); |
|
386 |
|
387 TPckgBuf<TImap4UiProgress> newProgressBuf; |
|
388 IMUM_OUT(); |
|
389 return CMsvCompletedOperation::NewL(Imap4BaseMtm()->Session(), Type(), newProgressBuf, aServiceId, aStatus, KErrNone);// KErrNone because we've reported the fact to the user |
|
390 } |
|
391 |
|
392 // ---------------------------------------------------------------------------- |
|
393 // CImap4MtmUi::EditL() |
|
394 // ---------------------------------------------------------------------------- |
|
395 // |
|
396 CMsvOperation* CImap4MtmUi::EditL( TRequestStatus& aStatus ) |
|
397 { |
|
398 IMUM_CONTEXT( CImap4MtmUi::EditL, 0, KImumMtmLog ); |
|
399 IMUM_IN(); |
|
400 |
|
401 CMsvOperation* op=NULL; |
|
402 const TMsvEntry& contextEntry=BaseMtm().Entry().Entry(); |
|
403 CheckEntryL(contextEntry); |
|
404 |
|
405 switch (contextEntry.iType.iUid) |
|
406 { |
|
407 case KUidMsvServiceEntryValue: |
|
408 if ( !iMailboxApi->HealthServicesL().IsMailboxHealthy( |
|
409 contextEntry.Id() ) ) |
|
410 { |
|
411 User::Leave( KErrNotFound ); |
|
412 } |
|
413 op=EditImap4ServiceL( aStatus, contextEntry.iRelatedId ); |
|
414 break; |
|
415 case KUidMsvMessageEntryValue: |
|
416 case KUidMsvFolderEntryValue: |
|
417 op=EditL(aStatus, *SingleEntrySelectionLC(contextEntry.Id())); |
|
418 CleanupStack::PopAndDestroy(); |
|
419 break; |
|
420 default: |
|
421 User::Leave(KErrNotSupported); |
|
422 } |
|
423 IMUM_OUT(); |
|
424 |
|
425 return op?op:CompletedImap4OperationL(BaseMtm().Entry().OwningService(), aStatus); |
|
426 } |
|
427 |
|
428 // ---------------------------------------------------------------------------- |
|
429 // CImap4MtmUi::EditL() |
|
430 // ---------------------------------------------------------------------------- |
|
431 // |
|
432 CMsvOperation* CImap4MtmUi::EditL( |
|
433 TRequestStatus& aStatus, |
|
434 const CMsvEntrySelection& aSelection ) |
|
435 { |
|
436 IMUM_CONTEXT( CImap4MtmUi::EditL, 0, KImumMtmLog ); |
|
437 IMUM_IN(); |
|
438 |
|
439 CMsvOperation* op=NULL; |
|
440 |
|
441 iEntry->SetEntryL(aSelection[0]); |
|
442 const TMsvId owningService=iEntry->OwningService(); |
|
443 |
|
444 TMsvEmailEntry tentry=iEntry->Entry(); |
|
445 |
|
446 switch(iEntry->Entry().iType.iUid) |
|
447 { |
|
448 case KUidMsvServiceEntryValue: |
|
449 BaseMtm().SwitchCurrentEntryL(tentry.Id()); |
|
450 op=EditL(aStatus); |
|
451 break; |
|
452 case KUidMsvMessageEntryValue: |
|
453 { |
|
454 if ( tentry.DisconnectedOperation() == EDisconnectedDeleteOperation ) |
|
455 { |
|
456 // remove deleted flag |
|
457 TInt error = MsvEmailMtmUiUtils::RemoveOfflineDeleteL( |
|
458 BaseMtm(), |
|
459 KIMAP4MTMUndeleteAll, |
|
460 tentry.Id() ); |
|
461 User::LeaveIfError( error ); |
|
462 } |
|
463 |
|
464 if(tentry.iRelatedId==KMsvNullIndexEntryId) |
|
465 // The entry is not a ghost - operate on it directly |
|
466 // |
|
467 if(tentry.BodyTextComplete()) |
|
468 { |
|
469 op=LaunchMultipleEditorApplicationsL(aSelection, aStatus); |
|
470 } |
|
471 else |
|
472 { |
|
473 TEditorParameters editorParams; |
|
474 editorParams.iId = aSelection[0]; |
|
475 editorParams.iFlags &= ~(EMsgLaunchEditorEmbedded | EMsgLaunchEditorThenWait); |
|
476 editorParams.iFlags |= EMsgReadOnly; |
|
477 const TUint preferences = Preferences(); |
|
478 if(preferences & EMtmUiFlagEditorPreferEmbedded) |
|
479 { |
|
480 editorParams.iFlags |= EMsgLaunchEditorEmbedded; |
|
481 } |
|
482 if(!(preferences & EMtmUiFlagEditorNoWaitForExit)) |
|
483 { |
|
484 editorParams.iFlags |= EMsgLaunchEditorThenWait; |
|
485 } |
|
486 |
|
487 op = OpenMessageL(aStatus, editorParams); |
|
488 } |
|
489 else |
|
490 { |
|
491 // The entry is a ghost entry - we need to follow the |
|
492 // iRelatedId back to the originator to determine what |
|
493 // we need to do. |
|
494 iEntry->SetEntryL(tentry.iRelatedId); |
|
495 tentry=iEntry->Entry(); |
|
496 if(tentry.BodyTextComplete()) |
|
497 { |
|
498 CMsvEntrySelection* mySelection=SingleEntrySelectionLC(tentry.Id()); |
|
499 op=LaunchMultipleEditorApplicationsL(*mySelection, aStatus); |
|
500 CleanupStack::PopAndDestroy(); // mySelection |
|
501 } |
|
502 else |
|
503 { |
|
504 op=OfferSynchroniseL(owningService,aStatus); |
|
505 } |
|
506 } |
|
507 } |
|
508 break; |
|
509 case KUidMsvFolderEntryValue: |
|
510 default: |
|
511 User::Leave(KErrNotSupported); |
|
512 } |
|
513 IMUM_OUT(); |
|
514 return op?op:CompletedImap4OperationL(owningService, aStatus); |
|
515 } |
|
516 |
|
517 // ---------------------------------------------------------------------------- |
|
518 // CImap4MtmUi::ViewL() |
|
519 // ---------------------------------------------------------------------------- |
|
520 // |
|
521 CMsvOperation* CImap4MtmUi::ViewL( TRequestStatus& aStatus ) |
|
522 { |
|
523 IMUM_CONTEXT( CImap4MtmUi::ViewL, 0, KImumMtmLog ); |
|
524 IMUM_IN(); |
|
525 |
|
526 CMsvOperation* op = NULL; |
|
527 TMsvEmailEntry context=BaseMtm().Entry().Entry(); |
|
528 if (context.iType != KUidMsvMessageEntry) |
|
529 User::Leave(KErrNotSupported); |
|
530 |
|
531 if(context.iRelatedId==KMsvNullIndexEntryId) |
|
532 // This entry is not a ghost entry - operate on it directly. |
|
533 if(context.Complete()) |
|
534 { |
|
535 op=LaunchEditorApplicationL(aStatus); |
|
536 } |
|
537 else |
|
538 { |
|
539 TEditorParameters editorParams; |
|
540 editorParams.iId = context.Id(); |
|
541 editorParams.iFlags &= ~(EMsgLaunchEditorEmbedded | EMsgLaunchEditorThenWait); |
|
542 editorParams.iFlags |= EMsgReadOnly; |
|
543 const TUint preferences = Preferences(); |
|
544 if(preferences & EMtmUiFlagEditorPreferEmbedded) |
|
545 { |
|
546 editorParams.iFlags |= EMsgLaunchEditorEmbedded; |
|
547 } |
|
548 if(!(preferences & EMtmUiFlagEditorNoWaitForExit)) |
|
549 { |
|
550 editorParams.iFlags |= EMsgLaunchEditorThenWait; |
|
551 } |
|
552 op = OpenMessageL(aStatus, editorParams); |
|
553 } |
|
554 else |
|
555 { |
|
556 // The context is a ghost entry - follow the iRelatedId |
|
557 // back to the originating entry |
|
558 BaseMtm().SwitchCurrentEntryL(context.iRelatedId); |
|
559 if(BaseMtm().Entry().Entry().Complete()) |
|
560 op=LaunchEditorApplicationL(aStatus); |
|
561 else |
|
562 op=OfferSynchroniseL(BaseMtm().Entry().OwningService(),aStatus); |
|
563 } |
|
564 IMUM_OUT(); |
|
565 |
|
566 return op; |
|
567 } |
|
568 |
|
569 // ---------------------------------------------------------------------------- |
|
570 // CImap4MtmUi::ViewL() |
|
571 // ---------------------------------------------------------------------------- |
|
572 // |
|
573 CMsvOperation* CImap4MtmUi::ViewL( |
|
574 TRequestStatus& aStatus, |
|
575 const CMsvEntrySelection& aSelection) |
|
576 { |
|
577 IMUM_CONTEXT( CImap4MtmUi::ViewL, 0, KImumMtmLog ); |
|
578 IMUM_IN(); |
|
579 |
|
580 __ASSERT_DEBUG(aSelection.Count()>0, |
|
581 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiSelectionIsEmpty)); |
|
582 BaseMtm().Entry().SetEntryL(aSelection[0]); |
|
583 IMUM_OUT(); |
|
584 return ViewL(aStatus); |
|
585 } |
|
586 |
|
587 // ---------------------------------------------------------------------------- |
|
588 // CImap4MtmUi::CopyToL() |
|
589 // ---------------------------------------------------------------------------- |
|
590 // |
|
591 CMsvOperation* CImap4MtmUi::CopyToL( |
|
592 const CMsvEntrySelection& /*aSelection*/, |
|
593 TRequestStatus& /*aStatus*/) |
|
594 { |
|
595 IMUM_CONTEXT( CImap4MtmUi::CopyToL, 0, KImumMtmLog ); |
|
596 |
|
597 __ASSERT_DEBUG( EFalse, |
|
598 User::Panic(KImumMtmUiPanic, EIMAP4MtmUiCopyToNotSupported ) ); |
|
599 User::Leave(KErrNotSupported); |
|
600 IMUM_OUT(); |
|
601 return NULL; |
|
602 } |
|
603 |
|
604 // ---------------------------------------------------------------------------- |
|
605 // CImap4MtmUi::MoveToL() |
|
606 // ---------------------------------------------------------------------------- |
|
607 // |
|
608 CMsvOperation* CImap4MtmUi::MoveToL( |
|
609 const CMsvEntrySelection& /*aSelection*/, |
|
610 TRequestStatus& /*aStatus*/) |
|
611 { |
|
612 IMUM_CONTEXT( CImap4MtmUi::MoveToL, 0, KImumMtmLog ); |
|
613 IMUM_IN(); |
|
614 |
|
615 __ASSERT_DEBUG( EFalse, |
|
616 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiMoveToNotSupported )); |
|
617 User::Leave(KErrNotSupported); |
|
618 IMUM_OUT(); |
|
619 return NULL; |
|
620 } |
|
621 |
|
622 // ---------------------------------------------------------------------------- |
|
623 // CImap4MtmUi::CopyFromL() |
|
624 // ---------------------------------------------------------------------------- |
|
625 // |
|
626 CMsvOperation* CImap4MtmUi::CopyFromL( |
|
627 const CMsvEntrySelection& /*aSelection*/, |
|
628 TMsvId /*aTargetId*/, |
|
629 TRequestStatus& /*aStatus*/ ) |
|
630 { |
|
631 IMUM_CONTEXT( CImap4MtmUi::CopyFromL, 0, KImumMtmLog ); |
|
632 IMUM_IN(); |
|
633 |
|
634 __ASSERT_DEBUG( EFalse, |
|
635 User::Panic( KImumMtmUiPanic,EIMAP4MtmUiCopyFromNotSupported ) ); |
|
636 User::Leave( KErrNotSupported ); |
|
637 IMUM_OUT(); |
|
638 return NULL; |
|
639 } |
|
640 |
|
641 // ---------------------------------------------------------------------------- |
|
642 // CImap4MtmUi::MoveFromL() |
|
643 // ---------------------------------------------------------------------------- |
|
644 // |
|
645 CMsvOperation* CImap4MtmUi::MoveFromL( |
|
646 const CMsvEntrySelection& /*aSelection*/, |
|
647 TMsvId /*aTargetId*/, |
|
648 TRequestStatus& /*aStatus*/) |
|
649 { |
|
650 IMUM_CONTEXT( CImap4MtmUi::MoveFromL, 0, KImumMtmLog ); |
|
651 IMUM_IN(); |
|
652 |
|
653 // Context should be MTM folder/service to move from |
|
654 __ASSERT_DEBUG( EFalse, |
|
655 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiMoveFromNotSupported ) ); |
|
656 User::Leave(KErrNotSupported); |
|
657 IMUM_OUT(); |
|
658 return NULL; |
|
659 } |
|
660 |
|
661 // ---------------------------------------------------------------------------- |
|
662 // CImap4MtmUi::CancelL() |
|
663 // ---------------------------------------------------------------------------- |
|
664 // |
|
665 CMsvOperation* CImap4MtmUi::CancelL( |
|
666 TRequestStatus& /*aStatus*/, |
|
667 const CMsvEntrySelection& /*aSelection*/) |
|
668 { |
|
669 IMUM_CONTEXT( CImap4MtmUi::CancelL, 0, KImumMtmLog ); |
|
670 IMUM_IN(); |
|
671 |
|
672 // Currently this function only used to suspend messages queued for sending. |
|
673 // Can't send IMAP4 messages, so can't cancel them either. |
|
674 User::Leave(KErrNotSupported); |
|
675 IMUM_OUT(); |
|
676 return NULL; |
|
677 } |
|
678 |
|
679 // ---------------------------------------------------------------------------- |
|
680 // CImap4MtmUi::QueryCapability() |
|
681 // Reporting on which commands are supported |
|
682 // ---------------------------------------------------------------------------- |
|
683 // |
|
684 TInt CImap4MtmUi::QueryCapability( TUid aCapability, TInt& aResponse ) |
|
685 { |
|
686 IMUM_CONTEXT( CImap4MtmUi::QueryCapability, 0, KImumMtmLog ); |
|
687 IMUM_IN(); |
|
688 IMUM_OUT(); |
|
689 |
|
690 return CBaseMtmUi::QueryCapability(aCapability, aResponse); |
|
691 } |
|
692 |
|
693 // ---------------------------------------------------------------------------- |
|
694 // CImap4MtmUi::ServiceState() |
|
695 // ---------------------------------------------------------------------------- |
|
696 // |
|
697 TInt CImap4MtmUi::ServiceState( TMsvId aServiceId ) const |
|
698 { |
|
699 IMUM_CONTEXT( CImap4MtmUi::ServiceState, 0, KImumMtmLog ); |
|
700 IMUM_IN(); |
|
701 |
|
702 // Inline functions are provided to test the returned status flags |
|
703 // |
|
704 TPckgBuf<TImap4CompoundProgress> myProgressBuf; |
|
705 const TInt error=BaseMtm().Session().ServiceProgress(aServiceId, myProgressBuf); |
|
706 |
|
707 TInt statusFlags=0; |
|
708 if(!error) // NB. If error, all the flags should be returned unset |
|
709 { |
|
710 TImap4GenericProgress::TImap4GenericProgressState genericProgressState=myProgressBuf().iGenericProgress.iState; |
|
711 TImap4SyncProgress::TImap4SyncProgressState syncProgressState=myProgressBuf().iSyncProgress.iState; |
|
712 |
|
713 statusFlags|= |
|
714 (genericProgressState==TImap4GenericProgress::EIdle && |
|
715 syncProgressState==TImap4SyncProgress::EIdle)?EIsIdle:0; |
|
716 |
|
717 statusFlags|= |
|
718 (genericProgressState==TImap4GenericProgress::EDisconnected)?EIsDisconnected:0; |
|
719 |
|
720 statusFlags|= |
|
721 (genericProgressState==TImap4GenericProgress::EConnecting)?EIsConnecting:0; |
|
722 |
|
723 statusFlags|= |
|
724 (genericProgressState==TImap4GenericProgress::EDisconnecting)?EIsDisconnecting:0; |
|
725 |
|
726 statusFlags|=EIsLoaded; // Must be loaded to have been able to get the progress |
|
727 } |
|
728 else |
|
729 // Service is not loaded, we can set the disconnected flag accordingly |
|
730 statusFlags|=EIsDisconnected; |
|
731 IMUM_OUT(); |
|
732 return statusFlags; |
|
733 } |
|
734 |
|
735 |
|
736 // ---------------------------------------------------------------------------- |
|
737 // CImap4MtmUi::IsConnected() |
|
738 // ---------------------------------------------------------------------------- |
|
739 // |
|
740 TBool CImap4MtmUi::IsConnected( const TMsvId aService ) const |
|
741 { |
|
742 IMUM_CONTEXT( CImap4MtmUi::IsConnected, 0, KImumMtmLog ); |
|
743 IMUM_IN(); |
|
744 IMUM_OUT(); |
|
745 return(!ServiceIsDisconnected(ServiceState(aService))); |
|
746 } |
|
747 |
|
748 // ---------------------------------------------------------------------------- |
|
749 // CImap4MtmUi::InvokeAsyncFunctionL() |
|
750 // ---------------------------------------------------------------------------- |
|
751 // |
|
752 CMsvOperation* CImap4MtmUi::InvokeAsyncFunctionL( |
|
753 TInt aFunctionId, |
|
754 const CMsvEntrySelection& aSelection, |
|
755 TRequestStatus& aStatus, |
|
756 TDes8& aParameter ) |
|
757 { |
|
758 IMUM_CONTEXT( CImap4MtmUi::InvokeAsyncFunctionL, 0, KImumMtmLog ); |
|
759 IMUM_IN(); |
|
760 |
|
761 CMsvOperation* op = NULL; |
|
762 |
|
763 //Offline checks VARIATION START |
|
764 if( iFeatureFlags->GF( EMailFeatureOfflineMode ) && |
|
765 aFunctionId != KMtmUiFunctionMessageInfo ) |
|
766 { |
|
767 TMsvId mailboxId = BaseMtm().Entry().EntryId(); |
|
768 //No need to do this if we're online... |
|
769 TBool offline = EFalse; |
|
770 if( !IsConnected( mailboxId ) && |
|
771 !iMailboxApi->MailboxUtilitiesL().HasWlanConnectionL( mailboxId ) ) |
|
772 { |
|
773 offline = MsvEmailMtmUiUtils::DoOfflineChecksL( mailboxId ); |
|
774 } |
|
775 |
|
776 if( offline ) |
|
777 { |
|
778 op = CMsvCompletedOperation::NewL( |
|
779 Session(), Type(), KNullDesC8, |
|
780 KMsvLocalServiceIndexEntryId, aStatus, KErrCancel ); |
|
781 return op; |
|
782 } |
|
783 }//if |
|
784 //VARIATION END |
|
785 |
|
786 switch( aFunctionId ) |
|
787 { |
|
788 case KMtmUiFunctionFetchAll: // 'Fetch All' |
|
789 case KMtmUiFunctionFetchNew: // 'Fetch New' |
|
790 { |
|
791 // aSelection is empty. |
|
792 TImImap4GetMailInfo getMailInfo; |
|
793 CMsvEntrySelection* sel = new ( ELeave ) CMsvEntrySelection; |
|
794 CleanupStack::PushL( sel ); |
|
795 InitParametersForFetchCmdL( sel, getMailInfo ); |
|
796 if( aFunctionId == KMtmUiFunctionFetchAll ) |
|
797 { |
|
798 aFunctionId = KIMAP4MTMPopulateAllMailWhenAlreadyConnected; |
|
799 } |
|
800 else |
|
801 { |
|
802 aFunctionId = KIMAP4MTMPopulateNewMailWhenAlreadyConnected; |
|
803 } |
|
804 op = FetchMessagesL( aStatus, *sel, aFunctionId, getMailInfo ); |
|
805 CleanupStack::PopAndDestroy(); // sel |
|
806 } |
|
807 break; |
|
808 |
|
809 case KMtmUiFunctionFetchSelected: // 'Fetch Selected' |
|
810 // aSelection contains the messages to populate. |
|
811 op = PopulateMessagesL( aStatus, aSelection ); |
|
812 break; |
|
813 |
|
814 case KImpiMTMConnect: |
|
815 case KImpiMTMConnectAndSyncCompleteAfterConnection: |
|
816 case KImpiMTMConnectAndSyncCompleteAfterFolderSync: |
|
817 case KImpiMTMConnectAndSyncCompleteAfterDisconnection: |
|
818 case KImpiMTMRefreshFolderList: |
|
819 { |
|
820 if( aFunctionId != KImpiMTMRefreshFolderList ) |
|
821 { |
|
822 TImImap4GetPartialMailInfo partialGetMailInfo; |
|
823 CMsvEntrySelection* sel = new(ELeave) CMsvEntrySelection; |
|
824 CleanupStack::PushL( sel ); |
|
825 |
|
826 InitParametersForFilteredPopulateL( *sel, partialGetMailInfo ); |
|
827 if( partialGetMailInfo.iPartialMailOptions != ENoSizeLimits ) |
|
828 { |
|
829 //if partial fetch is used, we connect this way |
|
830 op = DoFilteredPopulateL(aStatus, *sel, aFunctionId, partialGetMailInfo ); |
|
831 CleanupStack::PopAndDestroy(); //sel |
|
832 break; |
|
833 } |
|
834 else |
|
835 { |
|
836 CleanupStack::PopAndDestroy(); //sel |
|
837 } |
|
838 }//if |
|
839 |
|
840 // All function IDs requiring a progress reporter op |
|
841 CMsvProgressReporterOperation* myProgressReporterOp= |
|
842 CMsvProgressReporterOperation::NewL( |
|
843 ETrue, ETrue, Session(), |
|
844 aStatus, EMbmAvkonQgn_note_progress ); |
|
845 |
|
846 CleanupStack::PushL( myProgressReporterOp ); |
|
847 CMsvOperation* wrappedOp = NULL; |
|
848 |
|
849 if( aFunctionId != KImpiMTMRefreshFolderList ) |
|
850 { |
|
851 // Must be some flavour of connection op |
|
852 |
|
853 __ASSERT_DEBUG( aSelection.Count(), |
|
854 User::Panic(KImumMtmUiPanic, EIMAP4MtmUiNoService ) ); |
|
855 if( aSelection.Count() == 0 ) |
|
856 { |
|
857 op = CMsvCompletedOperation::NewL( |
|
858 Session(), Type(), KNullDesC8, |
|
859 KMsvLocalServiceIndexEntryId, aStatus, KErrCancel ); |
|
860 break; |
|
861 } |
|
862 |
|
863 iEntry->SetEntryL( aSelection[ 0 ] ); |
|
864 const TMsvId service = iEntry->OwningService(); |
|
865 |
|
866 CImapConnectionOp::TImapConnectionType connectionCase = |
|
867 CImapConnectionOp::EWithSyncCompleteAfterDisconnection; |
|
868 switch( aFunctionId ) |
|
869 { |
|
870 case KImpiMTMConnect: |
|
871 connectionCase = CImapConnectionOp::ECompleteAfterConnect; |
|
872 break; |
|
873 case KImpiMTMConnectAndSyncCompleteAfterConnection: |
|
874 connectionCase = CImapConnectionOp::EWithSyncCompleteAfterConnect; |
|
875 break; |
|
876 case KImpiMTMConnectAndSyncCompleteAfterFolderSync: |
|
877 connectionCase = CImapConnectionOp::EWithSyncCompleteAfterFullSync; |
|
878 break; |
|
879 default: |
|
880 break; |
|
881 } |
|
882 |
|
883 wrappedOp = CImapConnectionOp::NewL( |
|
884 iMailboxApi->MsvSession(), CActive::EPriorityStandard, |
|
885 myProgressReporterOp->RequestStatus(), // ie. complete the reporter when finished |
|
886 service, *myProgressReporterOp, // the reporter owns the wrapped op |
|
887 connectionCase ); |
|
888 |
|
889 myProgressReporterOp->SetOperationL( wrappedOp ); // Takes immediate ownership |
|
890 |
|
891 TBuf<EProgressStringMaxLen> title; |
|
892 MsvEmailMtmUiUtils::CreateConnectingToText( title, |
|
893 Session(), BaseMtm().Entry().EntryId() ); |
|
894 |
|
895 myProgressReporterOp->SetTitleL( title ); |
|
896 } |
|
897 |
|
898 else |
|
899 { |
|
900 //note text for imap folderlist update |
|
901 HBufC* title = StringLoader::LoadLC( |
|
902 R_IMAS_SETTINGS_DIALOG_UPDATING_FOLDERLIST, iCoeEnv ); |
|
903 |
|
904 myProgressReporterOp->SetTitleL( *title ); |
|
905 wrappedOp = CImapConnectAndRefreshFolderList::NewL( |
|
906 *iMailboxApi, CActive::EPriorityStandard, |
|
907 myProgressReporterOp->RequestStatus(), aSelection[ 0 ], |
|
908 *myProgressReporterOp ); |
|
909 myProgressReporterOp->SetOperationL( wrappedOp ); // Takes immediate ownership |
|
910 CleanupStack::PopAndDestroy( title ); |
|
911 } |
|
912 CleanupStack::Pop(); // myProgressReporterOp |
|
913 op = myProgressReporterOp; |
|
914 } |
|
915 break; |
|
916 case KImpiMTMFetchAttachments: |
|
917 { |
|
918 __ASSERT_DEBUG( aSelection.Count(), |
|
919 User::Panic(KImumMtmUiPanic, EIMAP4MtmUiSelectionIsEmpty ) ); |
|
920 if ( aSelection.Count() > 0 ) |
|
921 { |
|
922 iEntry->SetEntryL( aSelection[ 0 ] ); |
|
923 const TMsvId service = iEntry->OwningService(); |
|
924 CMsvProgressReporterOperation* reporter = |
|
925 CMsvProgressReporterOperation::NewL( |
|
926 Session(), aStatus, EMbmAvkonQgn_note_progress ); |
|
927 CleanupStack::PushL( reporter ); |
|
928 op = CImap4FetchAttachmentOp::NewL( |
|
929 *iMailboxApi, reporter->RequestStatus(), |
|
930 *reporter, service, aSelection ); |
|
931 reporter->SetOperationL( op ); // Takes immediate ownership |
|
932 CleanupStack::Pop(); // reporter |
|
933 op = reporter; |
|
934 } |
|
935 else |
|
936 { |
|
937 op = CMsvCompletedOperation::NewL( |
|
938 Session(), Type(), KNullDesC8, |
|
939 KMsvLocalServiceIndexEntryId, aStatus, KErrCancel ); |
|
940 } |
|
941 } |
|
942 break; |
|
943 |
|
944 case KMtmUiFunctionMessageInfo: |
|
945 IMUM_OUT(); |
|
946 return ShowMessageInfoL( aStatus, aParameter ); |
|
947 |
|
948 case KIMAP4MTMConnectAndSyncCompleteAfterFullSync: |
|
949 default: |
|
950 op=BaseMtm().InvokeAsyncFunctionL( |
|
951 aFunctionId, aSelection, |
|
952 aParameter, aStatus ); |
|
953 break; |
|
954 } |
|
955 IMUM_OUT(); |
|
956 return op; |
|
957 } |
|
958 |
|
959 |
|
960 // ---------------------------------------------------------------------------- |
|
961 // InitParametersForFilteredPopulateL |
|
962 // ---------------------------------------------------------------------------- |
|
963 // |
|
964 void CImap4MtmUi::InitParametersForFilteredPopulateL( |
|
965 CMsvEntrySelection& aSelection, |
|
966 TImImap4GetPartialMailInfo& aPartialGetMailInfo) |
|
967 { |
|
968 CMsvEntrySelection* serviceChildren = BaseMtm().Entry().ChildrenL(); |
|
969 CleanupStack::PushL(serviceChildren); |
|
970 |
|
971 aSelection.AppendL( BaseMtm().Entry().Entry().Id() ); |
|
972 |
|
973 //add inbox to selection |
|
974 |
|
975 const TMsvId inboxId = SelectionContainsInboxL(BaseMtm().Entry(),*serviceChildren); |
|
976 CleanupStack::PopAndDestroy(); |
|
977 |
|
978 aSelection.AppendL( inboxId ); |
|
979 |
|
980 //read settings |
|
981 Imap4BaseMtm()->RestoreSettingsL(); |
|
982 const CImImap4Settings& settings = Imap4BaseMtm()->Imap4Settings(); |
|
983 |
|
984 aPartialGetMailInfo.iPartialMailOptions = settings.PartialMailOptions(); |
|
985 aPartialGetMailInfo.iBodyTextSizeLimit = settings.BodyTextSizeLimit(); |
|
986 aPartialGetMailInfo.iAttachmentSizeLimit = settings.AttachmentSizeLimit(); |
|
987 aPartialGetMailInfo.iTotalSizeLimit = aPartialGetMailInfo.iBodyTextSizeLimit + |
|
988 aPartialGetMailInfo.iAttachmentSizeLimit; |
|
989 } |
|
990 |
|
991 // ---------------------------------------------------------------------------- |
|
992 // DoFilteredPopulateL |
|
993 // ---------------------------------------------------------------------------- |
|
994 // |
|
995 CMsvOperation* CImap4MtmUi::DoFilteredPopulateL( |
|
996 TRequestStatus& aStatus, |
|
997 const CMsvEntrySelection& aSelection, |
|
998 TInt aFunctionId, |
|
999 TImImap4GetPartialMailInfo& aPartialGetMailInfo) |
|
1000 { |
|
1001 IMUM_CONTEXT( CImap4MtmUi::InitParametersForFilteredPopulateL, 0, KImumMtmLog ); |
|
1002 IMUM_IN(); |
|
1003 |
|
1004 CMsvProgressReporterOperation* reporter = |
|
1005 CMsvProgressReporterOperation::NewL( |
|
1006 Session(), aStatus, EMbmAvkonQgn_note_progress ); |
|
1007 CleanupStack::PushL(reporter); |
|
1008 const TMsvId service = BaseMtm().Entry().OwningService(); |
|
1009 |
|
1010 // Set func id as null, because we're only connecting, not |
|
1011 // fetching anything. ( fetching is done internally |
|
1012 // by fetchop, because we're populating ) |
|
1013 CMsvOperation* fetch = CImap4FetchOp::NewL( |
|
1014 *iMailboxApi, reporter->RequestStatus(), *reporter, |
|
1015 service, aFunctionId, aPartialGetMailInfo, aSelection ); |
|
1016 reporter->SetOperationL(fetch); // Takes immediate ownership |
|
1017 CleanupStack::Pop(); // reporter |
|
1018 IMUM_OUT(); |
|
1019 return reporter; |
|
1020 } |
|
1021 |
|
1022 // ---------------------------------------------------------------------------- |
|
1023 // InvokeSyncFunctionL |
|
1024 // ---------------------------------------------------------------------------- |
|
1025 // |
|
1026 void CImap4MtmUi::InvokeSyncFunctionL( |
|
1027 TInt aFunctionId, |
|
1028 const CMsvEntrySelection& aSelection, |
|
1029 TDes8& aParameter ) |
|
1030 { |
|
1031 IMUM_CONTEXT( CImap4MtmUi::InvokeSyncFunctionL, 0, KImumMtmLog ); |
|
1032 IMUM_IN(); |
|
1033 |
|
1034 CBaseMtmUi::InvokeSyncFunctionL(aFunctionId, aSelection, aParameter); |
|
1035 IMUM_OUT(); |
|
1036 } |
|
1037 |
|
1038 // ---------------------------------------------------------------------------- |
|
1039 // CImap4MtmUi::PopulateMessagesSyncL() |
|
1040 // ---------------------------------------------------------------------------- |
|
1041 // |
|
1042 TInt CImap4MtmUi::PopulateMessagesSyncL( const CMsvEntrySelection& aSelection ) |
|
1043 { |
|
1044 IMUM_CONTEXT( CImap4MtmUi::PopulateMessagesSyncL, 0, KImumMtmLog ); |
|
1045 IMUM_IN(); |
|
1046 |
|
1047 CMsvEntrySelection* sel = StripBodyTextCompleteEntriesLC(aSelection); |
|
1048 const TInt count = sel->Count(); |
|
1049 CleanupStack::PopAndDestroy(); // sel |
|
1050 if(!count) |
|
1051 { |
|
1052 IMUM_OUT(); |
|
1053 // Have body text. |
|
1054 return KErrNone; |
|
1055 } |
|
1056 |
|
1057 CMsvOperationWait* waiter = CMsvOperationWait::NewLC(); |
|
1058 waiter->iStatus = KRequestPending; |
|
1059 CMsvOperation* op = PopulateMessagesL(waiter->iStatus, aSelection); |
|
1060 CleanupStack::PushL(op); |
|
1061 |
|
1062 waiter->Start(); |
|
1063 CActiveScheduler::Start(); |
|
1064 const TInt err = DisplayProgressSummary(op->ProgressL()); |
|
1065 CleanupStack::PopAndDestroy(2); // CSI: 47 # op, waiter |
|
1066 IMUM_OUT(); |
|
1067 return err; |
|
1068 } |
|
1069 |
|
1070 // ---------------------------------------------------------------------------- |
|
1071 // CImap4MtmUi::GetResourceFileName() |
|
1072 // ---------------------------------------------------------------------------- |
|
1073 // |
|
1074 void CImap4MtmUi::GetResourceFileName( TFileName& aFileName ) const |
|
1075 { |
|
1076 IMUM_CONTEXT( CImap4MtmUi::GetResourceFileName, 0, KImumMtmLog ); |
|
1077 IMUM_IN(); |
|
1078 |
|
1079 aFileName=KImpuMtmUiResourceFile; |
|
1080 IMUM_OUT(); |
|
1081 } |
|
1082 |
|
1083 // ---------------------------------------------------------------------------- |
|
1084 // CImap4MtmUi::GetProgress() |
|
1085 // ---------------------------------------------------------------------------- |
|
1086 // |
|
1087 TInt CImap4MtmUi::GetProgress( |
|
1088 const TDesC8& aProgress, |
|
1089 TBuf<EProgressStringMaxLen>& aReturnString, |
|
1090 TInt& aTotalEntryCount, |
|
1091 TInt& aEntriesDone, |
|
1092 TInt& aCurrentEntrySize, |
|
1093 TInt& aCurrentBytesTrans ) const |
|
1094 { |
|
1095 IMUM_CONTEXT( CImap4MtmUi::GetProgress, 0, KImumMtmLog ); |
|
1096 IMUM_IN(); |
|
1097 |
|
1098 if( (!aProgress.Length()) || (aProgress.Size() == sizeof(TMsvLocalOperationProgress)) ) |
|
1099 return KErrNone; |
|
1100 |
|
1101 TPckgC<TInt> type(0); |
|
1102 type.Set(aProgress.Left(sizeof(TInt))); |
|
1103 switch (type()) |
|
1104 { |
|
1105 case KImap4UiProgressType: |
|
1106 // IMAP specific UI buffer |
|
1107 return GetUiProgress(aProgress, aReturnString, aTotalEntryCount, aEntriesDone, aCurrentEntrySize, aCurrentBytesTrans); |
|
1108 |
|
1109 case EUiProgTypeSizingMsg: |
|
1110 // Email message sizer operation progress - we don't decode this |
|
1111 // Fall-through |
|
1112 case EUiProgTypeEditing: |
|
1113 // Email editing progress - we don't decode this |
|
1114 // Fall-through |
|
1115 case EUiProgTypeConnecting: |
|
1116 // Email connection progress - we don't decode this |
|
1117 return KErrNone; |
|
1118 |
|
1119 case EImap4SyncProgressType: |
|
1120 return GetSyncProgress(aProgress, aReturnString, aTotalEntryCount, aEntriesDone, aCurrentEntrySize, aCurrentBytesTrans); |
|
1121 // Fall-through |
|
1122 default: |
|
1123 break; |
|
1124 } |
|
1125 |
|
1126 // If none of the above are true, then we should be getting a TImap4CompoundProgress, |
|
1127 // of which we should just decode the GenericProgress part (unless we are in the middle of |
|
1128 // a sync operation) |
|
1129 __ASSERT_DEBUG(type() == EImap4GenericProgressType, |
|
1130 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiInvalidProgress)); |
|
1131 |
|
1132 TPckgBuf<TImap4CompoundProgress> paramPack; |
|
1133 paramPack.Copy(aProgress); |
|
1134 const TImap4GenericProgress& progress=paramPack().iGenericProgress; |
|
1135 TInt sliderTotal=0; |
|
1136 TInt sliderNumber=0; |
|
1137 TInt itemTotal=progress.iMsgsToDo; |
|
1138 TInt itemNumber=Min(itemTotal, progress.iMsgsDone+1); |
|
1139 |
|
1140 TInt resourceId=0; |
|
1141 switch(progress.iOperation) |
|
1142 { |
|
1143 case TImap4GenericProgress::ECopyWithinService: |
|
1144 case TImap4GenericProgress::EMoveWithinService: |
|
1145 __ASSERT_DEBUG(EFalse, |
|
1146 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiProgressMoveCopyWithinServiceNotSupported)); |
|
1147 break; |
|
1148 case TImap4GenericProgress::ECopyToLocal: |
|
1149 case TImap4GenericProgress::EOffLineCopyToLocal: |
|
1150 case TImap4GenericProgress::EOffLineCopyFromLocal: |
|
1151 case TImap4GenericProgress::EOffLineCopyWithinService: |
|
1152 resourceId = (itemTotal==1) ? (R_IMAP4_PROGRESS_COPYING) : (R_IMAP4_PROGRESS_COPYING_MULTI); |
|
1153 if(itemTotal==1) |
|
1154 { |
|
1155 sliderTotal=progress.iBytesToDo; |
|
1156 sliderNumber=progress.iBytesDone; |
|
1157 } |
|
1158 else |
|
1159 { |
|
1160 sliderTotal=progress.iMsgsToDo; |
|
1161 sliderNumber=progress.iMsgsDone; |
|
1162 } |
|
1163 break; |
|
1164 |
|
1165 case TImap4GenericProgress::EPopulate: |
|
1166 case TImap4GenericProgress::EOffLinePopulate: |
|
1167 { |
|
1168 resourceId = (itemTotal==1) ? (R_IMAP4_PROGRESS_FETCHING) : (R_IMAP4_PROGRESS_FETCHING_MULTI); |
|
1169 //We don't want slider to be displayed. When no progress info, wait animation is shown instead. |
|
1170 sliderTotal=0; |
|
1171 sliderNumber=0; |
|
1172 } |
|
1173 break; |
|
1174 case TImap4GenericProgress::EOffLineUndelete: |
|
1175 { |
|
1176 resourceId = (itemTotal==1) ? (R_IMAP4_PROGRESS_UNDELETING) : (R_IMAP4_PROGRESS_UNDELETING_MANY); |
|
1177 } |
|
1178 break; |
|
1179 case TImap4GenericProgress::ESync: |
|
1180 { |
|
1181 TPckg<TImap4SyncProgress> syncProgress(paramPack().iSyncProgress); |
|
1182 return GetSyncProgress(syncProgress, aReturnString, aTotalEntryCount, aEntriesDone, aCurrentEntrySize, aCurrentBytesTrans); |
|
1183 } |
|
1184 |
|
1185 default: |
|
1186 { |
|
1187 switch(STATIC_CAST(TInt,progress.iState)) |
|
1188 { |
|
1189 case TImap4GenericProgress::EConnecting: |
|
1190 case TImap4GenericProgress::EDisconnecting: |
|
1191 case TImap4GenericProgress::EDisconnected: |
|
1192 case TImap4GenericProgress::EIdle: |
|
1193 case TImap4GenericProgress::ESelecting: |
|
1194 // No progress string to be returned for these, |
|
1195 // inc. no slider |
|
1196 break; |
|
1197 case TImap4GenericProgress::EBusy: |
|
1198 case TImap4GenericProgress::ESyncing: |
|
1199 sliderTotal=itemTotal; |
|
1200 sliderNumber=progress.iMsgsDone; |
|
1201 resourceId=R_IMAP4_PROGRESS_INBOXSYNC; |
|
1202 break; |
|
1203 case TImap4GenericProgress::EDeleting: |
|
1204 if( (itemTotal == 0) && (itemNumber == 0) ) |
|
1205 { |
|
1206 // IMPS does not report counts for folder deletions, but does for messages. |
|
1207 resourceId=R_IMAP4_PROGRESS_DELETING; |
|
1208 } |
|
1209 else |
|
1210 { |
|
1211 resourceId = (itemTotal==1) ? (R_IMAP4_PROGRESS_DELETING) : (R_IMAP4_PROGRESS_DELETING_MANY); |
|
1212 } |
|
1213 break; |
|
1214 case TImap4GenericProgress::EFetching: |
|
1215 case TImap4GenericProgress::EPopulateNewMail: |
|
1216 case TImap4GenericProgress::EPopulateAllMail: |
|
1217 case TImap4GenericProgress::EPopulateMailSelection: |
|
1218 { |
|
1219 resourceId = (itemTotal==1) ? (R_IMAP4_PROGRESS_FETCHING) : (R_IMAP4_PROGRESS_FETCHING_MULTI); |
|
1220 sliderTotal=progress.iBytesToDo; |
|
1221 sliderNumber=progress.iBytesDone; |
|
1222 } |
|
1223 break; |
|
1224 case TImap4GenericProgress::EAppending: |
|
1225 __ASSERT_DEBUG(EFalse, |
|
1226 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiProgressAppendingNotSupported)); |
|
1227 sliderTotal=progress.iBytesToDo; |
|
1228 sliderNumber=progress.iBytesDone; |
|
1229 break; |
|
1230 case TImap4GenericProgress::EMoveNewMail: |
|
1231 case TImap4GenericProgress::EMoving: |
|
1232 case TImap4GenericProgress::EMoveMailSelection: |
|
1233 case TImap4GenericProgress::EMoveAllMail: |
|
1234 __ASSERT_DEBUG(EFalse, |
|
1235 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiProgressMoveNotSupported)); |
|
1236 // drop through |
|
1237 case TImap4GenericProgress::ECopying: |
|
1238 case TImap4GenericProgress::ECopyNewMail: |
|
1239 case TImap4GenericProgress::ECopyMailSelection: |
|
1240 case TImap4GenericProgress::ECopyAllMail: |
|
1241 resourceId = (itemTotal==1) ? (R_IMAP4_PROGRESS_COPYING) : (R_IMAP4_PROGRESS_COPYING_MULTI); |
|
1242 sliderTotal=progress.iBytesToDo; |
|
1243 sliderNumber=progress.iBytesDone; |
|
1244 break; |
|
1245 case EImap4MtmUiEditing: |
|
1246 break; |
|
1247 default: |
|
1248 __ASSERT_DEBUG(EFalse, |
|
1249 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiInvalidProgress)); |
|
1250 break; |
|
1251 }; // end ofinner switch case |
|
1252 }; // end of outer switch's default |
|
1253 }; // end of outer switch |
|
1254 |
|
1255 |
|
1256 if ( progress.iOperation == TImap4GenericProgress::EPopulate ) |
|
1257 { |
|
1258 //We don't want slider to be displayed. When no progress info, wait animation is shown instead. |
|
1259 aEntriesDone=0; |
|
1260 aTotalEntryCount=0; |
|
1261 aCurrentEntrySize=0; |
|
1262 aCurrentBytesTrans=0; |
|
1263 } |
|
1264 else |
|
1265 { |
|
1266 aEntriesDone=itemNumber; |
|
1267 aTotalEntryCount=itemTotal; |
|
1268 aCurrentEntrySize=sliderTotal; |
|
1269 aCurrentBytesTrans=sliderNumber; |
|
1270 } |
|
1271 |
|
1272 if (resourceId!=0) |
|
1273 { |
|
1274 StringLoader::Load( aReturnString, resourceId, iCoeEnv); |
|
1275 if ( itemTotal>1 ) |
|
1276 { |
|
1277 aReturnString = aReturnString.Left( KImumProgressBufferLengthSafe ); |
|
1278 TBuf<EProgressStringMaxLen> tempBuffer; |
|
1279 StringLoader::Format( |
|
1280 tempBuffer, |
|
1281 aReturnString, |
|
1282 KImumEntriesDoneReplaceIndex, |
|
1283 itemNumber ); |
|
1284 StringLoader::Format( |
|
1285 aReturnString, |
|
1286 tempBuffer, |
|
1287 KImumTotalEntriesReplaceIndex, |
|
1288 itemTotal ); |
|
1289 } |
|
1290 } |
|
1291 else |
|
1292 { |
|
1293 aReturnString.Zero(); |
|
1294 } |
|
1295 IMUM_OUT(); |
|
1296 |
|
1297 return progress.iErrorCode; |
|
1298 } |
|
1299 |
|
1300 // ---------------------------------------------------------------------------- |
|
1301 // CImap4MtmUi::GetSyncProgress() |
|
1302 // ---------------------------------------------------------------------------- |
|
1303 // |
|
1304 TInt CImap4MtmUi::GetSyncProgress( |
|
1305 const TDesC8& aProgress, |
|
1306 TBuf<EProgressStringMaxLen>& aReturnString, |
|
1307 TInt& aTotalEntryCount, |
|
1308 TInt& aEntriesDone, |
|
1309 TInt& aCurrentEntrySize, |
|
1310 TInt& aCurrentBytesTrans ) const |
|
1311 { |
|
1312 IMUM_CONTEXT( CImap4MtmUi::GetSyncProgress, 0, KImumMtmLog ); |
|
1313 IMUM_IN(); |
|
1314 |
|
1315 TPckgBuf<TImap4SyncProgress> progressPack; |
|
1316 progressPack.Copy(aProgress); |
|
1317 const TImap4SyncProgress& progress=progressPack(); |
|
1318 |
|
1319 TInt sliderTotal=0; |
|
1320 TInt sliderNumber=0; |
|
1321 TInt itemTotal=progress.iFoldersToDo; |
|
1322 TInt itemNumber=Min(itemTotal, progress.iFoldersDone); |
|
1323 |
|
1324 TInt resourceId=0; |
|
1325 |
|
1326 switch(progress.iState) |
|
1327 { |
|
1328 case TImap4SyncProgress::EIdle: |
|
1329 case TImap4SyncProgress::EConnecting: |
|
1330 case TImap4SyncProgress::EDisconnecting: |
|
1331 case TImap4SyncProgress::ESyncFolderTree: |
|
1332 // No progress string to be returned for these states. |
|
1333 break; |
|
1334 case TImap4SyncProgress::ESyncInbox: |
|
1335 resourceId=R_IMAP4_PROGRESS_INBOXSYNC; |
|
1336 sliderTotal=progress.iMsgsToDo; |
|
1337 sliderNumber=progress.iMsgsDone; |
|
1338 break; |
|
1339 case TImap4SyncProgress::ECheckRemoteSubscription: |
|
1340 case TImap4SyncProgress::EUpdateRemoteSubscription: |
|
1341 __ASSERT_DEBUG(EFalse, |
|
1342 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiSyncProgressFolder)); |
|
1343 sliderTotal=0; |
|
1344 sliderNumber=0; |
|
1345 itemTotal=progress.iFoldersToDo; |
|
1346 itemNumber=progress.iFoldersDone; |
|
1347 break; |
|
1348 case TImap4SyncProgress::ESyncOther: |
|
1349 case TImap4SyncProgress::EBusy: |
|
1350 case TImap4SyncProgress::EDeleting: |
|
1351 case TImap4SyncProgress::EProcessingPendingOps: |
|
1352 resourceId=R_IMAP4_PROGRESS_INBOXSYNC; |
|
1353 sliderTotal=progress.iFoldersToDo; |
|
1354 sliderNumber=progress.iFoldersDone; |
|
1355 itemTotal=progress.iFoldersToDo; |
|
1356 itemNumber=progress.iFoldersDone; |
|
1357 break; |
|
1358 default: |
|
1359 break; |
|
1360 } |
|
1361 |
|
1362 aEntriesDone=sliderNumber; |
|
1363 aTotalEntryCount=sliderTotal; |
|
1364 aCurrentEntrySize=sliderTotal; |
|
1365 aCurrentBytesTrans=sliderNumber; |
|
1366 |
|
1367 if (resourceId!=0) |
|
1368 { |
|
1369 StringLoader::Load( aReturnString, resourceId, iCoeEnv); |
|
1370 } |
|
1371 else |
|
1372 { |
|
1373 aReturnString.Zero(); |
|
1374 } |
|
1375 IMUM_OUT(); |
|
1376 |
|
1377 return progress.iErrorCode; |
|
1378 } |
|
1379 |
|
1380 // ---------------------------------------------------------------------------- |
|
1381 // CImap4MtmUi::GetUiProgress() |
|
1382 // ---------------------------------------------------------------------------- |
|
1383 // |
|
1384 TInt CImap4MtmUi::GetUiProgress( |
|
1385 const TDesC8& aProgress, |
|
1386 TBuf<EProgressStringMaxLen>& aReturnString, |
|
1387 TInt& aTotalEntryCount, |
|
1388 TInt& aEntriesDone, |
|
1389 TInt& aCurrentEntrySize, |
|
1390 TInt& aCurrentBytesTrans ) const |
|
1391 { |
|
1392 IMUM_CONTEXT( CImap4MtmUi::GetUiProgress, 0, KImumMtmLog ); |
|
1393 IMUM_IN(); |
|
1394 |
|
1395 TPckgBuf<TImap4UiProgress> paramPack; |
|
1396 paramPack.Copy(aProgress); |
|
1397 const TImap4UiProgress& progress=paramPack(); |
|
1398 |
|
1399 TInt resourceId=0; |
|
1400 |
|
1401 switch(progress.iUiOperation) |
|
1402 { |
|
1403 case TImap4UiProgress::ESynchronising: |
|
1404 __ASSERT_DEBUG(EFalse, |
|
1405 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiUiProgressSync)); |
|
1406 break; |
|
1407 case TImap4UiProgress::ECreatingFolder: |
|
1408 __ASSERT_DEBUG(EFalse, |
|
1409 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiUiProgressCreateFolder)); |
|
1410 break; |
|
1411 case TImap4UiProgress::EFetchingAttachment: |
|
1412 resourceId=R_IMAP4_GETTING_ATTACHMENT; |
|
1413 default: |
|
1414 // NB. the "default" category includes purging |
|
1415 // attachments which should happen very quickly and |
|
1416 // not require any progress during it's activity |
|
1417 break; |
|
1418 } |
|
1419 |
|
1420 aEntriesDone=progress.iFoldersDone; |
|
1421 aTotalEntryCount=progress.iFoldersToDo; |
|
1422 aCurrentEntrySize=progress.iBytesToDo; |
|
1423 aCurrentBytesTrans=progress.iBytesDone; |
|
1424 if (resourceId==0) |
|
1425 { |
|
1426 aReturnString.Zero(); |
|
1427 } |
|
1428 else |
|
1429 { |
|
1430 StringLoader::Load( aReturnString, resourceId, iCoeEnv); |
|
1431 }; |
|
1432 IMUM_OUT(); |
|
1433 |
|
1434 return progress.iError; |
|
1435 } |
|
1436 |
|
1437 // ---------------------------------------------------------------------------- |
|
1438 // CImap4MtmUi::DisplayProgressSummary() |
|
1439 // ---------------------------------------------------------------------------- |
|
1440 // |
|
1441 TInt CImap4MtmUi::DisplayProgressSummary( const TDesC8& aProgress ) const |
|
1442 { |
|
1443 IMUM_CONTEXT( CImap4MtmUi::DisplayProgressSummary, 0, KImumMtmLog ); |
|
1444 IMUM_IN(); |
|
1445 |
|
1446 if ( ( !aProgress.Length() ) || |
|
1447 ( aProgress.Size() == sizeof(TMsvLocalOperationProgress) ) ) |
|
1448 return KErrCancel; // Probably a CMsvCompletedOperation |
|
1449 |
|
1450 TPckgC<TInt> type(0); |
|
1451 type.Set( aProgress.Left( sizeof(TInt) ) ); |
|
1452 switch( type() ) |
|
1453 { |
|
1454 case KImap4UiProgressType: |
|
1455 IMUM_OUT(); |
|
1456 return DisplayUiProgressSummary( aProgress ); |
|
1457 |
|
1458 case EUiProgTypeEditing: |
|
1459 // Email message editing/viewing progress, ignore errors. |
|
1460 // Fall through... |
|
1461 case EUiProgTypeSizingMsg: |
|
1462 // Email message sizer operation progress, ignore errors. |
|
1463 IMUM_OUT(); |
|
1464 return KErrNone; |
|
1465 case EUiProgTypeConnecting: |
|
1466 // Email connection progress |
|
1467 IMUM_OUT(); |
|
1468 return DisplayConnectionProgressSummary( aProgress ); |
|
1469 |
|
1470 case EImap4SyncProgressType: |
|
1471 IMUM_OUT(); |
|
1472 return DisplaySyncProgressSummary( aProgress ); |
|
1473 |
|
1474 default: |
|
1475 break; |
|
1476 } |
|
1477 |
|
1478 // Should be a TImap4CompoundProgress |
|
1479 __ASSERT_DEBUG( type() == EImap4GenericProgressType, |
|
1480 User::Panic(KImumMtmUiPanic, EIMAP4MtmUiInvalidProgress ) ); |
|
1481 |
|
1482 TPckgBuf<TImap4CompoundProgress> paramPack; |
|
1483 paramPack.Copy( aProgress ); |
|
1484 const TImap4CompoundProgress& progress = paramPack(); |
|
1485 const TImap4GenericProgress& genericProgress = progress.iGenericProgress; |
|
1486 const TImap4SyncProgress& syncProgress = progress.iSyncProgress; |
|
1487 |
|
1488 TBool displayErrorNote = EFalse; |
|
1489 TInt messageRID = 0; |
|
1490 TInt errorCode = KErrNone; |
|
1491 if ( genericProgress.iOperation == TImap4GenericProgress::EConnect || |
|
1492 genericProgress.iOperation == TImap4GenericProgress::EDisconnect || |
|
1493 genericProgress.iOperation == TImap4GenericProgress::ESync ) |
|
1494 { |
|
1495 // We take the progress from the sync progress part |
|
1496 errorCode = syncProgress.iErrorCode; |
|
1497 if ( errorCode == KErrNone ) |
|
1498 { |
|
1499 // Belt and braces approach; check generic progress for errors too. |
|
1500 errorCode = genericProgress.iErrorCode; |
|
1501 } |
|
1502 if ( errorCode != KErrNone ) |
|
1503 { |
|
1504 // There was an error. |
|
1505 switch ( genericProgress.iOperation ) |
|
1506 { |
|
1507 case TImap4GenericProgress::EConnect: |
|
1508 // If we are connecting, we should discount KErrCancels |
|
1509 // Also KErrNotSupported |
|
1510 if( ( errorCode != KErrCancel ) && |
|
1511 ( errorCode != KErrNotSupported ) ) |
|
1512 { |
|
1513 displayErrorNote = ETrue; |
|
1514 } |
|
1515 break; |
|
1516 case TImap4GenericProgress::EDisconnect: |
|
1517 if ( errorCode == KErrTimedOut ) |
|
1518 { |
|
1519 displayErrorNote = ETrue; |
|
1520 messageRID = R_IMAP4_TIMEOUT_DIALOG_TEXT; |
|
1521 } |
|
1522 else |
|
1523 { |
|
1524 displayErrorNote = ETrue; |
|
1525 } |
|
1526 break; |
|
1527 case TImap4GenericProgress::ESync: |
|
1528 displayErrorNote = ETrue; |
|
1529 // Fall through |
|
1530 default: |
|
1531 break; |
|
1532 }; |
|
1533 } |
|
1534 } |
|
1535 else // We take the progress from the generic progress part |
|
1536 { |
|
1537 errorCode=genericProgress.iErrorCode; |
|
1538 if ( errorCode == KErrNone ) |
|
1539 { |
|
1540 // Belt and braces approach; check sync progress for errors too. |
|
1541 errorCode=syncProgress.iErrorCode; |
|
1542 } |
|
1543 if ( errorCode != KErrNone && errorCode != KErrCancel ) |
|
1544 { |
|
1545 // There was an error. |
|
1546 switch ( genericProgress.iOperation ) |
|
1547 { |
|
1548 case TImap4GenericProgress::EPopulate: |
|
1549 case TImap4GenericProgress::ECopyToLocal: |
|
1550 case TImap4GenericProgress::ECopyWithinService: |
|
1551 case TImap4GenericProgress::ECopyFromLocal: |
|
1552 case TImap4GenericProgress::EMoveToLocal: |
|
1553 case TImap4GenericProgress::EMoveWithinService: |
|
1554 case TImap4GenericProgress::EMoveFromLocal: |
|
1555 displayErrorNote = ETrue; |
|
1556 break; |
|
1557 default: |
|
1558 break; |
|
1559 } |
|
1560 } |
|
1561 } |
|
1562 if ( displayErrorNote ) |
|
1563 { |
|
1564 IMUM_OUT(); |
|
1565 // messageRID can be 0 and then error text is received from error resolver |
|
1566 return ShowErrorDialog( errorCode, messageRID ); |
|
1567 } |
|
1568 IMUM_OUT(); |
|
1569 return errorCode; |
|
1570 } |
|
1571 |
|
1572 // ---------------------------------------------------------------------------- |
|
1573 // CImap4MtmUi::DisplaySyncProgressSummary() |
|
1574 // ---------------------------------------------------------------------------- |
|
1575 // |
|
1576 TInt CImap4MtmUi::DisplaySyncProgressSummary( const TDesC8& aProgress ) const |
|
1577 { |
|
1578 IMUM_CONTEXT( CImap4MtmUi::DisplaySyncProgressSummary, 0, KImumMtmLog ); |
|
1579 IMUM_IN(); |
|
1580 |
|
1581 // Sync progress is only returned by a connection operation |
|
1582 TPckgBuf<TImap4SyncProgress> paramPack; |
|
1583 paramPack.Copy( aProgress ); |
|
1584 const TImap4SyncProgress& syncProgress = paramPack(); |
|
1585 |
|
1586 TBool displayErrorNote = EFalse; |
|
1587 TInt messageRID = 0; |
|
1588 |
|
1589 if ( syncProgress.iErrorCode == KErrNone ) |
|
1590 { |
|
1591 IMUM_OUT(); |
|
1592 return KErrNone; |
|
1593 } |
|
1594 else |
|
1595 { |
|
1596 switch ( syncProgress.iState ) |
|
1597 { |
|
1598 case TImap4SyncProgress::EConnecting: |
|
1599 if ( syncProgress.iErrorCode == KErrTimedOut ) |
|
1600 { |
|
1601 displayErrorNote = ETrue; |
|
1602 messageRID=R_IMAP4_TIMEOUT_DIALOG_TEXT; |
|
1603 } |
|
1604 else if ( syncProgress.iErrorCode == KErrDndNameNotFound ) |
|
1605 { |
|
1606 displayErrorNote = ETrue; |
|
1607 messageRID = R_MAIL_ERR_NO_IN_SRVR; |
|
1608 } |
|
1609 else if ( (syncProgress.iErrorCode != KErrCancel ) && |
|
1610 ( syncProgress.iErrorCode != KErrNotSupported ) ) |
|
1611 // If we are connecting, we should discount KErrCancels |
|
1612 // Also KErrNotSupported |
|
1613 { |
|
1614 displayErrorNote = ETrue; |
|
1615 } |
|
1616 break; |
|
1617 case TImap4SyncProgress::EDisconnecting: |
|
1618 displayErrorNote = ETrue; |
|
1619 if ( syncProgress.iErrorCode == KErrTimedOut ) |
|
1620 { |
|
1621 messageRID = R_IMAP4_TIMEOUT_DIALOG_TEXT; |
|
1622 } |
|
1623 break; |
|
1624 case TImap4SyncProgress::EIdle: |
|
1625 displayErrorNote = ETrue; |
|
1626 messageRID=R_IMAP4_TIMEOUT_DIALOG_TEXT; |
|
1627 break; |
|
1628 default: |
|
1629 // All the rest of the sync states are related to syncing |
|
1630 displayErrorNote = ETrue; |
|
1631 break; |
|
1632 }; |
|
1633 } |
|
1634 IMUM_OUT(); |
|
1635 |
|
1636 return ( displayErrorNote ) ? |
|
1637 ShowErrorDialog( syncProgress.iErrorCode, messageRID ) : |
|
1638 syncProgress.iErrorCode; |
|
1639 } |
|
1640 |
|
1641 // ---------------------------------------------------------------------------- |
|
1642 // CImap4MtmUi::ShowErrorDialog() |
|
1643 // ---------------------------------------------------------------------------- |
|
1644 // |
|
1645 TInt CImap4MtmUi::ShowErrorDialog( |
|
1646 TInt aErrorCode, |
|
1647 TInt aErrorMessageRID ) const |
|
1648 { |
|
1649 IMUM_CONTEXT( CImap4MtmUi::ShowErrorDialog, 0, KImumMtmLog ); |
|
1650 IMUM_IN(); |
|
1651 |
|
1652 TInt ignore = 0; |
|
1653 TInt ret = KErrNone; |
|
1654 TBuf<EProgressStringMaxLen> errorBufferText; |
|
1655 const TDesC* line = NULL; |
|
1656 if(!aErrorMessageRID) |
|
1657 { |
|
1658 if ( aErrorCode == KErrGeneral || |
|
1659 aErrorCode == KErrEtelBusyDetected || |
|
1660 aErrorCode == KErrAbort ) |
|
1661 // general errors displayed by other components. for ex. phone app... |
|
1662 { |
|
1663 return KErrGeneral; |
|
1664 } |
|
1665 |
|
1666 if ( aErrorCode == KErrCouldNotConnect ) |
|
1667 { |
|
1668 aErrorCode = KErrImapConnectFail; |
|
1669 } |
|
1670 if( aErrorCode == KErrGprsServicesNotAllowed ) |
|
1671 { |
|
1672 aErrorCode = KImskErrorActiveSettingIsDifferent; |
|
1673 } |
|
1674 ret = aErrorCode; |
|
1675 TRAP( ignore, iErrorResolver->ShowGlobalErrorNoteL( aErrorCode ) ); |
|
1676 } |
|
1677 else if ( aErrorMessageRID == R_IMAP4_TIMEOUT_DIALOG_TEXT ) |
|
1678 { |
|
1679 TBuf<EProgressStringMaxLen> tempString; |
|
1680 StringLoader::Load( tempString, aErrorMessageRID, iEikonEnv); |
|
1681 TMsvId serviceId = 0; |
|
1682 TMsvId id = BaseMtm().Entry().OwningService(); |
|
1683 TMsvEntry serviceEntry; |
|
1684 if ( Session().GetEntry( |
|
1685 id, |
|
1686 serviceId, |
|
1687 serviceEntry ) == KErrNone ) |
|
1688 { |
|
1689 TInt descriptionLength = EProgressStringMaxLen - tempString.Length(); |
|
1690 if ( descriptionLength < 1 ) |
|
1691 { |
|
1692 descriptionLength = EProgressStringMaxLen - KImumProgressBufferLengthSafe; |
|
1693 tempString = tempString.Left( KImumProgressBufferLengthSafe ); |
|
1694 } |
|
1695 StringLoader::Format( |
|
1696 errorBufferText, |
|
1697 tempString, |
|
1698 -1, |
|
1699 serviceEntry.iDetails.Left(descriptionLength) ); |
|
1700 } |
|
1701 else |
|
1702 { |
|
1703 StringLoader::Format( errorBufferText, tempString, -1, KEmptySpace ); |
|
1704 } |
|
1705 line = &errorBufferText; |
|
1706 ret = KErrTimedOut; |
|
1707 TRAP( ignore, CIMSSettingsNoteUi::ShowNoteL( |
|
1708 *line, EIMSErrorNote, ETrue ) ); |
|
1709 } |
|
1710 else |
|
1711 { |
|
1712 StringLoader::Load( errorBufferText, aErrorMessageRID, iEikonEnv); |
|
1713 line = &errorBufferText; |
|
1714 ret = KErrCancel; // some other error, just return != KErrNone |
|
1715 TRAP_IGNORE( CIMSSettingsNoteUi::ShowQueryL( |
|
1716 *line, R_EMAIL_INFORMATION_QUERY ) ); |
|
1717 } |
|
1718 IMUM_OUT(); |
|
1719 |
|
1720 return ret; |
|
1721 } |
|
1722 |
|
1723 // ---------------------------------------------------------------------------- |
|
1724 // CImap4MtmUi::DisplayUiProgressSummary() |
|
1725 // ---------------------------------------------------------------------------- |
|
1726 // |
|
1727 TInt CImap4MtmUi::DisplayUiProgressSummary( const TDesC8& aProgress ) const |
|
1728 { |
|
1729 IMUM_CONTEXT( CImap4MtmUi::DisplayUiProgressSummary, 0, KImumMtmLog ); |
|
1730 IMUM_IN(); |
|
1731 |
|
1732 TPckgBuf<TImap4UiProgress> paramPack; |
|
1733 paramPack.Copy(aProgress); |
|
1734 const TImap4UiProgress& progress=paramPack(); |
|
1735 |
|
1736 if( (progress.iError != KErrNone) && (progress.iError != KErrCancel) ) |
|
1737 { |
|
1738 // Only failed creation or renaming of folders requires summary |
|
1739 // and you cannot do those so panic |
|
1740 switch(progress.iUiOperation) |
|
1741 { |
|
1742 case TImap4UiProgress::ECreatingFolder: |
|
1743 case TImap4UiProgress::ERenamingFolder: |
|
1744 __ASSERT_DEBUG(EFalse, |
|
1745 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiUiProgressSummaryCreateRenameFolder)); |
|
1746 break; |
|
1747 |
|
1748 case TImap4UiProgress::EDeletingMessages: |
|
1749 return ShowErrorDialog(progress.iError); |
|
1750 |
|
1751 default: |
|
1752 break; |
|
1753 } |
|
1754 } |
|
1755 IMUM_OUT(); |
|
1756 return KErrNone; |
|
1757 } |
|
1758 |
|
1759 // ---------------------------------------------------------------------------- |
|
1760 // CImap4MtmUi::DisplayConnectionProgressSummary() |
|
1761 // ---------------------------------------------------------------------------- |
|
1762 // |
|
1763 TInt CImap4MtmUi::DisplayConnectionProgressSummary( |
|
1764 const TDesC8& aProgress) const |
|
1765 { |
|
1766 IMUM_CONTEXT( CImap4MtmUi::DisplayConnectionProgressSummary, 0, KImumMtmLog ); |
|
1767 IMUM_IN(); |
|
1768 |
|
1769 TPckgBuf<TMsvEmailConnectionProgress> progressBuf; |
|
1770 progressBuf.Copy(aProgress); |
|
1771 const TMsvEmailConnectionProgress& connectionProgress=progressBuf(); |
|
1772 IMUM_OUT(); |
|
1773 |
|
1774 if(connectionProgress.iErrorCode!=KErrNone && connectionProgress.iErrorCode!=KErrCancel) |
|
1775 { |
|
1776 return ShowErrorDialog(connectionProgress.iErrorCode); |
|
1777 } |
|
1778 else |
|
1779 { |
|
1780 // If we are connecting, we should discount KErrCancels |
|
1781 return KErrNone; |
|
1782 } |
|
1783 } |
|
1784 |
|
1785 // ---------------------------------------------------------------------------- |
|
1786 // CImap4MtmUi::LaunchMultipleEditorApplicationsL() |
|
1787 // ---------------------------------------------------------------------------- |
|
1788 // |
|
1789 CMsvOperation* CImap4MtmUi::LaunchMultipleEditorApplicationsL( |
|
1790 const CMsvEntrySelection& aSelection, |
|
1791 TRequestStatus& aStatus ) |
|
1792 { |
|
1793 IMUM_CONTEXT( CImap4MtmUi::LaunchMultipleEditorApplicationsL, 0, KImumMtmLog ); |
|
1794 IMUM_IN(); |
|
1795 |
|
1796 BaseMtm().Entry().SetEntryL(aSelection.At(0)); |
|
1797 IMUM_OUT(); |
|
1798 return LaunchEditorApplicationL(aStatus); |
|
1799 } |
|
1800 |
|
1801 // ---------------------------------------------------------------------------- |
|
1802 // CImap4MtmUi::LaunchEditorApplicationL() |
|
1803 // ---------------------------------------------------------------------------- |
|
1804 // |
|
1805 CMsvOperation* CImap4MtmUi::LaunchEditorApplicationL( |
|
1806 TRequestStatus& aStatus) |
|
1807 { |
|
1808 IMUM_CONTEXT( CImap4MtmUi::LaunchEditorApplicationL, 0, KImumMtmLog ); |
|
1809 IMUM_IN(); |
|
1810 |
|
1811 // --- Create the parameters necessary for the editor --- |
|
1812 TEditorParameters editorParams; |
|
1813 editorParams.iId=BaseMtm().Entry().EntryId(); |
|
1814 editorParams.iFlags|=EMsgReadOnly; |
|
1815 IMUM_OUT(); |
|
1816 return LaunchEditorApplicationL(aStatus, editorParams); |
|
1817 } |
|
1818 |
|
1819 // ---------------------------------------------------------------------------- |
|
1820 // CImap4MtmUi::LaunchEditorApplicationL() |
|
1821 // ---------------------------------------------------------------------------- |
|
1822 // |
|
1823 CMsvOperation* CImap4MtmUi::LaunchEditorApplicationL( |
|
1824 TRequestStatus& aStatus, |
|
1825 const TEditorParameters& aParams) |
|
1826 { |
|
1827 IMUM_CONTEXT( CImap4MtmUi::LaunchEditorApplicationL, 0, KImumMtmLog ); |
|
1828 IMUM_IN(); |
|
1829 |
|
1830 // Get the app name, appName not owed so must not delete it at the end |
|
1831 HBufC* appName = (aParams.iFlags & EMsgReadOnly) ? (GetViewerFileNameL()) : (GetEditorFileNameL()); |
|
1832 const TUint preferences = Preferences(); |
|
1833 |
|
1834 TEmailEditParams editParams; |
|
1835 editParams.iPreferences = preferences; |
|
1836 editParams.iEditorFileName = *appName; |
|
1837 editParams.iEditorParams = aParams; |
|
1838 |
|
1839 editParams.iEditorParams.iFlags &= ~(EMsgLaunchEditorEmbedded | EMsgLaunchEditorThenWait); |
|
1840 if(preferences & EMtmUiFlagEditorPreferEmbedded) |
|
1841 { |
|
1842 editParams.iEditorParams.iFlags |= EMsgLaunchEditorEmbedded; |
|
1843 } |
|
1844 if(!(preferences & EMtmUiFlagEditorNoWaitForExit)) |
|
1845 { |
|
1846 editParams.iEditorParams.iFlags |= EMsgLaunchEditorThenWait; |
|
1847 } |
|
1848 const TBool ackReceipts = AcknowledgeReceiptsL(aParams.iId); |
|
1849 IMUM_OUT(); |
|
1850 return CImumEditOperation::NewL(*iMailboxApi, aStatus, Type(), editParams, ackReceipts); |
|
1851 } |
|
1852 |
|
1853 // ---------------------------------------------------------------------------- |
|
1854 // CImap4MtmUi::EditImap4ServiceL() |
|
1855 // ---------------------------------------------------------------------------- |
|
1856 // |
|
1857 CMsvOperation* CImap4MtmUi::EditImap4ServiceL( |
|
1858 TRequestStatus& aStatus, |
|
1859 TMsvId aServiceEntry ) |
|
1860 { |
|
1861 IMUM_CONTEXT( CImap4MtmUi::EditImap4ServiceL, 0, KImumMtmLog ); |
|
1862 IMUM_IN(); |
|
1863 |
|
1864 // Get SMTP client and ui dlls |
|
1865 CClientMtmRegistry* clientRegistry=CClientMtmRegistry::NewL(Session()); |
|
1866 CleanupStack::PushL(clientRegistry); |
|
1867 |
|
1868 CBaseMtm* smtpmtm=clientRegistry->NewMtmL(KUidMsgTypeSMTP); |
|
1869 CleanupStack::PushL(smtpmtm); |
|
1870 |
|
1871 CMtmUiRegistry* mtmuireg=CMtmUiRegistry::NewL(Session()); |
|
1872 CleanupStack::PushL(mtmuireg); |
|
1873 |
|
1874 CBaseMtmUi* smtpUi=mtmuireg->NewMtmUiL(*smtpmtm); |
|
1875 CleanupStack::PushL(smtpUi); |
|
1876 |
|
1877 smtpUi->BaseMtm().SetCurrentEntryL(Session().GetEntryL(aServiceEntry)); |
|
1878 |
|
1879 TRAPD(ret, STATIC_CAST(CSmtpClientMtm&,smtpUi->BaseMtm()).RestoreSettingsL()); |
|
1880 if (ret==KErrNotFound) |
|
1881 STATIC_CAST(CSmtpClientMtm&,smtpUi->BaseMtm()).StoreSettingsL(); |
|
1882 else |
|
1883 User::LeaveIfError(ret); |
|
1884 |
|
1885 CMsvOperation* op=smtpUi->EditL(aStatus); |
|
1886 CleanupStack::PopAndDestroy(4); // CSI: 47 # smtpui, mtmuireg, smtpmtm, clientregistry |
|
1887 IMUM_OUT(); |
|
1888 return op; |
|
1889 } |
|
1890 |
|
1891 // ---------------------------------------------------------------------------- |
|
1892 // CImap4MtmUi::CheckEntryL() |
|
1893 // ---------------------------------------------------------------------------- |
|
1894 // |
|
1895 void CImap4MtmUi::CheckEntryL( const TMsvEntry& aEntry ) const |
|
1896 { |
|
1897 IMUM_CONTEXT( CImap4MtmUi::CheckEntryL, 0, KImumMtmLog ); |
|
1898 IMUM_IN(); |
|
1899 |
|
1900 if ((aEntry.iType!=KUidMsvMessageEntry && aEntry.iType!=KUidMsvServiceEntry && aEntry.iType!=KUidMsvFolderEntry) || aEntry.iMtm!=Type()) |
|
1901 User::Leave(KErrNotSupported); |
|
1902 IMUM_OUT(); |
|
1903 } |
|
1904 |
|
1905 // ---------------------------------------------------------------------------- |
|
1906 // CImap4MtmUi::CheckSelectionL() |
|
1907 // ---------------------------------------------------------------------------- |
|
1908 // |
|
1909 void CImap4MtmUi::CheckSelectionL( |
|
1910 const CMsvEntrySelection& aSelection ) const |
|
1911 { |
|
1912 IMUM_CONTEXT( CImap4MtmUi::CheckSelectionL, 0, KImumMtmLog ); |
|
1913 IMUM_IN(); |
|
1914 |
|
1915 __ASSERT_DEBUG(aSelection.Count(), |
|
1916 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiSelectionIsEmpty)); |
|
1917 if ( aSelection.Count() == 0 ) |
|
1918 { |
|
1919 User::Leave(KErrNotSupported); |
|
1920 } |
|
1921 iEntry->SetEntryL(aSelection[0]); |
|
1922 iEntry->SetEntryL(iEntry->Entry().Parent()); |
|
1923 TMsvEntry tentry; |
|
1924 for (TInt cc=aSelection.Count(); --cc>=0;) |
|
1925 { |
|
1926 tentry=iEntry->ChildDataL(aSelection[cc]); |
|
1927 if (tentry.iType!=KUidMsvMessageEntry || tentry.iMtm!=Type()) |
|
1928 { |
|
1929 User::Leave(KErrNotSupported); |
|
1930 } |
|
1931 } |
|
1932 IMUM_OUT(); |
|
1933 } |
|
1934 |
|
1935 // ---------------------------------------------------------------------------- |
|
1936 // CImap4MtmUi::SingleEntrySelectionLC() |
|
1937 // ---------------------------------------------------------------------------- |
|
1938 // |
|
1939 CMsvEntrySelection* CImap4MtmUi::SingleEntrySelectionLC( |
|
1940 TMsvId aId ) const |
|
1941 { |
|
1942 IMUM_CONTEXT( CImap4MtmUi::SingleEntrySelectionLC, 0, KImumMtmLog ); |
|
1943 IMUM_IN(); |
|
1944 |
|
1945 CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; |
|
1946 CleanupStack::PushL(selection); |
|
1947 selection->AppendL(aId); |
|
1948 IMUM_OUT(); |
|
1949 return selection; |
|
1950 } |
|
1951 |
|
1952 // ---------------------------------------------------------------------------- |
|
1953 // CImap4MtmUi::StripInvalidEntriesLC() |
|
1954 // ---------------------------------------------------------------------------- |
|
1955 // |
|
1956 CMsvEntrySelection* CImap4MtmUi::StripInvalidEntriesLC( |
|
1957 const CMsvEntrySelection& aSelection ) const |
|
1958 { |
|
1959 IMUM_CONTEXT( CImap4MtmUi::StripInvalidEntriesLC, 0, KImumMtmLog ); |
|
1960 IMUM_IN(); |
|
1961 |
|
1962 CMsvEntrySelection* entries=aSelection.CopyLC(); |
|
1963 CMsvEntrySelection* contextChildren=BaseMtm().Entry().ChildrenL(); |
|
1964 CleanupStack::PushL(contextChildren); |
|
1965 TInt cc=entries->Count(); |
|
1966 while (cc--) |
|
1967 { |
|
1968 if (contextChildren->Find((*entries)[cc]) == KErrNotFound) |
|
1969 entries->Delete(cc); |
|
1970 } |
|
1971 CleanupStack::PopAndDestroy(); |
|
1972 IMUM_OUT(); |
|
1973 return entries; |
|
1974 } |
|
1975 |
|
1976 // ---------------------------------------------------------------------------- |
|
1977 // CImap4MtmUi::StripBodyTextCompleteEntriesLC() |
|
1978 // ---------------------------------------------------------------------------- |
|
1979 // |
|
1980 CMsvEntrySelection* CImap4MtmUi::StripBodyTextCompleteEntriesLC( |
|
1981 const CMsvEntrySelection& aSelection ) const |
|
1982 { |
|
1983 IMUM_CONTEXT( CImap4MtmUi::StripBodyTextCompleteEntriesLC, 0, KImumMtmLog ); |
|
1984 IMUM_IN(); |
|
1985 |
|
1986 CMsvEntrySelection* entries=aSelection.CopyLC(); |
|
1987 iEntry->SetEntryL((*entries)[0]); |
|
1988 iEntry->SetEntryL(iEntry->Entry().Parent()); |
|
1989 TInt cc=entries->Count(); |
|
1990 while (cc--) |
|
1991 { |
|
1992 TMsvEmailEntry emailEntry(iEntry->ChildDataL((*entries)[cc])); |
|
1993 if(emailEntry.BodyTextComplete()) |
|
1994 { |
|
1995 entries->Delete(cc); |
|
1996 } |
|
1997 } |
|
1998 IMUM_OUT(); |
|
1999 return entries; |
|
2000 } |
|
2001 |
|
2002 // ---------------------------------------------------------------------------- |
|
2003 // CImap4MtmUi::StripCompleteEntriesLC() |
|
2004 // ---------------------------------------------------------------------------- |
|
2005 // |
|
2006 CMsvEntrySelection* CImap4MtmUi::StripCompleteEntriesLC( |
|
2007 const CMsvEntrySelection& aSelection ) const |
|
2008 { |
|
2009 IMUM_CONTEXT( CImap4MtmUi::StripCompleteEntriesLC, 0, KImumMtmLog ); |
|
2010 IMUM_IN(); |
|
2011 |
|
2012 iEntry->SetEntryL(aSelection[0]); |
|
2013 iEntry->SetEntryL(iEntry->Entry().Parent()); |
|
2014 IMUM_OUT(); |
|
2015 return MsvEmailMtmUiUtils::StripCompleteEntriesLC(*iEntry, aSelection); |
|
2016 } |
|
2017 |
|
2018 // ---------------------------------------------------------------------------- |
|
2019 // CImap4MtmUi::ValidateFolderNameL() |
|
2020 // ---------------------------------------------------------------------------- |
|
2021 // |
|
2022 void CImap4MtmUi::ValidateFolderNameL( |
|
2023 const TDesC& aName, |
|
2024 TDes8& aRetProgress ) |
|
2025 { |
|
2026 IMUM_CONTEXT( CImap4MtmUi::ValidateFolderNameL, 0, KImumMtmLog ); |
|
2027 IMUM_IN(); |
|
2028 |
|
2029 Imap4BaseMtm()->RestoreSettingsL(); // To recover the imap settings |
|
2030 const TChar separatorChar = Imap4BaseMtm()->Imap4Settings().PathSeparator(); |
|
2031 |
|
2032 TImap4UiProgressBuf& retProgress = STATIC_CAST(TImap4UiProgressBuf&, aRetProgress); |
|
2033 retProgress().iError = KErrNone; |
|
2034 const TChar forwardSlash(KForwardSlash); |
|
2035 const TChar backSlash(KBackSlash); |
|
2036 if(!aName.Length()) |
|
2037 { |
|
2038 retProgress().iError = KErrPathNotFound; |
|
2039 } |
|
2040 else if(aName.Length() > KImpuIMAPFolderNameLength) |
|
2041 { |
|
2042 retProgress().iError = KErrTooBig; |
|
2043 } |
|
2044 else if( ((separatorChar == forwardSlash || separatorChar == backSlash) && |
|
2045 ((aName.Locate(forwardSlash) >= 0) || (aName.Locate(backSlash) >= 0))) || |
|
2046 (aName.Locate(separatorChar) >= 0) ) |
|
2047 { |
|
2048 retProgress().iSeparatorChar = separatorChar; |
|
2049 retProgress().iError = KErrBadName; |
|
2050 } |
|
2051 IMUM_OUT(); |
|
2052 } |
|
2053 |
|
2054 // ---------------------------------------------------------------------------- |
|
2055 // CImap4MtmUi::DeleteFoldersFromL() |
|
2056 // ---------------------------------------------------------------------------- |
|
2057 // |
|
2058 CMsvOperation* CImap4MtmUi::DeleteFoldersFromL( |
|
2059 const CMsvEntrySelection& /*aSelection*/, |
|
2060 TRequestStatus& /*aStatus*/, |
|
2061 TMsvId /*aService*/, |
|
2062 TBool /*aOnline*/) |
|
2063 { |
|
2064 IMUM_CONTEXT( CImap4MtmUi::DeleteFoldersFromL, 0, KImumMtmLog ); |
|
2065 IMUM_IN(); |
|
2066 |
|
2067 // not supported |
|
2068 User::Leave(KErrNotSupported); |
|
2069 IMUM_OUT(); |
|
2070 return NULL; |
|
2071 } |
|
2072 |
|
2073 // ---------------------------------------------------------------------------- |
|
2074 // CImap4MtmUi::SelectionContainsInboxL() |
|
2075 // ---------------------------------------------------------------------------- |
|
2076 // |
|
2077 TMsvId CImap4MtmUi::SelectionContainsInboxL( |
|
2078 const CMsvEntry& aParentEntry, |
|
2079 const CMsvEntrySelection& aSelection ) const |
|
2080 { |
|
2081 IMUM_CONTEXT( CImap4MtmUi::SelectionContainsInboxL, 0, KImumMtmLog ); |
|
2082 IMUM_IN(); |
|
2083 |
|
2084 if (aParentEntry.Entry().iType.iUid!=KUidMsvServiceEntryValue) |
|
2085 return KMsvNullIndexEntryId; |
|
2086 for (TInt cc=aSelection.Count(); --cc>=0;) |
|
2087 { |
|
2088 const TMsvEntry& tentry = aParentEntry.ChildDataL(aSelection[cc]); |
|
2089 if (tentry.iDetails.CompareF(iInboxName)==0) |
|
2090 return tentry.Id(); |
|
2091 } |
|
2092 IMUM_OUT(); |
|
2093 return KMsvNullIndexEntryId; |
|
2094 } |
|
2095 |
|
2096 // ---------------------------------------------------------------------------- |
|
2097 // CImap4MtmUi::SelectionContainsGhostEntryL() |
|
2098 // ---------------------------------------------------------------------------- |
|
2099 // |
|
2100 TBool CImap4MtmUi::SelectionContainsGhostEntryL( |
|
2101 const CMsvEntry& aParentEntry, |
|
2102 const CMsvEntrySelection& aSelection ) |
|
2103 { |
|
2104 IMUM_CONTEXT( CImap4MtmUi::SelectionContainsGhostEntryL, 0, KImumMtmLog ); |
|
2105 IMUM_IN(); |
|
2106 |
|
2107 if(aSelection.Count()==0) |
|
2108 { |
|
2109 return EFalse; |
|
2110 } |
|
2111 |
|
2112 for(TInt cc=aSelection.Count(); --cc>=0;) |
|
2113 { |
|
2114 if(aParentEntry.ChildDataL(aSelection[cc]).iRelatedId!=KMsvNullIndexEntryId) |
|
2115 { |
|
2116 IMUM_OUT(); |
|
2117 return ETrue; |
|
2118 } |
|
2119 } |
|
2120 IMUM_OUT(); |
|
2121 return EFalse; |
|
2122 } |
|
2123 |
|
2124 // ---------------------------------------------------------------------------- |
|
2125 // CImap4MtmUi::SelectionContainsOnlyMessagesL() |
|
2126 // ---------------------------------------------------------------------------- |
|
2127 // |
|
2128 TBool CImap4MtmUi::SelectionContainsOnlyMessagesL( |
|
2129 const CMsvEntry& aParentEntry, |
|
2130 const CMsvEntrySelection& aSelection ) const |
|
2131 { |
|
2132 IMUM_CONTEXT( CImap4MtmUi::SelectionContainsOnlyMessagesL, 0, KImumMtmLog ); |
|
2133 IMUM_IN(); |
|
2134 |
|
2135 for(TInt cc=aSelection.Count() ; --cc>=0;) |
|
2136 { |
|
2137 if(aParentEntry.ChildDataL(aSelection[cc]).iType!=KUidMsvMessageEntry) |
|
2138 { |
|
2139 IMUM_OUT(); |
|
2140 return EFalse; |
|
2141 } |
|
2142 } |
|
2143 IMUM_OUT(); |
|
2144 return ETrue; |
|
2145 } |
|
2146 |
|
2147 // ---------------------------------------------------------------------------- |
|
2148 // CImap4MtmUi::DeleteFromL() |
|
2149 // ---------------------------------------------------------------------------- |
|
2150 // |
|
2151 CMsvOperation* CImap4MtmUi::DeleteFromL( |
|
2152 const CMsvEntrySelection& aSelection, |
|
2153 TRequestStatus& aStatus ) |
|
2154 { |
|
2155 IMUM_CONTEXT( CImap4MtmUi::DeleteFromL, 0, KImumMtmLog ); |
|
2156 IMUM_IN(); |
|
2157 |
|
2158 TBuf8<1> buf; |
|
2159 CMsvOperation* op=NULL; |
|
2160 |
|
2161 // Validate selection. |
|
2162 __ASSERT_DEBUG(aSelection.Count(), |
|
2163 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiSelectionIsEmpty)); |
|
2164 CMsvEntrySelection* validEntries=StripInvalidEntriesLC(aSelection); |
|
2165 CMsvEntrySelection* entries=MsvEmailMtmUiUtils::StripDeletedEntriesLC(BaseMtm().Entry(), *validEntries); // Current context is parent. |
|
2166 const TBool hasInbox = (SelectionContainsInboxL(BaseMtm().Entry(),*entries) != KMsvNullIndexEntryId); |
|
2167 if( (!entries->Count()) || (hasInbox) ) |
|
2168 { |
|
2169 IMUM2(0, "Cancelling delete for reasons: %d or %d", entries->Count(), hasInbox ); |
|
2170 CleanupStack::PopAndDestroy(2); // CSI: 47 # entries,validEntries |
|
2171 IMUM_OUT(); |
|
2172 return CMsvCompletedOperation::NewL(Session(), Type(), buf, KMsvLocalServiceIndexEntryId, aStatus, KErrNone); |
|
2173 } |
|
2174 |
|
2175 // Remove folders from the selection. |
|
2176 iEntry->SetEntryL((*entries)[0]); |
|
2177 const TMsvId parent(iEntry->Entry().Parent()); |
|
2178 iEntry->SetEntryL(parent); |
|
2179 TInt numberOfItems = entries->Count(); |
|
2180 while (numberOfItems--) |
|
2181 { |
|
2182 if(iEntry->ChildDataL((*entries)[numberOfItems]).iType == KUidMsvFolderEntry) |
|
2183 { |
|
2184 // remove folders from selection, we can only delete messages |
|
2185 entries->Delete(numberOfItems); |
|
2186 } |
|
2187 } |
|
2188 numberOfItems = entries->Count(); |
|
2189 |
|
2190 TInt chosedDelMode = KErrNotFound; |
|
2191 const TInt delMode = GetMailDeletionModeL(); |
|
2192 IMUM1(0, "Selected deletion mode: %d", delMode ); |
|
2193 |
|
2194 TBool dlgResult = ETrue; |
|
2195 |
|
2196 if ( delMode == EIMASMailDeletionAlwaysAsk ) |
|
2197 { |
|
2198 IMUM0(0, "Deleting: Always Ask" ); |
|
2199 CImumListQueryDialog* dlg = new (ELeave) CImumListQueryDialog( &chosedDelMode ); |
|
2200 dlg->PrepareLC( R_IMUM_DELETE_LIST_QUERY ); |
|
2201 |
|
2202 if ( numberOfItems > 1 ) |
|
2203 { |
|
2204 // change list query title |
|
2205 HBufC* manyMailsText = StringLoader::LoadLC( |
|
2206 R_IMUM_DELETE_LIST_QUERY_TITLE_MANY_MAILS, numberOfItems, iEikonEnv ); |
|
2207 |
|
2208 CAknPopupHeadingPane* heading = dlg->QueryHeading(); |
|
2209 heading->SetTextL( *manyMailsText ); |
|
2210 CleanupStack::PopAndDestroy( manyMailsText ); |
|
2211 } |
|
2212 |
|
2213 IMUM0(0, "Running dialog" ); |
|
2214 dlgResult = dlg->RunLD(); |
|
2215 } |
|
2216 else if ( numberOfItems > 1 ) |
|
2217 { |
|
2218 |
|
2219 HBufC* queryText = NULL; |
|
2220 |
|
2221 if ( delMode == EIMASMailDeletionPhone ) |
|
2222 { |
|
2223 queryText = StringLoader::LoadLC( |
|
2224 R_IMUM_DELETE_MANY_MAILS_PHONE_QUERY, numberOfItems, iEikonEnv ); |
|
2225 } |
|
2226 else |
|
2227 { |
|
2228 queryText = StringLoader::LoadLC( |
|
2229 R_IMUM_DELETE_MANY_MAILS_SERVER_QUERY, numberOfItems, iEikonEnv ); |
|
2230 } |
|
2231 |
|
2232 dlgResult = CIMSSettingsNoteUi::ShowQueryL( |
|
2233 *queryText, R_EMAIL_CONFIRMATION_QUERY ); |
|
2234 |
|
2235 CleanupStack::PopAndDestroy( queryText ); |
|
2236 } |
|
2237 |
|
2238 if ( delMode == EIMASMailDeletionPhone ) |
|
2239 { |
|
2240 chosedDelMode = KImumDeleteMessagesLocally; |
|
2241 } |
|
2242 |
|
2243 |
|
2244 if( dlgResult ) |
|
2245 { |
|
2246 CMsvProgressReporterOperation* reporter = |
|
2247 CMsvProgressReporterOperation::NewL( |
|
2248 Session(), aStatus, EMbmAvkonQgn_note_erased ); |
|
2249 CleanupStack::PushL(reporter); |
|
2250 |
|
2251 |
|
2252 if ( chosedDelMode == KImumDeleteMessagesLocally ) |
|
2253 { |
|
2254 // Show a note to make sure that user understands that header will still be seen |
|
2255 // even if mail is deleted from the phone, only showed if setting is always ask |
|
2256 if ( delMode == EIMASMailDeletionAlwaysAsk ) |
|
2257 { |
|
2258 // Set info note timeout to 1 second. Otherwise progress |
|
2259 // note will come on top of info note. CAknProgressDialog |
|
2260 // lead time before displaying the dialog is hardcoded to |
|
2261 // 1 second and cannot be adjusted. |
|
2262 const TInt KTimeout = 1000000; |
|
2263 CIMSSettingsNoteUi::ShowNoteL( R_IMUM_HEADER_WILL_REMAIN_PHONE, |
|
2264 EIMSInformationNote, EFalse, KTimeout ); |
|
2265 } |
|
2266 |
|
2267 CImumDeleteMessagesLocally* deleteop = |
|
2268 CImumDeleteMessagesLocally::NewL( |
|
2269 *entries, |
|
2270 *iMailboxApi, |
|
2271 reporter->iStatus ); |
|
2272 reporter->SetProgressDecoder( *deleteop ); |
|
2273 reporter->SetOperationL( deleteop ); // Takes immediate ownership |
|
2274 } |
|
2275 else |
|
2276 { |
|
2277 CImumDeleteMessagesFromServer* deleteop = |
|
2278 CImumDeleteMessagesFromServer::NewL( |
|
2279 *iMailboxApi, |
|
2280 reporter->iStatus, |
|
2281 *entries ); |
|
2282 reporter->SetProgressDecoder( *deleteop ); |
|
2283 reporter->SetOperationL( deleteop ); // Takes immediate ownership |
|
2284 } |
|
2285 |
|
2286 CleanupStack::Pop(); //reporter |
|
2287 op = reporter; |
|
2288 } |
|
2289 else |
|
2290 { |
|
2291 op=CMsvCompletedOperation::NewL( |
|
2292 Session(), |
|
2293 Type(), |
|
2294 buf, |
|
2295 KMsvLocalServiceIndexEntryId, |
|
2296 aStatus, |
|
2297 KErrCancel); |
|
2298 } |
|
2299 |
|
2300 CleanupStack::PopAndDestroy(2); // CSI: 47 # entries,validEntries |
|
2301 |
|
2302 IMUM_OUT(); |
|
2303 return op; |
|
2304 } |
|
2305 |
|
2306 // ---------------------------------------------------------------------------- |
|
2307 // CImap4MtmUi::UnDeleteFromL() |
|
2308 // ---------------------------------------------------------------------------- |
|
2309 // |
|
2310 CMsvOperation* CImap4MtmUi::UnDeleteFromL( |
|
2311 const CMsvEntrySelection& aSelection, |
|
2312 TRequestStatus& aStatus ) |
|
2313 { |
|
2314 IMUM_CONTEXT( CImap4MtmUi::UnDeleteFromL, 0, KImumMtmLog ); |
|
2315 IMUM_IN(); |
|
2316 |
|
2317 //Un-deletes selection from current context |
|
2318 |
|
2319 // We shouldn't need to check for folders - they are always deleted |
|
2320 // immediately on-line, so should never be in a position to be |
|
2321 // un-deleted. |
|
2322 TBool undelete = EFalse; |
|
2323 if ( aSelection.Count() > 1 ) |
|
2324 { |
|
2325 HBufC* promptText = StringLoader::LoadLC( |
|
2326 R_EMAIL_UNDELETE_MANY_MESSAGES_QUERY, aSelection.Count(), iCoeEnv ); |
|
2327 undelete = CIMSSettingsNoteUi::ShowQueryL( |
|
2328 *promptText, R_EMAIL_CONFIRMATION_QUERY ); |
|
2329 CleanupStack::PopAndDestroy( promptText ); |
|
2330 } |
|
2331 else |
|
2332 { |
|
2333 undelete = CIMSSettingsNoteUi::ShowQueryL( |
|
2334 R_EMAIL_UNDELETE_MESSAGE_QUERY, R_EMAIL_CONFIRMATION_QUERY ); |
|
2335 } |
|
2336 if ( undelete ) |
|
2337 { |
|
2338 TBuf8<1> dummyParam; |
|
2339 CMsvProgressReporterOperation* reporter = CMsvProgressReporterOperation::NewL(Session(), aStatus, EMbmAvkonQgn_note_progress); |
|
2340 CleanupStack::PushL(reporter); |
|
2341 CMsvOperation* op = BaseMtm().InvokeAsyncFunctionL(KIMAP4MTMUndeleteAll,aSelection,dummyParam,reporter->RequestStatus()); |
|
2342 reporter->SetOperationL(op); // Takes immediate ownership |
|
2343 CleanupStack::Pop(); // reporter |
|
2344 IMUM_OUT(); |
|
2345 return reporter; |
|
2346 } |
|
2347 else |
|
2348 { |
|
2349 TBuf8<1> buf; |
|
2350 IMUM_OUT(); |
|
2351 return CMsvCompletedOperation::NewL( |
|
2352 Session(), |
|
2353 Type(), |
|
2354 buf, |
|
2355 KMsvLocalServiceIndexEntryId, |
|
2356 aStatus, |
|
2357 KErrCancel); |
|
2358 } |
|
2359 } |
|
2360 |
|
2361 // ---------------------------------------------------------------------------- |
|
2362 // CImap4MtmUi::ForwardL() |
|
2363 // ---------------------------------------------------------------------------- |
|
2364 // |
|
2365 CMsvOperation* CImap4MtmUi::ForwardL( |
|
2366 TMsvId aDestination, |
|
2367 TMsvPartList aPartList, |
|
2368 TRequestStatus& aCompletionStatus ) |
|
2369 { |
|
2370 IMUM_CONTEXT( CImap4MtmUi::ForwardL, 0, KImumMtmLog ); |
|
2371 IMUM_IN(); |
|
2372 IMUM_OUT(); |
|
2373 |
|
2374 return ForwardOrReplyL(aPartList, aDestination, aCompletionStatus, ETrue); |
|
2375 } |
|
2376 |
|
2377 // ---------------------------------------------------------------------------- |
|
2378 // CImap4MtmUi::ReplyL() |
|
2379 // ---------------------------------------------------------------------------- |
|
2380 // |
|
2381 CMsvOperation* CImap4MtmUi::ReplyL( |
|
2382 TMsvId aDestination, |
|
2383 TMsvPartList aPartList, |
|
2384 TRequestStatus& aCompletionStatus ) |
|
2385 { |
|
2386 IMUM_CONTEXT( CImap4MtmUi::ReplyL, 0, KImumMtmLog ); |
|
2387 IMUM_IN(); |
|
2388 IMUM_OUT(); |
|
2389 |
|
2390 return ForwardOrReplyL(aPartList, aDestination, aCompletionStatus, EFalse); |
|
2391 } |
|
2392 |
|
2393 // ---------------------------------------------------------------------------- |
|
2394 // CImap4MtmUi::ForwardOrReplyL() |
|
2395 // ---------------------------------------------------------------------------- |
|
2396 // |
|
2397 CMsvOperation* CImap4MtmUi::ForwardOrReplyL( |
|
2398 TMsvPartList aPartlist, |
|
2399 TMsvId aDestination, |
|
2400 TRequestStatus& aCompletionStatus, |
|
2401 TBool aForward) |
|
2402 { |
|
2403 IMUM_CONTEXT( CImap4MtmUi::ForwardOrReplyL, 0, KImumMtmLog ); |
|
2404 IMUM_IN(); |
|
2405 |
|
2406 // We need to determine whether we're working with a ghost entry or not |
|
2407 TMsvId relatedId=BaseMtm().Entry().Entry().iRelatedId; |
|
2408 |
|
2409 if(relatedId!=KMsvNullIndexEntryId) |
|
2410 // We're dealing with a ghost entry - trace back to originator |
|
2411 BaseMtm().SwitchCurrentEntryL(relatedId); |
|
2412 |
|
2413 TEditorParameters editorParams; |
|
2414 |
|
2415 editorParams.iFlags &= ~(EMsgLaunchEditorEmbedded | EMsgLaunchEditorThenWait); |
|
2416 const TUint preferences = Preferences(); |
|
2417 if(preferences & EMtmUiFlagEditorPreferEmbedded) |
|
2418 { |
|
2419 editorParams.iFlags |= EMsgLaunchEditorEmbedded; |
|
2420 } |
|
2421 if(!(preferences & EMtmUiFlagEditorNoWaitForExit)) |
|
2422 { |
|
2423 editorParams.iFlags |= EMsgLaunchEditorThenWait; |
|
2424 } |
|
2425 |
|
2426 if(aForward) |
|
2427 editorParams.iFlags|=EMsgForwardMessage; |
|
2428 else |
|
2429 editorParams.iFlags|=(aPartlist&KMsvMessagePartRecipient)?EMsgReplyToMessageAll:EMsgReplyToMessageSender; |
|
2430 |
|
2431 editorParams.iId=BaseMtm().Entry().EntryId(); |
|
2432 editorParams.iPartList = aPartlist; |
|
2433 editorParams.iDestinationFolderId = aDestination; |
|
2434 |
|
2435 CMsvOperation* op=NULL; |
|
2436 |
|
2437 if ( BaseMtm().Entry().Entry().Unread() ) |
|
2438 { |
|
2439 // mark read before reply... |
|
2440 |
|
2441 CMsvEntry* msgEntry = |
|
2442 Session().GetEntryL( BaseMtm().Entry().EntryId() ); |
|
2443 CleanupStack::PushL( msgEntry ); |
|
2444 TMsvEntry email = msgEntry->Entry(); |
|
2445 |
|
2446 // Set the unread flag |
|
2447 email.SetUnread( EFalse ); |
|
2448 |
|
2449 CMuiuOperationWait* wait = |
|
2450 CMuiuOperationWait::NewLC( EActivePriorityDefault ); |
|
2451 CMsvOperation* op=msgEntry->ChangeL( email, wait->iStatus ); |
|
2452 wait->Start(); |
|
2453 CleanupStack::PopAndDestroy( wait ); |
|
2454 wait = NULL; |
|
2455 |
|
2456 delete op; |
|
2457 op = NULL; |
|
2458 |
|
2459 CleanupStack::PopAndDestroy( msgEntry ); |
|
2460 msgEntry = NULL; |
|
2461 } |
|
2462 |
|
2463 if(BaseMtm().Entry().Entry().Complete()) |
|
2464 op=LaunchEditorApplicationL(aCompletionStatus, editorParams); |
|
2465 else if(relatedId!=KMsvNullIndexEntryId) |
|
2466 // We were originally dealing with ghost entry |
|
2467 op=OfferSynchroniseL(BaseMtm().Entry().OwningService(), aCompletionStatus); |
|
2468 else |
|
2469 // We are dealing with an incomplete, non-ghost entry |
|
2470 op=OpenMessageL(aCompletionStatus, editorParams); |
|
2471 IMUM_OUT(); |
|
2472 |
|
2473 return op; |
|
2474 } |
|
2475 |
|
2476 // ---------------------------------------------------------------------------- |
|
2477 // CImap4MtmUi::FetchMessagesL() |
|
2478 // ---------------------------------------------------------------------------- |
|
2479 // |
|
2480 CMsvOperation* CImap4MtmUi::FetchMessagesL( |
|
2481 TRequestStatus& aStatus, |
|
2482 const CMsvEntrySelection& aSelection, |
|
2483 TInt aFunctionId, |
|
2484 TImImap4GetMailInfo& aGetMailInfo ) |
|
2485 { |
|
2486 IMUM_CONTEXT( CImap4MtmUi::FetchMessagesL, 0, KImumMtmLog ); |
|
2487 IMUM_IN(); |
|
2488 |
|
2489 // Fetch messages, no size checking. |
|
2490 // Used for 'Fetch All', 'Fetch New', and 'Get Mail'. |
|
2491 CMsvProgressReporterOperation* reporter = |
|
2492 CMsvProgressReporterOperation::NewL( ETrue, ETrue, Session(), aStatus, |
|
2493 EMbmAvkonQgn_note_progress ); |
|
2494 CleanupStack::PushL( reporter ); |
|
2495 |
|
2496 HBufC* title = StringLoader::LoadLC( |
|
2497 R_IMAP4_PROGRESS_FETCHING, iCoeEnv ); |
|
2498 reporter->SetTitleL( *title ); |
|
2499 CleanupStack::PopAndDestroy( title ); |
|
2500 title=NULL; |
|
2501 |
|
2502 |
|
2503 const TMsvId service = BaseMtm().Entry().OwningService(); |
|
2504 CMsvOperation* fetch = CImap4FetchOp::NewL( *iMailboxApi, |
|
2505 reporter->RequestStatus(), *reporter, service, aFunctionId, |
|
2506 aGetMailInfo, aSelection ); |
|
2507 reporter->SetOperationL( fetch ); // Takes immediate ownership |
|
2508 CleanupStack::Pop(); // reporter |
|
2509 IMUM_OUT(); |
|
2510 return reporter; |
|
2511 } |
|
2512 |
|
2513 // ---------------------------------------------------------------------------- |
|
2514 // CImap4MtmUi::InitParametersForFetchCmdL() |
|
2515 // ---------------------------------------------------------------------------- |
|
2516 // |
|
2517 void CImap4MtmUi::InitParametersForFetchCmdL( |
|
2518 CMsvEntrySelection* aSelection, |
|
2519 TImImap4GetMailInfo& aGetMailInfo, |
|
2520 TBool aInsertParentFolder /* = ETrue */) const |
|
2521 { |
|
2522 IMUM_CONTEXT( CImap4MtmUi::InitParametersForFetchCmdL, 0, KImumMtmLog ); |
|
2523 IMUM_IN(); |
|
2524 |
|
2525 // Initialise the parameters for Fetch New, Fetch All or Fetch selected. |
|
2526 // Client MTM context is folder. |
|
2527 // For populate new or populate all, we must add the parent folder to the selection. |
|
2528 if ( aInsertParentFolder && aSelection) |
|
2529 { |
|
2530 aSelection->InsertL(0, BaseMtm().Entry().EntryId()); |
|
2531 } |
|
2532 aGetMailInfo.iMaxEmailSize = KMaxTInt32; |
|
2533 const TMsvId currentEntryId = BaseMtm().Entry().EntryId(); |
|
2534 BaseMtm().SwitchCurrentEntryL(BaseMtm().Entry().OwningService()); |
|
2535 Imap4BaseMtm()->RestoreSettingsL(); |
|
2536 BaseMtm().SwitchCurrentEntryL( currentEntryId ); |
|
2537 |
|
2538 if ( iFeatureFlags->GF( EMailFeatureMeetingRequestSupport ) ) |
|
2539 { |
|
2540 aGetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyAlternativeText; |
|
2541 } |
|
2542 else |
|
2543 { |
|
2544 aGetMailInfo.iGetMailBodyParts = EGetImap4EmailBodyText; |
|
2545 } |
|
2546 |
|
2547 // No destination for populate. |
|
2548 aGetMailInfo.iDestinationFolder = KMsvNullIndexEntryId; |
|
2549 |
|
2550 IMUM_OUT(); |
|
2551 } |
|
2552 |
|
2553 // ---------------------------------------------------------------------------- |
|
2554 // CImap4MtmUi::InitParametersForGetMailCmdL() |
|
2555 // ---------------------------------------------------------------------------- |
|
2556 // |
|
2557 void CImap4MtmUi::InitParametersForGetMailCmdL( |
|
2558 CMsvEntrySelection& aSelection, |
|
2559 TImImap4GetMailInfo& aGetMailInfo) |
|
2560 { |
|
2561 IMUM_CONTEXT( CImap4MtmUi::InitParametersForGetMailCmdL, 0, KImumMtmLog ); |
|
2562 IMUM_IN(); |
|
2563 |
|
2564 // Initialise the parameters for Get Mail. |
|
2565 // Client MTM context is service. |
|
2566 // We must add the inbox id to the selection. |
|
2567 CMsvEntrySelection* serviceChildren = BaseMtm().Entry().ChildrenL(); |
|
2568 CleanupStack::PushL(serviceChildren); |
|
2569 const TMsvId inboxId = SelectionContainsInboxL(BaseMtm().Entry(),*serviceChildren); |
|
2570 CleanupStack::PopAndDestroy(); // serviceChildren |
|
2571 aSelection.InsertL(0, inboxId); |
|
2572 Imap4BaseMtm()->RestoreSettingsL(); |
|
2573 const CImImap4Settings& settings = Imap4BaseMtm()->Imap4Settings(); |
|
2574 aGetMailInfo.iMaxEmailSize = (TInt32)(settings.MaxEmailSize()); |
|
2575 aGetMailInfo.iGetMailBodyParts = settings.GetMailOptions(); |
|
2576 aGetMailInfo.iDestinationFolder = KMsvNullIndexEntryId; // No destination for populate. |
|
2577 IMUM_OUT(); |
|
2578 } |
|
2579 |
|
2580 // ---------------------------------------------------------------------------- |
|
2581 // CImap4MtmUi::OpenMessageL() |
|
2582 // ---------------------------------------------------------------------------- |
|
2583 // |
|
2584 CMsvOperation* CImap4MtmUi::OpenMessageL( |
|
2585 TRequestStatus& aCompletionStatus, |
|
2586 const TEditorParameters& aEditorParams ) |
|
2587 { |
|
2588 IMUM_CONTEXT( CImap4MtmUi::OpenMessageL, 0, KImumMtmLog ); |
|
2589 IMUM_IN(); |
|
2590 |
|
2591 CMsvOperation* op = DoPopulateIncompleteMessageL(aCompletionStatus, *SingleEntrySelectionLC(aEditorParams.iId), aEditorParams); |
|
2592 CleanupStack::PopAndDestroy(); // selection |
|
2593 |
|
2594 IMUM_OUT(); |
|
2595 return op; |
|
2596 } |
|
2597 |
|
2598 // ---------------------------------------------------------------------------- |
|
2599 // CImap4MtmUi::PopulateMessagesL() |
|
2600 // ---------------------------------------------------------------------------- |
|
2601 // |
|
2602 CMsvOperation* CImap4MtmUi::PopulateMessagesL( |
|
2603 TRequestStatus& aCompletionStatus, |
|
2604 const CMsvEntrySelection& aSel ) |
|
2605 { |
|
2606 IMUM_CONTEXT( CImap4MtmUi::PopulateMessagesL, 0, KImumMtmLog ); |
|
2607 IMUM_IN(); |
|
2608 IMUM_OUT(); |
|
2609 return DoPopulateIncompleteMessageL( |
|
2610 aCompletionStatus, aSel, TEditorParameters() ); |
|
2611 } |
|
2612 |
|
2613 // ---------------------------------------------------------------------------- |
|
2614 // CImap4MtmUi::DoPopulateIncompleteMessageL() |
|
2615 // ---------------------------------------------------------------------------- |
|
2616 // |
|
2617 CMsvOperation* CImap4MtmUi::DoPopulateIncompleteMessageL( |
|
2618 TRequestStatus& aStatus, |
|
2619 const CMsvEntrySelection& aSel, |
|
2620 const TEditorParameters& aEditorParams ) |
|
2621 { |
|
2622 IMUM_CONTEXT( CImap4MtmUi::DoPopulateIncompleteMessageL, 0, KImumMtmLog ); |
|
2623 IMUM_IN(); |
|
2624 |
|
2625 TBuf8<1> dummyParams; |
|
2626 CMsvSession& session = Session(); |
|
2627 |
|
2628 // this is just to make sure fetching is not even started if no disk space left. |
|
2629 if ( !MsvEmailMtmUiUtils::CheckAvailableDiskSpaceForDownloadL( |
|
2630 KImumApproxMailFetchSize, *iEikonEnv, session ) ) |
|
2631 { |
|
2632 return CMsvCompletedOperation::NewL(Session(), Type(), dummyParams, KMsvLocalServiceIndexEntryId, aStatus, KErrNone); |
|
2633 } |
|
2634 // Determine how much of the message to fetch, and prompt if neccessary. |
|
2635 // Return the operation to be returned to the application. |
|
2636 // Copes with simply populating, and launching an editor after populating. If launching an editor, |
|
2637 // 'aSel' should contain only one message id. |
|
2638 |
|
2639 |
|
2640 // Check the whole selection for ghost entries. If such an entry exists, |
|
2641 // and we're offline, we need to synchronise. |
|
2642 CMsvEntry* msgEntry = Session().GetEntryL(aSel[0]); |
|
2643 CleanupStack::PushL(msgEntry); |
|
2644 TMsvId owningService=msgEntry->OwningService(); |
|
2645 TMsvEmailEntry emailEntry(msgEntry->Entry()); |
|
2646 |
|
2647 TBool currentBodyComplete = emailEntry.BodyTextComplete(); |
|
2648 |
|
2649 const TBool offline = !IsConnected(owningService); |
|
2650 const TMsvId parentId = msgEntry->Entry().Parent(); |
|
2651 msgEntry->SetEntryL(parentId); |
|
2652 if(SelectionContainsGhostEntryL(*msgEntry,aSel) && offline) |
|
2653 { |
|
2654 CleanupStack::PopAndDestroy(); // msgEntry; |
|
2655 return OfferSynchroniseL(owningService, aStatus); |
|
2656 } |
|
2657 |
|
2658 CMsvEntrySelection* entries = StripCompleteEntriesLC(aSel); |
|
2659 TInt numMsgs = entries->Count(); |
|
2660 CleanupStack::PopAndDestroy(); // entries |
|
2661 if(!numMsgs) |
|
2662 { |
|
2663 // no entries to fetch |
|
2664 CleanupStack::PopAndDestroy(); // msgEntry; |
|
2665 return CMsvCompletedOperation::NewL(Session(), Type(), dummyParams, KMsvLocalServiceIndexEntryId, aStatus, KErrNone); |
|
2666 } |
|
2667 //// |
|
2668 //// --- Get info --- |
|
2669 //// |
|
2670 const TBool forwarding = (aEditorParams.iFlags & EMsgForwardMessage); |
|
2671 TImImap4GetMailInfo getMailInfo; |
|
2672 InitParametersForFetchCmdL(NULL, getMailInfo, EFalse); |
|
2673 enum TFetchType { EFetchCompleted, EFetchBodyText, EFetchAttachments }; |
|
2674 TFetchType fetchType = EFetchBodyText; |
|
2675 |
|
2676 numMsgs = aSel.Count(); |
|
2677 TBool hasAttachments = EFalse; // Do *any* of the messages have attachments? |
|
2678 TInt msgCount = 0; |
|
2679 for(; msgCount < numMsgs; msgCount++) |
|
2680 { |
|
2681 if(msgEntry->ChildDataL(aSel[msgCount]).Attachment()) |
|
2682 { |
|
2683 hasAttachments = ETrue; // Can we tell if we already have all attachments? |
|
2684 break; |
|
2685 } |
|
2686 } |
|
2687 |
|
2688 if ( hasAttachments && |
|
2689 getMailInfo.iGetMailBodyParts == EGetImap4EmailBodyTextAndAttachments ) |
|
2690 { |
|
2691 fetchType = EFetchAttachments; |
|
2692 } |
|
2693 |
|
2694 for(msgCount = 0; msgCount < numMsgs; msgCount++) |
|
2695 { |
|
2696 emailEntry = msgEntry->ChildDataL(aSel[msgCount]); |
|
2697 if(!emailEntry.BodyTextComplete()) |
|
2698 { |
|
2699 break; |
|
2700 } |
|
2701 } |
|
2702 CleanupStack::PopAndDestroy(); //msgEntry |
|
2703 |
|
2704 if(hasAttachments && forwarding) |
|
2705 { |
|
2706 // Always get attachments if forwarding. |
|
2707 fetchType = EFetchAttachments; |
|
2708 } |
|
2709 |
|
2710 IMUM0(0, "Prompt for the fetching"); |
|
2711 |
|
2712 //Do the prompting only if opening unfetched message and offline and message body is incomplete |
|
2713 if( !currentBodyComplete && offline && aEditorParams.iFlags) |
|
2714 { |
|
2715 if ( CIMSSettingsNoteUi::ShowQueryL( |
|
2716 R_EMAIL_RETRIEVE_1_TEXT, R_EMAIL_CONFIRMATION_QUERY ) ) |
|
2717 { |
|
2718 //VARIATION START |
|
2719 if ( iFeatureFlags->GF( EMailFeatureOfflineMode ) ) |
|
2720 { |
|
2721 TMsvId mailboxId = BaseMtm().Entry().EntryId(); |
|
2722 //No need to do this if we're online... |
|
2723 TBool offline = EFalse; |
|
2724 if( !IsConnected( mailboxId ) && |
|
2725 !iMailboxApi->MailboxUtilitiesL().HasWlanConnectionL( mailboxId ) ) |
|
2726 { |
|
2727 offline = MsvEmailMtmUiUtils::DoOfflineChecksL( mailboxId ); |
|
2728 } |
|
2729 if( offline ) |
|
2730 { |
|
2731 return CMsvCompletedOperation::NewL(Session(), Type(), KNullDesC8, KMsvLocalServiceIndexEntryId, aStatus, KErrCancel); |
|
2732 } |
|
2733 }//if |
|
2734 //VARIATION END |
|
2735 if( hasAttachments ) |
|
2736 { |
|
2737 fetchType = EFetchAttachments; |
|
2738 } |
|
2739 } |
|
2740 else |
|
2741 { |
|
2742 return CMsvCompletedOperation::NewL(Session(), Type(), dummyParams, KMsvLocalServiceIndexEntryId, aStatus, KErrCancel); |
|
2743 } |
|
2744 } |
|
2745 |
|
2746 //// |
|
2747 //// --- Check there is work to do --- |
|
2748 //// |
|
2749 // We know none of the entries are complete, (since we check at the top of the fn). |
|
2750 // If just fetching body text, check we don't have the body text for all the messages. |
|
2751 if(fetchType == EFetchBodyText) |
|
2752 { |
|
2753 entries = StripBodyTextCompleteEntriesLC(aSel); |
|
2754 if(entries->Count() == 0) |
|
2755 { |
|
2756 // No messages to fetch. |
|
2757 fetchType = EFetchCompleted; |
|
2758 } |
|
2759 CleanupStack::PopAndDestroy(); // entries |
|
2760 } |
|
2761 |
|
2762 if(fetchType == EFetchCompleted) |
|
2763 { |
|
2764 if(aEditorParams.iFlags) |
|
2765 { |
|
2766 IMUM_OUT(); |
|
2767 // Editing, but no fetch to do. |
|
2768 return LaunchEditorApplicationL(aStatus, aEditorParams); |
|
2769 } |
|
2770 } |
|
2771 |
|
2772 //// |
|
2773 //// --- Create the operation(s) --- |
|
2774 //// |
|
2775 |
|
2776 // Create a progress reporting dialog. |
|
2777 CMsvProgressReporterOperation* reporter = |
|
2778 CMsvProgressReporterOperation::NewL( |
|
2779 ETrue, |
|
2780 ETrue, |
|
2781 Session(), |
|
2782 aStatus, |
|
2783 EMbmAvkonQgn_note_progress ); |
|
2784 CleanupStack::PushL(reporter); |
|
2785 |
|
2786 // If already connected, display the "Retrieving..." note right away. |
|
2787 if ( IsConnected( owningService )) |
|
2788 reporter->SetTitleL( R_IMAP4_PROGRESS_FETCHING ); |
|
2789 |
|
2790 else |
|
2791 { |
|
2792 TBuf<EProgressStringMaxLen> title; |
|
2793 MsvEmailMtmUiUtils::CreateConnectingToText( title, |
|
2794 *iMsvSession, owningService ); |
|
2795 reporter->SetTitleL( title ); |
|
2796 } |
|
2797 |
|
2798 |
|
2799 CMsvOperation* fetch = NULL; |
|
2800 getMailInfo.iDestinationFolder = parentId; |
|
2801 if(aEditorParams.iFlags) |
|
2802 { |
|
2803 // Create a fetch and edit operation. |
|
2804 HBufC* appName = (aEditorParams.iFlags & EMsgReadOnly) ? (GetViewerFileNameL()) : (GetEditorFileNameL()); |
|
2805 TEmailEditParams fetchAndEditParams; |
|
2806 fetchAndEditParams.iPreferences = Preferences(); |
|
2807 fetchAndEditParams.iEditorFileName = *appName; |
|
2808 fetchAndEditParams.iEditorParams = aEditorParams; |
|
2809 const TBool ackReceipts = AcknowledgeReceiptsL(aEditorParams.iId); |
|
2810 CImumFetchAndEditOperation* fetchAndEdit = CImumFetchAndEditOperation::NewL( |
|
2811 *iMailboxApi, reporter->RequestStatus(), *reporter, fetchAndEditParams, ackReceipts); |
|
2812 CleanupStack::PushL(fetchAndEdit); |
|
2813 // Create a fetch operation. |
|
2814 fetch = InvokeRemoteFetchOpL(*reporter, fetchAndEdit->RequestStatus(), aSel, |
|
2815 KIMAP4MTMPopulateMailSelectionWhenAlreadyConnected, getMailInfo); |
|
2816 // Set up the wrapping. |
|
2817 fetchAndEdit->SetFetchOpL(fetch); |
|
2818 CleanupStack::Pop(); // fetchAndEdit |
|
2819 reporter->SetOperationL(fetchAndEdit); // Takes immediate ownership |
|
2820 } |
|
2821 else |
|
2822 { |
|
2823 // Create a fetch operation. |
|
2824 fetch = InvokeRemoteFetchOpL(*reporter, reporter->RequestStatus(), aSel, |
|
2825 KIMAP4MTMPopulateMailSelectionWhenAlreadyConnected, getMailInfo); |
|
2826 reporter->SetOperationL(fetch); // Takes immediate ownership |
|
2827 } |
|
2828 CleanupStack::Pop(); // reporter |
|
2829 |
|
2830 IMUM_OUT(); |
|
2831 return reporter; |
|
2832 } |
|
2833 |
|
2834 // ---------------------------------------------------------------------------- |
|
2835 // CImap4MtmUi::InvokeRemoteFetchOpL() |
|
2836 // ---------------------------------------------------------------------------- |
|
2837 // |
|
2838 CMsvOperation* CImap4MtmUi::InvokeRemoteFetchOpL( |
|
2839 CMsvProgressReporterOperation& aReporter, |
|
2840 TRequestStatus& aCompletionStatus, |
|
2841 const CMsvEntrySelection& aSel, |
|
2842 TInt aFunctionId, |
|
2843 const TImImap4GetMailInfo& aGetMailInfo) |
|
2844 { |
|
2845 IMUM_CONTEXT( CImap4MtmUi::InvokeRemoteFetchOpL, 0, KImumMtmLog ); |
|
2846 IMUM_IN(); |
|
2847 |
|
2848 CMsvEntry* centry = Session().GetEntryL(aSel[0]); |
|
2849 TMsvId service = centry->OwningService(); |
|
2850 delete centry; |
|
2851 IMUM_OUT(); |
|
2852 return CImap4SizeAndFetchOp::NewL(*iMailboxApi,aCompletionStatus, aReporter, service, aFunctionId, aGetMailInfo, aSel); |
|
2853 } |
|
2854 |
|
2855 // ---------------------------------------------------------------------------- |
|
2856 // CImap4MtmUi::InvokeCopyMoveOpL() |
|
2857 // ---------------------------------------------------------------------------- |
|
2858 // |
|
2859 CMsvOperation* CImap4MtmUi::InvokeCopyMoveOpL( |
|
2860 CMsvProgressReporterOperation& aReporter, |
|
2861 TRequestStatus& aCompletionStatus, |
|
2862 const CMsvEntrySelection& aSel, |
|
2863 TMsvId aTargetId, |
|
2864 TBool aCopy ) |
|
2865 { |
|
2866 IMUM_CONTEXT( CImap4MtmUi::InvokeCopyMoveOpL, 0, KImumMtmLog ); |
|
2867 IMUM_IN(); |
|
2868 IMUM_OUT(); |
|
2869 |
|
2870 return CImap4CopyMoveLocalOp::NewL(*iMailboxApi, aCompletionStatus, aReporter, aSel, aTargetId, aCopy); |
|
2871 } |
|
2872 |
|
2873 // ---------------------------------------------------------------------------- |
|
2874 // CImap4MtmUi::OfferSynchroniseL() |
|
2875 // ---------------------------------------------------------------------------- |
|
2876 // |
|
2877 CMsvOperation* CImap4MtmUi::OfferSynchroniseL( |
|
2878 TMsvId aService, |
|
2879 TRequestStatus& aStatus) |
|
2880 { |
|
2881 IMUM_CONTEXT( CImap4MtmUi::OfferSynchroniseL, 0, KImumMtmLog ); |
|
2882 IMUM_IN(); |
|
2883 |
|
2884 CMsvOperation* op=NULL; |
|
2885 TInt state=ServiceState(aService); |
|
2886 if(ServiceIsDisconnected(state) && !ServiceIsConnecting(state)) |
|
2887 // no query to user, just synchronise... |
|
2888 { |
|
2889 // User wishes to connect and sync... |
|
2890 CMsvEntrySelection* mySelection=SingleEntrySelectionLC(aService); |
|
2891 TBuf8<1> dummyParam; |
|
2892 op=InvokeAsyncFunctionL(KImpiMTMConnectAndSyncCompleteAfterDisconnection, *mySelection, aStatus, dummyParam); |
|
2893 CleanupStack::PopAndDestroy(); // mySelection |
|
2894 } |
|
2895 else |
|
2896 op=CompletedImap4OperationL(aService, aStatus); |
|
2897 IMUM_OUT(); |
|
2898 return op; |
|
2899 } |
|
2900 |
|
2901 // --------------------------------------------------------------------------- |
|
2902 // CImap4MtmUi::ShowMessageInfoL() |
|
2903 // --------------------------------------------------------------------------- |
|
2904 // |
|
2905 CMsvOperation* CImap4MtmUi::ShowMessageInfoL( |
|
2906 TRequestStatus& aCompletionStatus, |
|
2907 TDes8& /*aParameter*/ ) |
|
2908 { |
|
2909 IMUM_CONTEXT( CImap4MtmUi::ShowMessageInfoL, 0, KImumMtmLog ); |
|
2910 IMUM_IN(); |
|
2911 |
|
2912 TMsgInfoMessageInfoData infoData; |
|
2913 TBuf<KImumMessageInfoBuffer> dateBuf; |
|
2914 TBuf<KImumMessageInfoBuffer> timeBuf; |
|
2915 TBuf<KImumMessageInfoBuffer> sizeBuf; |
|
2916 TBuf<KImumMessagePriorityBufferLength> priorityBuf; |
|
2917 TBool readStoreFound = MsvEmailMtmUiUtils::SetMessageInfoDataLCC( |
|
2918 infoData,*Imap4BaseMtm(),*iEikonEnv,dateBuf,timeBuf,sizeBuf,priorityBuf ); |
|
2919 |
|
2920 TBuf<KImumMessageInfoBuffer> type; |
|
2921 iEikonEnv->ReadResourceL( type,R_IMAP_MESSAGE_INFO_MAIL_TYPE ); |
|
2922 infoData.iType.Set(type); |
|
2923 |
|
2924 CMsgInfoMessageInfoDialog* infoDialog = CMsgInfoMessageInfoDialog::NewL(); |
|
2925 infoDialog->ExecuteLD( infoData, CMsgInfoMessageInfoDialog::EEmailViewer ); |
|
2926 CleanupStack::PopAndDestroy( 2 ); // CSI: 47 # 2 because SetMessageInfoDataLCC |
|
2927 if ( readStoreFound ) |
|
2928 { |
|
2929 CleanupStack::PopAndDestroy( 2 ); // CSI: 47 # 2 because store found |
|
2930 } |
|
2931 IMUM_OUT(); |
|
2932 |
|
2933 return CMsvCompletedOperation::NewL( |
|
2934 Session(), KUidMsvLocalServiceMtm, KNullDesC8, |
|
2935 KMsvLocalServiceIndexEntryId, aCompletionStatus, KErrNone ); |
|
2936 } |
|
2937 |
|
2938 // End of file |
|
2939 |