13 * |
13 * |
14 * Description: POP3 fetch message operation class |
14 * Description: POP3 fetch message operation class |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 |
18 #include "emailtrace.h" |
19 #include "emailtrace.h" |
19 #include "ipsplgheaders.h" |
20 #include "ipsplgheaders.h" |
20 |
21 |
21 // <qmail> priority const has been removed |
22 // Constants and defines |
22 // ---------------------------------------------------------------------------- |
23 const TInt KFetchOpPriority = CActive::EPriorityStandard; |
23 // ---------------------------------------------------------------------------- |
24 |
24 // <qmail> MFSMailRequestObserver& changed to pointer |
25 // ---------------------------------------------------------------------------- |
|
26 // ---------------------------------------------------------------------------- |
25 CIpsPlgPop3FetchOperation* CIpsPlgPop3FetchOperation::NewL( |
27 CIpsPlgPop3FetchOperation* CIpsPlgPop3FetchOperation::NewL( |
26 CMsvSession& aMsvSession, |
28 CMsvSession& aMsvSession, |
27 TRequestStatus& aObserverRequestStatus, |
29 TRequestStatus& aObserverRequestStatus, |
|
30 TInt aFunctionId, |
28 TMsvId aService, |
31 TMsvId aService, |
29 CIpsPlgTimerOperation& aActivityTimer, |
32 CIpsPlgTimerOperation& aActivityTimer, |
30 const TImPop3GetMailInfo& aGetMailInfo, |
33 const TImPop3GetMailInfo& aGetMailInfo, |
31 CMsvEntrySelection* aSelection, |
34 const CMsvEntrySelection& aSel, |
32 TFSMailMsgId aFSMailBoxId, |
35 TFSMailMsgId aFSMailBoxId, |
33 MFSMailRequestObserver* aFSOperationObserver, |
36 MFSMailRequestObserver& aFSOperationObserver, |
34 TInt aFSRequestId, |
37 TInt aFSRequestId, |
35 CIpsPlgEventHandler* aEventHandler ) |
38 CIpsPlgEventHandler* aEventHandler ) |
36 { |
39 { |
37 FUNC_LOG; |
40 FUNC_LOG; |
38 CIpsPlgPop3FetchOperation* op = new(ELeave) CIpsPlgPop3FetchOperation( |
41 CIpsPlgPop3FetchOperation* op = new(ELeave) CIpsPlgPop3FetchOperation( |
39 aMsvSession, |
42 aMsvSession, aObserverRequestStatus, aFunctionId, aService, |
40 aObserverRequestStatus, |
43 aActivityTimer, aGetMailInfo, aFSMailBoxId, aFSOperationObserver, |
41 aService, |
44 aFSRequestId, aEventHandler ); |
42 aActivityTimer, |
|
43 aGetMailInfo, |
|
44 aSelection, |
|
45 aFSMailBoxId, |
|
46 aFSOperationObserver, |
|
47 aFSRequestId, |
|
48 aEventHandler ); |
|
49 |
45 |
50 CleanupStack::PushL(op); |
46 CleanupStack::PushL(op); |
51 op->ConstructL(); |
47 op->ConstructL(aSel); |
52 CleanupStack::Pop( op ); |
48 CleanupStack::Pop( op ); |
53 return op; |
49 return op; |
54 } |
50 } |
55 |
51 |
56 // ---------------------------------------------------------------------------- |
52 // ---------------------------------------------------------------------------- |
89 } |
85 } |
90 |
86 |
91 // ---------------------------------------------------------------------------- |
87 // ---------------------------------------------------------------------------- |
92 // ConstructL |
88 // ConstructL |
93 // ---------------------------------------------------------------------------- |
89 // ---------------------------------------------------------------------------- |
94 void CIpsPlgPop3FetchOperation::ConstructL() |
90 void CIpsPlgPop3FetchOperation::ConstructL(const CMsvEntrySelection& aSel) |
95 { |
91 { |
96 FUNC_LOG; |
92 FUNC_LOG; |
97 |
93 |
98 BaseConstructL( KUidMsgTypePOP3 ); |
94 BaseConstructL( KUidMsgTypePOP3 ); |
99 // <qmail> 1st entry must be serviceId |
95 |
|
96 iSelection = aSel.CopyL(); |
|
97 |
100 iSelection->InsertL( 0, iService ); |
98 iSelection->InsertL( 0, iService ); |
101 // For Get Mail API, first selection element must be service. |
99 // For Get Mail API, first selection element must be service. |
102 |
100 |
103 // It is possible that the complete flag is on and we want to |
101 // It is possible that the complete flag is on and we want to |
104 // download the attachment. In these cases we need to clear the |
102 // download the attachment. In these cases we need to clear the |
105 // complete flag. |
103 // complete flag. |
106 |
104 |
107 TInt count = iSelection->Count(); |
105 TInt count = iSelection->Count(); |
108 |
106 |
109 for ( ; iEntryIndex < count && !iSubOperation; iEntryIndex++ ) |
107 for ( ; iEntryIndex < count && !iOperation; iEntryIndex++ ) |
110 { |
108 { |
111 delete iEntry; |
109 delete iEntry; |
112 iEntry = NULL; |
110 iEntry = NULL; |
113 |
111 |
114 iEntry = iMsvSession.GetEntryL( iSelection->At( iEntryIndex ) ); |
112 iEntry = iMsvSession.GetEntryL( iSelection->At( iEntryIndex ) ); |
143 FUNC_LOG; |
141 FUNC_LOG; |
144 |
142 |
145 |
143 |
146 iState = EStateConnecting; |
144 iState = EStateConnecting; |
147 iStatus = KRequestPending; |
145 iStatus = KRequestPending; |
148 // <qmail> |
146 |
|
147 // when connecting for the fetch operation, don't let connect operation to do fetch, |
|
148 // because we do it by ourself. That's why give 0 to connect operation. |
149 CIpsPlgPop3ConnectOp* connOp = CIpsPlgPop3ConnectOp::NewL( |
149 CIpsPlgPop3ConnectOp* connOp = CIpsPlgPop3ConnectOp::NewL( |
150 iMsvSession, |
150 iMsvSession, iStatus, iService, EFalse, *iActivityTimer, |
151 iStatus, |
151 iFSMailboxId, iFSOperationObserver, iFSRequestId, NULL,EFalse ); |
152 iService, |
|
153 EFalse, // We do fetch by ourselves |
|
154 *iActivityTimer, |
|
155 iFSMailboxId, |
|
156 iFSOperationObserver, |
|
157 iFSRequestId, |
|
158 NULL, |
|
159 EFalse, // Signalling not allowed |
|
160 ETrue ); // Fetch will follow, let connection be open |
|
161 |
152 |
162 // </qmail> |
153 delete iOperation; |
163 delete iSubOperation; |
154 iOperation = connOp; |
164 iSubOperation = connOp; |
|
165 |
155 |
166 SetActive(); |
156 SetActive(); |
167 } |
157 } |
168 |
158 |
169 // ---------------------------------------------------------------------------- |
159 // ---------------------------------------------------------------------------- |
173 { |
163 { |
174 FUNC_LOG; |
164 FUNC_LOG; |
175 |
165 |
176 iState = EStateFetching; |
166 iState = EStateFetching; |
177 |
167 |
178 // <qmail> deletion of possible previous iSubOperaiton is handled in InvokeClientMtmAsyncFunctionL |
168 // Switch operations. |
179 // <qmail> delete iSubOperation; |
169 delete iOperation; |
180 // <qmail> iSubOperation = NULL; |
170 iOperation = NULL; |
181 iStatus = KRequestPending; |
171 iStatus = KRequestPending; |
182 |
172 |
183 // Filters are not used when performing 'fetch' operation, use normal |
173 // Filters are not used when performing 'fetch' operation, use normal |
184 // getmail info instead |
174 // getmail info instead |
185 TPckg<TImPop3GetMailInfo> param( iGetMailInfo ); |
175 TPckg<TImPop3GetMailInfo> param( iGetMailInfo ); |
186 // <qmail> using constant functionId as its always the same |
176 InvokeClientMtmAsyncFunctionL( iFunctionId, *iSelection, iService, param ); |
187 InvokeClientMtmAsyncFunctionL( KPOP3MTMCopyMailSelectionWhenAlreadyConnected, *iSelection, param ); |
|
188 SetActive(); |
177 SetActive(); |
189 |
178 |
190 if ( iEventHandler ) |
179 if ( iEventHandler ) |
191 { |
180 { |
192 iEventHandler->SetNewPropertyEvent( |
181 iEventHandler->SetNewPropertyEvent( |
193 iService, KIpsSosEmailSyncStarted, KErrNone ); |
182 iService, KIpsSosEmailSyncStarted, KErrNone ); |
194 } |
183 } |
195 |
184 |
196 } |
185 } |
197 |
186 |
198 // ---------------------------------------------------------------------------- |
187 |
199 // ---------------------------------------------------------------------------- |
188 |
200 // <qmail> priority parameter has been removed |
189 // ---------------------------------------------------------------------------- |
201 // <qmail> MFSMailRequestObserver& changed to pointer |
190 // ---------------------------------------------------------------------------- |
202 // <qmail> aFunctionId parameter has been removed |
|
203 // <qmail> aSelection parameter has been added |
|
204 CIpsPlgPop3FetchOperation::CIpsPlgPop3FetchOperation( |
191 CIpsPlgPop3FetchOperation::CIpsPlgPop3FetchOperation( |
205 CMsvSession& aMsvSession, |
192 CMsvSession& aMsvSession, |
206 TRequestStatus& aObserverRequestStatus, |
193 TRequestStatus& aObserverRequestStatus, |
|
194 TInt aFunctionId, |
207 TMsvId aService, |
195 TMsvId aService, |
208 CIpsPlgTimerOperation& aActivityTimer, |
196 CIpsPlgTimerOperation& aActivityTimer, |
209 const TImPop3GetMailInfo& aGetMailInfo, |
197 const TImPop3GetMailInfo& aGetMailInfo, |
210 CMsvEntrySelection* aSelection, |
|
211 TFSMailMsgId aFSMailBoxId, |
198 TFSMailMsgId aFSMailBoxId, |
212 MFSMailRequestObserver* aFSOperationObserver, |
199 MFSMailRequestObserver& aFSOperationObserver, |
213 TInt aFSRequestId, |
200 TInt aFSRequestId, |
214 CIpsPlgEventHandler* aEventHandler ) |
201 CIpsPlgEventHandler* aEventHandler ) |
215 : |
202 : |
216 CIpsPlgOnlineOperation( |
203 CIpsPlgOnlineOperation( aMsvSession, KFetchOpPriority, |
217 aMsvSession, |
204 aObserverRequestStatus, aActivityTimer, aFSMailBoxId, |
218 aObserverRequestStatus, |
205 aFSOperationObserver, aFSRequestId), iFunctionId( aFunctionId ), |
219 aActivityTimer, |
206 iGetMailInfo( aGetMailInfo ), iEventHandler( aEventHandler ) |
220 aFSMailBoxId, |
|
221 aFSOperationObserver, |
|
222 aFSRequestId ), |
|
223 iGetMailInfo( aGetMailInfo ), |
|
224 iSelection( aSelection ), |
|
225 iEventHandler( aEventHandler ) |
|
226 { |
207 { |
227 FUNC_LOG; |
208 FUNC_LOG; |
228 iService = aService; |
209 iService = aService; |
229 } |
210 } |
230 |
211 |
250 FUNC_LOG; |
231 FUNC_LOG; |
251 |
232 |
252 CIpsPlgOnlineOperation::DoCancel(); |
233 CIpsPlgOnlineOperation::DoCancel(); |
253 if(iState == EStateFetching) |
234 if(iState == EStateFetching) |
254 { |
235 { |
255 // Stops any operations that a Server-side MTM for the specified service is running, |
236 // Cancelled while fetching. Need to disconnect. |
256 // and then unloads the Server-side MTM. |
|
257 // The current operation and any queued operations are cancelled. |
|
258 iMsvSession.StopService( iService ); |
237 iMsvSession.StopService( iService ); |
|
238 // Ignore return value, nothing we can do. |
259 } |
239 } |
260 if ( iEventHandler ) |
240 if ( iEventHandler ) |
261 { |
241 { |
262 // <qmail> |
242 iEventHandler->SetNewPropertyEvent( |
263 iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncCompleted, KErrCancel ); |
243 iService, KIpsSosEmailSyncCompleted, KErrCancel ); |
264 // </qmail> |
|
265 } |
244 } |
266 } |
245 } |
267 |
246 |
268 // ---------------------------------------------------------------------------- |
247 // ---------------------------------------------------------------------------- |
269 // DoRunL |
248 // DoRunL |
275 switch(iState) |
254 switch(iState) |
276 { |
255 { |
277 case EStateClearCompleteFlag: |
256 case EStateClearCompleteFlag: |
278 { |
257 { |
279 // First clean things |
258 // First clean things |
280 delete iSubOperation; |
259 delete iOperation; |
281 iSubOperation = NULL; |
260 iOperation = NULL; |
282 |
261 |
283 delete iEntry; |
262 delete iEntry; |
284 iEntry = NULL; |
263 iEntry = NULL; |
285 |
264 |
286 // Leave if setting the complete flag was a failure. |
265 // Leave if setting the complete flag was a failure. |
287 User::LeaveIfError( iStatus.Int() ); |
266 User::LeaveIfError( iStatus.Int() ); |
288 |
267 |
289 TInt count = iSelection->Count(); |
268 TInt count = iSelection->Count(); |
290 |
269 |
291 for ( ; iEntryIndex < count && !iSubOperation; iEntryIndex++ ) |
270 for ( ; iEntryIndex < count && !iOperation; iEntryIndex++ ) |
292 { |
271 { |
293 delete iEntry; |
272 delete iEntry; |
294 iEntry = NULL; |
273 iEntry = NULL; |
295 |
274 |
296 iEntry = iMsvSession.GetEntryL( |
275 iEntry = iMsvSession.GetEntryL( |
302 |
281 |
303 if ( complete ) |
282 if ( complete ) |
304 { |
283 { |
305 entry.SetComplete( EFalse ); |
284 entry.SetComplete( EFalse ); |
306 |
285 |
307 iSubOperation = iEntry->ChangeL( entry, iStatus ); |
286 iOperation = iEntry->ChangeL( entry, iStatus ); |
308 |
287 |
309 SetActive(); |
288 SetActive(); |
310 } |
289 } |
311 } |
290 } |
312 |
291 |
313 if ( !iSubOperation ) |
292 if ( !iOperation ) |
314 { |
293 { |
315 DoConnectL(); |
294 DoConnectL(); |
316 } |
295 } |
317 |
296 |
318 break; |
297 break; |
319 } |
298 } |
320 case EStateConnecting: |
299 case EStateConnecting: |
321 { |
300 { |
322 // Connect complete. |
301 // Connect complete. |
323 // <qmail> Connected() usage |
302 TBool connected = |
324 if ( !Connected() ) |
303 STATIC_CAST( CIpsPlgPop3ConnectOp*, iOperation )->Connected(); |
|
304 if(!connected) |
325 { |
305 { |
326 CompleteObserver( KErrCouldNotConnect ); |
306 CompleteObserver( KErrCouldNotConnect ); |
327 return; |
307 return; |
328 } |
308 } |
329 DoFetchL(); |
309 DoFetchL(); |
330 } |
310 } |
331 break; |
311 break; |
332 case EStateFetching: |
312 case EStateFetching: |
333 { |
313 { |
334 TInt err = iStatus.Int(); |
314 TInt err = iStatus.Int(); |
335 // <qmail> |
315 |
336 if( err ) |
316 if( KErrNone != err ) |
337 // </qmail> |
|
338 { |
317 { |
339 TPckgBuf<TPop3Progress> paramPack; |
318 TPckgBuf<TPop3Progress> paramPack; |
340 if ( iSubOperation ) |
319 if ( iOperation ) |
341 { |
320 { |
342 paramPack.Copy( iSubOperation->ProgressL() ); |
321 paramPack.Copy( iOperation->ProgressL() ); |
343 } |
322 } |
344 TPop3Progress& progress = paramPack(); |
323 TPop3Progress& progress = paramPack(); |
345 progress.iErrorCode = err; |
324 progress.iErrorCode = err; |
346 iFetchErrorProgress = paramPack.AllocL(); |
325 iFetchErrorProgress = paramPack.AllocL(); |
347 } |
326 } |
348 DoDisconnectL(); |
327 |
349 |
328 iState = EStateIdle; |
|
329 CompleteObserver( err ); |
350 if ( iEventHandler ) |
330 if ( iEventHandler ) |
351 { |
331 { |
352 // <qmail> |
332 iEventHandler->SetNewPropertyEvent( |
353 iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncCompleted, err ); |
333 iService, KIpsSosEmailSyncCompleted, err ); |
354 // </qmail> |
334 } |
355 } |
|
356 } |
|
357 break; |
|
358 case EStateDisconnecting: |
|
359 { |
|
360 CompleteObserver( iStatus.Int() ); |
|
361 } |
335 } |
362 break; |
336 break; |
363 |
337 |
364 default: |
338 default: |
365 break; |
339 break; |
380 TFSProgress CIpsPlgPop3FetchOperation::GetFSProgressL() const |
354 TFSProgress CIpsPlgPop3FetchOperation::GetFSProgressL() const |
381 { |
355 { |
382 FUNC_LOG; |
356 FUNC_LOG; |
383 // might not never called, but gives something reasonable if called |
357 // might not never called, but gives something reasonable if called |
384 TFSProgress result = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone }; |
358 TFSProgress result = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone }; |
385 // <qmail> removed result.iError = KErrNone; |
359 result.iError = KErrNone; |
386 switch( iState ) |
360 switch( iState ) |
387 { |
361 { |
388 case EStateConnecting: |
362 case EStateConnecting: |
389 result.iProgressStatus = TFSProgress::EFSStatus_Connecting; |
363 result.iProgressStatus = TFSProgress::EFSStatus_Connecting; |
390 break; |
364 break; |
402 } |
376 } |
403 |
377 |
404 return result; |
378 return result; |
405 } |
379 } |
406 |
380 |
407 // <qmail> new func to this op |
381 // ---------------------------------------------------------------------------- |
408 // ---------------------------------------------------------------------------- |
382 // CIpsPlgPop3FetchOperation::IpsOpType() |
409 // ---------------------------------------------------------------------------- |
383 // ---------------------------------------------------------------------------- |
410 TIpsOpType CIpsPlgPop3FetchOperation::IpsOpType() const |
384 // |
411 { |
385 TInt CIpsPlgPop3FetchOperation::IpsOpType() const |
412 FUNC_LOG; |
386 { |
413 return EIpsOpTypePop3FetchOp; |
387 FUNC_LOG; |
414 } |
388 return EIpsOpTypePop3PopulateOp; |
415 // </qmail> |
389 } |
416 |
390 // EOF |
417 //<qmail> new function |
391 |
418 // ---------------------------------------------------------------------------- |
|
419 // ---------------------------------------------------------------------------- |
|
420 void CIpsPlgPop3FetchOperation::DoDisconnectL() |
|
421 { |
|
422 FUNC_LOG; |
|
423 iState = EStateDisconnecting; |
|
424 InvokeClientMtmAsyncFunctionL( KPOP3MTMDisconnect, iService ); // <qmail> 1 param removed |
|
425 SetActive(); |
|
426 } |
|
427 // </qmail> |
|
428 |
|
429 |
|