diff --git a/ChangeLog b/ChangeLog index eb77fdca..c3ac158c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-05-28 Tatsuhiro Tsujikawa + + Fixed compile error without BitTorrent and Metalink support. + * src/XmlRpcMethod.cc + * src/XmlRpcMethodFactory.cc + * src/XmlRpcMethodImpl.cc + * src/XmlRpcMethodImpl.h + * test/XmlRpcMethodTest.cc + 2009-05-27 Tatsuhiro Tsujikawa Rewritten the help message for --allow-overwrite option. diff --git a/src/XmlRpcMethod.cc b/src/XmlRpcMethod.cc index 5200933f..e13dfe0b 100644 --- a/src/XmlRpcMethod.cc +++ b/src/XmlRpcMethod.cc @@ -86,6 +86,9 @@ static void gatherOption const BDE& value = optionsDict[*first]; SharedHandle optionHandler = optionParser->findByName(*first); + if(optionHandler.isNull()) { + continue; + } // header and index-out option can take array as value if((*first == PREF_HEADER || *first == PREF_INDEX_OUT) && value.isList()){ for(BDE::List::const_iterator argiter = value.listBegin(); diff --git a/src/XmlRpcMethodFactory.cc b/src/XmlRpcMethodFactory.cc index ac9fa57b..c42007ab 100644 --- a/src/XmlRpcMethodFactory.cc +++ b/src/XmlRpcMethodFactory.cc @@ -46,11 +46,17 @@ XmlRpcMethodFactory::create(const std::string& methodName) { if(methodName == "aria2.addUri") { return SharedHandle(new AddUriXmlRpcMethod()); +#ifdef ENABLE_BITTORRENT } else if(methodName == "aria2.addTorrent") { return SharedHandle(new AddTorrentXmlRpcMethod()); - } else if(methodName == "aria2.addMetalink") { +#endif // ENABLE_BITTORRENT +#ifdef ENABLE_METALINK + } + else if(methodName == "aria2.addMetalink") { return SharedHandle(new AddMetalinkXmlRpcMethod()); - } else if(methodName == "aria2.remove") { +#endif // ENABLE_METALINK + } + else if(methodName == "aria2.remove") { return SharedHandle(new RemoveXmlRpcMethod()); } else if(methodName == "aria2.tellStatus") { return SharedHandle(new TellStatusXmlRpcMethod()); @@ -58,8 +64,11 @@ XmlRpcMethodFactory::create(const std::string& methodName) return SharedHandle(new GetUrisXmlRpcMethod()); } else if(methodName == "aria2.getFiles") { return SharedHandle(new GetFilesXmlRpcMethod()); - } else if(methodName == "aria2.getPeers") { +#ifdef ENABLE_BITTORRENT + } + else if(methodName == "aria2.getPeers") { return SharedHandle(new GetPeersXmlRpcMethod()); +#endif // ENABLE_BITTORRENT } else if(methodName == "aria2.tellActive") { return SharedHandle(new TellActiveXmlRpcMethod()); } else if(methodName == "aria2.changeOption") { diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc index b2356312..e3a626f8 100644 --- a/src/XmlRpcMethodImpl.cc +++ b/src/XmlRpcMethodImpl.cc @@ -113,6 +113,7 @@ BDE AddUriXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) } } +#ifdef ENABLE_BITTORRENT BDE AddTorrentXmlRpcMethod::process (const XmlRpcRequest& req, DownloadEngine* e) { @@ -147,8 +148,10 @@ BDE AddTorrentXmlRpcMethod::process } else { throw DL_ABORT_EX("No Torrent to download."); } -} +} +#endif // ENABLE_BITTORRENT +#ifdef ENABLE_METALINK BDE AddMetalinkXmlRpcMethod::process (const XmlRpcRequest& req, DownloadEngine* e) { @@ -176,7 +179,7 @@ BDE AddMetalinkXmlRpcMethod::process throw DL_ABORT_EX("No files to download."); } } - +#endif // ENABLE_METALINK BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) { @@ -235,6 +238,7 @@ static void gatherProgressCommon Util::uitos(group->getDownloadContext()->getNumPieces()); } +#ifdef ENABLE_BITTORRENT static void gatherProgressBitTorrent (BDE& entryDict, const SharedHandle& btctx) { @@ -263,16 +267,19 @@ static void gatherPeer(BDE& peers, const SharedHandle& ps) peers << peerEntry; } } +#endif // ENABLE_BITTORRENT static void gatherProgress (BDE& entryDict, const SharedHandle& group, DownloadEngine* e) { gatherProgressCommon(entryDict, group); +#ifdef ENABLE_BITTORRENT SharedHandle btctx = dynamic_pointer_cast(group->getDownloadContext()); if(!btctx.isNull()) { gatherProgressBitTorrent(entryDict, btctx); } +#endif // ENABLE_BITTORRENT } static void gatherStoppedDownload @@ -373,6 +380,7 @@ BDE GetUrisXmlRpcMethod::process return uriList; } +#ifdef ENABLE_BITTORRENT BDE GetPeersXmlRpcMethod::process (const XmlRpcRequest& req, DownloadEngine* e) { @@ -404,6 +412,7 @@ BDE GetPeersXmlRpcMethod::process } return peers; } +#endif // ENABLE_BITTORRENT BDE TellStatusXmlRpcMethod::process (const XmlRpcRequest& req, DownloadEngine* e) diff --git a/src/XmlRpcMethodImpl.h b/src/XmlRpcMethodImpl.h index 05d53dc0..917b198d 100644 --- a/src/XmlRpcMethodImpl.h +++ b/src/XmlRpcMethodImpl.h @@ -51,15 +51,19 @@ protected: virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); }; +#ifdef ENABLE_BITTORRENT class AddTorrentXmlRpcMethod:public XmlRpcMethod { protected: virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); }; +#endif // ENABLE_BITTORRENT +#ifdef ENABLE_METALINK class AddMetalinkXmlRpcMethod:public XmlRpcMethod { protected: virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); }; +#endif // ENABLE_METALINK class PurgeDownloadResultXmlRpcMethod:public XmlRpcMethod { protected: @@ -76,10 +80,12 @@ protected: virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); }; +#ifdef ENABLE_BITTORRENT class GetPeersXmlRpcMethod:public XmlRpcMethod { protected: virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e); }; +#endif // ENABLE_BITTORRENT class TellStatusXmlRpcMethod:public XmlRpcMethod { protected: diff --git a/test/XmlRpcMethodTest.cc b/test/XmlRpcMethodTest.cc index a1c88f77..737ae91f 100644 --- a/test/XmlRpcMethodTest.cc +++ b/test/XmlRpcMethodTest.cc @@ -29,12 +29,16 @@ class XmlRpcMethodTest:public CppUnit::TestFixture { CPPUNIT_TEST(testAddUri_withoutUri); CPPUNIT_TEST(testAddUri_notUri); CPPUNIT_TEST(testAddUri_withBadOption); +#ifdef ENABLE_BITTORRENT CPPUNIT_TEST(testAddTorrent); CPPUNIT_TEST(testAddTorrent_withoutTorrent); CPPUNIT_TEST(testAddTorrent_notBase64Torrent); +#endif // ENABLE_BITTORRENT +#ifdef ENABLE_METALINK CPPUNIT_TEST(testAddMetalink); CPPUNIT_TEST(testAddMetalink_withoutMetalink); CPPUNIT_TEST(testAddMetalink_notBase64Metalink); +#endif // ENABLE_METALINK CPPUNIT_TEST(testChangeOption); CPPUNIT_TEST(testChangeOption_withBadOption); CPPUNIT_TEST(testChangeOption_withoutGid); @@ -65,12 +69,16 @@ public: void testAddUri_withoutUri(); void testAddUri_notUri(); void testAddUri_withBadOption(); +#ifdef ENABLE_BITTORRENT void testAddTorrent(); void testAddTorrent_withoutTorrent(); void testAddTorrent_notBase64Torrent(); +#endif // ENABLE_BITTORRENT +#ifdef ENABLE_METALINK void testAddMetalink(); void testAddMetalink_withoutMetalink(); void testAddMetalink_notBase64Metalink(); +#endif // ENABLE_METALINK void testChangeOption(); void testChangeOption_withBadOption(); void testChangeOption_withoutGid(); @@ -142,6 +150,7 @@ void XmlRpcMethodTest::testAddUri_withBadOption() CPPUNIT_ASSERT_EQUAL(1, res._code); } +#ifdef ENABLE_BITTORRENT void XmlRpcMethodTest::testAddTorrent() { AddTorrentXmlRpcMethod m; @@ -191,7 +200,9 @@ void XmlRpcMethodTest::testAddTorrent_notBase64Torrent() XmlRpcResponse res = m.execute(req, _e.get()); CPPUNIT_ASSERT_EQUAL(1, res._code); } +#endif // ENABLE_BITTORRENT +#ifdef ENABLE_METALINK void XmlRpcMethodTest::testAddMetalink() { AddMetalinkXmlRpcMethod m; @@ -241,6 +252,7 @@ void XmlRpcMethodTest::testAddMetalink_notBase64Metalink() XmlRpcResponse res = m.execute(req, _e.get()); CPPUNIT_ASSERT_EQUAL(1, res._code); } +#endif // ENABLE_METALINK void XmlRpcMethodTest::testChangeOption() { @@ -253,14 +265,18 @@ void XmlRpcMethodTest::testChangeOption() req._params << BDE("1"); BDE opt = BDE::dict(); opt[PREF_MAX_DOWNLOAD_LIMIT] = BDE("100K"); +#ifdef ENABLE_BITTORRENT opt[PREF_MAX_UPLOAD_LIMIT] = BDE("50K"); +#endif // ENABLE_BITTORRENT req._params << opt; XmlRpcResponse res = m.execute(req, _e.get()); CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024, group->getMaxDownloadSpeedLimit()); - CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024, group->getMaxUploadSpeedLimit()); +#ifdef ENABLE_BITTORRENT + CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024, group->getMaxUploadSpeedLimit()); +#endif // ENABLE_BITTORRENT } void XmlRpcMethodTest::testChangeOption_withBadOption() @@ -293,15 +309,19 @@ void XmlRpcMethodTest::testChangeGlobalOption() XmlRpcRequest req("aria2.changeGlobalOption", BDE::list()); BDE opt = BDE::dict(); opt[PREF_MAX_OVERALL_DOWNLOAD_LIMIT] = BDE("100K"); +#ifdef ENABLE_BITTORRENT opt[PREF_MAX_OVERALL_UPLOAD_LIMIT] = BDE("50K"); +#endif // ENABLE_BITTORRENT req._params << opt; XmlRpcResponse res = m.execute(req, _e.get()); CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024, _e->_requestGroupMan->getMaxOverallDownloadSpeedLimit()); +#ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024, _e->_requestGroupMan->getMaxOverallUploadSpeedLimit()); +#endif // ENABLE_BITTORRENT } void XmlRpcMethodTest::testChangeGlobalOption_withBadOption()