diff --git a/framework/cloud/audiocom/iaudiocomservice.h b/framework/cloud/audiocom/iaudiocomservice.h index 70ea7b2b60..63996659b2 100644 --- a/framework/cloud/audiocom/iaudiocomservice.h +++ b/framework/cloud/audiocom/iaudiocomservice.h @@ -27,13 +27,15 @@ #include "cloud/cloudtypes.h" +#include "cloud/iauthorizationservice.h" + class QIODevice; class QString; using DevicePtr = std::shared_ptr; namespace muse::cloud { -class IAudioComService : MODULE_GLOBAL_INTERFACE +class IAudioComService : MODULE_CONTEXT_INTERFACE { INTERFACE_ID(IAudioComService) diff --git a/framework/cloud/cloudmodule.cpp b/framework/cloud/cloudmodule.cpp index 38041a4b5a..c7a5e734c9 100644 --- a/framework/cloud/cloudmodule.cpp +++ b/framework/cloud/cloudmodule.cpp @@ -35,6 +35,8 @@ using namespace muse; using namespace muse::cloud; using namespace muse::modularity; +static const std::string mname("cloud"); + std::string CloudModule::moduleName() const { return "cloud"; @@ -44,12 +46,6 @@ void CloudModule::registerExports() { m_cloudConfiguration = std::make_shared(globalCtx()); globalIoc()->registerExport(moduleName(), m_cloudConfiguration); -#ifdef MUSE_MODULE_CLOUD_MUSESCORECOM - m_museScoreComService = std::make_shared(globalCtx()); - globalIoc()->registerExport(moduleName(), m_museScoreComService); -#endif - m_audioComService = std::make_shared(globalCtx()); - globalIoc()->registerExport(moduleName(), m_audioComService); } void CloudModule::resolveImports() @@ -63,6 +59,25 @@ void CloudModule::resolveImports() void CloudModule::onInit(const IApplication::RunMode&) { m_cloudConfiguration->init(); +} + +modularity::IContextSetup* CloudModule::newContext(const muse::modularity::ContextPtr& ctx) const +{ + return new CloudModuleContext(ctx); +} + +void CloudModuleContext::registerExports() +{ +#ifdef MUSE_MODULE_CLOUD_MUSESCORECOM + m_museScoreComService = std::make_shared(iocContext()); + ioc()->registerExport(mname, m_museScoreComService); +#endif + m_audioComService = std::make_shared(iocContext()); + ioc()->registerExport(mname, m_audioComService); +} + +void CloudModuleContext::onInit(const IApplication::RunMode&) +{ #ifdef MUSE_MODULE_CLOUD_MUSESCORECOM m_museScoreComService->init(); #endif diff --git a/framework/cloud/cloudmodule.h b/framework/cloud/cloudmodule.h index cfae26a704..2be0ffd994 100644 --- a/framework/cloud/cloudmodule.h +++ b/framework/cloud/cloudmodule.h @@ -28,8 +28,6 @@ namespace muse::cloud { class CloudConfiguration; -class MuseScoreComService; -class AudioComService; class CloudModule : public modularity::IModuleSetup { public: @@ -38,8 +36,24 @@ class CloudModule : public modularity::IModuleSetup void resolveImports() override; void onInit(const IApplication::RunMode& mode) override; + modularity::IContextSetup* newContext(const muse::modularity::ContextPtr& ctx) const override; + private: std::shared_ptr m_cloudConfiguration; +}; + +class MuseScoreComService; +class AudioComService; +class CloudModuleContext : public modularity::IContextSetup +{ +public: + CloudModuleContext(const muse::modularity::ContextPtr& ctx) + : modularity::IContextSetup(ctx) {} + + void registerExports() override; + void onInit(const IApplication::RunMode& mode) override; + +private: #ifdef MUSE_MODULE_CLOUD_MUSESCORECOM std::shared_ptr m_museScoreComService; #endif diff --git a/framework/cloud/musescorecom/imusescorecomservice.h b/framework/cloud/musescorecom/imusescorecomservice.h index 1ffbd9f465..bc063cbcef 100644 --- a/framework/cloud/musescorecom/imusescorecomservice.h +++ b/framework/cloud/musescorecom/imusescorecomservice.h @@ -37,7 +37,7 @@ class QString; using DevicePtr = std::shared_ptr; namespace muse::cloud { -class IMuseScoreComService : MODULE_GLOBAL_INTERFACE +class IMuseScoreComService : MODULE_CONTEXT_INTERFACE { INTERFACE_ID(IMuseScoreComService) diff --git a/framework/cloud/qml/Muse/Cloud/cloudsmodel.h b/framework/cloud/qml/Muse/Cloud/cloudsmodel.h index d151ae9222..db0c283f22 100644 --- a/framework/cloud/qml/Muse/Cloud/cloudsmodel.h +++ b/framework/cloud/qml/Muse/Cloud/cloudsmodel.h @@ -42,9 +42,9 @@ class CloudsModel : public QAbstractListModel, public Contextable, public async: QML_ELEMENT #ifdef MUSE_MODULE_CLOUD_MUSESCORECOM - GlobalInject museScoreComService; + ContextInject museScoreComService = { this }; #endif - GlobalInject audioComService; + ContextInject audioComService = { this }; public: explicit CloudsModel(QObject* parent = nullptr); diff --git a/framework/cloud/qml/Muse/Cloud/musescorecomauthorizationmodel.h b/framework/cloud/qml/Muse/Cloud/musescorecomauthorizationmodel.h index 87b16a6419..f8ea4e6026 100644 --- a/framework/cloud/qml/Muse/Cloud/musescorecomauthorizationmodel.h +++ b/framework/cloud/qml/Muse/Cloud/musescorecomauthorizationmodel.h @@ -39,7 +39,7 @@ class MuseScoreComAuthorizationModel : public QObject, public Contextable, publi QML_ELEMENT - GlobalInject museScoreComService; + ContextInject museScoreComService = { this }; public: explicit MuseScoreComAuthorizationModel(QObject* parent = nullptr);