Browse Source

Attempt to add the ability to listing file entries in a .torrent
file.
This feature is not yet complete.

* src/prefs.h (PREF_TORRENT_SHOW_FILES): New definition
* src/TorrentMan.cc (getMultiFileEntries): New function.
(getName): New function.
* src/TorrentMan.h (getMultiFileEntries): New function.
(getName): New function.
* src/main.cc (main): Use above 2 funtion.

Tatsuhiro Tsujikawa 19 years ago
parent
commit
1013d207f3
6 changed files with 50 additions and 5 deletions
  1. 17 3
      ChangeLog
  2. 1 1
      src/PeerInteractionCommand.cc
  3. 8 0
      src/TorrentMan.cc
  4. 3 0
      src/TorrentMan.h
  5. 19 1
      src/main.cc
  6. 2 0
      src/prefs.h

+ 17 - 3
ChangeLog

@@ -1,10 +1,24 @@
+2006-04-01  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Attempt to add the ability to listing file entries in a .torrent file.
+	This feature is not yet complete.
+	
+	* src/prefs.h (PREF_TORRENT_SHOW_FILES): New definition
+	* src/TorrentMan.cc (getMultiFileEntries): New function.
+	(getName): New function.
+	* src/TorrentMan.h (getMultiFileEntries): New function.
+	(getName): New function.
+	* src/main.cc (main): Use above 2 funtion. 
+	
+	* Release 0.3.2
+	
 2006-03-31  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	* src/PeerInteractionCommand.cc (checkInactiveConnection): New function
-	(detectMessageFlooding): Updated.
-	(checkLongTimePeerChoking): Updated.
+	(detectMessageFlooding): Updated threshold value.
+	(checkLongTimePeerChoking): Updated timeout value.
 	(getNewPieceAndSendInterest): Added debug log.
-	* src/PeerInteractionCommand.h: New function checkInactiveConnection()
+	* src/PeerInteractionCommand.h (checkInactiveConnection): New function
 	
 	* src/TorrentMan.cc (deleteOldErrorPeers): Updated.
 	(getPeer): Updated.

+ 1 - 1
src/PeerInteractionCommand.cc

@@ -336,7 +336,7 @@ Piece PeerInteractionCommand::getNewPieceAndSendInterest() {
     PendingMessage pendingMessage(PeerMessage::NOT_INTERESTED, peerConnection);
     sendMessageQueue->addPendingMessage(pendingMessage);
   } else {
-    e->logger->debug("CUID#%d - starting download for piece #%d", cuid, piece.getIndex());
+    e->logger->debug("CUID#%d - starting download for piece index=%d", cuid, piece.getIndex());
     e->logger->debug("CUID#%d - try to send interested", cuid);
     PendingMessage pendingMessage(PeerMessage::INTERESTED, peerConnection);
     sendMessageQueue->addPendingMessage(pendingMessage);

+ 8 - 0
src/TorrentMan.cc

@@ -381,6 +381,14 @@ void TorrentMan::setup(string metaInfoFile) {
   setupComplete = true;
 }
 
+const MultiFileEntries& TorrentMan::getMultiFileEntries() const {
+  return multiFileEntries;
+}
+
+string TorrentMan::getName() const {
+  return name;
+}
+
 bool TorrentMan::hasPiece(int index) const {
   return bitfield->isBitSet(index);
 }

+ 3 - 0
src/TorrentMan.h

@@ -223,6 +223,9 @@ public:
   int countUsedPiece() const { return usedPieces.size(); }
   int countAdvertisedPiece() const { return haves.size(); }
 
+  const MultiFileEntries& getMultiFileEntries() const;
+  string getName() const;
+
   enum FILE_MODE {
     SINGLE,
     MULTI

+ 19 - 1
src/main.cc

@@ -577,7 +577,25 @@ int main(int argc, char* argv[]) {
       te->torrentMan->logger = logger;
       te->torrentMan->setup(torrentFile.empty() ? 
 			    downloadedTorrentFile : torrentFile);
-
+      if(op->get(PREF_TORRENT_SHOW_FILES) == V_TRUE) {
+	cout << "File listing:" << endl;
+	switch(te->torrentMan->getFileMode()) {
+	case TorrentMan::SINGLE:
+	  printf("%s %s\nBytes", te->torrentMan->getName().c_str(),
+		 Util::llitos(te->torrentMan->getTotalLength(), true).c_str());
+	  break;
+	case TorrentMan::MULTI: {
+	  const MultiFileEntries& entries = te->torrentMan->getMultiFileEntries();
+	  for(MultiFileEntries::const_iterator itr = entries.begin();
+	      itr != entries.end(); itr++) {
+	    printf("%s %s\nBytes", itr->path.c_str(),
+		   Util::llitos(itr->length, true).c_str());
+	  break;
+	  }
+	}
+	}
+	exit(0);
+      }
       PeerListenCommand* listenCommand =
 	new PeerListenCommand(te->torrentMan->getNewCuid(), te);
       int port = listenCommand->bindPort(6881, 6999);

+ 2 - 0
src/prefs.h

@@ -88,5 +88,7 @@
  */
 // values: 1*digit
 #define PREF_PEER_CONNECTION_TIMEOUT "peer_connection_timeout"
+// values: true | false
+#define PREF_TORRENT_SHOW_FILES "torrent_show_files"
 
 #endif // _D_PREFS_H_