Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2026 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 : #include "midiremotemodule.h"
24 :
25 : #include "midiremote/internal/midiremoteconfiguration.h"
26 : #include "midiremote/internal/midiremote.h"
27 : #include "midiremote/internal/mmcdecoderfactory.h"
28 :
29 : #include "muse_framework_config.h"
30 :
31 : #ifdef MUSE_MODULE_DIAGNOSTICS
32 : #include "diagnostics/idiagnosticspathsregister.h"
33 : #endif
34 :
35 : using namespace muse::midiremote;
36 : using namespace muse::modularity;
37 :
38 : static const std::string mname("midiremote");
39 :
40 0 : std::string MidiRemoteModule::moduleName() const
41 : {
42 0 : return mname;
43 : }
44 :
45 0 : void MidiRemoteModule::registerExports()
46 : {
47 0 : m_configuration = std::make_shared<MidiRemoteConfiguration>();
48 :
49 0 : globalIoc()->registerExport<IMidiRemoteConfiguration>(mname, m_configuration);
50 :
51 0 : globalIoc()->registerExport<IMMCDecoderFactory>(moduleName(), std::make_shared<MMCDecoderFactory>());
52 :
53 : #ifdef MUSE_MODULE_DIAGNOSTICS
54 0 : auto pr = globalIoc()->resolve<muse::diagnostics::IDiagnosticsPathsRegister>(mname);
55 0 : if (pr) {
56 0 : pr->reg("midiMappingUserAppDataPath", m_configuration->midiMappingUserAppDataPath());
57 : }
58 : #endif
59 0 : }
60 :
61 0 : void MidiRemoteModule::onInit(const IApplication::RunMode&)
62 : {
63 0 : m_configuration->init();
64 0 : }
65 :
66 0 : IContextSetup* MidiRemoteModule::newContext(const ContextPtr& ctx) const
67 : {
68 0 : return new MidiRemoteContext(ctx);
69 : }
70 :
71 0 : void MidiRemoteContext::registerExports()
72 : {
73 0 : m_midiRemote = std::make_shared<MidiRemote>(iocContext());
74 :
75 0 : ioc()->registerExport<IMidiRemote>(mname, m_midiRemote);
76 0 : }
77 :
78 0 : void MidiRemoteContext::onInit(const IApplication::RunMode&)
79 : {
80 0 : m_midiRemote->init();
81 0 : }
|