#pragma once #include "OpaqueHandle.hpp" #include "PluginTypes.hpp" #include "StateBlob.hpp" #include "Types.hpp" #include #include #include #include #include #include #include #include namespace Echoion::Api { // Forward declarations - Core provides implementations struct TrackInfo; struct QueueEntry; struct PlaylistInfo; // Minimal PlaybackState for Plugin struct PlaybackSummary { std::optional currentTrack; bool isPlaying = false; bool isPaused = false; std::chrono::milliseconds position{0}; float volume = 0.5f; bool repeat = false; bool shuffle = false; }; // Callback types for async operations using TrackCallback = std::function; using StateCallback = std::function; // Forward declarations class ICoreInterface; using CoreInterfacePtr = std::shared_ptr; using CoreCreateFunc = std::function; using CoreDestroyFunc = std::function; // Core interface that the Plugin will use to communicate with the Core // MINIMAL VERSION - breaks dependencies on Core-specific types class ICoreInterface { public: virtual ~ICoreInterface() = default; // Lifecycle // Plugin passes config file path, Core loads config internally virtual Result initialize(const std::filesystem::path& configPath) = 0; virtual Result shutdown() = 0; virtual bool isInitialized() const noexcept = 0; // Playback control - using string identifiers instead of TrackInfo virtual Result play(const std::string& trackId) = 0; virtual Result pause() = 0; virtual Result resume() = 0; virtual Result stop() = 0; virtual Result skip(uint32_t count = 1) = 0; virtual Result seek(std::chrono::milliseconds position) = 0; virtual Result setVolume(float volume) = 0; // Queue management - using string identifiers virtual Result queueTrack(const std::string& trackId, uint64_t clientId) = 0; virtual Result removeFromQueue(uint64_t queueId) = 0; virtual Result clearQueue() = 0; // Get queue as summaries (minimal data) [[nodiscard]] virtual Result> getQueueSummaries() const = 0; virtual Result moveInQueue(uint64_t queueId, uint32_t newPosition) = 0; // Track info - return summaries instead of full TrackInfo [[nodiscard]] virtual Result> getCurrentTrackSummary() const = 0; [[nodiscard]] virtual Result getPlaybackSummary() const = 0; // Playlist - using string identifiers virtual Result loadPlaylist(const std::string& playlistId, uint64_t clientId) = 0; [[nodiscard]] virtual Result> getPlaylistIds() const = 0; // Configuration - using serialization instead of AppConfig // Plugin sends JSON string, Core parses internally virtual Result updateConfigJson(const std::string& configJson) = 0; [[nodiscard]] virtual Result getConfigJson() const = 0; // Hot reload - using serialization instead of HotReloadState // Returns opaque handle that Plugin just passes back [[nodiscard]] virtual Result prepareForHotReload() = 0; virtual Result restoreAfterHotReload(const std::string& state) = 0; // Decoupled state management - Plugin never knows state internals // Core handles all serialization/deserialization internally // State format can change without Plugin rebuild [[nodiscard]] virtual StateBlob saveState() = 0; virtual Result restoreState(const StateBlob& state) = 0; // Version info for state compatibility checking [[nodiscard]] virtual uint32_t getStateFormatVersion() const = 0; [[nodiscard]] virtual bool canRestoreStateVersion(uint32_t version) const = 0; // Event handling virtual void registerEventCallback(const EventCallback& callback) = 0; virtual void unregisterEventCallback(const EventCallback& callback) = 0; // Plugin event processing virtual Result onPluginEvent(const PluginEvent& event) = 0; // Status [[nodiscard]] virtual std::string getVersion() const = 0; [[nodiscard]] virtual std::chrono::system_clock::time_point getUptime() const = 0; // Plugin interface virtual void setPluginInterface(PluginInterfacePtr pluginInterface) = 0; // Trigger auto-connect (call after setPluginInterface) virtual void triggerAutoConnect() = 0; // === Advanced methods for Core-to-Core communication (not for // Plugin) === These are only called by Core implementations, not // Plugin They use OpaqueHandle for type safety without exposing // types // Full TrackInfo access (for internal use) [[nodiscard]] virtual Result> getCurrentTrackHandle() const = 0; // Full QueueEntry access (for internal use) [[nodiscard]] virtual Result>> getQueueHandles() const = 0; // Raw config access (for internal use) [[nodiscard]] virtual Result getConfigHandle() const = 0; virtual Result updateConfigFromHandle(AppConfigHandle config) = 0; }; } // namespace Echoion::Api