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

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 MAGNATUNE_REDOWNLOAD_HANDLER_H
0018 #define MAGNATUNE_REDOWNLOAD_HANDLER_H
0019 
0020 #include "MagnatuneAlbumDownloader.h"
0021 #include "MagnatuneDownloadDialog.h"
0022 #include "MagnatuneDownloadInfo.h"
0023 #include "MagnatuneRedownloadDialog.h"
0024 
0025 #include <QObject>
0026 
0027 /**
0028 This class handles the redownloading of previously downloaded albums
0029 
0030     @author Nikolaj Hald Nielsen <nhn@kde.org>
0031 */
0032 
0033 class MagnatuneRedownloadHandler : public QObject
0034 {
0035 Q_OBJECT
0036 public:
0037     explicit MagnatuneRedownloadHandler(QWidget * parent);
0038 
0039     ~MagnatuneRedownloadHandler() override;
0040 
0041     /**
0042      * Calls forth the redownload dialog.
0043      */
0044     void showRedownloadDialog();
0045 
0046 Q_SIGNALS:
0047 
0048     void reDownloadCompleted( bool success );
0049 
0050 protected:
0051 
0052     QStringList GetPurchaseList( );
0053 
0054    /**
0055     * Attempt to get a list of previous purchases for an email.
0056     * If set, use the email from the magnatune settings, otherwise, QueryMaker
0057     * the user (and then save it to settings)
0058     */
0059     void fetchServerSideRedownloadList();
0060 
0061     QWidget * m_parent;
0062     MagnatuneRedownloadDialog * m_redownloadDialog;
0063     MagnatuneDownloadDialog * m_downloadDialog;
0064     MagnatuneAlbumDownloader * m_albumDownloader;
0065 
0066     KIO::TransferJob * m_redownloadApiJob;
0067 
0068 protected Q_SLOTS:
0069 
0070     void redownload(const MagnatuneDownloadInfo &info );
0071     void selectionDialogCancelled();
0072     void albumDownloadComplete( bool success );
0073     void redownloadApiResult( KJob* job );
0074 };
0075 
0076 #endif