#pragma once #include #include #include #include #include #include #include #include "../Activity.h" /** * Activity for browsing and downloading books from an OPDS server. * Displays a list of available books and allows downloading EPUBs. */ class OpdsBookBrowserActivity final : public Activity { public: enum class BrowserState { LOADING, // Fetching OPDS feed BOOK_LIST, // Displaying books DOWNLOADING, // Downloading selected EPUB ERROR // Error state with message }; explicit OpdsBookBrowserActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, const std::function& onGoHome) : Activity("OpdsBookBrowser", renderer, mappedInput), onGoHome(onGoHome) {} void onEnter() override; void onExit() override; void loop() override; private: TaskHandle_t displayTaskHandle = nullptr; SemaphoreHandle_t renderingMutex = nullptr; bool updateRequired = false; BrowserState state = BrowserState::LOADING; std::vector books; int selectorIndex = 0; std::string errorMessage; std::string statusMessage; size_t downloadProgress = 0; size_t downloadTotal = 0; const std::function onGoHome; static void taskTrampoline(void* param); [[noreturn]] void displayTaskLoop(); void render() const; void fetchBooks(); void downloadBook(const OpdsBook& book); std::string sanitizeFilename(const std::string& title) const; };