From 7cba24e8b2ade4e14e4181bf0a5806966178bed0 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 29 Oct 2011 18:50:52 +0900 Subject: [PATCH] Options for -i list is now available in aria2.changeOption. Options for -i list, except for PREF_CHECKSUM, PREF_DIR, PREF_DRY_RUN, PREF_INDEX_OUT, PREF_LOWEST_SPEED_LIMIT, PREF_MAX_CONNECTION_PER_SERVER, PREF_METALINK_BASE_URI, PREF_OUT, PREF_PIECE_LENGTH, PREF_SELECT_FILE, PREF_SPLIT, PREF_PAUSE and PREF_PARAMETERIZED_URI, are available in aria2.changeOption if the download is waiting state, including paused downloads. --- src/AbstractOptionHandler.cc | 1 + src/AbstractOptionHandler.h | 11 +++++ src/OptionHandler.h | 2 + src/OptionHandlerFactory.cc | 88 ++++++++++++++++++++++++++++++++++++ src/OptionHandlerImpl.cc | 10 ++++ src/OptionHandlerImpl.h | 2 + src/RpcMethod.cc | 11 +++++ src/RpcMethod.h | 3 ++ src/RpcMethodImpl.cc | 46 +++++++++++++------ 9 files changed, 159 insertions(+), 15 deletions(-) diff --git a/src/AbstractOptionHandler.cc b/src/AbstractOptionHandler.cc index d9b17202..412a6520 100644 --- a/src/AbstractOptionHandler.cc +++ b/src/AbstractOptionHandler.cc @@ -58,6 +58,7 @@ AbstractOptionHandler::AbstractOptionHandler eraseAfterParse_(false), initialOption_(false), changeOption_(false), + changeOptionForReserved_(false), globalChangeOption_(false), cumulative_(false) {} diff --git a/src/AbstractOptionHandler.h b/src/AbstractOptionHandler.h index 1c1dc7f0..f533bd66 100644 --- a/src/AbstractOptionHandler.h +++ b/src/AbstractOptionHandler.h @@ -66,6 +66,7 @@ protected: bool initialOption_; bool changeOption_; + bool changeOptionForReserved_; bool globalChangeOption_; bool cumulative_; @@ -154,6 +155,16 @@ public: changeOption_ = f; } + virtual bool getChangeOptionForReserved() const + { + return changeOptionForReserved_; + } + + virtual void setChangeOptionForReserved(bool f) + { + changeOptionForReserved_ = f; + } + virtual bool getChangeGlobalOption() const { return globalChangeOption_; diff --git a/src/OptionHandler.h b/src/OptionHandler.h index b7a5dbb8..10be6737 100644 --- a/src/OptionHandler.h +++ b/src/OptionHandler.h @@ -104,6 +104,8 @@ public: virtual void setInitialOption(bool f) = 0; virtual bool getChangeOption() const = 0; virtual void setChangeOption(bool f) = 0; + virtual bool getChangeOptionForReserved() const = 0; + virtual void setChangeOptionForReserved(bool f) = 0; virtual bool getChangeGlobalOption() const = 0; virtual void setChangeGlobalOption(bool f) = 0; virtual bool getCumulative() const = 0; diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 92342a4d..27ce387b 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -60,6 +60,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_FILE); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -71,6 +72,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_ADVANCED); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -84,6 +86,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } #ifdef ENABLE_ASYNC_DNS @@ -96,6 +99,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_ADVANCED); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } #if defined HAVE_ARES_SET_SERVERS && HAVE_ARES_ADDR_NODE @@ -119,6 +123,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_FILE); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -145,6 +150,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_CHECKSUM); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } #endif // ENABLE_MESSAGE_DIGEST @@ -158,6 +164,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -181,6 +188,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -246,6 +254,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_ADVANCED); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } #endif // ENABLE_ASYNC_DNS @@ -319,6 +328,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_FILE); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -345,6 +355,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_CHECKSUM); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } #endif // ENABLE_MESSAGE_DIGEST @@ -439,6 +450,7 @@ OptionHandlerFactory::createOptionHandlers() op->setInitialOption(true); op->setChangeOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -474,6 +486,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -488,6 +501,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -509,6 +523,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_FILE); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -605,6 +620,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_CHECKSUM); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } #endif // ENABLE_MESSAGE_DIGEST @@ -617,6 +633,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_ADVANCED); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -747,6 +764,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -783,6 +801,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -796,6 +815,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -809,6 +829,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -851,6 +872,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -863,6 +885,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -875,6 +898,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -943,6 +967,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -956,6 +981,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -970,6 +996,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } // HTTP Specific Options @@ -1012,6 +1039,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1023,6 +1051,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1035,6 +1064,7 @@ OptionHandlerFactory::createOptionHandlers() op->setInitialOption(true); op->setCumulative(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1046,6 +1076,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1057,6 +1088,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1068,6 +1100,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1079,6 +1112,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1090,6 +1124,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1119,6 +1154,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_METALINK); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1138,6 +1174,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1160,6 +1197,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1173,6 +1211,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } // FTP Specific Options @@ -1185,6 +1224,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1197,6 +1237,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_FTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1208,6 +1249,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_FTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1219,6 +1261,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_FTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1230,6 +1273,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1250,6 +1294,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1261,6 +1306,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1272,6 +1318,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1283,6 +1330,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTPS); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1295,6 +1343,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1307,6 +1356,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1317,6 +1367,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_FTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1328,6 +1379,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1339,6 +1391,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1351,6 +1404,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTPS); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1364,6 +1418,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1377,6 +1432,7 @@ OptionHandlerFactory::createOptionHandlers() op->setEraseAfterParse(true); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1390,6 +1446,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTPS); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1402,6 +1459,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_HTTP); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } // BitTorrent/Metalink Options @@ -1441,6 +1499,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1453,6 +1512,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1464,6 +1524,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1485,6 +1546,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_CHECKSUM); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1506,6 +1568,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1518,6 +1581,7 @@ OptionHandlerFactory::createOptionHandlers() op->setInitialOption(true); op->setChangeOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } @@ -1530,6 +1594,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1541,6 +1606,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1550,6 +1616,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1562,6 +1629,7 @@ OptionHandlerFactory::createOptionHandlers() op->setInitialOption(true); op->setChangeOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1573,6 +1641,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1593,6 +1662,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1604,6 +1674,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1615,6 +1686,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1635,6 +1707,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1646,6 +1719,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1657,6 +1731,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1668,6 +1743,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1775,6 +1851,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1786,6 +1863,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1831,6 +1909,7 @@ OptionHandlerFactory::createOptionHandlers() op->setInitialOption(true); op->setChangeOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1869,6 +1948,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1880,6 +1960,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_BITTORRENT); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1905,6 +1986,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_METALINK); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1926,6 +2008,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_METALINK); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1946,6 +2029,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_METALINK); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1955,6 +2039,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_METALINK); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1968,6 +2053,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_METALINK); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1980,6 +2066,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_METALINK); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } { @@ -1989,6 +2076,7 @@ OptionHandlerFactory::createOptionHandlers() op->addTag(TAG_METALINK); op->setInitialOption(true); op->setChangeGlobalOption(true); + op->setChangeOptionForReserved(true); handlers.push_back(op); } #endif // ENABLE_METALINK diff --git a/src/OptionHandlerImpl.cc b/src/OptionHandlerImpl.cc index 098e2cf6..0571233f 100644 --- a/src/OptionHandlerImpl.cc +++ b/src/OptionHandlerImpl.cc @@ -807,6 +807,16 @@ void DeprecatedOptionHandler::setChangeOption(bool f) depOptHandler_->setChangeOption(f); } +bool DeprecatedOptionHandler::getChangeOptionForReserved() const +{ + return depOptHandler_->getChangeOptionForReserved(); +} + +void DeprecatedOptionHandler::setChangeOptionForReserved(bool f) +{ + depOptHandler_->setChangeOptionForReserved(f); +} + bool DeprecatedOptionHandler::getChangeGlobalOption() const { return depOptHandler_->getChangeGlobalOption(); diff --git a/src/OptionHandlerImpl.h b/src/OptionHandlerImpl.h index 13cc1b8b..c4799894 100644 --- a/src/OptionHandlerImpl.h +++ b/src/OptionHandlerImpl.h @@ -315,6 +315,8 @@ public: virtual void setInitialOption(bool f); virtual bool getChangeOption() const; virtual void setChangeOption(bool f); + virtual bool getChangeOptionForReserved() const; + virtual void setChangeOptionForReserved(bool f); virtual bool getChangeGlobalOption() const; virtual void setChangeGlobalOption(bool f); virtual bool getCumulative() const; diff --git a/src/RpcMethod.cc b/src/RpcMethod.cc index d25107f9..9cacf072 100644 --- a/src/RpcMethod.cc +++ b/src/RpcMethod.cc @@ -137,6 +137,17 @@ void RpcMethod::gatherChangeableOption(Option* option, const Dict* optionsDict) } } +void RpcMethod::gatherChangeableOptionForReserved +(Option* option, + const Dict* optionsDict) +{ + if(optionsDict) { + gatherOption(optionsDict->begin(), optionsDict->end(), + mem_fun_sh(&OptionHandler::getChangeOptionForReserved), + option, optionParser_); + } +} + void RpcMethod::gatherChangeableGlobalOption (Option* option, const Dict* optionsDict) { diff --git a/src/RpcMethod.h b/src/RpcMethod.h index 1e2f9d7a..caad0fa4 100644 --- a/src/RpcMethod.h +++ b/src/RpcMethod.h @@ -76,6 +76,9 @@ protected: void gatherChangeableOption(Option* option, const Dict* optionDict); + void gatherChangeableOptionForReserved + (Option* option, const Dict* optionsDict); + void gatherChangeableGlobalOption(Option* option, const Dict* optionDict); SharedHandle createErrorResponse diff --git a/src/RpcMethodImpl.cc b/src/RpcMethodImpl.cc index 55ded866..11e72106 100644 --- a/src/RpcMethodImpl.cc +++ b/src/RpcMethodImpl.cc @@ -1113,22 +1113,12 @@ SharedHandle RemoveDownloadResultRpcMethod::process return VLB_OK; } -SharedHandle ChangeOptionRpcMethod::process -(const RpcRequest& req, DownloadEngine* e) +namespace { +void changeOption +(const SharedHandle& group, + const Option& option, + DownloadEngine* e) { - const String* gidParam = checkRequiredParam(req, 0); - const Dict* optsParam = checkRequiredParam(req, 1); - - a2_gid_t gid = str2Gid(gidParam); - SharedHandle group = - findRequestGroup(e->getRequestGroupMan(), gid); - if(!group) { - throw DL_ABORT_EX - (fmt("Cannot change option for GID#%s", - util::itos(gid).c_str())); - } - Option option; - gatherChangeableOption(&option, optsParam); group->getOption()->merge(option); if(option.defined(PREF_MAX_DOWNLOAD_LIMIT)) { group->setMaxDownloadSpeedLimit @@ -1145,6 +1135,32 @@ SharedHandle ChangeOptionRpcMethod::process } } #endif // ENABLE_BITTORRENT +} +} // namespace + +SharedHandle ChangeOptionRpcMethod::process +(const RpcRequest& req, DownloadEngine* e) +{ + const String* gidParam = checkRequiredParam(req, 0); + const Dict* optsParam = checkRequiredParam(req, 1); + + a2_gid_t gid = str2Gid(gidParam); + SharedHandle group = + e->getRequestGroupMan()->findRequestGroup(gid); + Option option; + if(group) { + gatherChangeableOption(&option, optsParam); + changeOption(group, option, e); + } else { + group = e->getRequestGroupMan()->findReservedGroup(gid); + if(group) { + gatherChangeableOptionForReserved(&option, optsParam); + changeOption(group, option, e); + } else { + throw DL_ABORT_EX + (fmt("Cannot change option for GID#%s", util::itos(gid).c_str())); + } + } return VLB_OK; }