Changeset View
Changeset View
Standalone View
Standalone View
src/core-impl/podcasts/sql/SqlPodcastProvider.cpp
Show All 19 Lines | |||||
20 | #include "MainWindow.h" | 20 | #include "MainWindow.h" | ||
21 | #include "OpmlWriter.h" | 21 | #include "OpmlWriter.h" | ||
22 | #include "SvgHandler.h" | 22 | #include "SvgHandler.h" | ||
23 | #include "QStringx.h" | 23 | #include "QStringx.h" | ||
24 | #include "browsers/playlistbrowser/PodcastModel.h" | 24 | #include "browsers/playlistbrowser/PodcastModel.h" | ||
25 | // #include "context/popupdropper/libpud/PopupDropper.h" | 25 | // #include "context/popupdropper/libpud/PopupDropper.h" | ||
26 | // #include "context/popupdropper/libpud/PopupDropperItem.h" | 26 | // #include "context/popupdropper/libpud/PopupDropperItem.h" | ||
27 | #include <core/storage/SqlStorage.h> | 27 | #include <core/storage/SqlStorage.h> | ||
28 | #include "core/interfaces/Logger.h" | 28 | #include "core/logger/Logger.h" | ||
29 | #include "core/podcasts/PodcastImageFetcher.h" | 29 | #include "core/podcasts/PodcastImageFetcher.h" | ||
30 | #include "core/podcasts/PodcastReader.h" | 30 | #include "core/podcasts/PodcastReader.h" | ||
31 | #include "core/support/Amarok.h" | 31 | #include "core/support/Amarok.h" | ||
32 | #include "core/support/Components.h" | 32 | #include "core/support/Components.h" | ||
33 | #include "core/support/Debug.h" | 33 | #include "core/support/Debug.h" | ||
34 | #include "core-impl/storage/StorageManager.h" | 34 | #include "core-impl/storage/StorageManager.h" | ||
35 | #include "core-impl/podcasts/sql/PodcastSettingsDialog.h" | 35 | #include "core-impl/podcasts/sql/PodcastSettingsDialog.h" | ||
36 | #include "playlistmanager/sql/SqlPlaylistGroup.h" | 36 | #include "playlistmanager/sql/SqlPlaylistGroup.h" | ||
▲ Show 20 Lines • Show All 432 Lines • ▼ Show 20 Line(s) | 461 | { | |||
469 | QString command = "SELECT title FROM podcastchannels WHERE url='%1';"; | 469 | QString command = "SELECT title FROM podcastchannels WHERE url='%1';"; | ||
470 | command = command.arg( sqlStorage->escape( kurl.url() ) ); | 470 | command = command.arg( sqlStorage->escape( kurl.url() ) ); | ||
471 | 471 | | |||
472 | QStringList dbResult = sqlStorage->query( command ); | 472 | QStringList dbResult = sqlStorage->query( command ); | ||
473 | if( !dbResult.isEmpty() ) | 473 | if( !dbResult.isEmpty() ) | ||
474 | { | 474 | { | ||
475 | //Already subscribed to this Channel | 475 | //Already subscribed to this Channel | ||
476 | //notify the user. | 476 | //notify the user. | ||
477 | Amarok::Components::logger()->longMessage( | 477 | Amarok::Logger::longMessage( | ||
478 | i18n( "Already subscribed to %1.", dbResult.first() ), Amarok::Logger::Error ); | 478 | i18n( "Already subscribed to %1.", dbResult.first() ), Amarok::Logger::Error ); | ||
479 | } | 479 | } | ||
480 | else | 480 | else | ||
481 | { | 481 | { | ||
482 | subscribe( kurl ); | 482 | subscribe( kurl ); | ||
483 | } | 483 | } | ||
484 | } | 484 | } | ||
485 | 485 | | |||
▲ Show 20 Lines • Show All 559 Lines • ▼ Show 20 Line(s) | |||||
1045 | } | 1045 | } | ||
1046 | 1046 | | |||
1047 | void | 1047 | void | ||
1048 | SqlPodcastProvider::slotReadResult( Podcasts::PodcastReader *podcastReader ) | 1048 | SqlPodcastProvider::slotReadResult( Podcasts::PodcastReader *podcastReader ) | ||
1049 | { | 1049 | { | ||
1050 | if( podcastReader->error() != QXmlStreamReader::NoError ) | 1050 | if( podcastReader->error() != QXmlStreamReader::NoError ) | ||
1051 | { | 1051 | { | ||
1052 | debug() << podcastReader->errorString(); | 1052 | debug() << podcastReader->errorString(); | ||
1053 | Amarok::Components::logger()->longMessage( podcastReader->errorString(), | 1053 | Amarok::Logger::longMessage( podcastReader->errorString(), | ||
1054 | Amarok::Logger::Error ); | 1054 | Amarok::Logger::Error ); | ||
1055 | } | 1055 | } | ||
1056 | debug() << "Finished updating: " << podcastReader->url(); | 1056 | debug() << "Finished updating: " << podcastReader->url(); | ||
1057 | --m_updatingChannels; | 1057 | --m_updatingChannels; | ||
1058 | debug() << "Updating counter reached " << m_updatingChannels; | 1058 | debug() << "Updating counter reached " << m_updatingChannels; | ||
1059 | 1059 | | |||
1060 | Podcasts::SqlPodcastChannelPtr channel = | 1060 | Podcasts::SqlPodcastChannelPtr channel = | ||
1061 | Podcasts::SqlPodcastChannelPtr::dynamicCast( podcastReader->channel() ); | 1061 | Podcasts::SqlPodcastChannelPtr::dynamicCast( podcastReader->channel() ); | ||
Show All 30 Lines | |||||
1092 | } | 1092 | } | ||
1093 | } | 1093 | } | ||
1094 | 1094 | | |||
1095 | void | 1095 | void | ||
1096 | SqlPodcastProvider::slotStatusBarNewProgressOperation( KIO::TransferJob * job, | 1096 | SqlPodcastProvider::slotStatusBarNewProgressOperation( KIO::TransferJob * job, | ||
1097 | const QString &description, | 1097 | const QString &description, | ||
1098 | Podcasts::PodcastReader* reader ) | 1098 | Podcasts::PodcastReader* reader ) | ||
1099 | { | 1099 | { | ||
1100 | Amarok::Components::logger()->newProgressOperation( job, description, reader, &Podcasts::PodcastReader::slotAbort ); | 1100 | Amarok::Logger::newProgressOperation( job, description, reader, &Podcasts::PodcastReader::slotAbort ); | ||
1101 | } | 1101 | } | ||
1102 | 1102 | | |||
1103 | void | 1103 | void | ||
1104 | SqlPodcastProvider::downloadEpisode( Podcasts::SqlPodcastEpisodePtr sqlEpisode ) | 1104 | SqlPodcastProvider::downloadEpisode( Podcasts::SqlPodcastEpisodePtr sqlEpisode ) | ||
1105 | { | 1105 | { | ||
1106 | if( sqlEpisode.isNull() ) | 1106 | if( sqlEpisode.isNull() ) | ||
1107 | { | 1107 | { | ||
1108 | error() << "SqlPodcastProvider::downloadEpisode( Podcasts::SqlPodcastEpisodePtr sqlEpisode ) was called for a non-SqlPodcastEpisode"; | 1108 | error() << "SqlPodcastProvider::downloadEpisode( Podcasts::SqlPodcastEpisodePtr sqlEpisode ) was called for a non-SqlPodcastEpisode"; | ||
Show All 40 Lines | 1147 | { | |||
1149 | debug() << "temporary file exists, resume download from offset " << offset; | 1149 | debug() << "temporary file exists, resume download from offset " << offset; | ||
1150 | QMap<QString, QString> resumeData; | 1150 | QMap<QString, QString> resumeData; | ||
1151 | resumeData.insert( "resume", QString::number( offset ) ); | 1151 | resumeData.insert( "resume", QString::number( offset ) ); | ||
1152 | transferJob->addMetaData( resumeData ); | 1152 | transferJob->addMetaData( resumeData ); | ||
1153 | } | 1153 | } | ||
1154 | 1154 | | |||
1155 | if( !tmpFile->open( QIODevice::WriteOnly | QIODevice::Append ) ) | 1155 | if( !tmpFile->open( QIODevice::WriteOnly | QIODevice::Append ) ) | ||
1156 | { | 1156 | { | ||
1157 | Amarok::Components::logger()->longMessage( i18n( "Unable to save podcast episode file to %1", | 1157 | Amarok::Logger::longMessage( i18n( "Unable to save podcast episode file to %1", | ||
1158 | tmpFile->fileName() ) ); | 1158 | tmpFile->fileName() ) ); | ||
1159 | delete tmpFile; | 1159 | delete tmpFile; | ||
1160 | return; | 1160 | return; | ||
1161 | } | 1161 | } | ||
1162 | 1162 | | |||
1163 | debug() << "starting download for " << sqlEpisode->title() | 1163 | debug() << "starting download for " << sqlEpisode->title() | ||
1164 | << " url: " << sqlEpisode->prettyUrl(); | 1164 | << " url: " << sqlEpisode->prettyUrl(); | ||
1165 | Amarok::Components::logger()->newProgressOperation( transferJob | 1165 | Amarok::Logger::newProgressOperation( transferJob | ||
1166 | , sqlEpisode->title().isEmpty() | 1166 | , sqlEpisode->title().isEmpty() | ||
1167 | ? i18n( "Downloading Podcast Media" ) | 1167 | ? i18n( "Downloading Podcast Media" ) | ||
1168 | : i18n( "Downloading Podcast \"%1\"" | 1168 | : i18n( "Downloading Podcast \"%1\"" | ||
1169 | , sqlEpisode->title() ), | 1169 | , sqlEpisode->title() ), | ||
1170 | transferJob, | 1170 | transferJob, | ||
1171 | &KIO::TransferJob::kill, | 1171 | &KIO::TransferJob::kill, | ||
1172 | Qt::AutoConnection, | 1172 | Qt::AutoConnection, | ||
1173 | KJob::Quietly | 1173 | KJob::Quietly | ||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | |||||
1305 | SqlPodcastProvider::deleteDownloadedEpisode( Podcasts::PodcastEpisodePtr episode ) | 1305 | SqlPodcastProvider::deleteDownloadedEpisode( Podcasts::PodcastEpisodePtr episode ) | ||
1306 | { | 1306 | { | ||
1307 | deleteDownloadedEpisode( SqlPodcastEpisodePtr::dynamicCast( episode ) ); | 1307 | deleteDownloadedEpisode( SqlPodcastEpisodePtr::dynamicCast( episode ) ); | ||
1308 | } | 1308 | } | ||
1309 | 1309 | | |||
1310 | void | 1310 | void | ||
1311 | SqlPodcastProvider::slotStatusBarSorryMessage( const QString &message ) | 1311 | SqlPodcastProvider::slotStatusBarSorryMessage( const QString &message ) | ||
1312 | { | 1312 | { | ||
1313 | Amarok::Components::logger()->longMessage( message, Amarok::Logger::Error ); | 1313 | Amarok::Logger::longMessage( message, Amarok::Logger::Error ); | ||
1314 | } | 1314 | } | ||
1315 | 1315 | | |||
1316 | void | 1316 | void | ||
1317 | SqlPodcastProvider::downloadResult( KJob *job ) | 1317 | SqlPodcastProvider::downloadResult( KJob *job ) | ||
1318 | { | 1318 | { | ||
1319 | struct PodcastEpisodeDownload download = m_downloadJobMap.value( job ); | 1319 | struct PodcastEpisodeDownload download = m_downloadJobMap.value( job ); | ||
1320 | QFile *tmpFile = download.tmpFile; | 1320 | QFile *tmpFile = download.tmpFile; | ||
1321 | bool downloadFailed = false; | 1321 | bool downloadFailed = false; | ||
1322 | 1322 | | |||
1323 | if( job->error() ) | 1323 | if( job->error() ) | ||
1324 | { | 1324 | { | ||
1325 | // NOTE: prevents empty error notifications from popping up | 1325 | // NOTE: prevents empty error notifications from popping up | ||
1326 | // in the statusbar when the user cancels a download | 1326 | // in the statusbar when the user cancels a download | ||
1327 | if( job->error() != KJob::KilledJobError ) | 1327 | if( job->error() != KJob::KilledJobError ) | ||
1328 | { | 1328 | { | ||
1329 | Amarok::Components::logger()->longMessage( job->errorText() ); | 1329 | Amarok::Logger::longMessage( job->errorText() ); | ||
1330 | } | 1330 | } | ||
1331 | error() << "Unable to retrieve podcast media. KIO Error: " << job->errorText(); | 1331 | error() << "Unable to retrieve podcast media. KIO Error: " << job->errorText(); | ||
1332 | error() << "keeping temporary file for download restart"; | 1332 | error() << "keeping temporary file for download restart"; | ||
1333 | downloadFailed = false; | 1333 | downloadFailed = false; | ||
1334 | } | 1334 | } | ||
1335 | else | 1335 | else | ||
1336 | { | 1336 | { | ||
1337 | Podcasts::SqlPodcastEpisodePtr sqlEpisode = download.episode; | 1337 | Podcasts::SqlPodcastEpisodePtr sqlEpisode = download.episode; | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 1392 | { | |||
1397 | if( sqlChannel->writeTags() ) | 1397 | if( sqlChannel->writeTags() ) | ||
1398 | sqlEpisode->writeTagsToFile(); | 1398 | sqlEpisode->writeTagsToFile(); | ||
1399 | //TODO: force a redraw of the view so the icon can be updated in the PlaylistBrowser | 1399 | //TODO: force a redraw of the view so the icon can be updated in the PlaylistBrowser | ||
1400 | 1400 | | |||
1401 | emit episodeDownloaded( Podcasts::PodcastEpisodePtr::dynamicCast( sqlEpisode ) ); | 1401 | emit episodeDownloaded( Podcasts::PodcastEpisodePtr::dynamicCast( sqlEpisode ) ); | ||
1402 | } | 1402 | } | ||
1403 | else | 1403 | else | ||
1404 | { | 1404 | { | ||
1405 | Amarok::Components::logger()->longMessage( i18n( "Unable to save podcast episode file to %1", | 1405 | Amarok::Logger::longMessage( i18n( "Unable to save podcast episode file to %1", | ||
1406 | finalName ) ); | 1406 | finalName ) ); | ||
1407 | downloadFailed = true; | 1407 | downloadFailed = true; | ||
1408 | } | 1408 | } | ||
1409 | } | 1409 | } | ||
1410 | 1410 | | |||
1411 | //remove it from the jobmap | 1411 | //remove it from the jobmap | ||
1412 | m_completedDownloads++; | 1412 | m_completedDownloads++; | ||
1413 | cleanupDownload( job, downloadFailed ); | 1413 | cleanupDownload( job, downloadFailed ); | ||
▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines |