2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FIo_RegistryCore.h
20 * @brief This is the header file for the %_RegistryCore class.
23 #ifndef _FIO_INTERNAL_REGISTRYCORE_H_
24 #define _FIO_INTERNAL_REGISTRYCORE_H_
26 #include <FBaseUuId.h>
27 #include <FBaseString.h>
28 #include <FBaseByteBuffer.h>
29 #include <FBaseColArrayList.h>
30 #include <FBaseColLinkedList.h>
31 #include <FBaseColHashMap.h>
32 #include <FBaseColIMap.h>
33 #include <FBaseResult.h>
34 #include <FIoFileLock.h>
37 namespace Tizen { namespace Io
43 : public Tizen::Base::Object
48 virtual ~_RegistryCore(void);
50 virtual result Flush(void);
52 bool VerifyRegistryOpenMode(const char* pOpenMode);
56 result Load(const Tizen::Base::String& regPath, const char* pOpenMode);
58 result AddSection(const Tizen::Base::String& SectionName);
60 result RemoveSection(const Tizen::Base::String& SectionName);
62 result GetSectionListN(Tizen::Base::Collection::IList** pRetList);
64 result GetEntryListN(const Tizen::Base::String& sectionName, Tizen::Base::Collection::HashMap** pRetList);
66 Tizen::Base::Collection::IMap* GetAllEntriesN(const Tizen::Base::String& sectionName);
68 Tizen::Base::Collection::IList* GetAllEntryNamesN(const Tizen::Base::String& sectionName);
70 result GetEntryList(const Tizen::Base::String& sectionName, Tizen::Base::Collection::HashMap& retMap);
72 result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::String& valStr);
74 result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& valStr);
76 result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& valStr);
78 result RemoveValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName);
80 result PrepareToWrite(void);
84 int GetSectionIndex(const Tizen::Base::String& sectionName);
86 Tizen::Base::String GetSectionName(int sectionIndex);
88 int GetEntryIndex(int sectionIndex, const Tizen::Base::String& entryName);
90 Tizen::Base::String GetEntryName(int sectionIndex, int entryIndex);
92 void Removekey(const Tizen::Base::String& sectionName, const Tizen::Base::String& keyName);
94 int GetAllSectionCount(void);
96 int GetAllEntryCount(int sectionIndex);
98 void RemoveEntry(int sectionIndex, int entryIndex);
100 void GetEntryValue(int sectionIndex, int entryIndex, _RegValueType type, void* pValue, int* pSize);
102 void ModifyEntryValue(int sectionIndex, int entryIndex, _RegValueType type, const void* pValue, int size);
104 void* GetSectionByIndex(int sectionIndex);
106 static result ConvertToSecureRegistry(const Tizen::Base::String& plainRegPath, const Tizen::Base::String& secureRegPath, const Tizen::Base::ByteBuffer* key = null);
108 FileLock* LockN(FileLockType lockType);
110 FileLock* TryToLockN(FileLockType lockType);
113 static result AddSection(Tizen::Base::Collection::LinkedList& sectionList, const Tizen::Base::String& sectionName);
115 static result AddValue(Tizen::Base::Collection::LinkedList& sectionList, const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& valStr);
117 static bool CheckSectionName(char* pSectionName);
119 static bool CheckEntryName(char* pEntryName);
121 static bool CheckEntryValue(char* pEntryVal);
124 _RegistryCore(const _RegistryCore& rhs);
126 _RegistryCore& operator =(const _RegistryCore& rhs);
128 void DecodeData(const Tizen::Base::String& strValueEncoded, _RegValueType type, void* pValue, int* pSize);
132 Tizen::Base::String _regPath;
138 Tizen::Base::Collection::LinkedList _sectionList; // <section_name, list<section_val_name, val>>
143 _FileImpl* __pFileImpl;
149 #endif //_FIO_INTERNAL_REGISTRYCORE_H_