|
1 /* |
|
2 * Copyright (c) 2008 - 20010 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: handles interface to CenRep settings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMAILCPSSETTINGS_H_ |
|
20 #define CMAILCPSSETTINGS_H_ |
|
21 |
|
22 #include "PSSubscriber.h" |
|
23 #include "PSSubscribeHandler.h" |
|
24 |
|
25 class CRepository; |
|
26 class CMailExternalAccount; |
|
27 |
|
28 /* |
|
29 * Callback interface for observer |
|
30 * |
|
31 * @lib fsmailserver.exe |
|
32 * @since S60 v5.1 |
|
33 */ |
|
34 class MMailCpsSettingsCallback |
|
35 { |
|
36 public: |
|
37 /** |
|
38 * Callback from CMailCpsSettings class |
|
39 * Informs that settings have changed |
|
40 * |
|
41 * @since S60 v5.1 |
|
42 */ |
|
43 virtual void SettingsChangedCallback() = 0; |
|
44 }; |
|
45 |
|
46 /** |
|
47 * CMail ContentPublishingService Settings Handler class |
|
48 * Class implementing interface towards cenrep and email widget settings |
|
49 * |
|
50 * @lib fsmailserver.exe |
|
51 * @since S60 v5.1 |
|
52 */ |
|
53 NONSHARABLE_CLASS( CMailCpsSettings ) : public CActive, |
|
54 public MPSSubscribeHandler |
|
55 { |
|
56 public: |
|
57 /** |
|
58 * Two-phased constructor. |
|
59 * @param aMailClient reference to CFSMailClient class. Mailserver offers |
|
60 * this for all handlers in order to prevent parallel instantiation |
|
61 */ |
|
62 static CMailCpsSettings* NewL( CFSMailClient& aMailClient ); |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 virtual ~CMailCpsSettings(); |
|
68 |
|
69 /** |
|
70 * Starts observing CenRep changes |
|
71 * @param aObserver will be callbacked once changes occur |
|
72 */ |
|
73 void StartObservingL( MMailCpsSettingsCallback* aObserver ); |
|
74 |
|
75 /** |
|
76 * Stops observing CenRep changes |
|
77 */ |
|
78 void StopObserving(); |
|
79 |
|
80 /** |
|
81 * Gets array of mailboxes that should be published to widget |
|
82 * @return array of mailboxes |
|
83 */ |
|
84 RArray<TFSMailMsgId>& Mailboxes(); |
|
85 |
|
86 /** |
|
87 * Gets array of external mailboxes from widget settings |
|
88 * @param aAccounts on completion, contains the necessary information of |
|
89 * external mailboxes that currently should have a widget |
|
90 * transfers ownership of accounts to caller |
|
91 */ |
|
92 void GetExtMailboxesL( RPointerArray<CMailExternalAccount>& aAccounts ); |
|
93 |
|
94 /** |
|
95 * Adds mailbox to widget settings |
|
96 * Method ensures that same mailbox is not added again, if it happens |
|
97 * to exist already in the settings. If already exists, method simply returns without |
|
98 * doing nothing. |
|
99 * @param aMailbox Id of the mailbox to add to settings |
|
100 */ |
|
101 void AddMailboxL( const TFSMailMsgId aMailbox ); |
|
102 |
|
103 /** |
|
104 * Removes mailbox from widget settings |
|
105 * @param aMailbox Id of the mailbox to remove from settings |
|
106 */ |
|
107 void RemoveMailboxL( const TFSMailMsgId aMailbox ); |
|
108 |
|
109 /** |
|
110 * Gets maximum row count |
|
111 * @return maximum row count |
|
112 */ |
|
113 TInt MaxRowCount(); |
|
114 |
|
115 /** |
|
116 * Gets maximum mailbox count |
|
117 * @return maximum mailbox count |
|
118 */ |
|
119 TInt MaxMailboxCount(); |
|
120 |
|
121 /** |
|
122 * |
|
123 * @return |
|
124 */ |
|
125 void AssociateWidgetToSetting( const TDesC& aContentId, |
|
126 const TFSMailMsgId aMailbox ); |
|
127 |
|
128 /** |
|
129 * |
|
130 */ |
|
131 void DissociateWidgetFromSettingL( const TDesC& aContentId ); |
|
132 |
|
133 /** |
|
134 * |
|
135 */ |
|
136 void GetContentId( TInt aMailboxId, TInt aNext, TDes16& aValue ); |
|
137 |
|
138 /** |
|
139 * |
|
140 */ |
|
141 TInt WidgetCountByMailbox( TInt aMailboxId ); |
|
142 |
|
143 /** |
|
144 * |
|
145 */ |
|
146 TBool IsSelected( TInt aId ); |
|
147 |
|
148 /** |
|
149 * |
|
150 */ |
|
151 TUint GetMailboxUidByContentId( const TDesC& aContentId ); |
|
152 |
|
153 /** |
|
154 * |
|
155 */ |
|
156 TUint GetPluginUidByContentId( const TDesC& aContentId ); |
|
157 |
|
158 /** |
|
159 * Gets a bitmasked configuration value (see cmailwidgetcenrepkeysinternal.h) |
|
160 * @return bitmasked configuration value |
|
161 */ |
|
162 TInt32 Configuration(); |
|
163 |
|
164 /** |
|
165 * Return total number of all native mailboxes in the system |
|
166 */ |
|
167 TInt TotalIntMailboxCount(); |
|
168 |
|
169 |
|
170 /** |
|
171 * |
|
172 */ |
|
173 TBool FindFromContentIdListL( const TDesC& aContentId ); |
|
174 |
|
175 /** |
|
176 * |
|
177 */ |
|
178 void AddToContentIdListL( const TDesC& aContentId ); |
|
179 |
|
180 /** |
|
181 * |
|
182 */ |
|
183 void RemoveFromContentIdListL( const TDesC& aContentId ); |
|
184 |
|
185 /** |
|
186 * |
|
187 */ |
|
188 void ToggleWidgetNewMailIconL( TBool aIconOn, const TFSMailMsgId& aMailBox ); |
|
189 |
|
190 /** |
|
191 * |
|
192 */ |
|
193 TBool GetNewMailStateL( const TFSMailMsgId& aMailBox, TInt aUnreadCount ); |
|
194 |
|
195 /** |
|
196 * Find next free CenRep key to store setting. |
|
197 * @param aContentId Id of widget instance |
|
198 * @return true if account is associated to content id, false if not |
|
199 */ |
|
200 TBool Associated( const TDesC& aContentId ); |
|
201 |
|
202 /** |
|
203 * Callback from PSSubscriber about a PS key event |
|
204 * @param aCategory defines the key category |
|
205 * @param aKey defines the changed key |
|
206 */ |
|
207 void HandlePropertyChangedL( const TUid& aCategory, TInt aKey ); |
|
208 |
|
209 /** |
|
210 * |
|
211 */ |
|
212 TBool BackupOrRestoreMode(); |
|
213 |
|
214 protected: |
|
215 /** |
|
216 * From CActive |
|
217 * Cancellation logic for the asynchronous request |
|
218 * |
|
219 * @since S60 v5.0 |
|
220 */ |
|
221 virtual void DoCancel(); |
|
222 |
|
223 /** |
|
224 * From CActive |
|
225 * |
|
226 * @since S60 v5.0 |
|
227 */ |
|
228 virtual void RunL(); |
|
229 |
|
230 private: |
|
231 /** |
|
232 * Constructor |
|
233 * @param aMailClient reference to CFSMailClient class. Mailserver offers |
|
234 * this for all handlers in order to prevent parallel instantiation |
|
235 */ |
|
236 CMailCpsSettings( CFSMailClient& aMailClient ); |
|
237 |
|
238 void ConstructL(); |
|
239 |
|
240 /** |
|
241 * Restarts observing after previous notification request was triggered |
|
242 */ |
|
243 void StartObservingL(); |
|
244 |
|
245 /** |
|
246 * Loads settings from CenRep |
|
247 */ |
|
248 void LoadSettingsL(); |
|
249 |
|
250 /** |
|
251 * Loads configuration data from CenRep |
|
252 * (This data contains internal configuration data for publishing logic |
|
253 * and should not be mixed with user modifiable settings) |
|
254 */ |
|
255 void LoadConfigurationL(); |
|
256 |
|
257 /** |
|
258 * Resolves mailbox based on mailbox id |
|
259 * (mailbox id is stored in CenRep as integer) |
|
260 * |
|
261 * @param aMailboxId mailboxId from CenRep |
|
262 * @param aMsg on completion, contains the mailbox Id in TFSMailMsgId format |
|
263 * @return KErrNone if mailbox exists |
|
264 * @return KErrNotFound if aValue points to non-existent mailbox |
|
265 */ |
|
266 TInt ResolveMailbox( const TInt aMailboxId, TFSMailMsgId& aMsg ); |
|
267 |
|
268 /** |
|
269 * Finds mailbox if plugin id is set - more efficient than Resolve mailbox |
|
270 * |
|
271 * @param aMsg mailbox both PluginId and Id is checked |
|
272 * @return KErrNone if mailbox exists |
|
273 * @return KErrNotFound aMsg.Id() points to non-existent mailbox |
|
274 **/ |
|
275 TInt CheckMailboxExistence( TFSMailMsgId& aMsg ); |
|
276 |
|
277 /** |
|
278 * Gets array of CenRep keys representing mailboxes configured to widget |
|
279 * @param aKeys array of keys |
|
280 */ |
|
281 void GetMailboxNonZeroKeysL( RArray<TUint32>& aKeys ); |
|
282 |
|
283 /** |
|
284 * Gets all the external mailbox identifiers |
|
285 * @param on completion, contains an array of cenrep keys that have an external |
|
286 * account specified (i.e. not empty) |
|
287 */ |
|
288 void GetExtMailboxNonZeroKeysL( RArray<TUint32>& aKeys ); |
|
289 |
|
290 /** |
|
291 * Find next free CenRep key to store setting. |
|
292 * @param aContentId Id of widget instance |
|
293 */ |
|
294 TInt GetSettingToAssociate( const TDesC& aContentId ); |
|
295 |
|
296 /** |
|
297 * Returns CMailExternalAccount::NewL() according to cenrep key aKey |
|
298 * @param aKey |
|
299 */ |
|
300 CMailExternalAccount* GetExtMailboxL( TInt aKey ); |
|
301 |
|
302 private: // data |
|
303 // reference to mailclient |
|
304 CFSMailClient& iMailClient; |
|
305 // pointer to central repository |
|
306 CRepository* iCenRep; |
|
307 // callback interface |
|
308 MMailCpsSettingsCallback* iObserver; |
|
309 // array of mailboxes |
|
310 RArray<TFSMailMsgId> iMailboxArray; |
|
311 // Internal configuration data |
|
312 TInt32 iConfigData; |
|
313 // large buffer for reading cenrep data |
|
314 TBuf<KMaxFileName> iCenrepText; |
|
315 // PubSub subsriber for notifying restore operation |
|
316 CPSSubscriber* iBackupRestoreSubscriber; |
|
317 // Indicates if restore operation is started |
|
318 TBool iRestoreStarted; |
|
319 // Indicates if backup operation is ongoing |
|
320 TBool iBackupOngoing; |
|
321 }; |
|
322 |
|
323 #endif /*CMAILCPSSETTINGS_H_*/ |