Browse Source

** BIG COMMIT **

- Fixed a bug in options (scan dir widget were not initialized well, still disabled when they shouldn't)
- Fixed a bug in scan dir (doesn't display torrent addition dialog several times for the same torrent if we don't close the dialog before next scan refresh
- Splitted GUI from Bittorrent, lot of code rewritten and optimized. Code changed so much that we will spend the next few days squashing eventual new bugs ;)
- We don't use the hash table to store the torrent handles anymore because libtorrent is already doing it for us (save memory)
adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
bd3bde919d
  1. 8
      Changelog
  2. 6
      TODO
  3. 912
      src/GUI.cpp
  4. 33
      src/GUI.h
  5. 213
      src/bittorrent.cpp
  6. 34
      src/bittorrent.h
  7. 3
      src/downloadThread.h
  8. 4
      src/options_imp.cpp
  9. 1
      src/properties_imp.cpp
  10. 9
      src/torrentAddition.h

8
Changelog

@ -10,15 +10,17 @@
- FEATURE: Number of complete/incomplete sources are now displayed in download list for each torrent - FEATURE: Number of complete/incomplete sources are now displayed in download list for each torrent
- FEATURE: Implemented close to systray - FEATURE: Implemented close to systray
- FEATURE: Added Autocompletion to search engine - FEATURE: Added Autocompletion to search engine
- BUGFIX: Two torrents can now have the same name although they are different - FEATURE: Splitted BT & GUI parts (huge code rewriting & optimization)
- BUGFIX: Two torrents can now have the same name although they are different (use their hash)
- BUGFIX: Fixed download from url that would fail sometimes - BUGFIX: Fixed download from url that would fail sometimes
- BUGFIX: Save directory was reset to default when filtering files in torrent - BUGFIX: Save directory was reset to default when filtering files in torrent
- BUGFIX: Force a refresh of download list when the window is shown (avoid delay) - BUGFIX: Force a refresh of download list when the window is shown (avoid delay)
- BUGFIX: Fixed deletion from hard drive (failed for non-empty folders) - BUGFIX: Fixed deletion from hard drive (failed for non-empty folders)
- BUGFIX: qBittorrent now identifies its version correctly on the network - BUGFIX: qBittorrent now identifies its version correctly on the network
- BUGFIX: Preventing GUI from freezing when deleting a download permanently - BUGFIX: Preventing GUI from freezing when deleting a download permanently
- BUGFIX: Fix directory scanning (stop trying to download the same files several times) - BUGFIX: Fixed directory scanning (stop trying to download the same files several times)
- COSMETIC: Replaced OSD messages by systray messages - BUGFIX: Fixed bad loading of scan dir in option (widgets still disabled)
- COSMETIC: Replaced OSD messages by Qt4.2 systray messages
* Tue Nov 28 2006 - Christophe Dumez <chris@qbittorrent.org> - v0.8.0 * Tue Nov 28 2006 - Christophe Dumez <chris@qbittorrent.org> - v0.8.0
- FEATURE: Added a torrent addition dialog - FEATURE: Added a torrent addition dialog

6
TODO

@ -40,6 +40,10 @@
- Allow to edit the trackers for a torrent - Allow to edit the trackers for a torrent
// In v0.9.0 // In v0.9.0
- Splitting torrent part from GUI (& remove handles hashtable to save up some memory) - Splitting torrent part from GUI (bug squashing + cleanup)
- Create options object only when necessary to save up some memory - Create options object only when necessary to save up some memory
- Wait for libtorrent v0.12 official release - Wait for libtorrent v0.12 official release
- report this to libtorrent:
"qbittorrent: kademlia/rpc_manager.cpp:327: void libtorrent::dht::rpc_manager::invoke(int, asio::ip::basic_endpoint<asio::ip::udp>, boost::shared_ptr<libtorrent::dht::observer>): l'assertion « false » a échoué."
Info: current TOP output:
25461 chris 15 0 106m 23m 14m S 0.7 2.4 0:01.60 qbittorrent

912
src/GUI.cpp

File diff suppressed because it is too large Load Diff

33
src/GUI.h

@ -43,7 +43,6 @@
#include "about_imp.h" #include "about_imp.h"
#include "previewSelect.h" #include "previewSelect.h"
#include "trackerLogin.h" #include "trackerLogin.h"
#include "deleteThread.h"
#include "bittorrent.h" #include "bittorrent.h"
@ -65,18 +64,11 @@ class GUI : public QMainWindow, private Ui::MainWindow{
private: private:
// Bittorrent // Bittorrent
session *s; bittorrent BTSession;
std::pair<unsigned short, unsigned short> listenPorts;
QHash<QString, torrent_handle> handles;
QTimer *checkConnect; QTimer *checkConnect;
QTimer *timerScan;
QHash<QString, QStringList> trackerErrors; QHash<QString, QStringList> trackerErrors;
trackerLogin *tracker_login;
QList<QPair<torrent_handle,std::string> > unauthenticated_trackers; QList<QPair<torrent_handle,std::string> > unauthenticated_trackers;
downloadThread *downloader;
downloadFromURL *downloadFromURLDialog; downloadFromURL *downloadFromURLDialog;
bool DHTEnabled;
QList<deleteThread*> deleters;
// GUI related // GUI related
options_imp *options; options_imp *options;
createtorrent *createWindow; createtorrent *createWindow;
@ -88,7 +80,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{
DLListDelegate *DLDelegate; DLListDelegate *DLDelegate;
QStandardItemModel *SearchListModel; QStandardItemModel *SearchListModel;
SearchListDelegate *SearchDelegate; SearchListDelegate *SearchDelegate;
QStringList supported_preview_extensions;
unsigned int nbTorrents; unsigned int nbTorrents;
QLabel *connecStatusLblIcon; QLabel *connecStatusLblIcon;
// Preview // Preview
@ -147,25 +138,17 @@ class GUI : public QMainWindow, private Ui::MainWindow{
// Torrent actions // Torrent actions
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 pauseSelection(); void pauseSelection();
void startSelection(); void startSelection();
void askForTorrents(); void askForTorrents();
void deletePermanently(); void deletePermanently();
void deleteSelection(); void deleteSelection();
void resumeUnfinished();
void saveFastResumeData() const;
void checkConnectionStatus(); void checkConnectionStatus();
void scanDirectory();
void setGlobalRatio(float ratio);
void configureSession(); void configureSession();
void processParams(const QStringList& params); void processParams(const QStringList& params);
void addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker); void addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker);
void processDownloadedFile(QString url, QString file_path, int return_code, QString errorBuffer); void processScannedFiles(const QStringList& params);
void downloadFromURLList(const QStringList& url_list); void processDownloadedFiles(const QString& path, const QString& url);
bool loadFilteredFiles(torrent_handle &h);
bool hasFilteredFiles(const QString& fileName);
void reloadTorrent(const torrent_handle &h, bool compact_mode = true);
// Search slots // Search slots
void on_search_button_clicked(); void on_search_button_clicked();
void on_stop_search_button_clicked(); void on_stop_search_button_clicked();
@ -185,11 +168,18 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void showOptions() const; void showOptions() const;
void OptionsSaved(const QString& info); void OptionsSaved(const QString& info);
// HTTP slots // HTTP slots
void downloadFromUrl(const QString& url);
void askForTorrentUrl(); void askForTorrentUrl();
public slots: public slots:
void setLocale(QString locale); void setLocale(QString locale);
void torrentAdded(const QString& path, torrent_handle& h, bool fastResume);
void torrentDuplicate(const QString& path);
void torrentCorrupted(const QString& path);
void finishedTorrent(torrent_handle& h);
void fullDiskError(torrent_handle& h);
void portListeningFailure();
void trackerError(const QString& hash, const QString& time, const QString& msg);
void trackerAuthenticationRequired(torrent_handle& h);
protected: protected:
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);
@ -204,7 +194,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{
float getNovaVersion(const QString& novaPath) const; float getNovaVersion(const QString& novaPath) const;
QByteArray getNovaChangelog(const QString& novaPath) const; QByteArray getNovaChangelog(const QString& novaPath) const;
void updateNova() const; void updateNova() const;
bool isFilePreviewPossible(const torrent_handle& h) const;
QString getSavePath(QString fileName); QString getSavePath(QString fileName);
QPoint screenCenter(); QPoint screenCenter();
}; };

