2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FIo_RegistryImpl.h
19 * @brief This is the header file for the %_RegistryImpl class.
21 * This header file contains the declarations of the %_RegistryImpl class.
24 #ifndef _FIO_INTERNAL_REGISTRY_IMPL_H_
25 #define _FIO_INTERNAL_REGISTRY_IMPL_H_
27 #include <FOspConfig.h>
28 #include <FBaseObject.h>
29 #include <FIoFileLock.h>
32 namespace Tizen {namespace Base
44 namespace Tizen { namespace Io
50 // @enum %Registry value Type
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
62 class _OSP_EXPORT_ _RegistryImpl
63 : public Tizen::Base::Object
69 virtual ~_RegistryImpl(void);
71 result Construct(const Tizen::Base::String& regPath, long openMode, const Tizen::Base::ByteBuffer* pKey = null);
73 result Construct(const Tizen::Base::String& regPath, const char* pOpenMode, const Tizen::Base::ByteBuffer* pSecretKey);
75 static result Remove(const Tizen::Base::String& regPath);
77 result AddSection(const Tizen::Base::String& SectionName);
79 result RemoveSection(const Tizen::Base::String& SectionName);
81 result GetSectionListN(Tizen::Base::Collection::IList** pRetList);
83 result GetEntryListN(const Tizen::Base::String& sectionName, Tizen::Base::Collection::HashMap** pRetList);
86 * Gets all entries in the specified section of the registry.
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.
103 Tizen::Base::Collection::IMap* GetAllEntriesN(const Tizen::Base::String& sectionName) const;
105 Tizen::Base::Collection::IList* GetAllEntryNamesN(const Tizen::Base::String& sectionName) const;
107 result GetEntryList(const Tizen::Base::String& sectionName, Tizen::Base::Collection::HashMap& retMap);
109 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float& entryValue);
111 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double& entryValue);
113 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::String& entryValue);
115 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float entryValue);
117 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double entryValue);
119 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& entryValue);
121 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, float entryValue);
123 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, double entryValue);
125 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& entryValue);
127 result RemoveValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName);
131 int GetSectionIndex(const Tizen::Base::String& sectionName);
133 Tizen::Base::String GetSectionName(int sectionIndex);
135 int GetEntryIndex(int sectionIndex, const Tizen::Base::String& entryName);
137 Tizen::Base::String GetEntryName(int sectionIndex, int entryIndex);
139 void Removekey(const Tizen::Base::String& sectionName, const Tizen::Base::String& keyName);
141 int GetAllSectionCount(void);
143 int GetAllEntryCount(int sectionIndex);
145 void RemoveEntry(int sectionIndex, int entryIndex);
147 void GetEntryValue(int sectionIndex, int entryIndex, _RegValueType type, void* pValue, int* pSize);
149 void ModifyEntryValue(int sectionIndex, int entryIndex, _RegValueType type, const void* pValue, int size);
151 FileLock* LockN(FileLockType lockType);
153 FileLock* TryToLockN(FileLockType lockType);
155 static result ConvertToSecureRegistry(const Tizen::Base::String& plainRegPath, const Tizen::Base::String& secureRegPath, const Tizen::Base::ByteBuffer* key = null);
157 static _RegistryImpl* GetInstance(Registry& registry);
159 static const _RegistryImpl* GetInstance(const Registry& registry);
162 _RegistryImpl(const _RegistryImpl& source);
164 _RegistryImpl& operator =(const _RegistryImpl& source);
166 void* GetSectionByIndex(int sectionIndex);
168 static bool ConvertRegistryOpenMode(long legacyMode, char* pOpenMode);
170 static result CheckOpenMode(const Tizen::Base::String& openMode);
172 _RegistryCore* __pRegistryCore;
180 #endif // _FIO_INTERNAL_REGISTRY_IMPL_H_