Code cleanup and optimisation
[profile/ivi/persistence-client-library.git] / src / persistence_client_library_data_organization.c
1 /******************************************************************************
2  * Project         Persistency
3  * (c) copyright   2012
4  * Company         XS Embedded GmbH
5  *****************************************************************************/
6 /******************************************************************************
7  * This Source Code Form is subject to the terms of the
8  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed
9  * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 ******************************************************************************/
11  /**
12  * @file           persistence_client_library_data_organization.c
13  * @ingroup        Persistence client library
14  * @author         Ingo Huerner
15  * @brief          Implementation of persistence database low level access
16  * @see            
17  */
18
19 #include "persistence_client_library_data_organization.h"
20
21 #include <string.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 /// configurable default database name
26 const char* gConfigDefault = "/configurable-default-data.itz";
27 /// default database name
28 const char* gDefault = "/default-data.itz";
29 /// write through database name
30 const char* gWt             = "/wt.itz";
31 /// cached database name
32 const char* gCached        = "/cached.itz";
33
34 const char* gDefDataFolder = "/defaultData/";
35
36
37 // define PERS_ORG_ROOT_PATH comes form persistence common object
38
39 /// cached path location
40 #define CACHEPREFIX         PERS_ORG_ROOT_PATH "/mnt-c/"
41 /// write through path location
42 #define WTPREFIX            PERS_ORG_ROOT_PATH "/mnt-wt/"
43 /// path for the backup location
44 const char* gBackupPrefix       = PERS_ORG_ROOT_PATH "/mnt-backup/";
45
46 /// size of cached path string
47 const int gCPathPrefixSize = sizeof(CACHEPREFIX)-1;
48 /// size of write through string
49 const int gWTPathPrefixSize = sizeof(WTPREFIX)-1;
50
51
52 /// backup filename postfix
53 const char* gBackupPostfix      = "~";
54 /// backup checksum filename postfix
55 const char* gBackupCsPostfix    = "~.crc";
56
57 /// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
58 const char* gLocalCachePath        = CACHEPREFIX "%s";
59 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
60 const char* gLocalWtPath           = WTPREFIX "%s";
61 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
62 const char* gSharedCachePath       = CACHEPREFIX "%s/shared_group_%x";
63 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
64 const char* gSharedWtPath          = WTPREFIX "%s/shared_group_%x";
65 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
66 const char* gSharedPublicCachePath = CACHEPREFIX "%s/shared_public";
67 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
68 const char* gSharedPublicWtPath    = WTPREFIX "%s/shared_public";
69
70 /// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
71 const char* gLocalCachePathKey        = CACHEPREFIX "%s%s";
72 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
73 const char* gLocalWtPathKey           = WTPREFIX "%s%s";
74 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
75 const char* gSharedCachePathKey       = CACHEPREFIX "%s/shared_group_%x%s";
76 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
77 const char* gSharedWtPathKey          = WTPREFIX "%s/shared_group_%x%s";
78 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
79 const char* gSharedPublicCachePathKey = CACHEPREFIX "%s/shared_public%s";
80 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
81 const char* gSharedPublicWtPathKey    = WTPREFIX "%s/shared_public%s";
82
83 /// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/<seat>/<resource>
84 const char* gLocalCacheFilePath        = CACHEPREFIX "%s/user/%d/seat/%d/%s";
85
86
87 const char* gChangeSignal = "PersistenceResChange";
88 const char* gDeleteSignal = "PersistenceResDelete";
89 const char* gCreateSignal = "PersistenceResCreate";
90
91
92 char gNotifykey[DbKeyMaxLen] = { [0 ... DbKeyMaxLen-1] = 0};
93
94 unsigned int gNotifyLdbid  = 0;
95 unsigned int gNotifyUserNo = 0;
96 unsigned int gNotifySeatNo = 0;
97 pclNotifyStatus_e       gNotifyReason = 0;
98 PersNotifyRegPolicy_e   gNotifyPolicy = 0;
99
100
101 int gTimeoutMs = 5000;
102
103 int gDbusPendingRvalue = 0;
104
105
106 /// application id
107 char gAppId[MaxAppNameLen] = { [0 ... MaxAppNameLen-1] = 0};
108
109
110 /// max key value data size [default 16kB]
111 int gMaxKeyValDataSize = defaultMaxKeyValDataSize;
112
113
114 unsigned int gPclInitialized = PCLnotInitialized;
115
116
117 DltContext gPclDLTContext;
118
119 int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);
120
121