1 //============================================================================= 2 // MuseScore 3 // Music Composition & Notation 4 // 5 // Copyright (C) 2020 MuseScore BVBA and others 6 // 7 // This program is free software; you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License version 2. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 //============================================================================= 19 20 #ifndef AVS_AVSOMRNETRECOGNIZER_H 21 #define AVS_AVSOMRNETRECOGNIZER_H 22 23 #include <QString> 24 #include <QByteArray> 25 #include <QVariantMap> 26 27 #include "iavsomrrecognizer.h" 28 29 class QNetworkAccessManager; 30 class QNetworkReply; 31 32 namespace Ms { 33 namespace Avs { 34 35 class AvsOmrNetRecognizer : public IAvsOmrRecognizer 36 { 37 public: 38 AvsOmrNetRecognizer(); 39 ~AvsOmrNetRecognizer() override; 40 41 QString type() const override; 42 bool isAvailable() const override; 43 bool recognize(const QString& filePath, QByteArray* avsFileData, const OnStep& onStep) override; 44 45 private: 46 47 Ret send(const QString& filePath, QString* getUrl); 48 Ret check(const QString& url, QString* fileUrl); 49 Ret load(const QString& url, QByteArray* ba); 50 51 struct NetRet 52 { 53 int httpStatus{0}; 54 int replyError{0}; 55 }; 56 57 Ret netRetToRet(const NetRet& nr) const; 58 59 NetRet doExecReply(QNetworkReply* reply, QByteArray* ba); 60 NetRet doCheck(const QString& url, QByteArray* ba); 61 62 QVariantMap parseInfo(const QByteArray& ba) const; 63 64 QNetworkAccessManager* _net{nullptr}; 65 }; 66 67 } // Avs 68 } // Ms 69 70 #endif // AVS_AVSOMRNETRECOGNIZER_H 71