00001 // 00002 // C++ Interface: HttpImageDownloader 00003 // 00004 // Description: 00005 // 00006 // 00007 // Author: vishwajeet <vishwajeet.dusane@gmail.com>, (C) 2009 00008 // 00009 // Copyright: See COPYING file that comes with this distribution 00010 // 00011 // 00012 #ifndef HTTPIMAGEDOWNLOADER_H 00013 #define HTTPIMAGEDOWNLOADER_H 00014 00015 #include <QThread> 00016 #include <QHttp> 00017 #include <QBuffer> 00025 class CHttpImageDownloader : public QThread 00026 { 00027 Q_OBJECT 00028 public: 00035 CHttpImageDownloader(const QString &imageUrl,const QString &imageMainUrl,QObject *parent = 0); 00036 00037 virtual ~CHttpImageDownloader(); 00038 00039 00044 void setDownloadImageUrl(const QString &imageUrl); 00045 00046 public slots: 00047 00052 void downloadImage(const QString &imageUrl); 00053 00054 protected: 00055 virtual void run(); 00056 00057 private slots: 00058 void httpRequestFinished(int requestId, bool error); 00059 void readResponseHeader(const QHttpResponseHeader &responseHeader); 00060 void updateDataReadProgress(int bytesRead, int totalBytes); 00061 00062 signals: 00067 void downloading(int ); 00068 00074 void downloadComplete(QByteArray downloadedImageData,QString mainURL); 00075 00076 private: 00077 QHttp *http; 00078 QBuffer buffer; 00079 int httpGetId; 00080 QString m_ImageUrl; 00081 QString m_ImageMainUrl; 00082 }; 00083 00084 #endif