File indexing completed on 2024-05-19 04:50:18
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 MAGNATUNEDOWNLOADHANDLER_H 0018 #define MAGNATUNEDOWNLOADHANDLER_H 0019 0020 #include <QObject> 0021 #include <kio/job.h> 0022 #include <kio/jobclasses.h> 0023 0024 #include "MagnatuneAlbumDownloader.h" 0025 #include "MagnatuneDownloadDialog.h" 0026 #include "MagnatuneMeta.h" 0027 0028 0029 /** 0030 The main class responsible for handling of downloads from Magnatune.com 0031 0032 @author Nikolaj Hald Nielsen 0033 */ 0034 class MagnatuneDownloadHandler : public QObject 0035 { 0036 Q_OBJECT 0037 public: 0038 MagnatuneDownloadHandler(); 0039 ~MagnatuneDownloadHandler() override; 0040 0041 void setParent( QWidget * parent ); 0042 /** 0043 * Starts a download operation 0044 * @param album The album to download 0045 */ 0046 void downloadAlbum( Meta::MagnatuneAlbum * album ); 0047 0048 Q_SIGNALS: 0049 0050 void downloadCompleted( bool success ); 0051 0052 private: 0053 KIO::TransferJob * m_resultDownloadJob; 0054 0055 //need a parent to pass to any dialogs we spawn 0056 QWidget * m_parent; 0057 MagnatuneDownloadDialog * m_downloadDialog; 0058 MagnatuneAlbumDownloader * m_albumDownloader; 0059 Meta::MagnatuneAlbum * m_currentAlbum; 0060 QString m_currentAlbumCoverName; 0061 bool m_membershipDownload; 0062 0063 bool parseDownloadXml( const QString &xml ); 0064 void membershipDownload( int membershipType, const QString &username, const QString &password ); 0065 0066 /** 0067 * This function saves the xml download info received from Magnatune.com after a 0068 * successful download. This information can be used to later redownload a lost album, 0069 * or acquire an album in a different file format. Note that no personal information 0070 * or credit card number is stored. The information is saved to the amarok config 0071 * directory in the sub folder magnatune.com/purchases. The name of each info file 0072 * is generated from the artist and album names. 0073 * @param infoXml The info to store. 0074 */ 0075 void saveDownloadInfo(const QString &infoXml); 0076 0077 0078 protected Q_SLOTS: 0079 0080 void xmlDownloadComplete( KJob* downLoadJob ); 0081 void albumDownloadComplete( bool success ); 0082 0083 }; 0084 0085 #endif