diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-11-13 15:08:52 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2008-11-13 15:08:52 +0000 |
| commit | 86478c49dd54f48204a7f7a4a412084bec09d265 (patch) | |
| tree | 013b5bd5f870d4de0057327411369a71966f02ce | |
| parent | eed0406484ce81e1154aaf61103814c7fa4a8fe0 (diff) | |
2008-11-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed compile error without SSL/XML library.
* src/DefaultBtProgressInfoFile.cc
* src/DefaultBtProgressInfoFile.h
* src/FileMetalinkParserState.cc
* src/RequestGroup.h
* src/SocketCore.cc
* src/SocketCore.h
* src/VerificationMetalinkParserState.cc
* src/download_helper.h
* src/main.cc
* test/DefaultBtProgressInfoFileTest.cc
* test/DownloadHelperTest.cc
| -rw-r--r-- | ChangeLog | 15 | ||||
| -rw-r--r-- | src/DefaultBtProgressInfoFile.cc | 13 | ||||
| -rw-r--r-- | src/DefaultBtProgressInfoFile.h | 5 | ||||
| -rw-r--r-- | src/FileMetalinkParserState.cc | 2 | ||||
| -rw-r--r-- | src/RequestGroup.h | 2 | ||||
| -rw-r--r-- | src/SocketCore.cc | 12 | ||||
| -rw-r--r-- | src/SocketCore.h | 6 | ||||
| -rw-r--r-- | src/VerificationMetalinkParserState.cc | 5 | ||||
| -rw-r--r-- | src/download_helper.h | 4 | ||||
| -rw-r--r-- | src/main.cc | 1 | ||||
| -rw-r--r-- | test/DefaultBtProgressInfoFileTest.cc | 16 | ||||
| -rw-r--r-- | test/DownloadHelperTest.cc | 39 |
12 files changed, 95 insertions, 25 deletions
@@ -1,3 +1,18 @@ +2008-11-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> + + Fixed compile error without SSL/XML library. + * src/DefaultBtProgressInfoFile.cc + * src/DefaultBtProgressInfoFile.h + * src/FileMetalinkParserState.cc + * src/RequestGroup.h + * src/SocketCore.cc + * src/SocketCore.h + * src/VerificationMetalinkParserState.cc + * src/download_helper.h + * src/main.cc + * test/DefaultBtProgressInfoFileTest.cc + * test/DownloadHelperTest.cc + 2008-11-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Rewritten URI handling functions. They are now provided as a testable diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index 31286de9..c1663969 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -41,8 +41,10 @@ #include "BtContext.h" #include "PieceStorage.h" #include "Piece.h" +#ifdef ENABLE_BITTORRENT #include "PeerStorage.h" #include "BtRuntime.h" +#endif // ENABLE_BITTORRENT #include "BitfieldMan.h" #include "Option.h" #include "TransferStat.h" @@ -87,7 +89,11 @@ void DefaultBtProgressInfoFile::updateFilename() bool DefaultBtProgressInfoFile::isTorrentDownload() { +#ifdef ENABLE_BITTORRENT return !_btRuntime.isNull(); +#else // !ENABLE_BITTORRENT + return false; +#endif // !ENABLE_BITTORRENT } // Since version 0001, Integers are saved in binary form, network byte order. @@ -138,10 +144,12 @@ void DefaultBtProgressInfoFile::save() { sizeof(totalLengthNL)); // uploadLength: 64 bits uint64_t uploadLengthNL = 0; +#ifdef ENABLE_BITTORRENT if(torrentDownload) { TransferStat stat = _peerStorage->calculateStat(); uploadLengthNL = hton64(stat.getAllTimeUploadLength()); } +#endif // ENABLE_BITTORRENT o.write(reinterpret_cast<const char*>(&uploadLengthNL), sizeof(uploadLengthNL)); // bitfieldLength: 32 bits @@ -266,10 +274,11 @@ void DefaultBtProgressInfoFile::load() if(version >= 1) { uploadLength = ntoh64(uploadLength); } +#ifdef ENABLE_BITTORRENT if(isTorrentDownload()) { _btRuntime->setUploadLengthAtStartup(uploadLength); } - +#endif // ENABLE_BITTORRENT // TODO implement the conversion mechanism between different piece length. uint32_t bitfieldLength; in.read(reinterpret_cast<char*>(&bitfieldLength), sizeof(bitfieldLength)); @@ -400,6 +409,7 @@ bool DefaultBtProgressInfoFile::exists() } } +#ifdef ENABLE_BITTORRENT void DefaultBtProgressInfoFile::setPeerStorage (const SharedHandle<PeerStorage>& peerStorage) { @@ -411,5 +421,6 @@ void DefaultBtProgressInfoFile::setBtRuntime { _btRuntime = btRuntime; } +#endif // ENABLE_BITTORRENT } // namespace aria2 diff --git a/src/DefaultBtProgressInfoFile.h b/src/DefaultBtProgressInfoFile.h index 8ea84df2..f6cdc2e6 100644 --- a/src/DefaultBtProgressInfoFile.h +++ b/src/DefaultBtProgressInfoFile.h @@ -50,9 +50,10 @@ class DefaultBtProgressInfoFile : public BtProgressInfoFile { private: SharedHandle<DownloadContext> _dctx; SharedHandle<PieceStorage> _pieceStorage; +#ifdef ENABLE_BITTORRENT SharedHandle<PeerStorage> _peerStorage; SharedHandle<BtRuntime> _btRuntime; - +#endif // ENABLE_BITTORRENT const Option* _option; Logger* _logger; std::string _filename; @@ -81,10 +82,12 @@ public: // re-set filename using current _dctx. virtual void updateFilename(); +#ifdef ENABLE_BITTORRENT // for torrents void setPeerStorage(const SharedHandle<PeerStorage>& peerStorage); void setBtRuntime(const SharedHandle<BtRuntime>& btRuntime); +#endif // ENABLE_BITTORRENT }; } // namespace aria2 diff --git a/src/FileMetalinkParserState.cc b/src/FileMetalinkParserState.cc index 2d5ebcd7..0f2c0edd 100644 --- a/src/FileMetalinkParserState.cc +++ b/src/FileMetalinkParserState.cc @@ -65,10 +65,8 @@ void FileMetalinkParserState::beginElement(MetalinkParserStateMachine* stm, stm->setLanguageState(); } else if(name == FileMetalinkParserState::OS) { stm->setOSState(); -#ifdef ENABLE_MESSAGE_DIGEST } else if(name == FileMetalinkParserState::VERIFICATION) { stm->setVerificationState(); -#endif // ENABLE_MESSAGE_DIGEST } else if(name == FileMetalinkParserState::RESOURCES) { stm->setResourcesState(); int maxConnections; diff --git a/src/RequestGroup.h b/src/RequestGroup.h index 7b37b9a1..291f9334 100644 --- a/src/RequestGroup.h +++ b/src/RequestGroup.h @@ -126,9 +126,11 @@ private: unsigned int _fileNotFoundCount; +#ifdef ENABLE_BITTORRENT WeakHandle<BtRuntime> _btRuntime; WeakHandle<PeerStorage> _peerStorage; +#endif // ENABLE_BITTORRENT const Option* _option; diff --git a/src/SocketCore.cc b/src/SocketCore.cc index e85f86ac..dcf1ad3b 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -76,8 +76,15 @@ namespace aria2 { +#ifdef ENABLE_SSL SharedHandle<TLSContext> SocketCore::_tlsContext; +void SocketCore::setTLSContext(const SharedHandle<TLSContext>& tlsContext) +{ + _tlsContext = tlsContext; +} +#endif // ENABLE_SSL + SocketCore::SocketCore(int sockType):_sockType(sockType), sockfd(-1) { init(); } @@ -1045,9 +1052,4 @@ bool SocketCore::wantWrite() const return _wantWrite; } -void SocketCore::setTLSContext(const SharedHandle<TLSContext>& tlsContext) -{ - _tlsContext = tlsContext; -} - } // namespace aria2 diff --git a/src/SocketCore.h b/src/SocketCore.h index 829b1cda..c385170b 100644 --- a/src/SocketCore.h +++ b/src/SocketCore.h @@ -61,7 +61,9 @@ namespace aria2 { +#ifdef ENABLE_SSL class TLSContext; +#endif // ENABLE_SSL class SocketCore { friend bool operator==(const SocketCore& s1, const SocketCore& s2); @@ -90,7 +92,7 @@ private: #if ENABLE_SSL static SharedHandle<TLSContext> _tlsContext; -#endif +#endif // ENABLE_SSL #ifdef HAVE_LIBSSL // for SSL @@ -325,7 +327,9 @@ public: */ bool wantWrite() const; +#ifdef ENABLE_SSL static void setTLSContext(const SharedHandle<TLSContext>& tlsContext); +#endif // ENABLE_SSL }; } // namespace aria2 diff --git a/src/VerificationMetalinkParserState.cc b/src/VerificationMetalinkParserState.cc index 7d3fc758..eaabea16 100644 --- a/src/VerificationMetalinkParserState.cc +++ b/src/VerificationMetalinkParserState.cc @@ -56,6 +56,7 @@ void VerificationMetalinkParserState::beginElement const std::string& name, const std::map<std::string, std::string>& attrs) { +#ifdef ENABLE_MESSAGE_DIGEST if(name == VerificationMetalinkParserState::HASH) { stm->setHashState(); std::map<std::string, std::string>::const_iterator itr = @@ -96,7 +97,9 @@ void VerificationMetalinkParserState::beginElement } catch(RecoverableException& e) { stm->cancelChunkChecksumTransaction(); } - } else if(name == VerificationMetalinkParserState::SIGNATURE) { + } else +#endif // ENABLE_MESSAGE_DIGEST + if(name == VerificationMetalinkParserState::SIGNATURE) { stm->setSignatureState(); std::map<std::string, std::string>::const_iterator itr = attrs.find(VerificationMetalinkParserState::TYPE); diff --git a/src/download_helper.h b/src/download_helper.h index 23f51d02..3100b597 100644 --- a/src/download_helper.h +++ b/src/download_helper.h @@ -47,16 +47,20 @@ namespace aria2 { class RequestGroup; class Option; +#ifdef ENABLE_BITTORRENT // Create RequestGroup object using torrent file specified by torrent-file // option. In this function, force-sequential is ignored. void createRequestGroupForBitTorrent (std::deque<SharedHandle<RequestGroup> >& result, Option* op, const std::deque<std::string>& uris); +#endif // ENABLE_BITTORRENT +#ifdef ENABLE_METALINK // Create RequestGroup objects using Metalink file specified by metalink-file // option. void createRequestGroupForMetalink (std::deque<SharedHandle<RequestGroup> >& result, Option* op); +#endif // ENABLE_METALINK // Create RequestGroup objects from reading file specified by input-file option. // If the value of input-file option is "-", stdin is used as a input source. diff --git a/src/main.cc b/src/main.cc index 869e2563..1d981fa1 100644 --- a/src/main.cc +++ b/src/main.cc @@ -65,6 +65,7 @@ #include "ConsoleStatCalc.h" #include "NullStatCalc.h" #include "download_helper.h" +#include "Exception.h" #ifdef ENABLE_METALINK # include "MetalinkHelper.h" # include "MetalinkEntry.h" diff --git a/test/DefaultBtProgressInfoFileTest.cc b/test/DefaultBtProgressInfoFileTest.cc index 536b3ea5..f5f98624 100644 --- a/test/DefaultBtProgressInfoFileTest.cc +++ b/test/DefaultBtProgressInfoFileTest.cc @@ -9,10 +9,10 @@ #include "Exception.h" #ifdef ENABLE_BITTORRENT #include "MockBtContext.h" -#endif // ENABLE_BITTORRENT #include "MockPeerStorage.h" -#include "MockPieceStorage.h" #include "BtRuntime.h" +#endif // ENABLE_BITTORRENT +#include "MockPieceStorage.h" #include "prefs.h" #include "SingleFileDownloadContext.h" #include "Piece.h" @@ -71,9 +71,11 @@ public: #endif // ENABLE_BITTORRENT } +#ifdef ENABLE_BITTORRENT void testSave(); void testLoad(); void testLoad_compat(); +#endif // ENABLE_BITTORRENT void testSave_nonBt(); void testLoad_nonBt(); void testLoad_nonBt_compat(); @@ -318,8 +320,6 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_compat() (new SingleFileDownloadContext(1024, 81920, "load-nonBt")); DefaultBtProgressInfoFile infoFile(dctx, _pieceStorage, _option.get()); - infoFile.setBtRuntime(_btRuntime); - infoFile.setPeerStorage(_peerStorage); CPPUNIT_ASSERT_EQUAL(std::string("./load-nonBt.aria2"), infoFile.getFilename()); @@ -364,8 +364,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt() (new SingleFileDownloadContext(1024, 81920, "load-nonBt-v0001")); DefaultBtProgressInfoFile infoFile(dctx, _pieceStorage, _option.get()); - infoFile.setBtRuntime(_btRuntime); - infoFile.setPeerStorage(_peerStorage); + CPPUNIT_ASSERT_EQUAL(std::string("./load-nonBt-v0001.aria2"), infoFile.getFilename()); infoFile.load(); @@ -410,8 +409,6 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_pieceLengthShorter() (new SingleFileDownloadContext(512, 81920, "load-nonBt-v0001")); DefaultBtProgressInfoFile infoFile(dctx, _pieceStorage, _option.get()); - infoFile.setBtRuntime(_btRuntime); - infoFile.setPeerStorage(_peerStorage); CPPUNIT_ASSERT_EQUAL(std::string("./load-nonBt-v0001.aria2"), infoFile.getFilename()); @@ -448,7 +445,6 @@ void DefaultBtProgressInfoFileTest::testSave_nonBt() _pieceStorage->addInFlightPiece(inFlightPieces); DefaultBtProgressInfoFile infoFile(dctx, _pieceStorage, _option.get()); - infoFile.setPeerStorage(_peerStorage); CPPUNIT_ASSERT_EQUAL(std::string("./save-temp.aria2"), infoFile.getFilename()); @@ -545,8 +541,10 @@ void DefaultBtProgressInfoFileTest::testUpdateFilename() (new SingleFileDownloadContext(1024, 81920, "file1")); DefaultBtProgressInfoFile infoFile(dctx, SharedHandle<MockPieceStorage>(), 0); +#ifdef ENABLE_BITTORRENT infoFile.setBtRuntime(_btRuntime); infoFile.setPeerStorage(_peerStorage); +#endif // ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL(std::string("./file1.aria2"), infoFile.getFilename()); diff --git a/test/DownloadHelperTest.cc b/test/DownloadHelperTest.cc index 77a8c56e..a0f94058 100644 --- a/test/DownloadHelperTest.cc +++ b/test/DownloadHelperTest.cc @@ -22,11 +22,18 @@ class DownloadHelperTest:public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(DownloadHelperTest); CPPUNIT_TEST(testCreateRequestGroupForUri); CPPUNIT_TEST(testCreateRequestGroupForUri_parameterized); - CPPUNIT_TEST(testCreateRequestGroupForUri_BitTorrent); - CPPUNIT_TEST(testCreateRequestGroupForUri_Metalink); CPPUNIT_TEST(testCreateRequestGroupForUriList); + +#ifdef ENABLE_BITTORRENT + CPPUNIT_TEST(testCreateRequestGroupForUri_BitTorrent); CPPUNIT_TEST(testCreateRequestGroupForBitTorrent); +#endif // ENABLE_BITTORRENT + +#ifdef ENABLE_METALINK + CPPUNIT_TEST(testCreateRequestGroupForUri_Metalink); CPPUNIT_TEST(testCreateRequestGroupForMetalink); +#endif // ENABLE_METALINK + CPPUNIT_TEST_SUITE_END(); public: void setUp() {} @@ -35,11 +42,17 @@ public: void testCreateRequestGroupForUri(); void testCreateRequestGroupForUri_parameterized(); - void testCreateRequestGroupForUri_BitTorrent(); - void testCreateRequestGroupForUri_Metalink(); void testCreateRequestGroupForUriList(); + +#ifdef ENABLE_BITTORRENT + void testCreateRequestGroupForUri_BitTorrent(); void testCreateRequestGroupForBitTorrent(); +#endif // ENABLE_BITTORRENT + +#ifdef ENABLE_METALINK + void testCreateRequestGroupForUri_Metalink(); void testCreateRequestGroupForMetalink(); +#endif // ENABLE_METALINK }; @@ -174,6 +187,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_parameterized() } } +#ifdef ENABLE_BITTORRENT void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent() { std::string array[] = { @@ -220,7 +234,9 @@ void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent() btctx->getActualBasePath()); } } +#endif // ENABLE_BITTORRENT +#ifdef ENABLE_METALINK void DownloadHelperTest::testCreateRequestGroupForUri_Metalink() { std::string array[] = { @@ -242,7 +258,12 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink() // group1: http://alpha/file, ... // group2-7: 6 file entry in Metalink and 1 torrent file download +#ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((size_t)7, result.size()); +#else // !ENABLE_BITTORRENT + CPPUNIT_ASSERT_EQUAL((size_t)6, result.size()); +#endif // !ENABLE_BITTORRENT + SharedHandle<RequestGroup> group = result[0]; std::deque<std::string> uris; group->getURIs(uris); @@ -270,6 +291,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink() aria2051Group->getNumConcurrentCommand()); } } +#endif // ENABLE_METALINK void DownloadHelperTest::testCreateRequestGroupForUriList() { @@ -304,6 +326,7 @@ void DownloadHelperTest::testCreateRequestGroupForUriList() fileISOCtx->getActualBasePath()); } +#ifdef ENABLE_BITTORRENT void DownloadHelperTest::testCreateRequestGroupForBitTorrent() { std::string array[] = { @@ -347,7 +370,9 @@ void DownloadHelperTest::testCreateRequestGroupForBitTorrent() CPPUNIT_ASSERT_EQUAL((size_t)1, result.size()); } } +#endif // ENABLE_BITTORRENT +#ifdef ENABLE_METALINK void DownloadHelperTest::testCreateRequestGroupForMetalink() { Option op; @@ -361,8 +386,11 @@ void DownloadHelperTest::testCreateRequestGroupForMetalink() createRequestGroupForMetalink(result, &op); +#ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((size_t)6, result.size()); - +#else // !ENABLE_BITTORRENT + CPPUNIT_ASSERT_EQUAL((size_t)5, result.size()); +#endif // !ENABLE_BITTORRENT SharedHandle<RequestGroup> group = result[0]; std::deque<std::string> uris; group->getURIs(uris); @@ -376,5 +404,6 @@ void DownloadHelperTest::testCreateRequestGroupForMetalink() CPPUNIT_ASSERT_EQUAL((unsigned int)1, group->getNumConcurrentCommand()); } } +#endif // ENABLE_METALINK } // namespace aria2 |
