16 */ |
16 */ |
17 |
17 |
18 #include "emailtrace.h" |
18 #include "emailtrace.h" |
19 #include "ipsplgheaders.h" |
19 #include "ipsplgheaders.h" |
20 |
20 |
21 // <qmail> priority const has been removed |
21 // Constants and defines |
22 |
22 const TInt KFetchOpPriority = CActive::EPriorityStandard; |
23 // ---------------------------------------------------------------------------- |
23 const TInt KIpsPlgSelectionGra = 16; |
24 // ---------------------------------------------------------------------------- |
24 |
25 // <qmail> priority parameter has been removed |
25 // ---------------------------------------------------------------------------- |
26 // <qmail> MFSMailRequestObserver& changed to pointer |
26 // ---------------------------------------------------------------------------- |
27 EXPORT_C CIpsPlgImap4PopulateOp* CIpsPlgImap4PopulateOp::NewL( |
27 EXPORT_C CIpsPlgImap4PopulateOp* CIpsPlgImap4PopulateOp::NewL( |
28 CMsvSession& aMsvSession, |
28 CMsvSession& aMsvSession, |
29 TRequestStatus& aObserverRequestStatus, |
29 TRequestStatus& aObserverRequestStatus, |
|
30 TInt aPriority, |
30 TMsvId aService, |
31 TMsvId aService, |
31 CIpsPlgTimerOperation& aActivityTimer, |
32 CIpsPlgTimerOperation& aActivityTimer, |
32 const TImImap4GetPartialMailInfo& aPartialMailInfo, |
33 const TImImap4GetPartialMailInfo& aPartialMailInfo, |
33 const CMsvEntrySelection& aSel, |
34 const CMsvEntrySelection& aSel, |
34 TFSMailMsgId aFSMailBoxId, |
35 TFSMailMsgId aFSMailBoxId, |
35 MFSMailRequestObserver* aFSOperationObserver, |
36 MFSMailRequestObserver& aFSOperationObserver, |
36 TInt aFSRequestId, |
37 TInt aFSRequestId, |
37 CIpsPlgEventHandler* aEventHandler, |
38 CIpsPlgEventHandler* aEventHandler, |
38 TBool aDoFilterSelection ) |
39 TBool aDoFilterSelection ) |
39 { |
40 { |
40 FUNC_LOG; |
41 FUNC_LOG; |
41 CIpsPlgImap4PopulateOp* op = new (ELeave) CIpsPlgImap4PopulateOp( |
42 CIpsPlgImap4PopulateOp* op = new (ELeave) CIpsPlgImap4PopulateOp( |
42 aMsvSession, |
43 aMsvSession, |
43 aObserverRequestStatus, |
44 aObserverRequestStatus, |
|
45 aPriority, |
44 aService, |
46 aService, |
45 aActivityTimer, |
47 aActivityTimer, |
46 aPartialMailInfo, |
48 aPartialMailInfo, |
47 aFSMailBoxId, |
49 aFSMailBoxId, |
48 aFSOperationObserver, |
50 aFSOperationObserver, |
55 return op; |
57 return op; |
56 } |
58 } |
57 |
59 |
58 // ---------------------------------------------------------------------------- |
60 // ---------------------------------------------------------------------------- |
59 // ---------------------------------------------------------------------------- |
61 // ---------------------------------------------------------------------------- |
60 // <qmail> priority parameter has been removed |
|
61 CIpsPlgImap4PopulateOp::CIpsPlgImap4PopulateOp( |
62 CIpsPlgImap4PopulateOp::CIpsPlgImap4PopulateOp( |
62 CMsvSession& aMsvSession, |
63 CMsvSession& aMsvSession, |
63 TRequestStatus& aObserverRequestStatus, |
64 TRequestStatus& aObserverRequestStatus, |
|
65 TInt aPriority, |
64 TMsvId aService, |
66 TMsvId aService, |
65 CIpsPlgTimerOperation& aActivityTimer, |
67 CIpsPlgTimerOperation& aActivityTimer, |
66 const TImImap4GetPartialMailInfo& aPartialMailInfo, |
68 const TImImap4GetPartialMailInfo& aPartialMailInfo, |
67 TFSMailMsgId aFSMailBoxId, |
69 TFSMailMsgId aFSMailBoxId, |
68 MFSMailRequestObserver* aFSOperationObserver, |
70 MFSMailRequestObserver& aFSOperationObserver, |
69 TInt aFSRequestId, |
71 TInt aFSRequestId, |
70 CIpsPlgEventHandler* aEventHandler ) |
72 CIpsPlgEventHandler* aEventHandler ) |
71 : |
73 : |
72 CIpsPlgOnlineOperation( |
74 CIpsPlgOnlineOperation( |
73 aMsvSession, |
75 aMsvSession, |
74 aObserverRequestStatus, |
76 aPriority, |
75 aActivityTimer, |
77 aObserverRequestStatus, |
76 aFSMailBoxId, |
78 aActivityTimer, |
77 aFSOperationObserver, |
79 aFSMailBoxId, |
78 aFSRequestId ), |
80 aFSOperationObserver, |
79 iState( EStateIdle ), |
81 aFSRequestId), |
80 iPartialMailInfo(aPartialMailInfo), |
82 iPartialMailInfo(aPartialMailInfo), |
81 iSelection( NULL ), |
83 iSelection( KIpsPlgSelectionGra ), |
82 iTempSelection( NULL ), |
84 iEventHandler( aEventHandler ) |
83 iEventHandler( aEventHandler ), |
|
84 iFetchErrorProgress( NULL ) |
|
85 { |
85 { |
86 FUNC_LOG; |
86 FUNC_LOG; |
87 iService = aService; |
87 iService = aService; |
88 } |
88 } |
89 |
89 |
90 // ---------------------------------------------------------------------------- |
90 // ---------------------------------------------------------------------------- |
91 // ---------------------------------------------------------------------------- |
91 // ---------------------------------------------------------------------------- |
92 CIpsPlgImap4PopulateOp::~CIpsPlgImap4PopulateOp() |
92 CIpsPlgImap4PopulateOp::~CIpsPlgImap4PopulateOp() |
93 { |
93 { |
94 FUNC_LOG; |
94 FUNC_LOG; |
95 delete iSelection; |
95 |
|
96 Cancel(); |
|
97 iSelection.Close(); |
96 |
98 |
97 if ( iTempSelection ) |
99 if ( iTempSelection ) |
98 { |
100 { |
99 iTempSelection->Reset(); |
101 iTempSelection->Reset(); |
100 delete iTempSelection; |
102 delete iTempSelection; |
101 } |
103 } |
102 } |
104 } |
103 |
105 |
104 // ---------------------------------------------------------------------------- |
106 // ---------------------------------------------------------------------------- |
105 // ---------------------------------------------------------------------------- |
107 // ---------------------------------------------------------------------------- |
108 TBool aDoFilterSelection ) |
110 TBool aDoFilterSelection ) |
109 { |
111 { |
110 FUNC_LOG; |
112 FUNC_LOG; |
111 BaseConstructL( KUidMsgTypeIMAP4 ); |
113 BaseConstructL( KUidMsgTypeIMAP4 ); |
112 |
114 |
113 // <qmail> instantiation moved here |
|
114 iSelection = new ( ELeave ) CMsvEntrySelection(); |
|
115 iTempSelection = new ( ELeave ) CMsvEntrySelection(); |
|
116 |
|
117 if ( aDoFilterSelection ) |
115 if ( aDoFilterSelection ) |
118 { |
116 { |
119 FilterSelectionL( aSel ); |
117 FilterSelectionL( aSel ); |
120 } |
118 } |
121 else // no filtering; populate all |
119 else |
122 { |
120 { |
123 // first entry in selection is serviceId |
|
124 for ( TInt i = 1; i < aSel.Count(); i++ ) |
121 for ( TInt i = 1; i < aSel.Count(); i++ ) |
125 { |
122 { |
126 if ( aSel[i] != iService ) |
123 if ( aSel[i] != iService ) |
127 { |
124 { |
128 iSelection->AppendL( aSel.At(i) ); |
125 iSelection.AppendL( aSel.At(i) ); |
129 } |
126 } |
130 } |
127 } |
131 } |
128 } |
|
129 iTempSelection = new ( ELeave ) CMsvEntrySelection(); |
132 DoConnectL(); |
130 DoConnectL(); |
133 } |
131 } |
134 |
132 |
135 // ---------------------------------------------------------------------------- |
133 // ---------------------------------------------------------------------------- |
136 // ---------------------------------------------------------------------------- |
134 // ---------------------------------------------------------------------------- |
137 // <qmail> return type changed: TInt -> TIpsOpType |
135 TInt CIpsPlgImap4PopulateOp::IpsOpType() const |
138 TIpsOpType CIpsPlgImap4PopulateOp::IpsOpType() const |
|
139 { |
136 { |
140 FUNC_LOG; |
137 FUNC_LOG; |
141 return EIpsOpTypeImap4PopulateOp; |
138 return EIpsOpTypeImap4PopulateOp; |
142 } |
139 } |
143 |
140 |
244 FUNC_LOG; |
258 FUNC_LOG; |
245 if(iFetchErrorProgress && (iState == EStateIdle)) |
259 if(iFetchErrorProgress && (iState == EStateIdle)) |
246 { |
260 { |
247 // Completed, but with an error during fetch. |
261 // Completed, but with an error during fetch. |
248 return *iFetchErrorProgress; |
262 return *iFetchErrorProgress; |
249 } |
263 } |
250 else |
264 TImap4SyncProgress progg; |
251 { |
265 progg.iFoldersNotFound = 0; |
252 TImap4SyncProgress progg; |
266 progg.iErrorCode = KErrNone; |
253 progg.iFoldersNotFound = 0; |
267 TPckgBuf<TImap4SyncProgress> param(progg); |
254 progg.iErrorCode = KErrNone; |
268 iSyncProgress.Copy(param); |
255 TPckgBuf<TImap4SyncProgress> param(progg); |
269 return iSyncProgress; |
256 iSyncProgress.Copy(param); |
|
257 return iSyncProgress; |
|
258 } |
|
259 } |
270 } |
260 |
271 |
261 // ---------------------------------------------------------------------------- |
272 // ---------------------------------------------------------------------------- |
262 // ---------------------------------------------------------------------------- |
273 // ---------------------------------------------------------------------------- |
263 const TDesC8& CIpsPlgImap4PopulateOp::GetErrorProgressL(TInt /*aError*/ ) |
274 const TDesC8& CIpsPlgImap4PopulateOp::GetErrorProgressL(TInt /*aError*/ ) |
339 |
367 |
340 if( IsPartialPopulate( ) |
368 if( IsPartialPopulate( ) |
341 && !isComplete |
369 && !isComplete |
342 && entry.iType == KUidMsvMessageEntry ) |
370 && entry.iType == KUidMsvMessageEntry ) |
343 { |
371 { |
344 iSelection->AppendL( messageId ); |
372 iSelection.AppendL(messageId); |
345 } |
373 } |
346 else if ( isMsgEntry && isSizeUnderMax && !isParentComp ) |
374 else if ( isMsgEntry && isSizeUnderMax && !isParentComp ) |
347 { |
375 { |
348 iSelection->AppendL( messageId ); |
376 iSelection.AppendL(messageId); |
349 } |
377 } |
350 } |
378 } |
351 } |
379 } |
352 |
380 |
353 // ---------------------------------------------------------------------------- |
381 // ---------------------------------------------------------------------------- |
354 // ---------------------------------------------------------------------------- |
382 // ---------------------------------------------------------------------------- |
355 TBool CIpsPlgImap4PopulateOp::IsPartialPopulate( ) |
383 TBool CIpsPlgImap4PopulateOp::IsPartialPopulate( ) |
356 { |
384 { |
357 // <qmail> cleaned up code and took one "always true" condition out from the if statement |
|
358 FUNC_LOG; |
385 FUNC_LOG; |
359 // NOTE: this code is taken from symbian os source IMPCMTM.CPP |
386 // NOTE: this code is taken from symbian os source IMPCMTM.CPP |
360 // code is modified to this class purpose |
387 // code is modified to this class purpose |
361 TBool isPartialPopulate( EFalse ); |
388 |
362 if ( iPartialMailInfo.iPartialMailOptions == ENoSizeLimits && |
389 TBool isPartialPopulate = EFalse; |
363 iPartialMailInfo.iTotalSizeLimit == KMaxTInt && |
390 if(iPartialMailInfo.iPartialMailOptions == ENoSizeLimits && |
364 iPartialMailInfo.iBodyTextSizeLimit == KMaxTInt && |
391 iPartialMailInfo.iTotalSizeLimit == KMaxTInt && |
365 iPartialMailInfo.iAttachmentSizeLimit == KMaxTInt ) |
392 iPartialMailInfo.iBodyTextSizeLimit == KMaxTInt && |
|
393 iPartialMailInfo.iAttachmentSizeLimit == KMaxTInt && |
|
394 (iPartialMailInfo.iGetMailBodyParts == EGetImap4EmailHeaders || |
|
395 iPartialMailInfo.iGetMailBodyParts == EGetImap4EmailBodyText || |
|
396 iPartialMailInfo.iGetMailBodyParts == EGetImap4EmailBodyTextAndAttachments || |
|
397 iPartialMailInfo.iGetMailBodyParts == EGetImap4EmailAttachments || |
|
398 iPartialMailInfo.iGetMailBodyParts == EGetImap4EmailBodyAlternativeText) ) |
366 { |
399 { |
367 isPartialPopulate = EFalse; |
400 isPartialPopulate = EFalse; |
368 } |
401 } |
369 else |
402 else |
370 { |
403 { |
371 isPartialPopulate = ETrue; |
404 isPartialPopulate = ETrue; |
372 } |
405 } |
|
406 |
373 return isPartialPopulate; |
407 return isPartialPopulate; |
374 } |
408 } |
375 |
409 |
376 // ---------------------------------------------------------------------------- |
410 // ---------------------------------------------------------------------------- |
377 // ---------------------------------------------------------------------------- |
411 // ---------------------------------------------------------------------------- |
378 void CIpsPlgImap4PopulateOp::DoPopulateL( ) |
412 void CIpsPlgImap4PopulateOp::DoPopulateL( ) |
379 { |
413 { |
380 FUNC_LOG; |
414 FUNC_LOG; |
381 if ( iSelection->Count() > 0 ) |
415 if ( iSelection.Count() > 0 ) |
382 { |
416 { |
383 TMsvEmailEntry tEntry; |
417 TMsvEmailEntry tEntry; |
384 TMsvId dummy; |
418 TMsvId dummy; |
385 TInt lastIndex = iSelection->Count()-1; |
419 TInt lastIndex = iSelection.Count()-1; |
386 User::LeaveIfError( iMsvSession.GetEntry( iSelection->At(lastIndex), dummy, tEntry ) ); |
420 User::LeaveIfError( iMsvSession.GetEntry( |
|
421 iSelection[lastIndex], dummy, tEntry ) ); |
387 |
422 |
388 iState = EStateFetching; |
423 iState = EStateFetching; |
389 |
424 |
390 iTempSelection->Reset(); |
425 iTempSelection->Reset(); |
391 iTempSelection->AppendL( iService ); |
426 iTempSelection->AppendL( iService ); |
392 iTempSelection->AppendL( iSelection->At( lastIndex ) ); |
427 iTempSelection->AppendL( iSelection[lastIndex] ); |
393 iSelection->Delete( lastIndex ); |
428 iSelection.Remove(lastIndex); |
394 |
429 |
|
430 |
|
431 iStatus = KRequestPending; |
|
432 |
395 // Filters are not used when performing 'fetch' |
433 // Filters are not used when performing 'fetch' |
396 // operation, use normal getmail info instead |
434 // operation, use normal getmail info instead |
397 TPckg<TImImap4GetPartialMailInfo> param( iPartialMailInfo ); |
435 TPckg<TImImap4GetPartialMailInfo> param(iPartialMailInfo); |
398 iBaseMtm->SwitchCurrentEntryL( iService ); |
436 iBaseMtm->SwitchCurrentEntryL( iService ); |
399 iSubOperation = iBaseMtm->InvokeAsyncFunctionL( |
437 iOperation = iBaseMtm->InvokeAsyncFunctionL( |
400 KIMAP4MTMPopulateMailSelectionWhenAlreadyConnected, |
438 KIMAP4MTMPopulateMailSelectionWhenAlreadyConnected, |
401 *iTempSelection, param, iStatus ); |
439 *iTempSelection, param, this->iStatus); |
402 iState = EStateInfoEntryChange; |
440 iState = EStateInfoEntryChange; |
403 SetActive(); |
441 SetActive(); |
|
442 |
|
443 if ( iEventHandler ) |
|
444 { |
|
445 iEventHandler->SetNewPropertyEvent( |
|
446 iService, KIpsSosEmailSyncStarted, KErrNone ); |
|
447 } |
404 } |
448 } |
405 else |
449 else |
406 { |
450 { |
407 iState = EStateIdle; |
451 iState = EStateIdle; |
408 CompleteObserver(); |
452 CompleteObserver(); |
|
453 |
|
454 if ( iEventHandler ) |
|
455 { |
|
456 iEventHandler->SetNewPropertyEvent( |
|
457 iService, KIpsSosEmailSyncCompleted, KErrNone ); |
|
458 } |
409 } |
459 } |
410 } |
460 } |
411 |
461 |
412 // End of File |
462 // End of File |