mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 23:27:38 +03:00
Apply clang-format fixes
This commit is contained in:
parent
24736eaa50
commit
a1be4bbfac
@ -1,9 +1,10 @@
|
|||||||
#include "KOReaderSyncClient.h"
|
#include "KOReaderSyncClient.h"
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <HardwareSerial.h>
|
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
|
#include <HardwareSerial.h>
|
||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include "KOReaderCredentialStore.h"
|
#include "KOReaderCredentialStore.h"
|
||||||
|
|||||||
@ -5,12 +5,12 @@
|
|||||||
* Progress data from KOReader sync server.
|
* Progress data from KOReader sync server.
|
||||||
*/
|
*/
|
||||||
struct KOReaderProgress {
|
struct KOReaderProgress {
|
||||||
std::string document; // Document hash
|
std::string document; // Document hash
|
||||||
std::string progress; // XPath-like progress string
|
std::string progress; // XPath-like progress string
|
||||||
float percentage; // Progress percentage (0.0 to 1.0)
|
float percentage; // Progress percentage (0.0 to 1.0)
|
||||||
std::string device; // Device name
|
std::string device; // Device name
|
||||||
std::string deviceId; // Device ID
|
std::string deviceId; // Device ID
|
||||||
int64_t timestamp; // Unix timestamp of last update
|
int64_t timestamp; // Unix timestamp of last update
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,15 +29,7 @@ struct KOReaderProgress {
|
|||||||
*/
|
*/
|
||||||
class KOReaderSyncClient {
|
class KOReaderSyncClient {
|
||||||
public:
|
public:
|
||||||
enum Error {
|
enum Error { OK = 0, NO_CREDENTIALS, NETWORK_ERROR, AUTH_FAILED, SERVER_ERROR, JSON_ERROR, NOT_FOUND };
|
||||||
OK = 0,
|
|
||||||
NO_CREDENTIALS,
|
|
||||||
NETWORK_ERROR,
|
|
||||||
AUTH_FAILED,
|
|
||||||
SERVER_ERROR,
|
|
||||||
JSON_ERROR,
|
|
||||||
NOT_FOUND
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticate with the sync server (validate credentials).
|
* Authenticate with the sync server (validate credentials).
|
||||||
|
|||||||
@ -8,9 +8,9 @@
|
|||||||
* CrossPoint position representation.
|
* CrossPoint position representation.
|
||||||
*/
|
*/
|
||||||
struct CrossPointPosition {
|
struct CrossPointPosition {
|
||||||
int spineIndex; // Current spine item (chapter) index
|
int spineIndex; // Current spine item (chapter) index
|
||||||
int pageNumber; // Current page within the spine item
|
int pageNumber; // Current page within the spine item
|
||||||
int totalPages; // Total pages in the current spine item
|
int totalPages; // Total pages in the current spine item
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -207,8 +207,8 @@ void KOReaderSyncActivity::onEnter() {
|
|||||||
|
|
||||||
// Launch WiFi selection subactivity
|
// Launch WiFi selection subactivity
|
||||||
Serial.printf("[%lu] [KOSync] Launching WifiSelectionActivity...\n", millis());
|
Serial.printf("[%lu] [KOSync] Launching WifiSelectionActivity...\n", millis());
|
||||||
enterNewActivity(
|
enterNewActivity(new WifiSelectionActivity(renderer, mappedInput,
|
||||||
new WifiSelectionActivity(renderer, mappedInput, [this](const bool connected) { onWifiSelectionComplete(connected); }));
|
[this](const bool connected) { onWifiSelectionComplete(connected); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void KOReaderSyncActivity::onExit() {
|
void KOReaderSyncActivity::onExit() {
|
||||||
@ -275,10 +275,11 @@ void KOReaderSyncActivity::render() {
|
|||||||
// Get chapter names from TOC
|
// Get chapter names from TOC
|
||||||
const int remoteTocIndex = epub->getTocIndexForSpineIndex(remotePosition.spineIndex);
|
const int remoteTocIndex = epub->getTocIndexForSpineIndex(remotePosition.spineIndex);
|
||||||
const int localTocIndex = epub->getTocIndexForSpineIndex(currentSpineIndex);
|
const int localTocIndex = epub->getTocIndexForSpineIndex(currentSpineIndex);
|
||||||
const std::string remoteChapter =
|
const std::string remoteChapter = (remoteTocIndex >= 0)
|
||||||
(remoteTocIndex >= 0) ? epub->getTocItem(remoteTocIndex).title : ("Section " + std::to_string(remotePosition.spineIndex + 1));
|
? epub->getTocItem(remoteTocIndex).title
|
||||||
const std::string localChapter =
|
: ("Section " + std::to_string(remotePosition.spineIndex + 1));
|
||||||
(localTocIndex >= 0) ? epub->getTocItem(localTocIndex).title : ("Section " + std::to_string(currentSpineIndex + 1));
|
const std::string localChapter = (localTocIndex >= 0) ? epub->getTocItem(localTocIndex).title
|
||||||
|
: ("Section " + std::to_string(currentSpineIndex + 1));
|
||||||
|
|
||||||
// Remote progress - chapter and page
|
// Remote progress - chapter and page
|
||||||
renderer.drawText(UI_10_FONT_ID, 20, 160, "Remote:", true);
|
renderer.drawText(UI_10_FONT_ID, 20, 160, "Remote:", true);
|
||||||
@ -286,7 +287,8 @@ void KOReaderSyncActivity::render() {
|
|||||||
snprintf(remoteChapterStr, sizeof(remoteChapterStr), " %s", remoteChapter.c_str());
|
snprintf(remoteChapterStr, sizeof(remoteChapterStr), " %s", remoteChapter.c_str());
|
||||||
renderer.drawText(UI_10_FONT_ID, 20, 185, remoteChapterStr);
|
renderer.drawText(UI_10_FONT_ID, 20, 185, remoteChapterStr);
|
||||||
char remotePageStr[64];
|
char remotePageStr[64];
|
||||||
snprintf(remotePageStr, sizeof(remotePageStr), " Page %d, %.0f%% overall", remotePosition.pageNumber + 1, remoteProgress.percentage * 100);
|
snprintf(remotePageStr, sizeof(remotePageStr), " Page %d, %.0f%% overall", remotePosition.pageNumber + 1,
|
||||||
|
remoteProgress.percentage * 100);
|
||||||
renderer.drawText(UI_10_FONT_ID, 20, 210, remotePageStr);
|
renderer.drawText(UI_10_FONT_ID, 20, 210, remotePageStr);
|
||||||
|
|
||||||
if (!remoteProgress.device.empty()) {
|
if (!remoteProgress.device.empty()) {
|
||||||
@ -301,7 +303,8 @@ void KOReaderSyncActivity::render() {
|
|||||||
snprintf(localChapterStr, sizeof(localChapterStr), " %s", localChapter.c_str());
|
snprintf(localChapterStr, sizeof(localChapterStr), " %s", localChapter.c_str());
|
||||||
renderer.drawText(UI_10_FONT_ID, 20, 295, localChapterStr);
|
renderer.drawText(UI_10_FONT_ID, 20, 295, localChapterStr);
|
||||||
char localPageStr[64];
|
char localPageStr[64];
|
||||||
snprintf(localPageStr, sizeof(localPageStr), " Page %d/%d, %.0f%% overall", currentPage + 1, totalPagesInSpine, localProgress.percentage * 100);
|
snprintf(localPageStr, sizeof(localPageStr), " Page %d/%d, %.0f%% overall", currentPage + 1, totalPagesInSpine,
|
||||||
|
localProgress.percentage * 100);
|
||||||
renderer.drawText(UI_10_FONT_ID, 20, 320, localPageStr);
|
renderer.drawText(UI_10_FONT_ID, 20, 320, localPageStr);
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user