|
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 * CImapConnectionOp implementation file |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // General includes |
|
22 #include <eikenv.h> |
|
23 #include <eikrutil.h> |
|
24 #include <StringLoader.h> |
|
25 |
|
26 // Messaging includes |
|
27 #include <miut_err.h> |
|
28 #include <miutset.h> |
|
29 #include <msvuids.h> |
|
30 #include <mtmuibas.h> |
|
31 #include <imapset.h> |
|
32 #include <MsvPrgReporter.h> |
|
33 #include <imapcmds.h> |
|
34 #include <ImumUtils.rsg> |
|
35 #include <AlwaysOnlineManagerClient.h> |
|
36 #include <SendUiConsts.h> |
|
37 #include <ImumInMailboxUtilities.h> |
|
38 |
|
39 #include "ImapConnectionOp.h" |
|
40 #include "MsvConnectionValidation.h" |
|
41 #include "MsvEmailConnectionProgressProvider.h" |
|
42 #include "PROGTYPE.H" |
|
43 #include "ImumPanic.h" |
|
44 #include "ImumMtmLogging.h" |
|
45 #include "ImapFolderSyncOperation.h" |
|
46 #include "EmailUtils.H" |
|
47 #include "ImumMboxSettingsUtils.h" |
|
48 |
|
49 |
|
50 const TInt KImumMaxLoginRetries = 3; |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // CImapConnectionOp::NewL() |
|
54 // ---------------------------------------------------------------------------- |
|
55 CImapConnectionOp* CImapConnectionOp::NewL( |
|
56 CMsvSession& aMsvSession, |
|
57 TInt aPriority, |
|
58 TRequestStatus& aStatus, |
|
59 TMsvId aService, |
|
60 MMsvProgressReporter& aProgressReporter, |
|
61 TImapConnectionType aConnectionType) |
|
62 { |
|
63 IMUM_STATIC_CONTEXT( CImapConnectionOp::NewL, 0, mtm, KImumMtmLog ); |
|
64 IMUM_IN(); |
|
65 |
|
66 CImapConnectionOp* me=new (ELeave) CImapConnectionOp( |
|
67 aMsvSession, aPriority, aStatus, |
|
68 aService, aProgressReporter, aConnectionType ); |
|
69 CleanupStack::PushL(me); |
|
70 me->ConstructL(); |
|
71 CleanupStack::Pop(); // me |
|
72 IMUM_OUT(); |
|
73 return me; |
|
74 } |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // CImapConnectionOp::CImapConnectionOp() |
|
78 // ---------------------------------------------------------------------------- |
|
79 CImapConnectionOp::CImapConnectionOp( |
|
80 CMsvSession& aMsvSession, |
|
81 TInt aPriority, |
|
82 TRequestStatus& aStatus, |
|
83 TMsvId aService, |
|
84 MMsvProgressReporter& aProgressReporter, |
|
85 TImapConnectionType aConnectionType ) |
|
86 : |
|
87 CMsvOperation(aMsvSession, aPriority, aStatus), |
|
88 iMailboxApi( NULL ), |
|
89 iState(EConstructing), |
|
90 iConnectionType(aConnectionType), |
|
91 iSyncProgress(), |
|
92 iProgressReporter(aProgressReporter)/*, |
|
93 iOperations( KImumOperationsArrayGranularity )*/ |
|
94 { |
|
95 IMUM_CONTEXT( CImapConnectionOp::CImapConnectionOp, 0, KImumMtmLog ); |
|
96 IMUM_IN(); |
|
97 |
|
98 iService=aService; |
|
99 iMtm=KUidMsgTypeIMAP4; |
|
100 iSyncProgress().iType=EImap4SyncProgressType; |
|
101 iCoeEnv = CCoeEnv::Static(); |
|
102 IMUM_OUT(); |
|
103 } |
|
104 |
|
105 // ---------------------------------------------------------------------------- |
|
106 // CImapConnectionOp::~CImapConnectionOp() |
|
107 // ---------------------------------------------------------------------------- |
|
108 CImapConnectionOp::~CImapConnectionOp() |
|
109 { |
|
110 IMUM_CONTEXT( CImapConnectionOp::~CImapConnectionOp, 0, KImumMtmLog ); |
|
111 IMUM_IN(); |
|
112 |
|
113 //iOperations.ResetAndDestroy(); |
|
114 |
|
115 Cancel(); |
|
116 iProgressReporter.UnsetProgressDecoder(); |
|
117 |
|
118 // Release the shared MtmUi |
|
119 if(iMtmUi) |
|
120 { |
|
121 iProgressReporter.MtmStore().ReleaseMtmUi(iMtm); |
|
122 } |
|
123 |
|
124 delete iConnectionProgressProvider; |
|
125 delete iSubOperation; |
|
126 delete iTitleText; |
|
127 delete iConnectionText; |
|
128 |
|
129 delete iMailboxApi; |
|
130 iMailboxApi = NULL; |
|
131 // don't own iCoeEnv so don't delete it |
|
132 iMtmUi = NULL; |
|
133 iCoeEnv = NULL; |
|
134 IMUM_OUT(); |
|
135 } |
|
136 |
|
137 // ---------------------------------------------------------------------------- |
|
138 // CImapConnectionOp::ConstructL() |
|
139 // ---------------------------------------------------------------------------- |
|
140 void CImapConnectionOp::ConstructL() |
|
141 { |
|
142 IMUM_CONTEXT( CImapConnectionOp::ConstructL, 0, KImumMtmLog ); |
|
143 IMUM_IN(); |
|
144 |
|
145 CMsvEntry* serviceEntry=NULL; |
|
146 |
|
147 serviceEntry=iMsvSession.GetEntryL(iService); |
|
148 CleanupStack::PushL(serviceEntry); |
|
149 |
|
150 iSyncProgress().iState=TImap4SyncProgress::EConnecting; |
|
151 iSyncProgress().iErrorCode=KErrNone; |
|
152 |
|
153 // Store the related service Id |
|
154 iRelatedServiceId=serviceEntry->Entry().iRelatedId; |
|
155 |
|
156 iConnectionText = NULL; |
|
157 iTitleText = StringLoader::LoadL( |
|
158 R_EMAIL_CONNECTING_SERVER, |
|
159 serviceEntry->Entry().iDetails, |
|
160 iCoeEnv ); |
|
161 |
|
162 CleanupStack::PopAndDestroy( serviceEntry ); |
|
163 |
|
164 iMailboxApi = CreateEmailApiL( &iMsvSession ); |
|
165 |
|
166 CActiveScheduler::Add(this); |
|
167 |
|
168 iObserverRequestStatus=KRequestPending; |
|
169 |
|
170 TRequestStatus* myStatus=&iStatus; |
|
171 User::RequestComplete(myStatus,KErrNone); |
|
172 |
|
173 SetActive(); |
|
174 // We complete ourselves so that the dialog gets a chance to redraw |
|
175 // before entering the lengthy process of opening system agent and |
|
176 // connection progress provider |
|
177 IMUM_OUT(); |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CImapConnectionOp::GetConnectionOperationL() |
|
182 // ---------------------------------------------------------------------------- |
|
183 CMsvOperation* CImapConnectionOp::GetConnectionOperationL() |
|
184 { |
|
185 IMUM_CONTEXT( CImapConnectionOp::GetConnectionOperationL, 0, KImumMtmLog ); |
|
186 IMUM_IN(); |
|
187 |
|
188 // Invoke the appropriate client connection operation |
|
189 // InvokeAsyncFunctionL in the MtmUi. |
|
190 // |
|
191 TPckg<MMsvImapConnectionObserver*> param(this); |
|
192 |
|
193 CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; |
|
194 CleanupStack::PushL(selection); |
|
195 selection->AppendL(iService); |
|
196 |
|
197 CMsvOperation* connectOp=NULL; |
|
198 |
|
199 switch(iConnectionType) |
|
200 { |
|
201 case ECompleteAfterConnect: |
|
202 connectOp=iMtmUi->InvokeAsyncFunctionL( |
|
203 KIMAP4MTMConnect, *selection, iStatus, param); |
|
204 break; |
|
205 case EWithSyncCompleteAfterConnect: |
|
206 connectOp=iMtmUi->InvokeAsyncFunctionL( |
|
207 KIMAP4MTMConnectAndSyncCompleteAfterConnect, *selection, iStatus, param); |
|
208 break; |
|
209 case EWithSyncCompleteAfterFullSync: |
|
210 connectOp=iMtmUi->InvokeAsyncFunctionL( |
|
211 KIMAP4MTMConnectAndSyncCompleteAfterFullSync, *selection, iStatus, param); |
|
212 break; |
|
213 case EWithSyncCompleteAfterDisconnection: |
|
214 connectOp=iMtmUi->InvokeAsyncFunctionL( |
|
215 KIMAP4MTMConnectAndSyncCompleteAfterDisconnect, *selection, iStatus, param); |
|
216 break; |
|
217 default: |
|
218 __ASSERT_DEBUG( 0, |
|
219 User::Panic(KImumMtmUiPanic, EIMAP4MtmUiUnknownOperation) ); |
|
220 } |
|
221 |
|
222 CleanupStack::PopAndDestroy(); // selection |
|
223 IMUM_OUT(); |
|
224 |
|
225 return connectOp; |
|
226 } |
|
227 |
|
228 // ---------------------------------------------------------------------------- |
|
229 // CImapConnectionOp::RunL() |
|
230 // ---------------------------------------------------------------------------- |
|
231 void CImapConnectionOp::RunL() |
|
232 { |
|
233 IMUM_CONTEXT( CImapConnectionOp::RunL, 0, KImumMtmLog ); |
|
234 IMUM_IN(); |
|
235 |
|
236 DoRunL(); |
|
237 |
|
238 IMUM_OUT(); |
|
239 } |
|
240 |
|
241 // ---------------------------------------------------------------------------- |
|
242 // CImapConnectionOp::DoRunL() |
|
243 // ---------------------------------------------------------------------------- |
|
244 void CImapConnectionOp::DoRunL() |
|
245 { |
|
246 IMUM_CONTEXT( CImapConnectionOp::DoRunL, 0, KImumMtmLog ); |
|
247 IMUM_IN(); |
|
248 |
|
249 if(iState==EConstructing) |
|
250 { |
|
251 FinishConstructionL(); |
|
252 } |
|
253 else |
|
254 { |
|
255 ConnectionCompletionL(); |
|
256 } |
|
257 IMUM_OUT(); |
|
258 } |
|
259 |
|
260 // ---------------------------------------------------------------------------- |
|
261 // CImapConnectionOp::RunError() |
|
262 // ---------------------------------------------------------------------------- |
|
263 TInt CImapConnectionOp::RunError(TInt aError) |
|
264 { |
|
265 IMUM_CONTEXT( CImapConnectionOp::RunError, 0, KImumMtmLog ); |
|
266 IMUM_IN(); |
|
267 |
|
268 IMUM1( 0, "RunL leaved with error code %d", aError ); |
|
269 |
|
270 iSyncProgress().iErrorCode = aError; |
|
271 Complete(); |
|
272 |
|
273 IMUM_OUT(); |
|
274 return KErrNone; |
|
275 } |
|
276 |
|
277 // ---------------------------------------------------------------------------- |
|
278 // CImapConnectionOp::FinishConstructionL() |
|
279 // ---------------------------------------------------------------------------- |
|
280 void CImapConnectionOp::FinishConstructionL() |
|
281 { |
|
282 IMUM_CONTEXT( CImapConnectionOp::FinishConstructionL, 0, KImumMtmLog ); |
|
283 IMUM_IN(); |
|
284 |
|
285 // Called by RunL when in EConstructing state |
|
286 TBool check = ETrue; |
|
287 |
|
288 // To speed up connection establishment, avoid loading settings multiple |
|
289 // times. Get all the info needed at once. |
|
290 CImumInSettingsData* settings = |
|
291 iMailboxApi->MailboxServicesL().LoadMailboxSettingsL( iService ); |
|
292 CleanupStack::PushL( settings ); |
|
293 |
|
294 // Check if the service has a password and valid IAP |
|
295 // Get login data from settings |
|
296 TMsvLoginData loginData; |
|
297 ImumMboxSettingsUtils::GetLoginInformationL( *settings, |
|
298 KSenduiMtmImap4Uid, loginData.iUsername, loginData.iPassword, |
|
299 loginData.iIsPasswordTemporary ); |
|
300 // Get iap name |
|
301 TBuf<KImasImailMaxSettingsLength> iapName; |
|
302 MsvConnectionValidation::GetServiceIapNameL( *settings, |
|
303 KSenduiMtmImap4Uid, iapName); |
|
304 TBool iapOk = ( settings->Validate() == KErrNone ); |
|
305 CleanupStack::PopAndDestroy(); // settings |
|
306 |
|
307 iLoginRetryCounter = 0; |
|
308 if( !check || |
|
309 !iapOk || |
|
310 !MsvConnectionValidation::CheckAndPromptForPasswordL( |
|
311 *iMailboxApi, iService, loginData, iLoginRetryCounter ) ) |
|
312 { |
|
313 // User has declined to provide a password or a IAP. Complete |
|
314 // _ourselves_ immediately. |
|
315 iStatus=KRequestPending; |
|
316 SetActive(); |
|
317 |
|
318 TRequestStatus* myStatus=&iStatus; |
|
319 User::RequestComplete(myStatus, KErrNone); |
|
320 iSyncProgress().iErrorCode= ( iapOk ? KErrCancel : KErrImapConnectFail ); |
|
321 iState=ECompleted; |
|
322 } |
|
323 else |
|
324 { |
|
325 // Service has password in it and a valid IAP. |
|
326 // |
|
327 iMtmUi=&(iProgressReporter.MtmStore().ClaimMtmUiL(iMtm)); |
|
328 iMtmUi->BaseMtm().SwitchCurrentEntryL(iService); |
|
329 |
|
330 iConnectionProgressProvider = CMsvEmailConnectionProgressProvider::NewL( |
|
331 iapName, iService); |
|
332 iSubOperation=GetConnectionOperationL(); |
|
333 iState=EEstablishingConnection; |
|
334 |
|
335 SetActive(); |
|
336 // |
|
337 // We're going to try and connect; tell our MMsvProgressReporter |
|
338 // to come to us for progress. |
|
339 // |
|
340 iProgressReporter.SetProgressDecoder(*this); |
|
341 } |
|
342 iObserverRequestStatus=KRequestPending; |
|
343 IMUM_OUT(); |
|
344 } |
|
345 |
|
346 // ---------------------------------------------------------------------------- |
|
347 // CImapConnectionOp::ConnectionCompletionL() |
|
348 // ---------------------------------------------------------------------------- |
|
349 void CImapConnectionOp::ConnectionCompletionL() |
|
350 { |
|
351 IMUM_CONTEXT( CImapConnectionOp::ConnectionCompletionL, 0, KImumMtmLog ); |
|
352 IMUM_IN(); |
|
353 |
|
354 // Called by RunL when past EConstructing state |
|
355 TInt err=KErrNone; |
|
356 if(iSubOperation) |
|
357 { |
|
358 // The sub connection operation has completed. |
|
359 |
|
360 // We need to detect a failure to connect due to invalid login details, |
|
361 // and prompt the user accordingly. |
|
362 // |
|
363 TBuf<CBaseMtmUi::EProgressStringMaxLen> dummyString; |
|
364 TInt dummyInt[4]; // CSI: 47 # For dummyInt. |
|
365 |
|
366 err=DecodeProgress(iSubOperation->ProgressL(),dummyString,dummyInt[0],dummyInt[1],dummyInt[2],dummyInt[3],ETrue); // CSI: 47 # dummyInts. |
|
367 if(err == KErrImapBadLogon) |
|
368 { |
|
369 // Login details are wrong. |
|
370 TBool retry = EFalse; |
|
371 if ( iLoginRetryCounter < KImumMaxLoginRetries ) |
|
372 { |
|
373 retry = MsvConnectionValidation::ShowLoginDetailsRejectionDlgL( |
|
374 *iMailboxApi, iService); |
|
375 } |
|
376 else |
|
377 { |
|
378 // User has entered wrong username or password max number of times, |
|
379 // sets error code for imap mtm ui to display correct note... |
|
380 iSyncProgress().iErrorCode = KErrImapBadLogon; |
|
381 iState=ECompleted; |
|
382 } |
|
383 iLoginRetryCounter++; |
|
384 |
|
385 if(retry) |
|
386 { |
|
387 // Retry connect. |
|
388 iProgressReporter.MakeProgressVisibleL(ETrue); |
|
389 iProgressReporter.SetTitleL(*iTitleText); |
|
390 delete iSubOperation; |
|
391 iSubOperation=NULL; |
|
392 iSubOperation=GetConnectionOperationL(); |
|
393 SetActive(); |
|
394 iProgressReporter.SetProgressDecoder(*this); |
|
395 IMUM_OUT(); |
|
396 return; |
|
397 } |
|
398 else |
|
399 { |
|
400 Complete(); |
|
401 IMUM_OUT(); |
|
402 return; |
|
403 } |
|
404 } |
|
405 } |
|
406 |
|
407 User::LeaveIfError(err); // Any error apart from KErrImapBadLogon |
|
408 |
|
409 Complete(); |
|
410 IMUM_OUT(); |
|
411 } |
|
412 |
|
413 // ---------------------------------------------------------------------------- |
|
414 // CImapConnectionOp::DoCancel() |
|
415 // ---------------------------------------------------------------------------- |
|
416 void CImapConnectionOp::DoCancel() |
|
417 { |
|
418 IMUM_CONTEXT( CImapConnectionOp::DoCancel, 0, KImumMtmLog ); |
|
419 IMUM_IN(); |
|
420 |
|
421 if( iSubOperation ) |
|
422 { |
|
423 iSubOperation->Cancel(); |
|
424 } |
|
425 |
|
426 iSyncProgress().iErrorCode = KErrCancel; |
|
427 Complete(); |
|
428 IMUM_OUT(); |
|
429 } |
|
430 |
|
431 // ---------------------------------------------------------------------------- |
|
432 // CImapConnectionOp::ProgressL() |
|
433 // ---------------------------------------------------------------------------- |
|
434 const TDesC8& CImapConnectionOp::ProgressL() |
|
435 { |
|
436 IMUM_CONTEXT( CImapConnectionOp::ProgressL, 0, KImumMtmLog ); |
|
437 IMUM_IN(); |
|
438 |
|
439 if(iSubOperation && (iState!=ECompleted)) |
|
440 { |
|
441 // Need to make the distinction between connection states. |
|
442 // |
|
443 // EEstablishingConnection -> CMsvEMailConnectionProgressProvider |
|
444 // EUpdatingFolderList -> iOperation->ProgressL |
|
445 // EUpdatingInbox, -> iOperation->ProgressL |
|
446 // EUpdatingFolders, -> iOperation->ProgressL |
|
447 // EOnline, -> iOperation->ProgressL |
|
448 // ECompleted -> iSyncProgress |
|
449 // |
|
450 if(iState==EEstablishingConnection) |
|
451 { |
|
452 IMUM_OUT(); |
|
453 return iConnectionProgressProvider->GetConnectionProgressL(); |
|
454 } |
|
455 else |
|
456 { |
|
457 IMUM_OUT(); |
|
458 return iSubOperation->ProgressL(); |
|
459 } |
|
460 } |
|
461 else |
|
462 { |
|
463 IMUM_OUT(); |
|
464 return iSyncProgress; |
|
465 } |
|
466 } |
|
467 |
|
468 // ---------------------------------------------------------------------------- |
|
469 // CImapConnectionOp::DecodeProgress() |
|
470 // ---------------------------------------------------------------------------- |
|
471 TInt CImapConnectionOp::DecodeProgress(const TDesC8& aProgress, |
|
472 TBuf<CBaseMtmUi::EProgressStringMaxLen>& aReturnString, |
|
473 TInt& aTotalEntryCount, TInt& aEntriesDone, |
|
474 TInt& aCurrentEntrySize, TInt& aCurrentBytesTrans, TBool aInternal) |
|
475 { |
|
476 IMUM_CONTEXT( CImapConnectionOp::DecodeProgress, 0, KImumMtmLog ); |
|
477 IMUM_IN(); |
|
478 |
|
479 if(aProgress.Length()==0) |
|
480 return KErrNone; |
|
481 |
|
482 TPckgC<TInt> type(0); |
|
483 type.Set(aProgress.Left(sizeof(TInt))); |
|
484 |
|
485 IMUM_OUT(); |
|
486 if(!aInternal || type()!=EUiProgTypeConnecting) |
|
487 return iMtmUi->GetProgress(aProgress, aReturnString, aTotalEntryCount, |
|
488 aEntriesDone, aCurrentEntrySize, aCurrentBytesTrans); |
|
489 else |
|
490 // We want the internal representation of connection progress... |
|
491 return DecodeConnectionProgress(aProgress, aReturnString,aTotalEntryCount, aEntriesDone, aCurrentEntrySize, aCurrentBytesTrans); |
|
492 } |
|
493 |
|
494 // ---------------------------------------------------------------------------- |
|
495 // CImapConnectionOp::DecodeConnectionProgress() |
|
496 // ---------------------------------------------------------------------------- |
|
497 TInt CImapConnectionOp::DecodeConnectionProgress( |
|
498 const TDesC8& aProgress, |
|
499 TBuf<CBaseMtmUi::EProgressStringMaxLen>& aReturnString, |
|
500 TInt& aTotalEntryCount, |
|
501 TInt& aEntriesDone, |
|
502 TInt& aCurrentEntrySize, |
|
503 TInt& aCurrentBytesTrans) |
|
504 { |
|
505 IMUM_CONTEXT( CImapConnectionOp::DecodeConnectionProgress, 0, KImumMtmLog ); |
|
506 IMUM_IN(); |
|
507 |
|
508 aTotalEntryCount=0; // No quantitative progress to return |
|
509 aEntriesDone=0; |
|
510 aCurrentEntrySize=0; |
|
511 aCurrentBytesTrans=0; |
|
512 |
|
513 TPckgBuf<TMsvEmailConnectionProgress> progressBuf; |
|
514 progressBuf.Copy(aProgress); |
|
515 const TMsvEmailConnectionProgress& connectionProgress=progressBuf(); |
|
516 |
|
517 switch(connectionProgress.iState) |
|
518 { |
|
519 case TMsvEmailConnectionProgress::EInitialising: |
|
520 case TMsvEmailConnectionProgress::EConnectNetwork: |
|
521 { |
|
522 // Check if the name is already prepared |
|
523 if( iConnectionText ) |
|
524 { |
|
525 aReturnString.Copy( *iConnectionText ); |
|
526 } |
|
527 else |
|
528 { |
|
529 MsvEmailMtmUiUtils::CreateConnectingToText( aReturnString, |
|
530 iMsvSession, iService ); |
|
531 iConnectionText = aReturnString.Alloc(); |
|
532 } |
|
533 |
|
534 } |
|
535 break; |
|
536 case TMsvEmailConnectionProgress::EConnectMailbox: |
|
537 aReturnString.Copy( *iTitleText ); |
|
538 break; |
|
539 } |
|
540 IMUM_OUT(); |
|
541 |
|
542 return connectionProgress.iErrorCode; |
|
543 } |
|
544 |
|
545 // ---------------------------------------------------------------------------- |
|
546 // CImapConnectionOp::Complete() |
|
547 // ---------------------------------------------------------------------------- |
|
548 void CImapConnectionOp::Complete() |
|
549 { |
|
550 IMUM_CONTEXT( CImapConnectionOp::Complete, 0, KImumMtmLog ); |
|
551 IMUM_IN(); |
|
552 |
|
553 TRequestStatus* observer=&iObserverRequestStatus; |
|
554 User::RequestComplete(observer, KErrNone); |
|
555 iState=ECompleted; |
|
556 IMUM_OUT(); |
|
557 } |
|
558 |
|
559 // ---------------------------------------------------------------------------- |
|
560 // CImapConnectionOp::HandleImapConnectionEvent() |
|
561 // ---------------------------------------------------------------------------- |
|
562 void CImapConnectionOp::HandleImapConnectionEvent( |
|
563 TImapConnectionEvent aConnectionEvent ) |
|
564 { |
|
565 IMUM_CONTEXT( CImapConnectionOp::HandleImapConnectionEvent, 0, KImumMtmLog ); |
|
566 IMUM_IN(); |
|
567 |
|
568 switch ( aConnectionEvent ) |
|
569 { |
|
570 case ESynchronisingInbox: |
|
571 // Means that the connection has finished |
|
572 iState=EUpdatingFolderList; |
|
573 delete iConnectionProgressProvider; |
|
574 iConnectionProgressProvider=NULL; |
|
575 |
|
576 // Get progress decoded by the default decoder |
|
577 iProgressReporter.UnsetProgressDecoder(); |
|
578 |
|
579 // Try to update successful connection time. If failed |
|
580 // just forget it. |
|
581 TRAP_IGNORE( ImumMboxSettingsUtils::SetLastUpdateInfoL( |
|
582 *iMailboxApi, iService, ETrue ) ); |
|
583 |
|
584 break; |
|
585 |
|
586 case ESynchronisingFolderList: |
|
587 break; |
|
588 |
|
589 case ESynchronisingFolders: |
|
590 case ESynchronisationComplete: |
|
591 { |
|
592 if ( iConnectionType == EWithSyncCompleteAfterDisconnection ) |
|
593 { |
|
594 // Only hide dialog if we're here 'til the end |
|
595 TRAP_IGNORE( iProgressReporter.MakeProgressVisibleL( EFalse ) ); |
|
596 } |
|
597 |
|
598 // Send the 'Turn ON' message to always online. |
|
599 TRAP_IGNORE( MsvEmailMtmUiUtils::SendAOCommandL( |
|
600 EServerAPIEmailUpdateMailWhileConnected, iService ) ); |
|
601 } |
|
602 |
|
603 break; |
|
604 |
|
605 default: |
|
606 break; |
|
607 } |
|
608 |
|
609 /* We can always call NewMessage function, because Ncnlist is responsible of |
|
610 checking whether there really is new messages or not. We only tell Ncnlist |
|
611 that now there might be new messages */ |
|
612 TRAP_IGNORE( MsvEmailMtmUiUtils::CallNewMessagesL( iService ) ); |
|
613 IMUM_OUT(); |
|
614 } |
|
615 |
|
616 // ---------------------------------------------------------------------------- |
|
617 // CImapConnectionOp::OpCompleted() |
|
618 // ---------------------------------------------------------------------------- |
|
619 void CImapConnectionOp::OpCompleted( |
|
620 CMsvSingleOpWatcher& /*aOpWatcher*/, |
|
621 TInt /*aCompletionCode*/ ) |
|
622 { |
|
623 IMUM_CONTEXT( CImapConnectionOp::OpCompleted, 0, KImumMtmLog ); |
|
624 IMUM_IN(); |
|
625 IMUM_OUT(); |
|
626 |
|
627 /* |
|
628 TMsvOp opId = aOpWatcher.Operation().Id(); |
|
629 const TInt count = iOperations.Count(); |
|
630 |
|
631 for ( TInt i=0; i < count; i++ ) |
|
632 { |
|
633 CMsvOperation& op = iOperations[i]->Operation(); |
|
634 |
|
635 if ( op.Id() == opId ) |
|
636 { |
|
637 delete iOperations[i]; |
|
638 iOperations.Delete(i); |
|
639 break; |
|
640 } |
|
641 } |
|
642 */ |
|
643 } |
|
644 |
|
645 // End of File |