/* * sprch.h — v1. THE SCORPIO PLAYER 2027 source boundary: the C twin of SP2025 * `IRuntimeConfigHandler` (bosxixi.ScorpioPlayer.Core/Toolkit14/RuntimeConfigHandlers/ * IRuntimeConfigHandler.cs). * * Canonical copy: scorpiox-scorpioplayer-runtime-config-handler-registry/include/sprch.h * Copy it VERBATIM into every handler repo (rows 50-53, 55-62, the file-protocol * clients 33/35/37/39/41/43/45/47, webdav-client, dlna client). Never edit a copy; * change the canonical one and bump SPRCH_ABI_VERSION. * * C# member -> C member * string RuntimeType -> runtime_type (EXACT legacy string, case-sensitive) * InitNativeHandler -> Test/Connect -> validate * CreateRootFolder(Pairs) -> list (folder_id "" = root) * CreatePlaybackStreamAsync(Pairs,Entry) -> stream_url * DownloadAsync(Pairs, Link) -> download * InitDelegateMediaCategorizer() -> (not here: row 28 media-categorizer walks list()) * * JSON shapes (all UTF-8, all NUL-terminated): * settings_json : the legacy RuntimeSettings dictionary, key names unchanged * {"RuntimeType":"JELLYFIN","ServerUrl":"...","UserName":"...", ...} * validate out : a settings object — full, or only the keys the handler changed. * The registry merges it onto the input (C#: c.RuntimeSettings[k] = v), * so unknown keys always survive. * list out : the folder-file-accessor (#26) item JSON, an array or {"items":[...]} * {"name":"a.mkv","path":"/Movies/a.mkv","folder":false,"size":123,...} * stream_url out: {"url":"https://...","headers":{"X-Emby-Token":"..."}} (headers optional) * download out : DebridInstantDownloadResponse * {"InstantURL":"...","InstantName":"...","InstantSize":123,"Payload":{...}} * * Return codes: SPRCH_OK or one SPRCH_E_*. On an error the handler MAY write * {"error":""} into the out buffer; it must never contain a secret. * If the out buffer is too small the handler returns SPRCH_E_BUFFER and the * caller retries with a larger one. A missing capability => SPRCH_E_NOTSUPPORTED * (the C# "return null"). A transport failure => SPRCH_E_NETWORK, NEVER * SPRCH_OK with an empty list. * * Transport: `scorpiox_io` (scorpiox-io.h) is the ONLY transport, so iOS works. */ #ifndef SPRCH_H #define SPRCH_H #include "scorpiox-io.h" #ifdef __cplusplus extern "C" { #endif #define SPRCH_ABI_VERSION 1 enum { SPRCH_OK = 0, SPRCH_E_AUTH = -1, /* 401/403, bad credentials, expired token */ SPRCH_E_NOTFOUND = -2, /* folder_id / entry does not exist */ SPRCH_E_RATE = -3, /* 429 / service quota */ SPRCH_E_NETWORK = -4, /* transport failure, 5xx, timeout */ SPRCH_E_PROTOCOL = -5, /* server answered something we cannot parse */ SPRCH_E_NOTSUPPORTED = -6, /* capability absent (C#: return null) */ SPRCH_E_REFUSED_WRITE = -7, /* a write op while writes are not allowed */ SPRCH_E_CONFIG = -8, /* settings unusable / RuntimeType unknown */ SPRCH_E_BUFFER = -9 /* out buffer too small: retry with a larger cap */ }; #define SPRCH_CAP_LIST (1u<<0) #define SPRCH_CAP_STREAM (1u<<1) #define SPRCH_CAP_DOWNLOAD (1u<<2) /* debrid, Synology DownloadStation, ARIA2 */ #define SPRCH_CAP_WRITES (1u<<3) /* has ops behind _allow_writes */ #define SPRCH_CAP_META (1u<<4) /* items carry title/year/imdb (Jellyfin/Emby) */ #define SPRCH_CAP_VALIDATE (1u<<5) /* has a Test/ConnectConnection */ #define SPRCH_CAP_ALL (0x3Fu) typedef struct sprch_handler { const char *runtime_type; unsigned caps; int (*validate) (const scorpiox_io *io, const char *settings_json, char *out_settings_json, int cap); int (*list) (const scorpiox_io *io, const char *settings_json, const char *folder_id, char *out_items_json, int cap); int (*stream_url)(const scorpiox_io *io, const char *settings_json, const char *entry_json, char *out_url_json, int cap); int (*download) (const scorpiox_io *io, const char *settings_json, const char *config_json, char *out_json, int cap); } sprch_handler; /* Each handler DLL implements exactly one (ONEDRIVE may also expose ONEDRIVEB). * The registry itself does NOT define this symbol. */ const sprch_handler *sprch_get(void); #ifdef __cplusplus } #endif #endif /* SPRCH_H */