← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2370: log ports UPnP closes

 

------------------------------------------------------------
revno: 2370
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-12-27 17:33:30 +0100
message:
  log ports UPnP closes
modified:
  dcpp/UPnP.cpp
  dcpp/UPnP.h
  dcpp/UPnPManager.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/UPnP.cpp'
--- dcpp/UPnP.cpp	2010-06-18 12:09:55 +0000
+++ dcpp/UPnP.cpp	2010-12-27 16:33:30 +0000
@@ -39,11 +39,15 @@
 bool UPnP::close() {
 	bool ret = true;
 
-	for(std::vector<rule>::const_iterator i = rules.begin(), iend = rules.end(); i != iend; ++i)
+	for(auto i = rules.cbegin(), iend = rules.cend(); i != iend; ++i)
 		ret &= remove(i->first, i->second);
 	rules.clear();
 
 	return ret;
 }
 
+bool UPnP::hasRules() const {
+	return !rules.empty();
+}
+
 } // namespace dcpp

=== modified file 'dcpp/UPnP.h'
--- dcpp/UPnP.h	2010-09-09 18:16:26 +0000
+++ dcpp/UPnP.h	2010-12-27 16:33:30 +0000
@@ -37,6 +37,7 @@
 
 	bool open(const unsigned short port, const Protocol protocol, const string& description);
 	bool close();
+	bool hasRules() const;
 
 	virtual string getExternalIP() = 0;
 	virtual const string& getName() const = 0;

=== modified file 'dcpp/UPnPManager.cpp'
--- dcpp/UPnPManager.cpp	2010-09-09 18:16:26 +0000
+++ dcpp/UPnPManager.cpp	2010-12-27 16:33:30 +0000
@@ -121,8 +121,9 @@
 }
 
 void UPnPManager::close(UPnP& impl) {
-	if(!impl.close()) {
-		log(_("Failed to remove port mappings"));
+	if(impl.hasRules()) {
+		log(impl.close() ? str(F_("Successfully removed port mappings with the %1% interface") % impl.getName()) :
+			str(F_("Failed to remove port mappings with the %1% interface") % impl.getName()));
 	}
 }