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) 2021 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 : #include "networkmodule.h"
23 :
24 : #include "modularity/ioc.h"
25 : #include "internal/networkmanagercreator.h"
26 : #include "internal/networkconfiguration.h"
27 : #include "internal/networkinformation.h"
28 :
29 : #include "global/api/iapiregister.h"
30 :
31 : #include "muse_framework_config.h"
32 :
33 : #ifdef MUSE_MODULE_NETWORK_API
34 : #include "api/fetchapi.h"
35 :
36 : #ifdef MUSE_MODULE_NETWORK_WEBSOCKET
37 : #include "api/websocketapi.h"
38 : #include "api/websocketserverapi.h"
39 : #endif // MUSE_MODULE_NETWORK_WEBSOCKET
40 : #endif // MUSE_MODULE_NETWORK_API
41 :
42 : using namespace muse::network;
43 :
44 0 : std::string NetworkModule::moduleName() const
45 : {
46 0 : return "network";
47 : }
48 :
49 0 : void NetworkModule::registerExports()
50 : {
51 0 : m_configuration = std::make_shared<NetworkConfiguration>(muse::modularity::globalCtx());
52 :
53 0 : globalIoc()->registerExport<INetworkManagerCreator>(moduleName(), new NetworkManagerCreator());
54 0 : globalIoc()->registerExport<INetworkConfiguration>(moduleName(), m_configuration);
55 0 : globalIoc()->registerExport<INetworkInformation>(moduleName(), new NetworkInformation());
56 0 : }
57 :
58 0 : void NetworkModule::registerApi()
59 : {
60 : using namespace muse::api;
61 :
62 : #ifdef MUSE_MODULE_NETWORK_API
63 0 : auto api = globalIoc()->resolve<IApiRegister>(moduleName());
64 0 : if (api) {
65 : #ifdef MUSE_MODULE_NETWORK_WEBSOCKET
66 : api->regApi<api::WebSocketApi>(moduleName(), "MuseApi.Websocket");
67 : api->regApi<api::WebSocketServerApi>(moduleName(), "MuseApi.WebsocketServer");
68 : #endif // MUSE_MODULE_NETWORK_WEBSOCKET
69 0 : api->regApi<api::FetchApi>(moduleName(), "MuseApi.Http");
70 : }
71 : #endif // MUSE_MODULE_NETWORK_API
72 0 : }
73 :
74 0 : void NetworkModule::onInit(const IApplication::RunMode&)
75 : {
76 0 : m_configuration->init();
77 0 : }
|