summaryrefslogtreecommitdiff
path: root/src/FeatureConfig.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-07-30 12:58:27 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2006-07-30 12:58:27 +0000
commit928465b7bc638380004b39d6a5c6737f9f30faa0 (patch)
tree004af049ff7254834f42cacbf552558d1de1f08e /src/FeatureConfig.cc
parentba4e5b776be3816eb695a125d5f4f0406c74c55b (diff)
2006-07-30 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/TorrentMan.h: (advertisePiece): Updated doc. (getAdvertisedPieceIndexes): Updated doc. (removeAdvertisedPiece); New function. * src/TorrentMan.cc (FindElapsedHave): New function object. (removeAdvertisedPiece): New function. * src/HaveEraseCommand.h: New class. * src/HaveEraseCommand.cc: New class. * src/FeatureConfig.h: New class. * src/FeatureConfig.cc: New class. * src/Request.h (defaultPorts): Removed. * src/Request.cc (FeatureConfig.h): Included. (Request): Removed the statements related to defaultPorts. (parseUrl): Removed metalinkEnabled. Use FeatureConfig instead. A default port number is now retrieved from FeatureConfig. * src/main.cc (HaveEraseCommand.h): Included. (showVersion): Added the output of feature list. (main): Added HaveEraseCommand to command queue in BitTorrent downloading. * src/PeerInteractionCommand.h (chokeCheckPoint): Commented out. (periodicExecPoint): New variable. * src/PeerInteractionCommand.cc (executeInternal): Following methods are now called in at least every 0.5 seconds to reduce CPU usage: detectMessageFlooding(), peerInteraction->checkRequestSlot(), checkHave(), sendKeepAlive(). (checkLongTimePeerChoking): Commented out. * src/BitfieldMan.h (getNthBitIndex): Changed the method signature. (getMissingIndexRandomly): Changed the method signature. * src/BitfieldMan.cc (getNthBitIndex): Rewritten (getMissingIndexRandomly): Rewritten. (hasMissingPiece): Rewritten. (getMissingIndex): Refactored. (getMissingUnusedIndex); Refactored. (getMissingIndex): Refactored.
Diffstat (limited to 'src/FeatureConfig.cc')
-rw-r--r--src/FeatureConfig.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc
new file mode 100644
index 00000000..3f48b6a1
--- /dev/null
+++ b/src/FeatureConfig.cc
@@ -0,0 +1,56 @@
+/* <!-- copyright */
+/*
+ * aria2 - a simple utility for downloading files faster
+ *
+ * Copyright (C) 2006 Tatsuhiro Tsujikawa
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+/* copyright --> */
+#include "FeatureConfig.h"
+
+string FeatureConfig::FEATURE_HTTP = "http";
+string FeatureConfig::FEATURE_HTTPS = "https";
+string FeatureConfig::FEATURE_FTP = "ftp";
+string FeatureConfig::FEATURE_BITTORRENT = "bittorrent";
+string FeatureConfig::FEATURE_METALINK = "metalink";
+
+static ProtocolPortMap::value_type defaultPortsArray[] = {
+ ProtocolPortMap::value_type(FeatureConfig::FEATURE_HTTP, 80),
+ ProtocolPortMap::value_type(FeatureConfig::FEATURE_HTTPS, 443),
+ ProtocolPortMap::value_type(FeatureConfig::FEATURE_FTP, 21),
+};
+
+ProtocolPortMap FeatureConfig::defaultPorts(&defaultPortsArray[0],
+ &defaultPortsArray[3]);
+
+static SupportedFeatureMap::value_type supportedFeaturesArray[] = {
+ SupportedFeatureMap::value_type(FeatureConfig::FEATURE_HTTP, true),
+#ifdef ENABLE_SSL
+ SupportedFeatureMap::value_type(FeatureConfig::FEATURE_HTTPS, true),
+#endif // ENABLE_SSL
+ SupportedFeatureMap::value_type(FeatureConfig::FEATURE_FTP, true),
+#ifdef ENABLE_BITTORRENT
+ SupportedFeatureMap::value_type(FeatureConfig::FEATURE_BITTORRENT, true),
+#endif // ENABLE_BITTORRENT
+#ifdef ENABLE_METALINK
+ SupportedFeatureMap::value_type(FeatureConfig::FEATURE_METALINK, true),
+#endif // ENABLE_METALINK
+};
+
+SupportedFeatureMap
+FeatureConfig::supportedFeatures(&supportedFeaturesArray[0],
+ &supportedFeaturesArray[sizeof(supportedFeaturesArray)/sizeof(SupportedFeatureMap::value_type)]);
+