Implemented on demand/static loading of plugins (part I); ATTENTION: pluginf config...
[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    TOKENARRAYSIZE = 255,
148
149    defaultMaxKeyValDataSize = PERS_DB_MAX_SIZE_KEY_DATA  /// default limit the key-value data size to 16kB
150 };
151
152 /// path for the backup location
153 extern const char* gBackupPrefix;
154 /// backup filename postfix
155 extern const char* gBackupPostfix;
156 /// backup checksum filename postfix
157 extern const char* gBackupCsPostfix;
158
159 /// size of cached prefix string
160 extern const int gCPathPrefixSize;
161 /// size of write through prefix string
162 extern const int gWTPathPrefixSize;
163
164 /// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
165 extern const char* gLocalCachePath;
166 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
167 extern const char* gLocalWtPath;
168 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
169 extern const char* gSharedCachePath;
170 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
171 extern const char* gSharedWtPath;
172 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
173 extern const char* gSharedPublicCachePath;
174 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
175 extern const char* gSharedPublicWtPath;
176
177 /// path prefix for local cached database: /Data/mnt_c/<appId>/<database_name>
178 extern const char* gLocalCachePathKey;
179 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
180 extern const char* gLocalWtPathKey;
181 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
182 extern const char* gSharedCachePathKey;
183 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
184 extern const char* gSharedWtPathKey;
185 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
186 extern const char* gSharedPublicCachePathKey;
187 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
188 extern const char* gSharedPublicWtPathKey;
189
190 /// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/>userno>/<seat>/>seatno>/<resource>
191 extern const char* gLocalCacheFilePath;
192
193 /// application id
194 extern char gAppId[MaxAppNameLen];
195
196 /// max key value data size
197 extern int gMaxKeyValDataSize;
198
199 /// the DLT context
200 extern DltContext gPclDLTContext;
201
202 /// flag to indicate if client library has been initialized
203 extern unsigned int gPclInitialized;
204
205
206 /// change signal string
207 extern const char* gChangeSignal;
208 /// delete signal string
209 extern const char* gDeleteSignal;
210 /// create signal string
211 extern const char* gCreateSignal;
212
213
214 /**
215  * Global notification variables, will be used to pass
216  * the notification information into the mainloop.
217  */
218 /// notification key string
219 extern char gNotifykey[DbKeyMaxLen];
220 /// notification lbid
221 extern unsigned int gNotifyLdbid;
222 /// notification user number
223 extern unsigned int gNotifyUserNo;
224 /// notification seat number
225 extern unsigned int gNotifySeatNo;
226 /// notification reason (created, changed, deleted)
227 extern pclNotifyStatus_e      gNotifyReason;
228 /// notification policy (register or unregister)
229 extern PersNotifyRegPolicy_e  gNotifyPolicy;
230
231
232 // dbus timeout (5 seconds)
233 extern int gTimeoutMs;
234
235 // dbus pending return value
236 extern int gDbusPendingRvalue;
237
238
239 /**
240  * @brief definition of change callback function
241  *
242  * @param pclNotification_s callback notification structure
243  */
244 extern int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);
245
246 /// character lookup table
247 extern const char gCharLookup[];
248
249
250 #ifdef __cplusplus
251 }
252 #endif
253
254 #endif /* PERSISTENCY_CLIENT_LIBRARY_DATA_ORGANIZATION_H */
255