Drop the web UI that was compiled into nautctl and serve the torrent-ui front end (../torrent-ui/public) from a native plugin (plugins/webui) loaded via `nautd --plugin`. The plugin talks to the engine only through the host call_rpc ABI and adapts the daemon's RPC surface to the qBittorrent-style contract the UI expects (snapshot/SSE, torrent detail tabs, add/delete, cookie auth). Also folds in the daemon refactor that owns per-torrent worker threads and the swarm engine (naut_swarm) used by the plugin's data source. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
52 lines
2.1 KiB
C
52 lines
2.1 KiB
C
/* naut_plugin.h - stable versioned native plugin ABI. */
|
|
#ifndef NAUT_PLUGIN_H
|
|
#define NAUT_PLUGIN_H
|
|
|
|
#include "naut/common.h"
|
|
#include "naut/event.h"
|
|
|
|
#define NAUT_PLUGIN_ABI_VERSION 1u
|
|
|
|
typedef struct {
|
|
uint32_t abi_version;
|
|
uint32_t struct_size;
|
|
const char *name;
|
|
void *(*open)(const char *root, naut_err *error);
|
|
void (*close)(void *storage);
|
|
naut_err (*read)(void *storage, int64_t offset, void *buffer, size_t length);
|
|
naut_err (*write)(void *storage, int64_t offset,
|
|
const void *buffer, size_t length);
|
|
} naut_storage_backend_v1;
|
|
|
|
/* request_json is a JSON object or null. response_json must be malloc-owned
|
|
* compact JSON on success; the host frees it after parsing. */
|
|
typedef naut_err (*naut_plugin_rpc_fn)(void *context,
|
|
const char *request_json,
|
|
char **response_json);
|
|
typedef void (*naut_plugin_event_fn)(void *context,
|
|
const naut_event *event);
|
|
typedef naut_err (*naut_plugin_shutdown_fn)(void);
|
|
|
|
typedef struct naut_host_api {
|
|
uint32_t abi_version;
|
|
uint32_t struct_size;
|
|
void *host_context;
|
|
|
|
naut_err (*set_plugin_name)(void *host_context, const char *name);
|
|
naut_err (*register_rpc)(void *host_context, const char *method,
|
|
naut_plugin_rpc_fn callback, void *context);
|
|
naut_err (*register_storage_backend)(
|
|
void *host_context, const naut_storage_backend_v1 *backend);
|
|
naut_err (*subscribe_event)(void *host_context,
|
|
naut_plugin_event_fn callback,
|
|
void *context);
|
|
void (*emit_event)(void *host_context, const naut_event *event);
|
|
void (*log)(void *host_context, int level, const char *message);
|
|
naut_err (*call_rpc)(void *host_context, const char *method,
|
|
const char *request_json, char **response_json);
|
|
} naut_host_api;
|
|
|
|
/* Every plugin exports this exact symbol. */
|
|
typedef naut_err (*naut_plugin_register_fn)(const naut_host_api *host);
|
|
|
|
#endif /* NAUT_PLUGIN_H */
|