Files
Crosspoint/src/activities/ActivityResult.h
T
jpirnayandClaude Opus 4.6 b625b8bd26 Add paragraph index LUT for accurate KOReader position sync
Store per-page paragraph indices in section cache to enable precise
XPath-to-page and page-to-XPath mapping without reparsing XHTML.

Forward path (upload): generates XPath directly from paragraph LUT
instead of byte-offset estimation, eliminating drift in chapters
with non-uniform content density.

Reverse path (download): resolves incoming KOReader XPath p[N] to
the exact page via paragraph LUT lookup.

Paragraph counter counts all <p> elements including display:none
to match ChapterXPathIndexer and crengine's standard XPath counting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 12:29:26 +01:00

72 lines
1.6 KiB
C++

#pragma once
#include <cstdint>
#include <functional>
#include <string>
#include <type_traits>
#include <utility>
#include <variant>
struct WifiResult {
bool connected = false;
std::string ssid;
std::string ip;
};
struct KeyboardResult {
std::string text;
};
struct MenuResult {
int action = -1;
uint8_t orientation = 0;
uint8_t pageTurnOption = 0;
int8_t embeddedStyleOverride = -1;
int8_t imageRenderingOverride = -1;
};
struct ChapterResult {
int spineIndex = 0;
};
struct PercentResult {
int percent = 0;
};
struct PageResult {
uint32_t page = 0;
};
struct SyncResult {
int spineIndex = 0;
int page = 0; // estimated page (fallback)
uint16_t paragraphIndex = 0; // 1-based <p> index from XPath
bool hasParagraphIndex = false; // true when paragraphIndex is available
};
enum class NetworkMode;
struct NetworkModeResult {
NetworkMode mode;
};
struct FootnoteResult {
std::string href;
};
using ResultVariant = std::variant<std::monostate, WifiResult, KeyboardResult, MenuResult, ChapterResult, PercentResult,
PageResult, SyncResult, NetworkModeResult, FootnoteResult>;
struct ActivityResult {
bool isCancelled = false;
ResultVariant data;
explicit ActivityResult() = default;
template <typename ResultType, typename = std::enable_if_t<std::is_constructible_v<ResultVariant, ResultType&&>>>
// cppcheck-suppress noExplicitConstructor
ActivityResult(ResultType&& result) : data{std::forward<ResultType>(result)} {}
};
using ActivityResultHandler = std::function<void(const ActivityResult&)>;