From 57069c8c0e792fe0b1cca46d8907122c35014055 Mon Sep 17 00:00:00 2001 From: Goldenkrew3000 Date: Sun, 15 Mar 2026 08:43:32 +1000 Subject: [PATCH] Added option to disable local music playback and to change client socket path --- src/configHandler.c | 25 +++++++++++++++++++++++++ src/configHandler.h | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/src/configHandler.c b/src/configHandler.c index 3ed6101..0b2166f 100644 --- a/src/configHandler.c +++ b/src/configHandler.c @@ -5,6 +5,8 @@ * Info: Configuration Handler */ +// TODO REFACTOR with OSS_P*oj + #include #include #include @@ -68,7 +70,9 @@ int configHandler_Read(configHandler_config_t** configObj) { (*configObj)->lv2_parax32_frequency_left = NULL; (*configObj)->lv2_parax32_frequency_right = NULL; (*configObj)->lv2_reverb_filter_name = NULL; + (*configObj)->local_enable = false; (*configObj)->local_rootdir = NULL; + (*configObj)->client_socket_path = NULL; // Set internal configuration values (*configObj)->internal_opensubsonic_version = strdup("1.8.0"); @@ -474,10 +478,30 @@ int configHandler_Read(configHandler_config_t** configObj) { return 1; } + cJSON* local_enable = cJSON_GetObjectItemCaseSensitive(scrobbler_root, "enable"); + if (cJSON_IsBool(local_enable)) { + if (cJSON_IsTrue(local_enable)) { + (*configObj)->local_enable = true; + } + } + cJSON* local_root_directory = cJSON_GetObjectItemCaseSensitive(local_root, "rootDirectory"); if (cJSON_IsString(local_root_directory) && local_root_directory->valuestring != NULL) { (*configObj)->local_rootdir = strdup(local_root_directory->valuestring); } + + // Make an object from client + cJSON* client_root = cJSON_GetObjectItemCaseSensitive(root, "client"); + if (client_root == NULL) { + logger_log_error(__func__, "Error parsing JSON - client does not exist."); + cJSON_Delete(root); + return 1; + } + + cJSON* client_socket_path = cJSON_GetObjectItemCaseSensitive(client_root, "socketPath"); + if (cJSON_IsString(client_socket_path) && client_socket_path->valuestring != NULL) { + (*configObj)->client_socket_path = strdup(client_socket_path->valuestring); + } cJSON_Delete(root); logger_log_general(__func__, "Successfully read configuration file."); @@ -512,5 +536,6 @@ void configHandler_Free(configHandler_config_t** configObj) { if ((*configObj)->lv2_parax32_frequency_right != NULL) { free((*configObj)->lv2_parax32_frequency_right); } if ((*configObj)->lv2_reverb_filter_name != NULL) { free((*configObj)->lv2_reverb_filter_name); } if ((*configObj)->local_rootdir != NULL) { free((*configObj)->local_rootdir); } + if ((*configObj)->client_socket_path != NULL) { free((*configObj)->client_socket_path); } if (*configObj != NULL) { free(*configObj); } } diff --git a/src/configHandler.h b/src/configHandler.h index c3ef84a..32e9615 100644 --- a/src/configHandler.h +++ b/src/configHandler.h @@ -67,7 +67,11 @@ typedef struct { char* lv2_reverb_filter_name; // LV2 Calf Reverb LV2 Name // Local Settings + bool local_enable; // Enable Local Music Playback char* local_rootdir; // Local Music Root Directory + + // Client Settings + char* client_socket_path; // Socket Path for client } configHandler_config_t; int configHandler_Read(configHandler_config_t** config);