19393b693c0dcc59c92bd264fc1cccb0a771c7d9
[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 #include <persComDbAccess.h>
34 #include <persComDataOrg.h>
35
36 #include <dlt/dlt.h>
37 #include <dlt/dlt_common.h>
38
39 #include <string.h>
40 #include <stdio.h>
41
42
43
44 /// structure used to manage database context
45 typedef struct _PersistenceDbContext_s
46 {
47    unsigned int ldbid;
48    unsigned int user_no;
49    unsigned int seat_no;
50 } PersistenceDbContext_s;
51
52 /// persistence information
53 typedef struct _PersistenceInfo_s
54 {
55    PersistenceDbContext_s           context;          /**< database context*/
56    PersistenceConfigurationKey_s    configKey;        /**< prct configuration key*/
57
58 } PersistenceInfo_s;
59
60
61 /** storages to manage the data */
62 typedef enum PersDefaultType_e_
63 {
64    PersDefaultType_Configurable = 0,  /**< get the data from configurable defaults */
65    PersDefaultType_Factory,           /**< get the data from factory defaults */
66
67    /** insert new entries here ... */
68    PersDefaultType_LastEntry          /**< last entry */
69
70 } PersDefaultType_e;
71
72 /** storages to manage the data */
73 typedef enum PersGetDefault_e_
74 {
75    PersGetDefault_Data = 0,           /**< get the data from configurable defaults */
76    PersGetDefault_Size,               /**< get the data from factory defaults */
77
78    /** insert new entries here ... */
79    PersGetDefault_LastEntry           /**< last entry */
80
81 } PersGetDefault_e;
82
83 /// enumerator used to identify the policy to manage the data
84 typedef enum _PersNotifyRegPolicy_e
85 {
86    Notify_register   = 0,  /**< register to change notifications*/
87    Notify_unregister = 1,  /**< unregister for change notifications */
88    Notify_lastEntry,       /**<last entry */
89 } PersNotifyRegPolicy_e;
90
91
92 /// constant definitions
93 enum _PersistenceConstantDef
94 {
95    ResIsNoFile          = 0,        /// flag to identify that resource a not file
96    ResIsFile            = 1,        /// flag to identify that resource a file
97    AccessNoLock         = 1,        /// flag to indicate that access is not locked
98
99    PCLnotInitialized    = 0,        /// indication if PCL is not initialized
100    PCLinitialized       = 1,        /// indication if PCL is initialized
101
102    FileClosed           = 0,        /// flag to identify if file will be closed
103    FileOpen             = 1,        /// flag to identify if file has been opend
104
105    Shutdown_Partial      = 0,                   /// make partial Shutdown (close but not free everything)
106    Shutdown_Full         = 1,                   /// make complete Shutdown (close and free everything)
107    Shutdown_MaxCount     = 3,                   /// max number of shutdown cancel calls
108
109    NsmShutdownNormal       = 1,     /// lifecycle shutdown normal
110    NsmErrorStatus_OK       = 1,     /// lifecycle return OK indicator
111    NsmErrorStatus_Fail     = -1,    /// lifecycle return failed indicator
112
113    ChecksumBufSize         = 64,       /// max checksum size
114
115    DbusSubMatchSize        = 12,       /// max character sub match size
116    DbusMatchRuleSize       = 300,      /// max character size of the dbus match rule size
117
118    PrctKeySize             = PERS_RCT_MAX_LENGTH_RESOURCE_ID,                   /// persistence resource config table max key size
119    PrctValueSize           = sizeof(PersistenceConfigurationKey_s),     /// persistence resource config table max value size
120    PrctDbTableSize         = 1024,     /// number of persistence resource config tables to store
121
122    RDRWBufferSize          = 1024,     /// write buffer size
123
124    DbKeySize               = PERS_DB_MAX_LENGTH_KEY_NAME,       /// database max key size
125    DbValueSize             = PERS_DB_MAX_SIZE_KEY_DATA,         /// database max value size
126    DbTableSize             = 1024,     /// database table size
127
128    PasMsg_Block            = 0x0001,   /// persistence administration service block access
129    PasMsg_Unblock          = 0x0002,   /// persistence administration service unblock access
130    PasMsg_WriteBack        = 0x0010,   /// persistence administration service write_back
131
132    PasErrorStatus_RespPend = 0x0001,   /// persistence administration service msg return status
133    PasErrorStatus_OK       = 0x0002,   /// persistence administration service msg return status
134    PasErrorStatus_FAIL     = 0x8000,   /// persistence administration service msg return status
135
136    CustLibMaxLen = PERS_RCT_MAX_LENGTH_CUSTOM_NAME,             /// max length of the custom library name and path
137    DbKeyMaxLen   = PERS_DB_MAX_LENGTH_KEY_NAME,         /// max database key length
138    DbResIDMaxLen = PERS_DB_MAX_LENGTH_KEY_NAME,          /// max database key length
139    DbPathMaxLen  = PERS_ORG_MAX_LENGTH_PATH_FILENAME,    /// max database path length
140    MaxAppNameLen = PERS_RCT_MAX_LENGTH_RESPONSIBLE,      /// max application name
141    MaxPersHandle = 128,             /// max number of parallel open persistence handles
142
143    MaxConfKeyLengthResp    = 32,    /// length of the config key responsible name
144    MaxConfKeyLengthCusName = 32,    /// length of the config key custom name
145    MaxRctLengthCustom_ID   = 64,    /// length of the customer ID
146
147    defaultMaxKeyValDataSize = PERS_DB_MAX_SIZE_KEY_DATA  /// default limit the key-value data size to 16kB
148 };
149
150 /// path for the backup location
151 extern const char* gBackupPrefix;
152 /// backup filename postfix
153 extern const char* gBackupPostfix;
154 /// backup checksum filename postfix
155 extern const char* gBackupCsPostfix;
156
157 /// size of cached prefix string
158 extern const int gCPathPrefixSize;
159 /// size of write through prefix string
160 extern const int gWTPathPrefixSize;
161
162 /// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
163 extern const char* gLocalCachePath;
164 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
165 extern const char* gLocalWtPath;
166 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
167 extern const char* gSharedCachePath;
168 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
169 extern const char* gSharedWtPath;
170 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
171 extern const char* gSharedPublicCachePath;
172 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
173 extern const char* gSharedPublicWtPath;
174
175 /// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
176 extern const char* gLocalCachePathKey;
177 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
178 extern const char* gLocalWtPathKey;
179 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
180 extern const char* gSharedCachePathKey;
181 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
182 extern const char* gSharedWtPathKey;
183 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
184 extern const char* gSharedPublicCachePathKey;
185 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
186 extern const char* gSharedPublicWtPathKey;
187
188 /// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/>userno>/<seat>/>seatno>/<resource>
189 extern const char* gLocalCacheFilePath;
190
191 /// application id
192 extern char gAppId[MaxAppNameLen];
193
194 /// max key value data size
195 extern int gMaxKeyValDataSize;
196
197 /// the DLT context
198 extern DltContext gPclDLTContext;
199
200 /// flag to indicate if client library has been initialized
201 extern unsigned int gPclInitialized;
202
203
204 /// change signal string
205 extern const char* gChangeSignal;
206 /// delete signal string
207 extern const char* gDeleteSignal;
208 /// create signal string
209 extern const char* gCreateSignal;
210
211
212 /**
213  * Global notification variables, will be used to pass
214  * the notification information into the mainloop.
215  */
216 /// notification key string
217 extern char gNotifykey[DbKeyMaxLen];
218 /// notification lbid
219 extern unsigned int gNotifyLdbid;
220 /// notification user number
221 extern unsigned int gNotifyUserNo;
222 /// notification seat number
223 extern unsigned int gNotifySeatNo;
224 /// notification reason (created, changed, deleted)
225 extern pclNotifyStatus_e      gNotifyReason;
226 /// notification policy (register or unregister)
227 extern PersNotifyRegPolicy_e  gNotifyPolicy;
228
229
230 // dbus timeout (5 seconds)
231 extern int gTimeoutMs;
232
233 // dbus pending return value
234 extern int gDbusPendingRvalue;
235
236
237 /**
238  * @brief definition of change callback function
239  *
240  * @param pclNotification_s callback notification structure
241  */
242 extern int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);
243
244
245 #ifdef __cplusplus
246 }
247 #endif
248
249 #endif /* PERSISTENCY_CLIENT_LIBRARY_DATA_ORGANIZATION_H */
250