1
mirror of https://github.com/qbittorrent/qBittorrent synced 2025-10-23 22:32:16 +02:00

Compare commits

..

3 Commits

Author SHA1 Message Date
Christophe Dumez
7d565e7f97 - Fixed empty line at the end 2008-07-07 09:16:44 +00:00
Christophe Dumez
b1f15e8714 - Update resource files 2008-07-07 09:13:40 +00:00
Christophe Dumez
1512630757 - Tagged beta3 release 2008-07-07 09:03:12 +00:00
106 changed files with 7145 additions and 12476 deletions

View File

@@ -47,8 +47,6 @@ Translations authors:
- Bulgarian: Tsvetan & Boiko Bankov (emerge_life@users.sourceforge.net)
- Catalan: Gekko Dam Beer (gekko04@users.sourceforge.net)
- Chinese (Simplified): Guo Yue (guoyue0418@hotmail.com)
- Chinese (Traditional): Yi-Shun Wang (dnextstep@gmail.com)
- Czech: Jirka Vilim (web@tets.cz)
- Danish: Mathias Nielsen (comoneo@gmail.com)
- Dutch: Joost Schipper (heavyjoost@users.sourceforge.net)
- English: Christophe Dumez (chris@qbittorrent.org)

View File

@@ -1,27 +1,4 @@
* Sun Sept 14 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.1.4
- FEATURE: DHT is no longer used as fallback only
- FEATURE: Ported WebUI to Mootools v1.2
- BUGFIX: Fixed 'start seeding after torrent creation' feature
- BUGFIX: Fixed compilation with boost v1.36
- BUGFIX: Some code optimization
- BUGFIX: Fixed memory leak in Web UI
- BUGFIX: Fixed problems with column sorting
- BUGFIX: Improved code for pausing torrents on startup
- BUGFIX: Torrent addition dialog is now disabled for downloads from WebUI
- BUGFIX: Give focus to input field in WebUI download dialog
* Tue Aug 26 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.1.3
- BUGFIX: Fixed ratio saving for seeding torrents
- I18N: Added czech and traditional chinese translations
* Sun Aug 17 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.1.2
- BUGFIX: Fixed progress calculation
- BUGFIX: Fixed finished torrent detection
* Fri Aug 01 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.1.1
- BUGFIX: Fixed bad resource file for icons
* Fri Aug 01 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.1.0
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.1.0
- FEATURE: Web interface to control qbittorrent (Ishan Arora)
- FEATURE: Can spoof Azureus peer id to avoid ban
- FEATURE: Allow to hide/show some columns in download and seeding lists
@@ -50,7 +27,6 @@
- COSMETIC: Display "unpaused/total_torrent" in download/upload tabs
- COSMETIC: Allow to resize RSS column
- COSMETIC: Global UP/DL speeds and ratio are displayed above tabs
- COSMETIC: Use infinity symbol for ETA when time is infinite
* Fri Apr 11 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.0.0
- FEATURE: Based on new libtorrent v0.13

View File

@@ -18,6 +18,7 @@ Dependencies:
Qt >= 4.4.0 is advised
- libtorrent-rasterbar by Arvid Norberg (>= v0.13.1 REQUIRED)
-> http://www.qbittorrent.org/download.php (advised)
-> http://www.libtorrent.net
Be careful: another library (the one used by rTorrent) uses a similar name.

57
TODO
View File

