1 /**
2  * \file acoustidimportplugin.cpp
3  * AcoustID import plugin.
4  *
5  * \b Project: Kid3
6  * \author Urs Fleisch
7  * \date 21 Jul 2013
8  *
9  * Copyright (C) 2013-2018  Urs Fleisch
10  *
11  * This file is part of Kid3.
12  *
13  * Kid3 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * Kid3 is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 #include "acoustidimportplugin.h"
28 #include "musicbrainzclient.h"
29 
30 namespace {
31 
32 const QLatin1String IMPORTER_NAME("AcoustidImport");
33 
34 }
35 
36 /*!
37  * Constructor.
38  * @param parent parent object
39  */
AcoustidImportPlugin(QObject * parent)40 AcoustidImportPlugin::AcoustidImportPlugin(QObject* parent) : QObject(parent)
41 {
42   setObjectName(QLatin1String("AcoustidImport"));
43 }
44 
45 /**
46  * Get keys of available server importers.
47  * @return list of keys.
48  */
serverTrackImporterKeys() const49 QStringList AcoustidImportPlugin::serverTrackImporterKeys() const
50 {
51   return {IMPORTER_NAME};
52 }
53 
54 /**
55  * Create server importer.
56  * @param key server importer key
57  * @param netMgr network access manager
58  * @param trackDataModel track data to be filled with imported values
59  * @return server importer instance, 0 if key unknown.
60  * @remarks The caller takes ownership of the returned instance.
61  */
createServerTrackImporter(const QString & key,QNetworkAccessManager * netMgr,TrackDataModel * trackDataModel)62 ServerTrackImporter* AcoustidImportPlugin::createServerTrackImporter(
63     const QString& key,
64     QNetworkAccessManager* netMgr, TrackDataModel* trackDataModel)
65 {
66   if (key == IMPORTER_NAME) {
67     return new MusicBrainzClient(netMgr, trackDataModel);
68   }
69   return nullptr;
70 }
71