- Fix compilation with Qt 4.4

- Fix compilation with older boost libraries
This commit is contained in:
Christophe Dumez 2009-11-28 21:46:46 +00:00
parent 88b77a63ed
commit 9323660c79
9 changed files with 68 additions and 32 deletions

View file

@ -32,7 +32,6 @@
#define FEEDDOWNLOADER_H
#include <QString>
#include <QHash>
#include <QSettings>
#include <QListWidget>
#include <QListWidgetItem>
@ -47,6 +46,14 @@
#include "bittorrent.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> {
private:
bool valid;
@ -477,4 +484,7 @@ protected slots:
};
#undef QHash
#undef toHash
#endif // FEEDDOWNLOADER_H

View file

@ -35,7 +35,8 @@
#include <QRegExp>
#include <QMessageBox>
#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 {
Q_OBJECT
@ -57,8 +58,8 @@ public:
return spinPort->value();
}
static boost::asio::ip::tcp::endpoint askForPeerEndpoint() {
boost::asio::ip::tcp::endpoint ep;
static libtorrent::asio::ip::tcp::endpoint askForPeerEndpoint() {
libtorrent::asio::ip::tcp::endpoint ep;
PeerAdditionDlg dlg;
if(dlg.exec() == QDialog::Accepted) {
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();
if(is_ipv4.exactMatch(IP)) {
// 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 {
// 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;

View file

@ -40,6 +40,7 @@
#include <QSortFilterProxyModel>
#include <QSet>
#include <QSettings>
#include <QHeaderView>
#include <QMenu>
#include <vector>
@ -143,8 +144,8 @@ void PeerListWidget::showPeerListMenu(QPoint) {
if(empty_menu) return;
QAction *act = menu.exec(QCursor::pos());
if(act == addPeerAct) {
boost::asio::ip::tcp::endpoint ep = PeerAdditionDlg::askForPeerEndpoint();
if(ep != boost::asio::ip::tcp::endpoint()) {
libtorrent::asio::ip::tcp::endpoint ep = PeerAdditionDlg::askForPeerEndpoint();
if(ep != libtorrent::asio::ip::tcp::endpoint()) {
try {
h.connect_peer(ep);
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);
if(!ok) return;
foreach(const QString &ip, peer_ips) {
boost::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, boost::asio::ip::tcp::endpoint());
if(ep != boost::asio::ip::tcp::endpoint()) {
libtorrent::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, libtorrent::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());
try {
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);
if(!ok) return;
foreach(const QString &ip, peer_ips) {
boost::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, boost::asio::ip::tcp::endpoint());
if(ep != boost::asio::ip::tcp::endpoint()) {
libtorrent::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, libtorrent::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());
try {
h.set_peer_download_limit(ep, limit);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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