← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2579: Setting to disable bundles

 

------------------------------------------------------------
revno: 2579
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Mon 2011-07-18 22:27:51 +0200
message:
  Setting to disable bundles
modified:
  dcpp/QueueManager.cpp
  dcpp/SettingsManager.cpp
  dcpp/SettingsManager.h


--
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/QueueManager.cpp'
--- dcpp/QueueManager.cpp	2011-06-18 12:49:10 +0000
+++ dcpp/QueueManager.cpp	2011-07-18 20:27:51 +0000
@@ -666,12 +666,14 @@
 		}
 	});
 
-	Lock l(cs);
+	if(BOOLSETTING(BUNDLES)) {
+		Lock l(cs);
 
-    auto i = bundles.insert(make_pair(bundle->getHash(), BundleItem(aRoot, bundle)));
-    if(i.second) {
-    	fire(QueueManagerListener::Added(), i.first->second);
-    }
+		auto i = bundles.insert(make_pair(bundle->getHash(), BundleItem(aRoot, bundle)));
+		if(i.second) {
+			fire(QueueManagerListener::Added(), i.first->second);
+		}
+	}
 }
 
 void QueueManager::readd(const string& target, const HintedUser& aUser) {
@@ -1353,12 +1355,14 @@
 }
 
 void QueueManager::removeBundle(const TTHValue& tth) noexcept {
-	Lock l(cs);
-	// TODO remove queueitems (probably...)
-	auto i = bundles.find(tth);
-	if(i != bundles.end()) {
-		fire(QueueManagerListener::Removed(), i->second);
-		bundles.erase(i);
+	if(BOOLSETTING(BUNDLES)) {
+		Lock l(cs);
+		// TODO remove queueitems (probably...)
+		auto i = bundles.find(tth);
+		if(i != bundles.end()) {
+			fire(QueueManagerListener::Removed(), i->second);
+			bundles.erase(i);
+		}
 	}
 }
 
@@ -1540,32 +1544,34 @@
 			}
 		}
 
