File indexing completed on 2024-05-12 04:55:37

0001 /**
0002  * \file freedbimporter.h
0003  * freedb.org importer.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 18 Jan 2004
0008  *
0009  * Copyright (C) 2004-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 "serverimporter.h"
0030 
0031 /**
0032  * freedb.org importer.
0033  */
0034 class FreedbImporter : public ServerImporter {
0035 public:
0036   /**
0037    * Constructor.
0038    *
0039    * @param netMgr network access manager
0040    * @param trackDataModel track data to be filled with imported values
0041    */
0042   FreedbImporter(QNetworkAccessManager* netMgr,
0043                  TrackDataModel *trackDataModel);
0044 
0045   /**
0046    * Destructor.
0047    */
0048   ~FreedbImporter() override = default;
0049 
0050   /**
0051    * Name of import source.
0052    * @return name.
0053    */
0054   const char* name() const override;
0055 
0056   /** NULL-terminated array of server strings, 0 if not used */
0057   const char** serverList() const override;
0058 
0059   /** default server, 0 to disable */
0060   const char* defaultServer() const override;
0061 
0062   /** default CGI path, 0 to disable */
0063   const char* defaultCgiPath() const override;
0064 
0065   /** anchor to online help, 0 to disable */
0066   const char* helpAnchor() const override;
0067 
0068   /** configuration, 0 if not used */
0069   ServerImporterConfig* config() const override;
0070 
0071   /**
0072    * Process finished findCddbAlbum request.
0073    *
0074    * @param searchStr search data received
0075    */
0076   void parseFindResults(const QByteArray& searchStr) override;
0077 
0078   /**
0079    * Parse result of album request and populate m_trackDataModel with results.
0080    *
0081    * @param albumStr album data received
0082    */
0083   void parseAlbumResults(const QByteArray& albumStr) override;
0084 
0085   /**
0086    * Send a query command to search on the server.
0087    *
0088    * @param cfg      import source configuration
0089    * @param artist   artist to search
0090    * @param album    album to search
0091    */
0092   void sendFindQuery(
0093     const ServerImporterConfig* cfg,
0094     const QString& artist, const QString& album) override;
0095 
0096   /**
0097    * Send a query command to fetch the track list
0098    * from the server.
0099    *
0100    * @param cfg      import source configuration
0101    * @param cat      category
0102    * @param id       ID
0103    */
0104   void sendTrackListQuery(
0105     const ServerImporterConfig* cfg, const QString& cat, const QString& id) override;
0106 };