|
1 /* |
|
2 * Copyright (c) 2002 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 * Imap agent implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef __ALWAYSONLINEIMAPAGENT_H__ |
|
20 #define __ALWAYSONLINEIMAPAGENT_H__ |
|
21 |
|
22 #include "AlwaysOnlineEmailAgentBase.h" |
|
23 #include "AlwaysOnlineImap4FolderObserver.h" |
|
24 #include "AlwaysOnlineEmailFlags.h" |
|
25 |
|
26 #include <mtclreg.h>//ClientMtmRegistry |
|
27 #include <impcmtm.h>//imapclientmtm |
|
28 #include <imapconnectionobserver.h> |
|
29 |
|
30 |
|
31 |
|
32 enum |
|
33 { |
|
34 EAlwaysOnlineImap4ThisHasBeenSynced = 0x01, |
|
35 EAlwaysOnlineImap4StayOnline = 0x02, |
|
36 EAlwaysOnlineImap4StartFetchAfterFolderSync = 0x04, |
|
37 EAlwaysOnlineImap4DontReconnect = 0x08, |
|
38 EAlwaysOnlineImap4RemoveMeImmediately = 0x10, |
|
39 EAlwaysOnlineImap4TemporaryConnectionObserver = 0x20, |
|
40 EAlwaysOnlineImap4DontRemoveOnDisconnect = 0x40 |
|
41 }; |
|
42 |
|
43 |
|
44 /** |
|
45 * CAlwaysOnlineImap4Agent |
|
46 * |
|
47 * Class takes care of IMAP mailbox "always" online logic |
|
48 */ |
|
49 class CAlwaysOnlineImap4Agent : |
|
50 public CAlwaysOnlineEmailAgentBase, |
|
51 public MMsvImapConnectionObserver, |
|
52 public MAlwaysOnlineImap4FolderObserver |
|
53 { |
|
54 public: |
|
55 |
|
56 |
|
57 /** |
|
58 * NewL |
|
59 * Two phased constructor |
|
60 * @param CMsvSession&, session reference |
|
61 * @param CClientMtmRegistry&, mtm registry reference |
|
62 * @param TMsvId, mailbox id |
|
63 * @param MAlwaysOnlineStatusQueryInterface&, status query interface |
|
64 * @param CAlwaysOnlineEmailAgent&, email agent reference |
|
65 * @return CAlwaysOnlineImap4Agent*, self pointer |
|
66 */ |
|
67 static CAlwaysOnlineImap4Agent* NewL( CMsvSession& aSession, |
|
68 CClientMtmRegistry& aClientMtmRegistry, |
|
69 TMsvId aMailboxId, |
|
70 MAlwaysOnlineStatusQueryInterface& aAlwaysOnlineManager, |
|
71 CAlwaysOnlineEmailAgent& aEmailAgent ); |
|
72 |
|
73 /** |
|
74 * ~CAlwaysOnlineImap4Agent() |
|
75 * Destructor |
|
76 */ |
|
77 ~CAlwaysOnlineImap4Agent(); |
|
78 |
|
79 //from CAlwaysOnlineEmailAgentBase |
|
80 public: |
|
81 |
|
82 /** |
|
83 * StartL |
|
84 * from CAlwaysOnlineEmailAgentBase |
|
85 */ |
|
86 void StartL(); |
|
87 |
|
88 /** |
|
89 * ConnectAndUpdateHeadersL |
|
90 * from CAlwaysOnlineEmailAgentBase |
|
91 */ |
|
92 void ConnectAndUpdateHeadersL( ); |
|
93 |
|
94 |
|
95 /** |
|
96 * DisconnectL |
|
97 * from CAlwaysOnlineEmailAgentBase |
|
98 * @param TBool, automatic or manual disconnection |
|
99 */ |
|
100 void DisconnectL( TBool aAutomatic ); |
|
101 |
|
102 |
|
103 /** |
|
104 * ResumeL |
|
105 * Need to override this to update EAlwaysOnlineImap4StayOnline flag |
|
106 * from CAlwaysOnlineEmailAgentBase |
|
107 */ |
|
108 void ResumeL( const TBool aConnectNow = EFalse ); |
|
109 |
|
110 |
|
111 /** |
|
112 * HandleImapConnectionEvent |
|
113 * From MMsvImapConnectionObserver |
|
114 * @param TImapConnectionEvent, imap connection event |
|
115 */ |
|
116 virtual void HandleImapConnectionEvent( |
|
117 TImapConnectionEvent aConnectionEvent); |
|
118 |
|
119 /** |
|
120 * From MAlwaysOnlineImap4FolderObserver |
|
121 */ |
|
122 virtual void HandleFolderEntryL( const CMsvEntrySelection& aFolderArray ); |
|
123 |
|
124 /** |
|
125 * |
|
126 */ |
|
127 void SetUpdateMailWhileConnectedL( TBool aAgentAlreadyCreated ); |
|
128 |
|
129 protected: |
|
130 /** |
|
131 * ChangeNextStateL |
|
132 * from CAlwaysOnlineEmailAgentBase |
|
133 */ |
|
134 void ChangeNextStateL(); |
|
135 |
|
136 /** |
|
137 * HandleOpErrorL |
|
138 * from CAlwaysOnlineEmailAgentBase |
|
139 */ |
|
140 void HandleOpErrorL(); |
|
141 |
|
142 /** |
|
143 * DoSyncDisconnectL(), from emailagentbase |
|
144 * Does sync disconnect. Meant to be called from ResetAll(). |
|
145 * This is needed because this must not have imapact on state machine. |
|
146 */ |
|
147 void DoSyncDisconnectL(); |
|
148 |
|
149 /** |
|
150 * HandleOpCompleted |
|
151 * from CAlwaysOnlineEmailAgentBase |
|
152 * @param TMsvOp, id of completed operation |
|
153 * @param, TInt, completion code |
|
154 */ |
|
155 void HandleOpCompleted( TMsvOp opId, TInt aCompletionCode ); |
|
156 |
|
157 /** |
|
158 * CreateCompletedOpL |
|
159 * from CAlwaysOnlineEmailAgentBase |
|
160 */ |
|
161 void CreateCompletedOpL(); |
|
162 |
|
163 /** |
|
164 * SynchroniseNewL() |
|
165 */ |
|
166 void SynchroniseNewL(); |
|
167 |
|
168 |
|
169 private: |
|
170 |
|
171 /** |
|
172 * CAlwaysOnlineImap4Agent |
|
173 * C++ constructor |
|
174 * @param CMsvSession&, session reference |
|
175 * @param CClientMtmRegistry&, mtm registry reference |
|
176 * @param TMsvId, mailbox id |
|
177 * @param MAlwaysOnlineStatusQueryInterface&, status query interface |
|
178 * @param CAlwaysOnlineEmailAgent&, email agent reference |
|
179 */ |
|
180 CAlwaysOnlineImap4Agent( CMsvSession& aSession, |
|
181 CClientMtmRegistry& aClientMtmRegistry, |
|
182 MAlwaysOnlineStatusQueryInterface& aAlwaysOnlineManager, |
|
183 CAlwaysOnlineEmailAgent& aEmailAgent); |
|
184 |
|
185 /** |
|
186 * ConstructL |
|
187 * @param TMsvId, mailbox id |
|
188 */ |
|
189 void ConstructL( TMsvId aMailboxId ); |
|
190 |
|
191 /** |
|
192 * StartWaitTimerL |
|
193 * starts interval waiter. Does not handle schedule waits, only polling interval |
|
194 */ |
|
195 void StartWaitTimerL(); |
|
196 |
|
197 /** |
|
198 * CreateImap4OperationL |
|
199 * aFunctionId ignored and completed operation is created if aCompletedOperation is true. |
|
200 * @param TMsvOp&, this operation id is set in this function |
|
201 * @param TInt, function Id |
|
202 * @param TBool, ETrue if we want completed operation instead of real one |
|
203 */ |
|
204 void CreateImap4OperationL( |
|
205 TMsvOp& aOpId, TInt aFunctionId, TBool aCompletedOperation = EFalse ); |
|
206 |
|
207 /** |
|
208 * CreateImap4OperationL |
|
209 * aFunctionId ignored and completed operation is created if aCompletedOperation is true. |
|
210 * @param TInt, function Id |
|
211 * @param TBool, ETrue if we want completed operation instead of real one |
|
212 */ |
|
213 void CreateImap4OperationL( |
|
214 TInt aFunctionId, TBool aCompletedOperation = EFalse ); |
|
215 |
|
216 /** |
|
217 * FetchNewMailL |
|
218 */ |
|
219 TMsvOp FetchNewMailL(); |
|
220 |
|
221 /** |
|
222 * FindInboxL |
|
223 * @return TMsvId, folder if of inbox |
|
224 */ |
|
225 TMsvId FindInboxL(); |
|
226 |
|
227 /** |
|
228 * StartFolderSyncL() |
|
229 * Starts imap folder sync and sets timer to repeat |
|
230 */ |
|
231 void DoFolderSyncL(); |
|
232 |
|
233 |
|
234 /** |
|
235 * StartFolderSyncTimerL() |
|
236 * Starts timer for folder sync. |
|
237 */ |
|
238 void StartFolderSyncTimerL(); |
|
239 |
|
240 /** |
|
241 * Updates iFolderArray member |
|
242 * @since 2.6 |
|
243 */ |
|
244 void UpdateSubscribedFoldersL( |
|
245 TMsvId aServiceId ); |
|
246 |
|
247 /** |
|
248 * Updates iFolderArray member |
|
249 * @since 2.6 |
|
250 */ |
|
251 void DoUpdateSubscribedFoldersL( |
|
252 TMsvId aFolderId ); |
|
253 |
|
254 /** |
|
255 * Appends iFolderArray (except aInboxId) to given folder selection |
|
256 * @since 2.6 |
|
257 * @param aFolders: |
|
258 * @param aInboxId |
|
259 */ |
|
260 void AppendFolderArrayL( CMsvEntrySelection& aFolders, TMsvId aInboxId ); |
|
261 |
|
262 /** |
|
263 * |
|
264 * @since 2.6 |
|
265 */ |
|
266 void StartFolderObserverL(); |
|
267 |
|
268 /** |
|
269 * |
|
270 * @since 2.6 |
|
271 */ |
|
272 void StopFolderObserver(); |
|
273 |
|
274 /** |
|
275 * Starts folder populate operation for the given folders |
|
276 * @since 2.6 |
|
277 * @param aFolder: folders to be populated |
|
278 * @return operation id |
|
279 */ |
|
280 TMsvOp FetchNewMailFromSelectedFoldersL( const CMsvEntrySelection& aFolders ); |
|
281 |
|
282 |
|
283 /** |
|
284 * Sets flag for whether to stay online or disconnect. |
|
285 */ |
|
286 void SetStayOnlineFlagL(); |
|
287 |
|
288 /** |
|
289 * Is agent temporary? |
|
290 * @since S60 3.1 |
|
291 * @return ETrue, if EAlwaysOnlineImap4TemporaryConnectionObserver |
|
292 * flag is set. |
|
293 */ |
|
294 TBool IsTemporary() const; |
|
295 |
|
296 /** |
|
297 * Fills mail fetching options |
|
298 * |
|
299 * @since S60 v3.2 |
|
300 * @return mail fetching options |
|
301 */ |
|
302 TImImap4GetPartialMailInfo FillMailOptionsL(); |
|
303 |
|
304 //data |
|
305 private: |
|
306 CImap4ClientMtm* iImap4ClientMtm; |
|
307 CAlwaysOnlineImap4FolderObserver* iFolderObserver; // at the moment only inbox, should we add others also? |
|
308 CMsvEntrySelection* iFolderArray; // subscribed folders and last fetched mail |
|
309 TMsvId iInboxId; |
|
310 TAlwaysOnlineEmailFlags iImap4StateFlags; |
|
311 }; |
|
312 |
|
313 |
|
314 #endif |
|
315 //EOF |