2010-10-15 21:55:56 +00:00
|
|
|
#ifndef QPEER_H
|
|
|
|
#define QPEER_H
|
|
|
|
|
|
|
|
#include <libtorrent/entry.hpp>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
struct QPeer {
|
|
|
|
|
|
|
|
bool operator!=(const QPeer &other) const {
|
|
|
|
return qhash() != other.qhash();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const QPeer &other) const {
|
|
|
|
return qhash() == other.qhash();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString qhash() const {
|
|
|
|
return ip+":"+QString::number(port);
|
|
|
|
}
|
|
|
|
|
2010-11-22 21:55:32 +00:00
|
|
|
libtorrent::entry toEntry(bool no_peer_id) const {
|
|
|
|
libtorrent::entry::dictionary_type peer_map;
|
2012-02-20 19:30:53 +02:00
|
|
|
if (!no_peer_id)
|
2010-11-22 21:55:32 +00:00
|
|
|
peer_map["id"] = libtorrent::entry(peer_id.toStdString());
|
|
|
|
peer_map["ip"] = libtorrent::entry(ip.toStdString());
|
|
|
|
peer_map["port"] = libtorrent::entry(port);
|
|
|
|
return libtorrent::entry(peer_map);
|
2010-10-15 21:55:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString ip;
|
|
|
|
QString peer_id;
|
|
|
|
int port;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QPEER_H
|