Changeset View
Changeset View
Standalone View
Standalone View
src/services/jamendo/JamendoService.cpp
Show All 16 Lines | |||||
17 | #include "JamendoService.h" | 17 | #include "JamendoService.h" | ||
18 | 18 | | |||
19 | #include "browsers/CollectionTreeItem.h" | 19 | #include "browsers/CollectionTreeItem.h" | ||
20 | #include "browsers/CollectionTreeView.h" | 20 | #include "browsers/CollectionTreeView.h" | ||
21 | #include "browsers/SingleCollectionTreeItemModel.h" | 21 | #include "browsers/SingleCollectionTreeItemModel.h" | ||
22 | #include "core-impl/collections/support/CollectionManager.h" | 22 | #include "core-impl/collections/support/CollectionManager.h" | ||
23 | #include "core/support/Debug.h" | 23 | #include "core/support/Debug.h" | ||
24 | #include "core/support/Components.h" | 24 | #include "core/support/Components.h" | ||
25 | #include "core/interfaces/Logger.h" | 25 | #include "core/logger/Logger.h" | ||
26 | #include "EngineController.h" | 26 | #include "EngineController.h" | ||
27 | #include "JamendoInfoParser.h" | 27 | #include "JamendoInfoParser.h" | ||
28 | #include "ServiceSqlRegistry.h" | 28 | #include "ServiceSqlRegistry.h" | ||
29 | #include "widgets/SearchWidget.h" | 29 | #include "widgets/SearchWidget.h" | ||
30 | 30 | | |||
31 | #include <QAction> | 31 | #include <QAction> | ||
32 | #include <QDesktopServices> | 32 | #include <QDesktopServices> | ||
33 | #include <QHBoxLayout> | 33 | #include <QHBoxLayout> | ||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | 184 | // tempFile.setSuffix( ".gz" ); | |||
185 | tempFile.setAutoRemove( false ); //file will be removed in JamendoXmlParser | 185 | tempFile.setAutoRemove( false ); //file will be removed in JamendoXmlParser | ||
186 | if( !tempFile.open() ) | 186 | if( !tempFile.open() ) | ||
187 | return; //error | 187 | return; //error | ||
188 | m_tempFileName = tempFile.fileName(); | 188 | m_tempFileName = tempFile.fileName(); | ||
189 | m_listDownloadJob = KIO::file_copy( | 189 | m_listDownloadJob = KIO::file_copy( | ||
190 | /* Deprecated */ QUrl("http://imgjam.com/data/dbdump_artistalbumtrack.xml.gz"), | 190 | /* Deprecated */ QUrl("http://imgjam.com/data/dbdump_artistalbumtrack.xml.gz"), | ||
191 | QUrl::fromLocalFile( m_tempFileName ), 0700 , KIO::HideProgressInfo | KIO::Overwrite ); | 191 | QUrl::fromLocalFile( m_tempFileName ), 0700 , KIO::HideProgressInfo | KIO::Overwrite ); | ||
192 | 192 | | |||
193 | Amarok::Components::logger()->newProgressOperation( m_listDownloadJob, i18n( "Downloading Jamendo.com database..." ), this, SLOT(listDownloadCancelled()) ); | 193 | Amarok::Logger::newProgressOperation( m_listDownloadJob, i18n( "Downloading Jamendo.com database..." ), this, SLOT(listDownloadCancelled()) ); | ||
194 | 194 | | |||
195 | connect( m_listDownloadJob, &KJob::result, | 195 | connect( m_listDownloadJob, &KJob::result, | ||
196 | this, &JamendoService::listDownloadComplete ); | 196 | this, &JamendoService::listDownloadComplete ); | ||
197 | } | 197 | } | ||
198 | 198 | | |||
199 | void | 199 | void | ||
200 | JamendoService::listDownloadComplete(KJob * downloadJob) | 200 | JamendoService::listDownloadComplete(KJob * downloadJob) | ||
201 | { | 201 | { | ||
202 | if( downloadJob != m_listDownloadJob ) | 202 | if( downloadJob != m_listDownloadJob ) | ||
203 | return ; //not the right job, so let's ignore it | 203 | return ; //not the right job, so let's ignore it | ||
204 | debug() << "JamendoService: xml file download complete"; | 204 | debug() << "JamendoService: xml file download complete"; | ||
205 | 205 | | |||
206 | m_listDownloadJob = 0; | 206 | m_listDownloadJob = 0; | ||
207 | //testing | 207 | //testing | ||
208 | if ( downloadJob->error() != 0 ) | 208 | if ( downloadJob->error() != 0 ) | ||
209 | { | 209 | { | ||
210 | //TODO: error handling here | 210 | //TODO: error handling here | ||
211 | m_updateListButton->setEnabled( true ); // otherwise button will remain inactive in case of error | 211 | m_updateListButton->setEnabled( true ); // otherwise button will remain inactive in case of error | ||
212 | return; | 212 | return; | ||
213 | } | 213 | } | ||
214 | 214 | | |||
215 | Amarok::Components::logger()->shortMessage( i18n( "Updating the local Jamendo database." ) ); | 215 | Amarok::Logger::shortMessage( i18n( "Updating the local Jamendo database." ) ); | ||
216 | debug() << "JamendoService: create xml parser"; | 216 | debug() << "JamendoService: create xml parser"; | ||
217 | 217 | | |||
218 | if( m_xmlParser == 0 ) | 218 | if( m_xmlParser == 0 ) | ||
219 | m_xmlParser = new JamendoXmlParser( m_tempFileName ); | 219 | m_xmlParser = new JamendoXmlParser( m_tempFileName ); | ||
220 | connect( m_xmlParser, &JamendoXmlParser::doneParsing, this, &JamendoService::doneParsing ); | 220 | connect( m_xmlParser, &JamendoXmlParser::doneParsing, this, &JamendoService::doneParsing ); | ||
221 | 221 | | |||
222 | ThreadWeaver::Queue::instance()->enqueue( QSharedPointer<ThreadWeaver::Job>(m_xmlParser) ); | 222 | ThreadWeaver::Queue::instance()->enqueue( QSharedPointer<ThreadWeaver::Job>(m_xmlParser) ); | ||
223 | downloadJob->deleteLater(); | 223 | downloadJob->deleteLater(); | ||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |