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 : #pragma once
23 :
24 : #include "modularity/imoduleinterface.h"
25 :
26 : #include "async/promise.h"
27 : #include "async/channel.h"
28 : #include "io/path.h"
29 : #include "types/retval.h"
30 :
31 : #include "types/converttypes.h"
32 :
33 : class QUrl;
34 :
35 : namespace mu::project {
36 : class IConvertFileToScoreScenario : MODULE_CONTEXT_INTERFACE
37 : {
38 0 : INTERFACE_ID(IConvertFileToScoreScenario)
39 :
40 : public:
41 187 : virtual ~IConvertFileToScoreScenario() = default;
42 :
43 : //! Server-provided limits (file size, formats, etc) for client-side validation
44 : virtual const ConvertConfig& config() const = 0;
45 :
46 : //! Whether the given file can be converted
47 : virtual bool isFileSupported(const muse::io::path_t& path) const = 0;
48 :
49 : //! Checks the given files against the server's config limits and determines their convert type and category
50 : virtual muse::RetVal<ConvertFilesValidation> validateFiles(const muse::io::paths_t& paths) = 0;
51 :
52 : //! Checks that the given link is from a supported source
53 : virtual muse::Ret validateLink(const QUrl& link) = 0;
54 :
55 : //! Single entry point for converting files from the UI. With no paths, opens the file/link
56 : //! picker directly; with paths (e.g. from drag-and-drop), confirms with the user first, then
57 : //! opens the picker with them pre-selected
58 : virtual void convertFiles(const muse::io::paths_t& paths = {}) = 0;
59 :
60 : //! Emits the result once the server-side conversion completes; on success, the converted score
61 : //! is already available in the user's MuseScore.com account, described by the WatchedScore
62 : virtual muse::async::Channel<muse::Ret, WatchedScore> convertFinished() const = 0;
63 :
64 : //! Uploads in progress, before they reach the convert queue
65 : virtual muse::ValNt<UploadingScoreList> uploadingScores() const = 0;
66 :
67 : //! All pending/reviewable conversions from the server's convert queue
68 : virtual muse::ValNt<WatchedScoreList> watchedScores() const = 0;
69 :
70 : //! Whether the cloud score with the given id is a converted score still awaiting a quality review
71 : virtual bool isAwaitingReview(int scoreId) const = 0;
72 :
73 : //! Confirms with the user, then aborts an upload in progress
74 : virtual void cancelUpload(int uploadId) = 0;
75 :
76 : //! Confirms with the user, then cancels a watched conversion
77 : virtual void cancelConversion(ConvertType type, int convertId) = 0;
78 :
79 : //! Emitted after every conversion status check, whether it succeeded or failed
80 : virtual muse::async::Channel<PollingStatus> pollingStatusChanged() const = 0;
81 :
82 : //! Retries polling after it gave up (e.g. due to a lost internet connection)
83 : virtual void retryPolling() = 0;
84 : };
85 :
86 : using IConvertFileToScoreScenarioPtr = std::shared_ptr<IConvertFileToScoreScenario>;
87 : }
|