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/channel.h"
27 : #include "async/notification.h"
28 : #include "io/path.h"
29 : #include "progress.h"
30 : #include "types/retval.h"
31 :
32 : #include "types/converttypes.h"
33 :
34 : class QUrl;
35 :
36 : namespace mu::project {
37 : class IConvertFileToScoreService : MODULE_CONTEXT_INTERFACE
38 : {
39 0 : INTERFACE_ID(IConvertFileToScoreService)
40 :
41 : public:
42 127 : virtual ~IConvertFileToScoreService() = default;
43 :
44 : //! Server-provided limits (file size, formats, etc) for client-side validation
45 : virtual const ConvertConfig& config() const = 0;
46 :
47 : //! Whether the given file can be converted
48 : virtual bool isFileSupported(const muse::io::path_t& path) const = 0;
49 :
50 : //! Checks the given files against the server's config limits and determines their convert type and category
51 : virtual muse::RetVal<ConvertFilesValidation> validateFiles(const muse::io::paths_t& paths) const = 0;
52 :
53 : //! Checks that the given link is from a supported source
54 : virtual muse::Ret validateLink(const QUrl& link) const = 0;
55 :
56 : //! Starts uploading the input to the server, returning the upload's progress
57 : //! (or an error if the upload couldn't be started, e.g. the files couldn't be read).
58 : //! The conversion's final result is reported via convertFinished()
59 : virtual muse::RetVal<muse::Progress> uploadToConvert(const ConvertInput& input, const muse::String& convertedScoreName) = 0;
60 :
61 : //! Emits the final result of a processed conversion (failure, or success with the WatchedScore)
62 : virtual muse::async::Channel<muse::Ret, WatchedScore> convertFinished() const = 0;
63 :
64 : //! Uploads in progress (not saved, not polled)
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 : //! Returns a previously converted/watched score by its cloud score id
71 : virtual const WatchedScore* watchedScoreById(int scoreId) const = 0;
72 :
73 : //! Emitted after every conversion status check, whether it succeeded or failed
74 : virtual muse::async::Channel<PollingStatus> pollingStatusChanged() const = 0;
75 :
76 : //! Resumes polling for any still-pending items - e.g. in response to the user pressing "Retry"
77 : virtual void retryPolling() = 0;
78 :
79 : virtual void submitReview(int scoreId, ReviewRating rating, const QString& comment = QString()) = 0;
80 : virtual void submitReviewComment(int scoreId, const QString& comment) = 0;
81 :
82 : //! Aborts an upload in progress
83 : virtual void cancelUpload(int uploadId) = 0;
84 :
85 : //! Cancels a watched conversion, removing it both server-side and from watchedScores()
86 : virtual void cancelConversion(ConvertType type, int convertId) = 0;
87 : };
88 :
89 : using IConvertFileToScoreServicePtr = std::shared_ptr<IConvertFileToScoreService>;
90 : }
|