mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-13 02:23:01 +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_CFLAGS = -D_AUDIO
|
||||
AUDIO_OBJ = device.o audio_call.o
|
||||
AV_LOADED = 0
|
||||
|
||||
# Variables for sound notify support
|
||||
SND_NOTIFY_LIBS = openal freealut
|
||||
SND_NOTIFY_CFLAGS = -D_SOUND_NOTIFY
|
||||
SND_NOTIFY_OBJ = device.o
|
||||
SND_NOTIFY_OBJ =
|
||||
|
||||
# Check on wich system we are running
|
||||
UNAME_S = $(shell uname -s)
|
||||
@ -80,6 +81,7 @@ ifneq ($(CHECK_AUDIO_LIBS), error)
|
||||
LIBS += $(AUDIO_LIBS)
|
||||
CFLAGS += $(AUDIO_CFLAGS)
|
||||
OBJ += $(AUDIO_OBJ)
|
||||
AV_LOADED = 1
|
||||
else
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
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)
|
||||
LIBS += $(SND_NOTIFY_LIBS)
|
||||
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)
|
||||
|
||||
else
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
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
|
||||
timestamps:true;
|
||||
|
||||
// true to disabale terminal alerts on messages, false to enable
|
||||
// true to enable terminal alerts on messages, false to disable
|
||||
alerts:true;
|
||||
|
||||
// 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
|
||||
autolog:false;
|
||||
@ -34,7 +34,7 @@ audio = {
|
||||
|
||||
tox = {
|
||||
// where to store received files
|
||||
download_path="/home/USERNAME/Downloads/";
|
||||
// download_path="/home/USERNAME/Downloads/";
|
||||
};
|
||||
|
||||
sounds = {
|
||||
|
@ -73,7 +73,7 @@ const struct _tox_strings {
|
||||
|
||||
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
|
||||
@ -124,7 +124,7 @@ const struct _sound_strings {
|
||||
};
|
||||
#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_setting_t *setting;
|
||||
@ -138,9 +138,29 @@ int settings_load(struct user_settings *s, char *path)
|
||||
#endif
|
||||
|
||||
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);
|
||||
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 ( config_setting_lookup_string(setting, tox_strings.download_path, &str) ) {
|
||||
s->download_path = calloc(1, strlen(str) + 1);
|
||||
strcpy(s->download_path, str);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ struct user_settings {
|
||||
int timestamps; /* boolean */
|
||||
int colour_theme; /* boolean (0 for default toxic colours) */
|
||||
int history_size; /* int between MIN_HISTORY and MAX_HISTORY */
|
||||
char* download_path;
|
||||
char download_path[MAX_STR_SIZE];
|
||||
|
||||
#ifdef _AUDIO
|
||||
int audio_in_dev;
|
||||
@ -59,6 +59,6 @@ enum {
|
||||
DFLT_HST_SIZE = 700,
|
||||
} 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 */
|
||||
|
Loading…
Reference in New Issue
Block a user