Merge "Revert "Fix N_SE-46938 for tz list."" into devel_3.0_main
[platform/framework/native/appfw.git] / src / io / inc / FIo_RegistryImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FIo_RegistryImpl.h
19  * @brief       This is the header file for the %_RegistryImpl class.
20  *
21  * This header file contains the declarations of the %_RegistryImpl class.
22  */
23
24 #ifndef _FIO_INTERNAL_REGISTRY_IMPL_H_
25 #define _FIO_INTERNAL_REGISTRY_IMPL_H_
26
27 #include <FBaseObject.h>
28 #include <FIoFileLock.h>
29
30 namespace Tizen {namespace Base
31 {
32 class String;
33 class ByteBuffer;
34 namespace Collection
35 {
36 class HashMap;
37 class IList;
38 class IMap;
39 }
40 }}
41
42 namespace Tizen { namespace Io
43 {
44
45 class Registry;
46 class _RegistryCore;
47
48 // @enum %Registry value Type
49 enum _RegValueType
50 {
51         REG_VALUE_TYPE_INT = 1,     // Integer type
52         REG_VALUE_TYPE_REAL,        // Real type
53         REG_VALUE_TYPE_STRING,      // String type
54         REG_VALUE_TYPE_BINARY,      // Binary type
55         REG_VALUE_TYPE_UUID,        // UUID type
56         REG_VALUE_TYPE_UUIDSET,     // UUIDSET type
57         REG_VALUE_TYPE_MAX
58 };
59
60 class _OSP_EXPORT_ _RegistryImpl
61         : public Tizen::Base::Object
62 {
63
64 public:
65         _RegistryImpl(void);
66
67         virtual ~_RegistryImpl(void);
68
69         result Construct(const Tizen::Base::String& regPath, long openMode, const Tizen::Base::ByteBuffer* pKey = null);
70
71         result Construct(const Tizen::Base::String& regPath, const char* pOpenMode, const Tizen::Base::ByteBuffer* pSecretKey);
72
73         static result Remove(const Tizen::Base::String& regPath);
74
75         result AddSection(const Tizen::Base::String& SectionName);
76
77         result RemoveSection(const Tizen::Base::String& SectionName);
78
79         result GetSectionListN(Tizen::Base::Collection::IList** pRetList);
80
81         result GetEntryListN(const Tizen::Base::String& sectionName, Tizen::Base::Collection::HashMap** pRetList);
82
83         /**
84         * Gets all entries in the specified section of the registry.
85         *
86         * @since 2.1
87         * @return               A map of entries @n
88         *                               If this method fails, @c null value is returned. @n
89         *                               When there are no entries at all, the method returns an empty map instance.
90         *                               Use the GetCount() method to check the number of element in the map.
91         * @param                sectionName                             The section name
92         * @exception    E_SUCCESS                               The method was successful.
93         * @exception    E_INVALID_STATE                 This instance has not been constructed yet.
94         * @exception    E_SECTION_NOT_FOUND             The specified @c sectionName was not found within the registry.
95         * @exception    E_OUT_OF_MEMORY                 The memory was insufficient.
96         * @exception    E_IO                                    The system error has occurred.
97         * @remarks              Do not forget to delete not only the returned IMap instance, but also its
98         *                               contents by invoking IMap::RemoveAll(). @n
99         *                               The specific error code can be accessed using the GetLastResult() method.
100         */
101         Tizen::Base::Collection::IMap* GetAllEntriesN(const Tizen::Base::String& sectionName) const;
102
103         Tizen::Base::Collection::IList* GetAllEntryNamesN(const Tizen::Base::String& sectionName) const;
104
105         result GetEntryList(const Tizen::Base::String& sectionName, Tizen::Base::Collection::HashMap& retMap);
106
107         result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float& entryValue);
108
109         result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double& entryValue);
110
111         result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::String& entryValue);
112
113         result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float entryValue);
114
115         result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double entryValue);
116
117         result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& entryValue);
118
119         result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float entryValue);
120
121         result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double entryValue);
122
123         result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& entryValue);
124
125         result RemoveValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName);
126
127         result Flush(void);
128
129         int GetSectionIndex(const Tizen::Base::String& sectionName);
130
131         Tizen::Base::String GetSectionName(int sectionIndex);
132
133         int GetEntryIndex(int sectionIndex, const Tizen::Base::String& entryName);
134
135         Tizen::Base::String GetEntryName(int sectionIndex, int entryIndex);
136
137         void Removekey(const Tizen::Base::String& sectionName, const Tizen::Base::String& keyName);
138
139         int GetAllSectionCount(void);
140
141         int GetAllEntryCount(int sectionIndex);
142
143         void RemoveEntry(int sectionIndex, int entryIndex);
144
145         void GetEntryValue(int sectionIndex, int entryIndex, _RegValueType type, void* pValue, int* pSize);
146
147         void ModifyEntryValue(int sectionIndex, int entryIndex, _RegValueType type, const void* pValue, int size);
148
149         FileLock* LockN(FileLockType lockType);
150
151         FileLock* TryToLockN(FileLockType lockType);
152
153         static result ConvertToSecureRegistry(const Tizen::Base::String& plainRegPath, const Tizen::Base::String& secureRegPath, const Tizen::Base::ByteBuffer* key = null);
154
155         static _RegistryImpl* GetInstance(Registry& registry);
156
157         static const _RegistryImpl* GetInstance(const Registry& registry);
158
159 private:
160         _RegistryImpl(const _RegistryImpl& source);
161
162         _RegistryImpl& operator =(const _RegistryImpl& source);
163
164         void* GetSectionByIndex(int sectionIndex);
165
166         static bool ConvertRegistryOpenMode(long legacyMode, char* pOpenMode);
167
168         static result CheckOpenMode(const Tizen::Base::String& openMode);
169
170         _RegistryCore* __pRegistryCore;
171
172 }; // _RegistryImpl
173
174 }} // Tizen::Io
175
176 #endif // _FIO_INTERNAL_REGISTRY_IMPL_H_
177