|
1 /* |
|
2 * Copyright (c) 2008 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 * Base class for always online mail syncing and fetchin operations |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef IPSSOSAOBASEAGENT_H_ |
|
21 #define IPSSOSAOBASEAGENT_H_ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <msvapi.h> |
|
25 #include <SendUiConsts.h> |
|
26 |
|
27 #include "ipsplgcommon.h" |
|
28 |
|
29 class CIpsSetDataApi; |
|
30 class CIpsSosAOImapSyncOp; |
|
31 class CImImap4Settings; |
|
32 class MIpsAOObserverNotifyInterface; |
|
33 class TIpsPlgPropertyEvent; |
|
34 |
|
35 const TInt KIpsSosAOTextBufferSize = 200; |
|
36 |
|
37 /** |
|
38 * class MIpsSosAOAgentOperationResponse; |
|
39 * |
|
40 * Interface for operation completion call backs |
|
41 * |
|
42 */ |
|
43 class MIpsSosAOAgentOperationResponse |
|
44 { |
|
45 public: |
|
46 virtual void OperationCompletedL( TInt aError ) = 0; |
|
47 }; |
|
48 |
|
49 |
|
50 /** |
|
51 * class CIpsSosAOBaseAgent |
|
52 * |
|
53 * Base class for always online mailbox syncing and fetching logic. |
|
54 * Offer interface for ao mbox logic class to hide symbian spesific |
|
55 * mail sync and fetch logic. |
|
56 * Created by IpsSosAOMboxLogic only ones, is active when asyncronic operation |
|
57 * is running. Instance of this class is mailbox spesific. |
|
58 * |
|
59 * @lib ipssosaoplugin.lib |
|
60 */ |
|
61 class CIpsSosAOBaseAgent : public CActive |
|
62 { |
|
63 |
|
64 public: // enums |
|
65 |
|
66 enum TAgentState |
|
67 { |
|
68 EStateConnectAndSync, |
|
69 EStateConnectAndSyncOnHold, |
|
70 EStateRefreshFolderArray, |
|
71 EStatePopulateAll, |
|
72 EStatePopulateOnHold, |
|
73 EStateFetchOngoing, |
|
74 EStateFetchOnHold, |
|
75 EStateDisconnect, |
|
76 EStateCompleted, |
|
77 EStateSuspended, |
|
78 EStateIdle }; |
|
79 |
|
80 public: |
|
81 |
|
82 /** |
|
83 * Creates CIpsSosAOImapAgent or CIpsSosAOPopAgent according to type |
|
84 * of service, return value is casted to CIpsSosAOBaseAgent type object |
|
85 * @param aSession valid msv session reference |
|
86 * @parem aOpResponse interface class to async operation response call backs |
|
87 * @param aServiceId id of mailbox |
|
88 * @return CIpsSisAOBaseAgent pointer |
|
89 */ |
|
90 static CIpsSosAOBaseAgent* CreateAgentL( |
|
91 CMsvSession& aSession, |
|
92 MIpsSosAOAgentOperationResponse& aOpResponse, |
|
93 TMsvId aServiceId ); |
|
94 |
|
95 /* |
|
96 * Destructor |
|
97 */ |
|
98 virtual ~CIpsSosAOBaseAgent(); |
|
99 |
|
100 /** |
|
101 * Checks from mtm uid is this agent imap agent, |
|
102 * mtm uid is set in constructor |
|
103 * @return ETrue if uid is IMAP, EFalse in other case |
|
104 */ |
|
105 TBool IsTypeImap4() const; |
|
106 |
|
107 /** |
|
108 * Gets FS plugin id related to protocol |
|
109 * @return FS plugin id |
|
110 */ |
|
111 TInt GetFSPluginId() const; |
|
112 |
|
113 /** |
|
114 * Signals mailbox sync to started via P&S (Publish & Subscribe) mechanism |
|
115 * @param aMailbox id of the mailbox which sync is started |
|
116 */ |
|
117 void SignalSyncStarted( TInt aMailbox ); |
|
118 |
|
119 /** |
|
120 * Signals mailbox sync to completed via P&S mechanism |
|
121 * @param aMailbox id of the mailbox which sync is competed |
|
122 * @param aError sync completion error code |
|
123 */ |
|
124 void SignalSyncCompleted( TInt aMailbox, TInt aError ); |
|
125 |
|
126 /** |
|
127 * Gets incoming server address from (symbian side) mailbox settings |
|
128 * NOTE: LoadSettingsL should be called before this in some point or |
|
129 * parameter is unchanged |
|
130 * @param aIncomingServer modifiable buffer where address is written |
|
131 */ |
|
132 virtual void GetServerAddress( |
|
133 TBuf<KIpsSosAOTextBufferSize>& aIncomingServer ) const = 0; |
|
134 |
|
135 /** |
|
136 * Gets mail account username from (symbian side) mailbox settings |
|
137 * NOTE: LoadSettingsL should be called before this in some point or |
|
138 * parameter is unchanged |
|
139 * @param aUsername modifiable buffer where username is written |
|
140 */ |
|
141 virtual void GetUsername( |
|
142 TBuf8<KIpsSosAOTextBufferSize>& aUsername ) const = 0; |
|
143 |
|
144 /** |
|
145 * Gets mailbox connection status |
|
146 * @return ETrue if mailbox is connected |
|
147 */ |
|
148 virtual TBool IsConnected() const = 0; |
|
149 |
|
150 /** |
|
151 * Starts mailbox sync asynchronically, sync completion is informed via |
|
152 * MIpsSosAOAgentOperationResponse interface |
|
153 */ |
|
154 virtual void StartSyncL() = 0; |
|
155 |
|
156 /** |
|
157 * Starts message fetch asynchronically, fetch completion is informed via |
|
158 * MIpsSosAOAgentOperationResponse interface |
|
159 * NOTE: this is not used in FS EMail 2.0, this is for later usege, mainly |
|
160 * for case if AO have to support IMAP-IDLE |
|
161 * @param aFetchMsgArray array of message ids to be fethced |
|
162 */ |
|
163 virtual void StartFetchMessagesL( const RArray<TMsvId>& aFetchMsgArray ) = 0; |
|
164 |
|
165 /** |
|
166 * Cancel all ongoing operations and disconnects the service if it's connected |
|
167 */ |
|
168 virtual void CancelAllAndDisconnectL() = 0; |
|
169 |
|
170 /** |
|
171 * Cancel all ongoing operations but not disconnect service, is used when |
|
172 * another operation should started for ex. user starts message fetching from ui |
|
173 * during always online sync |
|
174 */ |
|
175 virtual void CancelAllAndDoNotDisconnect() = 0; |
|
176 |
|
177 /** |
|
178 * Sets agent not to disconnect after operation is completed. |
|
179 */ |
|
180 virtual void DoNotDisconnect() = 0; |
|
181 |
|
182 /* |
|
183 * Clears not to disconnect flag |
|
184 */ |
|
185 virtual void ClearDoNotDisconnect() = 0; |
|
186 |
|
187 /* |
|
188 * Cancels ongoing operation and puts agent on hold state |
|
189 */ |
|
190 virtual void HoldOperations() = 0; |
|
191 |
|
192 /* |
|
193 * Continues operation that was cancelled when holded operations, |
|
194 * Does nothing if there's agent is not on hold state |
|
195 */ |
|
196 virtual void ContinueHoldOperations() = 0; |
|
197 |
|
198 /* |
|
199 * Gets current agent state |
|
200 */ |
|
201 virtual TAgentState GetState() const = 0; |
|
202 |
|
203 /* |
|
204 * Loads settings |
|
205 */ |
|
206 virtual void LoadSettingsL() = 0; |
|
207 |
|
208 protected: |
|
209 |
|
210 /* |
|
211 * Constructor |
|
212 */ |
|
213 CIpsSosAOBaseAgent(); |
|
214 |
|
215 /* |
|
216 * Clears flag that informs is some event signaled via P&S by this agent instance |
|
217 */ |
|
218 void ClearSignaledFlags(); |
|
219 |
|
220 private: |
|
221 |
|
222 /* |
|
223 * Sets new P&S property |
|
224 */ |
|
225 void SetPropertyEvent( |
|
226 TInt aEvent, |
|
227 TInt aMailbox, |
|
228 TInt aError ); |
|
229 |
|
230 private: |
|
231 |
|
232 TBool iSyncStartedSignaled; |
|
233 TUid iMtmType; |
|
234 TPckgBuf<TIpsPlgPropertyEvent> iPropertyBuf; |
|
235 |
|
236 }; |
|
237 |
|
238 #endif /*IPSSOSAOBASEAGENT_H_*/ |