|
1 /* |
|
2 * Copyright (c) 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: PSM storage base class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef PSMSTORAGE_H |
|
20 #define PSMSTORAGE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <xmlengdom.h> |
|
24 #include <psmtypes.h> |
|
25 |
|
26 /** |
|
27 * PSM Storage base class |
|
28 * |
|
29 * Base class for PSM storages |
|
30 * |
|
31 * @since S60 5.0 |
|
32 */ |
|
33 class CPsmStorage : public CBase |
|
34 |
|
35 { |
|
36 public: |
|
37 |
|
38 /** |
|
39 * Destructor. |
|
40 */ |
|
41 virtual ~CPsmStorage(); |
|
42 |
|
43 /** |
|
44 * Starts parsing config file. This function blocks until file is parsed |
|
45 */ |
|
46 virtual void InitStorageL( const TUint32 aStorageUid ) = 0; |
|
47 |
|
48 /** |
|
49 * Backsup configuration to backup storage |
|
50 */ |
|
51 virtual void BackupConfigurationL( const RConfigInfoArray& aConfigArray ); |
|
52 |
|
53 /** |
|
54 * Closes storage file. |
|
55 */ |
|
56 virtual void CloseStorageL(); |
|
57 |
|
58 /** |
|
59 * Reads configuration from config storage |
|
60 */ |
|
61 void GetConfigurationL( RConfigInfoArray& aConfigArray ); |
|
62 |
|
63 /** |
|
64 * Sets new mode |
|
65 */ |
|
66 void SetMode( TPsmsrvMode aMode ) { iMode = aMode; }; |
|
67 |
|
68 protected: |
|
69 |
|
70 /** |
|
71 * C++ constructor. |
|
72 */ |
|
73 CPsmStorage( TPsmsrvMode iMode, RFs& aFile ); |
|
74 |
|
75 /** |
|
76 * Blocks until XML parser / composer has done its job |
|
77 */ |
|
78 void WaitStorageActionComplete(); |
|
79 |
|
80 /** |
|
81 * Initializes root elements when storage file has been parsed |
|
82 */ |
|
83 virtual void InitRootElementsL() = 0; |
|
84 |
|
85 /** |
|
86 * Helper function to get correct configuration set for current mode |
|
87 * |
|
88 * @param aMode Identifies the configuration set to get |
|
89 * @return XML element if set is found, otherwise leaves with KErrNotFound |
|
90 */ |
|
91 TXmlEngElement FindConfigurationSetL( const TInt aMode ); |
|
92 |
|
93 /** |
|
94 * Lists set items of a specific passive configuration |
|
95 */ |
|
96 void CreateConfigArrayL( RConfigInfoArray& aPsmConfigArray, |
|
97 const TInt aMode ); |
|
98 |
|
99 /** |
|
100 * Helper functions for handling storage data |
|
101 * |
|
102 * Getters |
|
103 */ |
|
104 TInt GetAttributeIntValueL( const TXmlEngElement& aElement, const TDesC8& aAttrib ) const; |
|
105 void GetAttributeStrValueL( const TXmlEngElement& aElement, const TDesC8& aAttrib, TDes8& aTarget ) const; |
|
106 TReal GetAttributeRealValueL( const TXmlEngElement& aElement, const TDesC8& aAttrib ) const; |
|
107 TUint GetAttributeHexValueL( const TXmlEngElement& aElement, const TDesC8& aAttrib ) const; |
|
108 |
|
109 /** |
|
110 * Setters |
|
111 */ |
|
112 void SetAttributeValueL( TXmlEngElement& aElement, const TDesC8& aAttrib, const TInt aValue ) const; |
|
113 void SetAttributeValueL( TXmlEngElement& aElement, const TDesC8& aAttrib, const TDesC8& aValue ) const; |
|
114 void SetAttributeValueL( TXmlEngElement& aElement, const TDesC8& aAttrib, const TReal aValue ) const; |
|
115 void SetAttributeHexValueL( TXmlEngElement& aElement, const TDesC8& aAttrib, const TUint32 aValue ) const; |
|
116 |
|
117 private: |
|
118 |
|
119 /** |
|
120 * By default Symbian 2nd phase constructor is private. |
|
121 */ |
|
122 void ConstructL(); |
|
123 |
|
124 protected: // Data |
|
125 |
|
126 /** |
|
127 * Reference to file server session |
|
128 */ |
|
129 RFs& iFileSession; |
|
130 |
|
131 /** |
|
132 * Active scheduler wait for blocking construction until config file is parsed |
|
133 */ |
|
134 CActiveSchedulerWait iSchedulerWait; |
|
135 |
|
136 /** |
|
137 * Pointer of the config xml-file parser |
|
138 */ |
|
139 RXmlEngDOMParser iStorageParser; |
|
140 |
|
141 /** |
|
142 * Elements of the storage file. These needs to be stored |
|
143 */ |
|
144 RXmlEngDocument iStorageFile; // Storage file |
|
145 TXmlEngElement iStorageRoot; // Root of the storage |
|
146 RXmlEngDOMImplementation iDOMImpl; |
|
147 |
|
148 /** |
|
149 * Storage UID |
|
150 */ |
|
151 TUint32 iStorageUid; |
|
152 |
|
153 /** |
|
154 * Mode where to switch to |
|
155 */ |
|
156 TPsmsrvMode iMode; |
|
157 |
|
158 }; |
|
159 |
|
160 #endif // PSMSTORAGE_H |