Merge "Revert "Fix N_SE-46938 for tz list."" into devel_3.0_main
[platform/framework/native/appfw.git] / src / io / inc / FIo_RegistryCore.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_RegistryCore.h
19  * @brief       This is the header file for the %_RegistryCore class.
20  */
21
22 #ifndef _FIO_INTERNAL_REGISTRYCORE_H_
23 #define _FIO_INTERNAL_REGISTRYCORE_H_
24
25 #include <FBaseUuId.h>
26 #include <FBaseString.h>
27 #include <FBaseByteBuffer.h>
28 #include <FBaseColArrayList.h>
29 #include <FBaseColLinkedList.h>
30 #include <FBaseColHashMap.h>
31 #include <FBaseColIMap.h>
32 #include <FBaseResult.h>
33 #include <FIoFileLock.h>
34
35
36 namespace Tizen { namespace Io
37 {
38
39 class _FileImpl;
40
41 class _RegistryCore
42         : public Tizen::Base::Object
43 {
44 public:
45         _RegistryCore(void);
46
47         virtual ~_RegistryCore(void);
48
49         virtual result Flush(void);
50
51         bool VerifyRegistryOpenMode(const char* pOpenMode);
52
53         result Parse(void);
54
55         result Load(const Tizen::Base::String& regPath, const char* pOpenMode);
56
57         result AddSection(const Tizen::Base::String& SectionName);
58
59         result RemoveSection(const Tizen::Base::String& SectionName);
60
61         result GetSectionListN(Tizen::Base::Collection::IList** pRetList);
62
63         result GetEntryListN(const Tizen::Base::String& sectionName, Tizen::Base::Collection::HashMap** pRetList);
64
65         Tizen::Base::Collection::IMap* GetAllEntriesN(const Tizen::Base::String& sectionName);
66
67         Tizen::Base::Collection::IList* GetAllEntryNamesN(const Tizen::Base::String& sectionName);
68
69         result GetEntryList(const Tizen::Base::String& sectionName, Tizen::Base::Collection::HashMap& retMap);
70
71         result GetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, Tizen::Base::String& valStr);
72
73         result AddValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& valStr);
74
75         result SetValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& valStr);
76
77         result RemoveValue(const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName);
78
79         result PrepareToWrite(void);
80
81         result Write(void);
82
83         int GetSectionIndex(const Tizen::Base::String& sectionName);
84
85         Tizen::Base::String GetSectionName(int sectionIndex);
86
87         int GetEntryIndex(int sectionIndex, const Tizen::Base::String& entryName);
88
89         Tizen::Base::String GetEntryName(int sectionIndex, int entryIndex);
90
91         void Removekey(const Tizen::Base::String& sectionName, const Tizen::Base::String& keyName);
92
93         int GetAllSectionCount(void);
94
95         int GetAllEntryCount(int sectionIndex);
96
97         void RemoveEntry(int sectionIndex, int entryIndex);
98
99         void GetEntryValue(int sectionIndex, int entryIndex, _RegValueType type, void* pValue, int* pSize);
100
101         void ModifyEntryValue(int sectionIndex, int entryIndex, _RegValueType type, const void* pValue, int size);
102
103         void* GetSectionByIndex(int sectionIndex);
104
105         static result ConvertToSecureRegistry(const Tizen::Base::String& plainRegPath, const Tizen::Base::String& secureRegPath, const Tizen::Base::ByteBuffer* key = null);
106
107         FileLock* LockN(FileLockType lockType);
108
109         FileLock* TryToLockN(FileLockType lockType);
110
111 protected:
112         static result AddSection(Tizen::Base::Collection::LinkedList& sectionList, const Tizen::Base::String& sectionName);
113
114         static result AddValue(Tizen::Base::Collection::LinkedList& sectionList, const Tizen::Base::String& sectionName, const Tizen::Base::String& entryName, const Tizen::Base::String& valStr);
115
116         static bool CheckSectionName(char* pSectionName);
117
118         static bool CheckEntryName(char* pEntryName);
119
120         static bool CheckEntryValue(char* pEntryVal);
121
122 private:
123         _RegistryCore(const _RegistryCore& rhs);
124
125         _RegistryCore& operator =(const _RegistryCore& rhs);
126
127         void DecodeData(const Tizen::Base::String& strValueEncoded, _RegValueType type, void* pValue, int* pSize);
128
129 protected:
130         bool _constructed;
131         Tizen::Base::String _regPath;
132     bool _read;
133     bool _write;
134     bool _truncate;
135     bool _append;
136     bool _update;
137         Tizen::Base::Collection::LinkedList _sectionList; // <section_name, list<section_val_name, val>>
138         byte* _pBuffer;
139         int _length;
140
141 private:
142         _FileImpl* __pFileImpl;
143
144 }; // _RegistryCore
145
146 }} // Tizen::Io
147
148 #endif //_FIO_INTERNAL_REGISTRYCORE_H_
149