Browse Source

- A lot of fixes/improvements in bittorrent class (now compiling)

- Half way, now I need to rewrite the GUI class to use the bittorrent class
adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
dc89c5d381
  1. 75
      src/GUI.cpp
  2. 3
      src/GUI.h
  3. 171
      src/bittorrent.cpp
  4. 32
      src/bittorrent.h
  5. 4
      src/options_imp.h
  6. 6
      src/src.pro

75
src/GUI.cpp

@ -895,6 +895,18 @@ void GUI::closeEvent(QCloseEvent *e){
return; return;
} }
} }
//TODO: Clean finished torrents on exit
// if(options->getClearFinishedOnExit()){
// torrentBackup.remove(fileHash+".torrent");
// torrentBackup.remove(fileHash+".fastresume");
// torrentBackup.remove(fileHash+".paused");
// torrentBackup.remove(fileHash+".incremental");
// torrentBackup.remove(fileHash+".pieces");
// torrentBackup.remove(fileHash+".savepath");
// if(isScanningDir){
// QFile::remove(scan_dir+fileHash+".torrent");
// }
// }
// save the searchHistory for later uses // save the searchHistory for later uses
saveSearchHistory(); saveSearchHistory();
// Save DHT entry // Save DHT entry
@ -1685,40 +1697,6 @@ void GUI::configureSession(){
qDebug("Session configured"); qDebug("Session configured");
} }
// Pause All Downloads in DL list
void GUI::pauseAll(){
QString fileHash;
bool changes=false;
// Browse Handles to pause all downloads
foreach(torrent_handle h, handles){
if(!h.is_paused()){
fileHash = QString(misc::toString(h.info_hash()).c_str());
changes=true;
h.pause();
// Create .paused file
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
paused_file.close();
// update DL Status
int row = getRowFromHash(fileHash);
if(row == -1){
std::cerr << "Error: Filename could not be found in download list...\n";
continue;
}
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
setRowColor(row, "red");
}
}
//Set Info Bar
if(changes){
setInfoBar(tr("All Downloads Paused."));
}
}
// pause selected items in the list // pause selected items in the list
void GUI::pauseSelection(){ void GUI::pauseSelection(){
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
@ -1749,35 +1727,6 @@ void GUI::pauseSelection(){
} }
} }
// Start All Downloads in DL list
void GUI::startAll(){
QString fileHash;
bool changes=false;
// Browse Handles to pause all downloads
foreach(torrent_handle h, handles){
if(h.is_paused()){
fileHash = QString(misc::toString(h.info_hash()).c_str());
changes=true;
h.resume();
// Delete .paused file
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
// update DL Status
int row = getRowFromHash(fileHash);
if(row == -1){
std::cerr << "Error: Filename could not be found in download list...\n";
continue;
}
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
setRowColor(row, "grey");
}
}
//Set Info Bar
if(changes){
setInfoBar(tr("All Downloads Resumed."));
}
}
// start selected items in the list // start selected items in the list
void GUI::startSelection(){ void GUI::startSelection(){
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();

3
src/GUI.h

@ -44,6 +44,7 @@
#include "previewSelect.h" #include "previewSelect.h"
#include "trackerLogin.h" #include "trackerLogin.h"
#include "deleteThread.h" #include "deleteThread.h"
#include "bittorrent.h"
#define TIME_TRAY_BALLOON 5000 #define TIME_TRAY_BALLOON 5000
@ -147,8 +148,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void showProperties(const QModelIndex &index); void showProperties(const QModelIndex &index);
void propertiesSelection(); void propertiesSelection();
void addTorrent(const QString& path, bool fromScanDir = false, const QString& from_url = QString()); void addTorrent(const QString& path, bool fromScanDir = false, const QString& from_url = QString());
void pauseAll();
void startAll();
void pauseSelection(); void pauseSelection();
void startSelection(); void startSelection();
void askForTorrents(); void askForTorrents();

171
src/bittorrent.cpp

@ -19,53 +19,64 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#include "bittorrent.h" #include "bittorrent.h"
#include "misc.h"
#include <QDir> #include <QDir>
#include <QTime>
// Main constructor // Main constructor
bittorrent::bittorrent(){ bittorrent::bittorrent(){
supported_preview_extensions << "AVI" << "DIVX" << "MPG" << "MPEG" << "MP3" << "OGG" << "WMV" << "WMA" << "RMV" << "RMVB" << "ASF" << "MOV" << "WAV" << "MP2" << "SWF" << "AC3";
// Creating bittorrent session // Creating bittorrent session
s = new session(fingerprint("qB", VERSION_MAJOR, VERSION_MINOR, VERSION_BUGFIX, 0)); s = new session(fingerprint("qB", VERSION_MAJOR, VERSION_MINOR, VERSION_BUGFIX, 0));
// Set severity level of libtorrent session // Set severity level of libtorrent session
s->set_severity_level(alert::info); s->set_severity_level(alert::info);
// DHT (Trackerless), disabled until told otherwise // DHT (Trackerless), disabled until told otherwise
DHTEnabled = false; DHTEnabled = false;
// directory scanning, disabled until told otherwise
scanningEnabled = false;
// Enabling metadata plugin // Enabling metadata plugin
s->add_extension(&create_metadata_plugin); s->add_extension(&create_metadata_plugin);
timerAlerts = new QTimer(this);
connect(timerAlerts, SIGNAL(timeout()), this, SLOT(readAlerts()));
timerAlerts->start(3000);
} }
// Main destructor // Main destructor
bittorrent::~bittorrent(){ bittorrent::~bittorrent(){
disableDirectoryScanning(); disableDirectoryScanning();
delete timerAlerts;
delete s; delete s;
} }
// Return the torrent handle, given its hash // Return the torrent handle, given its hash
torrent_handle& bittorrent::getTorrentHandle(const QString& hash) const{ torrent_handle bittorrent::getTorrentHandle(const QString& hash) const{
return s->find_torrent(sha_hash(hash.toUtf8())); return s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
} }
// Delete a torrent from the session, given its hash // Delete a torrent from the session, given its hash
// permanent = true means that the torrent will be removed from the hard-drive too // permanent = true means that the torrent will be removed from the hard-drive too
void bittorrent::deleteTorrent(const QString& hash, bool permanent){ void bittorrent::deleteTorrent(const QString& hash, bool permanent){
torrent_handle& h = s->find_torrent(sha_hash(hash.toUtf8())); torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(!h.is_valid()){
return;
}
QString savePath = QString::fromUtf8(h.save_path().string().c_str());
QString fileName = QString(h.name().c_str());
// Remove it from session // Remove it from session
s->remove_torrent(h); s->remove_torrent(h);
// Remove it from torrent backup directory // Remove it from torrent backup directory
torrentBackup.remove(fileHash+".torrent"); QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
torrentBackup.remove(fileHash+".fastresume"); torrentBackup.remove(hash+".torrent");
torrentBackup.remove(fileHash+".paused"); torrentBackup.remove(hash+".fastresume");
torrentBackup.remove(fileHash+".incremental"); torrentBackup.remove(hash+".paused");
torrentBackup.remove(fileHash+".pieces"); torrentBackup.remove(hash+".incremental");
torrentBackup.remove(fileHash+".savepath"); torrentBackup.remove(hash+".pieces");
torrentBackup.remove(hash+".savepath");
if(permanent){ if(permanent){
// Remove from Hard drive // Remove from Hard drive
qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName)); qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName));
// Deleting in a thread to avoid GUI freeze // Deleting in a thread to avoid GUI freeze
deleteThread *deleter = new deleteThread(savePath+QDir::separator()+fileName); deleteThread *deleter = new deleteThread(savePath+QDir::separator()+fileName);
connect(deleter, SIGNAL(deletionFinished(deleteThread*)), this, SLOT(cleanDeleter(deleteThread*))) connect(deleter, SIGNAL(deletionFinished(deleteThread*)), this, SLOT(cleanDeleter(deleteThread*)));
} }
} }
@ -77,7 +88,7 @@ void bittorrent::cleanDeleter(deleteThread* deleter){
// Pause a running torrent // Pause a running torrent
void bittorrent::pauseTorrent(const QString& hash){ void bittorrent::pauseTorrent(const QString& hash){
torrent_handle& h = s->find_torrent(sha_hash(hash.toUtf8())); torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(h.is_valid() && !h.is_paused()){ if(h.is_valid() && !h.is_paused()){
h.pause(); h.pause();
} }
@ -85,14 +96,14 @@ void bittorrent::pauseTorrent(const QString& hash){
// Resume a torrent in paused state // Resume a torrent in paused state
void bittorrent::resumeTorrent(const QString& hash){ void bittorrent::resumeTorrent(const QString& hash){
torrent_handle& h = s->find_torrent(sha_hash(hash.toUtf8())); torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(h.is_valid() && h.is_paused()){ if(h.is_valid() && h.is_paused()){
h.resume(); h.resume();
} }
} }
// Add a torrent to the bittorrent session // Add a torrent to the bittorrent session
void bittorrent::addTorrent(const QString& path, bool fromScanDir = false, const QString& from_url = QString()){ void bittorrent::addTorrent(const QString& path, bool fromScanDir, const QString& from_url){
torrent_handle h; torrent_handle h;
entry resume_data; entry resume_data;
bool fastResume=false; bool fastResume=false;
@ -103,8 +114,8 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir = false, const
// create it if it is not // create it if it is not
if(! torrentBackup.exists()){ if(! torrentBackup.exists()){
if(! torrentBackup.mkpath(torrentBackup.path())){ if(! torrentBackup.mkpath(torrentBackup.path())){
std::cerr << "Couldn't create the directory: '" << torrentBackup.path().toUtf8() << "'\n"; std::cerr << "Couldn't create the directory: '" << (const char*)(torrentBackup.path().toUtf8()) << "'\n";
exit 1; exit(1);
} }
} }
// Processing torrents // Processing torrents
@ -158,7 +169,6 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir = false, const
catch (fs::filesystem_error&) {} catch (fs::filesystem_error&) {}
} }
QString savePath = getSavePath(hash); QString savePath = getSavePath(hash);
int row = DLListModel->rowCount();
// Adding files to bittorrent session // Adding files to bittorrent session
if(hasFilteredFiles(hash)){ if(hasFilteredFiles(hash)){
h = s->add_torrent(t, fs::path((const char*)savePath.toUtf8()), resume_data, false); h = s->add_torrent(t, fs::path((const char*)savePath.toUtf8()), resume_data, false);
@ -188,12 +198,6 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir = false, const
QFile::copy(file, newFile); QFile::copy(file, newFile);
} }
//qDebug("Copied to torrent backup directory"); //qDebug("Copied to torrent backup directory");
if(fromScanDir){
scan_dir = options->getScanDir();
if(scan_dir.at(scan_dir.length()-1) != QDir::separator()){
scan_dir += QDir::separator();
}
}
// Pause torrent if it was paused last time // Pause torrent if it was paused last time
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){
h.pause(); h.pause();
@ -251,7 +255,7 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir = false, const
// Check in .pieces file if the user filtered files // Check in .pieces file if the user filtered files
// in this torrent. // in this torrent.
bool bittorrent::hasFilteredFiles(const QString& fileHash){ bool bittorrent::hasFilteredFiles(const QString& fileHash) const{
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".pieces"); QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".pieces");
// Read saved file // Read saved file
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
@ -280,8 +284,17 @@ bool bittorrent::isDHTEnabled() const{
// Enable DHT // Enable DHT
void bittorrent::enableDHT(){ void bittorrent::enableDHT(){
if(!DHTEnabled){ if(!DHTEnabled){
boost::filesystem::ifstream dht_state_file((const char*)(misc::qBittorrentPath()+QString("dht_state")).toUtf8(), std::ios_base::binary);
dht_state_file.unsetf(std::ios_base::skipws);
entry dht_state;
try{
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
}catch (std::exception&) {}
s->start_dht(dht_state);
s->add_dht_router(std::make_pair(std::string("router.bittorrent.com"), 6881));
s->add_dht_router(std::make_pair(std::string("router.utorrent.com"), 6881));
s->add_dht_router(std::make_pair(std::string("router.bitcomet.com"), 6881));
DHTEnabled = true; DHTEnabled = true;
s->start_dht();
qDebug("DHT enabled"); qDebug("DHT enabled");
} }
} }
@ -339,7 +352,7 @@ void bittorrent::saveFastResumeData(){
} }
// Write fast resume data // Write fast resume data
std::vector<torrent_handle> handles = s->get_torrents(); std::vector<torrent_handle> handles = s->get_torrents();
for(int i=0; i<handles.size(); ++i){ for(unsigned int i=0; i<handles.size(); ++i){
torrent_handle &h = handles[i]; torrent_handle &h = handles[i];
// Pause download (needed before fast resume writing) // Pause download (needed before fast resume writing)
h.pause(); h.pause();
@ -365,9 +378,9 @@ void bittorrent::saveFastResumeData(){
bool bittorrent::isFilePreviewPossible(const QString& hash) const{ bool bittorrent::isFilePreviewPossible(const QString& hash) const{
// See if there are supported files in the torrent // See if there are supported files in the torrent
torrent_handle &h = s->find_torrent(sha_hash(hash.toUtf8())); torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(!h.is_valid()){ if(!h.is_valid()){
return; return false;
} }
torrent_info torrentInfo = h.get_torrent_info(); torrent_info torrentInfo = h.get_torrent_info();
for(int i=0; i<torrentInfo.num_files(); ++i){ for(int i=0; i<torrentInfo.num_files(); ++i){
@ -395,14 +408,8 @@ void bittorrent::scanDirectory(){
} }
} }
foreach(file, to_add){ foreach(file, to_add){
if(options->useAdditionDialog()){ // TODO: Support torrent addition dialog
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
connect(dialog, SIGNAL(torrentAddition(const QString&, bool, const QString&)), this, SLOT(addTorrent(const QString&, bool, const QString&)));
connect(dialog, SIGNAL(setInfoBarGUI(const QString&, const QString&)), this, SLOT(setInfoBar(const QString&, const QString&)));
dialog->showLoad(file, true);
}else{
addTorrent(file, true); addTorrent(file, true);
}
} }
} }
} }
@ -410,9 +417,10 @@ void bittorrent::scanDirectory(){
// Enable directory scanning // Enable directory scanning
void bittorrent::enableDirectoryScanning(const QString& _scan_dir){ void bittorrent::enableDirectoryScanning(const QString& _scan_dir){
if(!_scan_dir.isEmpty()){ if(!_scan_dir.isEmpty()){
scan_dir = _scan_dir scan_dir = _scan_dir;
timerScan = new QTimer(this); timerScan = new QTimer(this);
connect(timerScan, SIGNAL(timeout()), this, SLOT(scanDirectory())); connect(timerScan, SIGNAL(timeout()), this, SLOT(scanDirectory()));
timerScan->start(5000);
} }
} }
@ -420,6 +428,9 @@ void bittorrent::enableDirectoryScanning(const QString& _scan_dir){
void bittorrent::disableDirectoryScanning(){ void bittorrent::disableDirectoryScanning(){
if(!scan_dir.isNull()){ if(!scan_dir.isNull()){
scan_dir = QString::null; scan_dir = QString::null;
if(timerScan->isActive()){
timerScan->stop();
}
delete timerScan; delete timerScan;
} }
} }
@ -446,7 +457,91 @@ void bittorrent::setUploadRateLimit(int rate){
// This function will apply to same ratio to all torrents // This function will apply to same ratio to all torrents
void bittorrent::setGlobalRatio(float ratio){ void bittorrent::setGlobalRatio(float ratio){
std::vector<torrent_handle> handles = s->get_torrents(); std::vector<torrent_handle> handles = s->get_torrents();
for(int i=0; i<handles.size(); ++i){ for(unsigned int i=0; i<handles.size(); ++i){
handles[i].set_ratio(ratio); handles[i].set_ratio(ratio);
} }
} }
// Add uT PeX extension to bittorrent session
void bittorrent::enablePeerExchange(){
s->add_extension(&create_ut_pex_plugin);
}
// Set DHT port (>= 1000)
void bittorrent::setDHTPort(int dht_port){
if(dht_port >= 1000){
struct dht_settings DHTSettings;
DHTSettings.service_port = dht_port;
s->set_dht_settings(DHTSettings);
qDebug("Set DHT Port to %d", dht_port);
}
}
// Enable IP Filtering
void bittorrent::enableIPFilter(ip_filter filter){
s->set_ip_filter(filter);
}
// Disable IP Filtering
void bittorrent::disableIPFilter(){
s->set_ip_filter(ip_filter());
}
// Set BT session settings (proxy, user_agent)
void bittorrent::setSessionSettings(session_settings sessionSettings){
s->set_settings(sessionSettings);
}
// Read alerts sent by the bittorrent session
void bittorrent::readAlerts(){
// look at session alerts and display some infos
std::auto_ptr<alert> a = s->pop_alert();
while (a.get()){
if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())){
emit finishedTorrent(p->handle);
}
else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())){
emit fullDiskError(QString(p->handle.get_torrent_info().name().c_str()));
}
else if (dynamic_cast<listen_failed_alert*>(a.get())){
// Level: fatal
emit portListeningFailure();
}
else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())){
// Level: fatal
QString fileHash = QString(misc::toString(p->handle.info_hash()).c_str());
emit trackerError(fileHash, QTime::currentTime().toString("hh:mm:ss"), QString(a->msg().c_str()));
// Authentication
if(p->status_code == 401){
emit trackerAuthenticationRequired(p->handle);
}
}
a = s->pop_alert();
}
}
QString bittorrent::getSavePath(const QString& hash){
QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".savepath");
QByteArray line;
QString savePath;
if(savepath_file.open(QIODevice::ReadOnly | QIODevice::Text)){
line = savepath_file.readAll();
savepath_file.close();
qDebug("Save path: %s", line.data());
savePath = QString::fromUtf8(line.data());
}else{
//TODO: always create .savepath file
// savePath = options->getSavePath();
}
// Checking if savePath Dir exists
// create it if it is not
QDir saveDir(savePath);
if(!saveDir.exists()){
if(!saveDir.mkpath(saveDir.path())){
std::cerr << "Couldn't create the save directory: " << (const char*)saveDir.path().toUtf8() << "\n";
// TODO: handle this better
return QDir::homePath();
}
}
return savePath;
}

