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