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

            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) 2025 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 "updatemodule.h"
      23              : 
      24              : #include <QtGlobal>
      25              : 
      26              : #include "modularity/ioc.h"
      27              : 
      28              : #include "interactive/iinteractiveuriregister.h"
      29              : #include "rcommand/icommandsregister.h"
      30              : #include "rcommand/icommandsstate.h"
      31              : 
      32              : #include "internal/updateconfiguration.h"
      33              : #include "internal/updateactioncontroller.h"
      34              : #include "internal/updatecommandsregister.h"
      35              : #include "internal/updatecommandsstate.h"
      36              : 
      37              : #include "internal/appupdatescenario.h"
      38              : #include "internal/appupdateservice.h"
      39              : 
      40              : #include "iupdateinstaller.h"
      41              : #if defined(Q_OS_MAC)
      42              : #include "internal/platform/mac/macupdateinstaller.h"
      43              : #elif defined(Q_OS_WIN)
      44              : #include "internal/platform/win/winupdateinstaller.h"
      45              : #elif defined(Q_OS_LINUX)
      46              : #include "internal/platform/linux/linuxupdateinstaller.h"
      47              : #else
      48              : #include "internal/platform/stub/updateinstallerstub.h"
      49              : #endif
      50              : 
      51              : #include "muse_framework_config.h"
      52              : #ifdef MUSE_MODULE_ACTIONS_SUPPORT
      53              : #include "ui/iuiactionsregister.h"
      54              : #include "internal/updateuiactions.h"
      55              : #endif
      56              : 
      57              : using namespace muse::update;
      58              : using namespace muse::modularity;
      59              : 
      60              : static const std::string mname("update");
      61              : 
      62            0 : std::string UpdateModule::moduleName() const
      63              : {
      64            0 :     return mname;
      65              : }
      66              : 
      67            0 : void UpdateModule::registerExports()
      68              : {
      69            0 :     m_configuration = std::make_shared<UpdateConfiguration>(globalCtx());
      70              : 
      71              : #if defined(Q_OS_MAC)
      72              :     m_updateInstaller = std::make_shared<MacUpdateInstaller>(globalCtx());
      73              : #elif defined(Q_OS_WIN)
      74              :     m_updateInstaller = std::make_shared<WinUpdateInstaller>(globalCtx());
      75              : #elif defined(Q_OS_LINUX)
      76            0 :     m_updateInstaller = std::make_shared<LinuxUpdateInstaller>(globalCtx());
      77              : #else
      78              :     m_updateInstaller = std::make_shared<UpdateInstallerStub>();
      79              : #endif
      80              : 
      81            0 :     globalIoc()->registerExport<IUpdateConfiguration>(mname, m_configuration);
      82            0 :     globalIoc()->registerExport<IUpdateInstaller>(mname, m_updateInstaller);
      83            0 : }
      84              : 
      85            0 : void UpdateModule::resolveImports()
      86              : {
      87            0 :     auto ir = globalIoc()->resolve<interactive::IInteractiveUriRegister>(mname);
      88            0 :     if (ir) {
      89            0 :         ir->registerQmlUri(Uri("muse://update/appreleaseinfo"), "Muse.Update", "AppReleaseInfoDialog");
      90            0 :         ir->registerQmlUri(Uri("muse://update/app"), "Muse.Update", "AppUpdateProgressDialog");
      91              :     }
      92              : 
      93            0 :     auto cr = globalIoc()->resolve<muse::rcommand::ICommandsRegister>(mname);
      94            0 :     if (cr) {
      95            0 :         cr->reg(std::make_shared<UpdateCommandsRegister>());
      96              :     }
      97            0 : }
      98              : 
      99            0 : void UpdateModule::onInit(const IApplication::RunMode&)
     100              : {
     101            0 :     m_configuration->init();
     102              : 
     103              : #if defined(Q_OS_WIN)
     104              :     std::static_pointer_cast<WinUpdateInstaller>(m_updateInstaller)->importHelperLog();
     105              : #endif
     106            0 : }
     107              : 
     108            0 : IContextSetup* UpdateModule::newContext(const muse::modularity::ContextPtr& ctx) const
     109              : {
     110            0 :     return new UpdateContext(ctx);
     111              : }
     112              : 
     113              : // Context
     114              : 
     115            0 : void UpdateContext::registerExports()
     116              : {
     117            0 :     m_appUpdateScenario = std::make_shared<AppUpdateScenario>(iocContext());
     118            0 :     m_appUpdateService = std::make_shared<AppUpdateService>(iocContext());
     119            0 :     m_actionController = std::make_shared<UpdateActionController>(iocContext());
     120              : 
     121            0 :     ioc()->registerExport<IAppUpdateScenario>(mname, m_appUpdateScenario);
     122            0 :     ioc()->registerExport<IAppUpdateService>(mname, m_appUpdateService);
     123            0 : }
     124              : 
     125            0 : void UpdateContext::resolveImports()
     126              : {
     127              : #ifdef MUSE_MODULE_ACTIONS_SUPPORT
     128            0 :     auto ar = ioc()->resolve<ui::IUiActionsRegister>(mname);
     129            0 :     if (ar) {
     130            0 :         ar->reg(std::make_shared<UpdateUiActions>(m_actionController, iocContext()));
     131              :     }
     132              : #endif
     133              : 
     134            0 :     auto cs = ioc()->resolve<muse::rcommand::ICommandsState>(mname);
     135            0 :     if (cs) {
     136            0 :         cs->reg(std::make_shared<UpdateCommandsState>(iocContext()));
     137              :     }
     138            0 : }
     139              : 
     140            0 : void UpdateContext::onInit(const IApplication::RunMode&)
     141              : {
     142            0 :     m_appUpdateService->init();
     143            0 :     m_actionController->init();
     144            0 : }
     145              : 
     146            0 : void UpdateContext::onDelayedInit()
     147              : {
     148            0 :     m_appUpdateScenario->delayedInit();
     149            0 : }
        

Generated by: LCOV version 2.0-1