|
1 /* |
|
2 * Copyright (c) 2005 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: Contact lists manager base |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CPENGCONTACTLISTMANAGERBASE_H__ |
|
20 #define __CPENGCONTACTLISTMANAGERBASE_H__ |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include "CPEngStoreEntry.h" |
|
25 #include "MPEngContactListSettingsManager.h" |
|
26 #include <e32base.h> |
|
27 #include <badesca.h> |
|
28 |
|
29 |
|
30 // CONSTANTS |
|
31 _LIT( KPEngContactListManagerSId, "contactlistmanager" ); |
|
32 |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class MPEngStorageManager; |
|
36 class CPEngContactListSettings; |
|
37 class CPEngContactListModBase; |
|
38 class MPEngListLibFactory; |
|
39 class CPEngSessionSlotId; |
|
40 |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 * List manager base class |
|
46 * Implements base storing features common to list manager |
|
47 * related classes |
|
48 * |
|
49 * @lib PEngListLib2 |
|
50 * @since 3.0 |
|
51 */ |
|
52 NONSHARABLE_CLASS( CPEngContactListManagerBase ): |
|
53 public CPEngStoreEntry, |
|
54 public MPEngContactListSettingsManager |
|
55 { |
|
56 public: // Two-phased constructors and destructor |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 virtual ~CPEngContactListManagerBase(); |
|
62 |
|
63 |
|
64 protected: // Protected constructors |
|
65 |
|
66 /** |
|
67 * C++ constructor. |
|
68 */ |
|
69 CPEngContactListManagerBase( MPEngListLibFactory& aFactory ); |
|
70 |
|
71 /** |
|
72 * Symbian 2nd phase constructor |
|
73 */ |
|
74 void ConstructL( const CPEngSessionSlotId& aSessionSlot ); |
|
75 |
|
76 |
|
77 |
|
78 public: // New public functions |
|
79 |
|
80 /** |
|
81 * Session Id |
|
82 * @since 3.0 |
|
83 * @return session Id |
|
84 */ |
|
85 const CPEngSessionSlotId& SessionId( ) const; |
|
86 |
|
87 /** |
|
88 * Increase ref count |
|
89 * |
|
90 * @since 3.0 |
|
91 */ |
|
92 void Open( ); |
|
93 |
|
94 |
|
95 |
|
96 public: // From MPEngContactListSettingsManager |
|
97 |
|
98 |
|
99 /** |
|
100 * Get Contact list settings |
|
101 * @see <MPEngContactListSettingsManager.h> |
|
102 */ |
|
103 CPEngContactListSettings* ContactListSettingsOrNull( |
|
104 const TDesC& aContactList ); |
|
105 |
|
106 |
|
107 /** |
|
108 * Add contact list settings observer |
|
109 * @see <MPEngContactListSettingsManager.h> |
|
110 */ |
|
111 void AddContactListSettingsObserverL( |
|
112 const MPEngContactListSettingsObserver* aObserver ); |
|
113 |
|
114 |
|
115 /** |
|
116 * Remove contact list settings observer |
|
117 * @see <MPEngContactListSettingsManager.h> |
|
118 */ |
|
119 void RemoveContactListSettingsObserver( |
|
120 const MPEngContactListSettingsObserver* aObserver ); |
|
121 |
|
122 |
|
123 /** |
|
124 * Remove model from the array of loaded models |
|
125 * @see <MPEngContactListSettingsManager.h> |
|
126 */ |
|
127 void RemoveModel( CPEngContactListModBase* aModel ); |
|
128 |
|
129 |
|
130 /** |
|
131 * Get domain of the logged user, |
|
132 * @see <MPEngContactListSettingsManager.h> |
|
133 */ |
|
134 const TDesC& UserDomain() const; |
|
135 |
|
136 |
|
137 /** |
|
138 * Store contact list settings |
|
139 * @see <MPEngContactListSettingsManager.h> |
|
140 */ |
|
141 void StoreSettingsL(); |
|
142 |
|
143 |
|
144 /** |
|
145 * Size of the storage for Contact list settings |
|
146 * @see <MPEngContactListSettingsManager.h> |
|
147 */ |
|
148 TInt& StoreSize( ); |
|
149 |
|
150 |
|
151 |
|
152 public: // Functions from CPEngStoreEntry |
|
153 |
|
154 /** |
|
155 * ExternalizeL provides way to externalize data from store entry. |
|
156 * @see <CPEngStoreEntry.h> |
|
157 */ |
|
158 void ExternalizeL( RWriteStream& aStream, |
|
159 TPEngStorageType aStorageType ) const; |
|
160 |
|
161 /** |
|
162 * InternalizeL provides way to internalise data to store entry. |
|
163 * @see <CPEngStoreEntry.h> |
|
164 */ |
|
165 void InternalizeL( RReadStream& aStream, |
|
166 TPEngStorageType aStorageType ); |
|
167 |
|
168 /** |
|
169 * This method is used to retrieve ID for storing. |
|
170 * @see <CPEngStoreEntry.h> |
|
171 */ |
|
172 const TDesC& StorageId() const; |
|
173 |
|
174 /** |
|
175 * This method is used to ask entry size in bytes. |
|
176 * @see <CPEngStoreEntry.h> |
|
177 */ |
|
178 TUint32 EntrySize() const; |
|
179 |
|
180 |
|
181 |
|
182 public: //Functions from CPEngStoreEntry / MPEngSIDChangeObserver |
|
183 |
|
184 /** |
|
185 * Handle change of the Storage IDs |
|
186 * @see <MPEngSIDChangeObserver.h> |
|
187 */ |
|
188 void HandleSIDsChangeL( CPtrCArray& aChangedSIDs ); |
|
189 |
|
190 /** |
|
191 * Called when SIDs notifier fails |
|
192 * @see <MPEngSIDChangeObserver.h> |
|
193 */ |
|
194 void HandleSIDNotifyError( TInt aError ); |
|
195 |
|
196 |
|
197 |
|
198 protected: // Contact lists management for derived classes |
|
199 |
|
200 /** |
|
201 * Find contact list settings |
|
202 * |
|
203 * @since 3.0 |
|
204 * @param aContactList contact list name |
|
205 * @return index in the settings array or KErrNotFound |
|
206 */ |
|
207 TInt FindContactListSettings( const TDesC& aContactList ) const; |
|
208 |
|
209 |
|
210 public: // Unit test cases need to use this method, therefore public |
|
211 /** |
|
212 * Inserts Contact list settings |
|
213 * If seetings exist, functions will replace existing with new one |
|
214 * |
|
215 * @since 3.1 |
|
216 * @param aSettings contact list settings to be inserted |
|
217 */ |
|
218 void InsertContactListSettingsL( CPEngContactListSettings& aSettings ); |
|
219 |
|
220 protected: |
|
221 |
|
222 /** |
|
223 * Delete Contact list settings |
|
224 * Contact list is deleted from the storage as well |
|
225 * Contact list settings is deleted as well and |
|
226 * and contact list models are notified |
|
227 * |
|
228 * @since 3.1 |
|
229 * @param aContactList contact list settings to be deleted |
|
230 */ |
|
231 void DeleteContactListSettingsL( const TDesC& aContactList ); |
|
232 |
|
233 |
|
234 /** |
|
235 * Find default contact list |
|
236 * |
|
237 * @since 3.0 |
|
238 * @return Default contact list Settings or NULL. |
|
239 */ |
|
240 CPEngContactListSettings* DefaultCntListSettingsOrNull(); |
|
241 |
|
242 |
|
243 /** |
|
244 * Load contact list model. If contact list model is |
|
245 * not yet loaded from store it will be loaded. |
|
246 * |
|
247 * If contact list is not synchronized and flag aAnyTime is not |
|
248 * defined, function leaves with KErrNotReady. |
|
249 * |
|
250 * @since 3.0 |
|
251 * @param aContactList contact list name |
|
252 * @param aAnyTime flag if contact list synchronization is checked |
|
253 * @param aReferenceUpdate |
|
254 * @return contact list model |
|
255 */ |
|
256 CPEngContactListModBase& LoadContactListModelL( const TDesC& aContactList, |
|
257 TBool aReferenceUpdate, |
|
258 TBool aAnyTime ); |
|
259 |
|
260 /** |
|
261 * Finds contact list model if it is loaded and returns it. |
|
262 * |
|
263 * @since 3.0 |
|
264 * @param aContactList contact list name |
|
265 * @return contact list model if loaded, or NULL |
|
266 */ |
|
267 CPEngContactListModBase* ContactListModelOrNull( const TDesC& aContactList ); |
|
268 |
|
269 |
|
270 /** |
|
271 * Inserts new contact list model among existing ones. |
|
272 * @since 3.0 |
|
273 * @param aModel Contact list model |
|
274 */ |
|
275 void InsertContactListModelL( CPEngContactListModBase& aModel ); |
|
276 |
|
277 |
|
278 /** |
|
279 * Notify contact list observers about change of the settings |
|
280 * |
|
281 * @since 3.0 |
|
282 */ |
|
283 void NotifyCntLstSettingsObservers(); |
|
284 |
|
285 |
|
286 /** |
|
287 * Can be overwritten in derived classed, it is called when |
|
288 * Contact List manager settings is refreshed from store. |
|
289 * @since 3.0 |
|
290 */ |
|
291 virtual void HandleSettingsUpdateL(); |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 private: // Private helpers |
|
297 |
|
298 /** |
|
299 * Initializes cached domain name |
|
300 * |
|
301 * @since 3.0 |
|
302 * @param aSessionSlotId session slot id. |
|
303 */ |
|
304 inline void InitDomainNameL( const CPEngSessionSlotId& aSessionSlot ); |
|
305 |
|
306 |
|
307 /** |
|
308 * Creates watcher list related objects. |
|
309 * |
|
310 * @since 3.0 |
|
311 */ |
|
312 inline void InitWatcherListL(); |
|
313 |
|
314 |
|
315 |
|
316 protected: // Data used by derived classes |
|
317 |
|
318 /// OWN: Access count |
|
319 TInt iAccessCount; |
|
320 |
|
321 /// REF: List library factory |
|
322 MPEngListLibFactory& iFactory; |
|
323 |
|
324 /// OWN: Array of all contact lists settings |
|
325 RPointerArray<CPEngContactListSettings> iContactListSettings; |
|
326 |
|
327 /// OWN: pointer array of the list models |
|
328 RPointerArray<CPEngContactListModBase> iContactLists; |
|
329 |
|
330 /// REF: Contact lists settings observers |
|
331 RPointerArray<MPEngContactListSettingsObserver> iCntLstSettingsObservers; |
|
332 |
|
333 /// OWN: Is contact lists environment synchronized |
|
334 TBool iEnviromentSynchronized; |
|
335 |
|
336 /// OWN: Domain to which user is logged in |
|
337 TPtrC iUserDomain; |
|
338 |
|
339 /// OWN: Session Id |
|
340 CPEngSessionSlotId* iSessionId; |
|
341 }; |
|
342 |
|
343 #endif // __CPENGCONTACTLISTMANAGERBASE_H__ |
|
344 |
|
345 // End of File |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |