|
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 * folder refresh operation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // Messaging includes |
|
21 #include <miutset.h> |
|
22 #include <imapcmds.h> |
|
23 |
|
24 // Specific includes |
|
25 #include "RefreshImapFolderList.h" |
|
26 #include "ImapConnectionOp.h" |
|
27 #include "ImumDisconnectOperation.h" |
|
28 #include "ImumPanic.h" |
|
29 #include "ImumMtmLogging.h" |
|
30 |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // NewL |
|
34 // ---------------------------------------------------------------------------- |
|
35 CImapConnectAndRefreshFolderList* CImapConnectAndRefreshFolderList::NewL( |
|
36 CImumInternalApi& aMailboxApi, TInt aPriority, TRequestStatus& aObserverRequestStatus, |
|
37 TMsvId aService, MMsvProgressReporter& aProgressReporter) |
|
38 { |
|
39 IMUM_STATIC_CONTEXT( CImapConnectAndRefreshFolderList::NewL, 0, mtm, KImumMtmLog ); |
|
40 IMUM_IN(); |
|
41 |
|
42 CImapConnectAndRefreshFolderList* self=new (ELeave) CImapConnectAndRefreshFolderList |
|
43 (aMailboxApi, aPriority, aObserverRequestStatus, aService, aProgressReporter); |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(KUidMsgTypeIMAP4); |
|
46 CleanupStack::Pop(); |
|
47 IMUM_OUT(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
|
52 // CImapConnectAndRefreshFolderList |
|
53 // ---------------------------------------------------------------------------- |
|
54 CImapConnectAndRefreshFolderList::CImapConnectAndRefreshFolderList( |
|
55 CImumInternalApi& aMailboxApi, TInt aPriority, TRequestStatus& aObserverRequestStatus, |
|
56 TMsvId aService, MMsvProgressReporter& aProgressReporter) |
|
57 : CImumOnlineOperation(aMailboxApi, aPriority, aObserverRequestStatus, aProgressReporter) |
|
58 { |
|
59 IMUM_CONTEXT( CImapConnectAndRefreshFolderList::CImapConnectAndRefreshFolderList, 0, KImumMtmLog ); |
|
60 IMUM_IN(); |
|
61 |
|
62 iService=aService; |
|
63 IMUM_OUT(); |
|
64 }; |
|
65 |
|
66 // ---------------------------------------------------------------------------- |
|
67 // ConstructL |
|
68 // ---------------------------------------------------------------------------- |
|
69 void CImapConnectAndRefreshFolderList::ConstructL(TUid aMtm) |
|
70 { |
|
71 IMUM_CONTEXT( CImapConnectAndRefreshFolderList::ConstructL, 0, KImumMtmLog ); |
|
72 IMUM_IN(); |
|
73 |
|
74 BaseConstructL(aMtm); // Adds us to the scheduler, creates us |
|
75 // an MtmUi, sets progress reporter width |
|
76 |
|
77 iOperation=CImapConnectionOp::NewL( |
|
78 iMailboxApi.MsvSession(), CActive::EPriorityStandard, |
|
79 iStatus, iService, iReporter, |
|
80 CImapConnectionOp::ECompleteAfterConnect ); |
|
81 |
|
82 iObserverRequestStatus=KRequestPending; |
|
83 SetActive(); |
|
84 IMUM_OUT(); |
|
85 } |
|
86 |
|
87 // ---------------------------------------------------------------------------- |
|
88 // ~CImapConnectAndRefreshFolderList |
|
89 // ---------------------------------------------------------------------------- |
|
90 CImapConnectAndRefreshFolderList::~CImapConnectAndRefreshFolderList() |
|
91 { |
|
92 IMUM_CONTEXT( CImapConnectAndRefreshFolderList::~CImapConnectAndRefreshFolderList, 0, KImumMtmLog ); |
|
93 IMUM_IN(); |
|
94 IMUM_OUT(); |
|
95 |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------------------------------- |
|
99 // GetErrorProgressL |
|
100 // ---------------------------------------------------------------------------- |
|
101 const TDesC8& CImapConnectAndRefreshFolderList::GetErrorProgressL(TInt aError) |
|
102 { |
|
103 IMUM_CONTEXT( CImapConnectAndRefreshFolderList::GetErrorProgressL, 0, KImumMtmLog ); |
|
104 IMUM_IN(); |
|
105 |
|
106 TImap4GenericProgress& genProgress=iProgressBuf().iGenericProgress; |
|
107 genProgress.iErrorCode=aError; |
|
108 |
|
109 switch(iState) |
|
110 { |
|
111 case EConnecting: |
|
112 // RunL left while trying to initiate a refresh... |
|
113 genProgress.iOperation=TImap4GenericProgress::ESync; |
|
114 genProgress.iState=TImap4GenericProgress::ESyncing; |
|
115 break; |
|
116 case EDisconnecting: |
|
117 // If a RunL leave occurred after disconnection, no problem... |
|
118 genProgress.iErrorCode=KErrNone; |
|
119 // Fall through |
|
120 case ERefreshing: |
|
121 // RunL left while trying to initiate a disconnect... |
|
122 genProgress.iOperation=TImap4GenericProgress::EDisconnect; |
|
123 genProgress.iState=TImap4GenericProgress::EDisconnecting; |
|
124 break; |
|
125 default: |
|
126 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiBadStateInFolderListOp); |
|
127 } |
|
128 IMUM_OUT(); |
|
129 return iProgressBuf; |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------------------------- |
|
133 // DoRunL |
|
134 // ---------------------------------------------------------------------------- |
|
135 void CImapConnectAndRefreshFolderList::DoRunL() |
|
136 { |
|
137 IMUM_CONTEXT( CImapConnectAndRefreshFolderList::DoRunL, 0, KImumMtmLog ); |
|
138 IMUM_IN(); |
|
139 |
|
140 if(GetOperationCompletionCodeL()!=KErrNone || iState==EDisconnecting) |
|
141 { |
|
142 iState=ECompleted; |
|
143 CompleteObserver(); |
|
144 return; |
|
145 } |
|
146 |
|
147 switch(iState) |
|
148 { |
|
149 case EConnecting: |
|
150 // We have successfully completed connecting |
|
151 delete iOperation; |
|
152 iOperation=NULL; |
|
153 InvokeClientMtmAsyncFunctionL(KIMAP4MTMSyncTree, iService, iService); |
|
154 iState=ERefreshing; |
|
155 SetActive(); |
|
156 break; |
|
157 case ERefreshing: |
|
158 // We have successfully completed refreshing the folder list |
|
159 delete iOperation; |
|
160 iOperation=NULL; |
|
161 iOperation=CImumDisconnectOperation::NewL(iMailboxApi, |
|
162 iStatus, iReporter, iService, KIMAP4MTMDisconnect, iMtm); |
|
163 iState=EDisconnecting; |
|
164 SetActive(); |
|
165 break; |
|
166 default: |
|
167 User::Panic(KImumMtmUiPanic,EIMAP4MtmUiBadStateInFolderListOp); |
|
168 }; |
|
169 IMUM_OUT(); |
|
170 } |
|
171 |
|
172 // End of File |
|
173 |