213
src/bittorrent.cpp

@ -20,12 +20,15 @@
*/ */
#include "bittorrent.h" #include "bittorrent.h"
#include "misc.h" #include "misc.h"
#include "downloadThread.h"
#include <QDir> #include <QDir>
#include <QTime> #include <QTime>
// Main constructor // Main constructor
bittorrent::bittorrent(){ bittorrent::bittorrent(){
// Supported preview extensions
// XXX: might be incomplete
supported_preview_extensions << "AVI" << "DIVX" << "MPG" << "MPEG" << "MP3" << "OGG" << "WMV" << "WMA" << "RMV" << "RMVB" << "ASF" << "MOV" << "WAV" << "MP2" << "SWF" << "AC3"; 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));
@ -38,12 +41,21 @@ bittorrent::bittorrent(){
timerAlerts = new QTimer(this); timerAlerts = new QTimer(this);
connect(timerAlerts, SIGNAL(timeout()), this, SLOT(readAlerts())); connect(timerAlerts, SIGNAL(timeout()), this, SLOT(readAlerts()));
timerAlerts->start(3000); timerAlerts->start(3000);
// To download from urls
downloader = new downloadThread(this);
connect(downloader, SIGNAL(downloadFinished(const QString&, const QString&, int, const QString&)), this, SLOT(processDownloadedFile(const QString&, const QString&, int, const QString&)));
}
void bittorrent::resumeUnfinishedTorrents(){
// Resume unfinished torrents
resumeUnfinished();
} }
// Main destructor // Main destructor
bittorrent::~bittorrent(){ bittorrent::~bittorrent(){
disableDirectoryScanning(); disableDirectoryScanning();
delete timerAlerts; delete timerAlerts;
delete downloader;
delete s; delete s;
} }
@ -52,6 +64,16 @@ torrent_handle bittorrent::getTorrentHandle(const QString& hash) const{
return s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))); return s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
} }
// Return true if the torrent corresponding to the
// hash is paused
bool bittorrent::isPaused(const QString& hash) const{
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString())));
if(!h.is_valid()){
return true;
}
return h.is_paused();
}
// 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){
@ -91,6 +113,10 @@ void bittorrent::pauseTorrent(const QString& hash){
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))); 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();
// Create .paused file
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
paused_file.close();
} }
} }
@ -99,6 +125,8 @@ void bittorrent::resumeTorrent(const QString& hash){
torrent_handle h = s->find_torrent(misc::fromString<sha1_hash>((hash.toStdString()))); 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();
// Delete .paused file
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
} }
} }
@ -253,6 +281,11 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir, const QString
} }
} }
// Set the maximum number of opened connections
void bittorrent::setMaxConnections(int maxConnec){
s->set_max_connections(maxConnec);
}
// 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) const{ bool bittorrent::hasFilteredFiles(const QString& fileHash) const{
@ -404,14 +437,16 @@ void bittorrent::scanDirectory(){
foreach(file, files){ foreach(file, files){
QString fullPath = dir.path()+QDir::separator()+file; QString fullPath = dir.path()+QDir::separator()+file;
if(fullPath.endsWith(".torrent")){ if(fullPath.endsWith(".torrent")){
to_add << fullPath; QFile::rename(fullPath, fullPath+QString(".old"));
to_add << fullPath+QString(".old");
} }
} }
foreach(file, to_add){ emit scanDirFoundTorrents(to_add);
// TODO: Support torrent addition dialog
addTorrent(file, true);
} }
} }
void bittorrent::setDefaultSavePath(const QString& savepath){
defaultSavePath = savepath;
} }
// Enable directory scanning // Enable directory scanning
@ -501,7 +536,7 @@ void bittorrent::readAlerts(){
emit finishedTorrent(p->handle); emit finishedTorrent(p->handle);
} }
else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())){ else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())){
emit fullDiskError(QString(p->handle.get_torrent_info().name().c_str())); emit fullDiskError(p->handle);
} }
else if (dynamic_cast<listen_failed_alert*>(a.get())){ else if (dynamic_cast<listen_failed_alert*>(a.get())){
// Level: fatal // Level: fatal
@ -520,6 +555,71 @@ void bittorrent::readAlerts(){
} }
} }
void bittorrent::reloadTorrent(const torrent_handle &h, bool compact_mode){
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
fs::path saveDir = h.save_path();
QString fileName = QString(h.name().c_str());
QString fileHash = QString(misc::toString(h.info_hash()).c_str());
qDebug("Reloading torrent: %s", (const char*)fileName.toUtf8());
torrent_handle new_h;
entry resumeData;
torrent_info t = h.get_torrent_info();
// Checking if torrentBackup Dir exists
// create it if it is not
if(! torrentBackup.exists()){
torrentBackup.mkpath(torrentBackup.path());
}
// Write fast resume data
// Pause download (needed before fast resume writing)
h.pause();
// Extracting resume data
if (h.has_metadata()){
// get fast resume data
resumeData = h.write_resume_data();
}
// Remove torrent
s->remove_torrent(h);
// Add torrent again to session
unsigned short timeout = 0;
while(h.is_valid() && timeout < 6){
SleeperThread::msleep(1000);
++timeout;
}
if(h.is_valid()){
std::cerr << "Error: Couldn't reload the torrent\n";
return;
}
new_h = s->add_torrent(t, saveDir, resumeData, compact_mode);
if(compact_mode){
qDebug("Using compact allocation mode");
}else{
qDebug("Using full allocation mode");
}
// new_h.set_max_connections(60);
new_h.set_max_uploads(-1);
// Load filtered Files
loadFilteredFiles(new_h);
// Pause torrent if it was paused last time
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused")){
new_h.pause();
}
// Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".incremental")){
qDebug("Incremental download enabled for %s", (const char*)fileName.toUtf8());
new_h.set_sequenced_download_threshold(15);
}
}
int bittorrent::getListenPort() const{
return s->listen_port();
}
session_status bittorrent::getSessionStatus() const{
return s->status();
}
QString bittorrent::getSavePath(const QString& hash){ QString bittorrent::getSavePath(const QString& hash){
QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".savepath"); QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".savepath");
QByteArray line; QByteArray line;
@ -530,8 +630,8 @@ QString bittorrent::getSavePath(const QString& hash){
qDebug("Save path: %s", line.data()); qDebug("Save path: %s", line.data());
savePath = QString::fromUtf8(line.data()); savePath = QString::fromUtf8(line.data());
}else{ }else{
//TODO: always create .savepath file // use default save path
// savePath = options->getSavePath(); savePath = defaultSavePath;
} }
// Checking if savePath Dir exists // Checking if savePath Dir exists
// create it if it is not // create it if it is not
@ -539,9 +639,106 @@ QString bittorrent::getSavePath(const QString& hash){
if(!saveDir.exists()){ if(!saveDir.exists()){
if(!saveDir.mkpath(saveDir.path())){ if(!saveDir.mkpath(saveDir.path())){
std::cerr << "Couldn't create the save directory: " << (const char*)saveDir.path().toUtf8() << "\n"; std::cerr << "Couldn't create the save directory: " << (const char*)saveDir.path().toUtf8() << "\n";
// TODO: handle this better // XXX: handle this better
return QDir::homePath(); return QDir::homePath();
} }
} }
return savePath; return savePath;
} }
// Take an url string to a torrent file,
// download the torrent file to a tmp location, then
// add it to download list
void bittorrent::downloadFromUrl(const QString& url){
// Launch downloader thread
downloader->downloadUrl(url);
}
// Add to bittorrent session the downloaded torrent file
void bittorrent::processDownloadedFile(const QString& url, const QString& file_path, int return_code, const QString& errorBuffer){
if(return_code){
// Download failed
emit downloadFromUrlFailure(url, errorBuffer);
QFile::remove(file_path);
return;
}
// Add file to torrent download list
emit newDownloadedTorrent(file_path, url);
}
void bittorrent::downloadFromURLList(const QStringList& url_list){
QString url;
foreach(url, url_list){
downloadFromUrl(url);
}
}
// Return current download rate for the BT
// session. Payload means that it only take into
// account "useful" part of the rate
float bittorrent::getPayloadDownloadRate() const{
session_status sessionStatus = s->status();
return sessionStatus.payload_download_rate;
}
// Return current upload rate for the BT
// session. Payload means that it only take into
// account "useful" part of the rate
float bittorrent::getPayloadUploadRate() const{
session_status sessionStatus = s->status();
return sessionStatus.payload_upload_rate;
}
// Return a vector with all torrent handles in it
std::vector<torrent_handle> bittorrent::getTorrentHandles() const{
return s->get_torrents();
}
// Return a vector with all finished torrent handles in it
QList<torrent_handle> bittorrent::getFinishedTorrentHandles() const{
QList<torrent_handle> finished;
std::vector<torrent_handle> handles;
for(unsigned int i=0; i<handles.size(); ++i){
torrent_handle h = handles[i];
if(h.is_seed()){
finished << h;
}
}
return finished;
}
// Save DHT entry to hard drive
void bittorrent::saveDHTEntry(){
// Save DHT entry
if(DHTEnabled){
try{
entry dht_state = s->dht_state();
boost::filesystem::ofstream out((const char*)(misc::qBittorrentPath()+QString("dht_state")).toUtf8(), std::ios_base::binary);
out.unsetf(std::ios_base::skipws);
bencode(std::ostream_iterator<char>(out), dht_state);
}catch (std::exception& e){
std::cerr << e.what() << "\n";
}
}
}
// Will fast resume unfinished torrents in
// backup directory
void bittorrent::resumeUnfinished(){
qDebug("Resuming unfinished torrents");
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
QStringList fileNames, filePaths;
// Scan torrentBackup directory
fileNames = torrentBackup.entryList();
QString fileName;
foreach(fileName, fileNames){
if(fileName.endsWith(".torrent")){
filePaths.append(torrentBackup.path()+QDir::separator()+fileName);
}
}
// Resume downloads
foreach(fileName, filePaths){
addTorrent(fileName);
}
qDebug("Unfinished torrents resumed");
}

