Browse Source

- Fix compilation with Qt 4.4

- Fix compilation with older boost libraries
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
9323660c79
  1. 12
      src/feeddownloader.h
  2. 11
      src/peeraddition.h
  3. 13
      src/peerlistwidget.cpp
  4. 2
      src/peerlistwidget.h
  5. 1
      src/propertieswidget.cpp
  6. 22
      src/reverseresolution.h
  7. 11
      src/rss.cpp
  8. 14
      src/rss.h
  9. 14
      src/torrentpersistentdata.h

12
src/feeddownloader.h

@ -32,7 +32,6 @@
#define FEEDDOWNLOADER_H #define FEEDDOWNLOADER_H
#include <QString> #include <QString>
#include <QHash>
#include <QSettings> #include <QSettings>
#include <QListWidget> #include <QListWidget>
#include <QListWidgetItem> #include <QListWidgetItem>
@ -47,6 +46,14 @@
#include "bittorrent.h" #include "bittorrent.h"
#include "ui_feeddownloader.h" #include "ui_feeddownloader.h"
#ifdef QT_4_5
#include <QHash>
#else
#include <QMap>
#define QHash QMap
#define toHash toMap
#endif
class FeedFilter: public QHash<QString, QVariant> { class FeedFilter: public QHash<QString, QVariant> {
private: private:
bool valid; bool valid;
@ -477,4 +484,7 @@ protected slots:
}; };
#undef QHash
#undef toHash
#endif // FEEDDOWNLOADER_H #endif // FEEDDOWNLOADER_H

11
src/peeraddition.h

