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.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 // rrsource configuration database name
26 const char* gResTableCfg = "/resource-table-cfg.itz";
27
28 /// configurable default database name
29 const char* gConfigDefault = "/configurable-default-data.itz";
30
31 /// default database name
32 const char* gDefault = "/default-data.itz";
33
34 /// write through database name
35 const char* gWt             = "/wt.itz";
36 /// cached database name
37 const char* gCached        = "/cached.itz";
38
39
40 /// directory structure node name definition
41 const char* gNode = "/node";
42 /// directory structure user name definition
43 const char* gUser = "/user/";
44 /// directory structure seat name definition
45 const char* gSeat = "/seat/";
46 /// default data folder name definition
47 const char* gDefDataFolder = "/defaultData/";
48
49 /// cached path location
50 #define CACHEPREFIX         "/Data/mnt-c/"
51 /// write through path location
52 #define WTPREFIX            "/Data/mnt-wt/"
53
54 /// size of cached path string
55 const int gCPathPrefixSize = sizeof(CACHEPREFIX)-1;
56 /// size of write through string
57 const int gWTPathPrefixSize = sizeof(WTPREFIX)-1;
58
59 /// path for the backup location
60 const char* gBackupPrefix = "/Data/mnt-backup/";
61
62 /// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
63 const char* gLocalCachePath        = CACHEPREFIX "%s";
64 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
65 const char* gLocalWtPath           = WTPREFIX "%s";
66 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
67 const char* gSharedCachePath       = CACHEPREFIX "%s/shared_group_%x";
68 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
69 const char* gSharedWtPath          = WTPREFIX "%s/shared_group_%x";
70 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
71 const char* gSharedPublicCachePath = CACHEPREFIX "%s/shared_public";
72 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
73 const char* gSharedPublicWtPath    = WTPREFIX "%s/shared_public";
74
75 /// path prefix for local cached database: /Data/mnt_c/<appId>/ (<database_name>
76 const char* gLocalCachePathKey        = CACHEPREFIX "%s%s";
77 /// path prefix for local write through database /Data/mnt_wt/<appId>/<database_name>
78 const char* gLocalWtPathKey           = WTPREFIX "%s%s";
79 /// path prefix for shared cached database: /Data/mnt_c/Shared/Group/<group_no>/<database_name>
80 const char* gSharedCachePathKey       = CACHEPREFIX "%s/shared_group_%x%s";
81 /// path prefix for shared write through database: /Data/mnt_wt/Shared/Group/<group_no>/<database_name>
82 const char* gSharedWtPathKey          = WTPREFIX "%s/shared_group_%x%s";
83 /// path prefix for shared public cached database: /Data/mnt_c/Shared/Public//<database_name>
84 const char* gSharedPublicCachePathKey = CACHEPREFIX "%s/shared_public%s";
85 /// path prefix for shared public write through database: /Data/mnt_wt/Shared/Public/<database_name>
86 const char* gSharedPublicWtPathKey    = WTPREFIX "%s/shared_public%s";
87
88 /// path prefix for local cached files: /Data/mnt_c/<appId>/<user>/<seat>/<resource>
89 const char* gLocalCacheFilePath        = CACHEPREFIX "%s/user/%d/seat/%d/%s";
90
91
92 const char* gChangeSignal = "PersistenceResChange";
93 const char* gDeleteSignal = "PersistenceResDelete";
94 const char* gCreateSignal = "PersistenceResCreate";
95
96
97 char gNotifykey[DbKeyMaxLen] = {0};
98 unsigned int gNotifyLdbid  = 0;
99 unsigned int gNotifyUserNo = 0;
100 unsigned int gNotifySeatNo = 0;
101 pclNotifyStatus_e       gNotifyReason = 0;
102 PersNotifyRegPolicy_e   gNotifyPolicy = 0;
103
104
105 int gTimeoutMs = 5000;
106
107 int gDbusPendingRvalue = 0;
108
109
110 /// application id
111 char gAppId[MaxAppNameLen] = {0};
112
113
114 /// max key value data size [default 16kB]
115 int gMaxKeyValDataSize = defaultMaxKeyValDataSize;
116
117
118 unsigned int gPclInitialized = PCLnotInitialized;
119
120
121 DltContext gPclDLTContext;
122
123 int(* gChangeNotifyCallback)(pclNotification_s * notifyStruct);
124
125