Migrate to sdbus-c++ v2
Some checks failed
Build / build-gentoo (push) Failing after 31s
Build / download-system-deps (push) Successful in 3m5s
Build / get-source-code (push) Successful in 13m4s
Build / build-appimage (push) Successful in 5m0s
Build / build-android (push) Failing after 3m46s
Build / build-windows (push) Failing after 8m42s
Some checks failed
Build / build-gentoo (push) Failing after 31s
Build / download-system-deps (push) Successful in 3m5s
Build / get-source-code (push) Successful in 13m4s
Build / build-appimage (push) Successful in 5m0s
Build / build-android (push) Failing after 3m46s
Build / build-windows (push) Failing after 8m42s
This commit is contained in:
parent
fc6753f575
commit
ee94b97d19
7 changed files with 320 additions and 259 deletions
|
@ -43,6 +43,10 @@ if (UNIX AND NOT APPLE AND NOT ANDROID AND NOT HAIKU)
|
|||
option(ENABLE_DBUS "Enables DBus support" ON)
|
||||
endif()
|
||||
option(BUILD_LIBFMT "Builds libfmt" OFF)
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
endif()
|
||||
if(HAIKU)
|
||||
set(USE_CELT OFF CACHE BOOL "" FORCE)
|
||||
set(USE_SPEEX OFF CACHE BOOL "" FORCE)
|
||||
|
@ -362,8 +366,8 @@ if (DEFINED ANDROID_NDK)
|
|||
target_link_libraries(liblooper PUBLIC oboe)
|
||||
endif()
|
||||
pkg_check_modules(libxspf IMPORTED_TARGET libxspf)
|
||||
if (NOT libxspf_FOUND)
|
||||
include(ExternalProject)
|
||||
if (NOT libxspf_FOUND)
|
||||
set(XSPF ${CMAKE_BINARY_DIR}/libxspf-prefix/src/libxspf-build/.libs/${CMAKE_STATIC_LIBRARY_PREFIX}xspf${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
ExternalProject_Add(libxspf
|
||||
URL https://ftp.osuosl.org/pub/xiph/releases/xspf/libxspf-1.2.0.tar.lzma
|
||||
|
@ -413,11 +417,14 @@ else()
|
|||
target_link_libraries(SDL2_image::SDL2_image INTERFACE ${sdl2_image_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
if (WINDOWS)
|
||||
set(ENABLE_DBUS OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
if (ENABLE_DBUS)
|
||||
find_package(sdbus-c++)
|
||||
find_package(sdbus-c++ 2.0)
|
||||
if(NOT ${sdbus-c++_FOUND})
|
||||
set(ENABLE_DBUS OFF)
|
||||
message("Warning: Dbus support not found - Not enabling DBus")
|
||||
message("Warning: Dbus support not found - Not enabling DBus. This program requires version 2.0 or later.")
|
||||
endif()
|
||||
endif()
|
||||
set(SDL2_TARGET SDL2::SDL2)
|
||||
|
|
|
@ -20,27 +20,32 @@ public:
|
|||
|
||||
protected:
|
||||
Application_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
object_->registerMethod("Activate").onInterface(INTERFACE_NAME).withInputParamNames("platform_data").implementedAs([this](const std::map<std::string, sdbus::Variant>& platform_data){ return this->Activate(platform_data); });
|
||||
object_->registerMethod("Open").onInterface(INTERFACE_NAME).withInputParamNames("uris", "platform_data").implementedAs([this](const std::vector<std::string>& uris, const std::map<std::string, sdbus::Variant>& platform_data){ return this->Open(uris, platform_data); });
|
||||
object_->registerMethod("ActivateAction").onInterface(INTERFACE_NAME).withInputParamNames("action_name", "parameter", "platform_data").implementedAs([this](const std::string& action_name, const std::vector<sdbus::Variant>& parameter, const std::map<std::string, sdbus::Variant>& platform_data){ return this->ActivateAction(action_name, parameter, platform_data); });
|
||||
}
|
||||
|
||||
Application_adaptor(const Application_adaptor&) = delete;
|
||||
Application_adaptor& operator=(const Application_adaptor&) = delete;
|
||||
Application_adaptor(Application_adaptor&&) = default;
|
||||
Application_adaptor& operator=(Application_adaptor&&) = default;
|
||||
Application_adaptor(Application_adaptor&&) = delete;
|
||||
Application_adaptor& operator=(Application_adaptor&&) = delete;
|
||||
|
||||
~Application_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
m_object.addVTable( sdbus::registerMethod("Activate").withInputParamNames("platform_data").implementedAs([this](const std::map<std::string, sdbus::Variant>& platform_data){ return this->Activate(platform_data); })
|
||||
, sdbus::registerMethod("Open").withInputParamNames("uris", "platform_data").implementedAs([this](const std::vector<std::string>& uris, const std::map<std::string, sdbus::Variant>& platform_data){ return this->Open(uris, platform_data); })
|
||||
, sdbus::registerMethod("ActivateAction").withInputParamNames("action_name", "parameter", "platform_data").implementedAs([this](const std::string& action_name, const std::vector<sdbus::Variant>& parameter, const std::map<std::string, sdbus::Variant>& platform_data){ return this->ActivateAction(action_name, parameter, platform_data); })
|
||||
).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void Activate(const std::map<std::string, sdbus::Variant>& platform_data) = 0;
|
||||
virtual void Open(const std::vector<std::string>& uris, const std::map<std::string, sdbus::Variant>& platform_data) = 0;
|
||||
virtual void ActivateAction(const std::string& action_name, const std::vector<sdbus::Variant>& parameter, const std::map<std::string, sdbus::Variant>& platform_data) = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
@ -55,92 +60,97 @@ public:
|
|||
|
||||
protected:
|
||||
looper_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
object_->registerMethod("CreateHandle").onInterface(INTERFACE_NAME).withOutputParamNames("new_handle").implementedAs([this](){ return this->CreateHandle(); });
|
||||
object_->registerMethod("ClearHandle").onInterface(INTERFACE_NAME).withInputParamNames("handle").implementedAs([this](const std::string& handle){ return this->ClearHandle(handle); });
|
||||
object_->registerMethod("Start").onInterface(INTERFACE_NAME).withInputParamNames("path", "isUri").implementedAs([this](const std::string& path, const bool& isUri){ return this->Start(path, isUri); });
|
||||
object_->registerMethod("StartWithStreamIndex").onInterface(INTERFACE_NAME).withInputParamNames("path", "isUri", "streamIndex").implementedAs([this](const std::string& path, const bool& isUri, const uint32_t& streamIndex){ return this->StartWithStreamIndex(path, isUri, streamIndex); });
|
||||
object_->registerMethod("Load").onInterface(INTERFACE_NAME).withInputParamNames("path", "isUri").implementedAs([this](const std::string& path, const bool& isUri){ return this->Load(path, isUri); });
|
||||
object_->registerMethod("Quit").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->Quit(); });
|
||||
object_->registerMethod("Stop").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->Stop(); });
|
||||
object_->registerMethod("TogglePause").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->TogglePause(); });
|
||||
object_->registerMethod("GetStreams").onInterface(INTERFACE_NAME).withOutputParamNames("streams").implementedAs([this](){ return this->GetStreams(); });
|
||||
object_->registerMethod("PlayStream").onInterface(INTERFACE_NAME).withInputParamNames("idx").implementedAs([this](const uint32_t& idx){ return this->PlayStream(idx); });
|
||||
object_->registerSignal("PlaybackEngineStarted").onInterface(INTERFACE_NAME);
|
||||
object_->registerSignal("SpeedChanged").onInterface(INTERFACE_NAME).withParameters<double>("new_speed");
|
||||
object_->registerSignal("TempoChanged").onInterface(INTERFACE_NAME).withParameters<double>("new_tempo");
|
||||
object_->registerSignal("PitchChanged").onInterface(INTERFACE_NAME).withParameters<double>("new_pitch");
|
||||
object_->registerSignal("PauseChanged").onInterface(INTERFACE_NAME).withParameters<bool>("now_paused");
|
||||
object_->registerSignal("Stopped").onInterface(INTERFACE_NAME);
|
||||
object_->registerSignal("ErrorOccurred").onInterface(INTERFACE_NAME).withParameters<std::string, std::string>("error_desc", "error_type");
|
||||
object_->registerSignal("Seeked").onInterface(INTERFACE_NAME).withParameters<double>("to_position");
|
||||
object_->registerSignal("FileChanged").onInterface(INTERFACE_NAME).withParameters<std::string, std::string>("path", "title");
|
||||
object_->registerProperty("FilePath").onInterface(INTERFACE_NAME).withGetter([this](){ return this->FilePath(); });
|
||||
object_->registerProperty("FileTitle").onInterface(INTERFACE_NAME).withGetter([this](){ return this->FileTitle(); });
|
||||
object_->registerProperty("Position").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Position(); }).withSetter([this](const double& value){ this->Position(value); });
|
||||
object_->registerProperty("Length").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Length(); });
|
||||
object_->registerProperty("Speed").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Speed(); }).withSetter([this](const double& value){ this->Speed(value); });
|
||||
object_->registerProperty("Tempo").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Tempo(); }).withSetter([this](const double& value){ this->Tempo(value); });
|
||||
object_->registerProperty("Pitch").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Pitch(); }).withSetter([this](const double& value){ this->Pitch(value); });
|
||||
object_->registerProperty("Volume").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Volume(); }).withSetter([this](const double& value){ this->Volume(value); });
|
||||
object_->registerProperty("Paused").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Paused(); }).withSetter([this](const bool& value){ this->Paused(value); });
|
||||
object_->registerProperty("IsStopped").onInterface(INTERFACE_NAME).withGetter([this](){ return this->IsStopped(); });
|
||||
object_->registerProperty("IsDaemon").onInterface(INTERFACE_NAME).withGetter([this](){ return this->IsDaemon(); });
|
||||
object_->registerProperty("StreamIdx").onInterface(INTERFACE_NAME).withGetter([this](){ return this->StreamIdx(); });
|
||||
}
|
||||
|
||||
looper_adaptor(const looper_adaptor&) = delete;
|
||||
looper_adaptor& operator=(const looper_adaptor&) = delete;
|
||||
looper_adaptor(looper_adaptor&&) = default;
|
||||
looper_adaptor& operator=(looper_adaptor&&) = default;
|
||||
looper_adaptor(looper_adaptor&&) = delete;
|
||||
looper_adaptor& operator=(looper_adaptor&&) = delete;
|
||||
|
||||
~looper_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
m_object.addVTable( sdbus::registerMethod("CreateHandle").withOutputParamNames("new_handle").implementedAs([this](){ return this->CreateHandle(); })
|
||||
, sdbus::registerMethod("ClearHandle").withInputParamNames("handle").implementedAs([this](const std::string& handle){ return this->ClearHandle(handle); })
|
||||
, sdbus::registerMethod("Start").withInputParamNames("path", "isUri").implementedAs([this](const std::string& path, const bool& isUri){ return this->Start(path, isUri); })
|
||||
, sdbus::registerMethod("StartWithStreamIndex").withInputParamNames("path", "isUri", "streamIndex").implementedAs([this](const std::string& path, const bool& isUri, const uint32_t& streamIndex){ return this->StartWithStreamIndex(path, isUri, streamIndex); })
|
||||
, sdbus::registerMethod("Load").withInputParamNames("path", "isUri").implementedAs([this](const std::string& path, const bool& isUri){ return this->Load(path, isUri); })
|
||||
, sdbus::registerMethod("Quit").implementedAs([this](){ return this->Quit(); })
|
||||
, sdbus::registerMethod("Stop").implementedAs([this](){ return this->Stop(); })
|
||||
, sdbus::registerMethod("TogglePause").implementedAs([this](){ return this->TogglePause(); })
|
||||
, sdbus::registerMethod("GetStreams").withOutputParamNames("streams").implementedAs([this](){ return this->GetStreams(); })
|
||||
, sdbus::registerMethod("PlayStream").withInputParamNames("idx").implementedAs([this](const uint32_t& idx){ return this->PlayStream(idx); })
|
||||
, sdbus::registerSignal("PlaybackEngineStarted")
|
||||
, sdbus::registerSignal("SpeedChanged").withParameters<double>("new_speed")
|
||||
, sdbus::registerSignal("TempoChanged").withParameters<double>("new_tempo")
|
||||
, sdbus::registerSignal("PitchChanged").withParameters<double>("new_pitch")
|
||||
, sdbus::registerSignal("PauseChanged").withParameters<bool>("now_paused")
|
||||
, sdbus::registerSignal("Stopped")
|
||||
, sdbus::registerSignal("ErrorOccurred").withParameters<std::string, std::string>("error_desc", "error_type")
|
||||
, sdbus::registerSignal("Seeked").withParameters<double>("to_position")
|
||||
, sdbus::registerSignal("FileChanged").withParameters<std::string, std::string>("path", "title")
|
||||
, sdbus::registerProperty("FilePath").withGetter([this](){ return this->FilePath(); })
|
||||
, sdbus::registerProperty("FileTitle").withGetter([this](){ return this->FileTitle(); })
|
||||
, sdbus::registerProperty("Position").withGetter([this](){ return this->Position(); }).withSetter([this](const double& value){ this->Position(value); })
|
||||
, sdbus::registerProperty("Length").withGetter([this](){ return this->Length(); })
|
||||
, sdbus::registerProperty("Speed").withGetter([this](){ return this->Speed(); }).withSetter([this](const double& value){ this->Speed(value); })
|
||||
, sdbus::registerProperty("Tempo").withGetter([this](){ return this->Tempo(); }).withSetter([this](const double& value){ this->Tempo(value); })
|
||||
, sdbus::registerProperty("Pitch").withGetter([this](){ return this->Pitch(); }).withSetter([this](const double& value){ this->Pitch(value); })
|
||||
, sdbus::registerProperty("Volume").withGetter([this](){ return this->Volume(); }).withSetter([this](const double& value){ this->Volume(value); })
|
||||
, sdbus::registerProperty("Paused").withGetter([this](){ return this->Paused(); }).withSetter([this](const bool& value){ this->Paused(value); })
|
||||
, sdbus::registerProperty("IsStopped").withGetter([this](){ return this->IsStopped(); })
|
||||
, sdbus::registerProperty("IsDaemon").withGetter([this](){ return this->IsDaemon(); })
|
||||
, sdbus::registerProperty("StreamIdx").withGetter([this](){ return this->StreamIdx(); })
|
||||
).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
public:
|
||||
void emitPlaybackEngineStarted()
|
||||
{
|
||||
object_->emitSignal("PlaybackEngineStarted").onInterface(INTERFACE_NAME);
|
||||
m_object.emitSignal("PlaybackEngineStarted").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void emitSpeedChanged(const double& new_speed)
|
||||
{
|
||||
object_->emitSignal("SpeedChanged").onInterface(INTERFACE_NAME).withArguments(new_speed);
|
||||
m_object.emitSignal("SpeedChanged").onInterface(INTERFACE_NAME).withArguments(new_speed);
|
||||
}
|
||||
|
||||
void emitTempoChanged(const double& new_tempo)
|
||||
{
|
||||
object_->emitSignal("TempoChanged").onInterface(INTERFACE_NAME).withArguments(new_tempo);
|
||||
m_object.emitSignal("TempoChanged").onInterface(INTERFACE_NAME).withArguments(new_tempo);
|
||||
}
|
||||
|
||||
void emitPitchChanged(const double& new_pitch)
|
||||
{
|
||||
object_->emitSignal("PitchChanged").onInterface(INTERFACE_NAME).withArguments(new_pitch);
|
||||
m_object.emitSignal("PitchChanged").onInterface(INTERFACE_NAME).withArguments(new_pitch);
|
||||
}
|
||||
|
||||
void emitPauseChanged(const bool& now_paused)
|
||||
{
|
||||
object_->emitSignal("PauseChanged").onInterface(INTERFACE_NAME).withArguments(now_paused);
|
||||
m_object.emitSignal("PauseChanged").onInterface(INTERFACE_NAME).withArguments(now_paused);
|
||||
}
|
||||
|
||||
void emitStopped()
|
||||
{
|
||||
object_->emitSignal("Stopped").onInterface(INTERFACE_NAME);
|
||||
m_object.emitSignal("Stopped").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void emitErrorOccurred(const std::string& error_desc, const std::string& error_type)
|
||||
{
|
||||
object_->emitSignal("ErrorOccurred").onInterface(INTERFACE_NAME).withArguments(error_desc, error_type);
|
||||
m_object.emitSignal("ErrorOccurred").onInterface(INTERFACE_NAME).withArguments(error_desc, error_type);
|
||||
}
|
||||
|
||||
void emitSeeked(const double& to_position)
|
||||
{
|
||||
object_->emitSignal("Seeked").onInterface(INTERFACE_NAME).withArguments(to_position);
|
||||
m_object.emitSignal("Seeked").onInterface(INTERFACE_NAME).withArguments(to_position);
|
||||
}
|
||||
|
||||
void emitFileChanged(const std::string& path, const std::string& title)
|
||||
{
|
||||
object_->emitSignal("FileChanged").onInterface(INTERFACE_NAME).withArguments(path, title);
|
||||
m_object.emitSignal("FileChanged").onInterface(INTERFACE_NAME).withArguments(path, title);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -176,7 +186,7 @@ private:
|
|||
virtual uint32_t StreamIdx() = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
@ -192,26 +202,31 @@ public:
|
|||
|
||||
protected:
|
||||
Errors_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
object_->registerMethod("PopFront").onInterface(INTERFACE_NAME).withInputParamNames("handle").withOutputParamNames("error").implementedAs([this](const std::string& handle){ return this->PopFront(handle); });
|
||||
object_->registerMethod("PopBack").onInterface(INTERFACE_NAME).withInputParamNames("handle").withOutputParamNames("error").implementedAs([this](const std::string& handle){ return this->PopBack(handle); });
|
||||
object_->registerMethod("PeekFront").onInterface(INTERFACE_NAME).withInputParamNames("handle").withOutputParamNames("error").implementedAs([this](const std::string& handle){ return this->PeekFront(handle); });
|
||||
object_->registerMethod("PeekBack").onInterface(INTERFACE_NAME).withInputParamNames("handle").withOutputParamNames("error").implementedAs([this](const std::string& handle){ return this->PeekBack(handle); });
|
||||
object_->registerMethod("GetCount").onInterface(INTERFACE_NAME).withInputParamNames("handle").withOutputParamNames("count").implementedAs([this](const std::string& handle){ return this->GetCount(handle); });
|
||||
object_->registerMethod("IsEmpty").onInterface(INTERFACE_NAME).withInputParamNames("handle").withOutputParamNames("empty").implementedAs([this](const std::string& handle){ return this->IsEmpty(handle); });
|
||||
object_->registerMethod("Clear").onInterface(INTERFACE_NAME).withInputParamNames("handle").implementedAs([this](const std::string& handle){ return this->Clear(handle); });
|
||||
object_->registerMethod("PeekAll").onInterface(INTERFACE_NAME).withInputParamNames("handle").withOutputParamNames("errors").implementedAs([this](const std::string& handle){ return this->PeekAll(handle); });
|
||||
object_->registerMethod("GetAllAndClear").onInterface(INTERFACE_NAME).withInputParamNames("handle").withOutputParamNames("errors").implementedAs([this](const std::string& handle){ return this->GetAllAndClear(handle); });
|
||||
}
|
||||
|
||||
Errors_adaptor(const Errors_adaptor&) = delete;
|
||||
Errors_adaptor& operator=(const Errors_adaptor&) = delete;
|
||||
Errors_adaptor(Errors_adaptor&&) = default;
|
||||
Errors_adaptor& operator=(Errors_adaptor&&) = default;
|
||||
Errors_adaptor(Errors_adaptor&&) = delete;
|
||||
Errors_adaptor& operator=(Errors_adaptor&&) = delete;
|
||||
|
||||
~Errors_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
m_object.addVTable( sdbus::registerMethod("PopFront").withInputParamNames("handle").withOutputParamNames("error").implementedAs([this](const std::string& handle){ return this->PopFront(handle); })
|
||||
, sdbus::registerMethod("PopBack").withInputParamNames("handle").withOutputParamNames("error").implementedAs([this](const std::string& handle){ return this->PopBack(handle); })
|
||||
, sdbus::registerMethod("PeekFront").withInputParamNames("handle").withOutputParamNames("error").implementedAs([this](const std::string& handle){ return this->PeekFront(handle); })
|
||||
, sdbus::registerMethod("PeekBack").withInputParamNames("handle").withOutputParamNames("error").implementedAs([this](const std::string& handle){ return this->PeekBack(handle); })
|
||||
, sdbus::registerMethod("GetCount").withInputParamNames("handle").withOutputParamNames("count").implementedAs([this](const std::string& handle){ return this->GetCount(handle); })
|
||||
, sdbus::registerMethod("IsEmpty").withInputParamNames("handle").withOutputParamNames("empty").implementedAs([this](const std::string& handle){ return this->IsEmpty(handle); })
|
||||
, sdbus::registerMethod("Clear").withInputParamNames("handle").implementedAs([this](const std::string& handle){ return this->Clear(handle); })
|
||||
, sdbus::registerMethod("PeekAll").withInputParamNames("handle").withOutputParamNames("errors").implementedAs([this](const std::string& handle){ return this->PeekAll(handle); })
|
||||
, sdbus::registerMethod("GetAllAndClear").withInputParamNames("handle").withOutputParamNames("errors").implementedAs([this](const std::string& handle){ return this->GetAllAndClear(handle); })
|
||||
).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual std::string PopFront(const std::string& handle) = 0;
|
||||
virtual std::string PopBack(const std::string& handle) = 0;
|
||||
|
@ -224,7 +239,7 @@ private:
|
|||
virtual std::vector<std::string> GetAllAndClear(const std::string& handle) = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
|
|
@ -20,35 +20,39 @@ public:
|
|||
|
||||
protected:
|
||||
Application_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
Application_proxy(const Application_proxy&) = delete;
|
||||
Application_proxy& operator=(const Application_proxy&) = delete;
|
||||
Application_proxy(Application_proxy&&) = default;
|
||||
Application_proxy& operator=(Application_proxy&&) = default;
|
||||
Application_proxy(Application_proxy&&) = delete;
|
||||
Application_proxy& operator=(Application_proxy&&) = delete;
|
||||
|
||||
~Application_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
void Activate(const std::map<std::string, sdbus::Variant>& platform_data)
|
||||
{
|
||||
proxy_->callMethod("Activate").onInterface(INTERFACE_NAME).withArguments(platform_data);
|
||||
m_proxy.callMethod("Activate").onInterface(INTERFACE_NAME).withArguments(platform_data);
|
||||
}
|
||||
|
||||
void Open(const std::vector<std::string>& uris, const std::map<std::string, sdbus::Variant>& platform_data)
|
||||
{
|
||||
proxy_->callMethod("Open").onInterface(INTERFACE_NAME).withArguments(uris, platform_data);
|
||||
m_proxy.callMethod("Open").onInterface(INTERFACE_NAME).withArguments(uris, platform_data);
|
||||
}
|
||||
|
||||
void ActivateAction(const std::string& action_name, const std::vector<sdbus::Variant>& parameter, const std::map<std::string, sdbus::Variant>& platform_data)
|
||||
{
|
||||
proxy_->callMethod("ActivateAction").onInterface(INTERFACE_NAME).withArguments(action_name, parameter, platform_data);
|
||||
m_proxy.callMethod("ActivateAction").onInterface(INTERFACE_NAME).withArguments(action_name, parameter, platform_data);
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
@ -63,26 +67,30 @@ public:
|
|||
|
||||
protected:
|
||||
looper_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
proxy_->uponSignal("PlaybackEngineStarted").onInterface(INTERFACE_NAME).call([this](){ this->onPlaybackEngineStarted(); });
|
||||
proxy_->uponSignal("SpeedChanged").onInterface(INTERFACE_NAME).call([this](const double& new_speed){ this->onSpeedChanged(new_speed); });
|
||||
proxy_->uponSignal("TempoChanged").onInterface(INTERFACE_NAME).call([this](const double& new_tempo){ this->onTempoChanged(new_tempo); });
|
||||
proxy_->uponSignal("PitchChanged").onInterface(INTERFACE_NAME).call([this](const double& new_pitch){ this->onPitchChanged(new_pitch); });
|
||||
proxy_->uponSignal("PauseChanged").onInterface(INTERFACE_NAME).call([this](const bool& now_paused){ this->onPauseChanged(now_paused); });
|
||||
proxy_->uponSignal("Stopped").onInterface(INTERFACE_NAME).call([this](){ this->onStopped(); });
|
||||
proxy_->uponSignal("ErrorOccurred").onInterface(INTERFACE_NAME).call([this](const std::string& error_desc, const std::string& error_type){ this->onErrorOccurred(error_desc, error_type); });
|
||||
proxy_->uponSignal("Seeked").onInterface(INTERFACE_NAME).call([this](const double& to_position){ this->onSeeked(to_position); });
|
||||
proxy_->uponSignal("FileChanged").onInterface(INTERFACE_NAME).call([this](const std::string& path, const std::string& title){ this->onFileChanged(path, title); });
|
||||
}
|
||||
|
||||
looper_proxy(const looper_proxy&) = delete;
|
||||
looper_proxy& operator=(const looper_proxy&) = delete;
|
||||
looper_proxy(looper_proxy&&) = default;
|
||||
looper_proxy& operator=(looper_proxy&&) = default;
|
||||
looper_proxy(looper_proxy&&) = delete;
|
||||
looper_proxy& operator=(looper_proxy&&) = delete;
|
||||
|
||||
~looper_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
m_proxy.uponSignal("PlaybackEngineStarted").onInterface(INTERFACE_NAME).call([this](){ this->onPlaybackEngineStarted(); });
|
||||
m_proxy.uponSignal("SpeedChanged").onInterface(INTERFACE_NAME).call([this](const double& new_speed){ this->onSpeedChanged(new_speed); });
|
||||
m_proxy.uponSignal("TempoChanged").onInterface(INTERFACE_NAME).call([this](const double& new_tempo){ this->onTempoChanged(new_tempo); });
|
||||
m_proxy.uponSignal("PitchChanged").onInterface(INTERFACE_NAME).call([this](const double& new_pitch){ this->onPitchChanged(new_pitch); });
|
||||
m_proxy.uponSignal("PauseChanged").onInterface(INTERFACE_NAME).call([this](const bool& now_paused){ this->onPauseChanged(now_paused); });
|
||||
m_proxy.uponSignal("Stopped").onInterface(INTERFACE_NAME).call([this](){ this->onStopped(); });
|
||||
m_proxy.uponSignal("ErrorOccurred").onInterface(INTERFACE_NAME).call([this](const std::string& error_desc, const std::string& error_type){ this->onErrorOccurred(error_desc, error_type); });
|
||||
m_proxy.uponSignal("Seeked").onInterface(INTERFACE_NAME).call([this](const double& to_position){ this->onSeeked(to_position); });
|
||||
m_proxy.uponSignal("FileChanged").onInterface(INTERFACE_NAME).call([this](const std::string& path, const std::string& title){ this->onFileChanged(path, title); });
|
||||
}
|
||||
|
||||
virtual void onPlaybackEngineStarted() = 0;
|
||||
virtual void onSpeedChanged(const double& new_speed) = 0;
|
||||
virtual void onTempoChanged(const double& new_tempo) = 0;
|
||||
|
@ -97,150 +105,150 @@ public:
|
|||
std::string CreateHandle()
|
||||
{
|
||||
std::string result;
|
||||
proxy_->callMethod("CreateHandle").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("CreateHandle").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ClearHandle(const std::string& handle)
|
||||
{
|
||||
proxy_->callMethod("ClearHandle").onInterface(INTERFACE_NAME).withArguments(handle);
|
||||
m_proxy.callMethod("ClearHandle").onInterface(INTERFACE_NAME).withArguments(handle);
|
||||
}
|
||||
|
||||
void Start(const std::string& path, const bool& isUri)
|
||||
{
|
||||
proxy_->callMethod("Start").onInterface(INTERFACE_NAME).withArguments(path, isUri);
|
||||
m_proxy.callMethod("Start").onInterface(INTERFACE_NAME).withArguments(path, isUri);
|
||||
}
|
||||
|
||||
void StartWithStreamIndex(const std::string& path, const bool& isUri, const uint32_t& streamIndex)
|
||||
{
|
||||
proxy_->callMethod("StartWithStreamIndex").onInterface(INTERFACE_NAME).withArguments(path, isUri, streamIndex);
|
||||
m_proxy.callMethod("StartWithStreamIndex").onInterface(INTERFACE_NAME).withArguments(path, isUri, streamIndex);
|
||||
}
|
||||
|
||||
void Load(const std::string& path, const bool& isUri)
|
||||
{
|
||||
proxy_->callMethod("Load").onInterface(INTERFACE_NAME).withArguments(path, isUri);
|
||||
m_proxy.callMethod("Load").onInterface(INTERFACE_NAME).withArguments(path, isUri);
|
||||
}
|
||||
|
||||
void Quit()
|
||||
{
|
||||
proxy_->callMethod("Quit").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Quit").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Stop()
|
||||
{
|
||||
proxy_->callMethod("Stop").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Stop").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void TogglePause()
|
||||
{
|
||||
proxy_->callMethod("TogglePause").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("TogglePause").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::vector<sdbus::Struct<double, std::string, int32_t>> GetStreams()
|
||||
{
|
||||
std::vector<sdbus::Struct<double, std::string, int32_t>> result;
|
||||
proxy_->callMethod("GetStreams").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("GetStreams").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlayStream(const uint32_t& idx)
|
||||
{
|
||||
proxy_->callMethod("PlayStream").onInterface(INTERFACE_NAME).withArguments(idx);
|
||||
m_proxy.callMethod("PlayStream").onInterface(INTERFACE_NAME).withArguments(idx);
|
||||
}
|
||||
|
||||
public:
|
||||
std::string FilePath()
|
||||
{
|
||||
return proxy_->getProperty("FilePath").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("FilePath").onInterface(INTERFACE_NAME).get<std::string>();
|
||||
}
|
||||
|
||||
std::string FileTitle()
|
||||
{
|
||||
return proxy_->getProperty("FileTitle").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("FileTitle").onInterface(INTERFACE_NAME).get<std::string>();
|
||||
}
|
||||
|
||||
double Position()
|
||||
{
|
||||
return proxy_->getProperty("Position").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Position").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
void Position(const double& value)
|
||||
{
|
||||
proxy_->setProperty("Position").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("Position").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
double Length()
|
||||
{
|
||||
return proxy_->getProperty("Length").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Length").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
double Speed()
|
||||
{
|
||||
return proxy_->getProperty("Speed").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Speed").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
void Speed(const double& value)
|
||||
{
|
||||
proxy_->setProperty("Speed").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("Speed").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
double Tempo()
|
||||
{
|
||||
return proxy_->getProperty("Tempo").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Tempo").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
void Tempo(const double& value)
|
||||
{
|
||||
proxy_->setProperty("Tempo").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("Tempo").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
double Pitch()
|
||||
{
|
||||
return proxy_->getProperty("Pitch").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Pitch").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
void Pitch(const double& value)
|
||||
{
|
||||
proxy_->setProperty("Pitch").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("Pitch").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
double Volume()
|
||||
{
|
||||
return proxy_->getProperty("Volume").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Volume").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
void Volume(const double& value)
|
||||
{
|
||||
proxy_->setProperty("Volume").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("Volume").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
bool Paused()
|
||||
{
|
||||
return proxy_->getProperty("Paused").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Paused").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
void Paused(const bool& value)
|
||||
{
|
||||
proxy_->setProperty("Paused").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("Paused").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
bool IsStopped()
|
||||
{
|
||||
return proxy_->getProperty("IsStopped").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("IsStopped").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
bool IsDaemon()
|
||||
{
|
||||
return proxy_->getProperty("IsDaemon").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("IsDaemon").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
uint32_t StreamIdx()
|
||||
{
|
||||
return proxy_->getProperty("StreamIdx").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("StreamIdx").onInterface(INTERFACE_NAME).get<uint32_t>();
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
@ -256,81 +264,85 @@ public:
|
|||
|
||||
protected:
|
||||
Errors_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
Errors_proxy(const Errors_proxy&) = delete;
|
||||
Errors_proxy& operator=(const Errors_proxy&) = delete;
|
||||
Errors_proxy(Errors_proxy&&) = default;
|
||||
Errors_proxy& operator=(Errors_proxy&&) = default;
|
||||
Errors_proxy(Errors_proxy&&) = delete;
|
||||
Errors_proxy& operator=(Errors_proxy&&) = delete;
|
||||
|
||||
~Errors_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
std::string PopFront(const std::string& handle)
|
||||
{
|
||||
std::string result;
|
||||
proxy_->callMethod("PopFront").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
m_proxy.callMethod("PopFront").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string PopBack(const std::string& handle)
|
||||
{
|
||||
std::string result;
|
||||
proxy_->callMethod("PopBack").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
m_proxy.callMethod("PopBack").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string PeekFront(const std::string& handle)
|
||||
{
|
||||
std::string result;
|
||||
proxy_->callMethod("PeekFront").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
m_proxy.callMethod("PeekFront").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string PeekBack(const std::string& handle)
|
||||
{
|
||||
std::string result;
|
||||
proxy_->callMethod("PeekBack").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
m_proxy.callMethod("PeekBack").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t GetCount(const std::string& handle)
|
||||
{
|
||||
uint32_t result;
|
||||
proxy_->callMethod("GetCount").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
m_proxy.callMethod("GetCount").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsEmpty(const std::string& handle)
|
||||
{
|
||||
bool result;
|
||||
proxy_->callMethod("IsEmpty").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
m_proxy.callMethod("IsEmpty").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Clear(const std::string& handle)
|
||||
{
|
||||
proxy_->callMethod("Clear").onInterface(INTERFACE_NAME).withArguments(handle);
|
||||
m_proxy.callMethod("Clear").onInterface(INTERFACE_NAME).withArguments(handle);
|
||||
}
|
||||
|
||||
std::vector<std::string> PeekAll(const std::string& handle)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
proxy_->callMethod("PeekAll").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
m_proxy.callMethod("PeekAll").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> GetAllAndClear(const std::string& handle)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
proxy_->callMethod("GetAllAndClear").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
m_proxy.callMethod("GetAllAndClear").onInterface(INTERFACE_NAME).withArguments(handle).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
|
|
@ -20,25 +20,30 @@ public:
|
|||
|
||||
protected:
|
||||
MediaPlayer2_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
object_->registerMethod("Raise").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->Raise(); });
|
||||
object_->registerMethod("Quit").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->Quit(); });
|
||||
object_->registerProperty("CanRaise").onInterface(INTERFACE_NAME).withGetter([this](){ return this->CanRaise(); });
|
||||
object_->registerProperty("CanQuit").onInterface(INTERFACE_NAME).withGetter([this](){ return this->CanQuit(); });
|
||||
object_->registerProperty("HasTrackList").onInterface(INTERFACE_NAME).withGetter([this](){ return this->HasTrackList(); });
|
||||
object_->registerProperty("Identity").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Identity(); });
|
||||
object_->registerProperty("SupportedUriSchemes").onInterface(INTERFACE_NAME).withGetter([this](){ return this->SupportedUriSchemes(); });
|
||||
object_->registerProperty("SupportedMimeTypes").onInterface(INTERFACE_NAME).withGetter([this](){ return this->SupportedMimeTypes(); });
|
||||
}
|
||||
|
||||
MediaPlayer2_adaptor(const MediaPlayer2_adaptor&) = delete;
|
||||
MediaPlayer2_adaptor& operator=(const MediaPlayer2_adaptor&) = delete;
|
||||
MediaPlayer2_adaptor(MediaPlayer2_adaptor&&) = default;
|
||||
MediaPlayer2_adaptor& operator=(MediaPlayer2_adaptor&&) = default;
|
||||
MediaPlayer2_adaptor(MediaPlayer2_adaptor&&) = delete;
|
||||
MediaPlayer2_adaptor& operator=(MediaPlayer2_adaptor&&) = delete;
|
||||
|
||||
~MediaPlayer2_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
m_object.addVTable( sdbus::registerMethod("Raise").implementedAs([this](){ return this->Raise(); })
|
||||
, sdbus::registerMethod("Quit").implementedAs([this](){ return this->Quit(); })
|
||||
, sdbus::registerProperty("CanRaise").withGetter([this](){ return this->CanRaise(); })
|
||||
, sdbus::registerProperty("CanQuit").withGetter([this](){ return this->CanQuit(); })
|
||||
, sdbus::registerProperty("HasTrackList").withGetter([this](){ return this->HasTrackList(); })
|
||||
, sdbus::registerProperty("Identity").withGetter([this](){ return this->Identity(); })
|
||||
, sdbus::registerProperty("SupportedUriSchemes").withGetter([this](){ return this->SupportedUriSchemes(); })
|
||||
, sdbus::registerProperty("SupportedMimeTypes").withGetter([this](){ return this->SupportedMimeTypes(); })
|
||||
).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void Raise() = 0;
|
||||
virtual void Quit() = 0;
|
||||
|
@ -52,7 +57,7 @@ private:
|
|||
virtual std::vector<std::string> SupportedMimeTypes() = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
@ -68,44 +73,49 @@ public:
|
|||
|
||||
protected:
|
||||
Player_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
object_->registerMethod("Next").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->Next(); });
|
||||
object_->registerMethod("Previous").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->Previous(); });
|
||||
object_->registerMethod("Pause").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->Pause(); });
|
||||
object_->registerMethod("PlayPause").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->PlayPause(); });
|
||||
object_->registerMethod("Stop").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->Stop(); });
|
||||
object_->registerMethod("Play").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->Play(); });
|
||||
object_->registerMethod("Seek").onInterface(INTERFACE_NAME).withInputParamNames("Offset").implementedAs([this](const int64_t& Offset){ return this->Seek(Offset); });
|
||||
object_->registerMethod("SetPosition").onInterface(INTERFACE_NAME).withInputParamNames("TrackId", "Position").implementedAs([this](const sdbus::ObjectPath& TrackId, const int64_t& Position){ return this->SetPosition(TrackId, Position); });
|
||||
object_->registerMethod("OpenUri").onInterface(INTERFACE_NAME).withInputParamNames("Uri").implementedAs([this](const std::string& Uri){ return this->OpenUri(Uri); });
|
||||
object_->registerSignal("Seeked").onInterface(INTERFACE_NAME).withParameters<int64_t>("Position");
|
||||
object_->registerProperty("PlaybackStatus").onInterface(INTERFACE_NAME).withGetter([this](){ return this->PlaybackStatus(); });
|
||||
object_->registerProperty("Rate").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Rate(); }).withSetter([this](const double& value){ this->Rate(value); });
|
||||
object_->registerProperty("Metadata").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Metadata(); });
|
||||
object_->registerProperty("Volume").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Volume(); }).withSetter([this](const double& value){ this->Volume(value); });
|
||||
object_->registerProperty("Position").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Position(); });
|
||||
object_->registerProperty("MinimumRate").onInterface(INTERFACE_NAME).withGetter([this](){ return this->MinimumRate(); });
|
||||
object_->registerProperty("MaximumRate").onInterface(INTERFACE_NAME).withGetter([this](){ return this->MaximumRate(); });
|
||||
object_->registerProperty("CanGoNext").onInterface(INTERFACE_NAME).withGetter([this](){ return this->CanGoNext(); });
|
||||
object_->registerProperty("CanGoPrevious").onInterface(INTERFACE_NAME).withGetter([this](){ return this->CanGoPrevious(); });
|
||||
object_->registerProperty("CanPlay").onInterface(INTERFACE_NAME).withGetter([this](){ return this->CanPlay(); });
|
||||
object_->registerProperty("CanPause").onInterface(INTERFACE_NAME).withGetter([this](){ return this->CanPause(); });
|
||||
object_->registerProperty("CanSeek").onInterface(INTERFACE_NAME).withGetter([this](){ return this->CanSeek(); });
|
||||
object_->registerProperty("CanControl").onInterface(INTERFACE_NAME).withGetter([this](){ return this->CanControl(); });
|
||||
}
|
||||
|
||||
Player_adaptor(const Player_adaptor&) = delete;
|
||||
Player_adaptor& operator=(const Player_adaptor&) = delete;
|
||||
Player_adaptor(Player_adaptor&&) = default;
|
||||
Player_adaptor& operator=(Player_adaptor&&) = default;
|
||||
Player_adaptor(Player_adaptor&&) = delete;
|
||||
Player_adaptor& operator=(Player_adaptor&&) = delete;
|
||||
|
||||
~Player_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
m_object.addVTable( sdbus::registerMethod("Next").implementedAs([this](){ return this->Next(); })
|
||||
, sdbus::registerMethod("Previous").implementedAs([this](){ return this->Previous(); })
|
||||
, sdbus::registerMethod("Pause").implementedAs([this](){ return this->Pause(); })
|
||||
, sdbus::registerMethod("PlayPause").implementedAs([this](){ return this->PlayPause(); })
|
||||
, sdbus::registerMethod("Stop").implementedAs([this](){ return this->Stop(); })
|
||||
, sdbus::registerMethod("Play").implementedAs([this](){ return this->Play(); })
|
||||
, sdbus::registerMethod("Seek").withInputParamNames("Offset").implementedAs([this](const int64_t& Offset){ return this->Seek(Offset); })
|
||||
, sdbus::registerMethod("SetPosition").withInputParamNames("TrackId", "Position").implementedAs([this](const sdbus::ObjectPath& TrackId, const int64_t& Position){ return this->SetPosition(TrackId, Position); })
|
||||
, sdbus::registerMethod("OpenUri").withInputParamNames("Uri").implementedAs([this](const std::string& Uri){ return this->OpenUri(Uri); })
|
||||
, sdbus::registerSignal("Seeked").withParameters<int64_t>("Position")
|
||||
, sdbus::registerProperty("PlaybackStatus").withGetter([this](){ return this->PlaybackStatus(); })
|
||||
, sdbus::registerProperty("Rate").withGetter([this](){ return this->Rate(); }).withSetter([this](const double& value){ this->Rate(value); })
|
||||
, sdbus::registerProperty("Metadata").withGetter([this](){ return this->Metadata(); })
|
||||
, sdbus::registerProperty("Volume").withGetter([this](){ return this->Volume(); }).withSetter([this](const double& value){ this->Volume(value); })
|
||||
, sdbus::registerProperty("Position").withGetter([this](){ return this->Position(); })
|
||||
, sdbus::registerProperty("MinimumRate").withGetter([this](){ return this->MinimumRate(); })
|
||||
, sdbus::registerProperty("MaximumRate").withGetter([this](){ return this->MaximumRate(); })
|
||||
, sdbus::registerProperty("CanGoNext").withGetter([this](){ return this->CanGoNext(); })
|
||||
, sdbus::registerProperty("CanGoPrevious").withGetter([this](){ return this->CanGoPrevious(); })
|
||||
, sdbus::registerProperty("CanPlay").withGetter([this](){ return this->CanPlay(); })
|
||||
, sdbus::registerProperty("CanPause").withGetter([this](){ return this->CanPause(); })
|
||||
, sdbus::registerProperty("CanSeek").withGetter([this](){ return this->CanSeek(); })
|
||||
, sdbus::registerProperty("CanControl").withGetter([this](){ return this->CanControl(); })
|
||||
).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
public:
|
||||
void emitSeeked(const int64_t& Position)
|
||||
{
|
||||
object_->emitSignal("Seeked").onInterface(INTERFACE_NAME).withArguments(Position);
|
||||
m_object.emitSignal("Seeked").onInterface(INTERFACE_NAME).withArguments(Position);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -137,7 +147,7 @@ private:
|
|||
virtual bool CanControl() = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
@ -153,46 +163,51 @@ public:
|
|||
|
||||
protected:
|
||||
TrackList_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
object_->registerMethod("GetTracksMetadata").onInterface(INTERFACE_NAME).withInputParamNames("TrackIds").withOutputParamNames("Metadata").implementedAs([this](const std::vector<sdbus::ObjectPath>& TrackIds){ return this->GetTracksMetadata(TrackIds); });
|
||||
object_->registerMethod("AddTrack").onInterface(INTERFACE_NAME).withInputParamNames("Uri", "AfterTrack", "SetAsCurrent").implementedAs([this](const std::string& Uri, const sdbus::ObjectPath& AfterTrack, const bool& SetAsCurrent){ return this->AddTrack(Uri, AfterTrack, SetAsCurrent); });
|
||||
object_->registerMethod("RemoveTrack").onInterface(INTERFACE_NAME).withInputParamNames("TrackId").implementedAs([this](const sdbus::ObjectPath& TrackId){ return this->RemoveTrack(TrackId); });
|
||||
object_->registerMethod("GoTo").onInterface(INTERFACE_NAME).withInputParamNames("TrackId").implementedAs([this](const sdbus::ObjectPath& TrackId){ return this->GoTo(TrackId); });
|
||||
object_->registerSignal("TrackListReplaced").onInterface(INTERFACE_NAME).withParameters<std::vector<sdbus::ObjectPath>, sdbus::ObjectPath>("Tracks", "CurrentTrack");
|
||||
object_->registerSignal("TrackAdded").onInterface(INTERFACE_NAME).withParameters<std::map<std::string, sdbus::Variant>, sdbus::ObjectPath>("Metadata", "AfterTrack");
|
||||
object_->registerSignal("TrackRemoved").onInterface(INTERFACE_NAME).withParameters<sdbus::ObjectPath>("TrackId");
|
||||
object_->registerSignal("TrackMetadataChanged").onInterface(INTERFACE_NAME).withParameters<sdbus::ObjectPath, std::map<std::string, sdbus::Variant>>("TrackId", "Metadata");
|
||||
object_->registerProperty("Tracks").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Tracks(); });
|
||||
object_->registerProperty("CanEditTracks").onInterface(INTERFACE_NAME).withGetter([this](){ return this->CanEditTracks(); });
|
||||
}
|
||||
|
||||
TrackList_adaptor(const TrackList_adaptor&) = delete;
|
||||
TrackList_adaptor& operator=(const TrackList_adaptor&) = delete;
|
||||
TrackList_adaptor(TrackList_adaptor&&) = default;
|
||||
TrackList_adaptor& operator=(TrackList_adaptor&&) = default;
|
||||
TrackList_adaptor(TrackList_adaptor&&) = delete;
|
||||
TrackList_adaptor& operator=(TrackList_adaptor&&) = delete;
|
||||
|
||||
~TrackList_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
m_object.addVTable( sdbus::registerMethod("GetTracksMetadata").withInputParamNames("TrackIds").withOutputParamNames("Metadata").implementedAs([this](const std::vector<sdbus::ObjectPath>& TrackIds){ return this->GetTracksMetadata(TrackIds); })
|
||||
, sdbus::registerMethod("AddTrack").withInputParamNames("Uri", "AfterTrack", "SetAsCurrent").implementedAs([this](const std::string& Uri, const sdbus::ObjectPath& AfterTrack, const bool& SetAsCurrent){ return this->AddTrack(Uri, AfterTrack, SetAsCurrent); })
|
||||
, sdbus::registerMethod("RemoveTrack").withInputParamNames("TrackId").implementedAs([this](const sdbus::ObjectPath& TrackId){ return this->RemoveTrack(TrackId); })
|
||||
, sdbus::registerMethod("GoTo").withInputParamNames("TrackId").implementedAs([this](const sdbus::ObjectPath& TrackId){ return this->GoTo(TrackId); })
|
||||
, sdbus::registerSignal("TrackListReplaced").withParameters<std::vector<sdbus::ObjectPath>, sdbus::ObjectPath>("Tracks", "CurrentTrack")
|
||||
, sdbus::registerSignal("TrackAdded").withParameters<std::map<std::string, sdbus::Variant>, sdbus::ObjectPath>("Metadata", "AfterTrack")
|
||||
, sdbus::registerSignal("TrackRemoved").withParameters<sdbus::ObjectPath>("TrackId")
|
||||
, sdbus::registerSignal("TrackMetadataChanged").withParameters<sdbus::ObjectPath, std::map<std::string, sdbus::Variant>>("TrackId", "Metadata")
|
||||
, sdbus::registerProperty("Tracks").withGetter([this](){ return this->Tracks(); })
|
||||
, sdbus::registerProperty("CanEditTracks").withGetter([this](){ return this->CanEditTracks(); })
|
||||
).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
public:
|
||||
void emitTrackListReplaced(const std::vector<sdbus::ObjectPath>& Tracks, const sdbus::ObjectPath& CurrentTrack)
|
||||
{
|
||||
object_->emitSignal("TrackListReplaced").onInterface(INTERFACE_NAME).withArguments(Tracks, CurrentTrack);
|
||||
m_object.emitSignal("TrackListReplaced").onInterface(INTERFACE_NAME).withArguments(Tracks, CurrentTrack);
|
||||
}
|
||||
|
||||
void emitTrackAdded(const std::map<std::string, sdbus::Variant>& Metadata, const sdbus::ObjectPath& AfterTrack)
|
||||
{
|
||||
object_->emitSignal("TrackAdded").onInterface(INTERFACE_NAME).withArguments(Metadata, AfterTrack);
|
||||
m_object.emitSignal("TrackAdded").onInterface(INTERFACE_NAME).withArguments(Metadata, AfterTrack);
|
||||
}
|
||||
|
||||
void emitTrackRemoved(const sdbus::ObjectPath& TrackId)
|
||||
{
|
||||
object_->emitSignal("TrackRemoved").onInterface(INTERFACE_NAME).withArguments(TrackId);
|
||||
m_object.emitSignal("TrackRemoved").onInterface(INTERFACE_NAME).withArguments(TrackId);
|
||||
}
|
||||
|
||||
void emitTrackMetadataChanged(const sdbus::ObjectPath& TrackId, const std::map<std::string, sdbus::Variant>& Metadata)
|
||||
{
|
||||
object_->emitSignal("TrackMetadataChanged").onInterface(INTERFACE_NAME).withArguments(TrackId, Metadata);
|
||||
m_object.emitSignal("TrackMetadataChanged").onInterface(INTERFACE_NAME).withArguments(TrackId, Metadata);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -206,7 +221,7 @@ private:
|
|||
virtual bool CanEditTracks() = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
|
|
@ -20,61 +20,65 @@ public:
|
|||
|
||||
protected:
|
||||
MediaPlayer2_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
MediaPlayer2_proxy(const MediaPlayer2_proxy&) = delete;
|
||||
MediaPlayer2_proxy& operator=(const MediaPlayer2_proxy&) = delete;
|
||||
MediaPlayer2_proxy(MediaPlayer2_proxy&&) = default;
|
||||
MediaPlayer2_proxy& operator=(MediaPlayer2_proxy&&) = default;
|
||||
MediaPlayer2_proxy(MediaPlayer2_proxy&&) = delete;
|
||||
MediaPlayer2_proxy& operator=(MediaPlayer2_proxy&&) = delete;
|
||||
|
||||
~MediaPlayer2_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
void Raise()
|
||||
{
|
||||
proxy_->callMethod("Raise").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Raise").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Quit()
|
||||
{
|
||||
proxy_->callMethod("Quit").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Quit").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
public:
|
||||
bool CanRaise()
|
||||
{
|
||||
return proxy_->getProperty("CanRaise").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("CanRaise").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
bool CanQuit()
|
||||
{
|
||||
return proxy_->getProperty("CanQuit").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("CanQuit").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
bool HasTrackList()
|
||||
{
|
||||
return proxy_->getProperty("HasTrackList").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("HasTrackList").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
std::string Identity()
|
||||
{
|
||||
return proxy_->getProperty("Identity").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Identity").onInterface(INTERFACE_NAME).get<std::string>();
|
||||
}
|
||||
|
||||
std::vector<std::string> SupportedUriSchemes()
|
||||
{
|
||||
return proxy_->getProperty("SupportedUriSchemes").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("SupportedUriSchemes").onInterface(INTERFACE_NAME).get<std::vector<std::string>>();
|
||||
}
|
||||
|
||||
std::vector<std::string> SupportedMimeTypes()
|
||||
{
|
||||
return proxy_->getProperty("SupportedMimeTypes").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("SupportedMimeTypes").onInterface(INTERFACE_NAME).get<std::vector<std::string>>();
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
@ -90,144 +94,148 @@ public:
|
|||
|
||||
protected:
|
||||
Player_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
proxy_->uponSignal("Seeked").onInterface(INTERFACE_NAME).call([this](const int64_t& Position){ this->onSeeked(Position); });
|
||||
}
|
||||
|
||||
Player_proxy(const Player_proxy&) = delete;
|
||||
Player_proxy& operator=(const Player_proxy&) = delete;
|
||||
Player_proxy(Player_proxy&&) = default;
|
||||
Player_proxy& operator=(Player_proxy&&) = default;
|
||||
Player_proxy(Player_proxy&&) = delete;
|
||||
Player_proxy& operator=(Player_proxy&&) = delete;
|
||||
|
||||
~Player_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
m_proxy.uponSignal("Seeked").onInterface(INTERFACE_NAME).call([this](const int64_t& Position){ this->onSeeked(Position); });
|
||||
}
|
||||
|
||||
virtual void onSeeked(const int64_t& Position) = 0;
|
||||
|
||||
public:
|
||||
void Next()
|
||||
{
|
||||
proxy_->callMethod("Next").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Next").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Previous()
|
||||
{
|
||||
proxy_->callMethod("Previous").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Previous").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Pause()
|
||||
{
|
||||
proxy_->callMethod("Pause").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Pause").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void PlayPause()
|
||||
{
|
||||
proxy_->callMethod("PlayPause").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("PlayPause").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Stop()
|
||||
{
|
||||
proxy_->callMethod("Stop").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Stop").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Play()
|
||||
{
|
||||
proxy_->callMethod("Play").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Play").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void Seek(const int64_t& Offset)
|
||||
{
|
||||
proxy_->callMethod("Seek").onInterface(INTERFACE_NAME).withArguments(Offset);
|
||||
m_proxy.callMethod("Seek").onInterface(INTERFACE_NAME).withArguments(Offset);
|
||||
}
|
||||
|
||||
void SetPosition(const sdbus::ObjectPath& TrackId, const int64_t& Position)
|
||||
{
|
||||
proxy_->callMethod("SetPosition").onInterface(INTERFACE_NAME).withArguments(TrackId, Position);
|
||||
m_proxy.callMethod("SetPosition").onInterface(INTERFACE_NAME).withArguments(TrackId, Position);
|
||||
}
|
||||
|
||||
void OpenUri(const std::string& Uri)
|
||||
{
|
||||
proxy_->callMethod("OpenUri").onInterface(INTERFACE_NAME).withArguments(Uri);
|
||||
m_proxy.callMethod("OpenUri").onInterface(INTERFACE_NAME).withArguments(Uri);
|
||||
}
|
||||
|
||||
public:
|
||||
std::string PlaybackStatus()
|
||||
{
|
||||
return proxy_->getProperty("PlaybackStatus").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("PlaybackStatus").onInterface(INTERFACE_NAME).get<std::string>();
|
||||
}
|
||||
|
||||
double Rate()
|
||||
{
|
||||
return proxy_->getProperty("Rate").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Rate").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
void Rate(const double& value)
|
||||
{
|
||||
proxy_->setProperty("Rate").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("Rate").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
std::map<std::string, sdbus::Variant> Metadata()
|
||||
{
|
||||
return proxy_->getProperty("Metadata").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Metadata").onInterface(INTERFACE_NAME).get<std::map<std::string, sdbus::Variant>>();
|
||||
}
|
||||
|
||||
double Volume()
|
||||
{
|
||||
return proxy_->getProperty("Volume").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Volume").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
void Volume(const double& value)
|
||||
{
|
||||
proxy_->setProperty("Volume").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("Volume").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
int64_t Position()
|
||||
{
|
||||
return proxy_->getProperty("Position").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Position").onInterface(INTERFACE_NAME).get<int64_t>();
|
||||
}
|
||||
|
||||
double MinimumRate()
|
||||
{
|
||||
return proxy_->getProperty("MinimumRate").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("MinimumRate").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
double MaximumRate()
|
||||
{
|
||||
return proxy_->getProperty("MaximumRate").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("MaximumRate").onInterface(INTERFACE_NAME).get<double>();
|
||||
}
|
||||
|
||||
bool CanGoNext()
|
||||
{
|
||||
return proxy_->getProperty("CanGoNext").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("CanGoNext").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
bool CanGoPrevious()
|
||||
{
|
||||
return proxy_->getProperty("CanGoPrevious").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("CanGoPrevious").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
bool CanPlay()
|
||||
{
|
||||
return proxy_->getProperty("CanPlay").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("CanPlay").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
bool CanPause()
|
||||
{
|
||||
return proxy_->getProperty("CanPause").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("CanPause").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
bool CanSeek()
|
||||
{
|
||||
return proxy_->getProperty("CanSeek").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("CanSeek").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
bool CanControl()
|
||||
{
|
||||
return proxy_->getProperty("CanControl").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("CanControl").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
@ -243,21 +251,25 @@ public:
|
|||
|
||||
protected:
|
||||
TrackList_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
proxy_->uponSignal("TrackListReplaced").onInterface(INTERFACE_NAME).call([this](const std::vector<sdbus::ObjectPath>& Tracks, const sdbus::ObjectPath& CurrentTrack){ this->onTrackListReplaced(Tracks, CurrentTrack); });
|
||||
proxy_->uponSignal("TrackAdded").onInterface(INTERFACE_NAME).call([this](const std::map<std::string, sdbus::Variant>& Metadata, const sdbus::ObjectPath& AfterTrack){ this->onTrackAdded(Metadata, AfterTrack); });
|
||||
proxy_->uponSignal("TrackRemoved").onInterface(INTERFACE_NAME).call([this](const sdbus::ObjectPath& TrackId){ this->onTrackRemoved(TrackId); });
|
||||
proxy_->uponSignal("TrackMetadataChanged").onInterface(INTERFACE_NAME).call([this](const sdbus::ObjectPath& TrackId, const std::map<std::string, sdbus::Variant>& Metadata){ this->onTrackMetadataChanged(TrackId, Metadata); });
|
||||
}
|
||||
|
||||
TrackList_proxy(const TrackList_proxy&) = delete;
|
||||
TrackList_proxy& operator=(const TrackList_proxy&) = delete;
|
||||
TrackList_proxy(TrackList_proxy&&) = default;
|
||||
TrackList_proxy& operator=(TrackList_proxy&&) = default;
|
||||
TrackList_proxy(TrackList_proxy&&) = delete;
|
||||
TrackList_proxy& operator=(TrackList_proxy&&) = delete;
|
||||
|
||||
~TrackList_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
m_proxy.uponSignal("TrackListReplaced").onInterface(INTERFACE_NAME).call([this](const std::vector<sdbus::ObjectPath>& Tracks, const sdbus::ObjectPath& CurrentTrack){ this->onTrackListReplaced(Tracks, CurrentTrack); });
|
||||
m_proxy.uponSignal("TrackAdded").onInterface(INTERFACE_NAME).call([this](const std::map<std::string, sdbus::Variant>& Metadata, const sdbus::ObjectPath& AfterTrack){ this->onTrackAdded(Metadata, AfterTrack); });
|
||||
m_proxy.uponSignal("TrackRemoved").onInterface(INTERFACE_NAME).call([this](const sdbus::ObjectPath& TrackId){ this->onTrackRemoved(TrackId); });
|
||||
m_proxy.uponSignal("TrackMetadataChanged").onInterface(INTERFACE_NAME).call([this](const sdbus::ObjectPath& TrackId, const std::map<std::string, sdbus::Variant>& Metadata){ this->onTrackMetadataChanged(TrackId, Metadata); });
|
||||
}
|
||||
|
||||
virtual void onTrackListReplaced(const std::vector<sdbus::ObjectPath>& Tracks, const sdbus::ObjectPath& CurrentTrack) = 0;
|
||||
virtual void onTrackAdded(const std::map<std::string, sdbus::Variant>& Metadata, const sdbus::ObjectPath& AfterTrack) = 0;
|
||||
virtual void onTrackRemoved(const sdbus::ObjectPath& TrackId) = 0;
|
||||
|
@ -267,38 +279,38 @@ public:
|
|||
std::vector<std::map<std::string, sdbus::Variant>> GetTracksMetadata(const std::vector<sdbus::ObjectPath>& TrackIds)
|
||||
{
|
||||
std::vector<std::map<std::string, sdbus::Variant>> result;
|
||||
proxy_->callMethod("GetTracksMetadata").onInterface(INTERFACE_NAME).withArguments(TrackIds).storeResultsTo(result);
|
||||
m_proxy.callMethod("GetTracksMetadata").onInterface(INTERFACE_NAME).withArguments(TrackIds).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void AddTrack(const std::string& Uri, const sdbus::ObjectPath& AfterTrack, const bool& SetAsCurrent)
|
||||
{
|
||||
proxy_->callMethod("AddTrack").onInterface(INTERFACE_NAME).withArguments(Uri, AfterTrack, SetAsCurrent);
|
||||
m_proxy.callMethod("AddTrack").onInterface(INTERFACE_NAME).withArguments(Uri, AfterTrack, SetAsCurrent);
|
||||
}
|
||||
|
||||
void RemoveTrack(const sdbus::ObjectPath& TrackId)
|
||||
{
|
||||
proxy_->callMethod("RemoveTrack").onInterface(INTERFACE_NAME).withArguments(TrackId);
|
||||
m_proxy.callMethod("RemoveTrack").onInterface(INTERFACE_NAME).withArguments(TrackId);
|
||||
}
|
||||
|
||||
void GoTo(const sdbus::ObjectPath& TrackId)
|
||||
{
|
||||
proxy_->callMethod("GoTo").onInterface(INTERFACE_NAME).withArguments(TrackId);
|
||||
m_proxy.callMethod("GoTo").onInterface(INTERFACE_NAME).withArguments(TrackId);
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<sdbus::ObjectPath> Tracks()
|
||||
{
|
||||
return proxy_->getProperty("Tracks").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("Tracks").onInterface(INTERFACE_NAME).get<std::vector<sdbus::ObjectPath>>();
|
||||
}
|
||||
|
||||
bool CanEditTracks()
|
||||
{
|
||||
return proxy_->getProperty("CanEditTracks").onInterface(INTERFACE_NAME);
|
||||
return m_proxy.getProperty("CanEditTracks").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
|
26
dbus.cpp
26
dbus.cpp
|
@ -6,7 +6,7 @@
|
|||
#include <fmt/format.h>
|
||||
#ifdef DBUS_ENABLED
|
||||
MprisAPI::MprisAPI(sdbus::IConnection &connection, std::string objectPath, DBusAPI *dbus_api)
|
||||
: AdaptorInterfaces(connection, std::move(objectPath))
|
||||
: AdaptorInterfaces(connection, sdbus::ObjectPath{objectPath})
|
||||
, dbus_api(dbus_api)
|
||||
, connection(connection)
|
||||
{
|
||||
|
@ -57,12 +57,12 @@ void MprisAPI::Rate(const double &value) {
|
|||
std::map<std::string, sdbus::Variant> MprisAPI::Metadata() {
|
||||
std::map<std::string, sdbus::Variant> output;
|
||||
if (!dbus_api->IsStopped()) {
|
||||
output["mpris:length"] = (int64_t)(dbus_api->Length() * 1000000);
|
||||
output["mpris:trackid"] = playing_track_id;
|
||||
output["xesam:title"] = dbus_api->FileTitle();
|
||||
output["xesam:url"] = dbus_api->FilePath();
|
||||
output["mpris:length"] = sdbus::Variant{(int64_t)(dbus_api->Length() * 1000000)};
|
||||
output["mpris:trackid"] = sdbus::Variant{playing_track_id};
|
||||
output["xesam:title"] = sdbus::Variant{dbus_api->FileTitle()};
|
||||
output["xesam:url"] = sdbus::Variant{dbus_api->FilePath()};
|
||||
} else {
|
||||
output["mpris:trackid"] = empty_track_id;
|
||||
output["mpris:trackid"] = sdbus::Variant{empty_track_id};
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
@ -93,8 +93,8 @@ std::vector<meta_t> MprisAPI::GetTracksMetadata(const std::vector<track_id_t> &T
|
|||
int i = 0;
|
||||
for (auto stream : streams) {
|
||||
std::map<std::string, sdbus::Variant> meta;
|
||||
meta["mpris:trackid"] = fmt::format("{}{}", streamPrefix, i);
|
||||
meta["xesam:title"] = stream.name;
|
||||
meta["mpris:trackid"] = sdbus::Variant{fmt::format("{}{}", streamPrefix, i)};
|
||||
meta["xesam:title"] = sdbus::Variant{stream.name};
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ std::vector<track_id_t> MprisAPI::Tracks() {
|
|||
auto streams = dbus_api->playback->get_streams();
|
||||
int i = 0;
|
||||
for (auto stream : streams) {
|
||||
output.push_back(fmt::format("{}{}", streamPrefix, i));
|
||||
output.push_back(sdbus::ObjectPath{fmt::format("{}{}", streamPrefix, i)});
|
||||
i++;
|
||||
}
|
||||
return output;
|
||||
|
@ -143,14 +143,14 @@ DBusAPI::DBusAPI(Playback *playback, bool daemon)
|
|||
}
|
||||
#else
|
||||
DBusAPI::DBusAPI(Playback *playback, sdbus::IConnection &connection, std::string objectPath, bool daemon)
|
||||
: AdaptorInterfaces(connection, std::move(objectPath))
|
||||
: AdaptorInterfaces(connection, sdbus::ObjectPath{objectPath})
|
||||
, daemon(daemon)
|
||||
, playback(playback)
|
||||
, connection(connection)
|
||||
{
|
||||
registerAdaptor();
|
||||
playback->register_handle(this);
|
||||
auto mprisConnection = sdbus::createSessionBusConnection("org.mpris.MediaPlayer2.Looper");
|
||||
auto mprisConnection = sdbus::createSessionBusConnection(sdbus::ServiceName{"org.mpris.MediaPlayer2.Looper"});
|
||||
auto &mprisConRef = *mprisConnection.release();
|
||||
mpris = new MprisAPI(mprisConRef, "/org/mpris/MediaPlayer2", this);
|
||||
threadFunc = std::thread([this]() {
|
||||
|
@ -166,7 +166,7 @@ const char *DBusAPI::objectPath = "/com/complecwaft/looper";
|
|||
const char *DBusAPI::busName = "com.complecwaft.looper";
|
||||
DBusAPI *DBusAPI::Create(Playback *playback, bool daemon) {
|
||||
#ifdef DBUS_ENABLED
|
||||
auto connection = sdbus::createSessionBusConnection(busName);
|
||||
auto connection = sdbus::createSessionBusConnection(sdbus::ServiceName{busName});
|
||||
auto &con_ref = *connection.release();
|
||||
return new DBusAPI(playback, con_ref, objectPath, daemon);
|
||||
#else
|
||||
|
@ -590,7 +590,7 @@ DBusAPISender *DBusAPISender::Create() {
|
|||
}
|
||||
#ifdef DBUS_ENABLED
|
||||
DBusAPISender::DBusAPISender(sdbus::IConnection &connection, std::string busName, std::string objectPath)
|
||||
: ProxyInterfaces(connection, std::move(busName), std::move(objectPath)) {
|
||||
: ProxyInterfaces(connection, sdbus::BusName{busName}, sdbus::ObjectPath{objectPath}) {
|
||||
registerProxy();
|
||||
DEBUG.writeln("Pinging DBus API to check for its existance.");
|
||||
Ping();
|
||||
|
|
10
dbus.hpp
10
dbus.hpp
|
@ -23,17 +23,17 @@ class MprisAPI : public sdbus::AdaptorInterfaces<org::mpris::MediaPlayer2_adapto
|
|||
const std::string playerInterface = "org.mpris.MediaPlayer2.Player";
|
||||
const std::string trackInterface = "org.mpris.MediaPlayer2.TrackList";
|
||||
inline void sendPropertiesChanged(const std::string interface, const std::initializer_list<std::string> properties) {
|
||||
std::vector<std::string> property_vec;
|
||||
std::vector<sdbus::MemberName> property_vec;
|
||||
for (auto property : properties) {
|
||||
property_vec.push_back(property);
|
||||
property_vec.push_back(sdbus::MemberName{property});
|
||||
}
|
||||
emitPropertiesChangedSignal(interface, property_vec);
|
||||
emitPropertiesChangedSignal(sdbus::InterfaceName{interface}, property_vec);
|
||||
}
|
||||
public:
|
||||
#define meta_t std::map<std::string, sdbus::Variant>
|
||||
#define track_id_t sdbus::ObjectPath
|
||||
const sdbus::ObjectPath playing_track_id = "/com/complecwaft/Looper/PlayingTrack";
|
||||
const sdbus::ObjectPath empty_track_id = "/org/mpris/MediaPlayer2/TrackList/NoTrack";
|
||||
const sdbus::ObjectPath playing_track_id = sdbus::ObjectPath{"/com/complecwaft/Looper/PlayingTrack"};
|
||||
const sdbus::ObjectPath empty_track_id = sdbus::ObjectPath{"/org/mpris/MediaPlayer2/TrackList/NoTrack"};
|
||||
|
||||
inline void Raise() override { }
|
||||
void Quit() override;
|
||||
|
|
Loading…
Reference in a new issue