1
mirror of https://github.com/qbittorrent/qBittorrent synced 2025-10-28 14:50:53 +01:00

Compare commits

...

1 Commits

Author SHA1 Message Date
Christophe Dumez
a175812555 - Tagged v1.1.4 and v1.2.0beta6 releases 2008-09-14 10:30:27 +00:00
29 changed files with 236 additions and 704 deletions

View File

@@ -1,6 +1,5 @@
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.2.0 * Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.2.0
- FEATURE: Torrent queueing system (with priorities) - FEATURE: Torrent queueing system (with priorities)
- FEATURE: DHT is always ON (no longer used as fallback)
- FEATURE: The number of DHT nodes is displayed - FEATURE: The number of DHT nodes is displayed
- FEATURE: RSS can now be disabled from program preferences - FEATURE: RSS can now be disabled from program preferences
- BUGFIX: Disable ETA calculation when ETA column is hidden - BUGFIX: Disable ETA calculation when ETA column is hidden
@@ -10,6 +9,18 @@
- COSMETIC: Allow to hide or display top toolbar - COSMETIC: Allow to hide or display top toolbar
- COSMETIC: Log is now in a separate dialog - COSMETIC: Log is now in a separate dialog
* 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 * Tue Aug 26 2008 - Christophe Dumez <chris@qbittorrent.org> - v1.1.3
- BUGFIX: Fixed ratio saving for seeding torrents - BUGFIX: Fixed ratio saving for seeding torrents
- I18N: Added czech and traditional chinese translations - I18N: Added czech and traditional chinese translations

View File

