Browse Source

- Removed logging panel for now. It will be replaced by a seperate dialog in order to simplify the default UI.

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
f0049f1dae
  1. 4
      src/FinishedTorrents.cpp
  2. 2
      src/FinishedTorrents.h
  3. 79
      src/GUI.cpp
  4. 3
      src/GUI.h
  5. 110
      src/bittorrent.cpp
  6. 32
      src/bittorrent.h
  7. 94
      src/download.ui
  8. 98
      src/downloadingTorrents.cpp
  9. 15
      src/downloadingTorrents.h
  10. 2
      src/eventmanager.cpp
  11. 2
      src/eventmanager.h
  12. 4
      src/httpserver.cpp
  13. 4
      src/options_imp.cpp
  14. 2
      src/options_imp.h
  15. 29
      src/torrentAddition.h

4
src/FinishedTorrents.cpp

@ -37,7 +37,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
setupUi(this); setupUi(this);
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png"))); actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png"))); actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png")));
connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), this, SLOT(torrentAdded(QString, QTorrentHandle&, bool))); connect(BTSession, SIGNAL(addedTorrent(QTorrentHandle&)), this, SLOT(torrentAdded(QTorrentHandle&)));
finishedListModel = new QStandardItemModel(0,7); finishedListModel = new QStandardItemModel(0,7);
finishedListModel->setHeaderData(F_NAME, Qt::Horizontal, tr("Name", "i.e: file name")); finishedListModel->setHeaderData(F_NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
finishedListModel->setHeaderData(F_SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); finishedListModel->setHeaderData(F_SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
@ -141,7 +141,7 @@ void FinishedTorrents::addTorrent(QString hash){
emit finishedTorrentsNumberChanged(nbFinished); emit finishedTorrentsNumberChanged(nbFinished);
} }
void FinishedTorrents::torrentAdded(QString, QTorrentHandle& h, bool) { void FinishedTorrents::torrentAdded(QTorrentHandle& h) {
QString hash = h.hash(); QString hash = h.hash();
if(BTSession->isFinished(hash)) { if(BTSession->isFinished(hash)) {
addTorrent(hash); addTorrent(hash);

2
src/FinishedTorrents.h

@ -64,7 +64,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
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);
void torrentAdded(QString path, QTorrentHandle& h, bool fastResume); void torrentAdded(QTorrentHandle& h);
void on_actionSet_upload_limit_triggered(); void on_actionSet_upload_limit_triggered();
void notifyTorrentDoubleClicked(const QModelIndex& index); void notifyTorrentDoubleClicked(const QModelIndex& index);
void hideOrShowColumnName(); void hideOrShowColumnName();

79
src/GUI.cpp

@ -120,7 +120,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
toolBar->layout()->setSpacing(7); toolBar->layout()->setSpacing(7);
// creating options // creating options
options = new options_imp(this); options = new options_imp(this);
connect(options, SIGNAL(status_changed(QString, bool)), this, SLOT(OptionsSaved(QString, bool))); connect(options, SIGNAL(status_changed(bool)), this, SLOT(OptionsSaved(bool)));
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&)));
@ -130,7 +130,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString))); connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
connect(BTSession, SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString))); connect(BTSession, SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString)));
connect(BTSession, SIGNAL(deletedTorrent(QString)), this, SLOT(deleteTorrent(QString))); connect(BTSession, SIGNAL(deletedTorrent(QString)), this, SLOT(deleteTorrent(QString)));
connect(BTSession, SIGNAL(torrent_ratio_deleted(QString)), this, SLOT(deleteRatioTorrent(QString)));
connect(BTSession, SIGNAL(pausedTorrent(QString)), this, SLOT(pauseTorrent(QString))); connect(BTSession, SIGNAL(pausedTorrent(QString)), this, SLOT(pauseTorrent(QString)));
connect(BTSession, SIGNAL(updateUnfinishedTorrentNumber()), this, SLOT(updateUnfinishedTorrentNumberCalc())); connect(BTSession, SIGNAL(updateUnfinishedTorrentNumber()), this, SLOT(updateUnfinishedTorrentNumberCalc()));
connect(BTSession, SIGNAL(updateFinishedTorrentNumber()), this, SLOT(updateFinishedTorrentNumberCalc())); connect(BTSession, SIGNAL(updateFinishedTorrentNumber()), this, SLOT(updateFinishedTorrentNumberCalc()));
@ -373,7 +372,7 @@ void GUI::finishedTorrent(QTorrentHandle& h) const {
qDebug("We received a finished signal for torrent %s, but it already has a .finished file", hash.toUtf8().data()); qDebug("We received a finished signal for torrent %s, but it already has a .finished file", hash.toUtf8().data());
} }
if(show_msg) if(show_msg)
downloadingTorrentTab->setInfoBar(tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(fileName)); BTSession->addConsoleMessage(tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(fileName));
downloadingTorrentTab->deleteTorrent(hash); downloadingTorrentTab->deleteTorrent(hash);
finishedTorrentTab->addTorrent(hash); finishedTorrentTab->addTorrent(hash);
if(show_msg && systrayIntegration && useNotificationBalloons) { if(show_msg && systrayIntegration && useNotificationBalloons) {
@ -398,7 +397,7 @@ void GUI::fullDiskError(QTorrentHandle& h) const {
}else{ }else{
downloadingTorrentTab->pauseTorrent(hash); downloadingTorrentTab->pauseTorrent(hash);
} }
downloadingTorrentTab->setInfoBar(tr("An error occured (full disk?), '%1' paused.", "e.g: An error occured (full disk?), 'xxx.avi' paused.").arg(h.name())); BTSession->addConsoleMessage(tr("An error occured (full disk?), '%1' paused.", "e.g: An error occured (full disk?), 'xxx.avi' paused.").arg(h.name()));
} }
void GUI::createKeyboardShortcuts() { void GUI::createKeyboardShortcuts() {
@ -709,9 +708,7 @@ void GUI::dropEvent(QDropEvent *event) {
continue; continue;
} }
if(useTorrentAdditionDialog) { if(useTorrentAdditionDialog) {
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
connect(dialog, SIGNAL(torrentAddition(QString, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(QString, QColor)), downloadingTorrentTab, SLOT(setInfoBar(QString, QColor)));
dialog->showLoad(file); dialog->showLoad(file);
}else{ }else{
BTSession->addTorrent(file); BTSession->addTorrent(file);
@ -750,9 +747,7 @@ void GUI::on_actionOpen_triggered() {
unsigned int listSize = pathsList.size(); unsigned int listSize = pathsList.size();
for(unsigned int i=0; i<listSize; ++i) { for(unsigned int i=0; i<listSize; ++i) {
if(useTorrentAdditionDialog) { if(useTorrentAdditionDialog) {
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
connect(dialog, SIGNAL(torrentAddition(QString, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(QString, QColor)), downloadingTorrentTab, SLOT(setInfoBar(QString, QColor)));
dialog->showLoad(pathsList.at(i)); dialog->showLoad(pathsList.at(i));
}else{ }else{
BTSession->addTorrent(pathsList.at(i)); BTSession->addTorrent(pathsList.at(i));
@ -805,16 +800,9 @@ void GUI::on_actionDelete_Permanently_triggered() {
QString fileName = h.name(); QString fileName = h.name();
// Remove the torrent // Remove the torrent
BTSession->deleteTorrent(hash, true); BTSession->deleteTorrent(hash, true);
// Update info bar
downloadingTorrentTab->setInfoBar(tr("'%1' was removed permanently.", "'xxx.avi' was removed permanently.").arg(fileName));
} }
} }
void GUI::deleteRatioTorrent(QString fileName) {
// Update info bar
downloadingTorrentTab->setInfoBar(tr("'%1' was removed because its ratio reached the maximum value you set.", "%1 is a file name").arg(fileName));
}
void GUI::deleteTorrent(QString hash) { void GUI::deleteTorrent(QString hash) {
// Delete item from list // Delete item from list
downloadingTorrentTab->deleteTorrent(hash); downloadingTorrentTab->deleteTorrent(hash);
@ -865,8 +853,6 @@ void GUI::on_actionDelete_triggered() {
QString fileName = h.name(); QString fileName = h.name();
// Remove the torrent // Remove the torrent
BTSession->deleteTorrent(hash, false); BTSession->deleteTorrent(hash, false);
// Update info bar
downloadingTorrentTab->setInfoBar(tr("'%1' was removed.", "'xxx.avi' was removed.").arg(fileName));
} }
} }
@ -884,9 +870,7 @@ void GUI::processParams(const QStringList& params) {
BTSession->downloadFromUrl(param); BTSession->downloadFromUrl(param);
}else{ }else{
if(useTorrentAdditionDialog) { if(useTorrentAdditionDialog) {
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
connect(dialog, SIGNAL(torrentAddition(QString, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(QString, QColor)), downloadingTorrentTab, SLOT(setInfoBar(QString, QColor)));
dialog->showLoad(param); dialog->showLoad(param);
}else{ }else{
BTSession->addTorrent(param); BTSession->addTorrent(param);
@ -905,9 +889,7 @@ void GUI::processScannedFiles(const QStringList& params) {
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool(); bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
foreach(param, params) { foreach(param, params) {
if(useTorrentAdditionDialog) { if(useTorrentAdditionDialog) {
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
connect(dialog, SIGNAL(torrentAddition(QString, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(QString, QColor)), downloadingTorrentTab, SLOT(setInfoBar(QString, QColor)));
dialog->showLoad(param, true); dialog->showLoad(param, true);
}else{ }else{
BTSession->addTorrent(param, true); BTSession->addTorrent(param, true);
@ -919,9 +901,7 @@ void GUI::processDownloadedFiles(QString path, QString url) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool(); bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
if(useTorrentAdditionDialog) { if(useTorrentAdditionDialog) {
torrentAdditionDialog *dialog = new torrentAdditionDialog(this); torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
connect(dialog, SIGNAL(torrentAddition(QString, bool, QString)), BTSession, SLOT(addTorrent(QString, bool, QString)));
connect(dialog, SIGNAL(setInfoBarGUI(QString, QColor)), downloadingTorrentTab, SLOT(setInfoBar(QString, QColor)));
dialog->showLoad(path, false, url); dialog->showLoad(path, false, url);
}else{ }else{
BTSession->addTorrent(path, false, url); BTSession->addTorrent(path, false, url);
@ -967,7 +947,7 @@ void GUI::configureSession(bool deleteOptions) {
BTSession->setListeningPortsRange(options->getPorts()); BTSession->setListeningPortsRange(options->getPorts());
unsigned short new_listenPort = BTSession->getListenPort(); unsigned short new_listenPort = BTSession->getListenPort();
if(new_listenPort != old_listenPort) { if(new_listenPort != old_listenPort) {
downloadingTorrentTab->setInfoBar(tr("qBittorrent is bind to port: %1", "e.g: qBittorrent is bind to port: 1666").arg( misc::toQString(new_listenPort))); BTSession->addConsoleMessage(tr("qBittorrent is bind to port: %1", "e.g: qBittorrent is bind to port: 1666").arg( misc::toQString(new_listenPort)));
} }
// * Global download limit // * Global download limit
QPair<int, int> limits = options->getGlobalBandwidthLimits(); QPair<int, int> limits = options->getGlobalBandwidthLimits();
@ -989,18 +969,18 @@ void GUI::configureSession(bool deleteOptions) {
// * UPnP // * UPnP
if(options->isUPnPEnabled()) { if(options->isUPnPEnabled()) {
BTSession->enableUPnP(true); BTSession->enableUPnP(true);
downloadingTorrentTab->setInfoBar(tr("UPnP support [ON]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("UPnP support [ON]"), QString::fromUtf8("blue"));
} else { } else {
BTSession->enableUPnP(false); BTSession->enableUPnP(false);
downloadingTorrentTab->setInfoBar(tr("UPnP support [OFF]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("UPnP support [OFF]"), QString::fromUtf8("blue"));
} }
// * NAT-PMP // * NAT-PMP
if(options->isNATPMPEnabled()) { if(options->isNATPMPEnabled()) {
BTSession->enableNATPMP(true); BTSession->enableNATPMP(true);
downloadingTorrentTab->setInfoBar(tr("NAT-PMP support [ON]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("NAT-PMP support [ON]"), QString::fromUtf8("blue"));
} else { } else {
BTSession->enableNATPMP(false); BTSession->enableNATPMP(false);
downloadingTorrentTab->setInfoBar(tr("NAT-PMP support [OFF]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("NAT-PMP support [OFF]"), QString::fromUtf8("blue"));
} }
// * Proxy settings // * Proxy settings
proxy_settings proxySettings; proxy_settings proxySettings;
@ -1068,29 +1048,29 @@ void GUI::configureSession(bool deleteOptions) {
// Set DHT Port // Set DHT Port
BTSession->setDHTPort(new_listenPort); BTSession->setDHTPort(new_listenPort);
if(BTSession->enableDHT(true)) { if(BTSession->enableDHT(true)) {
downloadingTorrentTab->setInfoBar(tr("DHT support [ON], port: %1").arg(new_listenPort), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("DHT support [ON], port: %1").arg(new_listenPort), QString::fromUtf8("blue"));
} else { } else {
downloadingTorrentTab->setInfoBar(tr("DHT support [OFF]"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("DHT support [OFF]"), QString::fromUtf8("red"));
} }
} else { } else {
BTSession->enableDHT(false); BTSession->enableDHT(false);
downloadingTorrentTab->setInfoBar(tr("DHT support [OFF]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("DHT support [OFF]"), QString::fromUtf8("blue"));
} }
// * PeX // * PeX
if(options->isPeXEnabled()) { if(options->isPeXEnabled()) {
downloadingTorrentTab->setInfoBar(tr("PeX support [ON]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("PeX support [ON]"), QString::fromUtf8("blue"));
BTSession->enablePeerExchange(); BTSession->enablePeerExchange();
}else{ }else{
// TODO: How can we remove the extension? // TODO: How can we remove the extension?
downloadingTorrentTab->setInfoBar(tr("PeX support [OFF]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("PeX support [OFF]"), QString::fromUtf8("blue"));
} }
// * LSD // * LSD
if(options->isLSDEnabled()) { if(options->isLSDEnabled()) {
BTSession->enableLSD(true); BTSession->enableLSD(true);
downloadingTorrentTab->setInfoBar(tr("Local Peer Discovery [ON]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("Local Peer Discovery [ON]"), QString::fromUtf8("blue"));
} else { } else {
BTSession->enableLSD(false); BTSession->enableLSD(false);
downloadingTorrentTab->setInfoBar(tr("Local Peer Discovery support [OFF]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("Local Peer Discovery support [OFF]"), QString::fromUtf8("blue"));
} }
// * Encryption // * Encryption
int encryptionState = options->getEncryptionSetting(); int encryptionState = options->getEncryptionSetting();
@ -1102,17 +1082,17 @@ void GUI::configureSession(bool deleteOptions) {
case 0: //Enabled case 0: //Enabled
encryptionSettings.out_enc_policy = pe_settings::enabled; encryptionSettings.out_enc_policy = pe_settings::enabled;
encryptionSettings.in_enc_policy = pe_settings::enabled; encryptionSettings.in_enc_policy = pe_settings::enabled;
downloadingTorrentTab->setInfoBar(tr("Encryption support [ON]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("Encryption support [ON]"), QString::fromUtf8("blue"));
break; break;
case 1: // Forced case 1: // Forced
encryptionSettings.out_enc_policy = pe_settings::forced; encryptionSettings.out_enc_policy = pe_settings::forced;
encryptionSettings.in_enc_policy = pe_settings::forced; encryptionSettings.in_enc_policy = pe_settings::forced;
downloadingTorrentTab->setInfoBar(tr("Encryption support [FORCED]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("Encryption support [FORCED]"), QString::fromUtf8("blue"));
break; break;
default: // Disabled default: // Disabled
encryptionSettings.out_enc_policy = pe_settings::disabled; encryptionSettings.out_enc_policy = pe_settings::disabled;
encryptionSettings.in_enc_policy = pe_settings::disabled; encryptionSettings.in_enc_policy = pe_settings::disabled;
downloadingTorrentTab->setInfoBar(tr("Encryption support [OFF]"), QString::fromUtf8("blue")); BTSession->addConsoleMessage(tr("Encryption support [OFF]"), QString::fromUtf8("blue"));
} }
BTSession->applyEncryptionSettings(encryptionSettings); BTSession->applyEncryptionSettings(encryptionSettings);
// * Desired ratio // * Desired ratio
@ -1122,10 +1102,8 @@ void GUI::configureSession(bool deleteOptions) {
// Ip Filter // Ip Filter
if(options->isFilteringEnabled()) { if(options->isFilteringEnabled()) {
BTSession->enableIPFilter(options->getFilter()); BTSession->enableIPFilter(options->getFilter());
downloadingTorrentTab->setBottomTabEnabled(1, true);
}else{ }else{
BTSession->disableIPFilter(); BTSession->disableIPFilter();
downloadingTorrentTab->setBottomTabEnabled(1, false);
} }
// RSS // RSS
if(options->isRSSEnabled()) { if(options->isRSSEnabled()) {
@ -1233,7 +1211,6 @@ void GUI::togglePausedState(QString hash) {
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(BTSession->isPaused(hash) && !(BTSession->isQueueingEnabled() && (BTSession->isDownloadQueued(hash) || BTSession->isUploadQueued(hash)))) { if(BTSession->isPaused(hash) && !(BTSession->isQueueingEnabled() && (BTSession->isDownloadQueued(hash) || BTSession->isUploadQueued(hash)))) {
BTSession->resumeTorrent(hash); BTSession->resumeTorrent(hash);
downloadingTorrentTab->setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(h.name()));
if(inDownloadList) { if(inDownloadList) {
downloadingTorrentTab->resumeTorrent(hash); downloadingTorrentTab->resumeTorrent(hash);
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList()); updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
@ -1250,7 +1227,6 @@ void GUI::togglePausedState(QString hash) {
finishedTorrentTab->pauseTorrent(hash); finishedTorrentTab->pauseTorrent(hash);
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList()); updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
} }
downloadingTorrentTab->setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(h.name()));
} }
} }
@ -1275,7 +1251,6 @@ void GUI::on_actionPause_All_triggered() {
if(change) { if(change) {
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList()); updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList()); updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
downloadingTorrentTab->setInfoBar(tr("All downloads were paused."));
} }
} }
@ -1346,7 +1321,6 @@ void GUI::on_actionPause_triggered() {
finishedTorrentTab->pauseTorrent(hash); finishedTorrentTab->pauseTorrent(hash);
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList()); updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
} }
downloadingTorrentTab->setInfoBar(tr("'%1' paused.", "xxx.avi paused.").arg(BTSession->getTorrentHandle(hash).name()));
} }
} }
} }
@ -1379,7 +1353,6 @@ void GUI::on_actionStart_All_triggered() {
if(change) { if(change) {
updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList()); updateUnfinishedTorrentNumber(downloadingTorrentTab->getNbTorrentsInList());
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList()); updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
downloadingTorrentTab->setInfoBar(tr("All downloads were resumed."));
} }
} }
@ -1405,7 +1378,6 @@ void GUI::on_actionStart_triggered() {
finishedTorrentTab->resumeTorrent(hash); finishedTorrentTab->resumeTorrent(hash);
updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList()); updateFinishedTorrentNumber(finishedTorrentTab->getNbTorrentsInList());
} }
downloadingTorrentTab->setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(BTSession->getTorrentHandle(hash).name()));
} }
} }
} }
@ -1561,7 +1533,8 @@ void GUI::on_actionOptions_triggered() {
} }
// Is executed each time options are saved // Is executed each time options are saved
void GUI::OptionsSaved(QString info, bool deleteOptions) { void GUI::OptionsSaved(bool deleteOptions) {
BTSession->addConsoleMessage(tr("Options were saved successfully."));
bool newSystrayIntegration = options->systrayIntegration(); bool newSystrayIntegration = options->systrayIntegration();
if(newSystrayIntegration && !systrayIntegration) { if(newSystrayIntegration && !systrayIntegration) {
// create the trayicon // create the trayicon
@ -1573,8 +1546,6 @@ void GUI::OptionsSaved(QString info, bool deleteOptions) {
delete myTrayIconMenu; delete myTrayIconMenu;
} }
systrayIntegration = newSystrayIntegration; systrayIntegration = newSystrayIntegration;
// Update info bar
downloadingTorrentTab->setInfoBar(info);
// Update Web UI // Update Web UI
if (options->isWebUiEnabled()) if (options->isWebUiEnabled())
{ {

3
src/GUI.h

@ -161,7 +161,6 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void processDownloadedFiles(QString path, QString url); void processDownloadedFiles(QString path, QString url);
void downloadFromURLList(const QStringList& urls); void downloadFromURLList(const QStringList& urls);
void deleteTorrent(QString hash); void deleteTorrent(QString hash);
void deleteRatioTorrent(QString fileName);
void finishedTorrent(QTorrentHandle& h) const; void finishedTorrent(QTorrentHandle& h) const;
void torrentChecked(QString hash) const; void torrentChecked(QString hash) const;
void updateLists(); void updateLists();
@ -171,7 +170,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void on_actionDecreasePriority_triggered(); void on_actionDecreasePriority_triggered();
// Options slots // Options slots
void on_actionOptions_triggered(); void on_actionOptions_triggered();
void OptionsSaved(QString info, bool deleteOptions); void OptionsSaved(bool deleteOptions);
// HTTP slots // HTTP slots
void on_actionDownload_from_URL_triggered(); void on_actionDownload_from_URL_triggered();

110
src/bittorrent.cpp

@ -148,8 +148,9 @@ void bittorrent::deleteBigRatios() {
QString hash = h.hash(); QString hash = h.hash();
if(getRealRatio(hash) > max_ratio) { if(getRealRatio(hash) > max_ratio) {
QString fileName = h.name(); QString fileName = h.name();
addConsoleMessage(tr("%1 reached the maximum ratio you set.").arg(fileName));
deleteTorrent(hash); deleteTorrent(hash);
emit torrent_ratio_deleted(fileName); //emit torrent_ratio_deleted(fileName);
} }
} }
} }
@ -667,6 +668,10 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) {
// Deleting in a thread to avoid GUI freeze // Deleting in a thread to avoid GUI freeze
deleter->deleteTorrent(savePath, files_arb); deleter->deleteTorrent(savePath, files_arb);
} }
if(permanent)
addConsoleMessage(tr("'%1' was removed permanently.", "'xxx.avi' was removed permanently.").arg(fileName));
else
addConsoleMessage(tr("'%1' was removed.", "'xxx.avi' was removed.").arg(fileName));
emit deletedTorrent(hash); emit deletedTorrent(hash);
} }
@ -803,12 +808,15 @@ bool bittorrent::pauseTorrent(QString hash) {
TorrentsStartTime.remove(hash); TorrentsStartTime.remove(hash);
TorrentsStartData.remove(hash); TorrentsStartData.remove(hash);
} }
if(change) {
addConsoleMessage(tr("'%1' paused.", "e.g: xxx.avi paused.").arg(h.name()));
}
return change; return change;
} }
// Resume a torrent in paused state // Resume a torrent in paused state
bool bittorrent::resumeTorrent(QString hash) { bool bittorrent::resumeTorrent(QString hash) {
bool success = false; bool change = false;
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
if(h.is_valid() && h.is_paused()) { if(h.is_valid() && h.is_paused()) {
if(!(queueingEnabled && (isDownloadQueued(hash)||isUploadQueued(hash)))) { if(!(queueingEnabled && (isDownloadQueued(hash)||isUploadQueued(hash)))) {
@ -818,7 +826,7 @@ bool bittorrent::resumeTorrent(QString hash) {
TorrentsStartTime[hash] = QDateTime::currentDateTime(); TorrentsStartTime[hash] = QDateTime::currentDateTime();
} }
h.resume(); h.resume();
success = true; change = true;
emit resumedTorrent(hash); emit resumedTorrent(hash);
} }
} }
@ -828,13 +836,16 @@ bool bittorrent::resumeTorrent(QString hash) {
int index = torrentsToPauseAfterChecking.indexOf(hash); int index = torrentsToPauseAfterChecking.indexOf(hash);
if(index != -1) { if(index != -1) {
torrentsToPauseAfterChecking.removeAt(index); torrentsToPauseAfterChecking.removeAt(index);
success = true; change = true;
} }
if(queueingEnabled) { if(queueingEnabled) {
updateDownloadQueue(); updateDownloadQueue();
updateUploadQueue(); updateUploadQueue();
} }
return success; if(change) {
addConsoleMessage(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(h.name()));
}
return change;
} }
void bittorrent::pauseAllTorrents() { void bittorrent::pauseAllTorrents() {
@ -926,10 +937,12 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
if(!fromScanDir) { if(!fromScanDir) {
if(!from_url.isNull()) { if(!from_url.isNull()) {
// If download from url, remove temp file // If download from url, remove temp file
QFile::remove(file); QFile::remove(file);
emit duplicateTorrent(from_url); addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(from_url));
//emit duplicateTorrent(from_url);
}else{ }else{
emit duplicateTorrent(file); addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(file));
//emit duplicateTorrent(file);
} }
}else{ }else{
// Delete torrent from scan dir // Delete torrent from scan dir
@ -1028,19 +1041,30 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
} }
// Send torrent addition signal // Send torrent addition signal
if(!from_url.isNull()) { if(!from_url.isNull()) {
emit addedTorrent(from_url, h, fastResume); emit addedTorrent(h);
if(fastResume)
addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(from_url));
else
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(from_url));
}else{ }else{
emit addedTorrent(file, h, fastResume); emit addedTorrent(h);
if(fastResume)
addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(file));
else
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(file));
} }
}catch (invalid_encoding& e) { // Raised by bdecode() }catch (invalid_encoding& e) { // Raised by bdecode()
std::cerr << "Could not decode file, reason: " << e.what() << '\n'; std::cerr << "Could not decode file, reason: " << e.what() << '\n';
// Display warning to tell user we can't decode the torrent file // Display warning to tell user we can't decode the torrent file
if(!from_url.isNull()) { if(!from_url.isNull()) {
emit invalidTorrent(from_url); addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));
//emit invalidTorrent(from_url);
QFile::remove(file); QFile::remove(file);
}else{ }else{
emit invalidTorrent(file); addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red"));
//emit invalidTorrent(file);
} }
addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red"));
if(fromScanDir) { if(fromScanDir) {
// Remove .corrupt file in case it already exists // Remove .corrupt file in case it already exists
QFile::remove(file+".corrupt"); QFile::remove(file+".corrupt");
@ -1051,11 +1075,13 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
catch (invalid_torrent_file&) { // Raised by torrent_info constructor catch (invalid_torrent_file&) { // Raised by torrent_info constructor
// Display warning to tell user we can't decode the torrent file // Display warning to tell user we can't decode the torrent file
if(!from_url.isNull()) { if(!from_url.isNull()) {
emit invalidTorrent(from_url); addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));
//emit invalidTorrent(from_url);
qDebug("File path is: %s", file.toUtf8().data()); qDebug("File path is: %s", file.toUtf8().data());
QFile::remove(file); QFile::remove(file);
}else{ }else{
emit invalidTorrent(file); addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red"));
//emit invalidTorrent(file);
} }
if(fromScanDir) { if(fromScanDir) {
// Remove .corrupt file in case it already exists // Remove .corrupt file in case it already exists
@ -1068,10 +1094,12 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
std::cerr << "Could not decode file, reason: " << e.what() << '\n'; std::cerr << "Could not decode file, reason: " << e.what() << '\n';
// Display warning to tell user we can't decode the torrent file // Display warning to tell user we can't decode the torrent file
if(!from_url.isNull()) { if(!from_url.isNull()) {
emit invalidTorrent(from_url); addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));
//emit invalidTorrent(from_url);
QFile::remove(file); QFile::remove(file);
}else{ }else{
emit invalidTorrent(file); addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red"));
//emit invalidTorrent(file);
} }
if(fromScanDir) { if(fromScanDir) {
// Remove .corrupt file in case it already exists // Remove .corrupt file in case it already exists
@ -1408,6 +1436,31 @@ void bittorrent::saveFastResumeAndRatioData() {
} }
} }
QStringList bittorrent::getConsoleMessages() const {
return consoleMessages;
}
QStringList bittorrent::getPeerBanMessages() const {
return peerBanMessages;
}
void bittorrent::addConsoleMessage(QString msg, QColor color) {
if(consoleMessages.size() > 100) {
consoleMessages.removeFirst();
}
consoleMessages.append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + msg + QString::fromUtf8("</i></font>"));
}
void bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) {
if(peerBanMessages.size() > 100) {
peerBanMessages.removeFirst();
}
if(from_ipfilter)
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was blocked due to your IP filter</i>", "x.y.z.w was blocked").arg(ip));
else
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was banned due to corrupt pieces</i>", "x.y.z.w was banned").arg(ip));
}
void bittorrent::saveFastResumeAndRatioData(QString hash) { void bittorrent::saveFastResumeAndRatioData(QString hash) {
QString file; QString file;
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
@ -1696,7 +1749,8 @@ void bittorrent::readAlerts() {
} }
else if (dynamic_cast<listen_failed_alert*>(a.get())) { else if (dynamic_cast<listen_failed_alert*>(a.get())) {
// Level: fatal // Level: fatal
emit portListeningFailure(); addConsoleMessage(tr("Couldn't listen on any of the given ports."), QString::fromUtf8("red"));
//emit portListeningFailure();
} }
else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())) { else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())) {
// Level: fatal // Level: fatal
@ -1727,24 +1781,33 @@ void bittorrent::readAlerts() {
} }
} }
else if (portmap_error_alert* p = dynamic_cast<portmap_error_alert*>(a.get())) { else if (portmap_error_alert* p = dynamic_cast<portmap_error_alert*>(a.get())) {
emit UPnPError(QString(p->msg().c_str())); addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(QString(p->msg().c_str())), QColor("red"));
//emit UPnPError(QString(p->msg().c_str()));
} }
else if (portmap_alert* p = dynamic_cast<portmap_alert*>(a.get())) { else if (portmap_alert* p = dynamic_cast<portmap_alert*>(a.get())) {
qDebug("UPnP Success, msg: %s", p->msg().c_str()); qDebug("UPnP Success, msg: %s", p->msg().c_str());
emit UPnPSuccess(QString(p->msg().c_str())); addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping successful, message: %1").arg(QString(p->msg().c_str())), QColor("blue"));
//emit UPnPSuccess(QString(p->msg().c_str()));
} }
else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())) { else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())) {
emit peerBlocked(QString::fromUtf8(p->ip.to_string().c_str())); addPeerBanMessage(QString(p->ip.to_string().c_str()), true);
//emit peerBlocked(QString::fromUtf8(p->ip.to_string().c_str()));
}
else if (peer_ban_alert* p = dynamic_cast<peer_ban_alert*>(a.get())) {
addPeerBanMessage(QString(p->ip.address().to_string().c_str()), false);
//emit peerBlocked(QString::fromUtf8(p->ip.to_string().c_str()));
} }
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) { else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
if(h.is_valid()){ if(h.is_valid()){
qDebug("/!\\ Fast resume failed for %s, reason: %s", h.name().toUtf8().data(), p->msg().c_str()); qDebug("/!\\ Fast resume failed for %s, reason: %s", h.name().toUtf8().data(), p->msg().c_str());
emit fastResumeDataRejected(h.name()); addConsoleMessage(tr("Fast resume data was rejected for torrent %1, checking again...").arg(h.name()), QString::fromUtf8("red"));
//emit fastResumeDataRejected(h.name());
} }
} }
else if (url_seed_alert* p = dynamic_cast<url_seed_alert*>(a.get())) { else if (url_seed_alert* p = dynamic_cast<url_seed_alert*>(a.get())) {
emit urlSeedProblem(QString::fromUtf8(p->url.c_str()), QString::fromUtf8(p->msg().c_str())); addConsoleMessage(tr("Url seed lookup failed for url: %1, message: %2").arg(QString::fromUtf8(p->url.c_str())).arg(QString::fromUtf8(p->msg().c_str())), QString::fromUtf8("red"));
//emit urlSeedProblem(QString::fromUtf8(p->url.c_str()), QString::fromUtf8(p->msg().c_str()));
} }
else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) { else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
@ -1884,7 +1947,8 @@ QString bittorrent::getSavePath(QString hash) {
// download the torrent file to a tmp location, then // download the torrent file to a tmp location, then
// add it to download list // add it to download list
void bittorrent::downloadFromUrl(QString url) { void bittorrent::downloadFromUrl(QString url) {
emit aboutToDownloadFromUrl(url); addConsoleMessage(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(url), QPalette::WindowText);
//emit aboutToDownloadFromUrl(url);
// Launch downloader thread // Launch downloader thread
downloader->downloadUrl(url); downloader->downloadUrl(url);
} }

32
src/bittorrent.h

@ -26,6 +26,8 @@
#include <QPair> #include <QPair>
#include <QStringList> #include <QStringList>
#include <QDateTime> #include <QDateTime>
#include <QApplication>
#include <QPalette>
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include <libtorrent/ip_filter.hpp> #include <libtorrent/ip_filter.hpp>
@ -38,7 +40,7 @@ class deleteThread;
class QTimer; class QTimer;
class FilterParserThread; class FilterParserThread;
class bittorrent : public QObject{ class bittorrent : public QObject {
Q_OBJECT Q_OBJECT
private: private:
@ -56,6 +58,8 @@ class bittorrent : public QObject{
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;
QHash<QString, QHash<QString, QString> > trackersErrors; QHash<QString, QHash<QString, QString> > trackersErrors;
QStringList consoleMessages;
QStringList peerBanMessages;
deleteThread *deleter; deleteThread *deleter;
QStringList finishedTorrents; QStringList finishedTorrents;
QStringList unfinishedTorrents; QStringList unfinishedTorrents;
@ -114,6 +118,8 @@ class bittorrent : public QObject{
bool isDownloadQueued(QString hash) const; bool isDownloadQueued(QString hash) const;
bool isUploadQueued(QString hash) const; bool isUploadQueued(QString hash) const;
int loadTorrentPriority(QString hash); int loadTorrentPriority(QString hash);
QStringList getConsoleMessages() const;
QStringList getPeerBanMessages() 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);
@ -177,6 +183,8 @@ class bittorrent : public QObject{
void setMaxActiveDownloads(int val); void setMaxActiveDownloads(int val);
void setMaxActiveTorrents(int val); void setMaxActiveTorrents(int val);
void setETACalculation(bool enable); void setETACalculation(bool enable);
void addConsoleMessage(QString msg, QColor color=QApplication::palette().color(QPalette::WindowText));
void addPeerBanMessage(QString msg, bool from_ipfilter);
protected slots: protected slots:
void scanDirectory(); void scanDirectory();
@ -187,29 +195,29 @@ class bittorrent : public QObject{
void deleteBigRatios(); void deleteBigRatios();
signals: signals:
void invalidTorrent(QString path); //void invalidTorrent(QString path);
void duplicateTorrent(QString path); //void duplicateTorrent(QString path);
void addedTorrent(QString path, QTorrentHandle& h, bool fastResume); void addedTorrent(QTorrentHandle& h);
void deletedTorrent(QString hash); void deletedTorrent(QString hash);
void pausedTorrent(QString hash); void pausedTorrent(QString hash);
void resumedTorrent(QString hash); void resumedTorrent(QString hash);
void finishedTorrent(QTorrentHandle& h); void finishedTorrent(QTorrentHandle& h);
void fullDiskError(QTorrentHandle& h); void fullDiskError(QTorrentHandle& h);
void trackerError(QString hash, QString time, QString msg); void trackerError(QString hash, QString time, QString msg);
void portListeningFailure(); //void portListeningFailure();
void trackerAuthenticationRequired(QTorrentHandle& h); void trackerAuthenticationRequired(QTorrentHandle& h);
void scanDirFoundTorrents(const QStringList& pathList); void scanDirFoundTorrents(const QStringList& pathList);
void newDownloadedTorrent(QString path, QString url); void newDownloadedTorrent(QString path, QString url);
void aboutToDownloadFromUrl(QString url); //void aboutToDownloadFromUrl(QString url);
void updateFileSize(QString hash); void updateFileSize(QString hash);
void peerBlocked(QString); //void peerBlocked(QString);
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);
void updateFinishedTorrentNumber(); void updateFinishedTorrentNumber();
void updateUnfinishedTorrentNumber(); void updateUnfinishedTorrentNumber();
void forceUnfinishedListUpdate(); void forceUnfinishedListUpdate();

94
src/download.ui

@ -57,95 +57,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QTabWidget" name="tabBottom" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>142</height>
</size>
</property>
<property name="tabPosition" >
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="log_tab" >
<attribute name="title" >
<string>Log</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item>
<widget class="QTextBrowser" name="infoBar" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>120</height>
</size>
</property>
<property name="contextMenuPolicy" >
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="filter_tab" >
<attribute name="title" >
<string>IP filter</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item>
<widget class="QTextBrowser" name="textBlockedUsers" >
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>123</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout> </layout>
<action name="actionStart" > <action name="actionStart" >
<property name="text" > <property name="text" >
@ -162,11 +73,6 @@
<string>Delete</string> <string>Delete</string>
</property> </property>
</action> </action>
<action name="actionClearLog" >
<property name="text" >
<string>Clear</string>
</property>
</action>
<action name="actionPreview_file" > <action name="actionPreview_file" >
<property name="text" > <property name="text" >
<string>Preview file</string> <string>Preview file</string>

98
src/downloadingTorrents.cpp

@ -39,7 +39,6 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png"))); actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png"))); actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png")));
actionDelete->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png"))); actionDelete->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png")));
actionClearLog->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png")));
actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png"))); actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png")));
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
actionSet_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))); actionSet_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png")));
@ -68,16 +67,7 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
downloadList->hideColumn(HASH); downloadList->hideColumn(HASH);
loadHiddenColumns(); loadHiddenColumns();
connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), this, SLOT(torrentAdded(QString, QTorrentHandle&, bool))); connect(BTSession, SIGNAL(addedTorrent(QTorrentHandle&)), this, SLOT(torrentAdded(QTorrentHandle&)));
connect(BTSession, SIGNAL(duplicateTorrent(QString)), this, SLOT(torrentDuplicate(QString)));
connect(BTSession, SIGNAL(invalidTorrent(QString)), this, SLOT(torrentCorrupted(QString)));
connect(BTSession, SIGNAL(portListeningFailure()), this, SLOT(portListeningFailure()));
connect(BTSession, SIGNAL(peerBlocked(QString)), this, SLOT(addLogPeerBlocked(const QString)));
connect(BTSession, SIGNAL(fastResumeDataRejected(QString)), this, SLOT(addFastResumeRejectedAlert(QString)));
connect(BTSession, SIGNAL(aboutToDownloadFromUrl(QString)), this, SLOT(displayDownloadingUrlInfos(QString)));
connect(BTSession, SIGNAL(urlSeedProblem(QString, QString)), this, SLOT(addUrlSeedError(QString, QString)));
connect(BTSession, SIGNAL(UPnPError(QString)), this, SLOT(displayUPnPError(QString)));
connect(BTSession, SIGNAL(UPnPSuccess(QString)), this, SLOT(displayUPnPSuccess(QString)));
connect(BTSession, SIGNAL(forceUnfinishedListUpdate()), this, SLOT(updateDlList())); connect(BTSession, SIGNAL(forceUnfinishedListUpdate()), this, SLOT(updateDlList()));
// Load last columns width for download list // Load last columns width for download list
@ -93,7 +83,6 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
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&)));
connect(infoBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoBarMenu(const QPoint&)));
// Actions // Actions
connect(actionPause, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPause_triggered())); connect(actionPause, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPause_triggered()));
connect(actionStart, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionStart_triggered())); connect(actionStart, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionStart_triggered()));
@ -117,7 +106,7 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
connect(actionHOSColPriority, SIGNAL(triggered()), this, SLOT(hideOrShowColumnPriority())); connect(actionHOSColPriority, SIGNAL(triggered()), this, SLOT(hideOrShowColumnPriority()));
// Set info Bar infos // Set info Bar infos
setInfoBar(tr("qBittorrent %1 started.", "e.g: qBittorrent v0.x started.").arg(QString::fromUtf8(""VERSION))); BTSession->addConsoleMessage(tr("qBittorrent %1 started.", "e.g: qBittorrent v0.x started.").arg(QString::fromUtf8(""VERSION)));
qDebug("Download tab built"); qDebug("Download tab built");
} }
@ -142,16 +131,6 @@ void DownloadingTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) {
emit torrentDoubleClicked(hash, false); emit torrentDoubleClicked(hash, false);
} }
void DownloadingTorrents::addLogPeerBlocked(QString ip) {
static unsigned int nbLines = 0;
++nbLines;
if(nbLines > 200) {
textBlockedUsers->clear();
nbLines = 1;
}
textBlockedUsers->append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was blocked</i>", "x.y.z.w was blocked").arg(ip));
}
unsigned int DownloadingTorrents::getNbTorrentsInList() const { unsigned int DownloadingTorrents::getNbTorrentsInList() const {
return nbTorrents; return nbTorrents;
} }
@ -176,12 +155,6 @@ QString DownloadingTorrents::getHashFromRow(unsigned int row) const {
return DLListModel->data(DLListModel->index(row, HASH)).toString(); return DLListModel->data(DLListModel->index(row, HASH)).toString();
} }
void DownloadingTorrents::setBottomTabEnabled(unsigned int index, bool b){
if(index and !b)
tabBottom->setCurrentIndex(0);
tabBottom->setTabEnabled(index, b);
}
// Show torrent properties dialog // Show torrent properties dialog
void DownloadingTorrents::showProperties(const QModelIndex &index) { void DownloadingTorrents::showProperties(const QModelIndex &index) {
showPropertiesFromHash(DLListModel->data(DLListModel->index(index.row(), HASH)).toString()); showPropertiesFromHash(DLListModel->data(DLListModel->index(index.row(), HASH)).toString());
@ -214,34 +187,6 @@ void DownloadingTorrents::deleteTorrent(QString hash) {
emit unfinishedTorrentsNumberChanged(nbTorrents); emit unfinishedTorrentsNumberChanged(nbTorrents);
} }
void DownloadingTorrents::displayUPnPError(QString msg) {
setInfoBar(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(msg), QColor("red"));
}
void DownloadingTorrents::displayUPnPSuccess(QString msg) {
DownloadingTorrents::setInfoBar(tr("UPnP/NAT-PMP: Port mapping successful, message: %1").arg(msg), QColor("blue"));
}
// Update Info Bar information
void DownloadingTorrents::setInfoBar(QString info, QColor color) {
static unsigned int nbLines = 0;
++nbLines;
// Check log size, clear it if too big
if(nbLines > 200) {
infoBar->clear();
nbLines = 1;
}
infoBar->append(QString::fromUtf8("<font color='grey'>")+ QTime::currentTime().toString(QString::fromUtf8("hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + info + QString::fromUtf8("</i></font>"));
}
void DownloadingTorrents::addFastResumeRejectedAlert(QString name) {
setInfoBar(tr("Fast resume data was rejected for torrent %1, checking again...").arg(name), QString::fromUtf8("red"));
}
void DownloadingTorrents::addUrlSeedError(QString url, QString msg) {
setInfoBar(tr("Url seed lookup failed for url: %1, message: %2").arg(url).arg(msg), QString::fromUtf8("red"));
}
void DownloadingTorrents::on_actionSet_download_limit_triggered() { void DownloadingTorrents::on_actionSet_download_limit_triggered() {
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
QModelIndex index; QModelIndex index;
@ -481,10 +426,6 @@ void DownloadingTorrents::hideOrShowColumnPriority() {
hideOrShowColumn(PRIORITY); hideOrShowColumn(PRIORITY);
} }
void DownloadingTorrents::on_actionClearLog_triggered() {
infoBar->clear();
}
// getter, return the action hide or show whose id is index // getter, return the action hide or show whose id is index
QAction* DownloadingTorrents::getActionHoSCol(int index) { QAction* DownloadingTorrents::getActionHoSCol(int index) {
switch(index) { switch(index) {
@ -535,14 +476,6 @@ QStringList DownloadingTorrents::getSelectedTorrents(bool only_one) const{
return res; return res;
} }
void DownloadingTorrents::displayInfoBarMenu(const QPoint& pos) {
// Log Menu
QMenu myLogMenu(this);
myLogMenu.addAction(actionClearLog);
// XXX: Why mapToGlobal() is not enough?
myLogMenu.exec(mapToGlobal(pos)+QPoint(44,305));
}
void DownloadingTorrents::sortProgressColumnDelayed() { void DownloadingTorrents::sortProgressColumnDelayed() {
if(delayedSorting) { if(delayedSorting) {
sortDownloadListFloat(PROGRESS, delayedSortingOrder); sortDownloadListFloat(PROGRESS, delayedSortingOrder);
@ -865,7 +798,7 @@ bool DownloadingTorrents::loadColWidthDLList() {
} }
// Called when a torrent is added // Called when a torrent is added
void DownloadingTorrents::torrentAdded(QString path, QTorrentHandle& h, bool fastResume) { void DownloadingTorrents::torrentAdded(QTorrentHandle& h) {
QString hash = h.hash(); QString hash = h.hash();
if(BTSession->isFinished(hash)) { if(BTSession->isFinished(hash)) {
return; return;
@ -891,25 +824,10 @@ void DownloadingTorrents::torrentAdded(QString path, QTorrentHandle& h, bool fas
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/connecting.png"))), Qt::DecorationRole); DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/connecting.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("grey")); setRowColor(row, QString::fromUtf8("grey"));
} }
if(!fastResume) {
setInfoBar(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(path));
}else{
setInfoBar(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(path));
}
++nbTorrents; ++nbTorrents;
emit unfinishedTorrentsNumberChanged(nbTorrents); emit unfinishedTorrentsNumberChanged(nbTorrents);
} }
// Called when trying to add a duplicate torrent
void DownloadingTorrents::torrentDuplicate(QString path) {
setInfoBar(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(path));
}
void DownloadingTorrents::torrentCorrupted(QString path) {
setInfoBar(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(path), QString::fromUtf8("red"));
setInfoBar(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red"));
}
void DownloadingTorrents::updateFileSizeAndProgress(QString hash) { void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
int row = getRowFromHash(hash); int row = getRowFromHash(hash);
Q_ASSERT(row != -1); Q_ASSERT(row != -1);
@ -918,12 +836,6 @@ void DownloadingTorrents::updateFileSizeAndProgress(QString hash) {
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
// in the given range.
void DownloadingTorrents::portListeningFailure() {
setInfoBar(tr("Couldn't listen on any of the given ports."), QString::fromUtf8("red"));
}
// Set the color of a row in data model // Set the color of a row in data model
void DownloadingTorrents::setRowColor(int row, QColor color) { void DownloadingTorrents::setRowColor(int row, QColor color) {
unsigned int nbColumns = DLListModel->columnCount()-1; unsigned int nbColumns = DLListModel->columnCount()-1;
@ -943,7 +855,3 @@ int DownloadingTorrents::getRowFromHash(QString hash) const{
} }
return -1; return -1;
} }
void DownloadingTorrents::displayDownloadingUrlInfos(QString url) {
setInfoBar(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(url), QPalette::WindowText);
}

15
src/downloadingTorrents.h

@ -63,27 +63,18 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void torrentFinished(QString hash); void torrentFinished(QString hash);
protected slots: protected slots:
void addLogPeerBlocked(QString);
void addFastResumeRejectedAlert(QString);
void addUrlSeedError(QString url, QString msg);
void on_actionSet_download_limit_triggered(); void on_actionSet_download_limit_triggered();
void notifyTorrentDoubleClicked(const QModelIndex& index); void notifyTorrentDoubleClicked(const QModelIndex& index);
void on_actionSet_upload_limit_triggered(); void on_actionSet_upload_limit_triggered();
void displayDLListMenu(const QPoint& pos); void displayDLListMenu(const QPoint& pos);
void displayDLHoSMenu(const QPoint&); void displayDLHoSMenu(const QPoint&);
void on_actionClearLog_triggered();
void displayInfoBarMenu(const QPoint& pos);
void addTorrent(QString hash); void addTorrent(QString hash);
void sortDownloadList(int index, Qt::SortOrder startSortOrder=Qt::AscendingOrder, bool fromLoadColWidth=false); void sortDownloadList(int index, Qt::SortOrder startSortOrder=Qt::AscendingOrder, bool fromLoadColWidth=false);
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;
void torrentAdded(QString path, QTorrentHandle& h, bool fastResume); void torrentAdded(QTorrentHandle& h);
void torrentDuplicate(QString path);
void torrentCorrupted(QString path);
void portListeningFailure();
void setRowColor(int row, QColor color); void setRowColor(int row, QColor color);
void displayDownloadingUrlInfos(QString url);
void showProperties(const QModelIndex &index); void showProperties(const QModelIndex &index);
void hideOrShowColumnName(); void hideOrShowColumnName();
void hideOrShowColumnSize(); void hideOrShowColumnSize();
@ -94,16 +85,12 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void hideOrShowColumnRatio(); void hideOrShowColumnRatio();
void hideOrShowColumnEta(); void hideOrShowColumnEta();
void hideOrShowColumnPriority(); void hideOrShowColumnPriority();
void displayUPnPError(QString msg);
void displayUPnPSuccess(QString msg);
public slots: public slots:
void updateDlList(); void updateDlList();
void setInfoBar(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
void pauseTorrent(QString hash); void pauseTorrent(QString hash);
void resumeTorrent(QString hash); void resumeTorrent(QString hash);
void deleteTorrent(QString hash); void deleteTorrent(QString hash);
void setBottomTabEnabled(unsigned int index, bool b);
void propertiesSelection(); void propertiesSelection();
void sortProgressColumnDelayed(); void sortProgressColumnDelayed();
void updateFileSizeAndProgress(QString hash); void updateFileSizeAndProgress(QString hash);

2
src/eventmanager.cpp

@ -65,7 +65,7 @@ bool EventManager::isUpdated(ulong r) const
return (r < revision); return (r < revision);
} }
void EventManager::addedTorrent(QString, QTorrentHandle& h) void EventManager::addedTorrent(QTorrentHandle& h)
{ {
QVariantMap event; QVariantMap event;
event["type"] = QVariant("add"); event["type"] = QVariant("add");

2
src/eventmanager.h

@ -50,7 +50,7 @@ class EventManager : public QObject
void updated(); void updated();
public slots: public slots:
void addedTorrent(QString path, QTorrentHandle& h); void addedTorrent(QTorrentHandle& h);
void deletedTorrent(QString hash); void deletedTorrent(QString hash);
void modifiedTorrent(QTorrentHandle h); void modifiedTorrent(QTorrentHandle h);
}; };

4
src/httpserver.cpp

@ -38,10 +38,10 @@ HttpServer::HttpServer(bittorrent *BTSession, int msec, QObject* parent) : QTcpS
{ {
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid()) if(h.is_valid())
manager->addedTorrent(QString(), h); manager->addedTorrent(h);
} }
//connect BTSession to manager //connect BTSession to manager
connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), manager, SLOT(addedTorrent(QString, 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); QTimer *timer = new QTimer(this);

4
src/options_imp.cpp

@ -816,7 +816,7 @@ void options_imp::on_buttonBox_accepted(){
applyButton->setEnabled(false); applyButton->setEnabled(false);
// set infobar text // set infobar text
this->hide(); this->hide();
emit status_changed(tr("Options were saved successfully."), true); emit status_changed(true);
}else{ }else{
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
accept(); accept();
@ -826,7 +826,7 @@ void options_imp::on_buttonBox_accepted(){
void options_imp::applySettings(QAbstractButton* button) { void options_imp::applySettings(QAbstractButton* button) {
if(button == applyButton){ if(button == applyButton){
saveOptions(); saveOptions();
emit status_changed(tr("Options were saved successfully."), false); emit status_changed(false);
} }
} }

2
src/options_imp.h

@ -151,7 +151,7 @@ class options_imp : public QDialog, private Ui::Dialog {
void useStyle(); void useStyle();
signals: signals:
void status_changed(QString, bool) const; void status_changed(bool) const;
void exitWithCancel(); void exitWithCancel();
}; };

29
src/torrentAddition.h

@ -34,6 +34,7 @@
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
#include "bittorrent.h"
#include "misc.h" #include "misc.h"
#include "PropListDelegate.h" #include "PropListDelegate.h"
#include "ui_addTorrentDialog.h" #include "ui_addTorrentDialog.h"
@ -44,11 +45,8 @@ using namespace libtorrent;
class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
Q_OBJECT Q_OBJECT
signals:
void setInfoBarGUI(QString info, QColor color);
void torrentAddition(QString filePath, bool fromScanDir, QString from_url);
private: private:
bittorrent *BTSession;
QString fileName; QString fileName;
QString hash; QString hash;
QString filePath; QString filePath;
@ -59,9 +57,10 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
unsigned int nbFiles; unsigned int nbFiles;
public: public:
torrentAdditionDialog(QWidget *parent) : QDialog(parent) { torrentAdditionDialog(QWidget *parent, bittorrent* _BTSession) : QDialog(parent) {
setupUi(this); setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
BTSession = _BTSession;
// Set Properties list model // Set Properties list model
PropListModel = new QStandardItemModel(0,5); PropListModel = new QStandardItemModel(0,5);
PropListModel->setHeaderData(NAME, Qt::Horizontal, tr("File name")); PropListModel->setHeaderData(NAME, Qt::Horizontal, tr("File name"));
@ -126,12 +125,12 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
catch (invalid_torrent_file&){ // Raised by torrent_info constructor catch (invalid_torrent_file&){ // Raised by torrent_info constructor
// Display warning to tell user we can't decode the torrent file // Display warning to tell user we can't decode the torrent file
if(!from_url.isNull()){ if(!from_url.isNull()){
emit setInfoBarGUI(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
QFile::remove(filePath); QFile::remove(filePath);
}else{ }else{
emit setInfoBarGUI(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red"));
} }
emit setInfoBarGUI(tr("This file is either corrupted or this isn't a torrent."), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."), QString::fromUtf8("red"));
if(fromScanDir){ if(fromScanDir){
// Remove .corrupt file in case it already exists // Remove .corrupt file in case it already exists
QFile::remove(filePath+QString::fromUtf8(".corrupt")); QFile::remove(filePath+QString::fromUtf8(".corrupt"));
@ -144,13 +143,13 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
std::cerr << "Could not decode file, reason: " << e.what() << '\n'; std::cerr << "Could not decode file, reason: " << e.what() << '\n';
// Display warning to tell user we can't decode the torrent file // Display warning to tell user we can't decode the torrent file
if(!from_url.isNull()){ if(!from_url.isNull()){
emit setInfoBarGUI(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
QFile::remove(filePath); QFile::remove(filePath);
}else{ }else{
emit setInfoBarGUI(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red"));
} }
qDebug("path is %s", filePath.toUtf8().data()); qDebug("path is %s", filePath.toUtf8().data());
emit setInfoBarGUI(tr("This file is either corrupted or this isn't a torrent."), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."), QString::fromUtf8("red"));
if(fromScanDir){ if(fromScanDir){
// Remove .corrupt file in case it already exists // Remove .corrupt file in case it already exists
QFile::remove(filePath+QString::fromUtf8(".corrupt")); QFile::remove(filePath+QString::fromUtf8(".corrupt"));
@ -162,13 +161,13 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
catch(std::exception& e){ catch(std::exception& e){
std::cerr << "Could not decode file, reason: " << e.what() << '\n'; std::cerr << "Could not decode file, reason: " << e.what() << '\n';
if(!from_url.isNull()){ if(!from_url.isNull()){
emit setInfoBarGUI(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
QFile::remove(filePath); QFile::remove(filePath);
}else{ }else{
emit setInfoBarGUI(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red"));
} }
qDebug("path is %s", filePath.toUtf8().data()); qDebug("path is %s", filePath.toUtf8().data());
emit setInfoBarGUI(tr("This file is either corrupted or this isn't a torrent."), QString::fromUtf8("red")); BTSession->addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."), QString::fromUtf8("red"));
if(fromScanDir){ if(fromScanDir){
// Remove .corrupt file in case it already exists // Remove .corrupt file in case it already exists
QFile::remove(filePath+QString::fromUtf8(".corrupt")); QFile::remove(filePath+QString::fromUtf8(".corrupt"));
@ -469,7 +468,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
// save filtered files // save filtered files
savePiecesPriorities(); savePiecesPriorities();
// Add to download list // Add to download list
emit torrentAddition(filePath, fromScanDir, from_url); BTSession->addTorrent(filePath, fromScanDir, from_url);
close(); close();
} }
}; };

Loading…
Cancel
Save