Added use of default data for files; added test data that can be used by PAS installa...
[profile/ivi/persistence-client-library.git] / src / persistence_client_library_data_organization.h
1 #ifndef PERSISTENCE_CLIENT_LIBRARY_DATA_ORGANIZATION_H
2 #define PERSISTENCE_CLIENT_LIBRARY_DATA_ORGANIZATION_H
3
4 /******************************************************************************
5  * Project         Persistency
6  * (c) copyright   2012
7  * Company         XS Embedded GmbH
8  *****************************************************************************/
9 /******************************************************************************
10  * This Source Code Form is subject to the terms of the
11  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed
12  * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 ******************************************************************************/
14  /**
15  * @file           persistence_client_library_data_organization.h
16  * @ingroup        Persistence client library
17  * @author         Ingo Huerner
18  * @brief          Header of the persistence client library data organization.
19  * @see            
20  */
21
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #define  PERSIST_CLIENT_LIBRARY_DATA_ORGANIZATION_INTERFACE_VERSION   (0x03000000U)
28
29 #include "../include/persistence_client_library_error_def.h"
30 #include "../include/persistence_client_library_key.h"
31
32 #include <persComRct.h>
33
34 #include <dlt/dlt.h>
35 #include <dlt/dlt_common.h>
36
37 #include <string.h>
38 #include <stdio.h>
39
40
41
42 /// structure used to manage database context
43 typedef struct _PersistenceDbContext_s
44 {
45    unsigned int ldbid;
46    unsigned int user_no;
47    unsigned int seat_no;
48 } PersistenceDbContext_s;
49
50 /// persistence information
51 typedef struct _PersistenceInfo_s
52 {
53    PersistenceDbContext_s           context;          /**< database context*/
54    PersistenceConfigurationKey_s    configKey;        /**< prct configuration key*/
55
56 } PersistenceInfo_s;
57
58
59 /** storages to manage the data */
60 typedef enum PersDefaultType_e_
61 {
62    PersDefaultType_Configurable = 0,  /**< get the data from configurable defaults */
63    PersDefaultType_Factory,           /**< get the data from factory defaults */
64
65    /** insert new entries here ... */
66    PersDefaultType_LastEntry          /**< last entry */
67
68 } PersDefaultType_e;
69
70 /** storages to manage the data */
71 typedef enum PersGetDefault_e_
72 {
73    PersGetDefault_Data = 0,           /**< get the data from configurable defaults */
74    PersGetDefault_Size,               /**< get the data from factory defaults */
75
76    /** insert new entries here ... */
77    PersGetDefault_LastEntry           /**< last entry */
78
79 } PersGetDefault_e;
80
81 /// enumerator used to identify the policy to manage the data
82 typedef enum _PersNotifyRegPolicy_e
83 {
84    Notify_register   = 0,  /**< register to change notifications*/
85    Notify_unregister = 1,  /**< unregister for change notifications */
86    Notify_lastEntry,       /**<last entry */
87 } PersNotifyRegPolicy_e;
88
89
90 /// constant definitions
91 enum _PersistenceConstantDef
92 {
93    ResIsNoFile          = 0,        /// flag to identify that resource a not file
94    ResIsFile            = 1,        /// flag to identify that resource a file
95    AccessNoLock         = 1,        /// flag to indicate that access is not locked
96
97    PCLnotInitialized    = 0,        /// indication if PCL is not initialized
98    PCLinitialized       = 1,        /// indication if PCL is initialized
99
100    FileClosed           = 0,        /// flag to identify if file will be closed
101    FileOpen             = 1,        /// flag to identify if file has been opend
102
103    Shutdown_Partial      = 0,                   /// make partial Shutdown (close but not free everything)
104    Shutdown_Full         = 1,                   /// make complete Shutdown (close and free everything)
105    Shutdown_MaxCount     = 3,                   /// max number of shutdown cancel calls
106
107    NsmShutdownNormal       = 1,     /// lifecycle shutdown normal
108    NsmErrorStatus_OK       = 1,     /// lifecycle return OK indicator
109    NsmErrorStatus_Fail     = -1,    /// lifecycle return failed indicator
110
111    ChecksumBufSize         = 64,       /// max checksum size
112
113    DbusSubMatchSize        = 12,       /// max character sub match size
114    DbusMatchRuleSize       = 300,      /// max character size of the dbus match rule size
115
116    PrctKeySize             = 64,       /// persistence resource config table max key size
117    PrctValueSize           = 256,      /// persistence resource config table max value size
118    PrctDbTableSize         = 1024,     /// number of persistence resource config tables to store
119
120    RDRWBufferSize          = 1024,     /// write buffer size
121
122    DbKeySize               = 64,       /// database max key size
123    DbValueSize             = 16384,    /// database max value size
124    DbTableSize             = 1024,     /// database table size
125
126    PasMsg_Block            = 0x0001,   /// persistence administration service block access
127    PasMsg_Unblock          = 0x0002,   /// persistence administration service unblock access
128    PasMsg_WriteBack        = 0x0010,   /// persistence administration service write_back
129
130    PasErrorStatus_RespPend = 0x0001,   /// persistence administration service msg return status
131    PasErrorStatus_OK       = 0x0002,   /// persistence administration service msg return status
132    PasErrorStatus_FAIL     = 0x8000,   /// persistence administration service msg return status
133
134    CustLibMaxLen = 128,             /// max length of the custom library name and path
135    DbKeyMaxLen   = 128,             /// max database key length
136    DbResIDMaxLen = 128,             /// max database key length
137    DbPathMaxLen  = 128,             /// max database path length
138    MaxAppNameLen = 128,             /// max application name
139    MaxPersHandle = 256,             /// max number of parallel open persistence handles
140
141    MaxConfKeyLengthResp    = 32,    /// length of the config key responsible name
142    MaxConfKeyLengthCusName = 32,    /// length of the config key custom name
143    MaxRctLengthCustom_ID   = 64,    /// length of the customer ID
144
145    defaultMaxKeyValDataSize = 16384 /// default limit the key-value data size to 16kB
146 };
147
148
149 /// resource configuration table name
150 extern const char* gResTableCfg;
151
152 /// configurable default database name
153 extern const char* gConfigDefault;
154
155 /// default database name
156 extern const char* gDefault;
157
158
159 /// shared cached database
160 extern const char* gCached;
161
162 /// write through database name
163 extern const char* gWt;
164
165
166 /// directory structure node name definition
167 extern const char* gNode;
168 /// directory structure user name definition
169 extern const char* gUser;
170 /// directory structure seat name definition
171 extern const char* gSeat;
172
173 /// default data folder name definition
174 extern const char* gDefDataFolder;
175
176 /// path for the backup location
177 extern const char* gBackupPrefix;
178
179 /// size of cached prefix string
180 extern const int gCPathPrefixSize;
181 /// size of write through prefix string
182 extern const int gWTPathPrefixSize;
183
184 /// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
185 extern const char* gLocalCachePath;
186 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
187 extern const char* gLocalWtPath;
188 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
189 extern const char* gSharedCachePath;
190 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
191 extern const char* gSharedWtPath;
192 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
193 extern const char* gSharedPublicCachePath;
194 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
195 extern const char* gSharedPublicWtPath;
196
197 /// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
198 extern const char* gLocalCachePathKey;
199 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
200 extern const char* gLocalWtPathKey;
201 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
202 extern const char* gSharedCachePathKey;
203 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
204 extern const char* gSharedWtPathKey;
205 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
206 extern const char* gSharedPublicCachePathKey;
207 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
208 extern const char* gSharedPublicWtPathKey;
209
210 /// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/>userno>/<seat>/>seatno>/<resource>
211 extern const char* gLocalCacheFilePath;
212
213 /// application id
214 extern char gAppId[MaxAppNameLen];
215
216 /// max key value data size
217 extern int gMaxKeyValDataSize;
218
219 /// the DLT context
220 extern DltContext gPclDLTContext;
221
222 /// flag to indicate if client library has been initialized
223 extern unsigned int gPclInitialized;
224
225
226 /// change signal string
227 extern const char* gChangeSignal;
228 /// delete signal string
229 extern const char* gDeleteSignal;
230 /// create signal string
231 extern const char* gCreateSignal;
232
233
234 /**
235  * Global notification variables, will be used to pass
236  * the notification information into the mainloop.
237  */
238 /// notification key string
239 extern char gNotifykey[DbKeyMaxLen];
240 /// notification lbid
241 extern unsigned int gNotifyLdbid;
242 /// notification user number
243 extern unsigned int gNotifyUserNo;
244 /// notification seat number
245 extern unsigned int gNotifySeatNo;
246 /// notification reason (created, changed, deleted)
247 extern pclNotifyStatus_e      gNotifyReason;
248 /// notification policy (register or unregister)
249 extern PersNotifyRegPolicy_e  gNotifyPolicy;
250
251
252 // dbus timeout (5 seconds)
253 extern int gTimeoutMs;
254
255 // dbus pending return value
256 extern int gDbusPendingRvalue;
257
258
259 /**
260  * @brief definition of change callback function
261  *
262  * @param pclNotification_s callback notification structure
263  */
264 extern int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);
265
266
267 #ifdef __cplusplus
268 }
269 #endif
270
271 #endif /* PERSISTENCY_CLIENT_LIBRARY_DATA_ORGANIZATION_H */
272