@@ -58,7 +58,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
// Make download list header clickable for sorting // Make download list header clickable for sorting
finishedList->header()->setClickable(true); finishedList->header()->setClickable(true);
finishedList->header()->setSortIndicatorShown(true); finishedList->header()->setSortIndicatorShown(true);
connect(finishedList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortFinishedList(int))); connect(finishedList->header(), SIGNAL(sectionPressed(int)), this, SLOT(toggleFinishedListSortOrder(int)));
finishedListDelegate = new FinishedListDelegate(finishedList); finishedListDelegate = new FinishedListDelegate(finishedList);
finishedList->setItemDelegate(finishedListDelegate); finishedList->setItemDelegate(finishedListDelegate);
connect(finishedList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedListMenu(const QPoint&))); connect(finishedList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedListMenu(const QPoint&)));
@@ -139,6 +139,7 @@ void FinishedTorrents::addTorrent(QString hash){
// Update the number of finished torrents // Update the number of finished torrents
++nbFinished; ++nbFinished;
emit finishedTorrentsNumberChanged(nbFinished); emit finishedTorrentsNumberChanged(nbFinished);
sortFinishedList();
} }
void FinishedTorrents::torrentAdded(QTorrentHandle& h) { void FinishedTorrents::torrentAdded(QTorrentHandle& h) {
@@ -190,10 +191,27 @@ bool FinishedTorrents::loadColWidthFinishedList(){
for(unsigned int i=0; i<listSize; ++i){ for(unsigned int i=0; i<listSize; ++i){
finishedList->header()->resizeSection(i, width_list.at(i).toInt()); finishedList->header()->resizeSection(i, width_list.at(i).toInt());
} }
loadLastSortedColumn();
qDebug("Finished list columns width loaded"); qDebug("Finished list columns width loaded");
return true; 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 // Save columns width in a file to remember them
// (finished list) // (finished list)
void FinishedTorrents::saveColWidthFinishedList() const{ void FinishedTorrents::saveColWidthFinishedList() const{
@@ -262,9 +280,6 @@ void FinishedTorrents::updateFinishedList(){
} }
} }
if(h.is_paused()) continue; 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.is_seed())) { if(h.state() == torrent_status::downloading || (h.state() != torrent_status::checking_files && h.state() != torrent_status::queued_for_checking && h.is_seed())) {
// What are you doing here? go back to download tab! // 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); 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);
@@ -577,17 +592,12 @@ QAction* FinishedTorrents::getActionHoSCol(int index) {
* Sorting functions * Sorting functions
*/ */
void FinishedTorrents::sortFinishedList(int index){ void FinishedTorrents::toggleFinishedListSortOrder(int index) {
static Qt::SortOrder sortOrder = Qt::AscendingOrder; Qt::SortOrder sortOrder = Qt::AscendingOrder;
if(finishedList->header()->sortIndicatorSection() == index){ if(finishedList->header()->sortIndicatorSection() == index){
if(sortOrder == Qt::AscendingOrder){ sortOrder = (Qt::SortOrder)!(bool)finishedList->header()->sortIndicatorOrder();
sortOrder = Qt::DescendingOrder;
}else{
sortOrder = Qt::AscendingOrder;
}
} }
finishedList->header()->setSortIndicator(index, sortOrder); switch(index) {
switch(index){
case F_SIZE: case F_SIZE:
case F_UPSPEED: case F_UPSPEED:
case F_PRIORITY: case F_PRIORITY:
@@ -596,6 +606,30 @@ void FinishedTorrents::sortFinishedList(int index){
default: default:
sortFinishedListString(index, sortOrder); 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) {
case F_SIZE:
case F_UPSPEED:
sortFinishedListFloat(index, sortOrder);
break;
default:
sortFinishedListString(index, sortOrder);
}
} }
void FinishedTorrents::sortFinishedListFloat(int index, Qt::SortOrder sortOrder){ void FinishedTorrents::sortFinishedListFloat(int index, Qt::SortOrder sortOrder){

View File

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

View File

@@ -34,14 +34,13 @@
#include <QTcpServer> #include <QTcpServer>
#include <QTcpSocket> #include <QTcpSocket>
#endif #endif
#include <stdlib.h>
#include <QCloseEvent> #include <QCloseEvent>
#include <QShortcut> #include <QShortcut>
#include <QLabel> #include <QLabel>
#include <QModelIndex> #include <QModelIndex>
#include "GUI.h" #include "GUI.h"
#include "httpserver.h"
#include "downloadingTorrents.h" #include "downloadingTorrents.h"
#include "misc.h" #include "misc.h"
#include "createtorrent_imp.h" #include "createtorrent_imp.h"
@@ -56,8 +55,9 @@
#include "options_imp.h" #include "options_imp.h"
#include "previewSelect.h" #include "previewSelect.h"
#include "allocationDlg.h" #include "allocationDlg.h"
#include "stdlib.h" #include <stdlib.h>
#include "console_imp.h" #include "console_imp.h"
#include "httpserver.h"
using namespace libtorrent; using namespace libtorrent;
@@ -125,7 +125,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
BTSession = new bittorrent(); BTSession = new bittorrent();
connect(BTSession, SIGNAL(fullDiskError(QTorrentHandle&)), this, SLOT(fullDiskError(QTorrentHandle&))); connect(BTSession, SIGNAL(fullDiskError(QTorrentHandle&)), this, SLOT(fullDiskError(QTorrentHandle&)));
connect(BTSession, SIGNAL(finishedTorrent(QTorrentHandle&)), this, SLOT(finishedTorrent(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(trackerAuthenticationRequired(QTorrentHandle&)), this, SLOT(trackerAuthenticationRequired(QTorrentHandle&)));
connect(BTSession, SIGNAL(scanDirFoundTorrents(const QStringList&)), this, SLOT(processScannedFiles(const QStringList&))); connect(BTSession, SIGNAL(scanDirFoundTorrents(const QStringList&)), this, SLOT(processScannedFiles(const QStringList&)));
connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString))); connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
@@ -338,27 +337,6 @@ void GUI::writeSettings() {
settings.endGroup(); 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 // called when a torrent has finished
void GUI::finishedTorrent(QTorrentHandle& h) const { void GUI::finishedTorrent(QTorrentHandle& h) const {
qDebug("In GUI, a torrent has finished"); qDebug("In GUI, a torrent has finished");
@@ -472,7 +450,7 @@ void GUI::acceptConnection() {
} }
void GUI::readParamsOnSocket() { void GUI::readParamsOnSocket() {
if(clientConnection != 0) { if(clientConnection) {
QByteArray params = clientConnection->readAll(); QByteArray params = clientConnection->readAll();
if(!params.isEmpty()) { if(!params.isEmpty()) {
processParams(QString::fromUtf8(params.data()).split(QString::fromUtf8("\n"))); processParams(QString::fromUtf8(params.data()).split(QString::fromUtf8("\n")));
@@ -1488,7 +1466,6 @@ void GUI::createSystrayDelayed() {
createTrayIcon(); createTrayIcon();
systrayIntegration = true; systrayIntegration = true;
delete systrayCreator; delete systrayCreator;
systrayCreator = 0;
} else { } else {
if(timeout) { if(timeout) {
// Retry a bit later // Retry a bit later
@@ -1498,7 +1475,6 @@ void GUI::createSystrayDelayed() {
// Timed out, apparently system really does not // Timed out, apparently system really does not
// support systray icon // support systray icon
delete systrayCreator; delete systrayCreator;
systrayCreator = 0;
} }
} }
} }
@@ -1562,7 +1538,6 @@ void GUI::OptionsSaved(bool deleteOptions) {
else if(httpServer) else if(httpServer)
{ {
delete httpServer; delete httpServer;
httpServer = 0;
} }
// Update session // Update session
configureSession(deleteOptions); configureSession(deleteOptions);
@@ -1575,7 +1550,7 @@ bool GUI::initWebUi(QString username, QString password, int port)
httpServer->close(); httpServer->close();
} }
else else
httpServer = new HttpServer(BTSession, 500, this); httpServer = new HttpServer(BTSession, 1000, this);
httpServer->setAuthorization(username, password); httpServer->setAuthorization(username, password);
bool success = httpServer->listen(QHostAddress::Any, port); bool success = httpServer->listen(QHostAddress::Any, port);
if (success) if (success)

View File

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

View File

@@ -97,9 +97,9 @@ bittorrent::~bittorrent() {
delete deleter; delete deleter;
delete fastResumeSaver; delete fastResumeSaver;
delete timerAlerts; delete timerAlerts;
if(BigRatioTimer != 0) if(BigRatioTimer)
delete BigRatioTimer; delete BigRatioTimer;
if(filterParser != 0) if(filterParser)
delete filterParser; delete filterParser;
delete downloader; delete downloader;
if(queueingEnabled) { if(queueingEnabled) {
@@ -574,8 +574,6 @@ bool bittorrent::isPaused(QString hash) const{
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
return true; return true;
} }
if(torrentsToPauseAfterChecking.contains(hash))
return true;
return h.is_paused(); return h.is_paused();
} }
@@ -833,11 +831,6 @@ bool bittorrent::resumeTorrent(QString hash) {
// Delete .paused file // Delete .paused file
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"))
QFile::remove(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);
change = true;
}
if(queueingEnabled) { if(queueingEnabled) {
updateDownloadQueue(); updateDownloadQueue();
updateUploadQueue(); updateUploadQueue();
@@ -892,7 +885,7 @@ void bittorrent::loadWebSeeds(QString hash) {
} }
// Add a torrent to the bittorrent session // Add a torrent to the bittorrent session
void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) { void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool) {
QTorrentHandle h; QTorrentHandle h;
entry resume_data; entry resume_data;
bool fastResume=false; bool fastResume=false;
@@ -1005,18 +998,15 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
// Copy it to torrentBackup directory // Copy it to torrentBackup directory
QFile::copy(file, newFile); 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 // Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) { if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) {
qDebug("Incremental download enabled for %s", t->name().c_str()); qDebug("Incremental download enabled for %s", t->name().c_str());
h.set_sequenced_download_threshold(1); h.set_sequenced_download_threshold(1);
} }
// Start torrent because it was added in paused state if(!addInPause && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
h.resume(); // Start torrent because it was added in paused state
h.resume();
}
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) { if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) {
finishedTorrents << hash; finishedTorrents << hash;
if(queueingEnabled) { if(queueingEnabled) {
@@ -1353,6 +1343,14 @@ void bittorrent::loadDownloadUploadForTorrent(QString hash) {
ratioData[hash] = downUp; 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{ float bittorrent::getRealRatio(QString hash) const{
QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0)); QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0));
size_type download = downUpInfo.first; size_type download = downUpInfo.first;
@@ -1558,7 +1556,7 @@ void bittorrent::disableDirectoryScanning() {
timerScan->stop(); timerScan->stop();
} }
} }
if(timerScan != 0) if(timerScan)
delete timerScan; delete timerScan;
} }
@@ -1618,7 +1616,6 @@ void bittorrent::setDeleteRatio(float ratio) {
} else { } else {
if(max_ratio != -1 && ratio == -1) { if(max_ratio != -1 && ratio == -1) {
delete BigRatioTimer; delete BigRatioTimer;
BigRatioTimer = 0;
} }
} }
if(max_ratio != ratio) { if(max_ratio != ratio) {
@@ -1643,7 +1640,7 @@ bool bittorrent::loadTrackerFile(QString hash) {
t.tier = parts[1].toInt(); t.tier = parts[1].toInt();
trackers.push_back(t); trackers.push_back(t);
} }
if(trackers.size() != 0) { if(!trackers.empty()) {
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
h.replace_trackers(trackers); h.replace_trackers(trackers);
h.force_reannounce(); h.force_reannounce();
@@ -1814,20 +1811,14 @@ void bittorrent::readAlerts() {
if(h.is_valid()){ if(h.is_valid()){
QString hash = h.hash(); QString hash = h.hash();
qDebug("%s have just finished checking", hash.toUtf8().data()); qDebug("%s have just finished checking", hash.toUtf8().data());
int index = torrentsToPauseAfterChecking.indexOf(hash); if(!h.is_paused()) {
if(index != -1) {
torrentsToPauseAfterChecking.removeAt(index);
// Pause torrent
pauseTorrent(hash);
qDebug("%s was paused after checking", hash.toUtf8().data());
} else {
// Save Addition DateTime // Save Addition DateTime
if(calculateETA) { if(calculateETA) {
TorrentsStartTime[hash] = QDateTime::currentDateTime(); TorrentsStartTime[hash] = QDateTime::currentDateTime();
TorrentsStartData[hash] = h.total_payload_download(); TorrentsStartData[hash] = h.total_payload_download();
} }
} }
emit torrentFinishedChecking(hash); //emit torrentFinishedChecking(hash);
} }
} }
a = s->pop_alert(); a = s->pop_alert();
@@ -1838,10 +1829,6 @@ QHash<QString, QString> bittorrent::getTrackersErrors(QString hash) const{
return trackersErrors.value(hash, QHash<QString, QString>()); return trackersErrors.value(hash, QHash<QString, QString>());
} }
QStringList bittorrent::getTorrentsToPauseAfterChecking() const{
return torrentsToPauseAfterChecking;
}
// Reload a torrent with full allocation mode // Reload a torrent with full allocation mode
void bittorrent::reloadTorrent(const QTorrentHandle &h, bool full_alloc) { void bittorrent::reloadTorrent(const QTorrentHandle &h, bool full_alloc) {
qDebug("** Reloading a torrent"); qDebug("** Reloading a torrent");
@@ -1953,10 +1940,23 @@ void bittorrent::downloadFromUrl(QString url) {
downloader->downloadUrl(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 // Add to bittorrent session the downloaded torrent file
void bittorrent::processDownloadedFile(QString url, QString file_path) { void bittorrent::processDownloadedFile(QString url, QString file_path) {
// Add file to torrent download list int index = url_skippingDlg.indexOf(url);
emit newDownloadedTorrent(file_path, 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);
}
} }
void bittorrent::downloadFromURLList(const QStringList& url_list) { void bittorrent::downloadFromURLList(const QStringList& url_list) {

View File

@@ -28,6 +28,7 @@
#include <QDateTime> #include <QDateTime>
#include <QApplication> #include <QApplication>
#include <QPalette> #include <QPalette>
#include <QPointer>
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include <libtorrent/ip_filter.hpp> #include <libtorrent/ip_filter.hpp>
@@ -46,14 +47,13 @@ class bittorrent : public QObject {
private: private:
session *s; session *s;
QString scan_dir; QString scan_dir;
QTimer *timerScan; QPointer<QTimer> timerScan;
QTimer *timerAlerts; QTimer *timerAlerts;
QTimer *fastResumeSaver; QTimer *fastResumeSaver;
QTimer *BigRatioTimer; QPointer<QTimer> BigRatioTimer;
bool DHTEnabled; bool DHTEnabled;
downloadThread *downloader; downloadThread *downloader;
QString defaultSavePath; QString defaultSavePath;
QStringList torrentsToPauseAfterChecking;
QHash<QString, QDateTime> TorrentsStartTime; QHash<QString, QDateTime> TorrentsStartTime;
QHash<QString, size_type> TorrentsStartData; QHash<QString, size_type> TorrentsStartData;
QHash<QString, QPair<size_type,size_type> > ratioData; QHash<QString, QPair<size_type,size_type> > ratioData;
@@ -71,7 +71,7 @@ class bittorrent : public QObject {
bool UPnPEnabled; bool UPnPEnabled;
bool NATPMPEnabled; bool NATPMPEnabled;
bool LSDEnabled; bool LSDEnabled;
FilterParserThread *filterParser; QPointer<FilterParserThread> filterParser;
QString filterPath; QString filterPath;
int folderScanInterval; // in seconds int folderScanInterval; // in seconds
bool queueingEnabled; bool queueingEnabled;
@@ -83,6 +83,7 @@ class bittorrent : public QObject {
QStringList *uploadQueue; QStringList *uploadQueue;
QStringList *queuedUploads; QStringList *queuedUploads;
bool calculateETA; bool calculateETA;
QStringList url_skippingDlg;
protected: protected:
QString getSavePath(QString hash); QString getSavePath(QString hash);
@@ -99,7 +100,6 @@ class bittorrent : public QObject {
float getPayloadUploadRate() const; float getPayloadUploadRate() const;
session_status getSessionStatus() const; session_status getSessionStatus() const;
int getListenPort() const; int getListenPort() const;
QStringList getTorrentsToPauseAfterChecking() const;
qlonglong getETA(QString hash) const; qlonglong getETA(QString hash) const;
float getRealRatio(QString hash) const; float getRealRatio(QString hash) const;
session* getSession() const; session* getSession() const;
@@ -120,6 +120,7 @@ class bittorrent : public QObject {
int loadTorrentPriority(QString hash); int loadTorrentPriority(QString hash);
QStringList getConsoleMessages() const; QStringList getConsoleMessages() const;
QStringList getPeerBanMessages() const; QStringList getPeerBanMessages() const;
float getUncheckedTorrentProgress(QString hash) const;
public slots: public slots:
void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false); void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
@@ -154,6 +155,7 @@ class bittorrent : public QObject {
void increaseUpTorrentPriority(QString hash); void increaseUpTorrentPriority(QString hash);
void decreaseUpTorrentPriority(QString hash); void decreaseUpTorrentPriority(QString hash);
void saveTorrentPriority(QString hash, int prio); void saveTorrentPriority(QString hash, int prio);
void downloadUrlAndSkipDialog(QString);
// 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 setMaxConnections(int maxConnec);
@@ -214,7 +216,7 @@ class bittorrent : public QObject {
void downloadFromUrlFailure(QString url, QString reason); void downloadFromUrlFailure(QString url, QString reason);
//void fastResumeDataRejected(QString name); //void fastResumeDataRejected(QString name);
//void urlSeedProblem(QString url, QString msg); //void urlSeedProblem(QString url, QString msg);
void torrentFinishedChecking(QString hash); //void torrentFinishedChecking(QString hash);
//void torrent_ratio_deleted(QString fileName); //void torrent_ratio_deleted(QString fileName);
//void UPnPError(QString msg); //void UPnPError(QString msg);
//void UPnPSuccess(QString msg); //void UPnPSuccess(QString msg);

View File

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

View File

@@ -33,7 +33,7 @@
#include <QTime> #include <QTime>
#include <QMenu> #include <QMenu>
DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), delayedSorting(false), nbTorrents(0) { DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) : parent(parent), BTSession(BTSession), nbTorrents(0) {
setupUi(this); setupUi(this);
// Setting icons // Setting icons
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png"))); actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
@@ -79,7 +79,7 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
downloadList->header()->setSortIndicatorShown(true); downloadList->header()->setSortIndicatorShown(true);
// Connecting Actions to slots // Connecting Actions to slots
connect(downloadList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(notifyTorrentDoubleClicked(const QModelIndex&))); connect(downloadList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(notifyTorrentDoubleClicked(const QModelIndex&)));
connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortDownloadList(int))); connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(toggleDownloadListSortOrder(int)));
connect(downloadList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLListMenu(const QPoint&))); connect(downloadList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLListMenu(const QPoint&)));
downloadList->header()->setContextMenuPolicy(Qt::CustomContextMenu); downloadList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(downloadList->header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&))); connect(downloadList->header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
@@ -146,7 +146,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, NAME), QIcon(QString::fromUtf8(":/Icons/skin/paused.png")), Qt::DecorationRole);
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0"))); DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0")));
QTorrentHandle h = BTSession->getTorrentHandle(hash); 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")); setRowColor(row, QString::fromUtf8("red"));
} }
@@ -476,13 +476,6 @@ QStringList DownloadingTorrents::getSelectedTorrents(bool only_one) const{
return res; return res;
} }
void DownloadingTorrents::sortProgressColumnDelayed() {
if(delayedSorting) {
sortDownloadListFloat(PROGRESS, delayedSortingOrder);
qDebug("Delayed sorting of progress column");
}
}
// get information from torrent handles and // get information from torrent handles and
// update download list accordingly // update download list accordingly
void DownloadingTorrents::updateDlList() { void DownloadingTorrents::updateDlList() {
@@ -517,12 +510,6 @@ void DownloadingTorrents::updateDlList() {
} }
// No need to update a paused torrent // No need to update a paused torrent
if(h.is_paused()) continue; 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 // Parse download state
// Setting download state // Setting download state
switch(h.state()) { switch(h.state()) {
@@ -630,6 +617,7 @@ void DownloadingTorrents::addTorrent(QString hash) {
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash)); DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
// Pause torrent if it was paused last time // Pause torrent if it was paused last time
if(BTSession->isPaused(hash)) { 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); DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("red")); setRowColor(row, QString::fromUtf8("red"));
}else{ }else{
@@ -638,6 +626,7 @@ void DownloadingTorrents::addTorrent(QString hash) {
} }
++nbTorrents; ++nbTorrents;
emit unfinishedTorrentsNumberChanged(nbTorrents); emit unfinishedTorrentsNumberChanged(nbTorrents);
sortDownloadList();
} }
void DownloadingTorrents::sortDownloadListFloat(int index, Qt::SortOrder sortOrder) { void DownloadingTorrents::sortDownloadListFloat(int index, Qt::SortOrder sortOrder) {
@@ -686,27 +675,36 @@ void DownloadingTorrents::sortDownloadListString(int index, Qt::SortOrder sortOr
DLListModel->removeRows(0, nbRows_old); DLListModel->removeRows(0, nbRows_old);
} }
void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder startSortOrder, bool fromLoadColWidth) { void DownloadingTorrents::toggleDownloadListSortOrder(int index) {
qDebug("Called sort download list"); Qt::SortOrder sortOrder = Qt::AscendingOrder;
static Qt::SortOrder sortOrder = startSortOrder; qDebug("Toggling column sort order");
if(!fromLoadColWidth && downloadList->header()->sortIndicatorSection() == index) { if(downloadList->header()->sortIndicatorSection() == index) {
if(sortOrder == Qt::AscendingOrder) { sortOrder = (Qt::SortOrder)!(bool)downloadList->header()->sortIndicatorOrder();
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; QString sortOrderLetter;
if(sortOrder == Qt::AscendingOrder) if(sortOrder == Qt::AscendingOrder)
sortOrderLetter = QString::fromUtf8("a"); sortOrderLetter = QString::fromUtf8("a");
else else
sortOrderLetter = QString::fromUtf8("d"); sortOrderLetter = QString::fromUtf8("d");
if(fromLoadColWidth) { settings.setValue(QString::fromUtf8("DownloadListSortedCol"), misc::toQString(index)+sortOrderLetter);
// XXX: Why is this needed? }
if(sortOrder == Qt::DescendingOrder)
downloadList->header()->setSortIndicator(index, Qt::AscendingOrder); void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder sortOrder) {
else if(index == -1) {
downloadList->header()->setSortIndicator(index, Qt::DescendingOrder); index = downloadList->header()->sortIndicatorSection();
sortOrder = downloadList->header()->sortIndicatorOrder();
} else { } else {
downloadList->header()->setSortIndicator(index, sortOrder); downloadList->header()->setSortIndicator(index, sortOrder);
} }
@@ -716,23 +714,12 @@ void DownloadingTorrents::sortDownloadList(int index, Qt::SortOrder startSortOrd
case UPSPEED: case UPSPEED:
case DLSPEED: case DLSPEED:
case PRIORITY: case PRIORITY:
sortDownloadListFloat(index, sortOrder);
break;
case PROGRESS: case PROGRESS:
if(fromLoadColWidth) { sortDownloadListFloat(index, sortOrder);
// 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; break;
default: default:
sortDownloadListString(index, sortOrder); 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 // Save columns width in a file to remember them
@@ -781,7 +768,14 @@ bool DownloadingTorrents::loadColWidthDLList() {
for(unsigned int i=0; i<listSize; ++i) { for(unsigned int i=0; i<listSize; ++i) {
downloadList->header()->resizeSection(i, width_list.at(i).toInt()); 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 // Loading last sorted column
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString sortedCol = settings.value(QString::fromUtf8("DownloadListSortedCol"), QString()).toString(); QString sortedCol = settings.value(QString::fromUtf8("DownloadListSortedCol"), QString()).toString();
if(!sortedCol.isEmpty()) { if(!sortedCol.isEmpty()) {
Qt::SortOrder sortOrder; Qt::SortOrder sortOrder;
@@ -791,10 +785,8 @@ bool DownloadingTorrents::loadColWidthDLList() {
sortOrder = Qt::AscendingOrder; sortOrder = Qt::AscendingOrder;
sortedCol = sortedCol.left(sortedCol.size()-1); sortedCol = sortedCol.left(sortedCol.size()-1);
int index = sortedCol.toInt(); int index = sortedCol.toInt();
sortDownloadList(index, sortOrder, true); sortDownloadList(index, sortOrder);
} }
qDebug("Download list columns width loaded");
return true;
} }
// Called when a torrent is added // Called when a torrent is added
@@ -818,6 +810,7 @@ void DownloadingTorrents::torrentAdded(QTorrentHandle& h) {
// Pause torrent if it was paused last time // Pause torrent if it was paused last time
// Not using isPaused function because torrents are paused after checking now // 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"))) { 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); DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("red")); setRowColor(row, QString::fromUtf8("red"));
}else{ }else{
@@ -826,6 +819,7 @@ void DownloadingTorrents::torrentAdded(QTorrentHandle& h) {
} }
++nbTorrents; ++nbTorrents;
emit unfinishedTorrentsNumberChanged(nbTorrents); emit unfinishedTorrentsNumberChanged(nbTorrents);
sortDownloadList();
} }
void DownloadingTorrents::updateFileSizeAndProgress(QString hash) { void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
@@ -833,7 +827,7 @@ void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)h.actual_size())); 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()));
} }
// Set the color of a row in data model // Set the color of a row in data model

View File

@@ -38,9 +38,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
bittorrent *BTSession; bittorrent *BTSession;
DLListDelegate *DLDelegate; DLListDelegate *DLDelegate;
QStandardItemModel *DLListModel; QStandardItemModel *DLListModel;
bool delayedSorting;
unsigned int nbTorrents; unsigned int nbTorrents;
Qt::SortOrder delayedSortingOrder;
void hideOrShowColumn(int index); void hideOrShowColumn(int index);
bool loadHiddenColumns(); bool loadHiddenColumns();
void saveHiddenColumns(); void saveHiddenColumns();
@@ -69,7 +67,8 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void displayDLListMenu(const QPoint& pos); void displayDLListMenu(const QPoint& pos);
void displayDLHoSMenu(const QPoint&); void displayDLHoSMenu(const QPoint&);
void addTorrent(QString hash); void addTorrent(QString hash);
void sortDownloadList(int index, Qt::SortOrder startSortOrder=Qt::AscendingOrder, bool fromLoadColWidth=false); void sortDownloadList(int index=-1, Qt::SortOrder startSortOrder=Qt::AscendingOrder);
void toggleDownloadListSortOrder(int index);
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder); void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
void sortDownloadListString(int index, Qt::SortOrder sortOrder); void sortDownloadListString(int index, Qt::SortOrder sortOrder);
void saveColWidthDLList() const; void saveColWidthDLList() const;
@@ -85,6 +84,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void hideOrShowColumnRatio(); void hideOrShowColumnRatio();
void hideOrShowColumnEta(); void hideOrShowColumnEta();
void hideOrShowColumnPriority(); void hideOrShowColumnPriority();
void loadLastSortedColumn();
public slots: public slots:
void updateDlList(); void updateDlList();
@@ -92,7 +92,6 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void resumeTorrent(QString hash); void resumeTorrent(QString hash);
void deleteTorrent(QString hash); void deleteTorrent(QString hash);
void propertiesSelection(); void propertiesSelection();
void sortProgressColumnDelayed();
void updateFileSizeAndProgress(QString hash); void updateFileSizeAndProgress(QString hash);
void showPropertiesFromHash(QString hash); void showPropertiesFromHash(QString hash);
void hidePriorityColumn(bool hide); void hidePriorityColumn(bool hide);