-		for(auto i = bundles.begin(); i != bundles.end(); ++i) {
-			auto& bi = i->second;
-
-			f.write(LIT("\t<BundleItem Root=\""));
-			f.write(SimpleXML::escape(bi.getRoot(), tmp, true));
-			f.write(LIT("\">\r\n"));
-
-			auto& b = *bi.getBundle();
-
-			f.write(LIT("\t\t<Bundle Name=\""));
-			f.write(SimpleXML::escape(b.name, tmp, true));
-			f.write(LIT("\">\r\n"));
-			for(auto j = b.entries.begin(); j != b.entries.end(); ++j) {
-				f.write(LIT("\t\t\t<Entry Name=\""));
-				f.write(SimpleXML::escape(j->name, tmp, true));
-				f.write(LIT("\" Size=\""));
-				f.write(Util::toString(j->size));
-				f.write(LIT("\" Include=\""));
-				f.write(Util::toString((int)j->include));
-				b32tmp.clear();
-				f.write(LIT("\" TTH=\""));
-				f.write(j->tth.toBase32(b32tmp));
-				f.write(LIT("\"/>\r\n"));
+		if(BOOLSETTING(BUNDLES)) {
+			for(auto i = bundles.begin(); i != bundles.end(); ++i) {
+				auto& bi = i->second;
+
+				f.write(LIT("\t<BundleItem Root=\""));
+				f.write(SimpleXML::escape(bi.getRoot(), tmp, true));
+				f.write(LIT("\">\r\n"));
+
+				auto& b = *bi.getBundle();
+
+				f.write(LIT("\t\t<Bundle Name=\""));
+				f.write(SimpleXML::escape(b.name, tmp, true));
+				f.write(LIT("\">\r\n"));
+				for(auto j = b.entries.begin(); j != b.entries.end(); ++j) {
+					f.write(LIT("\t\t\t<Entry Name=\""));
+					f.write(SimpleXML::escape(j->name, tmp, true));
+					f.write(LIT("\" Size=\""));
+					f.write(Util::toString(j->size));
+					f.write(LIT("\" Include=\""));
+					f.write(Util::toString((int)j->include));
+					b32tmp.clear();
+					f.write(LIT("\" TTH=\""));
+					f.write(j->tth.toBase32(b32tmp));
+					f.write(LIT("\"/>\r\n"));
+				}
+				f.write(LIT("\t\t</Bundle>\r\n"));
+				f.write(LIT("\t</BundleItem>\r\n"));
 			}
-			f.write(LIT("\t\t</Bundle>\r\n"));
-			f.write(LIT("\t</BundleItem>\r\n"));
 		}
 
 		f.write("</Downloads>\r\n");
@@ -1734,7 +1740,7 @@
 			cur = NULL;
 		} else if(name == "Downloads") {
 			inDownloads = false;
-		} else if(name == sBundleItem) {
+		} else if(name == sBundleItem && BOOLSETTING(BUNDLES)) {
 			qm->bundles[bundle->getBundle()->getHash()] = *bundle;
 			delete bundle;
 			bundle = 0;
@@ -1947,20 +1953,25 @@
 }
 
 BundleItem* QueueManager::getBundle(QueueItem *qi) noexcept {
-	for(auto i = bundles.begin(); i != bundles.end(); ++i) {
-		if(find_if(i->second.getBundle()->entries, [&](const Bundle::Entry& e) {
-			return Util::stricmp(i->second.getRoot() + e.name, qi->getTarget()) == 0;
-		}) != i->second.getBundle()->entries.end()) {
-			return &i->second;
+	if(BOOLSETTING(BUNDLES)) {
+		for(auto i = bundles.begin(); i != bundles.end(); ++i) {
+			if(find_if(i->second.getBundle()->entries, [&](const Bundle::Entry& e) {
+				return Util::stricmp(i->second.getRoot() + e.name, qi->getTarget()) == 0;
+			}) != i->second.getBundle()->entries.end()) {
+				return &i->second;
+			}
 		}
 	}
+
 	return 0;
 }
 
 void QueueManager::removeBundle(BundleItem *bi) noexcept {
-	fire(QueueManagerListener::Removed(), *bi);
-	bundles.erase(bi->getBundle()->getHash());
-	delete bi;
+	if(BOOLSETTING(BUNDLES)) {
+		fire(QueueManagerListener::Removed(), *bi);
+		bundles.erase(bi->getBundle()->getHash());
+		delete bi;
+	}
 }
 
 bool QueueManager::isFinished(const BundleItem &bi) noexcept {

=== modified file 'dcpp/SettingsManager.cpp'
--- dcpp/SettingsManager.cpp	2011-06-28 20:07:49 +0000
+++ dcpp/SettingsManager.cpp	2011-07-18 20:27:51 +0000
@@ -91,7 +91,7 @@
 	"MaxUploadSpeedTime", "MaxDownloadSpeedPrimary", "MaxUploadSpeedPrimary",
 	"SlotsAlternateLimiting", "SlotsPrimaryLimiting",
 	"AutoDetectIncomingConnection", "SettingsSaveInterval",
-	"BalloonMainChat", "BalloonPM", "BalloonPMWindow", "BalloonFinishedDL", "BalloonFinishedFL",
+	"BalloonMainChat", "BalloonPM", "BalloonPMWindow", "BalloonFinishedDL", "BalloonFinishedFL", "Bundles",
 	"SENTRY",
 	// Int64
 	"TotalUpload", "TotalDownload",
@@ -103,7 +103,6 @@
 
 SettingsManager::SettingsManager()
 {
-
 	connectionSpeeds.push_back("0.005");
 	connectionSpeeds.push_back("0.01");
 	connectionSpeeds.push_back("0.02");
@@ -319,6 +318,7 @@
 	setDefault(BALLOON_PM_WINDOW, BALLOON_DISABLED);
 	setDefault(BALLOON_FINISHED_DL, BALLOON_ALWAYS);
 	setDefault(BALLOON_FINISHED_FL, BALLOON_DISABLED);
+	setDefault(BUNDLES, false);
 
 	setSearchTypeDefaults();
 

=== modified file 'dcpp/SettingsManager.h'
--- dcpp/SettingsManager.h	2011-06-28 20:07:49 +0000
+++ dcpp/SettingsManager.h	2011-07-18 20:27:51 +0000
@@ -112,7 +112,7 @@
 		MAX_UPLOAD_SPEED_ALTERNATE, MAX_DOWNLOAD_SPEED_MAIN, MAX_UPLOAD_SPEED_MAIN,
 		SLOTS_ALTERNATE_LIMITING, SLOTS_PRIMARY,
 		AUTO_DETECT_CONNECTION, SETTINGS_SAVE_INTERVAL,
-		BALLOON_MAIN_CHAT, BALLOON_PM, BALLOON_PM_WINDOW, BALLOON_FINISHED_DL, BALLOON_FINISHED_FL,
+		BALLOON_MAIN_CHAT, BALLOON_PM, BALLOON_PM_WINDOW, BALLOON_FINISHED_DL, BALLOON_FINISHED_FL, BUNDLES,
 		INT_LAST };
 
 	enum Int64Setting { INT64_FIRST = INT_LAST + 1,