32
src/bittorrent.h

@ -35,6 +35,7 @@
#include <libtorrent/alert_types.hpp> #include <libtorrent/alert_types.hpp>
#include <libtorrent/extensions/metadata_transfer.hpp> #include <libtorrent/extensions/metadata_transfer.hpp>
#include <libtorrent/extensions/ut_pex.hpp> #include <libtorrent/extensions/ut_pex.hpp>
#include <libtorrent/ip_filter.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
@ -50,26 +51,34 @@
using namespace libtorrent; using namespace libtorrent;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
class bittorrent{ class bittorrent : public QObject{
Q_OBJECT
private: private:
session *s; session *s;
QHash<QString, QStringList> trackerErrors;
bool DHTEnabled; bool DHTEnabled;
String scan_dir; QString scan_dir;
QTimer *timerScan; QTimer *timerScan;
QTimer *timerAlerts;
QWidget *parent;
QStringList supported_preview_extensions;
// Constructor / Destructor // Constructor / Destructor
bittorrent(); bittorrent();
~bittorrent(); ~bittorrent();
protected:
QString getSavePath(const QString& hash);
public: public:
torrent_handle& getTorrentHandle(const QString& hash) const; torrent_handle getTorrentHandle(const QString& hash) const;
bool hasFilteredFiles(const QString& fileHash) const; bool hasFilteredFiles(const QString& fileHash) const;
bool isFilePreviewPossible(const QString& fileHash) const;
bool isDHTEnabled() const; bool isDHTEnabled() const;
public slots: public slots:
void addTorrent(const QString& path, bool fromScanDir = false, const QString& from_url = QString()); void addTorrent(const QString& path, bool fromScanDir = false, const QString& from_url = QString());
void deleteTorrent(const QString& hash, bool permanent=false); void deleteTorrent(const QString& hash, bool permanent = false);
void pauseTorrent(const QString& hash); void pauseTorrent(const QString& hash);
void resumeTorrent(const QString& hash); void resumeTorrent(const QString& hash);
void enableDHT(); void enableDHT();
@ -77,22 +86,33 @@ class bittorrent{
void saveFastResumeData(); void saveFastResumeData();
void enableDirectoryScanning(const QString& scan_dir); void enableDirectoryScanning(const QString& scan_dir);
void disableDirectoryScanning(); void disableDirectoryScanning();
void enablePeerExchange();
void enableIPFilter(ip_filter filter);
void disableIPFilter();
// Session configuration - Setters // Session configuration - Setters
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports); void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
void setDownloadRateLimit(int rate); void setDownloadRateLimit(int rate);
void setUploadRateLimit(int rate); void setUploadRateLimit(int rate);
void setGlobalRatio(float ratio); void setGlobalRatio(float ratio);
void setDHTPort(int dht_port);
void setSessionSettings(session_settings sessionSettings);
protected slots: protected slots:
void cleanDeleter(deleteThread* deleter); void cleanDeleter(deleteThread* deleter);
void loadFilteredFiles(torrent_handle& h); void loadFilteredFiles(torrent_handle& h);
void scanDirectory(); void scanDirectory();
void readAlerts();
signals: signals:
void invalidTorrent(const QString& path); void invalidTorrent(const QString& path);
void duplicateTorrent(const QString& path); void duplicateTorrent(const QString& path);
void addedTorrent(const QString& path, torrent_handle& h, bool fastResume); void addedTorrent(const QString& path, torrent_handle& h, bool fastResume);
void resumedTorrent(const QString& path); void resumedTorrent(const QString& path);
} void finishedTorrent(torrent_handle& h);
void fullDiskError(const QString& fileName);
void trackerError(const QString& hash, const QString& time, const QString& msg);
void portListeningFailure();
void trackerAuthenticationRequired(torrent_handle& h);
};
#endif #endif

