--- /dev/null
+<!DOCTYPE busconfig PUBLIC
+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+ <!-- Only root can own the service -->
+ <policy user="root">
+ <allow own="org.genivi.persistence.admin"/>
+ <allow send_destination="org.genivi.persistence.admin"/>
+ <allow send_interface="org.genivi.persistence.admin"/>
+ </policy>
+ <policy context="default">
+ <allow send_destination="org.genivi.persistence.admin"/>
+ <allow send_interface="org.genivi.persistence.admin"/>
+ </policy>
+</busconfig>
-hwinfo /usr/local/lib/libhwinfoperscustom.so
-secure /usr/local/lib/libsecureperscustom.so
-custom3 /usr/local/lib/libcustom3perscustom.so
-emergency /usr/local/lib/libemergencyperscustom.so
-early /usr/local/lib/libearlyperscustom.so
*
* @return positive value: success;
* On error a negative value will be returned with th follwoing error codes:
- * ::EPERS_LOCKFS, ::EPERS_NOT_INITIALIZED
+ * ::EPERS_LOCKFS, ::EPERS_NOT_INITIALIZED, ::EPERS_INIT_DBUS_MAINLOOP,
*/
int pclInitLibrary(const char* appname, int shutdownMode);
#define EPERS_NOT_INITIALIZED (-32)
// max buffer size
#define EPERS_MAX_BUFF_SIZE (-33)
+// failed to setup dbus mainloop
+#define EPERS_DBUS_MAINLOOP (-34)
+// failed register lifecycle dbus
+#define EPERS_REGISTER_LIFECYCLE (-35)
+// failed register admin service dbus
+#define EPERS_REGISTER_ADMIN (-36)
+
#ifdef __cplusplus
}
* @param fd the file descriptor to close
*
* @return zero on success. On error a negative value will be returned with th follwoing error codes:
- * EPERS_LOCKFS
+ * ::EPERS_LOCKFS, ::EPERS_MAXHANDLE
*/
int pclFileClose(int fd);
#include <dbus/dbus.h>
-#define USE_DBUS 1
-
/// debug log and trace (DLT) setup
DLT_DECLARE_CONTEXT(gDLTContext);
gMaxKeyValDataSize = atoi(pDataSize);
}
- if(pBlacklistPath != NULL)
+ if(pBlacklistPath == NULL)
{
pBlacklistPath = "/etc/pclBackupBlacklist.txt"; // default path
}
if( setup_dbus_mainloop() == -1)
{
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => Failed to setup main loop"));
- return -1;
+ return EPERS_DBUS_MAINLOOP;
}
-#if USE_DBUS
// register for lifecycle and persistence admin service dbus messages
if(register_lifecycle(shutdownMode) == -1)
{
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => Failed to register to lifecycle dbus interface"));
- return -1;
+ return EPERS_REGISTER_LIFECYCLE;
}
-
- rval = register_pers_admin_service();
+ if(register_pers_admin_service() == -1)
{
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclInitLibrary => Failed to register to pers admin dbus interface"));
- return -1;
+ return EPERS_REGISTER_ADMIN;
}
-#endif
/// get custom library names to load
status = get_custom_libraries();
DLT_STRING("- init counter: "), DLT_INT(gPclInitialized));
// unregister for lifecycle and persistence admin service dbus messages
- #if USE_DBUS
rval = unregister_lifecycle(gShutdownMode);
- rval = unregister_pers_admin_service();
- #endif
+ //rval = unregister_pers_admin_service();
// unload custom client libraries
for(i=0; i<PersCustomLib_LastEntry; i++)
fd = open(filename, O_RDONLY);
if (fd == -1)
{
- DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("configReader::readConfigFile ==> Error file open"), DLT_STRING(filename), DLT_STRING(strerror(errno)) );
+ DLT_LOG(gDLTContext, DLT_LOG_WARN, DLT_STRING("configReader::readConfigFile ==> Error file open"), DLT_STRING(filename), DLT_STRING(strerror(errno)) );
return -1;
}
// check for empty file
if(gConfigFileSize == 0)
{
- DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("configReader::readConfigFile ==> Error file size is 0:"), DLT_STRING(filename));
+ DLT_LOG(gDLTContext, DLT_LOG_WARN, DLT_STRING("configReader::readConfigFile ==> Error file size is 0:"), DLT_STRING(filename));
close(fd);
return -1;
}
-int pers_db_open_default(itzam_btree* btree, PersistenceInfo_s* info, const char* dbPath, int configDefault)
+int pers_db_open_default(itzam_btree* btree, const char* dbPath, int configDefault)
{
itzam_state state = ITZAM_FAILED;
char path[DbPathMaxLen] = {0};
// --------------------------------
if(keyFound == 0)
{
- if(pers_db_open_default(&btreeConfDefault, info, dbPath, 1) != -1)
+ if(pers_db_open_default(&btreeConfDefault, dbPath, 1) != -1)
{
if(itzam_true == itzam_btree_find(&btreeConfDefault, key, &search)) // read db
{
// --------------------------------
if(keyFound == 0)
{
- if(pers_db_open_default(&btreeDefault, info, dbPath, 0) != -1)
+ if(pers_db_open_default(&btreeDefault, dbPath, 0) != -1)
{
if(itzam_true == itzam_btree_find(&btreeDefault, key, &search)) // read db
{
read_size = EPERS_NOPRCTABLE;
}
}
+
+
}
else if(PersistenceStorage_custom == info->configKey.storage) // custom storage implementation via custom library
{
if(PersistenceStorage_shared == info->configKey.storage)
{
- pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_deleted);
+ pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_changed);
}
}
else
if(PersistenceStorage_shared == info->configKey.storage)
{
- pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_changed);
+ pers_send_Notification_Signal(key, &info->context, pclNotifyStatus_deleted);
}
}
else
{
DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("setup_dbus_mainloop -> Use specific dbus address:"), DLT_STRING(pAddress) );
- gDbusConn = dbus_connection_open(pAddress, &err);
+ gDbusConn = dbus_connection_open_private(pAddress, &err);
if(gDbusConn != NULL)
{
}
close(gEfds);
}
+ //dbus_connection_close(conn);
dbus_connection_unref(conn);
dbus_shutdown();
}
}
else
{
- rval = -1;
+ rval = EPERS_MAXHANDLE;
}
}
if(gPclInitialized >= PCLinitialized)
{
- if(AccessNoLock == isAccessLocked() ) // check if access to persistent data is locked
+ if(AccessNoLock != isAccessLocked() ) // check if access to persistent data is locked
{
rval = lseek(fd, offset, whence);
}
#include "persistence_client_library_handle.h"
-#include "persistence_client_library_custom_loader.h"
#include <pthread.h>
#include <stdlib.h>
/// get persistence handle
-int get_persistence_handle_idx(char* dbPath, char* key, PersistenceInfo_s* info)
+int get_persistence_handle_idx()
{
int handle = 0;
if(pthread_mutex_lock(&gMtx) == 0)
{
- if( PersistenceStorage_shared == info->configKey.storage
- || PersistenceStorage_local == info->configKey.storage)
+ if(gFreeHandleIdxHead > 0) // check if we have a free spot in the array before the current max
{
- if(gFreeHandleIdxHead > 0) // check if we have a free spot in the array before the current max
- {
- handle = gFreeHandleArray[--gFreeHandleIdxHead];
- }
- else
- {
- if(gHandleIdx < MaxPersHandle-1)
- {
- handle = gHandleIdx++; // no free spot before current max, increment handle index
- }
- else
- {
- handle = -1;
- DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("get_persistence_handle_idx => Reached maximum of open handles: "), DLT_INT(MaxPersHandle));
- }
- }
+ handle = gFreeHandleArray[--gFreeHandleIdxHead];
}
- else if(PersistenceStorage_custom == info->configKey.storage)
+ else
{
- int idx = custom_client_name_to_id(dbPath, 1);
- char workaroundPath[128]; // workaround, because /sys/ can not be accessed on host!!!!
- snprintf(workaroundPath, 128, "%s%s", "/Data", dbPath );
-
- if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_open != NULL) )
+ if(gHandleIdx < MaxPersHandle-1)
{
- int flag = 0, mode = 0;
- handle = gPersCustomFuncs[idx].custom_plugin_handle_open(workaroundPath, flag, mode);
+ handle = gHandleIdx++; // no free spot before current max, increment handle index
}
else
{
- handle = EPERS_NOPLUGINFUNCT;
+ handle = -1;
+ DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("get_persistence_handle_idx => Reached maximum of open handles: "), DLT_INT(MaxPersHandle));
}
}
pthread_mutex_unlock(&gMtx);
}
+
return handle;
}
/// close persistence handle
-int set_persistence_handle_close_idx(int handle, char* dbPath, char* key, PersistenceInfo_s* info)
+void set_persistence_handle_close_idx(int handle)
{
- int rval = 0;
-
if(pthread_mutex_lock(&gMtx) == 0)
{
- if( PersistenceStorage_shared == info->configKey.storage
- || PersistenceStorage_local == info->configKey.storage)
+ if(gFreeHandleIdxHead < MaxPersHandle)
{
- if(gFreeHandleIdxHead < MaxPersHandle)
- {
- gFreeHandleArray[gFreeHandleIdxHead++] = handle;
- }
+ gFreeHandleArray[gFreeHandleIdxHead++] = handle;
}
- else if(PersistenceStorage_custom == gKeyHandleArray[handle].info.configKey.storage )
- {
- int idx = custom_client_name_to_id(gKeyHandleArray[handle].dbPath, 1);
-
- if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_close != NULL) )
- {
- rval = gPersCustomFuncs[idx].custom_plugin_handle_close(handle);
- }
- else
- {
- rval = EPERS_NOPLUGINFUNCT;
- }
- }
-
pthread_mutex_unlock(&gMtx);
}
}
*
* @return a new handle or 0 if an error occured
*/
-int get_persistence_handle_idx(char* dbPath, char* key, PersistenceInfo_s* info);
+int get_persistence_handle_idx();
/**
* @brief close persistence handle
*
* @param the handle to close
- *
- * @return error code
*/
-int set_persistence_handle_close_idx(int handle, char* dbPath, char* key, PersistenceInfo_s* info);
+void set_persistence_handle_close_idx(int handle);
#include "persistence_client_library_handle.h"
#include "persistence_client_library_pas_interface.h"
#include "persistence_client_library_prct_access.h"
-
+#include "persistence_client_library_custom_loader.h"
// ----------------------------------------------------------------------------
if( (handle >= 0)
&& (dbContext.configKey.type == PersistenceResourceType_key) ) // check if type matches
{
- handle = get_persistence_handle_idx(dbPath, dbKey, &dbContext);
-
- if((handle < MaxPersHandle) && (0 <= handle))
- {
- // remember data in handle array
- strncpy(gKeyHandleArray[handle].dbPath, dbPath, DbPathMaxLen);
- strncpy(gKeyHandleArray[handle].dbKey, dbKey, DbKeyMaxLen);
- strncpy(gKeyHandleArray[handle].resourceID, resource_id, DbResIDMaxLen);
- gKeyHandleArray[handle].dbPath[DbPathMaxLen-1] = '\0'; // Ensures 0-Termination
- gKeyHandleArray[handle].dbKey[ DbPathMaxLen-1] = '\0'; // Ensures 0-Termination
- gKeyHandleArray[handle].info = dbContext;
- }
- else
+ if(dbContext.configKey.storage < PersistenceStorage_LastEntry) // check if store policy is valid
{
- DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleOpen: error - handleId out of bounds:"), DLT_INT(handle));
+ if(PersistenceStorage_custom == dbContext.configKey.storage)
+ {
+ int idx = custom_client_name_to_id(dbPath, 1);
+ char workaroundPath[128]; // workaround, because /sys/ can not be accessed on host!!!!
+ snprintf(workaroundPath, 128, "%s%s", "/Data", dbPath );
+
+ if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_open != NULL) )
+ {
+ int flag = 0, mode = 0;
+ handle = gPersCustomFuncs[idx].custom_plugin_handle_open(workaroundPath, flag, mode);
+ }
+ else
+ {
+ handle = EPERS_NOPLUGINFUNCT;
+ }
+ }
+ else
+ {
+ handle = get_persistence_handle_idx();
+ }
+
+ if((handle < MaxPersHandle) && (0 <= handle))
+ {
+ // remember data in handle array
+ strncpy(gKeyHandleArray[handle].dbPath, dbPath, DbPathMaxLen);
+ strncpy(gKeyHandleArray[handle].dbKey, dbKey, DbKeyMaxLen);
+ strncpy(gKeyHandleArray[handle].resourceID, resource_id, DbResIDMaxLen);
+ gKeyHandleArray[handle].dbPath[DbPathMaxLen-1] = '\0'; // Ensures 0-Termination
+ gKeyHandleArray[handle].dbKey[ DbPathMaxLen-1] = '\0'; // Ensures 0-Termination
+ gKeyHandleArray[handle].info = dbContext;
+ }
+ else
+ {
+ DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleOpen: error - handleId out of bounds:"), DLT_INT(handle));
+ }
}
}
else
{
if(key_handle < MaxPersHandle)
{
- rval= set_persistence_handle_close_idx(key_handle, gKeyHandleArray[key_handle].dbPath,
- gKeyHandleArray[key_handle].dbKey,
- &gKeyHandleArray[key_handle].info);
+ if(PersistenceStorage_custom == gKeyHandleArray[key_handle].info.configKey.storage )
+ {
+ int idx = custom_client_name_to_id(gKeyHandleArray[key_handle].dbPath, 1);
+
+ if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_close != NULL) )
+ {
+ rval = gPersCustomFuncs[idx].custom_plugin_handle_close(key_handle);
+ }
+ else
+ {
+ rval = EPERS_NOPLUGINFUNCT;
+ }
+ }
+ else
+ {
+ set_persistence_handle_close_idx(key_handle);
+ }
// invalidate entries
memset(gKeyHandleArray[key_handle].dbPath, 0, DbPathMaxLen);
{
if(key_handle < MaxPersHandle)
{
- size = pers_db_get_key_size(gKeyHandleArray[key_handle].dbPath, gKeyHandleArray[key_handle].dbKey,
- &gKeyHandleArray[key_handle].info);
+ if(PersistenceStorage_custom == gKeyHandleArray[key_handle].info.configKey.storage)
+ {
+ int idx = custom_client_name_to_id(gKeyHandleArray[key_handle].dbPath, 1);
+
+ if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_get_size != NULL) )
+ {
+ size = gPersCustomFuncs[idx].custom_plugin_get_size(gKeyHandleArray[key_handle].dbPath);
+ }
+ else
+ {
+ size = EPERS_NOPLUGINFUNCT;
+ }
+ }
+ else
+ {
+ size = pers_db_get_key_size(gKeyHandleArray[key_handle].dbPath, gKeyHandleArray[key_handle].dbKey,
+ &gKeyHandleArray[key_handle].info);
+ }
}
else
{
{
int size = EPERS_NOT_INITIALIZED;
- //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleReadData: "),
- // DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) );
+ //DLT_LOG(gDLTContext, DLT_LOG_INFO, DLT_STRING("pclKeyHandleReadData: "),
+ // DLT_INT(gKeyHandleArray[key_handle].info.context.ldbid), DLT_STRING(gKeyHandleArray[key_handle].resourceID) );
- if(gPclInitialized >= PCLinitialized)
+ if(gPclInitialized >= PCLinitialized)
+ {
+ if(key_handle < MaxPersHandle)
{
- if(key_handle < MaxPersHandle)
+ if(PersistenceStorage_custom == gKeyHandleArray[key_handle].info.configKey.storage)
{
- size = pers_db_read_key(gKeyHandleArray[key_handle].dbPath, gKeyHandleArray[key_handle].dbKey,
- &gKeyHandleArray[key_handle].info, buffer, buffer_size);
+ int idx = custom_client_name_to_id(gKeyHandleArray[key_handle].dbPath, 1);
+
+ if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_get_data != NULL) )
+ {
+ size = gPersCustomFuncs[idx].custom_plugin_handle_get_data(key_handle, (char*)buffer, buffer_size-1);
+ }
+ else
+ {
+ size = EPERS_NOPLUGINFUNCT;
+ }
}
else
{
- size = EPERS_MAXHANDLE;
+ size = pers_db_read_key(gKeyHandleArray[key_handle].dbPath, gKeyHandleArray[key_handle].dbKey,
+ &gKeyHandleArray[key_handle].info, buffer, buffer_size);
}
}
+ else
+ {
+ size = EPERS_MAXHANDLE;
+ }
+ }
- return size;
+ return size;
}
{
if(key_handle < MaxPersHandle)
{
-
- size = pers_db_write_key(gKeyHandleArray[key_handle].dbPath, gKeyHandleArray[key_handle].dbKey,
- &gKeyHandleArray[key_handle].info, buffer, buffer_size);
+ if(PersistenceStorage_custom == gKeyHandleArray[key_handle].info.configKey.storage)
+ {
+ int idx = custom_client_name_to_id(gKeyHandleArray[key_handle].dbPath, 1);
+
+ if( (idx < PersCustomLib_LastEntry) && (gPersCustomFuncs[idx].custom_plugin_handle_set_data != NULL) )
+ {
+ size = gPersCustomFuncs[idx].custom_plugin_handle_set_data(key_handle, (char*)buffer, buffer_size-1);
+ }
+ else
+ {
+ size = EPERS_NOPLUGINFUNCT;
+ }
+ }
+ else
+ {
+ size = pers_db_write_key(gKeyHandleArray[key_handle].dbPath, gKeyHandleArray[key_handle].dbKey,
+ &gKeyHandleArray[key_handle].info, buffer, buffer_size);
+ }
}
else
{
}
else
{
- size = EPERS_MAX_BUFF_SIZE;
DLT_LOG(gDLTContext, DLT_LOG_ERROR, DLT_STRING("pclKeyHandleWriteData: error - buffer_size to big, limit is [bytes]:"), DLT_INT(gMaxKeyValDataSize));
+ size = EPERS_MAX_BUFF_SIZE;
}
}
else
#include <unistd.h>
#include <dlfcn.h>
-static int gTimeoutMs = 5000; // 5 seconds
+static int gTimeoutMs = 50000;
int check_lc_request(int request, int requestID)
{
#include <unistd.h>
-static int gTimeoutMs = 5000; // 5 seconds
+static int gTimeoutMs = 50000;
/// flag if access is locked
static int gLockAccess = 0;
int pers_data_sync(void)
{
- return 1; // TODO implement sync data back
+ sync();
+ return 1;
}
void pers_lock_access(void)
}
close(gEfds);
}
+ //dbus_connection_close(conn);
dbus_connection_unref(conn);
dbus_shutdown();
}
if(pAddress != NULL)
{
printf("Use specific dbus address: %s\n !", pAddress);
- gDbusConn = dbus_connection_open(pAddress, &err);
+ gDbusConn = dbus_connection_open_private(pAddress, &err);
if(gDbusConn != NULL)
{
/// debug log and trace (DLT) setup
DLT_REGISTER_APP("noty","tests the persistence client library");
- pclInitLibrary("lt-persistence_client_library_dbus_test", shutdownReg);
-
+ ret = pclInitLibrary("lt-persistence_client_library_dbus_test", shutdownReg);
+ printf("pclInitLibrary: %d\n", ret);
+#if 0
printf("Press a key to end application\n");
ret = pclKeyHandleOpen(0xFF, "posHandle/last_position", 0, 0);
ret = pclKeyRegisterNotifyOnChange(0x84, "links/last_link4", 4/*user_no*/, 1/*seat_no*/, &myChangeCallback);
getchar();
-
+#endif
+ sleep(2);
pclDeinitLibrary();
unsigned char buffer[READ_SIZE] = {0};
- pclInitLibrary(gTheAppId, shutdownReg);
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
/**
* Logical DB ID: 0xFF with user 0 and seat 0
char sysTimeBuffer[128];
- pclInitLibrary(gTheAppId, shutdownReg);
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
time_t t = time(0);
struct tm *locTime;
- pclInitLibrary(gTheAppId, shutdownReg);
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
time_t t = time(0);
unsigned char buffer[READ_SIZE] = {0};
struct tm *locTime;
- pclInitLibrary(gTheAppId, shutdownReg);
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
+
time_t t = time(0);
char sysTimeBuffer[128];
*/
START_TEST(test_GetDataSize)
{
- int size = 0;
+ int size = 0, ret = 0;
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- pclInitLibrary(gTheAppId, shutdownReg);
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
/**
* Logical DB ID: 0xFF with user 3 and seat 2
unsigned char buffer[READ_SIZE];
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- pclInitLibrary(gTheAppId, shutdownReg);
+ rval = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(rval < 0, "Failed to init PCL");
// read data from key
rval = pclKeyReadData(0xFF, "key_70", 1, 2, buffer, READ_SIZE);
char* writeBuffer;
char* fileMap = NULL;
- pclInitLibrary(gTheAppId, shutdownReg);
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
writeBuffer = malloc(writeSize);
char* wBuffer = "This is a buffer to write";
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- pclInitLibrary(gTheAppId, shutdownReg);
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
// test backup creation --------------------------------------------
fd_RO = pclFileOpen(0xFF, "media/mediaDB_ReadOnly.db", 1, 1);
int ret = 0;
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- pclInitLibrary(gTheAppId, shutdownReg);
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
// test file handles
handle1 = pclFileOpen(0xFF, "media/mediaDB.db", 1, 1);
fail_unless(handle1 != -1, "Could not closefile ==> /media/mediaDB.db");
ret = pclFileClose(1024);
- fail_unless(ret == -1, "Could close file, but should not!!");
+ fail_unless(ret == EPERS_MAXHANDLE, "Could close file, but should not!!");
+
ret = pclFileClose(17);
fail_unless(ret == -1, "Could close file, but should not!!");
fail_unless(ret != -1, "Failed to close handle!!");
ret = pclKeyHandleClose(1024);
- fail_unless(ret == -4, "Max handle!!");
+ fail_unless(ret == EPERS_MAXHANDLE, "Max handle!!");
pclDeinitLibrary();
}
int hd1 = -2, hd2 = -2, hd3 = -2, hd4 = -2, hd5 = -2, hd6 = -2, hd7 = -2, hd8 = -2, hd9 = -2, ret = 0;
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- pclInitLibrary(gTheAppId, shutdownReg);
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
// open handles ----------------------------------------------------
hd1 = pclKeyHandleOpen(0xFF, "posHandle/last_position1", 0, 0);
char bufferDataDst[READ_SIZE] = {0};
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- pclInitLibrary(gTheAppId, shutdownReg);
+ rval = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(rval < 0, "Failed to init PCL");
// create cursor
handle = pers_db_cursor_create("/Data/mnt-c/lt-persistence_client_library_test/cached.itz");
unsigned char buffer[READ_SIZE] = {0};
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- pclInitLibrary(gTheAppId, shutdownReg);
+
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
ret = pclKeyReadData(0xFF, "language/country_code", 0, 0, buffer, READ_SIZE);
fail_unless(ret != EPERS_NOT_INITIALIZED);
unsigned char buffer[READ_SIZE] = {0};
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- pclInitLibrary(gTheAppId, shutdownReg);
+
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
ret = pclKeyReadData(0xFF, "statusHandle/default01", 3, 2, buffer, READ_SIZE);
fail_unless(ret != EPERS_NOT_INITIALIZED);
- printf("B U F F E R: %s\n", buffer);
+ //printf("B U F F E R: %s\n", buffer);
fail_unless(strncmp((char*)buffer,"DEFAULT_01!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
ret = pclKeyReadData(0xFF, "statusHandle/default02", 3, 2, buffer, READ_SIZE);
fail_unless(ret != EPERS_NOT_INITIALIZED);
- printf("B U F F E R: %s\n", buffer);
+ //printf("B U F F E R: %s\n", buffer);
fail_unless(strncmp((char*)buffer,"DEFAULT_02!", strlen((char*)buffer)) == 0, "Buffer not correctly read");
pclDeinitLibrary();
unsigned char buffer[READ_SIZE] = {0};
unsigned int shutdownReg = PCL_SHUTDOWN_TYPE_FAST | PCL_SHUTDOWN_TYPE_NORMAL;
- pclInitLibrary(gTheAppId, shutdownReg);
+
+ ret = pclInitLibrary(gTheAppId, shutdownReg);
+ fail_unless(ret < 0, "Failed to init PCL");
ret = pclKeyReadData(0xFF, "statusHandle/confdefault01", 3, 2, buffer, READ_SIZE);
fail_unless(ret != EPERS_NOT_INITIALIZED);
suite_add_tcase(s, tc_ReadDefault);
suite_add_tcase(s, tc_ReadConfDefault);
- suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
+ //suite_add_tcase(s, tc_Plugin); // activate only if the plugins are available
return s;
}
gPollInfo.fds[0].events = POLLIN;
// register for messages
- if ( (TRUE==dbus_connection_register_object_path(conn, "/org/genivi/NodeStateManager/LifecycleConsumer", &vtable, userData))
+ if ( (TRUE==dbus_connection_register_object_path(conn, "/org/genivi/NodeStateManager", &vtable, userData))
&& (TRUE==dbus_connection_register_fallback(conn, "/", &vtableFallback, userData)) )
{
if (TRUE!=dbus_connection_set_watch_functions(conn, addWatch, removeWatch, watchToggled, NULL, NULL))
switch (buf[0])
{
case CMD_REQUEST_NAME:
- if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER !=dbus_bus_request_name(conn, "org.genivi.NodeStateManager.LifecycleConsumer", DBUS_NAME_FLAG_DO_NOT_QUEUE, &err))
+ if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER !=dbus_bus_request_name(conn, "org.genivi.NodeStateManager", DBUS_NAME_FLAG_DO_NOT_QUEUE, &err))
{
- fprintf(stderr, "Cannot acquire name 'org.genivi.NodeStateManager.LifeCycleConsumer': \n \"(%s)\". Bailing out!\n", err.message);
+ fprintf(stderr, "Cannot acquire name 'org.genivi.NodeStateManager': \n \"(%s)\". Bailing out!\n", err.message);
dbus_error_free(&err);
bContinue = FALSE;
}
}
while (0!=bContinue);
}
- dbus_connection_unregister_object_path(conn, "/org/genivi/NodeStateManager/LifeCycleConsumer");
+ dbus_connection_unregister_object_path(conn, "/org/genivi/NodeStateManager");
dbus_connection_unregister_object_path(conn, "/");
}
close(gEfds);
}
+ //dbus_connection_close(conn);
dbus_connection_unref(conn);
dbus_shutdown();
}
if(pAddress != NULL)
{
printf("Use specific dbus address: %s\n !", pAddress);
- gDbusConn = dbus_connection_open(pAddress, &err);
+ gDbusConn = dbus_connection_open_private(pAddress, &err);
if(gDbusConn != NULL)
{