@ -35,7 +35,8 @@
#include <QRegExp> #include <QRegExp>
#include <QMessageBox> #include <QMessageBox>
#include "ui_peer.h" #include "ui_peer.h"
#include <boost/asio/ip/tcp.hpp> #include <libtorrent/session.hpp>
#include <libtorrent/asio/ip/tcp.hpp>
class PeerAdditionDlg: public QDialog, private Ui::addPeerDialog { class PeerAdditionDlg: public QDialog, private Ui::addPeerDialog {
Q_OBJECT Q_OBJECT
@ -57,8 +58,8 @@ public:
return spinPort->value(); return spinPort->value();
} }
static boost::asio::ip::tcp::endpoint askForPeerEndpoint() { static libtorrent::asio::ip::tcp::endpoint askForPeerEndpoint() {
boost::asio::ip::tcp::endpoint ep; libtorrent::asio::ip::tcp::endpoint ep;
PeerAdditionDlg dlg; PeerAdditionDlg dlg;
if(dlg.exec() == QDialog::Accepted) { if(dlg.exec() == QDialog::Accepted) {
const QRegExp is_ipv6(QString::fromUtf8("[0-9a-f]{4}(:[0-9a-f]{4}){7}"), Qt::CaseInsensitive, QRegExp::RegExp); const QRegExp is_ipv6(QString::fromUtf8("[0-9a-f]{4}(:[0-9a-f]{4}){7}"), Qt::CaseInsensitive, QRegExp::RegExp);
@ -66,10 +67,10 @@ public:
QString IP = dlg.getIP(); QString IP = dlg.getIP();
if(is_ipv4.exactMatch(IP)) { if(is_ipv4.exactMatch(IP)) {
// IPv4 // IPv4
ep = boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v4::from_string(IP.toLocal8Bit().data()), dlg.getPort()); ep = libtorrent::asio::ip::tcp::endpoint(libtorrent::asio::ip::address_v4::from_string(IP.toLocal8Bit().data()), dlg.getPort());
} else { } else {
// IPv6 // IPv6
ep = boost::asio::ip::tcp::endpoint(boost::asio::ip::address_v6::from_string(IP.toLocal8Bit().data()), dlg.getPort()); ep = libtorrent::asio::ip::tcp::endpoint(libtorrent::asio::ip::address_v6::from_string(IP.toLocal8Bit().data()), dlg.getPort());
} }
} }
return ep; return ep;

13
src/peerlistwidget.cpp

@ -40,6 +40,7 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QSet> #include <QSet>
#include <QSettings> #include <QSettings>
#include <QHeaderView>
#include <QMenu> #include <QMenu>
#include <vector> #include <vector>
@ -143,8 +144,8 @@ void PeerListWidget::showPeerListMenu(QPoint) {
if(empty_menu) return; if(empty_menu) return;
QAction *act = menu.exec(QCursor::pos()); QAction *act = menu.exec(QCursor::pos());
if(act == addPeerAct) { if(act == addPeerAct) {
boost::asio::ip::tcp::endpoint ep = PeerAdditionDlg::askForPeerEndpoint(); libtorrent::asio::ip::tcp::endpoint ep = PeerAdditionDlg::askForPeerEndpoint();
if(ep != boost::asio::ip::tcp::endpoint()) { if(ep != libtorrent::asio::ip::tcp::endpoint()) {
try { try {
h.connect_peer(ep); h.connect_peer(ep);
QMessageBox::information(0, tr("Peer addition"), tr("The peer was added to this torrent.")); QMessageBox::information(0, tr("Peer addition"), tr("The peer was added to this torrent."));
@ -192,8 +193,8 @@ void PeerListWidget::limitUpRateSelectedPeers(QStringList peer_ips) {
long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Upload rate limiting"), -1); long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Upload rate limiting"), -1);
if(!ok) return; if(!ok) return;
foreach(const QString &ip, peer_ips) { foreach(const QString &ip, peer_ips) {
boost::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, boost::asio::ip::tcp::endpoint()); libtorrent::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, libtorrent::asio::ip::tcp::endpoint());
if(ep != boost::asio::ip::tcp::endpoint()) { if(ep != libtorrent::asio::ip::tcp::endpoint()) {
qDebug("Settings Upload limit of %.1f Kb/s to peer %s", limit/1024., ip.toLocal8Bit().data()); qDebug("Settings Upload limit of %.1f Kb/s to peer %s", limit/1024., ip.toLocal8Bit().data());
try { try {
h.set_peer_upload_limit(ep, limit); h.set_peer_upload_limit(ep, limit);
@ -213,8 +214,8 @@ void PeerListWidget::limitDlRateSelectedPeers(QStringList peer_ips) {
long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Download rate limiting"), -1); long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Download rate limiting"), -1);
if(!ok) return; if(!ok) return;
foreach(const QString &ip, peer_ips) { foreach(const QString &ip, peer_ips) {
boost::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, boost::asio::ip::tcp::endpoint()); libtorrent::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, libtorrent::asio::ip::tcp::endpoint());
if(ep != boost::asio::ip::tcp::endpoint()) { if(ep != libtorrent::asio::ip::tcp::endpoint()) {
qDebug("Settings Download limit of %.1f Kb/s to peer %s", limit/1024., ip.toLocal8Bit().data()); qDebug("Settings Download limit of %.1f Kb/s to peer %s", limit/1024., ip.toLocal8Bit().data());
try { try {
h.set_peer_download_limit(ep, limit); h.set_peer_download_limit(ep, limit);

2
src/peerlistwidget.h

@ -53,7 +53,7 @@ private:
PeerListDelegate *listDelegate; PeerListDelegate *listDelegate;
QSortFilterProxyModel * proxyModel; QSortFilterProxyModel * proxyModel;
QHash<QString, QStandardItem*> peerItems; QHash<QString, QStandardItem*> peerItems;
QHash<QString, boost::asio::ip::tcp::endpoint> peerEndpoints; QHash<QString, libtorrent::asio::ip::tcp::endpoint> peerEndpoints;
QSet<QString> missingFlags; QSet<QString> missingFlags;
QPointer<ReverseResolution> resolver; QPointer<ReverseResolution> resolver;
PropertiesWidget* properties; PropertiesWidget* properties;

1
src/propertieswidget.cpp

@ -33,6 +33,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QStackedWidget> #include <QStackedWidget>
#include <QSplitter> #include <QSplitter>
#include <QHeaderView>
#include <QAction> #include <QAction>
#include <QMessageBox> #include <QMessageBox>
#include <QMenu> #include <QMenu>

22
src/reverseresolution.h

@ -36,7 +36,7 @@
#include <QWaitCondition> #include <QWaitCondition>
#include <QMutex> #include <QMutex>
#include <QList> #include <QList>
#include <boost/asio/ip/tcp.hpp> #include <libtorrent/asio/ip/tcp.hpp>
#include "misc.h" #include "misc.h"
#define MAX_THREADS 20 #define MAX_THREADS 20
@ -45,12 +45,12 @@ class ReverseResolutionST: public QThread {
Q_OBJECT Q_OBJECT
private: private:
boost::asio::ip::tcp::endpoint ip; libtorrent::asio::ip::tcp::endpoint ip;
boost::asio::ip::tcp::resolver resolver; libtorrent::asio::ip::tcp::resolver resolver;
bool stopped; bool stopped;
public: public:
ReverseResolutionST(boost::asio::io_service &ios, QObject *parent=0): QThread(parent), resolver(ios), stopped(false) { ReverseResolutionST(libtorrent::asio::io_service &ios, QObject *parent=0): QThread(parent), resolver(ios), stopped(false) {
} }
@ -62,7 +62,7 @@ public:
} }
} }
void setIP(boost::asio::ip::tcp::endpoint &_ip) { void setIP(libtorrent::asio::ip::tcp::endpoint &_ip) {
ip = _ip; ip = _ip;
} }
@ -72,9 +72,9 @@ signals:
protected: protected:
void run() { void run() {
try { try {
boost::asio::ip::tcp::resolver::iterator it = resolver.resolve(ip); libtorrent::asio::ip::tcp::resolver::iterator it = resolver.resolve(ip);
if(stopped) return; if(stopped) return;
boost::asio::ip::tcp::endpoint endpoint = *it; libtorrent::asio::ip::tcp::endpoint endpoint = *it;
emit ip_resolved(misc::toQString(endpoint.address().to_string()), misc::toQString((*it).host_name())); emit ip_resolved(misc::toQString(endpoint.address().to_string()), misc::toQString((*it).host_name()));
} catch(std::exception &e) { } catch(std::exception &e) {
std::cerr << "Hostname resolution failed, reason: " << e.what() << std::endl; std::cerr << "Hostname resolution failed, reason: " << e.what() << std::endl;
@ -86,11 +86,11 @@ class ReverseResolution: public QThread {
Q_OBJECT Q_OBJECT
private: private:
QQueue<boost::asio::ip::tcp::endpoint> ips; QQueue<libtorrent::asio::ip::tcp::endpoint> ips;
QMutex mut; QMutex mut;
QWaitCondition cond; QWaitCondition cond;
bool stopped; bool stopped;
boost::asio::io_service ios; libtorrent::asio::io_service ios;
QList<ReverseResolutionST*> subThreads; QList<ReverseResolutionST*> subThreads;
@ -115,7 +115,7 @@ public:
cond.wakeOne(); cond.wakeOne();
} }
void resolve(boost::asio::ip::tcp::endpoint ip) { void resolve(libtorrent::asio::ip::tcp::endpoint ip) {
mut.lock(); mut.lock();
ips.enqueue(ip); ips.enqueue(ip);
if(subThreads.size() < MAX_THREADS) if(subThreads.size() < MAX_THREADS)
@ -147,7 +147,7 @@ protected:
mut.unlock(); mut.unlock();
break; break;
} }
boost::asio::ip::tcp::endpoint ip = ips.dequeue(); libtorrent::asio::ip::tcp::endpoint ip = ips.dequeue();
ReverseResolutionST *st = new ReverseResolutionST(ios); ReverseResolutionST *st = new ReverseResolutionST(ios);
subThreads.append(st); subThreads.append(st);
mut.unlock(); mut.unlock();

11
src/rss.cpp

@ -29,8 +29,14 @@
*/ */
#include "rss.h" #include "rss.h"
#include <QTimer>
#include <QUrl> #ifdef QT_4_5
#include <QHash>
#else
#include <QMap>
#define QHash QMap
#define toHash toMap
#endif
/** RssFolder **/ /** RssFolder **/
@ -673,3 +679,4 @@ void RssStream::processDownloadedFile(QString file_path) {
void RssStream::setDownloadFailed(){ void RssStream::setDownloadFailed(){
downloadFailure = true; downloadFailure = true;
} }

14
src/rss.h

@ -40,14 +40,23 @@
#include <QUrl> #include <QUrl>
#include <QTimer> #include <QTimer>
#include <QImage> #include <QImage>
#include <QHash>
#include <QDateTime> #include <QDateTime>
#include <QTimer>
#include <QUrl>
#include "misc.h" #include "misc.h"
#include "feeddownloader.h" #include "feeddownloader.h"
#include "bittorrent.h" #include "bittorrent.h"
#include "downloadthread.h" #include "downloadthread.h"
#ifdef QT_4_5
#include <QHash>
#else
#include <QMap>
#define QHash QMap
#define toHash toMap
#endif
class RssManager; class RssManager;
class RssFile; // Folder or Stream class RssFile; // Folder or Stream
class RssFolder; class RssFolder;
@ -511,7 +520,4 @@ public:
}; };
#endif #endif

14
src/torrentpersistentdata.h

@ -32,13 +32,19 @@
#define TORRENTPERSISTENTDATA_H #define TORRENTPERSISTENTDATA_H
#include <QSettings> #include <QSettings>
#include <QHash>
#include <QVariant> #include <QVariant>
#include <libtorrent/magnet_uri.hpp> #include <libtorrent/magnet_uri.hpp>
#include "qtorrenthandle.h" #include "qtorrenthandle.h"
#include "misc.h" #include "misc.h"
#ifdef QT_4_5
#include <QHash>
#else
#include <QMap>
#define QHash QMap
#define toHash toMap
#endif
class TorrentTempData { class TorrentTempData {
public: public:
static bool hasTempData(QString hash) { static bool hasTempData(QString hash) {
@ -256,4 +262,8 @@ public:
} }
}; };
#undef QHash
#undef toHash
#endif // TORRENTPERSISTENTDATA_H #endif // TORRENTPERSISTENTDATA_H

Loading…
Cancel
Save