LCOV - code coverage report
Current view: top level - muse/framework/extensions/internal - extensionsregister.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 51 0
Test Date: 2026-11-05 04:07:02

            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) 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 "extensionsregister.h"
      24              : 
      25              : #include "extensionsloader.h"
      26              : #include "legacy/extpluginsloader.h"
      27              : 
      28              : #include "log.h"
      29              : 
      30              : using namespace muse;
      31              : using namespace muse::extensions;
      32              : using namespace muse::rcommand;
      33              : 
      34            0 : void ExtensionsRegister::reload()
      35              : {
      36              :     ExtensionsLoader loader;
      37            0 :     m_manifests = loader.loadManifestList(configuration()->defaultPath(),
      38            0 :                                           configuration()->userPath());
      39              : 
      40              :     legacy::ExtPluginsLoader pluginsLoader;
      41            0 :     ManifestList plugins = pluginsLoader.loadManifestList(configuration()->pluginsDefaultPath(),
      42            0 :                                                           configuration()->pluginsUserPath());
      43              : 
      44            0 :     muse::join(m_manifests, plugins);
      45              : 
      46            0 :     m_configs = configuration()->extensionConfigs();
      47              : 
      48            0 :     m_manifestListChanged.notify();
      49            0 : }
      50              : 
      51            0 : ManifestList ExtensionsRegister::manifestList(Filter filter) const
      52              : {
      53            0 :     if (filter == Filter::Enabled) {
      54            0 :         ManifestList list;
      55            0 :         for (const Manifest& m : m_manifests) {
      56            0 :             if (isEnabled(m.uri)) {
      57            0 :                 list.push_back(m);
      58              :             }
      59              :         }
      60            0 :         return list;
      61            0 :     }
      62              : 
      63            0 :     return m_manifests;
      64              : }
      65              : 
      66            0 : async::Notification ExtensionsRegister::manifestListChanged() const
      67              : {
      68            0 :     return m_manifestListChanged;
      69              : }
      70              : 
      71            0 : bool ExtensionsRegister::exists(const ExtensionUri& uri) const
      72              : {
      73            0 :     auto it = std::find_if(m_manifests.begin(), m_manifests.end(), [uri](const Manifest& m) {
      74            0 :         return m.uri == uri;
      75              :     });
      76              : 
      77            0 :     if (it != m_manifests.end()) {
      78            0 :         return true;
      79              :     }
      80              : 
      81            0 :     return false;
      82              : }
      83              : 
      84            0 : const Manifest& ExtensionsRegister::manifest(const ExtensionUri& uri) const
      85              : {
      86            0 :     auto it = std::find_if(m_manifests.begin(), m_manifests.end(), [uri](const Manifest& m) {
      87            0 :         return m.uri == uri;
      88              :     });
      89              : 
      90            0 :     if (it != m_manifests.end()) {
      91            0 :         return *it;
      92              :     }
      93              : 
      94            0 :     static Manifest _dummy;
      95            0 :     return _dummy;
      96              : }
      97              : 
      98            0 : KnownCategories ExtensionsRegister::knownCategories() const
      99              : {
     100              :     static KnownCategories categories {
     101            0 :         { "composing-arranging-tools", TranslatableString("extensions", "Composing/arranging tools") },
     102            0 :         { "color-notes", TranslatableString("extensions", "Color notes") },
     103            0 :         { "playback", TranslatableString("extensions", "Playback") },
     104            0 :         { "lyrics", TranslatableString("extensions", "Lyrics") }
     105            0 :     };
     106              : 
     107            0 :     return categories;
     108            0 : }
     109              : 
     110            0 : void ExtensionsRegister::setEnabled(const ExtensionUri& uri, bool enabled)
     111              : {
     112            0 :     if (m_configs[uri].enabled == enabled) {
     113            0 :         return;
     114              :     }
     115              : 
     116            0 :     m_configs[uri].enabled = enabled;
     117            0 :     configuration()->setExtensionConfigs(m_configs);
     118              : 
     119            0 :     m_enabledChanged.send(uri);
     120              : }
     121              : 
     122            0 : bool ExtensionsRegister::isEnabled(const ExtensionUri& uri) const
     123              : {
     124            0 :     return muse::value(m_configs, uri).enabled;
     125              : }
     126              : 
     127            0 : async::Channel<ExtensionUri> ExtensionsRegister::enabledChanged() const
     128              : {
     129            0 :     return m_enabledChanged;
     130              : }
        

Generated by: LCOV version 2.0-1