4
src/options_imp.h

@ -24,8 +24,8 @@
#include <QTranslator> #include <QTranslator>
#include "ui_options.h" #include "ui_options.h"
#include "libtorrent/session.hpp" #include <libtorrent/session.hpp>
#include "libtorrent/ip_filter.hpp" #include <libtorrent/ip_filter.hpp>
using namespace libtorrent; using namespace libtorrent;

6
src/src.pro

@ -102,7 +102,8 @@ HEADERS += GUI.h misc.h options_imp.h about_imp.h \
PropListDelegate.h previewSelect.h \ PropListDelegate.h previewSelect.h \
PreviewListDelegate.h trackerLogin.h \ PreviewListDelegate.h trackerLogin.h \
downloadThread.h downloadFromURLImp.h \ downloadThread.h downloadFromURLImp.h \
torrentAddition.h deleteThread.h torrentAddition.h deleteThread.h \
bittorrent.h
FORMS += MainWindow.ui options.ui about.ui \ FORMS += MainWindow.ui options.ui about.ui \
properties.ui createtorrent.ui preview.ui \ properties.ui createtorrent.ui preview.ui \
login.ui downloadFromURL.ui addTorrentDialog.ui login.ui downloadFromURL.ui addTorrentDialog.ui
@ -110,5 +111,6 @@ SOURCES += GUI.cpp \
main.cpp \ main.cpp \
options_imp.cpp \ options_imp.cpp \
properties_imp.cpp \ properties_imp.cpp \
createtorrent_imp.cpp createtorrent_imp.cpp \
bittorrent.cpp

Loading…
Cancel
Save