Files
pyxis/lib/tdeck_ui/UI/LXMF/ComposeScreen.h
torlando-agent[bot] 70d4aa6be9 feat: graft pyxis onto upstream microReticulum 0.4.1
Repins microReticulum + microLXMF onto the upstream-0.4.1 graft and adapts
pyxis to the new src/microReticulum/ layout and 0.4.x APIs. The far-diverged
0.3.0 fork's Resource/Transport/Identity work is subsumed by upstream's
reimplementation; only the still-needed fixes ride on the pinned branches
(PKCS7/HMAC/X25519 crypto -- proven byte-identical to python RNS 1.3.1 --
Packet link-proof callback, Identity short-sig guard, and the bz2 layer +
decompress-on-receive in Resource::assemble()).

Consumer-side changes:
- platformio.ini: pin microReticulum @2f21fee (pyxis-fixes-on-0.4.1) and
  microLXMF @33760d0 (chore/microreticulum-0.4.1-layout); bump microStore
  ceea8f5 -> c5fb69d (0.4.x requires the new BasicFileStore::init API);
  -std=gnu++11 -> gnu++17 (upstream requires C++17).
- Namespace all microReticulum includes (angle + quote) to <microReticulum/...>
  for the relocated layout; shim-local Utilities/Stream.h|Print.h preserved.
- Interface::send_outgoing now returns bool: update TCP/BLE/SX1262/Auto
  overrides with correct success/failure returns.
- SDArchiveFileSystem::init(bool reformatOnFail=true) to match new microStore.
- Static Transport::get_path_table() -> path_table(); instance getter unchanged.
- Remove duplicate shim Cryptography/BZ2 (microReticulum provides it now; keep
  lib/libbz2 as the ESP32 bzlib provider).
- patch_littlefs_paths.py: normalize microStore's LittleFS adapter paths to a
  leading "/" -- ESP32 Arduino LittleFS rejects "./"-prefixed paths, which
  silently broke the path store (no peer paths learned, all messaging blocked).

Validated on T-Deck Plus: builds (RAM 27.5% / Flash 77.7%), boots stable
(no WDT/panic), and a full on-device LXMF e2e (DIRECT + OPPORTUNISTIC +
bz2-compressed-Resource receive) passes 5/5.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UWZuYkHBRqNb6BZHV8sTG5
2026-06-19 15:49:44 -04:00

130 lines
3.6 KiB
C++

// Copyright (c) 2024 microReticulum contributors
// SPDX-License-Identifier: MIT
#ifndef UI_LXMF_COMPOSESCREEN_H
#define UI_LXMF_COMPOSESCREEN_H
#ifdef ARDUINO
#include <Arduino.h>
#include <lvgl.h>
#include <functional>
#include <microReticulum/Bytes.h>
namespace UI {
namespace LXMF {
/**
* Compose New Message Screen
*
* Allows user to compose a message to a new peer by entering:
* - Destination hash (16 bytes = 32 hex characters)
* - Message content
*
* Layout:
* ┌─────────────────────────────────────┐
* │ ← New Message │ 32px Header
* ├─────────────────────────────────────┤
* │ To: │
* │ [Paste destination hash - 32 chars]│
* │ │
* │ Message: │
* │ ┌─────────────────────────────────┐ │ 156px content
* │ │ [Type your message here...] │ │
* │ │ │ │
* │ └─────────────────────────────────┘ │
* ├─────────────────────────────────────┤
* │ [Cancel] [Send] │ 52px buttons
* └─────────────────────────────────────┘
*/
class ComposeScreen {
public:
/**
* Callback types
*/
using CancelCallback = std::function<void()>;
using SendCallback = std::function<void(const RNS::Bytes& dest_hash, const String& message)>;
/**
* Create compose screen
* @param parent Parent LVGL object (usually lv_scr_act())
*/
ComposeScreen(lv_obj_t* parent = nullptr);
/**
* Destructor
*/
~ComposeScreen();
/**
* Clear all input fields
*/
void clear();
/**
* Set destination hash (pre-fill the to field)
* @param dest_hash Destination hash to set
*/
void set_destination(const RNS::Bytes& dest_hash);
/**
* Set callback for cancel button
* @param callback Function to call when cancel is pressed
*/
void set_cancel_callback(CancelCallback callback);
/**
* Set callback for send button
* @param callback Function to call when send is pressed
*/
void set_send_callback(SendCallback callback);
/**
* Show the screen
*/
void show();
/**
* Hide the screen
*/
void hide();
/**
* Get the root LVGL object
* @return Root object
*/
lv_obj_t* get_object();
private:
lv_obj_t* _screen;
lv_obj_t* _header;
lv_obj_t* _content_area;
lv_obj_t* _button_area;
lv_obj_t* _text_area_dest;
lv_obj_t* _text_area_message;
lv_obj_t* _btn_cancel;
lv_obj_t* _btn_send;
lv_obj_t* _btn_back;
CancelCallback _cancel_callback;
SendCallback _send_callback;
// UI construction
void create_header();
void create_content_area();
void create_button_area();
// Event handlers
static void on_back_clicked(lv_event_t* event);
static void on_cancel_clicked(lv_event_t* event);
static void on_send_clicked(lv_event_t* event);
// Validation
bool validate_destination_hash(const String& hash_str);
};
} // namespace LXMF
} // namespace UI
#endif // ARDUINO
#endif // UI_LXMF_COMPOSESCREEN_H