mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 15:17:37 +03:00
style: apply clang-format
This commit is contained in:
parent
f611cc9615
commit
f3ec7b8800
@ -1,33 +1,35 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Activity.h"
|
|
||||||
#include "../../extension/AppLoader.h"
|
|
||||||
#include <GfxRenderer.h>
|
#include <GfxRenderer.h>
|
||||||
#include <MappedInputManager.h>
|
#include <MappedInputManager.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "../../extension/AppLoader.h"
|
||||||
|
#include "../Activity.h"
|
||||||
|
|
||||||
class AppsActivity : public Activity {
|
class AppsActivity : public Activity {
|
||||||
public:
|
public:
|
||||||
using ExitCallback = std::function<void()>;
|
using ExitCallback = std::function<void()>;
|
||||||
|
|
||||||
AppsActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, ExitCallback exitCallback);
|
AppsActivity(GfxRenderer& renderer, MappedInputManager& mappedInput, ExitCallback exitCallback);
|
||||||
|
|
||||||
void onEnter() override;
|
void onEnter() override;
|
||||||
void onExit() override;
|
void onExit() override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GfxRenderer& renderer_;
|
GfxRenderer& renderer_;
|
||||||
MappedInputManager& mappedInput_;
|
MappedInputManager& mappedInput_;
|
||||||
ExitCallback exitCallback_;
|
ExitCallback exitCallback_;
|
||||||
|
|
||||||
std::vector<CrossPoint::AppInfo> appList_;
|
std::vector<CrossPoint::AppInfo> appList_;
|
||||||
int selectedIndex_;
|
int selectedIndex_;
|
||||||
bool needsUpdate_;
|
bool needsUpdate_;
|
||||||
bool isFlashing_;
|
bool isFlashing_;
|
||||||
int flashProgress_;
|
int flashProgress_;
|
||||||
|
|
||||||
void scanApps();
|
void scanApps();
|
||||||
void launchApp();
|
void launchApp();
|
||||||
void render();
|
void render();
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
#include <EpdFontFamily.h>
|
#include <EpdFontFamily.h>
|
||||||
#include <GfxRenderer.h>
|
#include <GfxRenderer.h>
|
||||||
#include <builtinFonts/all.h>
|
#include <builtinFonts/all.h>
|
||||||
|
|
||||||
#include <esp_attr.h>
|
#include <esp_attr.h>
|
||||||
#include <esp_ota_ops.h>
|
#include <esp_ota_ops.h>
|
||||||
#include <esp_system.h>
|
#include <esp_system.h>
|
||||||
@ -17,7 +16,7 @@ namespace {
|
|||||||
EpdFont ui12RegularFont(&ubuntu_12_regular);
|
EpdFont ui12RegularFont(&ubuntu_12_regular);
|
||||||
EpdFont ui12BoldFont(&ubuntu_12_bold);
|
EpdFont ui12BoldFont(&ubuntu_12_bold);
|
||||||
EpdFontFamily ui12FontFamily(&ui12RegularFont, &ui12BoldFont);
|
EpdFontFamily ui12FontFamily(&ui12RegularFont, &ui12BoldFont);
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
HelloWorldActivity::HelloWorldActivity(HalDisplay& display, HalGPIO& input)
|
HelloWorldActivity::HelloWorldActivity(HalDisplay& display, HalGPIO& input)
|
||||||
: display_(display), input_(input), needsUpdate_(true) {}
|
: display_(display), input_(input), needsUpdate_(true) {}
|
||||||
|
|||||||
@ -6,16 +6,16 @@
|
|||||||
class HelloWorldActivity {
|
class HelloWorldActivity {
|
||||||
public:
|
public:
|
||||||
HelloWorldActivity(HalDisplay& display, HalGPIO& input);
|
HelloWorldActivity(HalDisplay& display, HalGPIO& input);
|
||||||
|
|
||||||
void onEnter();
|
void onEnter();
|
||||||
void loop();
|
void loop();
|
||||||
void onExit();
|
void onExit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HalDisplay& display_;
|
HalDisplay& display_;
|
||||||
HalGPIO& input_;
|
HalGPIO& input_;
|
||||||
bool needsUpdate_;
|
bool needsUpdate_;
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
void returnToLauncher();
|
void returnToLauncher();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
#include "AppLoader.h"
|
#include "AppLoader.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <esp_ota_ops.h>
|
#include <esp_ota_ops.h>
|
||||||
#include <esp_partition.h>
|
#include <esp_partition.h>
|
||||||
#include <esp_system.h>
|
#include <esp_system.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "Battery.h"
|
#include "Battery.h"
|
||||||
|
|
||||||
namespace CrossPoint {
|
namespace CrossPoint {
|
||||||
@ -85,8 +86,8 @@ AppManifest AppLoader::parseManifest(const String& path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fileSize > MAX_MANIFEST_SIZE) {
|
if (fileSize > MAX_MANIFEST_SIZE) {
|
||||||
Serial.printf("[%lu] [AppLoader] Manifest file too large (%u bytes, max %u): %s\n",
|
Serial.printf("[%lu] [AppLoader] Manifest file too large (%u bytes, max %u): %s\n", millis(), fileSize,
|
||||||
millis(), fileSize, MAX_MANIFEST_SIZE, path.c_str());
|
MAX_MANIFEST_SIZE, path.c_str());
|
||||||
file.close();
|
file.close();
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
@ -97,8 +98,8 @@ AppManifest AppLoader::parseManifest(const String& path) {
|
|||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
if (bytesRead != fileSize) {
|
if (bytesRead != fileSize) {
|
||||||
Serial.printf("[%lu] [AppLoader] Failed to read complete manifest file (read %u of %u bytes): %s\n",
|
Serial.printf("[%lu] [AppLoader] Failed to read complete manifest file (read %u of %u bytes): %s\n", millis(),
|
||||||
millis(), bytesRead, fileSize, path.c_str());
|
bytesRead, fileSize, path.c_str());
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,8 +114,7 @@ AppManifest AppLoader::parseManifest(const String& path) {
|
|||||||
const DeserializationError error = deserializeJson(doc, json);
|
const DeserializationError error = deserializeJson(doc, json);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
Serial.printf("[%lu] [AppLoader] JSON parse error in %s: %s\n",
|
Serial.printf("[%lu] [AppLoader] JSON parse error in %s: %s\n", millis(), path.c_str(), error.c_str());
|
||||||
millis(), path.c_str(), error.c_str());
|
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,8 +307,6 @@ String AppLoader::buildManifestPath(const String& appDir) const {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppLoader::isSDReady() const {
|
bool AppLoader::isSDReady() const { return SdMan.ready(); }
|
||||||
return SdMan.ready();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
} // namespace CrossPoint
|
||||||
|
|||||||
@ -1,24 +1,25 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <WString.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <functional>
|
|
||||||
#include <SDCardManager.h>
|
#include <SDCardManager.h>
|
||||||
|
#include <WString.h>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace CrossPoint {
|
namespace CrossPoint {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief App manifest data structure
|
* @brief App manifest data structure
|
||||||
*
|
*
|
||||||
* Contains the metadata parsed from app.json files
|
* Contains the metadata parsed from app.json files
|
||||||
*/
|
*/
|
||||||
struct AppManifest {
|
struct AppManifest {
|
||||||
String name; ///< Display name of the app
|
String name; ///< Display name of the app
|
||||||
String version; ///< Version string (e.g., "1.0.0")
|
String version; ///< Version string (e.g., "1.0.0")
|
||||||
String description; ///< Brief description of the app
|
String description; ///< Brief description of the app
|
||||||
String author; ///< Author/creator name
|
String author; ///< Author/creator name
|
||||||
String minFirmware; ///< Minimum firmware version required
|
String minFirmware; ///< Minimum firmware version required
|
||||||
|
|
||||||
AppManifest() = default;
|
AppManifest() = default;
|
||||||
AppManifest(const String& n, const String& v, const String& d, const String& a, const String& f)
|
AppManifest(const String& n, const String& v, const String& d, const String& a, const String& f)
|
||||||
@ -27,7 +28,7 @@ struct AppManifest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Complete app information including manifest and path
|
* @brief Complete app information including manifest and path
|
||||||
*
|
*
|
||||||
* Combines the parsed manifest with file system path information
|
* Combines the parsed manifest with file system path information
|
||||||
*/
|
*/
|
||||||
struct AppInfo {
|
struct AppInfo {
|
||||||
@ -40,10 +41,10 @@ struct AppInfo {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Utility class for loading and managing apps from SD card
|
* @brief Utility class for loading and managing apps from SD card
|
||||||
*
|
*
|
||||||
* Handles scanning for app manifests in the /.crosspoint/apps directory,
|
* Handles scanning for app manifests in the /.crosspoint/apps directory,
|
||||||
* parsing JSON manifests, and providing access to app information.
|
* parsing JSON manifests, and providing access to app information.
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* AppLoader loader;
|
* AppLoader loader;
|
||||||
* std::vector<AppInfo> apps = loader.scanApps();
|
* std::vector<AppInfo> apps = loader.scanApps();
|
||||||
@ -60,21 +61,21 @@ class AppLoader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Scan for apps in the /.crosspoint/apps directory
|
* @brief Scan for apps in the /.crosspoint/apps directory
|
||||||
*
|
*
|
||||||
* Searches for subdirectories under /.crosspoint/apps and attempts to
|
* Searches for subdirectories under /.crosspoint/apps and attempts to
|
||||||
* parse app.json files in each directory. Invalid or missing manifests
|
* parse app.json files in each directory. Invalid or missing manifests
|
||||||
* are skipped gracefully.
|
* are skipped gracefully.
|
||||||
*
|
*
|
||||||
* @return Vector of AppInfo objects for all valid apps found
|
* @return Vector of AppInfo objects for all valid apps found
|
||||||
*/
|
*/
|
||||||
std::vector<AppInfo> scanApps();
|
std::vector<AppInfo> scanApps();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parse an app.json manifest file
|
* @brief Parse an app.json manifest file
|
||||||
*
|
*
|
||||||
* Reads and parses a JSON manifest file, extracting the required fields.
|
* Reads and parses a JSON manifest file, extracting the required fields.
|
||||||
* Logs errors for malformed JSON but does not throw exceptions.
|
* Logs errors for malformed JSON but does not throw exceptions.
|
||||||
*
|
*
|
||||||
* @param path Full path to the app.json file
|
* @param path Full path to the app.json file
|
||||||
* @return AppManifest object with parsed data (empty on failure)
|
* @return AppManifest object with parsed data (empty on failure)
|
||||||
*/
|
*/
|
||||||
@ -107,7 +108,7 @@ class AppLoader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Helper to build manifest file path from app directory path
|
* @brief Helper to build manifest file path from app directory path
|
||||||
*
|
*
|
||||||
* @param appDir Path to the app directory
|
* @param appDir Path to the app directory
|
||||||
* @return Full path to the app.json file
|
* @return Full path to the app.json file
|
||||||
*/
|
*/
|
||||||
@ -115,7 +116,7 @@ class AppLoader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if SD card is ready
|
* @brief Check if SD card is ready
|
||||||
*
|
*
|
||||||
* @return true if SD card is initialized and ready
|
* @return true if SD card is initialized and ready
|
||||||
*/
|
*/
|
||||||
bool isSDReady() const;
|
bool isSDReady() const;
|
||||||
|
|||||||
@ -15,9 +15,9 @@
|
|||||||
#include "KOReaderCredentialStore.h"
|
#include "KOReaderCredentialStore.h"
|
||||||
#include "MappedInputManager.h"
|
#include "MappedInputManager.h"
|
||||||
#include "RecentBooksStore.h"
|
#include "RecentBooksStore.h"
|
||||||
|
#include "activities/apps/AppsActivity.h"
|
||||||
#include "activities/boot_sleep/BootActivity.h"
|
#include "activities/boot_sleep/BootActivity.h"
|
||||||
#include "activities/boot_sleep/SleepActivity.h"
|
#include "activities/boot_sleep/SleepActivity.h"
|
||||||
#include "activities/apps/AppsActivity.h"
|
|
||||||
#include "activities/browser/OpdsBookBrowserActivity.h"
|
#include "activities/browser/OpdsBookBrowserActivity.h"
|
||||||
#include "activities/home/HomeActivity.h"
|
#include "activities/home/HomeActivity.h"
|
||||||
#include "activities/home/MyLibraryActivity.h"
|
#include "activities/home/MyLibraryActivity.h"
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "html/AppsPageHtml.generated.h"
|
||||||
#include "html/FilesPageHtml.generated.h"
|
#include "html/FilesPageHtml.generated.h"
|
||||||
#include "html/HomePageHtml.generated.h"
|
#include "html/HomePageHtml.generated.h"
|
||||||
#include "html/AppsPageHtml.generated.h"
|
|
||||||
#include "util/StringUtils.h"
|
#include "util/StringUtils.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -525,8 +525,8 @@ static bool isValidAppId(const String& appId) {
|
|||||||
}
|
}
|
||||||
for (size_t i = 0; i < appId.length(); i++) {
|
for (size_t i = 0; i < appId.length(); i++) {
|
||||||
const char c = appId.charAt(i);
|
const char c = appId.charAt(i);
|
||||||
const bool ok = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '.' ||
|
const bool ok =
|
||||||
c == '_' || c == '-';
|
(c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '.' || c == '_' || c == '-';
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user