File indexing completed on 2024-05-19 04:55:59
0001 /** 0002 * \file servertrackimporter.h 0003 * Abstract base class for track imports from a server. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 23 Jun 2013 0008 * 0009 * Copyright (C) 2013-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QObject> 0030 #include "kid3api.h" 0031 0032 class QNetworkAccessManager; 0033 class ImportTrackDataVector; 0034 class TrackDataModel; 0035 class ServerImporterConfig; 0036 class HttpClient; 0037 0038 /** 0039 * Abstract base class for track imports from a server. 0040 */ 0041 class KID3_CORE_EXPORT ServerTrackImporter : public QObject { 0042 Q_OBJECT 0043 public: 0044 /** 0045 * Constructor. 0046 * 0047 * @param netMgr network access manager 0048 * @param trackDataModel track data to be filled with imported values, 0049 * is passed with filenames set 0050 */ 0051 ServerTrackImporter(QNetworkAccessManager* netMgr, 0052 TrackDataModel* trackDataModel); 0053 0054 /** 0055 * Destructor. 0056 */ 0057 ~ServerTrackImporter() override = default; 0058 0059 /** 0060 * Name of import source. 0061 * @return name. 0062 */ 0063 virtual const char* name() const = 0; 0064 0065 /** NULL-terminated array of server strings, 0 if not used */ 0066 virtual const char** serverList() const; 0067 0068 /** default server, 0 to disable */ 0069 virtual const char* defaultServer() const; 0070 0071 /** anchor to online help, 0 to disable */ 0072 virtual const char* helpAnchor() const; 0073 0074 /** configuration, 0 if not used */ 0075 virtual ServerImporterConfig* config() const; 0076 0077 /** 0078 * Set configuration. 0079 * 0080 * @param cfg import server configuration, 0 if not used 0081 */ 0082 virtual void setConfig(const ServerImporterConfig* cfg); 0083 0084 /** 0085 * Add the files in the file list. 0086 */ 0087 virtual void start() = 0; 0088 0089 /** 0090 * Reset the client state. 0091 */ 0092 virtual void stop() = 0; 0093 0094 signals: 0095 /** 0096 * Emitted when status of a file changed. 0097 * Parameter: index of file, status text 0098 */ 0099 void statusChanged(int, const QString&); 0100 0101 /** 0102 * Emitted when results for a file are received. 0103 * Parameter index of file, track data list 0104 */ 0105 void resultsReceived(int, ImportTrackDataVector&); 0106 0107 protected: 0108 /** 0109 * Access to HTTP client. 0110 * @return HTTP client. 0111 */ 0112 HttpClient* httpClient() { return m_httpClient; } 0113 0114 /** 0115 * @brief Access to track data model. 0116 * @return track data model. 0117 */ 0118 TrackDataModel* trackDataModel() { return m_trackDataModel; } 0119 0120 private: 0121 HttpClient* m_httpClient; 0122 TrackDataModel* m_trackDataModel; 0123 };