View File

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

View File

@@ -42,14 +42,24 @@ HttpConnection::HttpConnection(QTcpSocket *socket, HttpServer *parent)
HttpConnection::~HttpConnection() 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() void HttpConnection::read()
{ {
QByteArray input = socket->readAll(); QByteArray input = socket->readAll();
qDebug(" -------"); /*qDebug(" -------");
qDebug("|REQUEST|"); qDebug("|REQUEST|");
qDebug(" -------"); qDebug(" -------"); */
//qDebug("%s", input.toAscii().constData()); //qDebug("%s", input.toAscii().constData());
if(input.size() > 100000) { if(input.size() > 100000) {
qDebug("Request too big"); qDebug("Request too big");
@@ -81,7 +91,7 @@ void HttpConnection::write()
void HttpConnection::respond() void HttpConnection::respond()
{ {
qDebug("Respond called"); //qDebug("Respond called");
QStringList auth = parser.value("Authorization").split(" ", QString::SkipEmptyParts); 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())) if (auth.size() != 2 || QString::compare(auth[0], "Basic", Qt::CaseInsensitive) != 0 || !parent->isAuthorized(auth[1].toUtf8()))
{ {
@@ -172,16 +182,13 @@ void HttpConnection::respondCommand(QString command)
{ {
QString urls = parser.post("urls"); QString urls = parser.post("urls");
QStringList list = urls.split('\n'); QStringList list = urls.split('\n');
QStringList url_list_cleaned;
foreach(QString url, list){ foreach(QString url, list){
url = url.trimmed(); url = url.trimmed();
if(!url.isEmpty()){ if(!url.isEmpty()){
if(url_list_cleaned.indexOf(QRegExp(url, Qt::CaseInsensitive, QRegExp::FixedString)) < 0){ qDebug("Downloading url: %s", (const char*)url.toUtf8());
url_list_cleaned << url; emit UrlReadyToBeDownloaded(url);
}
} }
} }
emit urlsReadyToBeDownloaded(url_list_cleaned);
return; return;
} }
if(command == "upload") if(command == "upload")

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,7 +11,7 @@ TARGET = qbittorrent
CONFIG += qt thread x11 network CONFIG += qt thread x11 network
# Update this VERSION for each release # Update this VERSION for each release
DEFINES += VERSION=\\\"v1.2.0beta5\\\" DEFINES += VERSION=\\\"v1.2.0beta6\\\"
DEFINES += VERSION_MAJOR=1 DEFINES += VERSION_MAJOR=1
DEFINES += VERSION_MINOR=2 DEFINES += VERSION_MINOR=2
DEFINES += VERSION_BUGFIX=0 DEFINES += VERSION_BUGFIX=0

View File

@@ -10,7 +10,7 @@
<file>webui/scripts/excanvas-compressed.js</file> <file>webui/scripts/excanvas-compressed.js</file>
<file>webui/scripts/mocha-events.js</file> <file>webui/scripts/mocha-events.js</file>
<file>webui/scripts/mocha.js</file> <file>webui/scripts/mocha.js</file>
<file>webui/scripts/mootools-trunk-1475.js</file> <file>webui/scripts/mootools-1.2-core-yc.js</file>
<file>webui/scripts/dynamicTable.js</file> <file>webui/scripts/dynamicTable.js</file>
<file>webui/scripts/client.js</file> <file>webui/scripts/client.js</file>
<file>webui/scripts/download.js</file> <file>webui/scripts/download.js</file>

View File

@@ -4,7 +4,7 @@
<title>qBittorrent web User Interface</title> <title>qBittorrent web User Interface</title>
<link rel="stylesheet" href="../css/style.css" type="text/css" /> <link rel="stylesheet" href="../css/style.css" type="text/css" />
<link rel="stylesheet" href="../css/mocha.css" type="text/css" /> <link rel="stylesheet" href="../css/mocha.css" type="text/css" />
<script type="text/javascript" src="../scripts/mootools-trunk-1475.js" charset="utf-8"></script> <script type="text/javascript" src="../scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
</head> </head>
<body> <body>

View File

@@ -5,7 +5,7 @@
<title>Download from URL</title> <title>Download from URL</title>
<link rel="stylesheet" href="css/style.css" type="text/css" /> <link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/mocha.css" type="text/css" /> <link rel="stylesheet" href="css/mocha.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-trunk-1475.js" charset="utf-8"></script> <script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/download.js" charset="utf-8"></script> <script type="text/javascript" src="scripts/download.js" charset="utf-8"></script>
</head> </head>
<body> <body>

View File

@@ -6,7 +6,7 @@
<link rel="stylesheet" href="css/dynamicTable.css" type="text/css" /> <link rel="stylesheet" href="css/dynamicTable.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" /> <link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/mocha.css" type="text/css" /> <link rel="stylesheet" href="css/mocha.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-trunk-1475.js" charset="utf-8"></script> <script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
<!--[if IE]> <!--[if IE]>
<script type="text/javascript" src="scripts/excanvas-compressed.js"></script> <script type="text/javascript" src="scripts/excanvas-compressed.js"></script>
<![endif]--> <![endif]-->
@@ -19,7 +19,7 @@
<div id="mochaDesktop"> <div id="mochaDesktop">
<div id="mochaDesktopHeader"> <div id="mochaDesktopHeader">
<div id="mochaDesktopTitlebar"> <div id="mochaDesktopTitlebar">
<h1>qBittorrent Web User Interface <span class="version">version 1.0</span></h1> <h1>qBittorrent Web User Interface <span class="version">version 1.1</span></h1>
</div> </div>
<div id="mochaDesktopNavbar"> <div id="mochaDesktopNavbar">
<ul> <ul>

View File

@@ -41,7 +41,8 @@ window.addEvent('domready', function(){
var url = 'json/events?r='+r; var url = 'json/events?r='+r;
if (!waiting){ if (!waiting){
waiting=true; waiting=true;
var request = new Json.Remote(url, { var request = new Request.JSON({
url: url,
method: 'get', method: 'get',
onComplete: function(jsonObj) { onComplete: function(jsonObj) {
if(jsonObj){ if(jsonObj){

View File

@@ -22,12 +22,13 @@
*/ */
window.addEvent('domready', function(){ window.addEvent('domready', function(){
$('urls').focus();
$('downButton').addEvent('click', function(e){ $('downButton').addEvent('click', function(e){
new Event(e).stop(); new Event(e).stop();
new Ajax('/command/download', {method: 'post', data: {urls: $('urls').value}, new Request({url: '/command/download', method: 'post', data: {urls: $('urls').value},
onComplete: function() { onComplete: function() {
window.parent.document.getElementById('downloadPage').parentNode.removeChild(window.parent.document.getElementById('downloadPage')); window.parent.document.getElementById('downloadPage').parentNode.removeChild(window.parent.document.getElementById('downloadPage'));
} }
}).request(); }).send();
}); });
}); });

View File

@@ -66,7 +66,7 @@ var dynamicTable = new Class ({
for(var i=0; i<row.length; i++) for(var i=0; i<row.length; i++)
{ {
var td = new Element('td'); var td = new Element('td');
td.setHTML(row[i]); td.set('html', row[i]);
td.injectInside(tr); td.injectInside(tr);
}; };
@@ -100,7 +100,7 @@ var dynamicTable = new Class ({
{ {
var tds = tr.getElements('td'); var tds = tr.getElements('td');
row.each(function(el, i){ row.each(function(el, i){
tds[i].setHTML(el); tds[i].set('html', el);
}); });
return true; return true;
} }
@@ -115,7 +115,7 @@ var dynamicTable = new Class ({
var tr = this.rows[id]; var tr = this.rows[id];
if($defined(tr)) if($defined(tr))
{ {
tr.remove(); tr.dispose();
this.altRow(); this.altRow();
return true; return true;
} }

View File

@@ -57,7 +57,7 @@ function attachMochaLinkEvents(){
new Event(e).stop(); new Event(e).stop();
var h = myTable.selectedId(); var h = myTable.selectedId();
if(h && confirm('Are you sure you want to delete the selected item in download list?')) if(h && confirm('Are you sure you want to delete the selected item in download list?'))
new Ajax('/command/delete', {method: 'post', data: {hash: h}}).request(); new Request({url: '/command/delete', method: 'post', data: {hash: h}}).send();
}); });
['pause','resume'].each(function(item) { ['pause','resume'].each(function(item) {
@@ -65,13 +65,13 @@ function attachMochaLinkEvents(){
new Event(e).stop(); new Event(e).stop();
var h = myTable.selectedId(); var h = myTable.selectedId();
if(h){ if(h){
new Ajax('/command/'+item, {method: 'post', data: {hash: h}}).request(); new Request({url: '/command/'+item, method: 'post', data: {hash: h}}).send();
} }
}); });
addClickEvent(item+'All', function(e){ addClickEvent(item+'All', function(e){
new Event(e).stop(); new Event(e).stop();
new Ajax('/command/'+item+'all').request(); new Request({url: '/command/'+item+'all'}).send();
}); });
}); });

View File

@@ -331,7 +331,7 @@ var MochaUI = new Class({
var subElements = this.insertWindowElements(windowEl, windowProperties.height, windowProperties.width); var subElements = this.insertWindowElements(windowEl, windowProperties.height, windowProperties.width);
// Set title // Set title
subElements.title.setHTML(windowProperties.title); subElements.title.set('html', windowProperties.title);
// Add content to window // Add content to window
switch(windowProperties.loadMethod) { switch(windowProperties.loadMethod) {
@@ -342,11 +342,11 @@ var MochaUI = new Class({
this.showLoadingIcon(subElements.canvasIcon); this.showLoadingIcon(subElements.canvasIcon);
}.bind(this), }.bind(this),
onFailure: function(){ onFailure: function(){
subElements.content.setHTML('<p><strong>Error Loading XMLHttpRequest</strong></p><p>Make sure all of your content is uploaded to your server, and that you are attempting to load a document from the same domain as this page. XMLHttpRequests will not work on your local machine.</p>'); subElements.content.set('html', '<p><strong>Error Loading XMLHttpRequest</strong></p><p>Make sure all of your content is uploaded to your server, and that you are attempting to load a document from the same domain as this page. XMLHttpRequests will not work on your local machine.</p>');
this.hideLoadingIcon.delay(150, this, subElements.canvasIcon); this.hideLoadingIcon.delay(150, this, subElements.canvasIcon);
}.bind(this), }.bind(this),
onSuccess: function(response) { onSuccess: function(response) {
subElements.content.setHTML(response); subElements.content.set('html', response);
this.hideLoadingIcon.delay(150, this, subElements.canvasIcon); this.hideLoadingIcon.delay(150, this, subElements.canvasIcon);
windowProperties.onContentLoaded(); windowProperties.onContentLoaded();
}.bind(this) }.bind(this)
@@ -374,7 +374,7 @@ var MochaUI = new Class({
break; break;
case 'html': case 'html':
default: default:
subElements.content.setHTML(windowProperties.content); subElements.content.set('html', windowProperties.content);
windowProperties.onContentLoaded(); windowProperties.onContentLoaded();
break; break;
} }
@@ -665,7 +665,7 @@ var MochaUI = new Class({
'id': windowEl.id + '_dockButton', 'id': windowEl.id + '_dockButton',
'class': 'mochaDockButton', 'class': 'mochaDockButton',
'title': titleText 'title': titleText
}).setHTML(titleText.substring(0,13) + (titleText.length > 13 ? '...' : '')).injectInside($(this.dock)); }).set('html', titleText.substring(0,13) + (titleText.length > 13 ? '...' : '')).injectInside($(this.dock));
dockButton.addEvent('click', function(event) { dockButton.addEvent('click', function(event) {
this.restoreMinimized(windowEl); this.restoreMinimized(windowEl);
}.bind(this)); }.bind(this));
@@ -1525,7 +1525,7 @@ function addSlider(){
steps: 20, steps: 20,
offset: 5, offset: 5,
onChange: function(pos){ onChange: function(pos){
$('updatevalue').setHTML(pos); $('updatevalue').set('html', pos);
document.mochaUI.options.cornerRadius = pos; document.mochaUI.options.cornerRadius = pos;
$$('div.mocha').each(function(windowEl, i) { $$('div.mocha').each(function(windowEl, i) {
document.mochaUI.drawWindow(windowEl); document.mochaUI.drawWindow(windowEl);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@
<title>Upload local torrent file</title> <title>Upload local torrent file</title>
<link rel="stylesheet" href="css/style.css" type="text/css" /> <link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/mocha.css" type="text/css" /> <link rel="stylesheet" href="css/mocha.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-trunk-1475.js" charset="utf-8"></script> <script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
<!-- <script type="text/javascript" src="scripts/upload.js" charset="utf-8"></script> --> <!-- <script type="text/javascript" src="scripts/upload.js" charset="utf-8"></script> -->
</head> </head>
<body> <body>