Skip to content

Commit 29c61f4

Browse files
authored
VERSION: bump to 3.1.2 (#156)
1 parent 0a0b182 commit 29c61f4

5 files changed

Lines changed: 2 additions & 135 deletions

File tree

.SRCINFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pkgbase = coolerdash
22
pkgdesc = Plug-in for CoolerControl that extends the LCD functionality with additional features
3-
pkgver = 3.1.1
3+
pkgver = 3.1.2
44
pkgrel = 1
55
url = https://github.com/damachine/coolerdash
66
install = coolerdash.install

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.1
1+
3.1.2

src/main.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -903,22 +903,6 @@ int main(int argc, char **argv)
903903
log_message(LOG_INFO, "Rendering initial display image...");
904904
draw_display_image(&config);
905905

906-
/* CC4: Register shutdown.png once at startup so CoolerControl displays
907-
* it natively when the CC daemon stops (MR !417 / CC 4.0). */
908-
if (config.paths_image_shutdown[0])
909-
{
910-
char device_uid[128] = {0};
911-
if (get_cached_lcd_device_data(&config, device_uid,
912-
sizeof(device_uid), NULL, 0, NULL,
913-
NULL) &&
914-
device_uid[0])
915-
{
916-
register_shutdown_image_with_cc(&config,
917-
config.paths_image_shutdown,
918-
device_uid);
919-
}
920-
}
921-
922906
log_message(LOG_STATUS, "Starting daemon");
923907
int result = run_daemon(&config);
924908

src/srv/cc_main.c

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -402,115 +402,3 @@ int send_image_to_lcd(const Config *config, const char *image_path,
402402

403403
return success;
404404
}
405-
406-
/**
407-
* @brief Register shutdown image with CC4's persistent LCD shutdown endpoint.
408-
* @details Called once at daemon startup. Sends the shutdown image path to
409-
* PUT /devices/{uid}/settings/lcd/lcd/shutdown-image so CoolerControl
410-
* displays it automatically whenever the CC daemon itself stops.
411-
* Gracefully skips if the endpoint is unavailable.
412-
*/
413-
int register_shutdown_image_with_cc(const Config *config,
414-
const char *image_path,
415-
const char *device_uid)
416-
{
417-
if (!validate_upload_params(image_path, device_uid))
418-
return 0;
419-
420-
if (!image_path || !image_path[0])
421-
return 1;
422-
423-
/* Verify the file exists before attempting to register */
424-
FILE *f = fopen(image_path, "r");
425-
if (!f)
426-
{
427-
log_message(LOG_WARNING,
428-
"CC4 shutdown registration skipped: image not found: %s",
429-
image_path);
430-
return 0;
431-
}
432-
fclose(f);
433-
434-
char upload_url[CC_URL_SIZE];
435-
int written = snprintf(upload_url, sizeof(upload_url),
436-
"%s/devices/%s/settings/lcd/lcd/shutdown-image",
437-
config->daemon_address, device_uid);
438-
if (!validate_snprintf(written, sizeof(upload_url), upload_url))
439-
return 0;
440-
441-
/* Build JSON body matching LcdSettings schema */
442-
json_t *body = json_object();
443-
if (!body)
444-
{
445-
log_message(LOG_ERROR, "Failed to create JSON object for shutdown image");
446-
return 0;
447-
}
448-
449-
json_object_set_new(body, "mode", json_string("image"));
450-
json_object_set_new(body, "image_file_processed", json_string(image_path));
451-
json_object_set_new(body, "brightness", json_integer(config->lcd_brightness));
452-
json_object_set_new(body, "orientation", json_integer(config->lcd_orientation));
453-
json_object_set_new(body, "colors", json_array());
454-
455-
char *json_str = json_dumps(body, JSON_COMPACT);
456-
json_decref(body);
457-
if (!json_str)
458-
{
459-
log_message(LOG_ERROR, "Failed to serialize shutdown image JSON");
460-
return 0;
461-
}
462-
463-
http_response response = {0};
464-
if (!cc_init_response_buffer(&response, 4096))
465-
{
466-
free(json_str);
467-
return 0;
468-
}
469-
470-
curl_easy_setopt(cc_session.curl_handle, CURLOPT_URL, upload_url);
471-
curl_easy_setopt(cc_session.curl_handle, CURLOPT_CUSTOMREQUEST, "PUT");
472-
curl_easy_setopt(cc_session.curl_handle, CURLOPT_POSTFIELDS, json_str);
473-
curl_easy_setopt(
474-
cc_session.curl_handle, CURLOPT_WRITEFUNCTION,
475-
(size_t (*)(const void *, size_t, size_t, void *))write_callback);
476-
curl_easy_setopt(cc_session.curl_handle, CURLOPT_WRITEDATA, &response);
477-
478-
struct curl_slist *headers = NULL;
479-
headers = curl_slist_append(headers, "Content-Type: application/json");
480-
headers = curl_slist_append(headers, "User-Agent: CoolerDash/1.0");
481-
headers = curl_slist_append(headers, "Accept: application/json");
482-
headers = curl_slist_append(headers, cc_session.access_token);
483-
curl_easy_setopt(cc_session.curl_handle, CURLOPT_HTTPHEADER, headers);
484-
485-
CURLcode res = curl_easy_perform(cc_session.curl_handle);
486-
long http_code = -1;
487-
curl_easy_getinfo(cc_session.curl_handle, CURLINFO_RESPONSE_CODE, &http_code);
488-
489-
int success = 0;
490-
if (res == CURLE_OK && (http_code == 200 || http_code == 204))
491-
{
492-
log_message(LOG_STATUS,
493-
"Shutdown image registered with CC4 (HTTP %ld)", http_code);
494-
success = 1;
495-
}
496-
else if (res == CURLE_OK && http_code == 404)
497-
{
498-
log_message(LOG_WARNING,
499-
"CC4 shutdown image endpoint not available (HTTP 404) "
500-
"- requires CoolerControl 4.0 or later");
501-
}
502-
else
503-
{
504-
log_message(LOG_WARNING,
505-
"Shutdown image registration failed: CURL %d, HTTP %ld",
506-
res, http_code);
507-
}
508-
509-
cc_cleanup_response_buffer(&response);
510-
if (headers)
511-
curl_slist_free_all(headers);
512-
free(json_str);
513-
reset_curl_request_options();
514-
515-
return success;
516-
}

src/srv/cc_main.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,4 @@ const char *get_session_access_token(void);
7272
int send_image_to_lcd(const struct Config *config, const char *image_path,
7373
const char *device_uid);
7474

75-
/** @brief Register shutdown image with CC4; called once at startup. */
76-
int register_shutdown_image_with_cc(const struct Config *config,
77-
const char *image_path,
78-
const char *device_uid);
79-
8075
#endif // CC_MAIN_H

0 commit comments

Comments
 (0)