File indexing completed on 2024-05-19 04:56:30

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