34
src/bittorrent.h

@ -51,6 +51,8 @@
using namespace libtorrent; using namespace libtorrent;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
class downloadThread;
class bittorrent : public QObject{ class bittorrent : public QObject{
Q_OBJECT Q_OBJECT
@ -60,59 +62,77 @@ class bittorrent : public QObject{
QString scan_dir; QString scan_dir;
QTimer *timerScan; QTimer *timerScan;
QTimer *timerAlerts; QTimer *timerAlerts;
QWidget *parent; downloadThread *downloader;
QStringList supported_preview_extensions; QStringList supported_preview_extensions;
QString defaultSavePath;
// Constructor / Destructor
bittorrent();
~bittorrent();
protected: protected:
QString getSavePath(const QString& hash); QString getSavePath(const QString& hash);
public: public:
// Constructor / Destructor
bittorrent();
~bittorrent();
torrent_handle getTorrentHandle(const QString& hash) const; torrent_handle getTorrentHandle(const QString& hash) const;
std::vector<torrent_handle> getTorrentHandles() const;
bool isPaused(const QString& hash) const;
bool hasFilteredFiles(const QString& fileHash) const; bool hasFilteredFiles(const QString& fileHash) const;
bool isFilePreviewPossible(const QString& fileHash) const; bool isFilePreviewPossible(const QString& fileHash) const;
bool isDHTEnabled() const; bool isDHTEnabled() const;
float getPayloadDownloadRate() const;
float getPayloadUploadRate() const;
QList<torrent_handle> getFinishedTorrentHandles() const;
session_status getSessionStatus() const;
int getListenPort() 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 downloadFromUrl(const QString& url);
void downloadFromURLList(const QStringList& url_list);
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();
void disableDHT(); void disableDHT();
void saveDHTEntry();
void saveFastResumeData(); void saveFastResumeData();
void enableDirectoryScanning(const QString& scan_dir); void enableDirectoryScanning(const QString& scan_dir);
void disableDirectoryScanning(); void disableDirectoryScanning();
void enablePeerExchange(); void enablePeerExchange();
void enableIPFilter(ip_filter filter); void enableIPFilter(ip_filter filter);
void disableIPFilter(); void disableIPFilter();
void reloadTorrent(const torrent_handle &h, bool compact_mode = true);
void resumeUnfinishedTorrents();
// 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 setMaxConnections(int maxConnec);
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 setDHTPort(int dht_port);
void setSessionSettings(session_settings sessionSettings); void setSessionSettings(session_settings sessionSettings);
void setDefaultSavePath(const QString& savepath);
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(); void readAlerts();
void processDownloadedFile(const QString&, const QString&, int, const QString&);
void resumeUnfinished();
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 finishedTorrent(torrent_handle& h); void finishedTorrent(torrent_handle& h);
void fullDiskError(const QString& fileName); void fullDiskError(torrent_handle& h);
void trackerError(const QString& hash, const QString& time, const QString& msg); void trackerError(const QString& hash, const QString& time, const QString& msg);
void portListeningFailure(); void portListeningFailure();
void trackerAuthenticationRequired(torrent_handle& h); void trackerAuthenticationRequired(torrent_handle& h);
void downloadFromUrlFailure(const QString& url, const QString& error);
void scanDirFoundTorrents(const QStringList& pathList);
void newDownloadedTorrent(const QString& path, const QString& url);
}; };
#endif #endif

3
src/downloadThread.h

@ -42,7 +42,7 @@ class downloadThread : public QThread {
QWaitCondition condition; QWaitCondition condition;
signals: signals:
void downloadFinished(QString url, QString file_path, int return_code, QString errorBuffer); void downloadFinished(const QString& url, const QString& file_path, int return_code, const QString& errorBuffer);
public: public:
downloadThread(QObject* parent) : QThread(parent){} downloadThread(QObject* parent) : QThread(parent){}
@ -144,6 +144,7 @@ class downloadThread : public QThread {
qDebug("In Download thread RUN, mutex unlocked (no urls) -> stopping"); qDebug("In Download thread RUN, mutex unlocked (no urls) -> stopping");
break; break;
} }
SleeperThread::msleep(500);
} }
} }
}; };

