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 : #pragma once
23 :
24 : #include "musesounds/imusesoundscheckupdatescenario.h"
25 :
26 : #include "global/async/asyncable.h"
27 : #include "global/modularity/ioc.h"
28 :
29 : #include "musesounds/imusesoundscheckupdateservice.h"
30 : #include "musesounds/imusesoundsconfiguration.h"
31 :
32 : #include "interactive/iinteractive.h"
33 : #include "interactive/iplatforminteractive.h"
34 :
35 : namespace mu::musesounds {
36 : class MuseSoundsCheckUpdateScenario : public IMuseSoundsCheckUpdateScenario, public muse::Contextable, public muse::async::Asyncable
37 : {
38 : muse::GlobalInject<IMuseSoundsConfiguration> configuration;
39 : muse::GlobalInject<muse::IPlatformInteractive> platformInteractive;
40 : muse::GlobalInject<IMuseSoundsCheckUpdateService> service;
41 : muse::ContextInject<muse::IInteractive> interactive = { this };
42 :
43 : public:
44 0 : MuseSoundsCheckUpdateScenario(const muse::modularity::ContextPtr& iocCtx)
45 0 : : muse::Contextable(iocCtx) {}
46 :
47 : bool needCheckForUpdate() const override;
48 : void checkForUpdate(bool manual) override;
49 :
50 : bool checkInProgress() const override;
51 : muse::async::Notification checkInProgressChanged() const override;
52 :
53 : bool hasUpdate() const override;
54 : muse::Ret showUpdate() override;
55 :
56 : private:
57 : bool shouldIgnoreUpdate(const muse::update::ReleaseInfo& info) const;
58 : void setIgnoredUpdate(const std::string& version);
59 :
60 : muse::Ret showReleaseInfo(const muse::update::ReleaseInfo& info);
61 : void tryOpenMuseHub(muse::ValList actions) const;
62 :
63 : bool m_checkInProgress = false;
64 : muse::async::Notification m_checkInProgressChanged;
65 : };
66 : }
|