Browse Source

- Ok. torrentless downloads paused state is now restored properly (once metadata is received)

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
e429126934
  1. 14
      src/GUI.cpp
  2. 1
      src/GUI.h
  3. 15
      src/bittorrent.cpp
  4. 1
      src/bittorrent.h

14
src/GUI.cpp

@ -143,6 +143,7 @@ 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(torrentPaused(QTorrentHandle&)), this, SLOT(setPaused(QTorrentHandle&)));
qDebug("create tabWidget"); qDebug("create tabWidget");
tabs = new QTabWidget(); tabs = new QTabWidget();
// Download torrents tab // Download torrents tab
@ -443,14 +444,20 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
// Download will be paused by libtorrent. Updating GUI information accordingly // Download will be paused by libtorrent. Updating GUI information accordingly
QString hash = h.hash(); QString hash = h.hash();
qDebug("Full disk error, pausing torrent %s", hash.toLocal8Bit().data()); qDebug("Full disk error, pausing torrent %s", hash.toLocal8Bit().data());
setPaused(h);
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::setPaused(QTorrentHandle &h) const {
Q_ASSERT(h.is_paused());
qDebug("Marking torrent %s as paused", h.hash().toUtf8().data());
if(h.is_seed()) { if(h.is_seed()) {
// In finished list // In finished list
qDebug("Automatically paused torrent was in finished list"); qDebug("Automatically paused torrent was in finished list");
finishedTorrentTab->pauseTorrent(hash); finishedTorrentTab->pauseTorrent(h.hash());
}else{ }else{
downloadingTorrentTab->pauseTorrent(hash); downloadingTorrentTab->pauseTorrent(h.hash());
} }
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() {
@ -1630,3 +1637,4 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
downloadFromURL *downloadFromURLDialog = new downloadFromURL(this); downloadFromURL *downloadFromURLDialog = new downloadFromURL(this);
connect(downloadFromURLDialog, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), BTSession, SLOT(downloadFromURLList(const QStringList&))); connect(downloadFromURLDialog, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), BTSession, SLOT(downloadFromURLList(const QStringList&)));
} }

1
src/GUI.h

@ -143,6 +143,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void fullDiskError(QTorrentHandle& h, QString msg) const; void fullDiskError(QTorrentHandle& h, QString msg) const;
void handleDownloadFromUrlFailure(QString, QString) const; void handleDownloadFromUrlFailure(QString, QString) const;
void createSystrayDelayed(); void createSystrayDelayed();
void setPaused(QTorrentHandle &h) const;
// Keyboard shortcuts // Keyboard shortcuts
void createKeyboardShortcuts(); void createKeyboardShortcuts();
void displayDownTab() const; void displayDownTab() const;

15
src/bittorrent.cpp

@ -1255,7 +1255,15 @@ void bittorrent::readAlerts() {
} }
else if (metadata_received_alert* p = dynamic_cast<metadata_received_alert*>(a.get())) { else if (metadata_received_alert* p = dynamic_cast<metadata_received_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
if(h.is_valid()) {
qDebug("Received metadata for %s", h.hash().toUtf8().data());
emit metadataReceived(h); emit metadataReceived(h);
if(h.is_paused()) {
// XXX: Unfortunately libtorrent-rasterbar does not send a torrent_paused_alert
// and the torrent can be paused when metadata is received
emit torrentPaused(h);
}
}
} }
else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())) { else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
@ -1269,6 +1277,13 @@ void bittorrent::readAlerts() {
addConsoleMessage(tr("Couldn't listen on any of the given ports."), QString::fromUtf8("red")); addConsoleMessage(tr("Couldn't listen on any of the given ports."), QString::fromUtf8("red"));
//emit portListeningFailure(); //emit portListeningFailure();
} }
else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {
QTorrentHandle h(p->handle);
qDebug("Received a torrent_paused_alert for %s", h.hash().toUtf8().data());
if(h.is_valid()) {
emit torrentPaused(h);
}
}
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) { else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
// Level: fatal // Level: fatal
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);

1
src/bittorrent.h

@ -186,6 +186,7 @@ class bittorrent : public QObject {
void downloadFromUrlFailure(QString url, QString reason); void downloadFromUrlFailure(QString url, QString reason);
void torrentFinishedChecking(QTorrentHandle& h); void torrentFinishedChecking(QTorrentHandle& h);
void metadataReceived(QTorrentHandle &h); void metadataReceived(QTorrentHandle &h);
void torrentPaused(QTorrentHandle &h);
}; };
#endif #endif

Loading…
Cancel
Save