mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 21:53:05 +01:00
fix config file loading, fix makefile compile errors
This commit is contained in:
parent
654e404e0e
commit
ac01d6d316
@ -33,11 +33,12 @@ OBJ += log.o misc_tools.o prompt.o settings.o toxic.o toxic_strings.o windows.o
|
|||||||
AUDIO_LIBS = libtoxav openal
|
AUDIO_LIBS = libtoxav openal
|
||||||
AUDIO_CFLAGS = -D_AUDIO
|
AUDIO_CFLAGS = -D_AUDIO
|
||||||
AUDIO_OBJ = device.o audio_call.o
|
AUDIO_OBJ = device.o audio_call.o
|
||||||
|
AV_LOADED = 0
|
||||||
|
|
||||||
# Variables for sound notify support
|
# Variables for sound notify support
|
||||||
SND_NOTIFY_LIBS = openal freealut
|
SND_NOTIFY_LIBS = openal freealut
|
||||||
SND_NOTIFY_CFLAGS = -D_SOUND_NOTIFY
|
SND_NOTIFY_CFLAGS = -D_SOUND_NOTIFY
|
||||||
SND_NOTIFY_OBJ = device.o
|
SND_NOTIFY_OBJ =
|
||||||
|
|
||||||
# Check on wich system we are running
|
# Check on wich system we are running
|
||||||
UNAME_S = $(shell uname -s)
|
UNAME_S = $(shell uname -s)
|
||||||
@ -80,6 +81,7 @@ ifneq ($(CHECK_AUDIO_LIBS), error)
|
|||||||
LIBS += $(AUDIO_LIBS)
|
LIBS += $(AUDIO_LIBS)
|
||||||
CFLAGS += $(AUDIO_CFLAGS)
|
CFLAGS += $(AUDIO_CFLAGS)
|
||||||
OBJ += $(AUDIO_OBJ)
|
OBJ += $(AUDIO_OBJ)
|
||||||
|
AV_LOADED = 1
|
||||||
else
|
else
|
||||||
ifneq ($(MAKECMDGOALS), clean)
|
ifneq ($(MAKECMDGOALS), clean)
|
||||||
MISSING_AUDIO_LIBS = $(shell for lib in $(AUDIO_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
|
MISSING_AUDIO_LIBS = $(shell for lib in $(AUDIO_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
|
||||||
@ -96,7 +98,13 @@ CHECK_NOTIFY_LIBS = $(shell pkg-config $(SND_NOTIFY_LIBS) || echo -n "error")
|
|||||||
ifneq ($(CHECK_NOTIFY_LIBS), error)
|
ifneq ($(CHECK_NOTIFY_LIBS), error)
|
||||||
LIBS += $(SND_NOTIFY_LIBS)
|
LIBS += $(SND_NOTIFY_LIBS)
|
||||||
CFLAGS += $(SND_NOTIFY_CFLAGS)
|
CFLAGS += $(SND_NOTIFY_CFLAGS)
|
||||||
|
|
||||||
|
# device.o is needed for both audio calls and notifications but should only be loaded once
|
||||||
|
ifneq ($(AV_LOADED), 1)
|
||||||
|
SND_NOTIFY_OBJ += device.o
|
||||||
|
endif
|
||||||
OBJ += $(SND_NOTIFY_OBJ)
|
OBJ += $(SND_NOTIFY_OBJ)
|
||||||
|
|
||||||
else
|
else
|
||||||
ifneq ($(MAKECMDGOALS), clean)
|
ifneq ($(MAKECMDGOALS), clean)
|
||||||
MISSING_NOTIFY_LIBS = $(shell for lib in $(SND_NOTIFY_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
|
MISSING_NOTIFY_LIBS = $(shell for lib in $(SND_NOTIFY_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
|
||||||
|
@ -5,11 +5,11 @@ ui = {
|
|||||||
// true to enable timestamps, false to disable
|
// true to enable timestamps, false to disable
|
||||||
timestamps:true;
|
timestamps:true;
|
||||||
|
|
||||||
// true to disabale terminal alerts on messages, false to enable
|
// true to enable terminal alerts on messages, false to disable
|
||||||
alerts:true;
|
alerts:true;
|
||||||
|
|
||||||
// true to use native terminal colours, false to use toxic default colour theme
|
// true to use native terminal colours, false to use toxic default colour theme
|
||||||
native_colors:true;
|
native_colors:false;
|
||||||
|
|
||||||
// true to enable autologging, false to disable
|
// true to enable autologging, false to disable
|
||||||
autolog:false;
|
autolog:false;
|
||||||
@ -34,7 +34,7 @@ audio = {
|
|||||||
|
|
||||||
tox = {
|
tox = {
|
||||||
// where to store received files
|
// where to store received files
|
||||||
download_path="/home/USERNAME/Downloads/";
|
// download_path="/home/USERNAME/Downloads/";
|
||||||
};
|
};
|
||||||
|
|
||||||
sounds = {
|
sounds = {
|
||||||
|
@ -73,7 +73,7 @@ const struct _tox_strings {
|
|||||||
|
|
||||||
static void tox_defaults(struct user_settings* settings)
|
static void tox_defaults(struct user_settings* settings)
|
||||||
{
|
{
|
||||||
/*settings->download_path;*/ /* TODO: Set this? */
|
strcpy(settings->download_path, ""); /* explicitly set default to pwd */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _AUDIO
|
#ifdef _AUDIO
|
||||||
@ -124,7 +124,7 @@ const struct _sound_strings {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int settings_load(struct user_settings *s, char *path)
|
int settings_load(struct user_settings *s, const char *patharg)
|
||||||
{
|
{
|
||||||
config_t cfg[1];
|
config_t cfg[1];
|
||||||
config_setting_t *setting;
|
config_setting_t *setting;
|
||||||
@ -138,9 +138,29 @@ int settings_load(struct user_settings *s, char *path)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
config_init(cfg);
|
config_init(cfg);
|
||||||
|
|
||||||
|
char path[MAX_STR_SIZE];
|
||||||
|
|
||||||
|
/* use default config file path */
|
||||||
|
if (patharg == NULL) {
|
||||||
|
char *user_config_dir = get_user_config_dir();
|
||||||
|
snprintf(path, sizeof(path), "%s%stoxic.conf", user_config_dir, CONFIGDIR);
|
||||||
|
free(user_config_dir);
|
||||||
|
|
||||||
|
/* make sure path exists or is created on first time running */
|
||||||
|
FILE *fp = fopen(path, "r");
|
||||||
|
|
||||||
|
if (fp == NULL) {
|
||||||
|
if ((fp = fopen(path, "w")) == NULL)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
} else {
|
||||||
|
snprintf(path, sizeof(path), "%s", patharg);
|
||||||
|
}
|
||||||
|
|
||||||
if(!config_read_file(cfg, path))
|
if (!config_read_file(cfg, path)) {
|
||||||
{
|
|
||||||
config_destroy(cfg);
|
config_destroy(cfg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -159,7 +179,6 @@ int settings_load(struct user_settings *s, char *path)
|
|||||||
|
|
||||||
if ((setting = config_lookup(cfg, tox_strings.self)) != NULL) {
|
if ((setting = config_lookup(cfg, tox_strings.self)) != NULL) {
|
||||||
if ( config_setting_lookup_string(setting, tox_strings.download_path, &str) ) {
|
if ( config_setting_lookup_string(setting, tox_strings.download_path, &str) ) {
|
||||||
s->download_path = calloc(1, strlen(str) + 1);
|
|
||||||
strcpy(s->download_path, str);
|
strcpy(s->download_path, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ struct user_settings {
|
|||||||
int timestamps; /* boolean */
|
int timestamps; /* boolean */
|
||||||
int colour_theme; /* boolean (0 for default toxic colours) */
|
int colour_theme; /* boolean (0 for default toxic colours) */
|
||||||
int history_size; /* int between MIN_HISTORY and MAX_HISTORY */
|
int history_size; /* int between MIN_HISTORY and MAX_HISTORY */
|
||||||
char* download_path;
|
char download_path[MAX_STR_SIZE];
|
||||||
|
|
||||||
#ifdef _AUDIO
|
#ifdef _AUDIO
|
||||||
int audio_in_dev;
|
int audio_in_dev;
|
||||||
@ -59,6 +59,6 @@ enum {
|
|||||||
DFLT_HST_SIZE = 700,
|
DFLT_HST_SIZE = 700,
|
||||||
} settings_values;
|
} settings_values;
|
||||||
|
|
||||||
int settings_load(struct user_settings *s, char *path);
|
int settings_load(struct user_settings *s, const char *patharg);
|
||||||
|
|
||||||
#endif /* #define _settings_h */
|
#endif /* #define _settings_h */
|
||||||
|
Loading…
Reference in New Issue
Block a user