diff --git a/.SRCINFO b/.SRCINFO index 80a4b61..5e0952d 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,6 +1,6 @@ pkgbase = coolerdash pkgdesc = Plug-in for CoolerControl that extends the LCD functionality with additional features - pkgver = 3.1.1 + pkgver = 3.1.2 pkgrel = 1 url = https://github.com/damachine/coolerdash install = coolerdash.install diff --git a/VERSION b/VERSION index 94ff29c..ef538c2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.1 +3.1.2 diff --git a/src/main.c b/src/main.c index b1c8f25..ef1a34c 100644 --- a/src/main.c +++ b/src/main.c @@ -903,22 +903,6 @@ int main(int argc, char **argv) log_message(LOG_INFO, "Rendering initial display image..."); draw_display_image(&config); - /* CC4: Register shutdown.png once at startup so CoolerControl displays - * it natively when the CC daemon stops (MR !417 / CC 4.0). */ - if (config.paths_image_shutdown[0]) - { - char device_uid[128] = {0}; - if (get_cached_lcd_device_data(&config, device_uid, - sizeof(device_uid), NULL, 0, NULL, - NULL) && - device_uid[0]) - { - register_shutdown_image_with_cc(&config, - config.paths_image_shutdown, - device_uid); - } - } - log_message(LOG_STATUS, "Starting daemon"); int result = run_daemon(&config); diff --git a/src/srv/cc_main.c b/src/srv/cc_main.c index dfa5c37..05ecaa9 100644 --- a/src/srv/cc_main.c +++ b/src/srv/cc_main.c @@ -402,115 +402,3 @@ int send_image_to_lcd(const Config *config, const char *image_path, return success; } - -/** - * @brief Register shutdown image with CC4's persistent LCD shutdown endpoint. - * @details Called once at daemon startup. Sends the shutdown image path to - * PUT /devices/{uid}/settings/lcd/lcd/shutdown-image so CoolerControl - * displays it automatically whenever the CC daemon itself stops. - * Gracefully skips if the endpoint is unavailable. - */ -int register_shutdown_image_with_cc(const Config *config, - const char *image_path, - const char *device_uid) -{ - if (!validate_upload_params(image_path, device_uid)) - return 0; - - if (!image_path || !image_path[0]) - return 1; - - /* Verify the file exists before attempting to register */ - FILE *f = fopen(image_path, "r"); - if (!f) - { - log_message(LOG_WARNING, - "CC4 shutdown registration skipped: image not found: %s", - image_path); - return 0; - } - fclose(f); - - char upload_url[CC_URL_SIZE]; - int written = snprintf(upload_url, sizeof(upload_url), - "%s/devices/%s/settings/lcd/lcd/shutdown-image", - config->daemon_address, device_uid); - if (!validate_snprintf(written, sizeof(upload_url), upload_url)) - return 0; - - /* Build JSON body matching LcdSettings schema */ - json_t *body = json_object(); - if (!body) - { - log_message(LOG_ERROR, "Failed to create JSON object for shutdown image"); - return 0; - } - - json_object_set_new(body, "mode", json_string("image")); - json_object_set_new(body, "image_file_processed", json_string(image_path)); - json_object_set_new(body, "brightness", json_integer(config->lcd_brightness)); - json_object_set_new(body, "orientation", json_integer(config->lcd_orientation)); - json_object_set_new(body, "colors", json_array()); - - char *json_str = json_dumps(body, JSON_COMPACT); - json_decref(body); - if (!json_str) - { - log_message(LOG_ERROR, "Failed to serialize shutdown image JSON"); - return 0; - } - - http_response response = {0}; - if (!cc_init_response_buffer(&response, 4096)) - { - free(json_str); - return 0; - } - - curl_easy_setopt(cc_session.curl_handle, CURLOPT_URL, upload_url); - curl_easy_setopt(cc_session.curl_handle, CURLOPT_CUSTOMREQUEST, "PUT"); - curl_easy_setopt(cc_session.curl_handle, CURLOPT_POSTFIELDS, json_str); - curl_easy_setopt( - cc_session.curl_handle, CURLOPT_WRITEFUNCTION, - (size_t (*)(const void *, size_t, size_t, void *))write_callback); - curl_easy_setopt(cc_session.curl_handle, CURLOPT_WRITEDATA, &response); - - struct curl_slist *headers = NULL; - headers = curl_slist_append(headers, "Content-Type: application/json"); - headers = curl_slist_append(headers, "User-Agent: CoolerDash/1.0"); - headers = curl_slist_append(headers, "Accept: application/json"); - headers = curl_slist_append(headers, cc_session.access_token); - curl_easy_setopt(cc_session.curl_handle, CURLOPT_HTTPHEADER, headers); - - CURLcode res = curl_easy_perform(cc_session.curl_handle); - long http_code = -1; - curl_easy_getinfo(cc_session.curl_handle, CURLINFO_RESPONSE_CODE, &http_code); - - int success = 0; - if (res == CURLE_OK && (http_code == 200 || http_code == 204)) - { - log_message(LOG_STATUS, - "Shutdown image registered with CC4 (HTTP %ld)", http_code); - success = 1; - } - else if (res == CURLE_OK && http_code == 404) - { - log_message(LOG_WARNING, - "CC4 shutdown image endpoint not available (HTTP 404) " - "- requires CoolerControl 4.0 or later"); - } - else - { - log_message(LOG_WARNING, - "Shutdown image registration failed: CURL %d, HTTP %ld", - res, http_code); - } - - cc_cleanup_response_buffer(&response); - if (headers) - curl_slist_free_all(headers); - free(json_str); - reset_curl_request_options(); - - return success; -} diff --git a/src/srv/cc_main.h b/src/srv/cc_main.h index 88e55a7..a59672e 100644 --- a/src/srv/cc_main.h +++ b/src/srv/cc_main.h @@ -72,9 +72,4 @@ const char *get_session_access_token(void); int send_image_to_lcd(const struct Config *config, const char *image_path, const char *device_uid); -/** @brief Register shutdown image with CC4; called once at startup. */ -int register_shutdown_image_with_cc(const struct Config *config, - const char *image_path, - const char *device_uid); - #endif // CC_MAIN_H