File indexing completed on 2024-05-19 04:48:28
0001 #include "service.h" 0002 #include <MauiKit3/FileBrowsing/downloader.h> 0003 0004 Service::Service(QObject *parent) 0005 : QObject(parent) 0006 { 0007 } 0008 0009 void Service::set(const PULPO::REQUEST &request) 0010 { 0011 this->request = request; 0012 } 0013 0014 void Service::parse(const QByteArray &array) 0015 { 0016 switch (this->request.ontology) { 0017 case PULPO::ONTOLOGY::ALBUM: 0018 this->parseAlbum(array); 0019 break; 0020 case PULPO::ONTOLOGY::ARTIST: 0021 this->parseArtist(array); 0022 break; 0023 case PULPO::ONTOLOGY::TRACK: 0024 this->parseTrack(array); 0025 break; 0026 } 0027 } 0028 0029 void Service::retrieve(const QString &url, const QMap<QString, QString> &headers) 0030 { 0031 if (!url.isEmpty()) { 0032 auto downloader = new FMH::Downloader; 0033 connect(downloader, &FMH::Downloader::dataReady, [this, downloader](QByteArray array) { 0034 emit this->arrayReady(array); 0035 downloader->deleteLater(); 0036 }); 0037 downloader->getArray(url, headers); 0038 } 0039 } 0040 0041 bool Service::scopePass() 0042 { 0043 auto info = this->request.info; 0044 for (const auto inf : info) { 0045 if (!this->scope[this->request.ontology].contains(inf)) { 0046 info.removeAll(inf); 0047 } 0048 } 0049 0050 return !info.isEmpty(); 0051 }