From e30b7a551a00ed6dd4a743a2492483e37945f7bc Mon Sep 17 00:00:00 2001 From: jpirnay Date: Wed, 22 Apr 2026 07:18:28 +0200 Subject: [PATCH 01/39] Introduction of small helper routines --- lib/KOReaderSync/KOReaderSyncClient.cpp | 65 ++++++++++--------------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/lib/KOReaderSync/KOReaderSyncClient.cpp b/lib/KOReaderSync/KOReaderSyncClient.cpp index 2bc41079..9bfc1087 100644 --- a/lib/KOReaderSync/KOReaderSyncClient.cpp +++ b/lib/KOReaderSync/KOReaderSyncClient.cpp @@ -247,6 +247,15 @@ void resetSessionClientForRetry() { } } +void applyAuthHeaders(esp_http_client_handle_t client) { + esp_http_client_set_header(client, "Accept", "application/vnd.koreader.v1+json"); + esp_http_client_set_header(client, "x-auth-user", KOREADER_STORE.getUsername().c_str()); + esp_http_client_set_header(client, "x-auth-key", KOREADER_STORE.getMd5Password().c_str()); + + std::string credentials = KOREADER_STORE.getUsername() + ":" + KOREADER_STORE.getPassword(); + esp_http_client_set_header(client, "Authorization", ("Basic " + base64Encode(credentials)).c_str()); +} + // Create configured esp_http_client with small TLS buffers esp_http_client_handle_t createClient(const char* url, ResponseBuffer* buf, esp_http_client_method_t method = HTTP_METHOD_GET) { @@ -256,14 +265,7 @@ esp_http_client_handle_t createClient(const char* url, ResponseBuffer* buf, esp_http_client_set_url(g_sessionClient, url); esp_http_client_set_method(g_sessionClient, method); - // KOSync auth headers - esp_http_client_set_header(g_sessionClient, "Accept", "application/vnd.koreader.v1+json"); - esp_http_client_set_header(g_sessionClient, "x-auth-user", KOREADER_STORE.getUsername().c_str()); - esp_http_client_set_header(g_sessionClient, "x-auth-key", KOREADER_STORE.getMd5Password().c_str()); - - std::string credentials = KOREADER_STORE.getUsername() + ":" + KOREADER_STORE.getPassword(); - std::string authHeader = "Basic " + base64Encode(credentials); - esp_http_client_set_header(g_sessionClient, "Authorization", authHeader.c_str()); + applyAuthHeaders(g_sessionClient); return g_sessionClient; } @@ -285,15 +287,7 @@ esp_http_client_handle_t createClient(const char* url, ResponseBuffer* buf, esp_http_client_handle_t client = esp_http_client_init(&config); if (!client) return nullptr; - // KOSync auth headers - esp_http_client_set_header(client, "Accept", "application/vnd.koreader.v1+json"); - esp_http_client_set_header(client, "x-auth-user", KOREADER_STORE.getUsername().c_str()); - esp_http_client_set_header(client, "x-auth-key", KOREADER_STORE.getMd5Password().c_str()); - - // HTTP Basic Auth for Calibre-Web-Automated compatibility - std::string credentials = KOREADER_STORE.getUsername() + ":" + KOREADER_STORE.getPassword(); - std::string authHeader = "Basic " + base64Encode(credentials); - esp_http_client_set_header(client, "Authorization", authHeader.c_str()); + applyAuthHeaders(client); if (g_keepSessionOpen) { g_sessionClient = client; @@ -303,6 +297,13 @@ esp_http_client_handle_t createClient(const char* url, ResponseBuffer* buf, } } // namespace +// Returns true if credentials are present; logs and returns false otherwise. +static inline bool hasCredentials() { + if (KOREADER_STORE.hasCredentials()) return true; + LOG_INF("KOSync", "No credentials configured"); + return false; +} + void KOReaderSyncClient::beginPersistentSession() { g_keepSessionOpen = true; clearResponseBuffer(&g_sessionResponseBuf); @@ -318,16 +319,13 @@ void KOReaderSyncClient::endPersistentSession() { } KOReaderSyncClient::Error KOReaderSyncClient::registerUser() { - if (!KOREADER_STORE.hasCredentials()) { - LOG_DBG("KOSync", "No credentials configured"); - return NO_CREDENTIALS; - } + if (!hasCredentials()) return NO_CREDENTIALS; beginRequest("register"); if (!checkHeapForTls()) return NETWORK_ERROR; std::string url = KOREADER_STORE.getBaseUrl() + "/users/create"; - LOG_DBG("KOSync", "Registering user: %s (heap: %u, contig: %u)", url.c_str(), lastHeapAtFailure, + LOG_INF("KOSync", "Registering user: %s (heap: %u, contig: %u)", url.c_str(), lastHeapAtFailure, lastContigHeapAtFailure); JsonDocument doc; @@ -390,10 +388,7 @@ KOReaderSyncClient::Error KOReaderSyncClient::registerUser() { } KOReaderSyncClient::Error KOReaderSyncClient::authenticate() { - if (!KOREADER_STORE.hasCredentials()) { - LOG_DBG("KOSync", "No credentials configured"); - return NO_CREDENTIALS; - } + if (!hasCredentials()) return NO_CREDENTIALS; beginRequest("auth"); if (!checkHeapForTls()) return NETWORK_ERROR; @@ -436,10 +431,7 @@ KOReaderSyncClient::Error KOReaderSyncClient::authenticate() { KOReaderSyncClient::Error KOReaderSyncClient::getProgress(const std::string& documentHash, KOReaderProgress& outProgress) { - if (!KOREADER_STORE.hasCredentials()) { - LOG_DBG("KOSync", "No credentials configured"); - return NO_CREDENTIALS; - } + if (!hasCredentials()) return NO_CREDENTIALS; beginRequest("get progress"); if (!checkHeapForTls()) return NETWORK_ERROR; @@ -522,7 +514,7 @@ KOReaderSyncClient::Error KOReaderSyncClient::getProgress(const std::string& doc if (doc["progress"].isNull()) { std::string jsonDump; serializeJson(doc, jsonDump); - LOG_DBG("KOSync", "Empty progress payload — treating as not found | payload=%s", jsonDump.c_str()); + LOG_INF("KOSync", "Empty progress payload — treating as not found | payload=%s", jsonDump.c_str()); return NOT_FOUND; } @@ -533,23 +525,20 @@ KOReaderSyncClient::Error KOReaderSyncClient::getProgress(const std::string& doc outProgress.deviceId = doc["device_id"].as(); outProgress.timestamp = doc["timestamp"].as(); - LOG_DBG("KOSync", "Got progress: %.2f%% at %s", outProgress.percentage * 100, outProgress.progress.c_str()); + LOG_INF("KOSync", "Got progress: %.2f%% at %s", outProgress.percentage * 100, outProgress.progress.c_str()); return OK; } if (httpCode == 401) return AUTH_FAILED; if (httpCode == 404) { - LOG_DBG("KOSync", "GET progress returned 404 for %s - treating as NOT_FOUND", url.c_str()); + LOG_INF("KOSync", "GET progress returned 404 for %s - treating as NOT_FOUND", url.c_str()); return NOT_FOUND; } return SERVER_ERROR; } KOReaderSyncClient::Error KOReaderSyncClient::updateProgress(const KOReaderProgress& progress) { - if (!KOREADER_STORE.hasCredentials()) { - LOG_DBG("KOSync", "No credentials configured"); - return NO_CREDENTIALS; - } + if (!hasCredentials()) return NO_CREDENTIALS; beginRequest("update progress"); if (!checkHeapForTls()) return NETWORK_ERROR; @@ -569,7 +558,7 @@ KOReaderSyncClient::Error KOReaderSyncClient::updateProgress(const KOReaderProgr std::string body; serializeJson(doc, body); - LOG_DBG("KOSync", "Request body: %s", body.c_str()); + LOG_INF("KOSync", "Request body: %s", body.c_str()); ResponseBuffer buf; ResponseBuffer* activeBuf = effectiveResponseBuffer(&buf); From 9116070335bb1b9f53def67487f02f3ebca489fa Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 23 Apr 2026 09:24:39 +0200 Subject: [PATCH 02/39] Update Spanish according to upstream #1717 --- lib/I18n/translations/spanish.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/I18n/translations/spanish.yaml b/lib/I18n/translations/spanish.yaml index 2f04f2b6..241e8c98 100644 --- a/lib/I18n/translations/spanish.yaml +++ b/lib/I18n/translations/spanish.yaml @@ -316,8 +316,8 @@ STR_FOOTNOTES: "Pie de página" STR_NO_FOOTNOTES: "No hay notas al pie de esta página" STR_LINK: "[enlace]" STR_SCREENSHOT_BUTTON: "Tomar captura de pantalla" -STR_AUTO_TURN_ENABLED: "Paso automático de páginas: " -STR_AUTO_TURN_PAGES_PER_MIN: "Paso automático de páginas (pág./min.)" +STR_AUTO_TURN_ENABLED: "Avance activado: " +STR_AUTO_TURN_PAGES_PER_MIN: "Avance auto. (pág./min)" STR_REGISTER: "Registrarse" STR_REGISTERING: "Registrando..." STR_REGISTER_SUCCESS: "¡Cuenta creada correctamente!" From e5e825e7a571b65a248dbb063b7c5abcf54e3c8e Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 23 Apr 2026 09:25:50 +0200 Subject: [PATCH 03/39] Update Italian according to #1718 --- lib/I18n/translations/italian.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/I18n/translations/italian.yaml b/lib/I18n/translations/italian.yaml index 35d52909..de90093a 100644 --- a/lib/I18n/translations/italian.yaml +++ b/lib/I18n/translations/italian.yaml @@ -318,7 +318,7 @@ STR_UPLOAD: "Carica" STR_BOOK_S_STYLE: "Stile libro" STR_EMBEDDED_STYLE: "Stile integrato dell'epub" STR_OPDS_SERVER_URL: "Server OPDS" -STR_FOOTNOTES: "Note piè pagina" +STR_FOOTNOTES: "Note a piè pagina" STR_NO_FOOTNOTES: "Nessuna nota in questa pagina" STR_LINK: "[link]" STR_SCREENSHOT_BUTTON: "Screenshot" From 4981086a1d290926d5a648b8b98899cce84325b5 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Thu, 23 Apr 2026 09:29:28 +0200 Subject: [PATCH 04/39] Update html title strings according to #1703 --- src/network/html/FilesPage.html | 23 +++++++++++++++-------- src/network/html/SettingsPage.html | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/network/html/FilesPage.html b/src/network/html/FilesPage.html index 256a86d0..1cb3f7db 100644 --- a/src/network/html/FilesPage.html +++ b/src/network/html/FilesPage.html @@ -4,12 +4,13 @@ - CrossPoint Reader - Files + Files - CrossPoint Reader