@@ -1,22 +1,37 @@
See https://blueprints.launchpad.net/qbittorrent/
// Easy
- Translations into as many languages as possible
- Use Launchpad/Rosetta for translations once it supports TS files
// Intermediate
- Port on MacOS, Windows (and create an installer for Windows) - Slow progress
- Add some transparency (menus,...), improve look / usabilty
- Skins support? (contact Mateusz)
// Harder
- Torrent scheduler ala µtorrent/Bitcomet
// Waiting for libtorrent
- Allow to prioritize torrents (may code this in qBittorrent?)
// Unsure
- Display the peers we are connected to for each torrent with infos (like flag, dl/up speeds, ...)
- Azureus spoofing to prevent ban from trackers?
- Option to shutdown computer when downloads are finished
- NAT checker/Tester
- Display hard drive space left?
- Make use of dbus on Linux for the single instance instead of socket communication?
(http://techbase.kde.org/Development/Tutorials/D-Bus/Accessing_Interfaces)
- When favicon can't be downloaded, try to parse the webpage for:
<link rel="icon" href="http://example.com/favicon.ico" type="image/vnd.microsoft.icon">
* Be careful, the link can be relative
- Improve search plugin install (choose in a list taken from plugins.qbittorrent.org)
- support zipped torrents? (useful?)
- Allow to limit the number of downloading torrents simultaneously (other are paused until a download finishes)
// in v1.2.0
- Allow user to organize the downloads into categories/folders?
// in v1.1.0
- Stop calculating ETAs when ETA column is hidden
-> See https://blueprints.launchpad.net/qbittorrent
Translations updated in v1.1.0:
- French
- Chinese
- Polish
- Portuguese
- Brazilian
- Slovak
- Swedish
- Romanian
- Finnish
- Italian
- Turkish
- Korean
- Hungarian
- German
- Spanish
- Russian
- Dutch
- Bulgarian
- Greek

View File

@@ -55,7 +55,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
// Make download list header clickable for sorting
finishedList->header()->setClickable(true);
finishedList->header()->setSortIndicatorShown(true);
connect(finishedList->header(), SIGNAL(sectionPressed(int)), this, SLOT(toggleFinishedListSortOrder(int)));
connect(finishedList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortFinishedList(int)));
finishedListDelegate = new FinishedListDelegate(finishedList);
finishedList->setItemDelegate(finishedListDelegate);
connect(finishedList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedListMenu(const QPoint&)));
@@ -123,7 +123,6 @@ void FinishedTorrents::addTorrent(QString hash){
// Update the number of finished torrents
++nbFinished;
emit finishedTorrentsNumberChanged(nbFinished);
sortFinishedList();
}
void FinishedTorrents::torrentAdded(QString, QTorrentHandle& h, bool) {
@@ -175,27 +174,10 @@ bool FinishedTorrents::loadColWidthFinishedList(){
for(unsigned int i=0; i<listSize; ++i){
finishedList->header()->resizeSection(i, width_list.at(i).toInt());
}
loadLastSortedColumn();
qDebug("Finished list columns width loaded");
return true;
}
void FinishedTorrents::loadLastSortedColumn() {
// Loading last sorted column
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortedCol = settings.value(QString::fromUtf8("FinishedListSortedCol"), QString()).toString();
if(!sortedCol.isEmpty()) {
Qt::SortOrder sortOrder;
if(sortedCol.endsWith(QString::fromUtf8("d")))
sortOrder = Qt::DescendingOrder;
else
sortOrder = Qt::AscendingOrder;
sortedCol = sortedCol.left(sortedCol.size()-1);
int index = sortedCol.toInt();
sortFinishedList(index, sortOrder);
}
}
// Save columns width in a file to remember them
// (finished list)
void FinishedTorrents::saveColWidthFinishedList() const{
@@ -256,13 +238,16 @@ void FinishedTorrents::updateFinishedList(){
}
Q_ASSERT(row != -1);
if(h.is_paused()) continue;
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(hash) != -1) {
continue;
}
if(h.state() == torrent_status::downloading || (h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking && h.progress() < 1.)) {
// What are you doing here? go back to download tab!
int reponse = QMessageBox::question(this, tr("Incomplete torrent in seeding list"), tr("It appears that the state of '%1' torrent changed from 'seeding' to 'downloading'. Would you like to move it back to download list? (otherwise the torrent will simply be deleted)").arg(h.name()), QMessageBox::Yes | QMessageBox::No);
if (reponse == QMessageBox::Yes) {
qDebug("Info: a torrent was moved from finished to download tab");
deleteTorrent(hash);
BTSession->setUnfinishedTorrent(hash);
BTSession->setFinishedTorrent(hash);
emit torrentMovedFromFinishedList(hash);
}
else if (reponse == QMessageBox::No) {
@@ -409,7 +394,7 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
// Call menu
// XXX: why mapToGlobal() is not enough?
myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,59));
myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,55));
}
@@ -425,7 +410,7 @@ void FinishedTorrents::displayFinishedHoSMenu(const QPoint& pos){
hideshowColumn.addAction(getActionHoSCol(i));
}
// Call menu
hideshowColumn.exec(mapToGlobal(pos)+QPoint(10,32));
hideshowColumn.exec(mapToGlobal(pos)+QPoint(10,55));
}
// toggle hide/show a column
@@ -550,36 +535,17 @@ QAction* FinishedTorrents::getActionHoSCol(int index) {
* Sorting functions
*/
void FinishedTorrents::toggleFinishedListSortOrder(int index) {
Qt::SortOrder sortOrder = Qt::AscendingOrder;
void FinishedTorrents::sortFinishedList(int index){
static Qt::SortOrder sortOrder = Qt::AscendingOrder;
if(finishedList->header()->sortIndicatorSection() == index){
sortOrder = (Qt::SortOrder)!(bool)finishedList->header()->sortIndicatorOrder();
if(sortOrder == Qt::AscendingOrder){
sortOrder = Qt::DescendingOrder;
}else{
sortOrder = Qt::AscendingOrder;
}
}
switch(index) {
case F_SIZE:
case F_UPSPEED:
sortFinishedListFloat(index, sortOrder);
break;
default:
sortFinishedListString(index, sortOrder);
}
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortOrderLetter;
if(sortOrder == Qt::AscendingOrder)
sortOrderLetter = QString::fromUtf8("a");
else
sortOrderLetter = QString::fromUtf8("d");
settings.setValue(QString::fromUtf8("FinishedListSortedCol"), misc::toQString(index)+sortOrderLetter);
}
void FinishedTorrents::sortFinishedList(int index, Qt::SortOrder sortOrder){
if(index == -1) {
index = finishedList->header()->sortIndicatorSection();
sortOrder = finishedList->header()->sortIndicatorOrder();
} else {
finishedList->header()->setSortIndicator(index, sortOrder);
}
switch(index) {
finishedList->header()->setSortIndicator(index, sortOrder);
switch(index){
case F_SIZE:
case F_UPSPEED:
sortFinishedListFloat(index, sortOrder);

View File

@@ -60,9 +60,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void displayFinishedHoSMenu(const QPoint&);
void setRowColor(int row, QString color);
void saveColWidthFinishedList() const;
void loadLastSortedColumn();
void toggleFinishedListSortOrder(int index);
void sortFinishedList(int index=-1, Qt::SortOrder sortOrder=Qt::AscendingOrder);
void sortFinishedList(int index);
void sortFinishedListFloat(int index, Qt::SortOrder sortOrder);
void sortFinishedListString(int index, Qt::SortOrder sortOrder);
void updateFileSize(QString hash);

View File

@@ -32,13 +32,14 @@
#include <QTcpServer>
#include <QTcpSocket>
#endif
#include <stdlib.h>
#include <QCloseEvent>
#include <QShortcut>
#include <QLabel>
#include <QModelIndex>
#include "GUI.h"
#include "httpserver.h"
#include "downloadingTorrents.h"
#include "misc.h"
#include "createtorrent_imp.h"
@@ -53,7 +54,7 @@
#include "options_imp.h"
#include "previewSelect.h"
#include "allocationDlg.h"
#include "httpserver.h"
#include "stdlib.h"
using namespace libtorrent;
@@ -124,6 +125,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
BTSession = new bittorrent();
connect(BTSession, SIGNAL(fullDiskError(QTorrentHandle&)), this, SLOT(fullDiskError(QTorrentHandle&)));
connect(BTSession, SIGNAL(finishedTorrent(QTorrentHandle&)), this, SLOT(finishedTorrent(QTorrentHandle&)));
connect(BTSession, SIGNAL(torrentFinishedChecking(QString)), this, SLOT(torrentChecked(QString)));
connect(BTSession, SIGNAL(trackerAuthenticationRequired(QTorrentHandle&)), this, SLOT(trackerAuthenticationRequired(QTorrentHandle&)));
connect(BTSession, SIGNAL(scanDirFoundTorrents(const QStringList&)), this, SLOT(processScannedFiles(const QStringList&)));
connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
@@ -291,6 +293,27 @@ void GUI::writeSettings() {
settings.endGroup();
}
// Called when a torrent finished checking
void GUI::torrentChecked(QString hash) const {
// Check if the torrent was paused after checking
if(BTSession->isPaused(hash)) {
// Was paused, change its icon/color
if(BTSession->isFinished(hash)) {
// In finished list
qDebug("Automatically paused torrent was in finished list");
finishedTorrentTab->pauseTorrent(hash);
}else{
// In download list
downloadingTorrentTab->pauseTorrent(hash);
}
}
if(!BTSession->isFinished(hash)){
// Delayed Sorting
downloadingTorrentTab->updateFileSizeAndProgress(hash);
downloadingTorrentTab->sortProgressColumnDelayed();
}
}
// called when a torrent has finished
void GUI::finishedTorrent(QTorrentHandle& h) const {
qDebug("In GUI, a torrent has finished");
@@ -402,7 +425,7 @@ void GUI::acceptConnection() {
}
void GUI::readParamsOnSocket() {
if(clientConnection) {
if(clientConnection != 0) {
QByteArray params = clientConnection->readAll();
if(!params.isEmpty()) {
processParams(QString::fromUtf8(params.data()).split(QString::fromUtf8("\n")));
@@ -976,7 +999,6 @@ void GUI::configureSession(bool deleteOptions) {
sessionSettings.user_agent = "qBittorrent "VERSION;
}
sessionSettings.upnp_ignore_nonrouters = true;
sessionSettings.use_dht_as_fallback = false;
BTSession->setSessionSettings(sessionSettings);
// Bittorrent
// * Max connections limit
@@ -1347,6 +1369,7 @@ void GUI::createSystrayDelayed() {
createTrayIcon();
systrayIntegration = true;
delete systrayCreator;
systrayCreator = 0;
} else {
if(timeout) {
// Retry a bit later
@@ -1356,6 +1379,7 @@ void GUI::createSystrayDelayed() {
// Timed out, apparently system really does not
// support systray icon
delete systrayCreator;
systrayCreator = 0;
}
}
}
@@ -1420,6 +1444,7 @@ void GUI::OptionsSaved(QString info, bool deleteOptions) {
else if(httpServer)
{
delete httpServer;
httpServer = 0;
}
// Update session
configureSession(deleteOptions);
@@ -1428,15 +1453,17 @@ void GUI::OptionsSaved(QString info, bool deleteOptions) {
bool GUI::initWebUi(QString username, QString password, int port)
{
if(httpServer)
{
httpServer->close();
}
else
httpServer = new HttpServer(BTSession, 1000, this);
httpServer = new HttpServer(BTSession, 500, this);
httpServer->setAuthorization(username, password);
bool success = httpServer->listen(QHostAddress::Any, port);
if (success)
qDebug("Web UI listening on port %d", port);
qDebug()<<"Web UI listening on port "<<port;
else
QMessageBox::critical(this, "Web User Interface Error", "Unable to initialize HTTP Server on port " + misc::toQString(port));
QMessageBox::critical(this, "Web User Interface Error", "Unable to initialize HTTP Server on port " + port);
return success;
}

View File

@@ -24,7 +24,7 @@
#include <QProcess>
#include <QSystemTrayIcon>
#include <QPointer>
#include "ui_MainWindow.h"
#include "qtorrenthandle.h"
@@ -65,7 +65,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
QTabWidget *tabs;
options_imp *options;
QSystemTrayIcon *myTrayIcon;
QPointer<QTimer> systrayCreator;
QTimer *systrayCreator;
QMenu *myTrayIconMenu;
DownloadingTorrents *downloadingTorrentTab;
FinishedTorrents *finishedTorrentTab;
@@ -86,7 +86,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
// RSS
RSSImp *rssWidget;
// Web UI
QPointer<HttpServer> httpServer;
HttpServer *httpServer;
// Misc
#ifdef QT_4_4
QLocalServer *localServer;
@@ -150,6 +150,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void deleteTorrent(QString hash);
void deleteRatioTorrent(QString fileName);
void finishedTorrent(QTorrentHandle& h) const;
void torrentChecked(QString hash) const;
void updateLists();
bool initWebUi(QString username, QString password, int port);
void pauseTorrent(QString hash);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

View File

@@ -1,7 +1,7 @@
[Desktop Entry]
Categories=Qt;Network;P2P
Comment=V1.1.4
Exec=qbittorrent %f
Categories=Qt;Application;Network;P2P
Comment=V1.1.0
Exec=qbittorrent
GenericName=Bittorrent client
GenericName[bg]=Торент клиент
GenericName[de]=Bittorren Client
@@ -19,7 +19,7 @@ GenericName[tr]=Bittorrent istemcisi
GenericName[uk]=Bittorrent-клієнт
GenericName[zh]=Bittorrent之用户
Icon=qbittorrent
MimeType=application/x-bittorrent;
MimeType=application/x-bittorrent
Name=qBittorrent
Name[ko]=큐비토런트
Terminal=false

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

@@ -41,7 +41,6 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget()
box=new QVBoxLayout();
results_lbl=new QLabel();
resultsBrowser = new QTreeView();
resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
box->addWidget(results_lbl);
box->addWidget(resultsBrowser);
@@ -186,5 +185,4 @@ bool SearchTab::loadColWidthSearchList(){
}
qDebug("Search list columns width loaded");
return true;
}
}

View File

@@ -44,7 +44,7 @@ class about : public QDialog, private Ui::AboutDlg{
// Thanks
te_thanks->append(QString::fromUtf8("<a name='top'></a>"));
te_thanks->append(QString::fromUtf8("<ul><li>I would like to thank sourceforge.net for hosting qBittorrent project.</li>"));
te_thanks->append(QString::fromUtf8("<li>I am happy that Ishan Arora and Arnaud Demaizière are contributing to the project as developers. Their help is greatly appreciated</li>"));
te_thanks->append(QString::fromUtf8("<li>I am happy that Arnaud Demaizière is contributing to the project as a developer. His help is greatly appreciated</li>"));
te_thanks->append(QString::fromUtf8("<li>I also want to thank Jeffery Fernandez (jeffery@qbittorrent.org), project consultant, RPM packager, for his help and support.</li>"));
te_thanks->append(QString::fromUtf8("<li>I am grateful to Peter Koeleman (peter@qbittorrent.org) who is helping port qBittorrent to Windows.</li>"));
te_thanks->append(QString::fromUtf8("<li>Thanks a lot to our graphist Mateusz Toboła (tobejodok@qbittorrent.org) for his great work.</li></ul><br><br>"));
@@ -57,14 +57,12 @@ class about : public QDialog, private Ui::AboutDlg{
- <u>Bulgarian:</u> Tsvetan & Boiko Bankov (emerge_life@users.sourceforge.net)<br>\
- <u>Catalan:</u> Gekko Dam Beer (gekko04@users.sourceforge.net)<br>\
- <u>Chinese (Simplified):</u> Guo Yue (guoyue0418@hotmail.com)<br>\
- <u>Chinese (Traditional):</u> Yi-Shun Wang (dnextstep@gmail.com)<br>\
- <u>Czech:</u> Jirka Vilim (web@tets.cz)<br>\
- <u>Danish:</u> Mathias Nielsen (comoneo@gmail.com)<br>\
- <u>Dutch:</u> Joost Schipper (heavyjoost@users.sourceforge.net) and Peter Koeleman (peter@peerweb.nl)<br>\
- <u>Dutch:</u> Joost Schipper (heavyjoost@users.sourceforge.net)<br>\
- <u>Finnish:</u> Niklas Laxström (nikerabbit@users.sourceforge.net)<br>\
- <u>German:</u> Niels Hoffmann (zentralmaschine@users.sourceforge.net)<br>\
- <u>Greek:</u> Tsvetan Bankov (emerge_life@users.sourceforge.net)<br>\
- <u>Hungarian:</u> Majoros Péter (majoros.peterj@gmail.com)<br>\
- <u>Hungarian:</u> Majoros Péter (majoros.j.p@t-online.hu)<br>\
- <u>Italian:</u> Mirko Ferrari (mirkoferrari@gmail.com) and Ferraro Luciano (luciano.ferraro@gmail.com)<br>\
- <u>Japanese:</u> Nardog (nardog@e2umail.com)<br>\
- <u>Korean:</u> Jin Woo Sin (jin828sin@users.sourceforge.net)<br>\
@@ -72,9 +70,9 @@ class about : public QDialog, private Ui::AboutDlg{
- <u>Polish:</u> Jarek Smieja (ajep9691@wp.pl)<br>\
- <u>Portuguese:</u> Nick Marinho (nickmarinho@gmail.com)<br>\
- <u>Romanian:</u> Obada Denis (obadadenis@users.sourceforge.net)<br>\
- <u>Russian:</u> Nick Khazov (m2k3d0n@users.sourceforge.net) and Alexey Morsov (samurai@ricom.ru)<br>\
- <u>Russian:</u> Nick Khazov (m2k3d0n at users.sourceforge.net)<br>\
- <u>Slovak:</u> helix84<br>\
- <u>Spanish:</u> Vicente Raul Plata Fonseca (silverxnt@users.sourceforge.net) and Gabriel de Oliveira (deadloop@hotmail.com)<br>\
- <u>Spanish:</u> Vicente Raul Plata Fonseca (silverxnt@users.sourceforge.net)<br>\
- <u>Swedish:</u> Daniel Nylander (po@danielnylander.se)<br>\
- <u>Turkish:</u> Erdem Bingöl (erdem84@gmail.com)<br>\
- <u>Ukrainian:</u> Andrey Shpachenko (masterfix@users.sourceforge.net)<br><br>"));

View File

@@ -234,7 +234,7 @@ class arborescence {
void addFile(QString path, size_type file_size, int index, float progress=0., int priority=1) {
Q_ASSERT(root->isDir());
path = QDir::cleanPath(path);
//Q_ASSERT(path.startsWith(root->path()));
Q_ASSERT(path.startsWith(root->path()));
QString relative_path = path.remove(0, root->path().size());
if(relative_path.at(0) ==QDir::separator())
relative_path.remove(0, 1);

View File

@@ -93,9 +93,9 @@ bittorrent::~bittorrent() {
delete deleter;
delete fastResumeSaver;
delete timerAlerts;
if(BigRatioTimer)
if(BigRatioTimer != 0)
delete BigRatioTimer;
if(filterParser)
if(filterParser != 0)
delete filterParser;
delete downloader;
// Delete BT session
@@ -206,6 +206,8 @@ bool bittorrent::isPaused(QString hash) const{
qDebug("/!\\ Error: Invalid handle");
return true;
}
if(torrentsToPauseAfterChecking.contains(hash))
return true;
return h.is_paused();
}
@@ -378,6 +380,11 @@ bool bittorrent::resumeTorrent(QString hash) {
// Delete .paused file
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
int index = torrentsToPauseAfterChecking.indexOf(hash);
if(index != -1) {
torrentsToPauseAfterChecking.removeAt(index);
success = true;
}
return success;
}
@@ -425,7 +432,7 @@ void bittorrent::loadWebSeeds(QString hash) {
}
// Add a torrent to the bittorrent session
void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool) {
void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) {
QTorrentHandle h;
entry resume_data;
bool fastResume=false;
@@ -536,15 +543,18 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
// Copy it to torrentBackup directory
QFile::copy(file, newFile);
}
// Pause torrent if it was paused last time
if((!resumed && addInPause) || QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
torrentsToPauseAfterChecking << hash;
qDebug("Adding a torrent to the torrentsToPauseAfterChecking list");
}
// Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) {
qDebug("Incremental download enabled for %s", t->name().c_str());
h.set_sequenced_download_threshold(1);
}
if(!addInPause && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
// Start torrent because it was added in paused state
h.resume();
}
// Start torrent because it was added in paused state
h.resume();
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) {
finishedTorrents << hash;
}else{
@@ -855,14 +865,6 @@ void bittorrent::loadDownloadUploadForTorrent(QString hash) {
ratioData[hash] = downUp;
}
float bittorrent::getUncheckedTorrentProgress(QString hash) const {
/*if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished"))
return 1.;*/
QTorrentHandle h = getTorrentHandle(hash);
QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0));
return (float)downUpInfo.first / (float)h.actual_size();
}
float bittorrent::getRealRatio(QString hash) const{
QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0));
size_type download = downUpInfo.first;
@@ -931,19 +933,6 @@ void bittorrent::saveFastResumeAndRatioData() {
}
saveFastResumeAndRatioData(hash);
}
hashes = getFinishedTorrents();
foreach(hash, hashes) {
QTorrentHandle h = getTorrentHandle(hash);
if(!h.is_valid()) {
qDebug("/!\\ Error: Invalid handle");
continue;
}
if(h.is_paused()) {
// Do not need to save ratio data for paused torrents
continue;
}
saveDownloadUploadForTorrent(hash);
}
}
void bittorrent::saveFastResumeAndRatioData(QString hash) {
@@ -1043,7 +1032,7 @@ void bittorrent::disableDirectoryScanning() {
timerScan->stop();
}
}
if(timerScan)
if(timerScan != 0)
delete timerScan;
}
@@ -1103,6 +1092,7 @@ void bittorrent::setDeleteRatio(float ratio) {
} else {
if(max_ratio != -1 && ratio == -1) {
delete BigRatioTimer;
BigRatioTimer = 0;
}
}
if(max_ratio != ratio) {
@@ -1127,7 +1117,7 @@ bool bittorrent::loadTrackerFile(QString hash) {
t.tier = parts[1].toInt();
trackers.push_back(t);
}
if(!trackers.empty()) {
if(trackers.size() != 0) {
QTorrentHandle h = getTorrentHandle(hash);
h.replace_trackers(trackers);
h.force_reannounce();
@@ -1288,12 +1278,18 @@ void bittorrent::readAlerts() {
if(h.is_valid()){
QString hash = h.hash();
qDebug("%s have just finished checking", hash.toUtf8().data());
if(!h.is_paused()) {
int index = torrentsToPauseAfterChecking.indexOf(hash);
if(index != -1) {
torrentsToPauseAfterChecking.removeAt(index);
// Pause torrent
pauseTorrent(hash);
qDebug("%s was paused after checking", hash.toUtf8().data());
} else {
// Save Addition DateTime
TorrentsStartTime[hash] = QDateTime::currentDateTime();
TorrentsStartData[hash] = h.total_payload_download();
}
//emit torrentFinishedChecking(hash);
}
emit torrentFinishedChecking(hash);
}
}
a = s->pop_alert();
@@ -1304,6 +1300,10 @@ QHash<QString, QString> bittorrent::getTrackersErrors(QString hash) const{
return trackersErrors.value(hash, QHash<QString, QString>());
}
QStringList bittorrent::getTorrentsToPauseAfterChecking() const{
return torrentsToPauseAfterChecking;
}
// Reload a torrent with full allocation mode
void bittorrent::reloadTorrent(const QTorrentHandle &h, bool full_alloc) {
qDebug("** Reloading a torrent");
@@ -1414,23 +1414,10 @@ void bittorrent::downloadFromUrl(QString url) {
downloader->downloadUrl(url);
}
void bittorrent::downloadUrlAndSkipDialog(QString url) {
emit aboutToDownloadFromUrl(url);
url_skippingDlg << url;
// Launch downloader thread
downloader->downloadUrl(url);
}
// Add to bittorrent session the downloaded torrent file
void bittorrent::processDownloadedFile(QString url, QString file_path) {
int index = url_skippingDlg.indexOf(url);
if(index < 0) {
// Add file to torrent download list
emit newDownloadedTorrent(file_path, url);
} else {
url_skippingDlg.removeAt(index);
addTorrent(file_path, false, url, false);
}
// Add file to torrent download list
emit newDownloadedTorrent(file_path, url);
}
void bittorrent::downloadFromURLList(const QStringList& url_list) {

View File

@@ -26,7 +26,6 @@
#include <QPair>
#include <QStringList>
#include <QDateTime>
#include <QPointer>
#include <libtorrent/session.hpp>
#include <libtorrent/ip_filter.hpp>
@@ -45,13 +44,14 @@ class bittorrent : public QObject{
private:
session *s;
QString scan_dir;
QPointer<QTimer> timerScan;
QTimer *timerScan;
QTimer *timerAlerts;
QTimer *fastResumeSaver;
QPointer<QTimer> BigRatioTimer;
QTimer *BigRatioTimer;
bool DHTEnabled;
downloadThread *downloader;
QString defaultSavePath;
QStringList torrentsToPauseAfterChecking;
QHash<QString, QDateTime> TorrentsStartTime;
QHash<QString, size_type> TorrentsStartData;
QHash<QString, QPair<size_type,size_type> > ratioData;
@@ -67,10 +67,9 @@ class bittorrent : public QObject{
bool UPnPEnabled;
bool NATPMPEnabled;
bool LSDEnabled;
QPointer<FilterParserThread> filterParser;
FilterParserThread *filterParser;
QString filterPath;
int folderScanInterval; // in seconds
QStringList url_skippingDlg;
protected:
QString getSavePath(QString hash);
@@ -87,6 +86,7 @@ class bittorrent : public QObject{
float getPayloadUploadRate() const;
session_status getSessionStatus() const;
int getListenPort() const;
QStringList getTorrentsToPauseAfterChecking() const;
qlonglong getETA(QString hash) const;
float getRealRatio(QString hash) const;
session* getSession() const;
@@ -97,7 +97,6 @@ class bittorrent : public QObject{
bool has_filtered_files(QString hash) const;
unsigned int getFinishedPausedTorrentsNb() const;
unsigned int getUnfinishedPausedTorrentsNb() const;
float getUncheckedTorrentProgress(QString hash) const;
public slots:
void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
@@ -124,7 +123,6 @@ class bittorrent : public QObject{
void loadDownloadUploadForTorrent(QString hash);
void handleDownloadFailure(QString url, QString reason);
void loadWebSeeds(QString fileHash);
void downloadUrlAndSkipDialog(QString);
// Session configuration - Setters
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
void setMaxConnections(int maxConnec);
@@ -180,7 +178,7 @@ class bittorrent : public QObject{
void downloadFromUrlFailure(QString url, QString reason);
void fastResumeDataRejected(QString name);
void urlSeedProblem(QString url, QString msg);
//void torrentFinishedChecking(QString hash);
void torrentFinishedChecking(QString hash);
void torrent_ratio_deleted(QString fileName);
void UPnPError(QString msg);
void UPnPSuccess(QString msg);

View File

@@ -45,7 +45,7 @@ createtorrent::createtorrent(QWidget *parent): QDialog(parent){
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
creatorThread = new torrentCreatorThread();
connect(creatorThread, SIGNAL(creationSuccess(QString, const char*, QString)), this, SLOT(handleCreationSuccess(QString, const char*, QString)));
connect(creatorThread, SIGNAL(creationSuccess(QString)), this, SLOT(handleCreationSucess(QString)));
connect(creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
connect(creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int)));
show();
@@ -129,23 +129,12 @@ void createtorrent::on_addURLSeed_button_clicked(){
// Subfunction to add files to a torrent_info structure
// Written by Arvid Norberg (libtorrent Author)
void add_files(torrent_info& t, path const& p, path const& l){
using boost::filesystem::path;
using boost::filesystem::directory_iterator;
#if BOOST_VERSION < 103600
std::string const& leaf = l.leaf();
#else
std::string const& leaf = l.filename();
#endif
if (leaf == ".." || leaf == ".") return;
qDebug("p: %s, l: %s, l.leaf(): %s", p.string().c_str(), l.string().c_str(), l.leaf().c_str());
path f(p / l);
if (is_directory(f)) {
if (is_directory(f)){
for (directory_iterator i(f), end; i != end; ++i)
#if BOOST_VERSION < 103600
add_files(t, p, l / i->leaf());
#else
add_files(t, p, l / i->filename());
#endif
} else {
}else{
qDebug("Adding %s", l.string().c_str());
t.add_file(l, file_size(f));
}
@@ -232,11 +221,7 @@ void torrentCreatorThread::run() {
ofstream out(complete(path((const char*)save_path.toUtf8())), std::ios_base::binary);
// Adding files to the torrent
path full_path = complete(path(input_path.toUtf8().data()));
#if BOOST_VERSION < 103600
add_files(*t, full_path.branch_path(), full_path.leaf());
#else
add_files(*t, full_path.branch_path(), full_path.filename());
#endif
if(abort) return;
// Set piece size
t->set_piece_size(piece_size);

View File

@@ -35,30 +35,27 @@ class subDeleteThread : public QThread {
private:
QString save_path;
arborescence *arb;
bool abort;
public:
subDeleteThread(QObject *parent, QString saveDir, arborescence *_arb) : QThread(parent), save_path(saveDir) {
arb = _arb;
}
subDeleteThread(QObject *parent, QString saveDir, arborescence *arb) : QThread(parent), save_path(saveDir), arb(arb), abort(false){}
~subDeleteThread(){
qDebug("subDeleteThread successfuly deleted");
//wait();
abort = true;
wait();
}
signals:
// For subthreads
void deletionSuccessST(subDeleteThread* st);
//void deletionFailureST(subDeleteThread* st);
void deletionFailureST(subDeleteThread* st);
protected:
void run(){
/*if(arb->removeFromFS(save_path))
if(arb->removeFromFS(save_path))
emit deletionSuccessST(this);
else
emit deletionFailureST(this);*/
arb->removeFromFS(save_path);
emit deletionSuccessST(this);
emit deletionFailureST(this);
delete arb;
}
};
@@ -102,13 +99,13 @@ class deleteThread : public QThread {
if(abort)
return;
mutex.lock();
if(!torrents_list.empty()){
if(torrents_list.size() != 0){
QPair<QString, arborescence *> torrent = torrents_list.takeFirst();
mutex.unlock();
subDeleteThread *st = new subDeleteThread(0, torrent.first, torrent.second);
subThreads << st;
connect(st, SIGNAL(deletionSuccessST(subDeleteThread*)), this, SLOT(deleteSubThread(subDeleteThread*)));
//connect(st, SIGNAL(deletionFailureST(subDeleteThread*)), this, SLOT(deleteSubThread(subDeleteThread*)));
connect(st, SIGNAL(deletionFailureST(subDeleteThread*)), this, SLOT(deleteSubThread(subDeleteThread*)));
st->start();
}else{
condition.wait(&mutex);

View File

@@ -24,8 +24,6 @@
#include <QSettings>
#include <stdio.h>
#define MAX_THREADS 3
// http://curl.rtin.bz/libcurl/c/libcurl-errors.html
QString subDownloadThread::errorCodeToString(CURLcode status) {
switch(status){
@@ -152,7 +150,9 @@ downloadThread::~downloadThread(){
void downloadThread::downloadUrl(QString url){
QMutexLocker locker(&mutex);
urls_queue.enqueue(url);
if(downloading_list.contains(url)) return;
url_list << url;
downloading_list << url;
if(!isRunning()){
start();
}else{
@@ -165,8 +165,8 @@ void downloadThread::run(){
if(abort)
return;
mutex.lock();
if(!urls_queue.empty() && subThreads.size() < MAX_THREADS){
QString url = urls_queue.dequeue();
if(url_list.size() != 0){
QString url = url_list.takeFirst();
mutex.unlock();
subDownloadThread *st = new subDownloadThread(0, url);
subThreads << st;
@@ -187,9 +187,9 @@ void downloadThread::propagateDownloadedFile(subDownloadThread* st, QString url,
delete st;
emit downloadFinished(url, path);
mutex.lock();
if(!urls_queue.empty()) {
condition.wakeOne();
}
index = downloading_list.indexOf(url);
Q_ASSERT(index != -1);
downloading_list.removeAt(index);
mutex.unlock();
}
@@ -200,8 +200,8 @@ void downloadThread::propagateDownloadFailure(subDownloadThread* st, QString url
delete st;
emit downloadFailure(url, reason);
mutex.lock();
if(!urls_queue.empty()) {
condition.wakeOne();
}
index = downloading_list.indexOf(url);
Q_ASSERT(index != -1);
downloading_list.removeAt(index);
mutex.unlock();
}

View File

@@ -30,7 +30,6 @@
#include <QWaitCondition>
#include <QStringList>
#include <curl/curl.h>
#include <QQueue>
class subDownloadThread : public QThread {
Q_OBJECT
@@ -56,7 +55,8 @@ class downloadThread : public QThread {
Q_OBJECT
private:
QQueue<QString> urls_queue;
QStringList url_list;
QStringList downloading_list;
QMutex mutex;
QWaitCondition condition;
bool abort;

View File

@@ -33,7 +33,7 @@
#include <QTime>
#include <QMenu>
DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), nbTorrents(0) {
DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), delayedSorting(false), nbTorrents(0) {
setupUi(this);
// Setting icons
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
@@ -85,7 +85,7 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
downloadList->header()->setSortIndicatorShown(true);
// Connecting Actions to slots
connect(downloadList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(notifyTorrentDoubleClicked(const QModelIndex&)));
connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(toggleDownloadListSortOrder(int)));
connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortDownloadList(int)));
connect(downloadList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLListMenu(const QPoint&)));
downloadList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(downloadList->header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
@@ -153,7 +153,7 @@ void DownloadingTorrents::pauseTorrent(QString hash) {
DLListModel->setData(DLListModel->index(row, NAME), QIcon(QString::fromUtf8(":/Icons/skin/paused.png")), Qt::DecorationRole);
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0")));
QTorrentHandle h = BTSession->getTorrentHandle(hash);
//DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
setRowColor(row, QString::fromUtf8("red"));
}
@@ -311,7 +311,7 @@ void DownloadingTorrents::displayDLListMenu(const QPoint& pos) {
myDLLlistMenu.addAction(actionBuy_it);
// Call menu
// XXX: why mapToGlobal() is not enough?
myDLLlistMenu.exec(mapToGlobal(pos)+QPoint(10,35));
myDLLlistMenu.exec(mapToGlobal(pos)+QPoint(10,60));
}
@@ -327,7 +327,7 @@ void DownloadingTorrents::displayDLHoSMenu(const QPoint& pos){
hideshowColumn.addAction(getActionHoSCol(i));
}
// Call menu
hideshowColumn.exec(mapToGlobal(pos)+QPoint(10,10));
hideshowColumn.exec(mapToGlobal(pos)+QPoint(10,55));
}
// toggle hide/show a column
@@ -496,6 +496,13 @@ void DownloadingTorrents::displayInfoBarMenu(const QPoint& pos) {
myLogMenu.exec(mapToGlobal(pos)+QPoint(44,305));
}
void DownloadingTorrents::sortProgressColumnDelayed() {
if(delayedSorting) {
sortDownloadListFloat(PROGRESS, delayedSortingOrder);
qDebug("Delayed sorting of progress column");
}
}
// get information from torrent handles and
// update download list accordingly
void DownloadingTorrents::updateDlList() {
@@ -519,6 +526,12 @@ void DownloadingTorrents::updateDlList() {
Q_ASSERT(row != -1);
// No need to update a paused torrent
if(h.is_paused()) continue;
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(hash) != -1) {
if(!downloadList->isColumnHidden(PROGRESS)) {
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
}
continue;
}
// Parse download state
// Setting download state
switch(h.state()) {
@@ -623,7 +636,6 @@ void DownloadingTorrents::addTorrent(QString hash) {
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
// Pause torrent if it was paused last time
if(BTSession->isPaused(hash)) {
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)BTSession->getUncheckedTorrentProgress(hash)));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("red"));
}else{
@@ -632,7 +644,6 @@ void DownloadingTorrents::addTorrent(QString hash) {
}
++nbTorrents;
emit unfinishedTorrentsNumberChanged(nbTorrents);
sortDownloadList();
}
void DownloadingTorrents::sortDownloadListFloat(int index, Qt::SortOrder sortOrder) {
@@ -681,36 +692,27 @@ void DownloadingTorrents::sortDownloadListString(int index, Qt::SortOrder sortOr
DLListModel->removeRows(0, nbRows_old);
}
void DownloadingTorrents::toggleDownloadListSortOrder(int index) {
Qt::SortOrder sortOrder = Qt::AscendingOrder;
qDebug("Toggling column sort order");
if(downloadList->header()->sortIndicatorSection() == index) {
sortOrder = (Qt::SortOrder)!(bool)downloadList->header()->sortIndicatorOrder();
void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder startSortOrder, bool fromLoadColWidth) {
qDebug("Called sort download list");
static Qt::SortOrder sortOrder = startSortOrder;
if(!fromLoadColWidth && downloadList->header()->sortIndicatorSection() == index) {
if(sortOrder == Qt::AscendingOrder) {
sortOrder = Qt::DescendingOrder;
}else{
sortOrder = Qt::AscendingOrder;
}
}
switch(index) {
case SIZE:
case ETA:
case UPSPEED:
case DLSPEED:
case PROGRESS:
sortDownloadListFloat(index, sortOrder);
break;
default:
sortDownloadListString(index, sortOrder);
}
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortOrderLetter;
if(sortOrder == Qt::AscendingOrder)
sortOrderLetter = QString::fromUtf8("a");
else
sortOrderLetter = QString::fromUtf8("d");
settings.setValue(QString::fromUtf8("DownloadListSortedCol"), misc::toQString(index)+sortOrderLetter);
}
void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder sortOrder) {
if(index == -1) {
index = downloadList->header()->sortIndicatorSection();
sortOrder = downloadList->header()->sortIndicatorOrder();
if(fromLoadColWidth) {
// XXX: Why is this needed?
if(sortOrder == Qt::DescendingOrder)
downloadList->header()->setSortIndicator(index, Qt::AscendingOrder);
else
downloadList->header()->setSortIndicator(index, Qt::DescendingOrder);
} else {
downloadList->header()->setSortIndicator(index, sortOrder);
}
@@ -719,12 +721,23 @@ void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder sortOrder) {
case ETA:
case UPSPEED:
case DLSPEED:
case PROGRESS:
sortDownloadListFloat(index, sortOrder);
break;
case PROGRESS:
if(fromLoadColWidth) {
// Progress sorting must be delayed until files are checked (on startup)
delayedSorting = true;
qDebug("Delayed sorting of the progress column");
delayedSortingOrder = sortOrder;
}else{
sortDownloadListFloat(index, sortOrder);
}
break;
default:
sortDownloadListString(index, sortOrder);
}
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.setValue(QString::fromUtf8("DownloadListSortedCol"), misc::toQString(index)+sortOrderLetter);
}
// Save columns width in a file to remember them
@@ -773,14 +786,7 @@ bool DownloadingTorrents::loadColWidthDLList() {
for(unsigned int i=0; i<listSize; ++i) {
downloadList->header()->resizeSection(i, width_list.at(i).toInt());
}
loadLastSortedColumn();
qDebug("Download list columns width loaded");
return true;
}
void DownloadingTorrents::loadLastSortedColumn() {
// Loading last sorted column
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortedCol = settings.value(QString::fromUtf8("DownloadListSortedCol"), QString()).toString();
if(!sortedCol.isEmpty()) {
Qt::SortOrder sortOrder;
@@ -790,8 +796,10 @@ void DownloadingTorrents::loadLastSortedColumn() {
sortOrder = Qt::AscendingOrder;
sortedCol = sortedCol.left(sortedCol.size()-1);
int index = sortedCol.toInt();
sortDownloadList(index, sortOrder);
sortDownloadList(index, sortOrder, true);
}
qDebug("Download list columns width loaded");
return true;
}
// Called when a torrent is added
@@ -814,7 +822,6 @@ void DownloadingTorrents::torrentAdded(QString path, QTorrentHandle& h, bool fas
// Pause torrent if it was paused last time
// Not using isPaused function because torrents are paused after checking now
if(QFile::exists(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".paused"))) {
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)BTSession->getUncheckedTorrentProgress(hash)));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("red"));
}else{
@@ -828,7 +835,6 @@ void DownloadingTorrents::torrentAdded(QString path, QTorrentHandle& h, bool fas
}
++nbTorrents;
emit unfinishedTorrentsNumberChanged(nbTorrents);
sortDownloadList();
}
// Called when trying to add a duplicate torrent
@@ -846,7 +852,7 @@ void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
Q_ASSERT(row != -1);
QTorrentHandle h = BTSession->getTorrentHandle(hash);
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)h.actual_size()));
//DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
}
// Called when we couldn't listen on any port

View File

@@ -38,7 +38,9 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
bittorrent *BTSession;
DLListDelegate *DLDelegate;
QStandardItemModel *DLListModel;
bool delayedSorting;
unsigned int nbTorrents;
Qt::SortOrder delayedSortingOrder;
void hideOrShowColumn(int index);
bool loadHiddenColumns();
void saveHiddenColumns();
@@ -71,8 +73,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void on_actionClearLog_triggered();
void displayInfoBarMenu(const QPoint& pos);
void addTorrent(QString hash);
void sortDownloadList(int index=-1, Qt::SortOrder startSortOrder=Qt::AscendingOrder);
void toggleDownloadListSortOrder(int index);
void sortDownloadList(int index, Qt::SortOrder startSortOrder=Qt::AscendingOrder, bool fromLoadColWidth=false);
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
void sortDownloadListString(int index, Qt::SortOrder sortOrder);
void saveColWidthDLList() const;
@@ -93,7 +94,6 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void hideOrShowColumnEta();
void displayUPnPError(QString msg);
void displayUPnPSuccess(QString msg);
void loadLastSortedColumn();
public slots:
void updateDlList();
@@ -103,6 +103,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void deleteTorrent(QString hash);
void setBottomTabEnabled(unsigned int index, bool b);
void propertiesSelection();
void sortProgressColumnDelayed();
void updateFileSizeAndProgress(QString hash);
void showPropertiesFromHash(QString hash);

View File

@@ -31,11 +31,11 @@ EventManager::EventManager(QObject *parent)
void EventManager::update(QVariantMap event)
{
++revision;
revision++;
events << QPair<ulong, QVariantMap>(revision, event);
emit updated();
//qDebug("Added the following event");
//qDebug() << event;
qDebug("Added the following event");
qDebug() << event;
/* QLinkedList<QPair<ulong, QVariantMap> >::iterator i;
for (i = events.begin(); i != events.end(); i++)
qDebug() << *i;*/

View File

@@ -30,7 +30,6 @@
#include <QHttpResponseHeader>
#include <QFile>
#include <QDebug>
#include <QTemporaryFile>
HttpConnection::HttpConnection(QTcpSocket *socket, HttpServer *parent)
: QObject(parent), socket(socket), parent(parent)
@@ -42,31 +41,15 @@ HttpConnection::HttpConnection(QTcpSocket *socket, HttpServer *parent)
HttpConnection::~HttpConnection()
{
delete socket;
}
void HttpConnection::processDownloadedFile(QString url, QString file_path) {
qDebug("URL %s successfully downloaded !", (const char*)url.toUtf8());
emit torrentReadyToBeDownloaded(file_path, false, url, false);
}
void HttpConnection::handleDownloadFailure(QString url, QString reason) {
std::cerr << "Could not download " << (const char*)url.toUtf8() << ", reason: " << (const char*)reason.toUtf8() << "\n";
}
void HttpConnection::read()
{
QByteArray input = socket->readAll();
/*qDebug(" -------");
QString input = socket->readAll();
qDebug(" -------");
qDebug("|REQUEST|");
qDebug(" -------"); */
//qDebug("%s", input.toAscii().constData());
if(input.size() > 100000) {
qDebug("Request too big");
generator.setStatusLine(400, "Bad Request");
write();
return;
}
qDebug(" -------");
qDebug("%s", input.toAscii().constData());
parser.write(input);
if(parser.isError())
{
@@ -81,17 +64,16 @@ void HttpConnection::read()
void HttpConnection::write()
{
QByteArray output = generator.toByteArray();
/*qDebug(" --------");
qDebug(" --------");
qDebug("|RESPONSE|");
qDebug(" --------");
qDebug()<<output;*/
qDebug()<<output;
socket->write(output);
socket->disconnectFromHost();
}
void HttpConnection::respond()
{
//qDebug("Respond called");
QStringList auth = parser.value("Authorization").split(" ", QString::SkipEmptyParts);
if (auth.size() != 2 || QString::compare(auth[0], "Basic", Qt::CaseInsensitive) != 0 || !parent->isAuthorized(auth[1].toUtf8()))
{
@@ -182,32 +164,16 @@ void HttpConnection::respondCommand(QString command)
{
QString urls = parser.post("urls");
QStringList list = urls.split('\n');
QStringList url_list_cleaned;
foreach(QString url, list){
url = url.trimmed();
if(!url.isEmpty()){
qDebug("Downloading url: %s", (const char*)url.toUtf8());
emit UrlReadyToBeDownloaded(url);
if(url_list_cleaned.indexOf(QRegExp(url, Qt::CaseInsensitive, QRegExp::FixedString)) < 0){
url_list_cleaned << url;
}
}
}
return;
}
if(command == "upload")
{
QByteArray torrentfile = parser.torrent();
// XXX: Trick to get a unique filename
QString filePath;
QTemporaryFile *tmpfile = new QTemporaryFile();
if (tmpfile->open()) {
filePath = tmpfile->fileName();
}
delete tmpfile;
// write it to HD
QFile torrent(filePath);
if(torrent.open(QIODevice::WriteOnly)) {
torrent.write(torrentfile);
torrent.close();
}
emit torrentReadyToBeDownloaded(filePath, false, QString(), false);
emit urlsReadyToBeDownloaded(url_list_cleaned);
return;
}
if(command == "resumeall")

View File

@@ -27,6 +27,7 @@
#include <QObject>
class QTcpSocket;
class HttpServer;
class HttpConnection : public QObject
@@ -46,8 +47,6 @@ class HttpConnection : public QObject
void respondJson();
void respondCommand(QString command);
void respondNotFound();
void processDownloadedFile(QString, QString);
void handleDownloadFailure(QString, QString);
public:
HttpConnection(QTcpSocket *socket, HttpServer *parent);
@@ -57,8 +56,7 @@ class HttpConnection : public QObject
void read();
signals:
void UrlReadyToBeDownloaded(QString url);
void torrentReadyToBeDownloaded(QString, bool, QString, bool);
void urlsReadyToBeDownloaded(const QStringList&);
void deleteTorrent(QString hash);
void resumeTorrent(QString hash);
void pauseTorrent(QString hash);

View File

@@ -49,11 +49,11 @@ QString HttpRequestParser::url() const
return path;
}
QByteArray HttpRequestParser::message() const
QString HttpRequestParser::message() const
{
if(isParsable())
return data;
return QByteArray();
return QString();
}
QString HttpRequestParser::get(const QString key) const
@@ -66,12 +66,7 @@ QString HttpRequestParser::post(const QString key) const
return postMap[key];
}
QByteArray HttpRequestParser::torrent() const
{
return torrent_content;
}
void HttpRequestParser::write(QByteArray str)
void HttpRequestParser::write(QString str)
{
while (!headerDone && str.size()>0)
{
@@ -116,7 +111,7 @@ void HttpRequestParser::write(QByteArray str)
if(contentType() == "application/x-www-form-urlencoded")
{
QUrl url;
url.setEncodedQuery(data);
url.setEncodedQuery(data.toAscii());
QListIterator<QPair<QString, QString> > i(url.queryItems());
while (i.hasNext())
{
@@ -125,15 +120,9 @@ void HttpRequestParser::write(QByteArray str)
qDebug() << pair.first << "=" << post(pair.first);
}
}
if(contentType() == "multipart/form-data")
{
//qDebug() << data.right(data.size()-data.indexOf("\r\n\r\n")-QByteArray("\r\n\r\n").size());
torrent_content = data.right(data.size()-data.indexOf("\r\n\r\n")-QByteArray("\r\n\r\n").size());
}
}
}
else
error = true;
}
qDebug() << "isError: " << isError();
}

View File

@@ -30,11 +30,10 @@ class HttpRequestParser : public QHttpRequestHeader
bool headerDone;
bool messageDone;
bool error;
QByteArray data;
QString data;
QString path;
QMap<QString, QString> postMap;
QMap<QString, QString> getMap;
QByteArray torrent_content;
public:
HttpRequestParser();
@@ -42,11 +41,10 @@ class HttpRequestParser : public QHttpRequestHeader
bool isParsable() const;
bool isError() const;
QString url() const;
QByteArray message() const;
QString message() const;
QString get(const QString key) const;
QString post(const QString key) const;
QByteArray torrent() const;
void write(QByteArray str);
void write(QString str);
};
#endif

View File

@@ -20,6 +20,7 @@
#include "httpresponsegenerator.h"
#include <QDebug>
void HttpResponseGenerator::setMessage(const QByteArray message)
{

View File

@@ -32,28 +32,25 @@ HttpServer::HttpServer(bittorrent *BTSession, int msec, QObject* parent) : QTcpS
HttpServer::BTSession = BTSession;
manager = new EventManager(this);
//add torrents
QStringList list = BTSession->getUnfinishedTorrents();
foreach(QString hash, list) {
QStringList list = BTSession->getUnfinishedTorrents() + BTSession->getFinishedTorrents();
QString hash;
foreach(hash, list)
{
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid()) manager->addedTorrent(QString(), h);
}
list = BTSession->getFinishedTorrents();
foreach(QString hash, list) {
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid()) manager->addedTorrent(QString(), h);
if(h.is_valid())
manager->addedTorrent(QString(), h);
}
//connect BTSession to manager
connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), manager, SLOT(addedTorrent(QString, QTorrentHandle&)));
connect(BTSession, SIGNAL(deletedTorrent(QString)), manager, SLOT(deletedTorrent(QString)));
//set timer
timer = new QTimer(this);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(onTimer()));
timer->start(msec);
}
HttpServer::~HttpServer()
{
delete timer;
delete manager;
}
@@ -64,8 +61,7 @@ void HttpServer::newHttpConnection()
{
HttpConnection *connection = new HttpConnection(socket, this);
//connect connection to BTSession
connect(connection, SIGNAL(UrlReadyToBeDownloaded(QString)), BTSession, SLOT(downloadUrlAndSkipDialog(QString)));
connect(connection, SIGNAL(torrentReadyToBeDownloaded(QString, bool, QString, bool)), BTSession, SLOT(addTorrent(QString, bool, QString, bool)));
connect(connection, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), BTSession, SLOT(downloadFromURLList(const QStringList&)));
connect(connection, SIGNAL(deleteTorrent(QString)), BTSession, SLOT(deleteTorrent(QString)));
connect(connection, SIGNAL(pauseTorrent(QString)), BTSession, SLOT(pauseTorrent(QString)));
connect(connection, SIGNAL(resumeTorrent(QString)), BTSession, SLOT(resumeTorrent(QString)));
@@ -76,15 +72,12 @@ void HttpServer::newHttpConnection()
void HttpServer::onTimer()
{
QStringList list = BTSession->getUnfinishedTorrents();
foreach(QString hash, list) {
QStringList list = BTSession->getUnfinishedTorrents() + BTSession->getFinishedTorrents();
foreach(QString hash, list)
{
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid()) manager->modifiedTorrent(h);
}
list = BTSession->getFinishedTorrents();
foreach(QString hash, list) {
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid()) manager->modifiedTorrent(h);
if(h.is_valid())
manager->modifiedTorrent(h);
}
}

View File

@@ -26,7 +26,7 @@
#include <QByteArray>
class bittorrent;
class QTimer;
class EventManager;
class HttpServer : public QTcpServer
@@ -37,7 +37,6 @@ class HttpServer : public QTcpServer
QByteArray base64;
bittorrent *BTSession;
EventManager *manager;
QTimer *timer;
public:
HttpServer(bittorrent *BTSession, int msec, QObject* parent = 0);

View File

@@ -1,108 +1,106 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>Icons/add_file.png</file>
<file>Icons/add_folder.png</file>
<file>Icons/bt_settings.png</file>
<file>Icons/button_cancel.png</file>
<file>Icons/button_ok.png</file>
<file>Icons/folder.png</file>
<file>Icons/qbittorrent32.png</file>
<file>Icons/file.png</file>
<file>Icons/smile.png</file>
<file>Icons/qbittorrent22.png</file>
<file>Icons/mascot.png</file>
<file>Icons/downarrow.png</file>
<file>Icons/unavailable.png</file>
<file>Icons/proxy.png</file>
<file>Icons/description.png</file>
<file>Icons/log.png</file>
<file>Icons/uparrow.png</file>
<file>Icons/home.png</file>
<file>Icons/unsubscribe.png</file>
<file>Icons/url.png</file>
<file>Icons/unsubscribe16.png</file>
<file>Icons/stare.png</file>
<file>Icons/qbittorrent16.png</file>
<file>Icons/locale.png</file>
<file>Icons/splash.png</file>
<file>Icons/subscribe16.png</file>
<file>Icons/loading.png</file>
<file>Icons/star.png</file>
<file>Icons/gnome-shutdown.png</file>
<file>Icons/style.png</file>
<file>Icons/rss16.png</file>
<file>Icons/configure.png</file>
<file>Icons/connection.png</file>
<file>Icons/description.png</file>
<file>Icons/downarrow.png</file>
<file>Icons/download.png</file>
<file>Icons/edit_clear.png</file>
<file>Icons/encrypted.png</file>
<file>Icons/file.png</file>
<file>Icons/filter.png</file>
<file>Icons/folder.png</file>
<file>Icons/gear.png</file>
<file>Icons/gnome-shutdown.png</file>
<file>Icons/home.png</file>
<file>Icons/loading.png</file>
<file>Icons/locale.png</file>
<file>Icons/log.png</file>
<file>Icons/mascot.png</file>
<file>Icons/money.png</file>
<file>Icons/newmsg.png</file>
<file>Icons/password.png</file>
<file>Icons/proxy.png</file>
<file>Icons/qbittorrent16.png</file>
<file>Icons/qbittorrent22.png</file>
<file>Icons/qbittorrent32.png</file>
<file>Icons/refresh.png</file>
<file>Icons/rss16.png</file>
<file>Icons/rss32.png</file>
<file>Icons/smile.png</file>
<file>Icons/sphere.png</file>
<file>Icons/sphere2.png</file>
<file>Icons/splash.png</file>
<file>Icons/star.png</file>
<file>Icons/stare.png</file>
<file>Icons/style.png</file>
<file>Icons/subscribe.png</file>
<file>Icons/subscribe16.png</file>
<file>Icons/systemtray.png</file>
<file>Icons/time.png</file>
<file>Icons/unavailable.png</file>
<file>Icons/unhappy.png</file>
<file>Icons/unsubscribe.png</file>
<file>Icons/unsubscribe16.png</file>
<file>Icons/uparrow.png</file>
<file>Icons/url.png</file>
<file>Icons/sphere.png</file>
<file>Icons/add_folder.png</file>
<file>Icons/button_cancel.png</file>
<file>Icons/encrypted.png</file>
<file>Icons/wizard.png</file>
<file>Icons/flags/brazil.png</file>
<file>Icons/flags/bulgaria.png</file>
<file>Icons/flags/china.png</file>
<file>Icons/flags/czech.png</file>
<file>Icons/flags/denmark.png</file>
<file>Icons/flags/finland.png</file>
<file>Icons/flags/france.png</file>
<file>Icons/flags/germany.png</file>
<file>Icons/flags/greece.png</file>
<file>Icons/flags/hungary.png</file>
<file>Icons/flags/italy.png</file>
<file>Icons/flags/japan.png</file>
<file>Icons/flags/netherlands.png</file>
<file>Icons/flags/norway.png</file>
<file>Icons/flags/poland.png</file>
<file>Icons/flags/portugal.png</file>
<file>Icons/flags/romania.png</file>
<file>Icons/flags/russia.png</file>
<file>Icons/flags/slovakia.png</file>
<file>Icons/flags/south_korea.png</file>
<file>Icons/flags/spain.png</file>
<file>Icons/flags/spain_catalunya.png</file>
<file>Icons/flags/sweden.png</file>
<file>Icons/flags/taiwan.png</file>
<file>Icons/flags/turkey.png</file>
<file>Icons/flags/ukraine.png</file>
<file>Icons/flags/united_kingdom.png</file>
<file>Icons/skin/add.png</file>
<file>Icons/skin/connected.png</file>
<file>Icons/skin/connecting.png</file>
<file>Icons/skin/delete.png</file>
<file>Icons/skin/delete_all.png</file>
<file>Icons/skin/delete_perm.png</file>
<file>Icons/skin/disconnected.png</file>
<file>Icons/skin/downloading.png</file>
<file>Icons/skin/exit.png</file>
<file>Icons/skin/firewalled.png</file>
<file>Icons/skin/info.png</file>
<file>Icons/edit_clear.png</file>
<file>Icons/rss32.png</file>
<file>Icons/subscribe.png</file>
<file>Icons/bt_settings.png</file>
<file>Icons/password.png</file>
<file>Icons/newmsg.png</file>
<file>Icons/sphere2.png</file>
<file>Icons/button_ok.png</file>
<file>Icons/unhappy.png</file>
<file>Icons/add_file.png</file>
<file>Icons/filter.png</file>
<file>Icons/money.png</file>
<file>Icons/download.png</file>
<file>Icons/time.png</file>
<file>Icons/refresh.png</file>
<file>Icons/gear.png</file>
<file>Icons/skin/new.png</file>
<file>Icons/skin/open.png</file>
<file>Icons/skin/pause.png</file>
<file>Icons/skin/pause_all.png</file>
<file>Icons/skin/paused.png</file>
<file>Icons/skin/play.png</file>
<file>Icons/skin/play_all.png</file>
<file>Icons/skin/preview.png</file>
<file>Icons/skin/properties.png</file>
<file>Icons/skin/qb_question.png</file>
<file>Icons/skin/remove.png</file>
<file>Icons/skin/search.png</file>
<file>Icons/skin/seeding.png</file>
<file>Icons/skin/play.png</file>
<file>Icons/skin/connecting.png</file>
<file>Icons/skin/settings.png</file>
<file>Icons/skin/stalled.png</file>
<file>Icons/skin/add.png</file>
<file>Icons/skin/open.png</file>
<file>Icons/skin/play_all.png</file>
<file>Icons/skin/info.png</file>
<file>Icons/skin/connected.png</file>
<file>Icons/skin/search.png</file>
<file>Icons/skin/url.png</file>
<file>Icons/skin/firewalled.png</file>
<file>Icons/skin/properties.png</file>
<file>Icons/skin/preview.png</file>
<file>Icons/skin/remove.png</file>
<file>Icons/skin/delete_perm.png</file>
<file>Icons/skin/pause_all.png</file>
<file>Icons/skin/delete_all.png</file>
<file>Icons/skin/stalled.png</file>
<file>Icons/skin/downloading.png</file>
<file>Icons/skin/delete.png</file>
<file>Icons/skin/exit.png</file>
<file>Icons/skin/seeding.png</file>
<file>Icons/skin/paused.png</file>
<file>Icons/skin/disconnected.png</file>
<file>Icons/skin/pause.png</file>
<file>Icons/flags/turkey.png</file>
<file>Icons/flags/portugal.png</file>
<file>Icons/flags/finland.png</file>
<file>Icons/flags/ukraine.png</file>
<file>Icons/flags/bulgaria.png</file>
<file>Icons/flags/spain_catalunya.png</file>
<file>Icons/flags/brazil.png</file>
<file>Icons/flags/norway.png</file>
<file>Icons/flags/slovakia.png</file>
<file>Icons/flags/romania.png</file>
<file>Icons/flags/united_kingdom.png</file>
<file>Icons/flags/netherlands.png</file>
<file>Icons/flags/china.png</file>
<file>Icons/flags/denmark.png</file>
<file>Icons/flags/hungary.png</file>
<file>Icons/flags/greece.png</file>
<file>Icons/flags/spain.png</file>
<file>Icons/flags/italy.png</file>
<file>Icons/flags/germany.png</file>
<file>Icons/flags/russia.png</file>
<file>Icons/flags/japan.png</file>
<file>Icons/flags/south_korea.png</file>
<file>Icons/flags/france.png</file>
<file>Icons/flags/sweden.png</file>
<file>Icons/flags/poland.png</file>
</qresource>
</RCC>

Some files were not shown because too many files have changed in this diff Show More