Skip to content

Commit f5d2cc1

Browse files
committed
Fix default configuration file installation location
Open-webOS-DCO-1.0-Signed-off-by: Pekka Ropo <[email protected]> Change-Id: I5e7ee638f4efc84224398d2643d6ed160e7a19e2
1 parent 7bc9a8a commit f5d2cc1

File tree

7 files changed

+19
-35
lines changed

7 files changed

+19
-35
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,4 @@ webos_build_daemon()
9696
webos_build_system_bus_files()
9797

9898
install(PROGRAMS scripts/public/suspend_action DESTINATION ${WEBOS_INSTALL_SBINDIR})
99-
install(FILES files/conf/sleepd.conf DESTINATION ${WEBOS_INSTALL_LOCALSTATEDIR}/preferences)
99+
install(FILES files/conf/sleepd.conf DESTINATION ${WEBOS_INSTALL_DEFAULTCONFDIR})

files/launch/sleepd.in

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ start on stopped finish
2727
stop on started start_update
2828

2929
respawn
30-
31-
pre-start script
32-
CONF_DIR="@WEBOS_INSTALL_LOCALSTATEDIR@/preferences/com.palm.sleep"
33-
CONF_FILE="${CONF_DIR}/sleepd.conf"
34-
DEFAULT_CONF_FILE="@WEBOS_INSTALL_DEFAULTCONFDIR@/sleepd.conf"
35-
TMP_FILE="${CONF_DIR}/sleepd.tmp"
36-
if [ ! -f ${CONF_FILE} ]; then
37-
mkdir -p ${CONF_DIR} || true
38-
cp ${DEFAULT_CONF_FILE} ${TMP_FILE} || true
39-
sync || true
40-
mv ${TMP_FILE} ${CONF_FILE} || true
41-
fi
42-
end script
4330

4431
service
4532
exec @WEBOS_INSTALL_SBINDIR@/sleepd

include/internal/main.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#include <luna-service2/lunaservice.h>
2828
#include <nyx/nyx_client.h>
2929

30-
#define PREFERENCE_DIR "/var/preferences/com.palm.sleep"
31-
3230
GMainContext * GetMainLoopContext(void);
3331

3432
LSHandle * GetLunaServiceHandle(void);

src/alarms/alarm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#include "main.h"
4242
#include "logging.h"
43+
#include "config.h"
4344
#include "timeout_alarm.h"
4445

4546
#define LOG_DOMAIN "ALARM: "
@@ -681,7 +682,7 @@ alarm_queue_create(void)
681682
gAlarmQueue->seq_id = 0;
682683

683684
gAlarmQueue->alarm_db =
684-
g_build_filename(PREFERENCE_DIR, "alarms.xml", NULL);
685+
g_build_filename(gSleepConfig.preference_dir, "alarms.xml", NULL);
685686

686687
return 0;
687688
}

src/alarms/timeout_alarm.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@
6767

6868
#define STD_ASCTIME_BUF_SIZE 26
6969

70-
// FIXME: database path should be based on gPowerConfig.preference_dir
71-
#define TIMEOUT_DATABASE_NAME "/var/preferences/com.palm.sleep/SysTimeouts.db"
72-
7370
// This allows testing the SQL commands to add the new columns. Set to false for production code
7471
#define CREATE_DB_WITHOUT_ACTIVITY_COLUMNS 0
7572

73+
#define TIMEOUT_DATABASE_NAME "SysTimeouts.db"
74+
7675
typedef enum {
7776
AlarmTimeoutRelative,
7877
AlarmTimeoutCalendar,
@@ -82,7 +81,6 @@ static LSPalmService *psh = NULL;
8281
static sqlite3 *timeout_db = NULL;
8382
static GTimerSource *sTimerCheck = NULL;
8483

85-
static const char* kSysTimeoutDatabaseName = TIMEOUT_DATABASE_NAME;
8684
/*
8785
Database Schema.
8886
@@ -1289,29 +1287,27 @@ _alarms_timeout_init(void)
12891287
{
12901288
bool retVal;
12911289

1290+
gchar* timeout_db_name = g_build_filename(gSleepConfig.preference_dir, TIMEOUT_DATABASE_NAME, NULL);
1291+
12921292
if (gSleepConfig.disable_rtc_alarms)
12931293
{
12941294
SLEEPDLOG(LOG_INFO, "%s: RTC alarms disabled", __FUNCTION__);
12951295
return 0;
12961296
}
12971297

1298-
/* Set up database */
1299-
const char* ptr = strrchr( kSysTimeoutDatabaseName, '/' );
1300-
gchar* filename = g_filename_from_utf8( kSysTimeoutDatabaseName, ptr-kSysTimeoutDatabaseName, 0, 0, 0);
1301-
if (!filename) {
1302-
goto error;
1303-
}
1304-
1305-
g_mkdir_with_parents(filename, S_IRWXU);
1306-
g_free(filename);
1298+
gchar* timeout_db_path = g_path_get_dirname(timeout_db_name);
1299+
g_mkdir_with_parents(timeout_db_path, S_IRWXU);
1300+
g_free(timeout_db_path);
13071301

1308-
retVal = smart_sql_open( kSysTimeoutDatabaseName, &timeout_db );
1302+
retVal = smart_sql_open( timeout_db_name, &timeout_db );
13091303
if( !retVal ) {
13101304
SLEEPDLOG(LOG_ERR,"Failed to open database %s\n",
1311-
kSysTimeoutDatabaseName );
1305+
timeout_db_name );
13121306
goto error;
13131307
}
13141308

1309+
g_free(timeout_db_name);
1310+
13151311
retVal = smart_sql_exec( timeout_db, kSysTimeoutDatabaseCreateSchema );
13161312
if( !retVal ) {
13171313
SLEEPDLOG(LOG_ERR, "%s could not create database\n", __FUNCTION__);

src/config.c.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ config_init(void)
111111
return -1;
112112
}
113113

114+
// Load default values from configuration file
114115
char *config_path =
115-
g_build_filename(gSleepConfig.preference_dir, "sleepd.conf", NULL);
116+
g_build_filename("@WEBOS_INSTALL_DEFAULTCONFDIR@", "sleepd.conf", NULL);
116117
retVal = g_key_file_load_from_file(config_file, config_path,
117118
G_KEY_FILE_NONE, NULL);
118119
if (!retVal)

src/utils/timesaver.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <fcntl.h>
2828
#include <string.h>
2929

30+
#include "config.h"
3031
#include "logging.h"
3132
#include "main.h"
3233

@@ -49,9 +50,9 @@ timesaver_save()
4950
if (!time_db)
5051
{
5152
time_db = g_build_filename(
52-
PREFERENCE_DIR, "time_saver", NULL);
53+
gSleepConfig.preference_dir, "time_saver", NULL);
5354
time_db_tmp = g_build_filename(
54-
PREFERENCE_DIR, "time_saver.tmp", NULL);
55+
gSleepConfig.preference_dir, "time_saver.tmp", NULL);
5556
}
5657

5758
if (NULL == time_db)

0 commit comments

Comments
 (0)