1 parent
295542ab9e
commit
24075fbd52
11 files changed
+305
-133
No files matched your search
@@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include <PluginTypes.hpp>
|
||||
#include <TrackTypes.hpp>
|
||||
#include <Types.hpp>
|
||||
#include <Void/Plugin/Plugin.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace Echoion::Api
|
||||
{
|
||||
struct ExtensionCommand {
|
||||
std::string name;
|
||||
std::vector<std::string> aliases;
|
||||
std::string description;
|
||||
std::string usage;
|
||||
std::uint8_t category = 5;
|
||||
bool adminOnly = false;
|
||||
};
|
||||
|
||||
struct ExtensionRpc {
|
||||
std::string name;
|
||||
bool adminOnly = false;
|
||||
};
|
||||
|
||||
struct ExtensionMediaSource {
|
||||
std::string name;
|
||||
bool supportsSearch = false;
|
||||
};
|
||||
|
||||
struct ExtensionWebAsset {
|
||||
std::string id;
|
||||
std::string javascript;
|
||||
std::string css;
|
||||
};
|
||||
|
||||
struct ExtensionCommandRequest {
|
||||
std::string command;
|
||||
std::string arguments;
|
||||
std::uint64_t clientId = 0;
|
||||
std::string invokerName;
|
||||
};
|
||||
|
||||
struct ExtensionRpcRequest {
|
||||
std::string method;
|
||||
std::string params;
|
||||
std::uint64_t clientId = 0;
|
||||
};
|
||||
|
||||
struct ExtensionStream {
|
||||
std::string url;
|
||||
bool localFile = false;
|
||||
};
|
||||
|
||||
// Native, trusted Echoion extension contract. Calls are always made while
|
||||
// the host holds a Void::Plugin::PluginHandle, so a hot reload cannot
|
||||
// unmap code that is still executing.
|
||||
class IExtensionPlugin : public Void::Plugin::IPlugin
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] virtual std::vector<ExtensionCommand> commands() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
[[nodiscard]] virtual std::vector<ExtensionRpc> rpcMethods() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
[[nodiscard]] virtual std::vector<ExtensionMediaSource> mediaSources() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
[[nodiscard]] virtual std::vector<ExtensionWebAsset> webAssets() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
virtual Result<std::string> executeCommand(
|
||||
const ExtensionCommandRequest&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension command is not supported");
|
||||
}
|
||||
virtual Result<std::string> callRpc(const ExtensionRpcRequest&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension RPC is not supported");
|
||||
}
|
||||
virtual void onEvent(const PluginEvent&) {}
|
||||
[[nodiscard]] virtual bool canHandleMedia(
|
||||
std::string_view, const std::string&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual Result<SearchResult> searchMedia(
|
||||
std::string_view, std::string_view)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension search is not supported");
|
||||
}
|
||||
virtual Result<TrackInfo> resolveMedia(
|
||||
std::string_view, const std::string&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension resolve is not supported");
|
||||
}
|
||||
virtual Result<ExtensionStream> streamMedia(
|
||||
std::string_view, const TrackInfo&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension stream is not supported");
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef PLUGIN
|
||||
#include <ConfigTypes.hpp>
|
||||
#endif
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
@@ -41,10 +39,14 @@ namespace Echoion::Api
|
||||
ConfigurationChanged,
|
||||
// Appended: fired once the TeamSpeak connection is fully established
|
||||
// (client list available), so the core can resolve online subscribers.
|
||||
ConnectionEstablished
|
||||
ConnectionEstablished,
|
||||
// Appended for the authoritative TeamSpeak directory cache. Hosts may
|
||||
// emit either event after refreshing their local topology mirror.
|
||||
ClientUpdated,
|
||||
ChannelUpdated
|
||||
};
|
||||
|
||||
// Minimal track info for Plugin (no internal types)
|
||||
// Minimal track info for the host boundary (no internal types)
|
||||
struct TrackSummary {
|
||||
std::string id;
|
||||
std::string title;
|
||||
@@ -69,12 +71,15 @@ namespace Echoion::Api
|
||||
|
||||
struct ClientInfo {
|
||||
uint64_t id = 0;
|
||||
std::optional<uint64_t> databaseId;
|
||||
std::string nickname;
|
||||
std::optional<std::string> uniqueIdentifier;
|
||||
uint64_t channelId = 0;
|
||||
bool isTalking = false;
|
||||
bool isMuted = false;
|
||||
bool isDeafened = false;
|
||||
bool isAway = false;
|
||||
bool isQuery = false;
|
||||
std::vector<uint64_t> serverGroups;
|
||||
};
|
||||
|
||||
@@ -84,11 +89,48 @@ namespace Echoion::Api
|
||||
std::optional<uint64_t> parentId;
|
||||
uint64_t order = 0;
|
||||
bool isDefault = false;
|
||||
bool isPermanent = false;
|
||||
bool isSemiPermanent = false;
|
||||
bool hasPassword = false;
|
||||
uint32_t maxClients = 0;
|
||||
uint32_t currentClients = 0;
|
||||
};
|
||||
|
||||
struct ChannelCreateOptions {
|
||||
std::string name;
|
||||
std::optional<uint64_t> parentId;
|
||||
std::optional<uint64_t> orderAfterId;
|
||||
std::optional<std::string> topic;
|
||||
std::optional<std::string> description;
|
||||
std::optional<std::string> password;
|
||||
uint32_t maxClients = 0;
|
||||
bool permanent = true;
|
||||
};
|
||||
|
||||
struct ChannelEditOptions {
|
||||
std::optional<std::string> name;
|
||||
std::optional<std::string> topic;
|
||||
std::optional<std::string> description;
|
||||
std::optional<std::string> password;
|
||||
std::optional<uint32_t> maxClients;
|
||||
std::optional<bool> permanent;
|
||||
};
|
||||
|
||||
struct ServerGroupInfo {
|
||||
uint64_t id = 0;
|
||||
std::string name;
|
||||
bool isDefault = false;
|
||||
};
|
||||
|
||||
struct BanInfo {
|
||||
uint64_t id = 0;
|
||||
std::optional<std::string> uniqueIdentifier;
|
||||
std::optional<std::string> nickname;
|
||||
std::string reason;
|
||||
uint64_t createdAt = 0;
|
||||
uint64_t durationSeconds = 0; // 0 means permanent
|
||||
};
|
||||
|
||||
struct ServerInfo {
|
||||
uint64_t id = 0;
|
||||
std::string name;
|
||||
@@ -98,22 +140,6 @@ namespace Echoion::Api
|
||||
uint64_t defaultChannelId = 0;
|
||||
};
|
||||
|
||||
// ServerConfig is needed for Plugin's connectToServer()
|
||||
// This is a minimal version without dependencies on AudioTypes, etc.
|
||||
// Available to both Core and Plugin
|
||||
#ifdef PLUGIN
|
||||
struct ServerConfig {
|
||||
std::string address;
|
||||
uint16_t port = 0;
|
||||
std::string serverPassword;
|
||||
std::string nickname;
|
||||
std::optional<std::string> defaultChannelId;
|
||||
std::optional<std::string> channelPassword;
|
||||
std::vector<uint64_t> adminGroups;
|
||||
std::vector<uint64_t> djGroups;
|
||||
std::vector<uint64_t> bannedGroups;
|
||||
};
|
||||
#endif
|
||||
// ===== Callback Types =====
|
||||
|
||||
using EventCallback = std::function<void(const PluginEvent&)>;
|
||||
|
||||
Reference in new issue
Block a user