mirror of
https://github.com/NohamR/RMHook.git
synced 2026-04-08 07:59:58 +00:00
Add native HTTP server, CLI scripts and docs
Implement a native macOS HTTP server for RMHook and wire it into the app. Adds HttpServer.h/.mm (CFSocket-based) with start/stop/isRunning APIs, broadcasts incoming POST /exportFile and /documentAccepted requests to the QML MessageBroker, and starts the server on port 8080 from reMarkable.m. Update CMakeLists to include HttpServer.mm and link Qt Qml when building qmlrebuild mode. Add documentation (docs/HTTP_SERVER.md) and QML snippets for MessageBroker integration, plus Python helper scripts (scripts/http_server.py and scripts/test_http_server.py) for invoking the endpoints. Also add small MessageBroker examples (src/utils/mb.m, src/utils/mb.qml) and update ResourceUtils to include additional QML resources.
This commit is contained in:
54
docs/DocumentAccepted_MessageBroker_snippet.qml
Normal file
54
docs/DocumentAccepted_MessageBroker_snippet.qml
Normal file
@@ -0,0 +1,54 @@
|
||||
// Add this MessageBroker to a QML component that has access to PlatformHelpers
|
||||
// This listens for documentAccepted signals from the HTTP server
|
||||
// and calls PlatformHelpers.documentAccepted()
|
||||
|
||||
import net.noham.MessageBroker
|
||||
|
||||
MessageBroker {
|
||||
id: documentAcceptedBroker
|
||||
listeningFor: ["documentAccepted"]
|
||||
|
||||
onSignalReceived: (signal, message) => {
|
||||
console.log("[DocumentAccepted.MessageBroker] Received signal:", signal);
|
||||
console.log("[DocumentAccepted.MessageBroker] Message data:", message);
|
||||
|
||||
try {
|
||||
// Parse JSON message from HTTP server
|
||||
const data = JSON.parse(message);
|
||||
console.log("[DocumentAccepted.MessageBroker] Parsed request:", JSON.stringify(data));
|
||||
|
||||
// Extract parameters with defaults
|
||||
const url = data.url || "";
|
||||
const password = data.password || "";
|
||||
const directoryId = data.directoryId || "";
|
||||
const flag1 = data.flag1 !== undefined ? data.flag1 : false;
|
||||
const flag2 = data.flag2 !== undefined ? data.flag2 : false;
|
||||
|
||||
console.log("[DocumentAccepted.MessageBroker] Parameters:");
|
||||
console.log("[DocumentAccepted.MessageBroker] url:", url);
|
||||
console.log("[DocumentAccepted.MessageBroker] password:", password ? "(set)" : "(empty)");
|
||||
console.log("[DocumentAccepted.MessageBroker] directoryId:", directoryId);
|
||||
console.log("[DocumentAccepted.MessageBroker] flag1:", flag1);
|
||||
console.log("[DocumentAccepted.MessageBroker] flag2:", flag2);
|
||||
|
||||
// Validate required parameters
|
||||
if (!url) {
|
||||
console.error("[DocumentAccepted.MessageBroker] ERROR: Missing 'url' parameter");
|
||||
return;
|
||||
}
|
||||
if (!directoryId) {
|
||||
console.error("[DocumentAccepted.MessageBroker] ERROR: Missing 'directoryId' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
// Call PlatformHelpers.documentAccepted
|
||||
console.log("[DocumentAccepted.MessageBroker] Calling PlatformHelpers.documentAccepted...");
|
||||
PlatformHelpers.documentAccepted(url, password, directoryId, flag1, flag2);
|
||||
console.log("[DocumentAccepted.MessageBroker] Document accepted successfully");
|
||||
|
||||
} catch (error) {
|
||||
console.error("[DocumentAccepted.MessageBroker] ERROR parsing request:", error);
|
||||
console.error("[DocumentAccepted.MessageBroker] Message was:", message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user