mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
Added consistent display of chunk map
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1837 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
adbdb51c5d
commit
e88d2c1928
@ -94,6 +94,20 @@ void ftController::setFtSearchNExtra(ftSearch *search, ftExtraList *list)
|
||||
mExtraList = list;
|
||||
}
|
||||
|
||||
bool ftController::getFileChunksDetails(const std::string& hash,FileChunksInfo& info)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string, ftFileControl>::iterator it = mDownloads.find(hash) ;
|
||||
|
||||
if(it == mDownloads.end())
|
||||
return false ;
|
||||
|
||||
it->second.mCreator->getChunkMap(info) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void ftController::addFileSource(const std::string& hash,const std::string& peer_id)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
@ -136,6 +136,7 @@ bool FileCancel(std::string hash);
|
||||
bool FileControl(std::string hash, uint32_t flags);
|
||||
bool FileClearCompleted();
|
||||
bool FlagFileComplete(std::string hash);
|
||||
bool getFileChunksDetails(const std::string& hash,FileChunksInfo& info);
|
||||
|
||||
/* get Details of File Transfers */
|
||||
bool FileDownloads(std::list<std::string> &hashs);
|
||||
|
@ -16,7 +16,7 @@
|
||||
***********************************************************/
|
||||
|
||||
ftFileCreator::ftFileCreator(std::string path, uint64_t size, std::string
|
||||
hash, uint64_t recvd): ftFileProvider(path,size,hash)
|
||||
hash, uint64_t recvd): ftFileProvider(path,size,hash), chunkMap(size)
|
||||
{
|
||||
/*
|
||||
* FIXME any inits to do?
|
||||
@ -38,6 +38,8 @@ hash, uint64_t recvd): ftFileProvider(path,size,hash)
|
||||
/* initialise the Transfer Lists */
|
||||
mStart = recvd;
|
||||
mEnd = recvd;
|
||||
|
||||
chunkMap.received(recvd) ;
|
||||
}
|
||||
|
||||
bool ftFileCreator::getFileData(uint64_t offset,
|
||||
@ -264,6 +266,9 @@ int ftFileCreator::locked_notifyReceived(uint64_t offset, uint32_t chunk_size)
|
||||
mStart = offset + chunk_size;
|
||||
}
|
||||
|
||||
// update chunk map
|
||||
chunkMap.received(mStart) ;
|
||||
|
||||
if (mChunks.size() == 0)
|
||||
{
|
||||
mStart = mEnd;
|
||||
@ -271,6 +276,7 @@ int ftFileCreator::locked_notifyReceived(uint64_t offset, uint32_t chunk_size)
|
||||
|
||||
/* otherwise there is another earlier block to go
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -349,11 +355,18 @@ bool ftFileCreator::getMissingChunk(uint64_t &offset, uint32_t &chunk)
|
||||
#endif
|
||||
|
||||
mChunks[offset] = ftChunk(offset, chunk, ts);
|
||||
|
||||
chunkMap.requested(offset,chunk) ;
|
||||
}
|
||||
|
||||
return true; /* cos more data to get */
|
||||
}
|
||||
|
||||
void ftFileCreator::getChunkMap(FileChunksInfo& info)
|
||||
{
|
||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||
info = chunkMap ;
|
||||
}
|
||||
|
||||
bool ftFileCreator::locked_printChunkMap()
|
||||
{
|
||||
|
@ -33,6 +33,7 @@
|
||||
*
|
||||
*/
|
||||
#include "ftfileprovider.h"
|
||||
#include "ftchunkmap.h"
|
||||
#include <map>
|
||||
class ftChunk;
|
||||
|
||||
@ -49,6 +50,7 @@ virtual bool getFileData(uint64_t offset, uint32_t &chunk_size, void *data);
|
||||
bool finished() { return getRecvd() == getFileSize(); }
|
||||
uint64_t getRecvd();
|
||||
|
||||
void getChunkMap(FileChunksInfo& info) ;
|
||||
|
||||
/*
|
||||
* creation functions for FileCreator
|
||||
@ -74,6 +76,7 @@ private:
|
||||
|
||||
std::map<uint64_t, ftChunk> mChunks;
|
||||
|
||||
ChunkMap chunkMap ;
|
||||
};
|
||||
|
||||
class ftChunk {
|
||||
|
@ -307,17 +307,19 @@ void ftServer::getDwlDetails(std::list<DwlDetails> & details)
|
||||
|
||||
bool ftServer::FileChunksDetails(const std::string& hash,FileChunksInfo& info)
|
||||
{
|
||||
// for know put some dummy info. It's for display sake only.
|
||||
info.chunk_size = 1024*1024 ;
|
||||
info.file_size = 250*info.chunk_size - 123 ; // last chunk is not complete.
|
||||
info.chunks.resize(250,FileChunksInfo::CHUNK_DONE) ;
|
||||
int n = rand()%150 + 50 ;
|
||||
for(int i=0;i<10;++i)
|
||||
info.chunks[n+i] = FileChunksInfo::CHUNK_ACTIVE ;
|
||||
for(int i=n+10;i<250;++i)
|
||||
info.chunks[i] = FileChunksInfo::CHUNK_OUTSTANDING ;
|
||||
|
||||
return true ;
|
||||
return mFtController->getFileChunksDetails(hash,info);
|
||||
//
|
||||
// // for know put some dummy info. It's for display sake only.
|
||||
// info.chunk_size = 1024*1024 ;
|
||||
// info.file_size = 250*info.chunk_size - 123 ; // last chunk is not complete.
|
||||
// info.chunks.resize(250,FileChunksInfo::CHUNK_DONE) ;
|
||||
// int n = rand()%150 + 50 ;
|
||||
// for(int i=0;i<10;++i)
|
||||
// info.chunks[n+i] = FileChunksInfo::CHUNK_ACTIVE ;
|
||||
// for(int i=n+10;i<250;++i)
|
||||
// info.chunks[i] = FileChunksInfo::CHUNK_OUTSTANDING ;
|
||||
//
|
||||
// return true ;
|
||||
}
|
||||
|
||||
/* Directory Handling */
|
||||
|
@ -14,8 +14,10 @@ debug {
|
||||
# DEFINES *= DEBUG
|
||||
# DEFINES *= OPENDHT_DEBUG DHT_DEBUG CONN_DEBUG DEBUG_UDP_SORTER P3DISC_DEBUG DEBUG_UDP_LAYER FT_DEBUG EXTADDRSEARCH_DEBUG
|
||||
# DEFINES *= CHAT_DEBUG CONTROL_DEBUG FT_DEBUG
|
||||
# DEFINES *= P3TURTLE_DEBUG
|
||||
# DEFINES *= UPNP_DEBUG CONN_DEBUG
|
||||
# DEFINES *= P3TURTLE_DEBUG UPNP_DEBUG
|
||||
# DEFINES *= CONN_DEBUG
|
||||
# DEFINES *= NET_DEBUG
|
||||
# DEFINES *= DISTRIB_DEBUG
|
||||
QMAKE_CXXFLAGS *= -g
|
||||
}
|
||||
|
||||
@ -147,6 +149,7 @@ HEADERS += dbase/cachestrapper.h \
|
||||
ft/ftfileprovider.h \
|
||||
ft/ftfilesearch.h \
|
||||
ft/ftsearch.h \
|
||||
ft/ftchunkmap.h \
|
||||
ft/ftserver.h \
|
||||
ft/fttransfermodule.h \
|
||||
ft/ftdwlqueue.h \
|
||||
@ -288,6 +291,7 @@ SOURCES += \
|
||||
ft/ftextralist.cc \
|
||||
ft/ftfilecreator.cc \
|
||||
ft/ftdata.cc \
|
||||
ft/ftchunkmap.cc \
|
||||
ft/ftfileprovider.cc \
|
||||
ft/ftdwlqueue.cc \
|
||||
dht/opendhtmgr.cc \
|
||||
|
@ -101,7 +101,7 @@ void FileTransferInfoWidget::draw(const FileChunksInfo& info,QPainter *painter)
|
||||
if (fileSize%blockSize == 0) blocks--;
|
||||
QRectF source(0.0, 0.0, 12.0, 12.0);
|
||||
|
||||
for (int i=0;i<=blocks;i++)
|
||||
for (int i=0;i<blocks;i++)
|
||||
{
|
||||
if (x > maxWidth - 13)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user