File indexing completed on 2024-05-19 04:50:17

0001 /****************************************************************************************
0002  * Copyright (c) 2006,2007 Nikolaj Hald Nielsen <nhn@kde.org>                           *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef MAGNATUNEALBUMDOWNLOADER_H
0018 #define MAGNATUNEALBUMDOWNLOADER_H
0019 
0020 #include "MagnatuneDownloadInfo.h"
0021 #include "MagnatuneMeta.h"
0022 
0023 #include <KIO/Job>
0024 #include <KIO/FileCopyJob>
0025 
0026 #include <QObject>
0027 #include <QTemporaryDir>
0028 
0029 /**
0030 This class encapsulates the downloading of an album once all required information has been retrieved
0031 
0032     @author Nikolaj Hald Nielsen <nhn@kde.org>
0033 */
0034 class MagnatuneAlbumDownloader : public QObject
0035 {
0036 Q_OBJECT
0037 public:
0038     MagnatuneAlbumDownloader();
0039 
0040     ~MagnatuneAlbumDownloader() override;
0041 
0042 Q_SIGNALS:
0043 
0044     /**
0045      * This signal is emitted when a download is finished or cancelled
0046      * @param success true is download completed, false if download was cancelled.
0047      */
0048     void downloadComplete( bool success );
0049 
0050 public Q_SLOTS:
0051     /**
0052      * Initiates the download of an album
0053      * @param info A MagnatuneDownloadInfo object containing all needed information
0054      */
0055     void downloadAlbum( MagnatuneDownloadInfo info );
0056 
0057 protected:
0058 
0059     KIO::FileCopyJob *m_albumDownloadJob;
0060     KIO::FileCopyJob *m_coverDownloadJob;
0061     QString m_currentAlbumUnpackLocation;
0062     QString m_currentAlbumFileName;
0063     MagnatuneDownloadInfo m_currentAlbumInfo;
0064     QTemporaryDir * m_tempDir;
0065 
0066 protected Q_SLOTS:
0067     /**
0068      * Unzip the downloaded album
0069      * @param downloadJob
0070      */
0071     void albumDownloadComplete( KJob* downloadJob );
0072     void albumDownloadAborted();
0073     void coverDownloadComplete( KJob* downloadJob );
0074     void coverAddAborted();
0075 
0076 };
0077 
0078 #endif