Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2024 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #pragma once
24 :
25 : #include "global/async/asyncable.h"
26 :
27 : #include "modularity/ioc.h"
28 : #include "../iextensionsconfiguration.h"
29 : #include "../iextensionsregister.h"
30 : #include "../iextensionsprovider.h"
31 : #include "../iextensionsuiengine.h"
32 : #include "interactive/iinteractive.h"
33 : #include "io/ifilesystem.h"
34 :
35 : namespace muse::extensions {
36 : class ExtensionsProvider : public IExtensionsProvider, public Contextable, public async::Asyncable
37 : {
38 : GlobalInject<IExtensionsConfiguration> configuration;
39 : GlobalInject<IExtensionsRegister> extensionsRegister;
40 : GlobalInject<io::IFileSystem> fileSystem;
41 : ContextInject<IExtensionsUiEngine> extensionsUiEngine = { this };
42 : ContextInject<IInteractive> interactive = { this };
43 :
44 : public:
45 0 : ExtensionsProvider(const modularity::ContextPtr& iocCtx)
46 0 : : Contextable(iocCtx) {}
47 :
48 : void reloadExtensions() override;
49 :
50 : ManifestList manifestList(Filter filter = Filter::All) const override;
51 : async::Notification manifestListChanged() const override;
52 :
53 : bool exists(const ExtensionUri& uri) const override;
54 : const Manifest& manifest(const ExtensionUri& uri) const override;
55 :
56 : void setEnabled(const ExtensionUri& uri, bool enabled) override;
57 : bool isEnabled(const ExtensionUri& uri) const override;
58 : async::Channel<ExtensionUri> enabledChanged() const override;
59 :
60 : Ret perform(const ExtensionUri& uri, const ExtensionActionCode& action) override;
61 : async::Channel<ExtensionUri, ExtensionActionCode> dockRequested() const override;
62 : Ret run(const ExtensionUri& uri, const ExtensionActionCode& action) override;
63 :
64 : std::unique_ptr<IExtensionSession> newSession(const ExtensionUri& uri, const io::path_t& relativeScriptPath) const override;
65 :
66 : private:
67 : async::Channel<ExtensionUri, ExtensionActionCode> m_dockRequested;
68 : Ret run(const Action& action, const Manifest& manifest);
69 : std::unique_ptr<IExtensionSession> newSession(const Manifest& manifest, const io::path_t& scriptPath) const;
70 : };
71 : }
|