|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 store manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBK2STOREMANAGER_H |
|
20 #define CPBK2STOREMANAGER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <MPbk2StoreObservationRegister.h> |
|
25 #include <MVPbkContactStoreListObserver.h> |
|
26 #include <MPbk2StoreConfigurationObserver.h> |
|
27 #include <MPbk2DefaultSavingStoreObserver.h> |
|
28 #include <MPbk2StoreValidityInformer.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CVPbkContactManager; |
|
32 class MVPbkContactStoreList; |
|
33 class CPbk2StoreConfiguration; |
|
34 class MPbk2CompressPolicyManager; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Phonebook 2 store manager. |
|
40 * The responsibilities of this class are to retrieve and observer the |
|
41 * device contact store configuration and to open these stores through |
|
42 * the Virtual Phonebook contact manager. It also manages the |
|
43 * compression of the contact stores. |
|
44 */ |
|
45 class CPbk2StoreManager : public CBase, |
|
46 public MPbk2StoreObservationRegister, |
|
47 public MPbk2StoreValidityInformer, |
|
48 public MVPbkContactStoreListObserver, |
|
49 public MPbk2StoreConfigurationObserver, |
|
50 public MPbk2DefaultSavingStoreObserver |
|
51 { |
|
52 public: // Constructor and destructor |
|
53 |
|
54 /** |
|
55 * Creates a new instance of this class. |
|
56 * |
|
57 * @param aContactManager Virtual Phonebook |
|
58 * contact manager. |
|
59 * @param aStoreConfiguration Contact store configuration. |
|
60 * @param aActOnConfigurationEvents Indicates whether to act on |
|
61 * configuration events. |
|
62 * @return A new instance of this class. |
|
63 */ |
|
64 IMPORT_C static CPbk2StoreManager* NewL( |
|
65 CVPbkContactManager& aContactManager, |
|
66 CPbk2StoreConfiguration& aStoreConfiguration, |
|
67 TBool aActOnConfigurationEvents ); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 ~CPbk2StoreManager(); |
|
73 |
|
74 public: // Interface |
|
75 |
|
76 /** |
|
77 * Opens all the contact stores that are loaded by |
|
78 * Virtual Phonebook contact manager. |
|
79 */ |
|
80 IMPORT_C void OpenStoresL(); |
|
81 |
|
82 /** |
|
83 * Enables and disables compression. |
|
84 * |
|
85 * @param aEnable Indicates whether to enable or |
|
86 * disable compression. |
|
87 */ |
|
88 IMPORT_C void EnableCompression( |
|
89 TBool aEnable ); |
|
90 |
|
91 /** |
|
92 * Ensures default saving store is loaded |
|
93 */ |
|
94 IMPORT_C void EnsureDefaultSavingStoreIncludedL(); |
|
95 |
|
96 /** |
|
97 * Ensures current configuation stores are loaded |
|
98 */ |
|
99 IMPORT_C void EnsureCurrentConfigurationStoresIncludedL(); |
|
100 |
|
101 public: // From MPbk2ContactStoreObservationRegister |
|
102 void RegisterStoreEventsL( |
|
103 const MVPbkContactStoreObserver& aObserver ); |
|
104 void DeregisterStoreEvents( |
|
105 const MVPbkContactStoreObserver& aObserver ); |
|
106 |
|
107 public: // From MPbk2StoreValidityInformer |
|
108 CVPbkContactStoreUriArray* CurrentlyValidStoresL() const; |
|
109 CVPbkContactStoreUriArray* CurrentlyValidShownStoresL() const; |
|
110 |
|
111 private: // From MVPbkContactStoreListObserver |
|
112 void OpenComplete(); |
|
113 void StoreReady( |
|
114 MVPbkContactStore& aContactStore ); |
|
115 void StoreUnavailable( |
|
116 MVPbkContactStore& aContactStore, |
|
117 TInt aReason ); |
|
118 void HandleStoreEventL( |
|
119 MVPbkContactStore& aContactStore, |
|
120 TVPbkContactStoreEvent aEvent ); |
|
121 |
|
122 private: // From MPbk2StoreConfigurationObserver |
|
123 void ConfigurationChanged(); |
|
124 void ConfigurationChangedComplete(); |
|
125 |
|
126 private: // From MPbk2DefaultSavingStoreObserver |
|
127 void SavingStoreChanged(); |
|
128 |
|
129 private: // Implementation |
|
130 CPbk2StoreManager( |
|
131 CVPbkContactManager& aContactManager, |
|
132 CPbk2StoreConfiguration& aStoreConfiguration, |
|
133 TBool aActOnConfigurationEvents ); |
|
134 void ConstructL(); |
|
135 void HandleConfigurationChangedL(); |
|
136 void EnsureCurrentConfigurationLoadedAndOpenL(); |
|
137 void CloseUnnecessaryStoresL(); |
|
138 void HandleSavingStoreChangedL(); |
|
139 TBool IsStoreOpen( |
|
140 MVPbkContactStore& aContactStore ) const; |
|
141 void ReplaceStoreL( |
|
142 MVPbkContactStore& aContactStore ); |
|
143 |
|
144 private: // Data |
|
145 /// Ref: Virtual Phonebook contact manager |
|
146 CVPbkContactManager& iContactManager; |
|
147 /// Ref: Contact stores, owned by the manager |
|
148 MVPbkContactStoreList* iContactStores; |
|
149 /// Own: An array of stores that failed to open |
|
150 RPointerArray<MVPbkContactStore> iFailedStores; |
|
151 /// Own: An array of store event observers |
|
152 RPointerArray<MVPbkContactStoreObserver> iStoreObservers; |
|
153 /// Ref: Store configuration |
|
154 CPbk2StoreConfiguration& iStoreConfiguration; |
|
155 /// Own: Store compression policy manager |
|
156 MPbk2CompressPolicyManager* iCompressPolicy; |
|
157 /// Ref: list of opened contact stores |
|
158 RPointerArray<MVPbkContactStore> iOpenedStores; |
|
159 /// Own: Indicates whether to act on configuration events |
|
160 TBool iActOnConfigurationEvents; |
|
161 }; |
|
162 |
|
163 #endif // CPBK2STOREMANAGER_H |
|
164 |
|
165 // End of File |