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