13 * |
13 * |
14 * Description: POP3 connect operation |
14 * Description: POP3 connect operation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
|
19 #include "emailtrace.h" |
18 #include "emailtrace.h" |
20 #include "ipsplgheaders.h" |
19 #include "ipsplgheaders.h" |
21 |
20 |
|
21 |
22 // Constants and defines |
22 // Constants and defines |
23 const TInt KConnectOpPriority = CActive::EPriorityStandard; |
23 // <qmail> rename const |
24 const TInt KIpsPlgPop3PopulateLimitInitValue = 50; |
24 const TInt KDefaultPopulateLimit( 50 ); |
25 |
25 const TInt KPopulateAlgorithmBytesInKilo( 1024 ); |
26 _LIT( KIpsPlgPopConnectPanic, "PopConnectOp" ); |
26 const TInt KPopulateAlgorithmRowLength( 75 ); |
|
27 |
27 |
28 |
28 // ---------------------------------------------------------------------------- |
29 // ---------------------------------------------------------------------------- |
29 // CIpsPlgPop3ConnectOp::NewL() |
30 // CIpsPlgPop3ConnectOp::NewL() |
30 // ---------------------------------------------------------------------------- |
31 // ---------------------------------------------------------------------------- |
31 // |
32 // <qmail> MFSMailRequestObserver& changed to pointer |
|
33 // <qmail> aSignallingAllowed parameter added |
|
34 // <qmail> aFetchWillFollow parameter added |
32 CIpsPlgPop3ConnectOp* CIpsPlgPop3ConnectOp::NewL( |
35 CIpsPlgPop3ConnectOp* CIpsPlgPop3ConnectOp::NewL( |
33 CMsvSession& aMsvSession, |
36 CMsvSession& aMsvSession, |
34 TRequestStatus& aObserverRequestStatus, |
37 TRequestStatus& aObserverRequestStatus, |
35 TMsvId aService, |
38 TMsvId aService, |
36 TBool aForcePopulate, |
39 TBool aForcePopulate, |
37 CIpsPlgTimerOperation& aActivityTimer, |
40 CIpsPlgTimerOperation& aActivityTimer, |
38 TFSMailMsgId aFSMailBoxId, |
41 TFSMailMsgId aFSMailBoxId, |
39 MFSMailRequestObserver& aFSOperationObserver, |
42 MFSMailRequestObserver* aFSOperationObserver, |
40 TInt aFSRequestId, |
43 TInt aFSRequestId, |
41 CIpsPlgEventHandler* aEventHandler, |
44 CIpsPlgEventHandler* aEventHandler, |
42 TBool aSignallingAllowed ) |
45 TBool aSignallingAllowed, |
43 { |
46 TBool aFetchWillFollow ) |
44 FUNC_LOG; |
47 { |
45 CIpsPlgPop3ConnectOp* op = |
48 FUNC_LOG; |
46 new(ELeave) CIpsPlgPop3ConnectOp( aMsvSession, aObserverRequestStatus, |
49 CIpsPlgPop3ConnectOp* op = new(ELeave) CIpsPlgPop3ConnectOp( |
47 aService, aForcePopulate, aActivityTimer, aFSMailBoxId, |
50 aMsvSession, |
48 aFSOperationObserver, aFSRequestId, |
51 aObserverRequestStatus, |
49 aEventHandler, aSignallingAllowed ); |
52 aService, |
50 |
53 aForcePopulate, |
|
54 aActivityTimer, |
|
55 aFSMailBoxId, |
|
56 aFSOperationObserver, |
|
57 aFSRequestId, |
|
58 aEventHandler, |
|
59 aSignallingAllowed, |
|
60 aFetchWillFollow ); |
|
61 |
51 CleanupStack::PushL( op ); |
62 CleanupStack::PushL( op ); |
52 op->ConstructL(); |
63 op->ConstructL(); |
53 CleanupStack::Pop( op ); |
64 CleanupStack::Pop( op ); |
54 return op; |
65 return op; |
55 } |
66 } |
105 // ---------------------------------------------------------------------------- |
115 // ---------------------------------------------------------------------------- |
106 // |
116 // |
107 void CIpsPlgPop3ConnectOp::DoRunL() |
117 void CIpsPlgPop3ConnectOp::DoRunL() |
108 { |
118 { |
109 FUNC_LOG; |
119 FUNC_LOG; |
110 // handle these error situations properly, |
120 TInt err( KErrNone ); |
111 // and report somehow back to framework |
121 |
112 TInt err = KErrNone; |
122 // <qmail> remove EQueryingDetails state |
113 |
123 if ( iState == EStartConnect ) |
114 if ( iState == EQueryingDetails ) |
124 { |
115 { |
125 if ( iSubOperation ) |
116 // Retry connect. |
|
117 DoConnectL(); |
|
118 iState = EConnected; |
|
119 } |
|
120 else if ( iState == EStartConnect ) |
|
121 { |
|
122 |
|
123 if ( iOperation ) |
|
124 { |
126 { |
125 // operation exist and it means |
127 // operation exist and it means |
126 // disconnect operation was ongoing. |
128 // disconnect operation was ongoing. |
127 // How handle errors |
129 delete iSubOperation; |
128 delete iOperation; |
130 iSubOperation = NULL; |
129 iOperation = NULL; |
|
130 } |
131 } |
131 |
132 |
132 if ( ValidateL() ) |
133 // <qmail> ValidateL removed |
|
134 // Begin Connect. |
|
135 DoConnectL(); |
|
136 iState = EConnected; |
|
137 } |
|
138 else if ( iState == EConnected ) |
|
139 { |
|
140 // Connect completed |
|
141 // <qmail> Login details checking removed |
|
142 err = GetOperationErrorCodeL( ); |
|
143 User::LeaveIfError( err ); |
|
144 |
|
145 if ( iForcePopulate && Connected() ) |
133 { |
146 { |
134 // Begin Connect. |
147 iState = EPopulate; |
135 DoConnectL(); |
148 DoPopulateL(); |
136 iState = EConnected; |
|
137 } |
149 } |
|
150 // <qmail> |
|
151 else if( iFetchWillFollow && Connected() ) |
|
152 { |
|
153 // Leave connection open to make fetch |
|
154 // operation possible |
|
155 iState = EIdle; |
|
156 CompleteObserver( KErrNone ); |
|
157 } |
|
158 // </qmail> |
138 else |
159 else |
139 { |
160 { |
140 User::Leave( KErrCancel ); // User cancelled. |
161 // <qmail> |
141 } |
162 // start disconnecting |
142 } |
163 iState = EDisconnecting; |
143 else if ( iState == EConnected ) |
164 DoDisconnectL(); |
144 { |
165 // </qmail> |
145 // Connect completed. |
|
146 err = GetOperationErrorCodeL( ); |
|
147 |
|
148 if ( ( err == KPop3InvalidUser ) || |
|
149 ( err == KPop3InvalidLogin ) || |
|
150 ( err == KPop3InvalidApopLogin ) ) |
|
151 { |
|
152 // Login details are wrong. Trying to ask for password |
|
153 if ( !QueryUserPassL() ) |
|
154 { |
|
155 CompleteObserver( err ); |
|
156 } |
|
157 } |
|
158 else if ( err == KErrNone ) |
|
159 { |
|
160 if ( iForcePopulate && Connected() ) |
|
161 { |
|
162 iState = EPopulate; |
|
163 DoPopulateL(); |
|
164 } |
|
165 else |
|
166 { |
|
167 iState = EIdle; |
|
168 CompleteObserver( KErrNone ); |
|
169 } |
|
170 } |
|
171 else |
|
172 { |
|
173 // We can't do this before, because |
|
174 // we want to handle KPop3InvalidUser, |
|
175 // KPop3InvalidLogin and KPop3InvalidApopLogin separately. |
|
176 User::Leave( err ); |
|
177 } |
166 } |
178 } |
167 } |
179 else if ( iState == EPopulate ) |
168 else if ( iState == EPopulate ) |
180 { |
169 { |
181 err = GetOperationErrorCodeL( ); |
170 err = GetOperationErrorCodeL( ); |
182 if ( iEventHandler ) |
171 if ( iEventHandler ) |
183 { |
172 { |
184 iEventHandler->SetNewPropertyEvent( |
173 iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncCompleted, err ); |
185 iService, KIpsSosEmailSyncCompleted, err ); |
|
186 } |
174 } |
187 CIpsPlgSyncStateHandler::SaveSuccessfulSyncTimeL( |
175 CIpsPlgSyncStateHandler::SaveSuccessfulSyncTimeL( iMsvSession, iService ); |
188 iMsvSession, iService ); |
176 |
189 CompleteObserver( err ); |
177 // <qmail> |
190 } |
178 // start disconnecting |
|
179 iState = EDisconnecting; |
|
180 DoDisconnectL(); |
|
181 // </qmail> |
|
182 } |
|
183 // <qmail> |
|
184 else if ( iState == EDisconnecting ) |
|
185 { |
|
186 // we're done here |
|
187 CompleteObserver( KErrNone ); |
|
188 } |
|
189 // </qmail> |
|
190 // <qmail> removed state EErrInvalidDetails |
191 else |
191 else |
192 { |
192 { |
193 User::Panic( KIpsPlgPopConnectPanic ,KErrNotFound); |
193 User::Panic( KIpsPlgPopConnectPanic ,KErrNotFound); |
194 } |
194 } |
195 |
|
196 } |
195 } |
197 |
196 |
198 // ---------------------------------------------------------------------------- |
197 // ---------------------------------------------------------------------------- |
199 // CIpsPlgPop3ConnectOp::GetErrorProgressL |
198 // CIpsPlgPop3ConnectOp::GetErrorProgressL |
200 // ---------------------------------------------------------------------------- |
199 // ---------------------------------------------------------------------------- |
201 // |
200 // |
202 const TDesC8& CIpsPlgPop3ConnectOp::GetErrorProgressL( TInt aError ) |
201 const TDesC8& CIpsPlgPop3ConnectOp::GetErrorProgressL( TInt aError ) |
203 { |
202 { |
204 FUNC_LOG; |
203 FUNC_LOG; |
205 iError = aError; |
204 iError = aError; |
206 if ( iOperation && iError == KErrNone ) |
205 if ( iSubOperation && iError == KErrNone ) |
207 { |
206 { |
208 return iOperation->ProgressL(); |
207 return iSubOperation->ProgressL(); |
209 } |
208 } |
210 TPop3Progress& progress = iProgress(); |
209 TPop3Progress& progress = iProgress(); |
211 progress.iPop3Progress = TPop3Progress::EPopConnecting; |
210 progress.iPop3Progress = TPop3Progress::EPopConnecting; |
212 progress.iTotalMsgs = 0; |
211 progress.iTotalMsgs = 0; |
213 progress.iMsgsToProcess = 0; |
212 progress.iMsgsToProcess = 0; |
258 |
252 |
259 // ---------------------------------------------------------------------------- |
253 // ---------------------------------------------------------------------------- |
260 // CIpsPlgPop3ConnectOp::CIpsPlgPop3ConnectOp |
254 // CIpsPlgPop3ConnectOp::CIpsPlgPop3ConnectOp |
261 // ---------------------------------------------------------------------------- |
255 // ---------------------------------------------------------------------------- |
262 // |
256 // |
|
257 // <qmail> priority parameter has been removed |
|
258 // <qmail> MFSMailRequestObserver& changed to pointer |
|
259 // <qmail> aSignallingAllowed parameter added |
|
260 // <qmail> aFetchWillFollow parameter added |
|
261 // <qmail> iAlreadyConnected removed |
263 CIpsPlgPop3ConnectOp::CIpsPlgPop3ConnectOp( |
262 CIpsPlgPop3ConnectOp::CIpsPlgPop3ConnectOp( |
264 CMsvSession& aMsvSession, |
263 CMsvSession& aMsvSession, |
265 TRequestStatus& aObserverRequestStatus, |
264 TRequestStatus& aObserverRequestStatus, |
266 TMsvId aServiceId, |
265 TMsvId aServiceId, |
267 TBool aForcePopulate, |
266 TBool aForcePopulate, |
268 CIpsPlgTimerOperation& aActivityTimer, |
267 CIpsPlgTimerOperation& aActivityTimer, |
269 TFSMailMsgId aFSMailBoxId, |
268 TFSMailMsgId aFSMailBoxId, |
270 MFSMailRequestObserver& aFSOperationObserver, |
269 MFSMailRequestObserver* aFSOperationObserver, |
271 TInt aFSRequestId, |
270 TInt aFSRequestId, |
272 CIpsPlgEventHandler* aEventHandler, |
271 CIpsPlgEventHandler* aEventHandler, |
273 TBool aSignallingAllowed ) |
272 TBool aSignallingAllowed, |
|
273 TBool aFetchWillFollow ) |
274 : |
274 : |
275 CIpsPlgOnlineOperation( aMsvSession, KConnectOpPriority, |
275 CIpsPlgOnlineOperation( |
276 aObserverRequestStatus, aActivityTimer, aFSMailBoxId, |
276 aMsvSession, |
277 aFSOperationObserver, aFSRequestId, aSignallingAllowed ), |
277 aObserverRequestStatus, |
|
278 aActivityTimer, |
|
279 aFSMailBoxId, |
|
280 aFSOperationObserver, |
|
281 aFSRequestId, |
|
282 aSignallingAllowed ), |
278 iState( EIdle ), |
283 iState( EIdle ), |
279 iEntry( NULL ), |
|
280 iPopulateLimit( KIpsPlgPop3PopulateLimitInitValue ), |
|
281 iForcePopulate( aForcePopulate ), |
284 iForcePopulate( aForcePopulate ), |
282 iSelection( NULL ), |
|
283 iEventHandler( aEventHandler ), |
285 iEventHandler( aEventHandler ), |
284 iAlreadyConnected( EFalse ) |
286 iFetchWillFollow( aFetchWillFollow ) |
285 { |
287 { |
286 iService = aServiceId; |
288 iService = aServiceId; |
287 } |
289 } |
288 |
290 |
289 // ---------------------------------------------------------------------------- |
291 // ---------------------------------------------------------------------------- |
292 // |
294 // |
293 void CIpsPlgPop3ConnectOp::ConstructL() |
295 void CIpsPlgPop3ConnectOp::ConstructL() |
294 { |
296 { |
295 FUNC_LOG; |
297 FUNC_LOG; |
296 BaseConstructL( KUidMsgTypePOP3 ); |
298 BaseConstructL( KUidMsgTypePOP3 ); |
297 |
299 |
298 iEntry = iMsvSession.GetEntryL( iService ); |
300 // <qmail> iSelection construction has been removed |
299 if ( !iEntry ) |
301 |
300 { |
302 CMsvEntry* cEntry = iMsvSession.GetEntryL( iService ); |
301 User::Leave( KErrGeneral ); |
303 User::LeaveIfNull( cEntry ); |
302 } |
304 // NOTE: Not using cleanupStack as it is not needed in this situation: |
303 iSelection = new(ELeave) CMsvEntrySelection; |
305 const TMsvEntry tentry = cEntry->Entry(); |
304 const TMsvEntry& tentry = iEntry->Entry(); |
306 delete cEntry; |
305 |
307 cEntry = NULL; |
|
308 |
306 if ( tentry.iType.iUid != KUidMsvServiceEntryValue ) |
309 if ( tentry.iType.iUid != KUidMsvServiceEntryValue ) |
307 { |
310 { |
308 // should we panic with own codes? |
311 // should we panic with own codes? |
309 User::Leave( KErrNotSupported ); |
312 User::Leave( KErrNotSupported ); |
310 } |
313 } |
|
314 |
|
315 // <qmail> no need to have population limit as member variable |
|
316 // <qmail> it is read from settings when needed |
311 |
317 |
312 // get correct populate and sync limet values from settings |
318 if ( tentry.Connected() ) |
|
319 { |
|
320 iState = EConnected; |
|
321 // <qmail> iAlreadyConnected removed |
|
322 } |
|
323 else |
|
324 { |
|
325 iState = EStartConnect; |
|
326 } |
|
327 // <qmail> SetActive(); moved inside CompleteThis(); |
|
328 CompleteThis(); |
|
329 } |
|
330 |
|
331 // ---------------------------------------------------------------------------- |
|
332 // CIpsPlgPop3ConnectOp::DoConnectL() |
|
333 // ---------------------------------------------------------------------------- |
|
334 // |
|
335 void CIpsPlgPop3ConnectOp::DoConnectL() |
|
336 { |
|
337 FUNC_LOG; |
|
338 // <qmail> unnecessary: iStatus = KRequestPending; |
|
339 NM_COMMENT("CIpsPlgPop3ConnectOp: connecting"); |
|
340 InvokeClientMtmAsyncFunctionL( KPOP3MTMConnect, iService ); // <qmail> 1 param removed |
|
341 SetActive(); |
|
342 |
|
343 // <qmail> |
|
344 if ( iEventHandler ) |
|
345 { |
|
346 iEventHandler->SetNewPropertyEvent( iService, KIpsSosEmailSyncStarted, KErrNone ); |
|
347 } |
|
348 // </qmail> |
|
349 } |
|
350 |
|
351 // ---------------------------------------------------------------------------- |
|
352 // CIpsPlgPop3ConnectOp::DoPopulateL() |
|
353 // ---------------------------------------------------------------------------- |
|
354 // |
|
355 void CIpsPlgPop3ConnectOp::DoPopulateL() |
|
356 { |
|
357 FUNC_LOG; |
|
358 NM_COMMENT("CIpsPlgPop3ConnectOp: populating"); |
|
359 // <qmail> unnecessary: iStatus = KRequestPending; |
|
360 |
|
361 // Prepare parameters and include filtering |
|
362 TImPop3PopulateOptions pop3GetMailInfo; |
|
363 pop3GetMailInfo.SetMaxEmailSize( KMaxTInt32 ); |
|
364 // <qmail> |
|
365 pop3GetMailInfo.SetPopulationLimit( GetPopulateLimitFromSettingsL() ); |
|
366 TPckgBuf<TImPop3PopulateOptions> params( pop3GetMailInfo ); |
|
367 |
|
368 // <qmail> selection is no longer a member variable |
|
369 CMsvEntrySelection* selection = new(ELeave) CMsvEntrySelection; |
|
370 CleanupStack::PushL( selection ); |
|
371 selection->InsertL( 0, iService ); |
|
372 iBaseMtm->SwitchCurrentEntryL( iService ); |
|
373 // Start the fetch operation |
|
374 InvokeClientMtmAsyncFunctionL( KPOP3MTMPopulateAll, *selection, params ); // <qmail> 1 param removed |
|
375 SetActive(); |
|
376 CleanupStack::PopAndDestroy( selection ); |
|
377 // <qmail> iEventHandler->SetNewPropertyEvent call removed from here |
|
378 // </qmail> |
|
379 } |
|
380 // <qmail> Connected() moved to baseclass |
|
381 |
|
382 // ---------------------------------------------------------------------------- |
|
383 // ---------------------------------------------------------------------------- |
|
384 // <qmail> return type |
|
385 TIpsOpType CIpsPlgPop3ConnectOp::IpsOpType() const |
|
386 { |
|
387 FUNC_LOG; |
|
388 return EIpsOpTypePop3SyncOp; |
|
389 } |
|
390 |
|
391 // <qmail> removed QueryUsrPassL() from here as unneeded |
|
392 // <qmail> removed ValidateL() (did nothing) |
|
393 |
|
394 // ---------------------------------------------------------------------------- |
|
395 // ---------------------------------------------------------------------------- |
|
396 // |
|
397 TInt CIpsPlgPop3ConnectOp::GetOperationErrorCodeL( ) |
|
398 { |
|
399 FUNC_LOG; |
|
400 if ( !iSubOperation ) |
|
401 { |
|
402 return KErrNotFound; |
|
403 } |
|
404 if ( !iSubOperation->IsActive() && iSubOperation->iStatus.Int() != KErrNone ) |
|
405 { |
|
406 return iSubOperation->iStatus.Int(); |
|
407 } |
|
408 |
|
409 TPckgBuf<TPop3Progress> paramPack; |
|
410 paramPack.Copy( iSubOperation->ProgressL() ); |
|
411 const TPop3Progress& progress = paramPack(); |
|
412 |
|
413 return progress.iErrorCode; |
|
414 } |
|
415 |
|
416 // <qmail> removed CIpsPlgImap4ConnectOp::CredientialsSetL |
|
417 |
|
418 //<qmail> new functions |
|
419 // ---------------------------------------------------------------------------- |
|
420 // ---------------------------------------------------------------------------- |
|
421 void CIpsPlgPop3ConnectOp::DoDisconnectL() |
|
422 { |
|
423 FUNC_LOG; |
|
424 // <qmail> unnecessary: iStatus = KRequestPending; |
|
425 NM_COMMENT("CIpsPlgPop3ConnectOp: disconnecting"); |
|
426 InvokeClientMtmAsyncFunctionL( KPOP3MTMDisconnect, iService ); // <qmail> 1 param removed |
|
427 SetActive(); |
|
428 } |
|
429 |
|
430 // ---------------------------------------------------------------------------- |
|
431 // ---------------------------------------------------------------------------- |
|
432 TInt CIpsPlgPop3ConnectOp::GetPopulateLimitFromSettingsL() |
|
433 { |
|
434 FUNC_LOG; |
|
435 TInt limit( KDefaultPopulateLimit ); |
|
436 |
313 CImPop3Settings* settings = new(ELeave) CImPop3Settings(); |
437 CImPop3Settings* settings = new(ELeave) CImPop3Settings(); |
314 CleanupStack::PushL( settings ); |
438 CleanupStack::PushL( settings ); |
315 TPopAccount popAccountId; |
439 TPopAccount popAccountId; |
316 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
440 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
317 accounts->GetPopAccountL( iService , popAccountId ); |
441 accounts->GetPopAccountL( iService , popAccountId ); |
318 accounts->LoadPopSettingsL( popAccountId, *settings ); |
442 accounts->LoadPopSettingsL( popAccountId, *settings ); |
319 iPopulateLimit = settings->PopulationLimit(); |
443 limit = settings->PopulationLimit(); |
320 if ( iPopulateLimit > 0 ) |
444 if ( limit > 0 ) |
321 { |
445 { |
322 iPopulateLimit = ( iPopulateLimit * 1024 ) / 75; |
446 // basically doing a _very_rough_ conversion from kilobyte value to number-of-rows |
323 } |
447 limit = ( limit * KPopulateAlgorithmBytesInKilo ) / KPopulateAlgorithmRowLength; |
324 else if ( iPopulateLimit == KIpsSetDataHeadersOnly ) |
448 } |
325 { |
|
326 iPopulateLimit = 0; |
|
327 } |
|
328 else |
|
329 { |
|
330 iPopulateLimit = KMaxTInt; |
|
331 } |
|
332 |
|
333 CleanupStack::PopAndDestroy( 2, settings ); |
449 CleanupStack::PopAndDestroy( 2, settings ); |
334 |
450 return limit; |
335 if ( tentry.Connected() ) |
451 } |
336 { |
452 |
337 iState = EConnected; |
453 //</qmail> |
338 iAlreadyConnected = ETrue; |
|
339 SetActive(); |
|
340 CompleteThis(); |
|
341 } |
|
342 else |
|
343 { |
|
344 iState = EStartConnect; |
|
345 SetActive(); |
|
346 CompleteThis(); |
|
347 } |
|
348 } |
|
349 |
|
350 // ---------------------------------------------------------------------------- |
|
351 // CIpsPlgPop3ConnectOp::DoConnectL() |
|
352 // ---------------------------------------------------------------------------- |
|
353 // |
|
354 void CIpsPlgPop3ConnectOp::DoConnectL() |
|
355 { |
|
356 FUNC_LOG; |
|
357 iStatus = KRequestPending; |
|
358 InvokeClientMtmAsyncFunctionL( KPOP3MTMConnect, iService, iService ); |
|
359 SetActive(); |
|
360 } |
|
361 |
|
362 // ---------------------------------------------------------------------------- |
|
363 // CIpsPlgPop3ConnectOp::DoPopulateL() |
|
364 // ---------------------------------------------------------------------------- |
|
365 // |
|
366 void CIpsPlgPop3ConnectOp::DoPopulateL() |
|
367 { |
|
368 FUNC_LOG; |
|
369 iStatus = KRequestPending; |
|
370 |
|
371 // Prepare parameters and include filtering |
|
372 TImPop3PopulateOptions pop3GetMailInfo; |
|
373 pop3GetMailInfo.SetMaxEmailSize( KMaxTInt32 ); |
|
374 pop3GetMailInfo.SetPopulationLimit( iPopulateLimit ); |
|
375 TPckgBuf<TImPop3PopulateOptions> params( pop3GetMailInfo ); |
|
376 |
|
377 iSelection->InsertL(0, iService); |
|
378 iBaseMtm->SwitchCurrentEntryL( iService ); |
|
379 // Start the fetch operation |
|
380 InvokeClientMtmAsyncFunctionL( KPOP3MTMPopulateAll, *iSelection, |
|
381 iService, params); |
|
382 |
|
383 SetActive(); |
|
384 |
|
385 if ( iEventHandler ) |
|
386 { |
|
387 iEventHandler->SetNewPropertyEvent( |
|
388 iService, KIpsSosEmailSyncStarted, KErrNone ); |
|
389 } |
|
390 } |
|
391 // ---------------------------------------------------------------------------- |
|
392 // ---------------------------------------------------------------------------- |
|
393 // |
|
394 TBool CIpsPlgPop3ConnectOp::Connected() const |
|
395 { |
|
396 FUNC_LOG; |
|
397 TMsvEntry tentry; |
|
398 TMsvId service; |
|
399 iMsvSession.GetEntry(iService, service, tentry ); |
|
400 return tentry.Connected(); |
|
401 } |
|
402 |
|
403 // ---------------------------------------------------------------------------- |
|
404 // CIpsPlgImap4ConnectOp::IpsOpType() |
|
405 // ---------------------------------------------------------------------------- |
|
406 // |
|
407 TInt CIpsPlgPop3ConnectOp::IpsOpType() const |
|
408 { |
|
409 FUNC_LOG; |
|
410 return EIpsOpTypePop3SyncOp; |
|
411 } |
|
412 |
|
413 |
|
414 // ---------------------------------------------------------------------------- |
|
415 // CIpsPlgPop3ConnectOp::ValidateL() |
|
416 // ---------------------------------------------------------------------------- |
|
417 // |
|
418 TBool CIpsPlgPop3ConnectOp::ValidateL() |
|
419 { |
|
420 // do proper validation. OR: not needed? |
|
421 return ETrue; |
|
422 } |
|
423 |
|
424 // ---------------------------------------------------------------------------- |
|
425 // CIpsPlgPop3ConnectOp::QueryUserPassL() |
|
426 // ---------------------------------------------------------------------------- |
|
427 // |
|
428 TBool CIpsPlgPop3ConnectOp::QueryUserPassL() |
|
429 { |
|
430 FUNC_LOG; |
|
431 |
|
432 if ( iEventHandler ) |
|
433 { |
|
434 // ask for credentials for pop3 account and wait for callback |
|
435 if ( iEventHandler->QueryUsrPassL( iEntry->EntryId(), this ) ) |
|
436 { |
|
437 iState = EQueryingDetails; |
|
438 } |
|
439 else |
|
440 { |
|
441 // another operation is waiting for password |
|
442 iState = EQueryingDetailsBusy; |
|
443 } |
|
444 |
|
445 return ETrue; |
|
446 } |
|
447 |
|
448 return EFalse; |
|
449 } |
|
450 |
|
451 |
|
452 // ---------------------------------------------------------------------------- |
|
453 // CIpsPlgPop3ConnectOp::GetOperationErrorCodeL() |
|
454 // ---------------------------------------------------------------------------- |
|
455 // |
|
456 TInt CIpsPlgPop3ConnectOp::GetOperationErrorCodeL( ) |
|
457 { |
|
458 FUNC_LOG; |
|
459 |
|
460 if ( iAlreadyConnected ) |
|
461 { |
|
462 // Connected state was set in CIpsPlgPop3ConnectOp::ConstructL() |
|
463 // so iOperation is null |
|
464 return KErrNone; |
|
465 } |
|
466 |
|
467 if ( !iOperation ) |
|
468 { |
|
469 return KErrNotFound; |
|
470 } |
|
471 if ( !iOperation->IsActive() && iOperation->iStatus.Int() != KErrNone ) |
|
472 { |
|
473 return iOperation->iStatus.Int(); |
|
474 } |
|
475 |
|
476 TPckgBuf<TPop3Progress> paramPack; |
|
477 paramPack.Copy( iOperation->ProgressL() ); |
|
478 const TPop3Progress& progress = paramPack(); |
|
479 |
|
480 return progress.iErrorCode; |
|
481 } |
|
482 |
|
483 // ---------------------------------------------------------------------------- |
|
484 // ---------------------------------------------------------------------------- |
|
485 void CIpsPlgPop3ConnectOp::CredientialsSetL( TInt aEvent ) |
|
486 { |
|
487 FUNC_LOG; |
|
488 |
|
489 if ( iState == EQueryingDetails ) |
|
490 { |
|
491 // response for our operation`s query |
|
492 if ( aEvent == EIPSSosCredientialsCancelled ) |
|
493 { |
|
494 // user canceled operation |
|
495 CompleteObserver( KErrCancel ); |
|
496 } |
|
497 |
|
498 // password has been set, continue with operation |
|
499 SetActive(); |
|
500 CompleteThis(); |
|
501 } |
|
502 else if ( iState == EQueryingDetailsBusy ) |
|
503 { |
|
504 // response for other operation`s query |
|
505 // we could try to ask for password now, |
|
506 // but decision was made to cancel operation |
|
507 CompleteObserver( KErrCancel ); |
|
508 SetActive(); |
|
509 CompleteThis(); |
|
510 } |
|
511 } |
|
512 //EOF |
|
513 |
|
514 |
|