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

0001 /****************************************************************************************
0002  * Copyright (c) 2008 Casey Link <unnamedrambler@gmail.com>                             *
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 AVATAR_DOWNLOADER_H
0018 #define AVATAR_DOWNLOADER_H
0019 
0020 #include "network/NetworkAccessManagerProxy.h"
0021 
0022 #include <QHash>
0023 #include <QObject>
0024 #include <QPixmap>
0025 
0026 class AvatarDownloader : public QObject
0027 {
0028     Q_OBJECT
0029 
0030     public:
0031 
0032         /**
0033         * Constructor.
0034         */
0035         AvatarDownloader();
0036 
0037         /**
0038         * Destructor.
0039         */
0040         ~AvatarDownloader() override;
0041 
0042         /**
0043         * Start the download
0044         * @param username The username for which avatar should be downloaded.
0045         * @param url The url that should be downloaded.
0046         */
0047         void downloadAvatar( const QString& username, const QUrl &url );
0048 
0049     Q_SIGNALS:
0050         void avatarDownloaded( const QString &username, QPixmap avatar );
0051 
0052     private Q_SLOTS:
0053         /**
0054          * Slot called when the network access manager finished a request
0055          */
0056         void downloaded( const QUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e );
0057 
0058     private:
0059         QHash<QUrl, QString> m_userAvatarUrls;
0060 };
0061 
0062 #endif