From 4ca852c2b3e76ce3aa79968e0f5c54090ed2a18b Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 29 Mar 2007 14:49:01 +0000 Subject: [PATCH] - Added a message log when an UPnP WAN service is detected --- TODO | 2 +- src/GUI.cpp | 6 ++++++ src/GUI.h | 1 + src/UPnP.cpp | 2 +- src/UPnP.h | 1 + src/bittorrent.cpp | 6 ++++++ src/bittorrent.h | 2 ++ 7 files changed, 18 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index a46b84940..6319f684e 100644 --- a/TODO +++ b/TODO @@ -43,5 +43,5 @@ - Use tooltips to explain options - Exit confirmation only if there are active downloads (display number of downloads) - SMARTER - Make use of QNetworkInterface (could be useful ?) -- Display more info in log (PeX, UPnP, DHT w/ ports...) +- Display more info in log (UPnP successful) - Possibility to disable the trayicon \ No newline at end of file diff --git a/src/GUI.cpp b/src/GUI.cpp index 796d6901e..2eff51191 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -106,6 +106,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ tabs->setTabText(0, tr("Transfers") +" (0)"); #ifndef NO_UPNP connect(&BTSession, SIGNAL(noWanServiceDetected()), this, SLOT(displayNoUPnPWanServiceDetected())); + connect(&BTSession, SIGNAL(wanServiceDetected()), this, SLOT(displayUPnPWanServiceDetected())); #endif connect(&BTSession, SIGNAL(addedTorrent(const QString&, torrent_handle&, bool)), this, SLOT(torrentAdded(const QString&, torrent_handle&, bool))); connect(&BTSession, SIGNAL(duplicateTorrent(const QString&)), this, SLOT(torrentDuplicate(const QString&))); @@ -284,6 +285,11 @@ void GUI::readParamsOnSocket(){ void GUI::displayNoUPnPWanServiceDetected(){ setInfoBar(tr("UPnP: no WAN service detected..."), "red"); } + +void GUI::displayUPnPWanServiceDetected(){ + setInfoBar(tr("UPnP: WAN service detected!"), "green"); +} + #endif // Toggle paused state of selected torrent diff --git a/src/GUI.h b/src/GUI.h index 68fced354..0479a1336 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -142,6 +142,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void askForTorrentUrl(); #ifndef NO_UPNP void displayNoUPnPWanServiceDetected(); + void displayUPnPWanServiceDetected(); #endif diff --git a/src/UPnP.cpp b/src/UPnP.cpp index f2af521b0..bc5195d71 100644 --- a/src/UPnP.cpp +++ b/src/UPnP.cpp @@ -893,7 +893,7 @@ bool CUPnPControlPoint::AddPortMappings( qDebug("UPnP: %s", msg.str().c_str()); return false; } - + emit yeswanServiceDetected(); int n = upnpPortMapping.size(); bool ok = false; diff --git a/src/UPnP.h b/src/UPnP.h index f5b56b336..968534bf5 100644 --- a/src/UPnP.h +++ b/src/UPnP.h @@ -599,6 +599,7 @@ public: signals: void noWanServiceDetected(); + void yeswanServiceDetected(); private: void OnEventReceived( diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 5b77a3a80..816517bb8 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -90,6 +90,7 @@ void bittorrent::enableUPnP(int port){ "qBittorrent"); m_upnp = new CUPnPControlPoint(port); connect(m_upnp, SIGNAL(noWanServiceDetected()), this, SLOT(noWanServiceEventHandler())); + connect(m_upnp, SIGNAL(yeswanServiceDetected()), this, SLOT(wanServiceEventHandler())); m_upnp->AddPortMappings(m_upnpMappings); } } @@ -99,6 +100,11 @@ void bittorrent::noWanServiceEventHandler(){ emit noWanServiceDetected(); } +void bittorrent::wanServiceEventHandler(){ + // Forward this signal + emit wanServiceDetected(); +} + // Set UPnP port (>= 1000) void bittorrent::setUPnPPort(int upnp_port){ if(!UPnPEnabled){ diff --git a/src/bittorrent.h b/src/bittorrent.h index 617bfc336..1f4407565 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -135,6 +135,7 @@ class bittorrent : public QObject{ void saveTrackerFile(const QString& hash); #ifndef NO_UPNP void noWanServiceEventHandler(); + void wanServiceEventHandler(); #endif signals: @@ -152,6 +153,7 @@ class bittorrent : public QObject{ void aboutToDownloadFromUrl(const QString& url); #ifndef NO_UPNP void noWanServiceDetected(); + void wanServiceDetected(); #endif };