mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
Optimized some small things in TransferDialog and SearchDialog.
Changed the parameter of the constructor of ftFileCreator and ftFileProvider and some methods of ftTransferModule from "std::string" to "const std::string&" git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4045 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
61b57ede65
commit
db19db7e60
8 changed files with 40 additions and 33 deletions
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
***********************************************************/
|
||||
|
||||
ftFileCreator::ftFileCreator(std::string path, uint64_t size, std::string hash,bool assume_availability)
|
||||
ftFileCreator::ftFileCreator(const std::string& path, uint64_t size, const std::string& hash,bool assume_availability)
|
||||
: ftFileProvider(path,size,hash), chunkMap(size,assume_availability)
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -47,7 +47,7 @@ class ftFileCreator: public ftFileProvider
|
|||
{
|
||||
public:
|
||||
|
||||
ftFileCreator(std::string savepath, uint64_t size, std::string hash,bool assume_availability);
|
||||
ftFileCreator(const std::string& savepath, uint64_t size, const std::string& hash,bool assume_availability);
|
||||
|
||||
~ftFileCreator();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
static const time_t UPLOAD_CHUNK_MAPS_TIME = 20 ; // time to ask for a new chunkmap from uploaders in seconds.
|
||||
|
||||
ftFileProvider::ftFileProvider(std::string path, uint64_t size, std::string hash)
|
||||
ftFileProvider::ftFileProvider(const std::string& path, uint64_t size, const std::string& hash)
|
||||
: mSize(size), hash(hash), file_name(path), fd(NULL)
|
||||
{
|
||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
class ftFileProvider
|
||||
{
|
||||
public:
|
||||
ftFileProvider(std::string path, uint64_t size, std::string hash);
|
||||
ftFileProvider(const std::string& path, uint64_t size, const std::string& hash);
|
||||
virtual ~ftFileProvider();
|
||||
|
||||
virtual bool getFileData(const std::string& peer_id,uint64_t offset, uint32_t &chunk_size, void *data);
|
||||
|
|
|
@ -95,7 +95,7 @@ ftTransferModule::~ftTransferModule()
|
|||
{}
|
||||
|
||||
|
||||
bool ftTransferModule::setFileSources(std::list<std::string> peerIds)
|
||||
bool ftTransferModule::setFileSources(const std::list<std::string>& peerIds)
|
||||
{
|
||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||
|
||||
|
@ -106,7 +106,7 @@ bool ftTransferModule::setFileSources(std::list<std::string> peerIds)
|
|||
std::cerr << " List of peers: " ;
|
||||
#endif
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<std::string>::const_iterator it;
|
||||
for(it = peerIds.begin(); it != peerIds.end(); it++)
|
||||
{
|
||||
|
||||
|
@ -136,7 +136,7 @@ bool ftTransferModule::getFileSources(std::list<std::string> &peerIds)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftTransferModule::addFileSource(std::string peerId)
|
||||
bool ftTransferModule::addFileSource(const std::string& peerId)
|
||||
{
|
||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||
std::map<std::string,peerInfo>::iterator mit;
|
||||
|
@ -167,7 +167,7 @@ bool ftTransferModule::addFileSource(std::string peerId)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftTransferModule::removeFileSource(std::string peerId)
|
||||
bool ftTransferModule::removeFileSource(const std::string& peerId)
|
||||
{
|
||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||
std::map<std::string,peerInfo>::iterator mit;
|
||||
|
@ -189,7 +189,7 @@ bool ftTransferModule::removeFileSource(std::string peerId)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftTransferModule::setPeerState(std::string peerId,uint32_t state,uint32_t maxRate)
|
||||
bool ftTransferModule::setPeerState(const std::string& peerId,uint32_t state,uint32_t maxRate)
|
||||
{
|
||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||
#ifdef FT_DEBUG
|
||||
|
@ -237,7 +237,7 @@ bool ftTransferModule::setPeerState(std::string peerId,uint32_t state,uint32_t m
|
|||
}
|
||||
|
||||
|
||||
bool ftTransferModule::getPeerState(std::string peerId,uint32_t &state,uint32_t &tfRate)
|
||||
bool ftTransferModule::getPeerState(const std::string& peerId,uint32_t &state,uint32_t &tfRate)
|
||||
{
|
||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||
std::map<std::string,peerInfo>::iterator mit;
|
||||
|
@ -257,7 +257,7 @@ bool ftTransferModule::getPeerState(std::string peerId,uint32_t &state,uint32_t
|
|||
return true;
|
||||
}
|
||||
|
||||
uint32_t ftTransferModule::getDataRate(std::string peerId)
|
||||
uint32_t ftTransferModule::getDataRate(const std::string& peerId)
|
||||
{
|
||||
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
|
||||
std::map<std::string,peerInfo>::iterator mit;
|
||||
|
@ -277,7 +277,7 @@ uint32_t ftTransferModule::getDataRate(std::string peerId)
|
|||
|
||||
|
||||
//interface to client module
|
||||
bool ftTransferModule::recvFileData(std::string peerId, uint64_t offset, uint32_t chunk_size, void *data)
|
||||
bool ftTransferModule::recvFileData(const std::string& peerId, uint64_t offset, uint32_t chunk_size, void *data)
|
||||
{
|
||||
#ifdef FT_DEBUG
|
||||
std::cerr << "ftTransferModule::recvFileData()";
|
||||
|
@ -316,7 +316,7 @@ bool ftTransferModule::recvFileData(std::string peerId, uint64_t offset, uint32_
|
|||
return ok;
|
||||
}
|
||||
|
||||
void ftTransferModule::requestData(std::string peerId, uint64_t offset, uint32_t chunk_size)
|
||||
void ftTransferModule::requestData(const std::string& peerId, uint64_t offset, uint32_t chunk_size)
|
||||
{
|
||||
#ifdef FT_DEBUG
|
||||
std::cerr << "ftTransferModule::requestData()";
|
||||
|
|
|
@ -133,13 +133,13 @@ public:
|
|||
~ftTransferModule();
|
||||
|
||||
//interface to download controller
|
||||
bool setFileSources(std::list<std::string> peerIds);
|
||||
bool addFileSource(std::string peerId);
|
||||
bool removeFileSource(std::string peerId);
|
||||
bool setPeerState(std::string peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
|
||||
bool setFileSources(const std::list<std::string>& peerIds);
|
||||
bool addFileSource(const std::string& peerId);
|
||||
bool removeFileSource(const std::string& peerId);
|
||||
bool setPeerState(const std::string& peerId,uint32_t state,uint32_t maxRate); //state = ONLINE/OFFLINE
|
||||
bool getFileSources(std::list<std::string> &peerIds);
|
||||
bool getPeerState(std::string peerId,uint32_t &state,uint32_t &tfRate);
|
||||
uint32_t getDataRate(std::string peerId);
|
||||
bool getPeerState(const std::string& peerId,uint32_t &state,uint32_t &tfRate);
|
||||
uint32_t getDataRate(const std::string& peerId);
|
||||
bool cancelTransfer();
|
||||
bool cancelFileTransferUpward();
|
||||
bool completeFileTransfer();
|
||||
|
@ -148,9 +148,9 @@ public:
|
|||
void addCRC32Map(const CRC32Map& map) ;
|
||||
|
||||
//interface to multiplex module
|
||||
bool recvFileData(std::string peerId, uint64_t offset,
|
||||
bool recvFileData(const std::string& peerId, uint64_t offset,
|
||||
uint32_t chunk_size, void *data);
|
||||
void requestData(std::string peerId, uint64_t offset, uint32_t chunk_size);
|
||||
void requestData(const std::string& peerId, uint64_t offset, uint32_t chunk_size);
|
||||
|
||||
//interface to file creator
|
||||
bool getChunk(const std::string& peer_id,uint32_t size_hint,uint64_t &offset, uint32_t &chunk_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue