|
1 /* |
|
2 * Copyright (c) 2008 - 2009 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 class CRepository; |
|
23 |
|
24 /* |
|
25 * Callback interface for observer |
|
26 * |
|
27 * @lib fsmailserver.exe |
|
28 * @since S60 v5.1 |
|
29 */ |
|
30 class MMailCpsSettingsCallback |
|
31 { |
|
32 public: |
|
33 /** |
|
34 * Callback from CMailCpsSettings class |
|
35 * Informs that settings have changed |
|
36 * |
|
37 * @since S60 v5.1 |
|
38 */ |
|
39 virtual void SettingsChangedCallback() = 0; |
|
40 }; |
|
41 |
|
42 /** |
|
43 * CMail ContentPublishingService Settings Handler class |
|
44 * Class implementing interface towards cenrep and email widget settings |
|
45 * |
|
46 * @lib fsmailserver.exe |
|
47 * @since S60 v5.1 |
|
48 */ |
|
49 NONSHARABLE_CLASS( CMailCpsSettings ) : public CActive |
|
50 { |
|
51 public: |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 * @param aMailClient reference to CFSMailClient class. Mailserver offers |
|
55 * this for all handlers in order to prevent parallel instantiation |
|
56 */ |
|
57 static CMailCpsSettings* NewL( CFSMailClient& aMailClient ); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 virtual ~CMailCpsSettings(); |
|
63 |
|
64 /** |
|
65 * Starts observing CenRep changes |
|
66 * @param aObserver will be callbacked once changes occur |
|
67 */ |
|
68 void StartObservingL( MMailCpsSettingsCallback* aObserver ); |
|
69 |
|
70 /** |
|
71 * Stops observing CenRep changes |
|
72 */ |
|
73 void StopObserving(); |
|
74 |
|
75 /** |
|
76 * Gets array of mailboxes that should be published to widget |
|
77 * @return array of mailboxes |
|
78 */ |
|
79 RArray<TFSMailMsgId>& Mailboxes(); |
|
80 |
|
81 /** |
|
82 * Adds mailbox to widget settings |
|
83 * Method ensures that same mailbox is not added again, if it happens |
|
84 * to exist already in the settings. If already exists, method simply returns without |
|
85 * doing nothing. |
|
86 * @param aMailbox Id of the mailbox to add to settings |
|
87 */ |
|
88 void AddMailboxL( const TFSMailMsgId aMailbox ); |
|
89 |
|
90 /** |
|
91 * Removes mailbox from widget settings |
|
92 * @param aMailbox Id of the mailbox to remove from settings |
|
93 */ |
|
94 void RemoveMailboxL( const TFSMailMsgId aMailbox ); |
|
95 |
|
96 /** |
|
97 * Removes mailbox from widget settings |
|
98 * @param aIndex refers to index in mailbox array that is returned by |
|
99 * CMailCpsSettings::Mailboxes() |
|
100 */ |
|
101 void RemoveMailboxL( const TInt aIndex ); |
|
102 |
|
103 /** |
|
104 * Gets maximum row count |
|
105 * @return maximum row count |
|
106 */ |
|
107 TInt MaxRowCount(); |
|
108 |
|
109 /** |
|
110 * Gets maximum mailbox count |
|
111 * @return maximum mailbox count |
|
112 */ |
|
113 TInt MaxMailboxCount(); |
|
114 |
|
115 /** |
|
116 * |
|
117 * @return |
|
118 */ |
|
119 TBool AssociateWidgetToSetting( const TDesC& aContentId ); |
|
120 |
|
121 /** |
|
122 * |
|
123 */ |
|
124 void DissociateWidgetFromSetting( const TDesC& aContentId ); |
|
125 |
|
126 /** |
|
127 * |
|
128 */ |
|
129 void GetContentId( TInt aId, TDes16& aValue ); |
|
130 |
|
131 /** |
|
132 * |
|
133 */ |
|
134 TBool IsSelected( TInt aId ); |
|
135 |
|
136 /** |
|
137 * |
|
138 */ |
|
139 TUint GetMailboxUidByContentId( const TDesC& aContentId ); |
|
140 |
|
141 /** |
|
142 * |
|
143 */ |
|
144 TUint GetPluginUidByContentId( const TDesC& aContentId ); |
|
145 |
|
146 /** |
|
147 * Gets a bitmasked configuration value (see cmailwidgetcenrepkeysinternal.h) |
|
148 * @return bitmasked configuration value |
|
149 */ |
|
150 TInt32 Configuration(); |
|
151 |
|
152 /** |
|
153 * |
|
154 */ |
|
155 TInt GetTotalMailboxCount(); |
|
156 |
|
157 protected: |
|
158 /** |
|
159 * From CActive |
|
160 * Cancellation logic for the asynchronous request |
|
161 * |
|
162 * @since S60 v5.0 |
|
163 */ |
|
164 virtual void DoCancel(); |
|
165 |
|
166 /** |
|
167 * From CActive |
|
168 * |
|
169 * @since S60 v5.0 |
|
170 */ |
|
171 virtual void RunL(); |
|
172 |
|
173 private: |
|
174 /** |
|
175 * Constructor |
|
176 * @param aMailClient reference to CFSMailClient class. Mailserver offers |
|
177 * this for all handlers in order to prevent parallel instantiation |
|
178 */ |
|
179 CMailCpsSettings( CFSMailClient& aMailClient ); |
|
180 |
|
181 void ConstructL(); |
|
182 |
|
183 /** |
|
184 * Restarts observing after previous notification request was triggered |
|
185 */ |
|
186 void StartObservingL(); |
|
187 |
|
188 /** |
|
189 * Loads settings from CenRep |
|
190 */ |
|
191 void LoadSettingsL(); |
|
192 |
|
193 /** |
|
194 * Loads configuration data from CenRep |
|
195 * (This data contains internal configuration data for publishing logic |
|
196 * and should not be mixed with user modifiable settings) |
|
197 */ |
|
198 void LoadConfigurationL(); |
|
199 |
|
200 /** |
|
201 * Resolves mailbox based on mailbox id |
|
202 * (mailbox id is stored in CenRep as integer) |
|
203 * |
|
204 * @param aMailboxId mailboxId from CenRep |
|
205 * @param aMsg on completion, contains the mailbox Id in TFSMailMsgId format |
|
206 * @return KErrNone if mailbox exists |
|
207 * @return KErrNotFound if aValue points to non-existent mailbox |
|
208 */ |
|
209 TInt ResolveMailbox( const TInt aMailboxId, TFSMailMsgId& aMsg ); |
|
210 |
|
211 /** |
|
212 * Gets array of CenRep keys representing mailboxes configured to widget |
|
213 * @param aKeys array of keys |
|
214 */ |
|
215 void GetMailboxNonZeroKeysL( RArray<TUint32>& aKeys ); |
|
216 |
|
217 /** |
|
218 * |
|
219 * @param aContentId |
|
220 */ |
|
221 TBool IsAlreadyAssociated( const TDesC& aContentId ); |
|
222 |
|
223 /** |
|
224 * |
|
225 */ |
|
226 TUint32 GetSettingToAssociate(); |
|
227 |
|
228 private: // data |
|
229 // reference to mailclient |
|
230 CFSMailClient& iMailClient; |
|
231 // pointer to central repository |
|
232 CRepository* iCenRep; |
|
233 // callback interface |
|
234 MMailCpsSettingsCallback* iObserver; |
|
235 // array of mailboxes |
|
236 RArray<TFSMailMsgId> iMailboxArray; |
|
237 // Internal configuration data |
|
238 TInt32 iConfigData; |
|
239 }; |
|
240 |
|
241 #endif /*CMAILCPSSETTINGS_H_*/ |