4
src/options_imp.cpp

@ -317,10 +317,14 @@ void options_imp::loadOptions(){
strValue = settings.value("ScanDir", QString()).toString(); strValue = settings.value("ScanDir", QString()).toString();
if(!strValue.isEmpty()){ if(!strValue.isEmpty()){
enableScan_checkBox->setChecked(true); enableScan_checkBox->setChecked(true);
lbl_scanDir->setEnabled(true);
scanDir->setEnabled(true); scanDir->setEnabled(true);
browse_button_scan->setEnabled(true);
scanDir->setText(strValue); scanDir->setText(strValue);
}else{ }else{
enableScan_checkBox->setChecked(false); enableScan_checkBox->setChecked(false);
lbl_scanDir->setEnabled(false);
browse_button_scan->setEnabled(false);
scanDir->setEnabled(false); scanDir->setEnabled(false);
} }
// End Main options // End Main options

1
src/properties_imp.cpp

@ -100,6 +100,7 @@ properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErr
} }
properties::~properties(){ properties::~properties(){
qDebug("Properties destroyed");
delete updateProgressTimer; delete updateProgressTimer;
delete PropDelegate; delete PropDelegate;
delete PropListModel; delete PropListModel;

9
src/torrentAddition.h

@ -86,7 +86,14 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
// Setting file name // Setting file name
fileName = QString(t.name().c_str()); fileName = QString(t.name().c_str());
fileHash = QString(misc::toString(t.info_hash()).c_str()); fileHash = QString(misc::toString(t.info_hash()).c_str());
fileNameLbl->setText("<center><b>"+fileName+"</b></center>"); // Use left() to remove .old extension
QString newFileName;
if(fileName.endsWith(".old")){
newFileName = fileName.left(fileName.size()-4);
}else{
newFileName = fileName;
}
fileNameLbl->setText("<center><b>"+newFileName+"</b></center>");
// List files in torrent // List files in torrent
for(int i=0; i<t.num_files(); ++i){ for(int i=0; i<t.num_files(); ++i){
QStringList line; QStringList line;

Loading…
Cancel
Save