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