Changeset View
Changeset View
Standalone View
Standalone View
src/core-impl/playlists/types/file/PlaylistFileLoaderJob.cpp
Show All 11 Lines | |||||
12 | * * | 12 | * * | ||
13 | * You should have received a copy of the GNU General Public License along with * | 13 | * You should have received a copy of the GNU General Public License along with * | ||
14 | * this program. If not, see <http://www.gnu.org/licenses/>. * | 14 | * this program. If not, see <http://www.gnu.org/licenses/>. * | ||
15 | ****************************************************************************************/ | 15 | ****************************************************************************************/ | ||
16 | #include "core-impl/playlists/types/file/PlaylistFileLoaderJob.h" | 16 | #include "core-impl/playlists/types/file/PlaylistFileLoaderJob.h" | ||
17 | 17 | | |||
18 | #include "core/meta/Meta.h" | 18 | #include "core/meta/Meta.h" | ||
19 | #include "core/playlists/PlaylistFormat.h" | 19 | #include "core/playlists/PlaylistFormat.h" | ||
20 | #include "core/interfaces/Logger.h" | 20 | #include "core/logger/Logger.h" | ||
21 | #include "core/support/Amarok.h" | 21 | #include "core/support/Amarok.h" | ||
22 | #include "core/support/Components.h" | 22 | #include "core/support/Components.h" | ||
23 | #include "core/support/Debug.h" | 23 | #include "core/support/Debug.h" | ||
24 | #include "core/support/SemaphoreReleaser.h" | 24 | #include "core/support/SemaphoreReleaser.h" | ||
25 | 25 | | |||
26 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
27 | #include <KMessageBox> | 27 | #include <KMessageBox> | ||
28 | #include <KIO/Job> | 28 | #include <KIO/Job> | ||
Show All 20 Lines | 48 | { | |||
49 | m_actualPlaylistFile = url.toLocalFile(); | 49 | m_actualPlaylistFile = url.toLocalFile(); | ||
50 | m_downloadSemaphore.release(); // pretend file "already downloaded" | 50 | m_downloadSemaphore.release(); // pretend file "already downloaded" | ||
51 | } | 51 | } | ||
52 | else | 52 | else | ||
53 | { | 53 | { | ||
54 | // m_tempFile.setFileTemplate( QDir::tempPath() + "/XXXXXX." + Amarok::extension( url.url() ) ); | 54 | // m_tempFile.setFileTemplate( QDir::tempPath() + "/XXXXXX." + Amarok::extension( url.url() ) ); | ||
55 | if( !m_tempFile.open() ) | 55 | if( !m_tempFile.open() ) | ||
56 | { | 56 | { | ||
57 | Amarok::Components::logger()->longMessage( | 57 | Amarok::Logger::longMessage( | ||
58 | i18n( "Could not create a temporary file to download playlist." ) ); | 58 | i18n( "Could not create a temporary file to download playlist." ) ); | ||
59 | m_downloadSemaphore.release(); // prevent deadlock | 59 | m_downloadSemaphore.release(); // prevent deadlock | ||
60 | return; | 60 | return; | ||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | KIO::FileCopyJob *job = KIO::file_copy( url , QUrl::fromLocalFile(m_tempFile.fileName()), 0774, | 63 | KIO::FileCopyJob *job = KIO::file_copy( url , QUrl::fromLocalFile(m_tempFile.fileName()), 0774, | ||
64 | KIO::Overwrite | KIO::HideProgressInfo ); | 64 | KIO::Overwrite | KIO::HideProgressInfo ); | ||
65 | Amarok::Components::logger()->newProgressOperation( job, | 65 | Amarok::Logger::newProgressOperation( job, | ||
66 | i18n("Downloading remote playlist" ) ); | 66 | i18n("Downloading remote playlist" ) ); | ||
67 | if( playlist->isLoadingAsync() ) | 67 | if( playlist->isLoadingAsync() ) | ||
68 | // job is started automatically by KIO | 68 | // job is started automatically by KIO | ||
69 | connect( job, &KIO::FileCopyJob::finished, this, &PlaylistFileLoaderJob::slotDonwloadFinished ); | 69 | connect( job, &KIO::FileCopyJob::finished, this, &PlaylistFileLoaderJob::slotDonwloadFinished ); | ||
70 | else | 70 | else | ||
71 | { | 71 | { | ||
72 | job->exec(); | 72 | job->exec(); | ||
73 | slotDonwloadFinished( job ); | 73 | slotDonwloadFinished( job ); | ||
Show All 9 Lines | 80 | { | |||
83 | SemaphoreReleaser releaser( m_playlist->isLoadingAsync() ? 0 : &m_playlist->m_loadingDone ); | 83 | SemaphoreReleaser releaser( m_playlist->isLoadingAsync() ? 0 : &m_playlist->m_loadingDone ); | ||
84 | m_downloadSemaphore.acquire(); // wait for possible download to finish | 84 | m_downloadSemaphore.acquire(); // wait for possible download to finish | ||
85 | if( m_actualPlaylistFile.isEmpty() ) | 85 | if( m_actualPlaylistFile.isEmpty() ) | ||
86 | return; // previous error, already reported | 86 | return; // previous error, already reported | ||
87 | 87 | | |||
88 | QFile file( m_actualPlaylistFile ); | 88 | QFile file( m_actualPlaylistFile ); | ||
89 | if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) | 89 | if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) | ||
90 | { | 90 | { | ||
91 | using namespace Amarok; | 91 | Amarok::Logger::longMessage( i18nc( "%1 is file path", | ||
92 | Components::logger()->longMessage( i18nc( "%1 is file path", | 92 | "Cannot read playlist from %1", m_actualPlaylistFile ), Amarok::Logger::Error ); | ||
93 | "Cannot read playlist from %1", m_actualPlaylistFile ), Logger::Error ); | | |||
94 | return; | 93 | return; | ||
95 | } | 94 | } | ||
96 | 95 | | |||
97 | QByteArray content = file.readAll(); | 96 | QByteArray content = file.readAll(); | ||
98 | file.close(); | 97 | file.close(); | ||
99 | 98 | | |||
100 | m_playlist->load( content ); | 99 | m_playlist->load( content ); | ||
101 | } | 100 | } | ||
Show All 37 Lines |