Browse Source

- qBittorrent no longer listens on a random port whenever it receives a listen_failed_alert (because it may correspond to another network interface)

- Display a "disconnected" icon in status bar whenever qBittorrent fails to listen on the selected port
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
2168d5a30e
  1. BIN
      src/Icons/skin/disconnected.png
  2. 12
      src/bittorrent.cpp
  3. 1
      src/icons.qrc
  4. 5
      src/statusbar.h

BIN
src/Icons/skin/disconnected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

12
src/bittorrent.cpp

@ -1705,18 +1705,6 @@ void Bittorrent::readAlerts() {
} }
} }
#endif #endif
else if (listen_failed_alert* p = dynamic_cast<listen_failed_alert*>(a.get())) {
// Level: fatal
int tried_port = p->endpoint.port();
srand(time(0));
int fallback_port = tried_port;
do {
fallback_port = rand() % 64512 + 1024;
} while(fallback_port == tried_port);
addConsoleMessage(tr("Couldn't listen on port %1, using %2 instead.").arg(QString::number(tried_port)).arg(QString::number(fallback_port)), QString::fromUtf8("red"));
setListeningPort(fallback_port);
//emit portListeningFailure();
}
/*else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) { /*else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
qDebug("Received a torrent_paused_alert for %s", h.hash().toLocal8Bit().data()); qDebug("Received a torrent_paused_alert for %s", h.hash().toLocal8Bit().data());

1
src/icons.qrc

@ -60,6 +60,7 @@
<file>Icons/skin/exit.png</file> <file>Icons/skin/exit.png</file>
<file>Icons/skin/delete_all.png</file> <file>Icons/skin/delete_all.png</file>
<file>Icons/skin/splash.png</file> <file>Icons/skin/splash.png</file>
<file>Icons/skin/disconnected.png</file>
<file>Icons/skin/decrease.png</file> <file>Icons/skin/decrease.png</file>
<file>Icons/skin/uploading.png</file> <file>Icons/skin/uploading.png</file>
<file>Icons/skin/filterall.png</file> <file>Icons/skin/filterall.png</file>

5
src/statusbar.h

@ -142,6 +142,10 @@ public slots:
void refreshStatusBar() { void refreshStatusBar() {
// Update connection status // Update connection status
session_status sessionStatus = BTSession->getSessionStatus(); session_status sessionStatus = BTSession->getSessionStatus();
if(!BTSession->getSession()->is_listening()) {
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/disconnected.png")));
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection Status:")+QString::fromUtf8("</b><br>")+tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections."));
} else {
if(sessionStatus.has_incoming_connections) { if(sessionStatus.has_incoming_connections) {
// Connection OK // Connection OK
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/connected.png"))); connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/connected.png")));
@ -150,6 +154,7 @@ public slots:
connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/firewalled.png"))); connecStatusLblIcon->setPixmap(QPixmap(QString::fromUtf8(":/Icons/skin/firewalled.png")));
connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection status:")+QString::fromUtf8("</b><br>")+QString::fromUtf8("<i>")+tr("No direct connections. This may indicate network configuration problems.")+QString::fromUtf8("</i>")); connecStatusLblIcon->setToolTip(QString::fromUtf8("<b>")+tr("Connection status:")+QString::fromUtf8("</b><br>")+QString::fromUtf8("<i>")+tr("No direct connections. This may indicate network configuration problems.")+QString::fromUtf8("</i>"));
} }
}
// Update Number of DHT nodes // Update Number of DHT nodes
if(BTSession->isDHTEnabled()) { if(BTSession->isDHTEnabled()) {
DHTLbl->setVisible(true); DHTLbl->setVisible(true);

Loading…
Cancel
Save