|
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: factory settings functionality for content harvester |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_FACTORYSETTINGSPARSER_H |
|
20 #define C_FACTORYSETTINGSPARSER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <xcfwengine.h> |
|
25 // CONSTANTS |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CXCFWTree; |
|
29 class MXCFWNode; |
|
30 class CGECODefaultObject; |
|
31 class CLiwDefaultMap; |
|
32 class CLiwContainer; |
|
33 class CLiwDefaultList; |
|
34 class MLiwInterface; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 /** |
|
38 * Factory Settings Observer. |
|
39 * |
|
40 * @lib XCFW.lib |
|
41 * @since Series 60 3.1 |
|
42 */ |
|
43 class MADatFactorySettingsObserver |
|
44 { |
|
45 public: |
|
46 //event enumeration |
|
47 |
|
48 enum TADatFactorySettingsStatus // statuses |
|
49 |
|
50 { |
|
51 ECompleted = 0, // factory settings completed successfully |
|
52 EFailed = -1 // factory settings failed |
|
53 }; |
|
54 |
|
55 public: |
|
56 /** |
|
57 * Called when the factory settings finish the restoriation process |
|
58 * |
|
59 * @param aEvent Restoration status. |
|
60 */ |
|
61 virtual void HandleCompletionL( TADatFactorySettingsStatus aStatus ) = 0; |
|
62 |
|
63 }; |
|
64 |
|
65 /** |
|
66 * Factory settings for |
|
67 * |
|
68 * @since Series Series60 3.1 |
|
69 */ |
|
70 class CCHFactorySettingsParser : public CBase, public MXCFWEngineObserver, |
|
71 public MADatFactorySettingsObserver |
|
72 |
|
73 { |
|
74 |
|
75 enum TTypes |
|
76 { |
|
77 EUndefined, |
|
78 EInteger, |
|
79 EUInteger, |
|
80 EDescriptor8, |
|
81 EDescriptor16, |
|
82 EMap, |
|
83 EList, |
|
84 EBool, |
|
85 EReal, |
|
86 EUid |
|
87 }; |
|
88 |
|
89 public: |
|
90 // Constructors and destructor |
|
91 |
|
92 /** |
|
93 * Two-phased constructor. |
|
94 * @param aStorage instance of AS storage DB |
|
95 */ |
|
96 static CCHFactorySettingsParser* NewL( MLiwInterface* aInterface ); |
|
97 static CCHFactorySettingsParser* NewLC( MLiwInterface* aInterface ); |
|
98 |
|
99 /** |
|
100 * Destructor. |
|
101 */ |
|
102 virtual ~CCHFactorySettingsParser(); |
|
103 |
|
104 public: |
|
105 // New functions |
|
106 |
|
107 |
|
108 /** |
|
109 * Restores all factory settings |
|
110 * |
|
111 * @since Series 60 3.1 |
|
112 * @param aStorage instance of AS storage DB |
|
113 */ |
|
114 TInt RestoreL( const TDesC& aStr, TBool aUnInstall=EFalse ); |
|
115 |
|
116 public: |
|
117 // Functions from base classes |
|
118 |
|
119 /** |
|
120 * Called when Engine parsing / saving state changes |
|
121 * User can do desired actions on corresponding events. |
|
122 * @param aEvent Engine event. |
|
123 */ |
|
124 virtual void HandleEngineEventL( TXCFWEngineEvent aEvent ); |
|
125 |
|
126 /** |
|
127 * Called when there's an error during parsing / saving |
|
128 * @param aErrorCode Error code from engine |
|
129 */ |
|
130 virtual void HandleEngineErrorL( TInt aErrorCode ); |
|
131 |
|
132 public: |
|
133 // function from MASpaFactorySettingsObserver |
|
134 /** |
|
135 * Called when the factory settings finish the restoriation process |
|
136 * |
|
137 * @param aEvent Restoration status. |
|
138 */ |
|
139 void HandleCompletionL( TADatFactorySettingsStatus aStatus ); |
|
140 |
|
141 private: |
|
142 // New functions |
|
143 |
|
144 /** |
|
145 * Handles the "entries" node. |
|
146 * @since Series 60 3.1 |
|
147 * @param aUnInstall Uninstall bool. |
|
148 */ |
|
149 void HandleEntriesL( TBool aUnInstall ); |
|
150 |
|
151 /** |
|
152 * Adds an item do the database. |
|
153 * @since Series 60 3.1 |
|
154 * @param aItem An "item" node. |
|
155 * @param aContainer container with item. |
|
156 * @param aType type of item. |
|
157 */ |
|
158 void AddItemL( MXCFWNode* aItem, CLiwContainer* aContainer, TTypes aType ); |
|
159 |
|
160 /** |
|
161 * Removes an item from the database. |
|
162 * @since Series 60 3.2 |
|
163 * @param aItem An "item" node. |
|
164 * @param aMap CLiwDefaultMap with item. |
|
165 */ |
|
166 void RemoveItemL( MXCFWNode* aItem, CLiwDefaultMap* aMap ); |
|
167 |
|
168 /** |
|
169 * Extracts deleted attributes from "item" node. |
|
170 * @since Series 60 3.2 |
|
171 * @param aItem An "item" node. |
|
172 * @param aMap CLiwDefaultMap with item. |
|
173 */ |
|
174 void ExtractDeleteAttributesL( MXCFWNode* aItem, CLiwDefaultMap* aMap ); |
|
175 |
|
176 /** |
|
177 * Extracts and adds attributes from "item" node to map. |
|
178 * @since Series 60 3.2 |
|
179 * @param aItem An "item" node. |
|
180 * @param aMap CLiwDefaultMap with item. |
|
181 */ |
|
182 void ExtractAttributesAndAddL( MXCFWNode* aItem, CLiwDefaultMap* aMap ); |
|
183 |
|
184 /** |
|
185 * Extracts and adds attributes from "item" node to list. |
|
186 * @since Series 60 3.2 |
|
187 * @param aItem An "item" node. |
|
188 * @param aMap CLiwDefaultList with item. |
|
189 */ |
|
190 void ExtractAttributesAndAddL( MXCFWNode* aItem, CLiwDefaultList* aMap ); |
|
191 |
|
192 /** |
|
193 * Converts type from TDesC to TTypes. |
|
194 * @since Series 60 3.2 |
|
195 * @param aType type key as attributes. |
|
196 */ |
|
197 TTypes ConvertToType( const TDesC& aType ); |
|
198 |
|
199 private: |
|
200 |
|
201 /** |
|
202 * C++ default constructor. |
|
203 */ |
|
204 CCHFactorySettingsParser(); |
|
205 |
|
206 /** |
|
207 * By default Symbian 2nd phase constructor is private. |
|
208 */ |
|
209 void ConstructL( MLiwInterface* aInterface ); |
|
210 |
|
211 private: |
|
212 // Data |
|
213 /** |
|
214 * Content tree |
|
215 */ |
|
216 CXCFWTree* iContentTree; |
|
217 |
|
218 /** |
|
219 * Content parsing engine |
|
220 */ |
|
221 CXCFWEngine* iContentEngine; |
|
222 |
|
223 /** |
|
224 * completion observer |
|
225 * Not own. |
|
226 */ |
|
227 MADatFactorySettingsObserver* iCompletionObserver; |
|
228 |
|
229 /** |
|
230 * scheduler for make synchronous restoration |
|
231 */ |
|
232 CActiveSchedulerWait* iActiveScheduler; |
|
233 |
|
234 /** |
|
235 * status about completion of restoration |
|
236 */ |
|
237 TADatFactorySettingsStatus iCompletionStatus; |
|
238 |
|
239 /** |
|
240 * CPS interface |
|
241 * Not own |
|
242 */ |
|
243 MLiwInterface* iCPSInterface; |
|
244 }; |
|
245 |
|
246 #endif // C_FACTORYSETTINGSPARSER_H |
|
247 // End of File |