mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-17 10:31:05 -04:00
changed std::string into RsFileHash for all file hashes
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7137 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
533216c9e3
commit
acf34cd7ad
84 changed files with 698 additions and 718 deletions
|
@ -92,7 +92,7 @@ bool CacheSource::loadLocalCache(const RsCacheData &data)
|
|||
}
|
||||
|
||||
/* control Caches available */
|
||||
bool CacheSource::refreshCache(const RsCacheData &data,const std::set<SSLIdType>& destination_peers)
|
||||
bool CacheSource::refreshCache(const RsCacheData &data,const std::set<RsPeerId>& destination_peers)
|
||||
{
|
||||
bool ret = false;
|
||||
{
|
||||
|
@ -122,9 +122,9 @@ bool CacheSource::refreshCache(const RsCacheData &data,const std::set<SSLIdType>
|
|||
|
||||
if (mStrapper) /* allow testing without full feedback */
|
||||
{
|
||||
std::set<SSLIdType> allowed_dest_peers ;
|
||||
std::set<RsPeerId> allowed_dest_peers ;
|
||||
|
||||
for(std::set<SSLIdType>::const_iterator it(destination_peers.begin());it!=destination_peers.end();++it)
|
||||
for(std::set<RsPeerId>::const_iterator it(destination_peers.begin());it!=destination_peers.end();++it)
|
||||
if(isPeerAcceptedAsCacheReceiver(*it))
|
||||
allowed_dest_peers.insert(*it) ;
|
||||
|
||||
|
@ -161,14 +161,14 @@ bool CacheSource::refreshCache(const RsCacheData &data)
|
|||
}
|
||||
// Strip down destination peers to eliminate peers that are not allowed to receive cache items.
|
||||
|
||||
std::list<SSLIdType> ids;
|
||||
std::list<RsPeerId> ids;
|
||||
rsPeers->getOnlineList(ids);
|
||||
|
||||
if (mStrapper) /* allow testing without full feedback */
|
||||
{
|
||||
std::set<SSLIdType> allowed_dest_peers ;
|
||||
std::set<RsPeerId> allowed_dest_peers ;
|
||||
|
||||
for(std::list<SSLIdType>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
for(std::list<RsPeerId>::const_iterator it(ids.begin());it!=ids.end();++it)
|
||||
if(isPeerAcceptedAsCacheReceiver(*it))
|
||||
allowed_dest_peers.insert(*it) ;
|
||||
|
||||
|
@ -232,7 +232,7 @@ bool CacheSource::clearCache(CacheId id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool CacheSource::cachesAvailable(const SSLIdType& pid, std::map<CacheId, RsCacheData> &ids)
|
||||
bool CacheSource::cachesAvailable(const RsPeerId& pid, std::map<CacheId, RsCacheData> &ids)
|
||||
{
|
||||
if(!isPeerAcceptedAsCacheReceiver(pid))
|
||||
return false ;
|
||||
|
@ -253,7 +253,7 @@ bool CacheSource::cachesAvailable(const SSLIdType& pid, std::map<CacheId, RsC
|
|||
}
|
||||
|
||||
|
||||
bool CacheSource::findCache(std::string hash, RsCacheData &data) const
|
||||
bool CacheSource::findCache(const RsFileHash &hash, RsCacheData &data) const
|
||||
{
|
||||
lockData(); /* LOCK MUTEX */
|
||||
|
||||
|
@ -271,7 +271,7 @@ bool CacheSource::findCache(std::string hash, RsCacheData &data) const
|
|||
|
||||
if (!found)
|
||||
{
|
||||
std::map<std::string, RsCacheData>::const_iterator oit;
|
||||
std::map<RsFileHash, RsCacheData>::const_iterator oit;
|
||||
oit = mOldCaches.find(hash);
|
||||
if (oit != mOldCaches.end())
|
||||
{
|
||||
|
@ -336,7 +336,7 @@ void CacheStore::listCaches(std::ostream &out)
|
|||
lockData(); /* LOCK MUTEX */
|
||||
|
||||
/* can overwrite for more control! */
|
||||
std::map<SSLIdType, CacheSet>::iterator pit;
|
||||
std::map<RsPeerId, CacheSet>::iterator pit;
|
||||
out << "CacheStore::listCaches() [" << getCacheType();
|
||||
out << "] Total People: " << caches.size();
|
||||
out << std::endl;
|
||||
|
@ -377,7 +377,7 @@ bool CacheStore::locked_getStoredCache(RsCacheData &data)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::map<SSLIdType, CacheSet>::iterator pit;
|
||||
std::map<RsPeerId, CacheSet>::iterator pit;
|
||||
if (caches.end() == (pit = caches.find(data.pid)))
|
||||
{
|
||||
return false;
|
||||
|
@ -414,7 +414,7 @@ bool CacheStore::getAllStoredCaches(std::list<RsCacheData> &data)
|
|||
{
|
||||
lockData(); /* LOCK MUTEX */
|
||||
|
||||
std::map<SSLIdType, CacheSet>::iterator pit;
|
||||
std::map<RsPeerId, CacheSet>::iterator pit;
|
||||
for(pit = caches.begin(); pit != caches.end(); pit++)
|
||||
{
|
||||
CacheSet::iterator cit;
|
||||
|
@ -547,7 +547,7 @@ int CacheStore::nameCache(RsCacheData &data)
|
|||
std::cerr << "CacheStore::nameCache() for:" << data << std::endl;
|
||||
#endif
|
||||
|
||||
data.name = data.hash;
|
||||
data.name = data.hash.toStdString();
|
||||
data.path = getCacheDir();
|
||||
|
||||
#ifdef CS_DEBUG
|
||||
|
@ -585,7 +585,7 @@ int CacheStore::loadCache(const RsCacheData &data)
|
|||
void CacheStore::locked_storeCacheEntry(const RsCacheData &data)
|
||||
{
|
||||
/* store what we loaded - overwriting if necessary */
|
||||
std::map<SSLIdType, CacheSet>::iterator pit;
|
||||
std::map<RsPeerId, CacheSet>::iterator pit;
|
||||
if (caches.end() == (pit = caches.find(data.pid)))
|
||||
{
|
||||
/* add in a new CacheSet */
|
||||
|
@ -658,7 +658,7 @@ void CacheStrapper::statusChange(const std::list<pqipeer> &plist)
|
|||
|
||||
/**************** from pqimonclient ********************/
|
||||
|
||||
void CacheStrapper::refreshCache(const RsCacheData &data,const std::set<SSLIdType>& destination_peers)
|
||||
void CacheStrapper::refreshCache(const RsCacheData &data,const std::set<RsPeerId>& destination_peers)
|
||||
{
|
||||
/* we've received an update
|
||||
* send to all online peers + self intersected with online peers.
|
||||
|
@ -666,13 +666,13 @@ void CacheStrapper::refreshCache(const RsCacheData &data,const std::set<SSLIdTyp
|
|||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheStrapper::refreshCache() : " << data << std::endl;
|
||||
#endif
|
||||
const SSLIdType& ownid = mLinkMgr->getOwnId() ;
|
||||
std::list<SSLIdType> ids;
|
||||
const RsPeerId& ownid = mLinkMgr->getOwnId() ;
|
||||
std::list<RsPeerId> ids;
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
ids.push_back(ownid) ;
|
||||
|
||||
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
|
||||
for(std::list<SSLIdType>::const_iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
for(std::list<RsPeerId>::const_iterator it = ids.begin(); it != ids.end(); ++it)
|
||||
if(destination_peers.find(*it) != destination_peers.end())
|
||||
{
|
||||
#ifdef CS_DEBUG
|
||||
|
@ -714,7 +714,7 @@ void CacheStrapper::refreshCacheStore(const RsCacheData & /* data */ )
|
|||
|
||||
}
|
||||
|
||||
bool CacheStrapper::getCacheUpdates(std::list<std::pair<SSLIdType, RsCacheData> > &updates)
|
||||
bool CacheStrapper::getCacheUpdates(std::list<std::pair<RsPeerId, RsCacheData> > &updates)
|
||||
{
|
||||
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
|
||||
updates = mCacheUpdates;
|
||||
|
@ -741,7 +741,7 @@ void CacheStrapper::recvCacheResponse(RsCacheData &data, time_t /* ts */)
|
|||
|
||||
}
|
||||
|
||||
void CacheStrapper::handleCacheQuery(const SSLIdType& id, std::map<CacheId,RsCacheData> &hashs)
|
||||
void CacheStrapper::handleCacheQuery(const RsPeerId& id, std::map<CacheId,RsCacheData> &hashs)
|
||||
{
|
||||
/* basic version just iterates through ....
|
||||
* more complex could decide who gets what!
|
||||
|
@ -795,7 +795,7 @@ void CacheStrapper::listPeerStatus(std::ostream & /* out */)
|
|||
}
|
||||
|
||||
|
||||
bool CacheStrapper::findCache(std::string hash, RsCacheData &data) const
|
||||
bool CacheStrapper::findCache(const RsFileHash& hash, RsCacheData &data) const
|
||||
{
|
||||
/* can overwrite for more control! */
|
||||
std::map<uint16_t, CachePair>::const_iterator it;
|
||||
|
@ -854,7 +854,7 @@ bool CacheStrapper::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
std::list<RsCacheData>::iterator cit;
|
||||
std::list<RsCacheData> ownCaches;
|
||||
std::list<RsCacheData> remoteCaches;
|
||||
const SSLIdType& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
|
||||
std::map<uint16_t, CachePair>::iterator it;
|
||||
for(it = caches.begin(); it != caches.end(); it++)
|
||||
|
@ -934,7 +934,7 @@ bool CacheStrapper::loadList(std::list<RsItem *>& load)
|
|||
#endif
|
||||
std::list<RsCacheData> ownCaches;
|
||||
std::list<RsCacheData> remoteCaches;
|
||||
const SSLIdType& ownId = mLinkMgr->getOwnId();
|
||||
const RsPeerId& ownId = mLinkMgr->getOwnId();
|
||||
|
||||
//peerConnectState ownState;
|
||||
//mPeerMgr->getOwnNetStatus(ownState);
|
||||
|
@ -956,7 +956,7 @@ bool CacheStrapper::loadList(std::list<RsItem *>& load)
|
|||
#endif
|
||||
RsCacheData cd;
|
||||
|
||||
cd.pid = SSLIdType(rscc->pid) ;
|
||||
cd.pid = RsPeerId(rscc->pid) ;
|
||||
|
||||
#if 0
|
||||
if(cd.pid == ownId)
|
||||
|
@ -1133,8 +1133,8 @@ bool CacheTransfer::RequestCache(RsCacheData &data, CacheStore *cbStore)
|
|||
* - if duplicate hash -> Fail Transfer
|
||||
*/
|
||||
|
||||
std::map<std::string, RsCacheData>::iterator dit;
|
||||
std::map<std::string, CacheStore *>::iterator sit;
|
||||
std::map<RsFileHash, RsCacheData>::iterator dit;
|
||||
std::map<RsFileHash, CacheStore *>::iterator sit;
|
||||
|
||||
for(dit = cbData.begin(); dit != cbData.end(); dit++)
|
||||
{
|
||||
|
@ -1199,7 +1199,7 @@ bool CacheTransfer::RequestCache(RsCacheData &data, CacheStore *cbStore)
|
|||
|
||||
|
||||
/* to be overloaded */
|
||||
bool CacheTransfer::RequestCacheFile(const SSLIdType& id, std::string path, std::string hash, uint64_t size)
|
||||
bool CacheTransfer::RequestCacheFile(const RsPeerId& id, std::string path, const RsFileHash& hash, uint64_t size)
|
||||
{
|
||||
(void) id;
|
||||
(void) path;
|
||||
|
@ -1218,7 +1218,7 @@ bool CacheTransfer::RequestCacheFile(const SSLIdType& id, std::string path, std:
|
|||
}
|
||||
|
||||
/* to be overloaded */
|
||||
bool CacheTransfer::CancelCacheFile(const SSLIdType& id, std::string path, std::string hash, uint64_t size)
|
||||
bool CacheTransfer::CancelCacheFile(const RsPeerId& id, std::string path, const RsFileHash &hash, uint64_t size)
|
||||
{
|
||||
(void) id;
|
||||
(void) path;
|
||||
|
@ -1237,10 +1237,10 @@ bool CacheTransfer::CancelCacheFile(const SSLIdType& id, std::string path, std::
|
|||
|
||||
|
||||
/* internal completion -> does cb */
|
||||
bool CacheTransfer::CompletedCache(std::string hash)
|
||||
bool CacheTransfer::CompletedCache(const RsFileHash& hash)
|
||||
{
|
||||
std::map<std::string, RsCacheData>::iterator dit;
|
||||
std::map<std::string, CacheStore *>::iterator sit;
|
||||
std::map<RsFileHash, RsCacheData>::iterator dit;
|
||||
std::map<RsFileHash, CacheStore *>::iterator sit;
|
||||
|
||||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheTransfer::CompletedCache(" << hash << ")";
|
||||
|
@ -1276,10 +1276,10 @@ bool CacheTransfer::CompletedCache(std::string hash)
|
|||
}
|
||||
|
||||
/* internal completion -> does cb */
|
||||
bool CacheTransfer::FailedCache(std::string hash)
|
||||
bool CacheTransfer::FailedCache(const RsFileHash& hash)
|
||||
{
|
||||
std::map<std::string, RsCacheData>::iterator dit;
|
||||
std::map<std::string, CacheStore *>::iterator sit;
|
||||
std::map<RsFileHash, RsCacheData>::iterator dit;
|
||||
std::map<RsFileHash, CacheStore *>::iterator sit;
|
||||
|
||||
/* find in store.... */
|
||||
sit = cbStores.find(hash);
|
||||
|
@ -1301,7 +1301,7 @@ bool CacheTransfer::FailedCache(std::string hash)
|
|||
}
|
||||
|
||||
|
||||
bool CacheTransfer::FindCacheFile(std::string hash, std::string &path, uint64_t &size)
|
||||
bool CacheTransfer::FindCacheFile(const RsFileHash &hash, std::string &path, uint64_t &size)
|
||||
{
|
||||
RsCacheData data;
|
||||
if (strapper->findCache(hash, data))
|
||||
|
|
|
@ -86,12 +86,12 @@ class RsCacheData
|
|||
{
|
||||
public:
|
||||
|
||||
SSLIdType pid; /// peer id
|
||||
RsPeerId pid; /// peer id
|
||||
/// REMOVED as a WASTE to look it up everywhere! std::string pname; /// peer name (can be used by cachestore)
|
||||
CacheId cid; /// cache id
|
||||
std::string path; /// file system path where physical cache data is located
|
||||
std::string name;
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
uint64_t size;
|
||||
time_t recvd; /// received timestamp
|
||||
};
|
||||
|
@ -114,7 +114,7 @@ class CacheTransfer
|
|||
/*!
|
||||
* upload side of things .... searches through CacheStrapper.
|
||||
*/
|
||||
bool FindCacheFile(std::string hash, std::string &path, uint64_t &size);
|
||||
bool FindCacheFile(const RsFileHash& hash, std::string &path, uint64_t &size);
|
||||
|
||||
/*!
|
||||
* At the download side RequestCache() => overloaded RequestCacheFile()
|
||||
|
@ -127,18 +127,18 @@ class CacheTransfer
|
|||
/*!
|
||||
* to be overloaded
|
||||
*/
|
||||
virtual bool RequestCacheFile(const SSLIdType& id, std::string path, std::string hash, uint64_t size);
|
||||
virtual bool CancelCacheFile(const SSLIdType& id, std::string path, std::string hash, uint64_t size);
|
||||
virtual bool RequestCacheFile(const RsPeerId& id, std::string path, const RsFileHash& hash, uint64_t size);
|
||||
virtual bool CancelCacheFile(const RsPeerId& id, std::string path, const RsFileHash& hash, uint64_t size);
|
||||
|
||||
bool CompletedCache(std::string hash); /* internal completion -> does cb */
|
||||
bool FailedCache(std::string hash); /* internal completion -> does cb */
|
||||
bool CompletedCache(const RsFileHash &hash); /* internal completion -> does cb */
|
||||
bool FailedCache(const RsFileHash &hash); /* internal completion -> does cb */
|
||||
|
||||
private:
|
||||
|
||||
CacheStrapper *strapper;
|
||||
|
||||
std::map<std::string, RsCacheData> cbData;
|
||||
std::map<std::string, CacheStore *> cbStores;
|
||||
std::map<RsFileHash, RsCacheData> cbData;
|
||||
std::map<RsFileHash, CacheStore *> cbStores;
|
||||
};
|
||||
|
||||
|
||||
|
@ -167,7 +167,7 @@ class CacheSource
|
|||
* called to determine available cache for peer -
|
||||
* default acceptable (returns all)
|
||||
*/
|
||||
virtual bool cachesAvailable(const SSLIdType& pid, std::map<CacheId, RsCacheData> &ids);
|
||||
virtual bool cachesAvailable(const RsPeerId& pid, std::map<CacheId, RsCacheData> &ids);
|
||||
|
||||
/*!
|
||||
* function called at startup to load from
|
||||
|
@ -177,12 +177,12 @@ class CacheSource
|
|||
virtual bool loadLocalCache(const RsCacheData &data);
|
||||
|
||||
/* control Caches available */
|
||||
bool refreshCache(const RsCacheData &data,const std::set<SSLIdType>& destination_peers);
|
||||
bool refreshCache(const RsCacheData &data,const std::set<RsPeerId>& destination_peers);
|
||||
bool refreshCache(const RsCacheData &data);
|
||||
bool clearCache(CacheId id);
|
||||
|
||||
/* controls if peer is an accepted receiver for cache items. Default is yes. To be overloaded. */
|
||||
virtual bool isPeerAcceptedAsCacheReceiver(const SSLIdType& /*peer_id*/) { return true ; }
|
||||
virtual bool isPeerAcceptedAsCacheReceiver(const RsPeerId& /*peer_id*/) { return true ; }
|
||||
|
||||
/* get private data */
|
||||
std::string getCacheDir() { return cacheDir; }
|
||||
|
@ -193,7 +193,7 @@ class CacheSource
|
|||
void listCaches(std::ostream &out);
|
||||
|
||||
/* search */
|
||||
bool findCache(std::string hash, RsCacheData &data) const;
|
||||
bool findCache(const RsFileHash& hash, RsCacheData &data) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -206,7 +206,7 @@ class CacheSource
|
|||
void unlockData() const;
|
||||
|
||||
CacheSet caches; /// all local cache data stored here
|
||||
std::map<std::string, RsCacheData> mOldCaches; /// replaced/cleared caches are pushed here (in case requested)
|
||||
std::map<RsFileHash, RsCacheData> mOldCaches; /// replaced/cleared caches are pushed here (in case requested)
|
||||
|
||||
private:
|
||||
|
||||
|
@ -271,7 +271,7 @@ class CacheStore
|
|||
/* virtual functions overloaded by cache implementor */
|
||||
|
||||
/* controls if peer is an accepted provider for cache items. Default is yes. To be overloaded. */
|
||||
virtual bool isPeerAcceptedAsCacheProvider(const SSLIdType& /*peer_id*/) { return true ; }
|
||||
virtual bool isPeerAcceptedAsCacheProvider(const RsPeerId& /*peer_id*/) { return true ; }
|
||||
|
||||
/*!
|
||||
* @param data cache data is stored here
|
||||
|
@ -329,7 +329,7 @@ class CacheStore
|
|||
std::string cacheDir;
|
||||
|
||||
mutable RsMutex cMutex;
|
||||
std::map<SSLIdType, CacheSet> caches;
|
||||
std::map<RsPeerId, CacheSet> caches;
|
||||
|
||||
};
|
||||
|
||||
|
@ -402,7 +402,7 @@ virtual void statusChange(const std::list<pqipeer> &plist);
|
|||
*
|
||||
*/
|
||||
void refreshCache(const RsCacheData &data);
|
||||
void refreshCache(const RsCacheData &data,const std::set<SSLIdType>& destination_peers); // specify a particular list of destination peers (self not added!)
|
||||
void refreshCache(const RsCacheData &data,const std::set<RsPeerId>& destination_peers); // specify a particular list of destination peers (self not added!)
|
||||
|
||||
/*!
|
||||
* forces config savelist
|
||||
|
@ -414,7 +414,7 @@ void refreshCacheStore(const RsCacheData &data);
|
|||
/*!
|
||||
* list of Caches to send out
|
||||
*/
|
||||
bool getCacheUpdates(std::list<std::pair<SSLIdType, RsCacheData> > &updates);
|
||||
bool getCacheUpdates(std::list<std::pair<RsPeerId, RsCacheData> > &updates);
|
||||
|
||||
/*!
|
||||
* add to strapper's cachepair set so a related service's store and source can be maintained
|
||||
|
@ -424,14 +424,14 @@ void addCachePair(CachePair pair);
|
|||
|
||||
/*** I/O (2) ***/
|
||||
void recvCacheResponse(RsCacheData &data, time_t ts);
|
||||
void handleCacheQuery(const SSLIdType& id, std::map<CacheId, RsCacheData> &data);
|
||||
void handleCacheQuery(const RsPeerId& id, std::map<CacheId, RsCacheData> &data);
|
||||
|
||||
|
||||
/*!
|
||||
* search through CacheSources.
|
||||
* @return false if cachedate mapping to hash not found
|
||||
*/
|
||||
bool findCache(std::string hash, RsCacheData &data) const;
|
||||
bool findCache(const RsFileHash &hash, RsCacheData &data) const;
|
||||
|
||||
/* display */
|
||||
void listCaches(std::ostream &out);
|
||||
|
@ -467,7 +467,7 @@ virtual bool loadList(std::list<RsItem *>& load);
|
|||
|
||||
RsMutex csMtx; /* protect below */
|
||||
|
||||
std::list<std::pair<SSLIdType, RsCacheData> > mCacheUpdates;
|
||||
std::list<std::pair<RsPeerId, RsCacheData> > mCacheUpdates;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "retroshare/rsiface.h"
|
||||
#include "pqi/p3notify.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "util/folderiterator.h"
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -52,7 +53,7 @@
|
|||
//#define FIM_DEBUG 1
|
||||
// ***********/
|
||||
|
||||
FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, std::string cachedir, const SSLIdType& pid,const std::string& config_dir)
|
||||
FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, std::string cachedir, const RsPeerId& pid,const std::string& config_dir)
|
||||
:CacheSource(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cachedir), fiMutex("FileIndexMonitor"), fi(pid),
|
||||
pendingDirs(false), pendingForceCacheWrite(false),
|
||||
mForceCheck(false), mInCheck(false), hashCache(config_dir+"/" + "file_cache.lst"),useHashCache(true)
|
||||
|
@ -142,12 +143,6 @@ HashCache::HashCache(const std::string& path)
|
|||
f.getline(buff,max_line_size,'\n') ; if(sscanf(buff,RsDirUtil::scanf_string_for_uint(sizeof(info.modf_stamp)),&info.modf_stamp) != 1) { std::cerr << "Could not read one entry! Giving up." << std::endl; break ; }
|
||||
f.getline(buff,max_line_size,'\n') ; info.hash = std::string(buff) ;
|
||||
|
||||
if(info.hash.length() != 40)
|
||||
{
|
||||
std::cerr << "Loaded hash is not a hash: " << info.hash << std::endl;
|
||||
break ;
|
||||
}
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << " (" << name << ", " << info.size << ", " << info.time_stamp << ", " << info.modf_stamp << ", " << info.hash << std::endl ;
|
||||
++n ;
|
||||
|
@ -194,7 +189,7 @@ void HashCache::save()
|
|||
#endif
|
||||
}
|
||||
|
||||
bool HashCache::find(const std::string& full_path,uint64_t size,time_t time_stamp,std::string& hash)
|
||||
bool HashCache::find(const std::string& full_path,uint64_t size,time_t time_stamp,RsFileHash& hash)
|
||||
{
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "HashCache: looking for " << full_path << std::endl ;
|
||||
|
@ -219,7 +214,7 @@ bool HashCache::find(const std::string& full_path,uint64_t size,time_t time_stam
|
|||
return false ;
|
||||
}
|
||||
}
|
||||
void HashCache::insert(const std::string& full_path,uint64_t size,time_t time_stamp,const std::string& hash)
|
||||
void HashCache::insert(const std::string& full_path,uint64_t size,time_t time_stamp,const RsFileHash& hash)
|
||||
{
|
||||
HashCacheInfo info ;
|
||||
info.size = size ;
|
||||
|
@ -271,7 +266,7 @@ FileIndexMonitor::~FileIndexMonitor()
|
|||
/* Data cleanup - TODO */
|
||||
}
|
||||
|
||||
int FileIndexMonitor::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const SSLIdType& peer_id)
|
||||
int FileIndexMonitor::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id)
|
||||
{
|
||||
results.clear();
|
||||
std::list<FileEntry *> firesults;
|
||||
|
@ -284,7 +279,7 @@ int FileIndexMonitor::SearchKeywords(std::list<std::string> keywords, std::list<
|
|||
return filterResults(firesults,results,flags,peer_id) ;
|
||||
}
|
||||
|
||||
int FileIndexMonitor::SearchBoolExp(Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const SSLIdType& peer_id) const
|
||||
int FileIndexMonitor::SearchBoolExp(Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const
|
||||
{
|
||||
results.clear();
|
||||
std::list<FileEntry *> firesults;
|
||||
|
@ -297,7 +292,7 @@ int FileIndexMonitor::SearchBoolExp(Expression *exp, std::list<DirDetails>& resu
|
|||
return filterResults(firesults,results,flags,peer_id) ;
|
||||
}
|
||||
|
||||
int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const SSLIdType& peer_id) const
|
||||
int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if((flags & ~RS_FILE_HINTS_PERMISSION_MASK) > 0)
|
||||
|
@ -337,7 +332,7 @@ int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<D
|
|||
return !results.empty() ;
|
||||
}
|
||||
|
||||
bool FileIndexMonitor::findLocalFile(std::string hash,FileSearchFlags hint_flags, const SSLIdType& peer_id,std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const
|
||||
bool FileIndexMonitor::findLocalFile(const RsFileHash& hash,FileSearchFlags hint_flags, const RsPeerId& peer_id,std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const
|
||||
{
|
||||
std::list<FileEntry *> results;
|
||||
bool ok = false;
|
||||
|
@ -451,7 +446,7 @@ bool FileIndexMonitor::loadLocalCache(const RsCacheData &data) /* called with s
|
|||
|
||||
std::string name = data.name ;
|
||||
|
||||
if ((ok = fi.loadIndex(data.path + '/' + name, "", data.size)))
|
||||
if ((ok = fi.loadIndex(data.path + '/' + name, RsFileHash(), data.size)))
|
||||
{
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::loadCache() Success!";
|
||||
|
@ -516,7 +511,7 @@ bool FileIndexMonitor::loadLocalCache(const RsCacheData &data) /* called with s
|
|||
return false;
|
||||
}
|
||||
|
||||
bool FileIndexMonitor::updateCache(const RsCacheData &data,const std::set<SSLIdType>& destination_peers) /* we call this one */
|
||||
bool FileIndexMonitor::updateCache(const RsCacheData &data,const std::set<RsPeerId>& destination_peers) /* we call this one */
|
||||
{
|
||||
return refreshCache(data,destination_peers);
|
||||
}
|
||||
|
@ -1107,7 +1102,7 @@ time_t FileIndexMonitor::locked_saveFileIndexes(bool update_cache)
|
|||
// To figure out which sets are different, we index them by the set of forbidden indexes from the directory list.
|
||||
// This is probably a bit costly, but we can't suppose that the number of shared directories is bounded.
|
||||
//
|
||||
std::list<SSLIdType> all_friend_ids ;
|
||||
std::list<RsPeerId> all_friend_ids ;
|
||||
rsPeers->getFriendList(all_friend_ids);
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
|
@ -1116,9 +1111,9 @@ time_t FileIndexMonitor::locked_saveFileIndexes(bool update_cache)
|
|||
std::cerr << " " << *it << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::set<std::string>, std::set<SSLIdType> > peers_per_directory_combination ;
|
||||
std::map<std::set<std::string>, std::set<RsPeerId> > peers_per_directory_combination ;
|
||||
|
||||
for(std::list<SSLIdType>::const_iterator it(all_friend_ids.begin());it!=all_friend_ids.end();++it)
|
||||
for(std::list<RsPeerId>::const_iterator it(all_friend_ids.begin());it!=all_friend_ids.end();++it)
|
||||
{
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "About to save, with the following restrictions:" << std::endl ;
|
||||
|
@ -1153,14 +1148,14 @@ time_t FileIndexMonitor::locked_saveFileIndexes(bool update_cache)
|
|||
|
||||
peers_per_directory_combination[forbidden_dirs].insert(*it) ;
|
||||
}
|
||||
SSLIdType ownId = rsPeers->getOwnId() ;
|
||||
RsPeerId ownId = rsPeers->getOwnId() ;
|
||||
peers_per_directory_combination[std::set<std::string>()].insert(ownId) ; // add full configuration to self, i.e. no forbidden directories.
|
||||
|
||||
int n=0 ;
|
||||
time_t now = time(NULL) ;
|
||||
time_t mod_time = 0 ;
|
||||
|
||||
for(std::map<std::set<std::string>, std::set<SSLIdType> >::const_iterator it(peers_per_directory_combination.begin());
|
||||
for(std::map<std::set<std::string>, std::set<RsPeerId> >::const_iterator it(peers_per_directory_combination.begin());
|
||||
it!=peers_per_directory_combination.end();++it,++n)
|
||||
{
|
||||
std::string tmpname_browsable;
|
||||
|
@ -1183,7 +1178,7 @@ time_t FileIndexMonitor::locked_saveFileIndexes(bool update_cache)
|
|||
std::cerr << " " << *itt << std::endl;
|
||||
#endif
|
||||
|
||||
std::string hash ;
|
||||
RsFileHash hash ;
|
||||
uint64_t size ;
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
|
@ -1210,7 +1205,7 @@ time_t FileIndexMonitor::locked_saveFileIndexes(bool update_cache)
|
|||
data.size = size;
|
||||
data.recvd = time(NULL);
|
||||
|
||||
for(std::set<SSLIdType>::const_iterator ff(it->second.begin());ff!=it->second.end();++ff)
|
||||
for(std::set<RsPeerId>::const_iterator ff(it->second.begin());ff!=it->second.end();++ff)
|
||||
_cache_items_per_peer[*ff] = data ;
|
||||
|
||||
data.cid.subid = 0;
|
||||
|
@ -1261,7 +1256,7 @@ bool FileIndexMonitor::cachesAvailable(RsPeerId pid,std::map<CacheId, RsCacheDat
|
|||
//
|
||||
ids.clear() ;
|
||||
std::map<RsPeerId,RsCacheData>::const_iterator it(_cache_items_per_peer.find(pid)) ;
|
||||
SSLIdType ownId = rsPeers->getOwnId();
|
||||
RsPeerId ownId = rsPeers->getOwnId();
|
||||
|
||||
if(it != _cache_items_per_peer.end())
|
||||
{
|
||||
|
|
|
@ -76,8 +76,8 @@ class HashCache
|
|||
HashCache(const std::string& save_file_name) ;
|
||||
|
||||
void save() ;
|
||||
void insert(const std::string& full_path,uint64_t size,time_t time_stamp,const std::string& hash) ;
|
||||
bool find(const std::string& full_path,uint64_t size,time_t time_stamp,std::string& hash) ;
|
||||
void insert(const std::string& full_path,uint64_t size,time_t time_stamp,const RsFileHash& hash) ;
|
||||
bool find(const std::string& full_path,uint64_t size,time_t time_stamp,RsFileHash& hash) ;
|
||||
void clean() ;
|
||||
|
||||
typedef struct
|
||||
|
@ -85,7 +85,7 @@ class HashCache
|
|||
uint64_t size ;
|
||||
uint64_t time_stamp ;
|
||||
uint64_t modf_stamp ;
|
||||
std::string hash ;
|
||||
RsFileHash hash ;
|
||||
} HashCacheInfo ;
|
||||
|
||||
void setRememberHashFilesDuration(uint32_t days) { _max_cache_duration_days = days ; }
|
||||
|
@ -106,16 +106,16 @@ class HashCache
|
|||
class FileIndexMonitor: public CacheSource, public RsThread
|
||||
{
|
||||
public:
|
||||
FileIndexMonitor(CacheStrapper *cs, std::string cachedir, const SSLIdType& pid, const std::string& config_dir);
|
||||
FileIndexMonitor(CacheStrapper *cs, std::string cachedir, const RsPeerId& pid, const std::string& config_dir);
|
||||
virtual ~FileIndexMonitor();
|
||||
|
||||
/* external interface for filetransfer */
|
||||
bool findLocalFile(std::string hash,FileSearchFlags flags,const SSLIdType& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const;
|
||||
bool findLocalFile(const RsFileHash& hash,FileSearchFlags flags,const RsPeerId& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const;
|
||||
|
||||
int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const SSLIdType& peer_id) ;
|
||||
int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,FileSearchFlags flags,const SSLIdType& peer_id) const ;
|
||||
int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) ;
|
||||
int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
|
||||
|
||||
int filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const SSLIdType& peer_id) const ;
|
||||
int filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const ;
|
||||
|
||||
|
||||
/* external interface for local access to files */
|
||||
|
@ -125,7 +125,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
|
|||
/* Interacting with CacheSource */
|
||||
/* overloaded from CacheSource */
|
||||
virtual bool loadLocalCache(const RsCacheData &data); /* called with stored data */
|
||||
bool updateCache(const RsCacheData &data,const std::set<SSLIdType>& dest_peers); /* we call when we have a new cache for others */
|
||||
bool updateCache(const RsCacheData &data,const std::set<RsPeerId>& dest_peers); /* we call when we have a new cache for others */
|
||||
|
||||
|
||||
/* the FileIndexMonitor inner workings */
|
||||
|
|
|
@ -500,7 +500,7 @@ int FileEntry::print(std::string &out)
|
|||
else
|
||||
out += "[MISSING PARENT]";
|
||||
|
||||
rs_sprintf_append(out, " %s [ s: %lld ] ==> [ %s ]\n", name.c_str(), size, hash.c_str());
|
||||
rs_sprintf_append(out, " %s [ s: %lld ] ==> [ %s ]\n", name.c_str(), size, hash.toStdString().c_str());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ int FileIndex::printFileIndex(std::string &out)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int FileIndex::loadIndex(const std::string& filename, const std::string& expectedHash, uint64_t size)
|
||||
int FileIndex::loadIndex(const std::string& filename, const RsFileHash& expectedHash, uint64_t size)
|
||||
{
|
||||
FILE *file = RsDirUtil::rs_fopen(filename.c_str(),"rb") ;
|
||||
|
||||
|
@ -783,7 +783,7 @@ int FileIndex::loadIndex(const std::string& filename, const std::string& expecte
|
|||
}
|
||||
fclose(file) ;
|
||||
|
||||
std::string tmpout = RsDirUtil::sha1sum((unsigned char *)(compressed_data),size).toStdString() ;
|
||||
RsFileHash tmpout = RsDirUtil::sha1sum((unsigned char *)(compressed_data),size);
|
||||
|
||||
// /* calculate hash */
|
||||
// unsigned char sha_buf[SHA_DIGEST_LENGTH];
|
||||
|
@ -799,7 +799,7 @@ int FileIndex::loadIndex(const std::string& filename, const std::string& expecte
|
|||
// rs_sprintf_append(tmpout, "%02x", (unsigned int) (sha_buf[i]));
|
||||
// }
|
||||
|
||||
if (expectedHash != "" && expectedHash != tmpout)
|
||||
if (!expectedHash.isNull() && expectedHash != tmpout)
|
||||
{
|
||||
#ifdef FI_DEBUG
|
||||
std::cerr << "FileIndex::loadIndex expected hash does not match" << std::endl;
|
||||
|
@ -991,7 +991,7 @@ error:
|
|||
}
|
||||
|
||||
|
||||
int FileIndex::saveIndex(const std::string& filename, std::string &fileHash, uint64_t &size,const std::set<std::string>& forbidden_dirs)
|
||||
int FileIndex::saveIndex(const std::string& filename, RsFileHash &fileHash, uint64_t &size,const std::set<std::string>& forbidden_dirs)
|
||||
{
|
||||
unsigned char sha_buf[SHA_DIGEST_LENGTH];
|
||||
std::string filenametmp = filename + ".tmp" ;
|
||||
|
@ -1138,7 +1138,7 @@ void DirEntry::writeFileInfo(std::string& s)
|
|||
{
|
||||
rs_sprintf_append(s, "f%s%c%s%c%lld%c%ld%c%d%c%ld%c\n",
|
||||
FixName((fit->second)->name).c_str(), FILE_CACHE_SEPARATOR_CHAR,
|
||||
(fit->second)->hash.c_str(), FILE_CACHE_SEPARATOR_CHAR,
|
||||
(fit->second)->hash.toStdString().c_str(), FILE_CACHE_SEPARATOR_CHAR,
|
||||
(fit->second)->size, FILE_CACHE_SEPARATOR_CHAR,
|
||||
(fit->second)->modtime, FILE_CACHE_SEPARATOR_CHAR,
|
||||
(fit->second)->pop, FILE_CACHE_SEPARATOR_CHAR,
|
||||
|
@ -1165,14 +1165,14 @@ int DirEntry::saveEntry(std::string &s)
|
|||
}
|
||||
|
||||
|
||||
int FileIndex::searchHash(const std::string& hash, std::list<FileEntry *> &results) const
|
||||
int FileIndex::searchHash(const RsFileHash& hash, std::list<FileEntry *> &results) const
|
||||
{
|
||||
#ifdef FI_DEBUG
|
||||
std::cerr << "FileIndex::searchHash(" << hash << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string,FileEntry*>::const_iterator it = _file_hashes.find(hash) ;
|
||||
std::map<RsFileHash,FileEntry*>::const_iterator it = _file_hashes.find(hash) ;
|
||||
|
||||
if(it!=_file_hashes.end() && isValid((void*)it->second))
|
||||
results.push_back(it->second) ;
|
||||
|
@ -1394,7 +1394,7 @@ bool FileIndex::extractData(void *ref,DirDetails& details)
|
|||
}
|
||||
|
||||
FileEntry *file = static_cast<FileEntry *>(ref);
|
||||
DirEntry *dir = (file->hash.empty())?static_cast<DirEntry *>(file):NULL ; // This is a hack to avoid doing a dynamic_cast
|
||||
DirEntry *dir = (file->hash.isNull())?static_cast<DirEntry *>(file):NULL ; // This is a hack to avoid doing a dynamic_cast
|
||||
|
||||
details.children.clear() ;
|
||||
time_t now = time(NULL) ;
|
||||
|
|
|
@ -91,7 +91,7 @@ virtual int print(std::string &out);
|
|||
|
||||
/* Data */
|
||||
std::string name;
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
uint64_t size; /* file size */
|
||||
time_t modtime; /* modification time - most recent mod time for a sub entry for dirs */
|
||||
int pop; /* popularity rating */
|
||||
|
@ -230,12 +230,12 @@ class FileIndex
|
|||
int printFileIndex(std::ostream &out);
|
||||
|
||||
/* load/save to file */
|
||||
int loadIndex(const std::string& filename, const std::string& expectedHash, uint64_t size);
|
||||
int saveIndex(const std::string& filename, std::string &fileHash, uint64_t &size, const std::set<std::string>& forbidden_roots);
|
||||
int loadIndex(const std::string& filename, const RsFileHash &expectedHash, uint64_t size);
|
||||
int saveIndex(const std::string& filename, RsFileHash &fileHash, uint64_t &size, const std::set<std::string>& forbidden_roots);
|
||||
|
||||
/* search through this index */
|
||||
int searchTerms(const std::list<std::string>& terms, std::list<FileEntry *> &results) const;
|
||||
int searchHash(const std::string& hash, std::list<FileEntry *> &results) const;
|
||||
int searchHash(const RsFileHash& hash, std::list<FileEntry *> &results) const;
|
||||
int searchBoolExp(Expression * exp, std::list<FileEntry *> &results) const;
|
||||
|
||||
/// Recursively compute the maximum modification time of children.
|
||||
|
@ -262,7 +262,7 @@ class FileIndex
|
|||
void updateHashIndex() ;
|
||||
void recursUpdateHashIndex(DirEntry *) ;
|
||||
|
||||
std::map<std::string,FileEntry*> _file_hashes ;
|
||||
std::map<RsFileHash,FileEntry*> _file_hashes ;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ uint32_t FileIndexStore::getType(void *ref) const
|
|||
return b;
|
||||
}
|
||||
|
||||
int FileIndexStore::SearchHash(std::string hash, std::list<FileDetail> &results) const
|
||||
int FileIndexStore::SearchHash(const RsFileHash& hash, std::list<FileDetail> &results) const
|
||||
{
|
||||
lockData();
|
||||
results.clear() ;
|
||||
|
|
|
@ -73,7 +73,7 @@ virtual ~FileIndexStore();
|
|||
virtual int loadCache(const RsCacheData &data); /* actual load, once data available */
|
||||
|
||||
/* Search Interface - For FileTransfer Lookup */
|
||||
int SearchHash(std::string hash, std::list<FileDetail> &results) const;
|
||||
int SearchHash(const RsFileHash &hash, std::list<FileDetail> &results) const;
|
||||
|
||||
/* Search Interface - For Search Interface */
|
||||
int SearchKeywords(std::list<std::string> terms, std::list<DirDetails> &results,FileSearchFlags flags) const;
|
||||
|
@ -83,7 +83,7 @@ virtual int loadCache(const RsCacheData &data); /* actual load, once data avai
|
|||
|
||||
|
||||
/* Search Interface - For Directory Access */
|
||||
int RequestDirDetails(const SSLIdType& uid, const std::string& path, DirDetails &details) const;
|
||||
int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details) const;
|
||||
int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) const;
|
||||
uint32_t getType(void *ref) const ;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ bool ExtExpression::eval(FileEntry *file){
|
|||
}
|
||||
|
||||
bool HashExpression::eval(FileEntry *file){
|
||||
return evalStr(file->hash);
|
||||
return evalStr(file->hash.toStdString());
|
||||
}
|
||||
|
||||
/*Check whether two strings are 'equal' to each other*/
|
||||
|
@ -115,7 +115,7 @@ static bool StrEquals(const std::string & str1, const std::string & str2,
|
|||
}
|
||||
|
||||
/*Check whether one string contains the other*/
|
||||
static bool StrContains( std::string & str1, std::string & str2,
|
||||
static bool StrContains( const std::string & str1, const std::string & str2,
|
||||
bool IgnoreCase){
|
||||
|
||||
std::string::const_iterator iter ;
|
||||
|
@ -131,7 +131,7 @@ static bool StrContains( std::string & str1, std::string & str2,
|
|||
}
|
||||
|
||||
|
||||
bool StringExpression :: evalStr ( std::string &str ){
|
||||
bool StringExpression :: evalStr ( const std::string &str ){
|
||||
std::list<std::string>::iterator iter;
|
||||
switch (Op) {
|
||||
case ContainsAllStrings:
|
||||
|
|
|
@ -143,7 +143,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mProxyStunner->addStunPeer(id->addr, NULL);
|
||||
//mProxyStunner->addStunPeer(id->addr, NULL);
|
||||
}
|
||||
/* else */ // removed else until we have lots of peers.
|
||||
|
||||
|
@ -154,7 +154,7 @@ int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
|
|||
bdStdPrintId(std::cerr, id);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
mDhtStunner->addStunPeer(id->addr, NULL);
|
||||
//mDhtStunner->addStunPeer(id->addr, NULL);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -89,7 +89,7 @@ ftFileControl::ftFileControl()
|
|||
|
||||
ftFileControl::ftFileControl(std::string fname,
|
||||
std::string tmppath, std::string dest,
|
||||
uint64_t size, std::string hash, TransferRequestFlags flags,
|
||||
uint64_t size, const RsFileHash &hash, TransferRequestFlags flags,
|
||||
ftFileCreator *fc, ftTransferModule *tm)
|
||||
:mName(fname), mCurrentPath(tmppath), mDestination(dest),
|
||||
mTransfer(tm), mCreator(fc), mState(DOWNLOADING), mHash(hash),
|
||||
|
@ -124,11 +124,11 @@ void ftController::setFtSearchNExtra(ftSearch *search, ftExtraList *list)
|
|||
mExtraList = list;
|
||||
}
|
||||
|
||||
bool ftController::getFileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info)
|
||||
bool ftController::getFileDownloadChunksDetails(const RsFileHash& hash,FileChunksInfo& info)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string, ftFileControl*>::iterator it = mDownloads.find(hash) ;
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it = mDownloads.find(hash) ;
|
||||
|
||||
if(it != mDownloads.end())
|
||||
{
|
||||
|
@ -161,11 +161,11 @@ bool ftController::getFileDownloadChunksDetails(const std::string& hash,FileChun
|
|||
return false ;
|
||||
}
|
||||
|
||||
void ftController::addFileSource(const std::string& hash,const SSLIdType& peer_id)
|
||||
void ftController::addFileSource(const RsFileHash& hash,const RsPeerId& peer_id)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
|
||||
//#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController: Adding source " << peer_id << " to current download hash=" << hash ;
|
||||
|
@ -184,11 +184,11 @@ void ftController::addFileSource(const std::string& hash,const SSLIdType& peer_i
|
|||
std::cerr << "... not added: hash not found." << std::endl ;
|
||||
#endif
|
||||
}
|
||||
void ftController::removeFileSource(const std::string& hash,const SSLIdType& peer_id)
|
||||
void ftController::removeFileSource(const RsFileHash& hash,const RsPeerId& peer_id)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController: Adding source " << peer_id << " to current download hash=" << hash ;
|
||||
|
@ -245,7 +245,7 @@ void ftController::run()
|
|||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
for(std::map<std::string,ftFileControl*>::iterator it(mDownloads.begin());it!=mDownloads.end();++it)
|
||||
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin());it!=mDownloads.end();++it)
|
||||
it->second->mCreator->removeInactiveChunks() ;
|
||||
|
||||
last_clean_time = now ;
|
||||
|
@ -263,7 +263,7 @@ void ftController::run()
|
|||
tickTransfers() ;
|
||||
|
||||
{
|
||||
std::list<std::string> files_to_complete ;
|
||||
std::list<RsFileHash> files_to_complete ;
|
||||
|
||||
{
|
||||
RsStackMutex stack2(doneMutex);
|
||||
|
@ -271,7 +271,7 @@ void ftController::run()
|
|||
mDone.clear();
|
||||
}
|
||||
|
||||
for(std::list<std::string>::iterator it(files_to_complete.begin()); it != files_to_complete.end(); ++it)
|
||||
for(std::list<RsFileHash>::iterator it(files_to_complete.begin()); it != files_to_complete.end(); ++it)
|
||||
completeFile(*it);
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ void ftController::searchForDirectSources()
|
|||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
for(std::map<std::string,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); it++)
|
||||
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); it++)
|
||||
if(it->second->mState != ftFileControl::QUEUED && it->second->mState != ftFileControl::PAUSED)
|
||||
if(! (it->second->mFlags & RS_FILE_REQ_CACHE))
|
||||
{
|
||||
|
@ -310,16 +310,16 @@ void ftController::tickTransfers()
|
|||
#endif
|
||||
// Collect all non queued files.
|
||||
//
|
||||
for(std::map<std::string,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); it++)
|
||||
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); it++)
|
||||
if(it->second->mState != ftFileControl::QUEUED && it->second->mState != ftFileControl::PAUSED)
|
||||
it->second->mTransfer->tick() ;
|
||||
}
|
||||
|
||||
bool ftController::getPriority(const std::string& hash,DwlSpeed& p)
|
||||
bool ftController::getPriority(const RsFileHash& hash,DwlSpeed& p)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string,ftFileControl*>::iterator it(mDownloads.find(hash)) ;
|
||||
std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.find(hash)) ;
|
||||
|
||||
if(it != mDownloads.end())
|
||||
{
|
||||
|
@ -330,11 +330,11 @@ bool ftController::getPriority(const std::string& hash,DwlSpeed& p)
|
|||
return false ;
|
||||
}
|
||||
|
||||
void ftController::setPriority(const std::string& hash,DwlSpeed p)
|
||||
void ftController::setPriority(const RsFileHash& hash,DwlSpeed p)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string,ftFileControl*>::iterator it(mDownloads.find(hash)) ;
|
||||
std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.find(hash)) ;
|
||||
|
||||
if(it != mDownloads.end())
|
||||
it->second->mTransfer->setDownloadPriority(p) ;
|
||||
|
@ -342,13 +342,13 @@ void ftController::setPriority(const std::string& hash,DwlSpeed p)
|
|||
|
||||
void ftController::cleanCacheDownloads()
|
||||
{
|
||||
std::vector<std::string> toCancel ;
|
||||
std::vector<RsFileHash> toCancel ;
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
for(std::map<std::string,ftFileControl*>::iterator it(mDownloads.begin());it!=mDownloads.end();++it)
|
||||
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin());it!=mDownloads.end();++it)
|
||||
if (((it->second)->mFlags & RS_FILE_REQ_CACHE) && it->second->mState != ftFileControl::DOWNLOADING)
|
||||
// check if a cache file is downloaded, if the case, timeout the transfer after TIMOUT_CACHE_FILE_TRANSFER
|
||||
{
|
||||
|
@ -423,7 +423,7 @@ void ftController::checkDownloadQueue()
|
|||
time_t now = time(NULL) ;
|
||||
uint32_t nb_moved = 0 ; // don't move more files than the size of the queue.
|
||||
|
||||
for(std::map<std::string,ftFileControl*>::const_iterator it(mDownloads.begin());it!=mDownloads.end() && nb_moved <= _max_active_downloads;++it)
|
||||
for(std::map<RsFileHash,ftFileControl*>::const_iterator it(mDownloads.begin());it!=mDownloads.end() && nb_moved <= _max_active_downloads;++it)
|
||||
if( it->second->mState != ftFileControl::QUEUED
|
||||
&& (it->second->mState == ftFileControl::PAUSED
|
||||
|| now > it->second->mTransfer->lastActvTimeStamp() + (time_t)MAX_TIME_INACTIVE_REQUEUED))
|
||||
|
@ -557,11 +557,11 @@ uint32_t ftController::getQueueSize()
|
|||
return _max_active_downloads ;
|
||||
}
|
||||
|
||||
void ftController::moveInQueue(const std::string& hash,QueueMove mv)
|
||||
void ftController::moveInQueue(const RsFileHash& hash,QueueMove mv)
|
||||
{
|
||||
RsStackMutex mtx(ctrlMutex) ;
|
||||
|
||||
std::map<std::string,ftFileControl*>::iterator it(mDownloads.find(hash)) ;
|
||||
std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.find(hash)) ;
|
||||
|
||||
if(it == mDownloads.end())
|
||||
{
|
||||
|
@ -658,7 +658,7 @@ void ftController::locked_checkQueueElement(uint32_t pos)
|
|||
}
|
||||
}
|
||||
|
||||
bool ftController::FlagFileComplete(std::string hash)
|
||||
bool ftController::FlagFileComplete(const RsFileHash& hash)
|
||||
{
|
||||
RsStackMutex stack2(doneMutex);
|
||||
mDone.push_back(hash);
|
||||
|
@ -780,7 +780,7 @@ bool ftController::copyFile(const std::string& source,const std::string& dest)
|
|||
|
||||
|
||||
|
||||
bool ftController::completeFile(std::string hash)
|
||||
bool ftController::completeFile(const RsFileHash& hash)
|
||||
{
|
||||
/* variables... so we can drop mutex later */
|
||||
std::string path;
|
||||
|
@ -799,7 +799,7 @@ bool ftController::completeFile(std::string hash)
|
|||
std::cerr << "ftController:completeFile(" << hash << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
std::map<std::string, ftFileControl*>::iterator it(mDownloads.find(hash));
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it(mDownloads.find(hash));
|
||||
|
||||
if (it == mDownloads.end())
|
||||
{
|
||||
|
@ -840,7 +840,7 @@ bool ftController::completeFile(std::string hash)
|
|||
/* done - cleanup */
|
||||
|
||||
// (csoler) I'm copying this because "delete fc->mTransfer" deletes the hash string!
|
||||
std::string hash_to_suppress(fc->mTransfer->hash());
|
||||
RsFileHash hash_to_suppress(fc->mTransfer->hash());
|
||||
|
||||
// This should be done that early, because once the file creator is
|
||||
// deleted, it should not be accessed by the data multiplex anymore!
|
||||
|
@ -965,9 +965,9 @@ bool ftController::completeFile(std::string hash)
|
|||
|
||||
/* Notify GUI */
|
||||
if ((flags & RS_FILE_REQ_CACHE) == 0) {
|
||||
RsServer::notify()->AddPopupMessage(RS_POPUP_DOWNLOAD, hash, name, "");
|
||||
RsServer::notify()->AddPopupMessage(RS_POPUP_DOWNLOAD, hash.toStdString(), name, "");
|
||||
|
||||
RsServer::notify()->notifyDownloadComplete(hash);
|
||||
RsServer::notify()->notifyDownloadComplete(hash.toStdString());
|
||||
RsServer::notify()->notifyDownloadCompleteCount(completeCount);
|
||||
|
||||
rsFiles->ForceDirectoryCheck() ;
|
||||
|
@ -1019,12 +1019,12 @@ bool ftController::handleAPendingRequest()
|
|||
//
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string,RsFileTransfer*>::iterator it(mPendingChunkMaps.find(req.mHash)) ;
|
||||
std::map<RsFileHash,RsFileTransfer*>::iterator it(mPendingChunkMaps.find(req.mHash)) ;
|
||||
|
||||
if(it != mPendingChunkMaps.end())
|
||||
{
|
||||
RsFileTransfer *rsft = it->second ;
|
||||
std::map<std::string, ftFileControl*>::iterator fit = mDownloads.find(rsft->file.hash);
|
||||
std::map<RsFileHash, ftFileControl*>::iterator fit = mDownloads.find(rsft->file.hash);
|
||||
|
||||
if((fit==mDownloads.end() || (fit->second)->mCreator == NULL))
|
||||
{
|
||||
|
@ -1055,7 +1055,7 @@ bool ftController::handleAPendingRequest()
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftController::alreadyHaveFile(const std::string& hash, FileInfo &info)
|
||||
bool ftController::alreadyHaveFile(const RsFileHash& hash, FileInfo &info)
|
||||
{
|
||||
// check for downloads
|
||||
if (FileDetails(hash, info) && (info.downloadStatus == FT_STATE_COMPLETE))
|
||||
|
@ -1068,11 +1068,11 @@ bool ftController::alreadyHaveFile(const std::string& hash, FileInfo &info)
|
|||
return false ;
|
||||
}
|
||||
|
||||
bool ftController::FileRequest(const std::string& fname, const std::string& hash,
|
||||
bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash,
|
||||
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
||||
const std::list<SSLIdType> &_srcIds, uint16_t state)
|
||||
const std::list<RsPeerId> &_srcIds, uint16_t state)
|
||||
{
|
||||
std::list<SSLIdType> srcIds(_srcIds) ;
|
||||
std::list<RsPeerId> srcIds(_srcIds) ;
|
||||
|
||||
/* check if we have the file */
|
||||
|
||||
|
@ -1134,10 +1134,10 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
|
|||
// remove the sources from the list, if they don't have clearance for direct transfer. This happens only for non cache files.
|
||||
//
|
||||
if(!(flags & RS_FILE_REQ_CACHE))
|
||||
for(std::list<SSLIdType>::iterator it = srcIds.begin(); it != srcIds.end(); )
|
||||
for(std::list<RsPeerId>::iterator it = srcIds.begin(); it != srcIds.end(); )
|
||||
if(!(rsPeers->servicePermissionFlags(*it) & RS_SERVICE_PERM_DIRECT_DL))
|
||||
{
|
||||
std::list<SSLIdType>::iterator tmp(it) ;
|
||||
std::list<RsPeerId>::iterator tmp(it) ;
|
||||
++tmp ;
|
||||
srcIds.erase(it) ;
|
||||
it = tmp ;
|
||||
|
@ -1145,7 +1145,7 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
|
|||
else
|
||||
++it ;
|
||||
|
||||
std::list<SSLIdType>::const_iterator it;
|
||||
std::list<RsPeerId>::const_iterator it;
|
||||
std::list<TransferInfo>::const_iterator pit;
|
||||
|
||||
#ifdef CONTROL_DEBUG
|
||||
|
@ -1174,7 +1174,7 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
|
|||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string, ftFileControl*>::const_iterator dit = mDownloads.find(hash);
|
||||
std::map<RsFileHash, ftFileControl*>::const_iterator dit = mDownloads.find(hash);
|
||||
|
||||
if (dit != mDownloads.end())
|
||||
{
|
||||
|
@ -1268,7 +1268,7 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
|
|||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
savepath = mPartialsPath + "/" + hash;
|
||||
savepath = mPartialsPath + "/" + hash.toStdString();
|
||||
destination = dest + "/" + fname;
|
||||
|
||||
/* if no destpath - send to download directory */
|
||||
|
@ -1331,7 +1331,7 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftController::setPeerState(ftTransferModule *tm, const SSLIdType& id, uint32_t maxrate, bool online)
|
||||
bool ftController::setPeerState(ftTransferModule *tm, const RsPeerId& id, uint32_t maxrate, bool online)
|
||||
{
|
||||
if (id == mLinkMgr->getOwnId())
|
||||
{
|
||||
|
@ -1363,9 +1363,9 @@ bool ftController::setPeerState(ftTransferModule *tm, const SSLIdType& id, uint
|
|||
}
|
||||
|
||||
|
||||
bool ftController::setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s)
|
||||
bool ftController::setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy s)
|
||||
{
|
||||
std::map<std::string,ftFileControl*>::iterator mit=mDownloads.find(hash);
|
||||
std::map<RsFileHash,ftFileControl*>::iterator mit=mDownloads.find(hash);
|
||||
if (mit==mDownloads.end())
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
|
@ -1378,7 +1378,7 @@ bool ftController::setChunkStrategy(const std::string& hash,FileChunksInfo::Chun
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftController::FileCancel(const std::string& hash)
|
||||
bool ftController::FileCancel(const RsFileHash& hash)
|
||||
{
|
||||
rsTurtle->stopMonitoringTunnels(hash) ;
|
||||
|
||||
|
@ -1390,7 +1390,7 @@ bool ftController::FileCancel(const std::string& hash)
|
|||
{
|
||||
RsStackMutex mtx(ctrlMutex) ;
|
||||
|
||||
std::map<std::string,ftFileControl*>::iterator mit=mDownloads.find(hash);
|
||||
std::map<RsFileHash,ftFileControl*>::iterator mit=mDownloads.find(hash);
|
||||
if (mit==mDownloads.end())
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
|
@ -1461,7 +1461,7 @@ bool ftController::FileCancel(const std::string& hash)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftController::FileControl(const std::string& hash, uint32_t flags)
|
||||
bool ftController::FileControl(const RsFileHash& hash, uint32_t flags)
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController::FileControl(" << hash << ",";
|
||||
|
@ -1470,7 +1470,7 @@ bool ftController::FileControl(const std::string& hash, uint32_t flags)
|
|||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
/*check if the file in the download map*/
|
||||
std::map<std::string,ftFileControl*>::iterator mit=mDownloads.find(hash);
|
||||
std::map<RsFileHash,ftFileControl*>::iterator mit=mDownloads.find(hash);
|
||||
if (mit==mDownloads.end())
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
|
@ -1513,7 +1513,7 @@ bool ftController::FileClearCompleted()
|
|||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
for(std::map<std::string, ftFileControl*>::iterator it(mCompleted.begin());it!=mCompleted.end();++it)
|
||||
for(std::map<RsFileHash, ftFileControl*>::iterator it(mCompleted.begin());it!=mCompleted.end();++it)
|
||||
delete it->second ;
|
||||
|
||||
mCompleted.clear();
|
||||
|
@ -1527,11 +1527,11 @@ bool ftController::FileClearCompleted()
|
|||
}
|
||||
|
||||
/* get Details of File Transfers */
|
||||
bool ftController::FileDownloads(std::list<std::string> &hashs)
|
||||
bool ftController::FileDownloads(std::list<RsFileHash> &hashs)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string, ftFileControl*>::iterator it;
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it;
|
||||
for(it = mDownloads.begin(); it != mDownloads.end(); it++)
|
||||
{
|
||||
hashs.push_back(it->second->mHash);
|
||||
|
@ -1611,7 +1611,7 @@ bool ftController::setPartialsDirectory(std::string path)
|
|||
|
||||
#if 0 /*** FIX ME !!!**************/
|
||||
/* move all existing files! */
|
||||
std::map<std::string, ftFileControl>::iterator it;
|
||||
std::map<RsFileHash, ftFileControl>::iterator it;
|
||||
for(it = mDownloads.begin(); it != mDownloads.end(); it++)
|
||||
{
|
||||
(it->second).mCreator->changePartialDirectory(mPartialPath);
|
||||
|
@ -1638,10 +1638,10 @@ std::string ftController::getPartialsDirectory()
|
|||
return mPartialsPath;
|
||||
}
|
||||
|
||||
bool ftController::setDestinationDirectory(const std::string& hash,const std::string& dest_dir)
|
||||
bool ftController::setDestinationDirectory(const RsFileHash& hash,const std::string& dest_dir)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
std::map<std::string, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
|
||||
if (it == mDownloads.end())
|
||||
return false;
|
||||
|
@ -1654,10 +1654,10 @@ bool ftController::setDestinationDirectory(const std::string& hash,const std::st
|
|||
|
||||
return true ;
|
||||
}
|
||||
bool ftController::setDestinationName(const std::string& hash,const std::string& dest_name)
|
||||
bool ftController::setDestinationName(const RsFileHash& hash,const std::string& dest_name)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
std::map<std::string, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
|
||||
if (it == mDownloads.end())
|
||||
return false;
|
||||
|
@ -1675,12 +1675,12 @@ bool ftController::setDestinationName(const std::string& hash,const std::string&
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftController::FileDetails(const std::string &hash, FileInfo &info)
|
||||
bool ftController::FileDetails(const RsFileHash &hash, FileInfo &info)
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
bool completed = false;
|
||||
std::map<std::string, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it = mDownloads.find(hash);
|
||||
if (it == mDownloads.end())
|
||||
{
|
||||
/* search completed files too */
|
||||
|
@ -1708,8 +1708,8 @@ bool ftController::FileDetails(const std::string &hash, FileInfo &info)
|
|||
info.storage_permission_flags |= DIR_FLAGS_NETWORK_WIDE_OTHERS ; // file being downloaded anonymously are always anonymously available.
|
||||
|
||||
/* get list of sources from transferModule */
|
||||
std::list<SSLIdType> peerIds;
|
||||
std::list<SSLIdType>::iterator pit;
|
||||
std::list<RsPeerId> peerIds;
|
||||
std::list<RsPeerId>::iterator pit;
|
||||
|
||||
if (!completed)
|
||||
{
|
||||
|
@ -1821,7 +1821,7 @@ void ftController::statusChange(const std::list<pqipeer> &plist)
|
|||
uint32_t rate = FT_CNTRL_STANDARD_RATE;
|
||||
|
||||
/* add online to all downloads */
|
||||
std::map<std::string, ftFileControl*>::iterator it;
|
||||
std::map<RsFileHash, ftFileControl*>::iterator it;
|
||||
std::list<pqipeer>::const_iterator pit;
|
||||
|
||||
#ifdef CONTROL_DEBUG
|
||||
|
@ -1913,7 +1913,7 @@ void ftController::statusChange(const std::list<pqipeer> &plist)
|
|||
}
|
||||
|
||||
/* Cache Interface */
|
||||
bool ftController::RequestCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size)
|
||||
bool ftController::RequestCacheFile(RsPeerId id, std::string path, const RsFileHash& hash, uint64_t size)
|
||||
{
|
||||
#ifdef CONTROL_DEBUG
|
||||
std::cerr << "ftController::RequestCacheFile(" << id << ",";
|
||||
|
@ -1922,7 +1922,7 @@ bool ftController::RequestCacheFile(RsPeerId id, std::string path, std::string h
|
|||
#endif
|
||||
|
||||
/* Request File */
|
||||
std::list<SSLIdType> ids;
|
||||
std::list<RsPeerId> ids;
|
||||
ids.push_back(id);
|
||||
|
||||
FileInfo info ;
|
||||
|
@ -1937,7 +1937,7 @@ bool ftController::RequestCacheFile(RsPeerId id, std::string path, std::string h
|
|||
std::cerr << "Copying it !!" << std::endl ;
|
||||
#endif
|
||||
|
||||
if(info.size > 0 && copyFile(info.path,path+"/"+hash))
|
||||
if(info.size > 0 && copyFile(info.path,path+"/"+hash.toStdString()))
|
||||
{
|
||||
CompletedCache(hash);
|
||||
return true ;
|
||||
|
@ -1946,13 +1946,13 @@ bool ftController::RequestCacheFile(RsPeerId id, std::string path, std::string h
|
|||
return false ;
|
||||
}
|
||||
|
||||
FileRequest(hash, hash, size, path, RS_FILE_REQ_CACHE | RS_FILE_REQ_NO_SEARCH, ids);
|
||||
FileRequest(hash.toStdString(), hash, size, path, RS_FILE_REQ_CACHE | RS_FILE_REQ_NO_SEARCH, ids);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ftController::CancelCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size)
|
||||
bool ftController::CancelCacheFile(RsPeerId id, std::string path, const RsFileHash& hash, uint64_t size)
|
||||
{
|
||||
std::cerr << "ftController::CancelCacheFile(" << id << ",";
|
||||
std::cerr << path << "," << hash << "," << size << ")";
|
||||
|
@ -1994,7 +1994,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
/* create a key/value set for most of the parameters */
|
||||
std::map<std::string, std::string> configMap;
|
||||
std::map<std::string, std::string>::iterator mit;
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<RsFileHash>::iterator it;
|
||||
|
||||
/* basic control parameters */
|
||||
std::string s ;
|
||||
|
@ -2043,7 +2043,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
|
||||
|
||||
/* get Details of File Transfers */
|
||||
std::list<std::string> hashs;
|
||||
std::list<RsFileHash> hashs;
|
||||
FileDownloads(hashs);
|
||||
|
||||
for(it = hashs.begin(); it != hashs.end(); it++)
|
||||
|
@ -2051,7 +2051,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
/* stack mutex released each loop */
|
||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||
|
||||
std::map<std::string, ftFileControl*>::iterator fit = mDownloads.find(*it);
|
||||
std::map<RsFileHash, ftFileControl*>::iterator fit = mDownloads.find(*it);
|
||||
if (fit == mDownloads.end())
|
||||
continue;
|
||||
|
||||
|
@ -2111,7 +2111,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||
/* make RsFileTransfer item for save list */
|
||||
RsFileTransfer *rft = NULL;
|
||||
|
||||
std::map<std::string,RsFileTransfer*>::iterator rit = mPendingChunkMaps.find(pit->mHash);
|
||||
std::map<RsFileHash,RsFileTransfer*>::iterator rit = mPendingChunkMaps.find(pit->mHash);
|
||||
if (rit != mPendingChunkMaps.end()) {
|
||||
/* use item from the not loaded pending list */
|
||||
rft = new RsFileTransfer(*(rit->second));
|
||||
|
@ -2210,7 +2210,7 @@ bool ftController::loadList(std::list<RsItem *>& load)
|
|||
{
|
||||
RsStackMutex mtx(ctrlMutex) ;
|
||||
|
||||
std::map<std::string, ftFileControl*>::iterator fit = mDownloads.find(rsft->file.hash);
|
||||
std::map<RsFileHash, ftFileControl*>::iterator fit = mDownloads.find(rsft->file.hash);
|
||||
|
||||
if((fit==mDownloads.end() || (fit->second)->mCreator == NULL))
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ class ftFileControl
|
|||
|
||||
ftFileControl();
|
||||
ftFileControl(std::string fname, std::string tmppath, std::string dest,
|
||||
uint64_t size, std::string hash, TransferRequestFlags flags,
|
||||
uint64_t size, const RsFileHash& hash, TransferRequestFlags flags,
|
||||
ftFileCreator *fc, ftTransferModule *tm);
|
||||
|
||||
std::string mName;
|
||||
|
@ -83,7 +83,7 @@ class ftFileControl
|
|||
ftTransferModule * mTransfer;
|
||||
ftFileCreator * mCreator;
|
||||
uint32_t mState;
|
||||
std::string mHash;
|
||||
RsFileHash mHash;
|
||||
uint64_t mSize;
|
||||
TransferRequestFlags mFlags;
|
||||
time_t mCreateTime;
|
||||
|
@ -94,7 +94,7 @@ class ftFileControl
|
|||
class ftPendingRequest
|
||||
{
|
||||
public:
|
||||
ftPendingRequest(const std::string& fname, const std::string& hash,
|
||||
ftPendingRequest(const std::string& fname, const RsFileHash& hash,
|
||||
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
||||
const std::list<SSLIdType> &srcIds, uint16_t state)
|
||||
: mName(fname), mHash(hash), mSize(size),
|
||||
|
@ -103,7 +103,7 @@ class ftPendingRequest
|
|||
ftPendingRequest() : mSize(0), mFlags(0), mState(0) { return; }
|
||||
|
||||
std::string mName;
|
||||
std::string mHash;
|
||||
RsFileHash mHash;
|
||||
uint64_t mSize;
|
||||
std::string mDest;
|
||||
TransferRequestFlags mFlags;
|
||||
|
@ -131,34 +131,34 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
|||
/********************** Controller Access **********************/
|
||||
/***************************************************************/
|
||||
|
||||
bool FileRequest(const std::string& fname, const std::string& hash,
|
||||
bool FileRequest(const std::string& fname, const RsFileHash& hash,
|
||||
uint64_t size, const std::string& dest, TransferRequestFlags flags,
|
||||
const std::list<SSLIdType> &sourceIds, uint16_t state = ftFileControl::DOWNLOADING);
|
||||
|
||||
/// Do we already have this file, either in download or in file lists ?
|
||||
bool alreadyHaveFile(const std::string& hash, FileInfo &info);
|
||||
bool alreadyHaveFile(const RsFileHash& hash, FileInfo &info);
|
||||
|
||||
bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s);
|
||||
bool setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy s);
|
||||
void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy s);
|
||||
FileChunksInfo::ChunkStrategy defaultChunkStrategy();
|
||||
uint32_t freeDiskSpaceLimit() const ;
|
||||
void setFreeDiskSpaceLimit(uint32_t size_in_mb) ;
|
||||
|
||||
bool FileCancel(const std::string& hash);
|
||||
bool FileControl(const std::string& hash, uint32_t flags);
|
||||
bool FileCancel(const RsFileHash& hash);
|
||||
bool FileControl(const RsFileHash& hash, uint32_t flags);
|
||||
bool FileClearCompleted();
|
||||
bool FlagFileComplete(std::string hash);
|
||||
bool getFileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info);
|
||||
bool setDestinationName(const std::string& hash,const std::string& dest_name) ;
|
||||
bool setDestinationDirectory(const std::string& hash,const std::string& dest_name) ;
|
||||
bool FlagFileComplete(const RsFileHash& hash);
|
||||
bool getFileDownloadChunksDetails(const RsFileHash& hash,FileChunksInfo& info);
|
||||
bool setDestinationName(const RsFileHash& hash,const std::string& dest_name) ;
|
||||
bool setDestinationDirectory(const RsFileHash& hash,const std::string& dest_name) ;
|
||||
|
||||
// Download speed
|
||||
bool getPriority(const std::string& hash,DwlSpeed& p);
|
||||
void setPriority(const std::string& hash,DwlSpeed p);
|
||||
bool getPriority(const RsFileHash& hash,DwlSpeed& p);
|
||||
void setPriority(const RsFileHash& hash,DwlSpeed p);
|
||||
|
||||
// Action on queue position
|
||||
//
|
||||
void moveInQueue(const std::string& hash,QueueMove mv) ;
|
||||
void moveInQueue(const RsFileHash& hash,QueueMove mv) ;
|
||||
void clearQueue() ;
|
||||
void setQueueSize(uint32_t size) ;
|
||||
uint32_t getQueueSize() ;
|
||||
|
@ -166,14 +166,14 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
|||
uint32_t getMinPrioritizedTransfers() ;
|
||||
|
||||
/* get Details of File Transfers */
|
||||
bool FileDownloads(std::list<std::string> &hashs);
|
||||
bool FileDownloads(std::list<RsFileHash> &hashs);
|
||||
|
||||
/* Directory Handling */
|
||||
bool setDownloadDirectory(std::string path);
|
||||
bool setPartialsDirectory(std::string path);
|
||||
std::string getDownloadDirectory();
|
||||
std::string getPartialsDirectory();
|
||||
bool FileDetails(const std::string &hash, FileInfo &info);
|
||||
bool FileDetails(const RsFileHash &hash, FileInfo &info);
|
||||
|
||||
bool moveFile(const std::string& source,const std::string& dest) ;
|
||||
bool copyFile(const std::string& source,const std::string& dest) ;
|
||||
|
@ -188,13 +188,13 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
|||
|
||||
/* pqiMonitor callback (also provided mConnMgr pointer!) */
|
||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
void addFileSource(const std::string& hash,const SSLIdType& peer_id) ;
|
||||
void removeFileSource(const std::string& hash,const SSLIdType& peer_id) ;
|
||||
void addFileSource(const RsFileHash& hash,const SSLIdType& peer_id) ;
|
||||
void removeFileSource(const RsFileHash& hash,const SSLIdType& peer_id) ;
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool RequestCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||
virtual bool CancelCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||
virtual bool RequestCacheFile(RsPeerId id, std::string path, const RsFileHash& hash, uint64_t size);
|
||||
virtual bool CancelCacheFile(RsPeerId id, std::string path, const RsFileHash& hash, uint64_t size);
|
||||
|
||||
void cleanCacheDownloads() ;
|
||||
void searchForDirectSources() ;
|
||||
|
@ -223,7 +223,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
|||
void locked_queueRemove(uint32_t pos) ; // delete this element from the queue
|
||||
void locked_swapQueue(uint32_t pos1,uint32_t pos2) ; // swap position of the two elements
|
||||
|
||||
bool completeFile(std::string hash);
|
||||
bool completeFile(const RsFileHash& hash);
|
||||
bool handleAPendingRequest();
|
||||
|
||||
bool setPeerState(ftTransferModule *tm, const SSLIdType& id,
|
||||
|
@ -241,8 +241,8 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
|||
|
||||
RsMutex ctrlMutex;
|
||||
|
||||
std::map<std::string, ftFileControl*> mCompleted;
|
||||
std::map<std::string, ftFileControl*> mDownloads;
|
||||
std::map<RsFileHash, ftFileControl*> mCompleted;
|
||||
std::map<RsFileHash, ftFileControl*> mDownloads;
|
||||
std::vector<ftFileControl*> _queue ;
|
||||
|
||||
std::string mConfigPath;
|
||||
|
@ -253,13 +253,13 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
|
|||
|
||||
/* callback list (for File Completion) */
|
||||
RsMutex doneMutex;
|
||||
std::list<std::string> mDone;
|
||||
std::list<RsFileHash> mDone;
|
||||
|
||||
/* List to Pause File transfers until Caches are properly loaded */
|
||||
bool mFtActive;
|
||||
bool mFtPendingDone;
|
||||
std::list<ftPendingRequest> mPendingRequests;
|
||||
std::map<std::string,RsFileTransfer*> mPendingChunkMaps ;
|
||||
std::map<RsFileHash,RsFileTransfer*> mPendingChunkMaps ;
|
||||
|
||||
FileChunksInfo::ChunkStrategy mDefaultChunkStrategy ;
|
||||
|
||||
|
|
|
@ -50,23 +50,23 @@ class ftDataSend
|
|||
virtual ~ftDataSend() { return; }
|
||||
|
||||
/* Client Send */
|
||||
virtual bool sendDataRequest(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize) = 0;
|
||||
virtual bool sendDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize) = 0;
|
||||
|
||||
/* Server Send */
|
||||
virtual bool sendData(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data) = 0;
|
||||
virtual bool sendData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data) = 0;
|
||||
|
||||
/// Send a chunkmap[request]. Because requests/chunkmaps can go both
|
||||
//directions, but for different usages, we have this "is_client" flags,
|
||||
//that gives the ultimate goal of the data. "is_client==true" means that
|
||||
//the message is for a client (download) instead of a server.
|
||||
//
|
||||
virtual bool sendChunkMapRequest(const RsPeerId& peer_id,const std::string& hash,bool is_client) = 0;
|
||||
virtual bool sendChunkMap(const RsPeerId& peer_id,const std::string& hash,const CompressedChunkMap& cmap,bool is_client) = 0;
|
||||
virtual bool sendChunkMapRequest(const RsPeerId& peer_id,const RsFileHash& hash,bool is_client) = 0;
|
||||
virtual bool sendChunkMap(const RsPeerId& peer_id,const RsFileHash& hash,const CompressedChunkMap& cmap,bool is_client) = 0;
|
||||
|
||||
/// Send a request for a chunk crc map
|
||||
virtual bool sendSingleChunkCRCRequest(const RsPeerId& peer_id,const std::string& hash,uint32_t chunk_number) = 0;
|
||||
virtual bool sendSingleChunkCRCRequest(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_number) = 0;
|
||||
/// Send a chunk crc map
|
||||
virtual bool sendSingleChunkCRC(const RsPeerId& peer_id,const std::string& hash,uint32_t chunk_number,const Sha1CheckSum& crc) = 0;
|
||||
virtual bool sendSingleChunkCRC(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_number,const Sha1CheckSum& crc) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -79,19 +79,19 @@ class ftDataRecv
|
|||
virtual ~ftDataRecv() { return; }
|
||||
|
||||
/* Client Recv */
|
||||
virtual bool recvData(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data) = 0;
|
||||
virtual bool recvData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data) = 0;
|
||||
|
||||
/* Server Recv */
|
||||
virtual bool recvDataRequest(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize) = 0;
|
||||
virtual bool recvDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize) = 0;
|
||||
|
||||
/// Send a request for a chunk map
|
||||
virtual bool recvChunkMapRequest(const RsPeerId& peer_id,const std::string& hash,bool is_client) = 0;
|
||||
virtual bool recvChunkMapRequest(const RsPeerId& peer_id,const RsFileHash& hash,bool is_client) = 0;
|
||||
|
||||
/// Send a chunk map
|
||||
virtual bool recvChunkMap(const RsPeerId& peer_id,const std::string& hash,const CompressedChunkMap& cmap,bool is_client) = 0;
|
||||
virtual bool recvChunkMap(const RsPeerId& peer_id,const RsFileHash& hash,const CompressedChunkMap& cmap,bool is_client) = 0;
|
||||
|
||||
virtual bool recvSingleChunkCRCRequest(const RsPeerId& peer_id,const std::string& hash,uint32_t chunk_id) = 0;
|
||||
virtual bool recvSingleChunkCRC(const RsPeerId& peer_id,const std::string& hash,uint32_t chunk_id,const Sha1CheckSum& sum) = 0;
|
||||
virtual bool recvSingleChunkCRCRequest(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_id) = 0;
|
||||
virtual bool recvSingleChunkCRC(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_id,const Sha1CheckSum& sum) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ const uint32_t FT_SERVER_CHUNK_MAP_REQ = 0x0004; // chunk map request to be tre
|
|||
//const uint32_t FT_CRC32MAP_REQ = 0x0005; // crc32 map request to be treated by server
|
||||
const uint32_t FT_CLIENT_CHUNK_CRC_REQ = 0x0006; // chunk sha1 crc request to be treated
|
||||
|
||||
ftRequest::ftRequest(uint32_t type, const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunk, void *data)
|
||||
ftRequest::ftRequest(uint32_t type, const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunk, void *data)
|
||||
:mType(type), mPeerId(peerId), mHash(hash), mSize(size),
|
||||
mOffset(offset), mChunk(chunk), mData(data)
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ ftDataMultiplex::ftDataMultiplex(const RsPeerId& ownId, ftDataSend *server, ftSe
|
|||
bool ftDataMultiplex::addTransferModule(ftTransferModule *mod, ftFileCreator *f)
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
std::map<std::string, ftClient>::iterator it;
|
||||
std::map<RsFileHash, ftClient>::iterator it;
|
||||
if (mClients.end() != (it = mClients.find(mod->hash())))
|
||||
{
|
||||
/* error */
|
||||
|
@ -91,11 +91,11 @@ bool ftDataMultiplex::addTransferModule(ftTransferModule *mod, ftFileCreator *f)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::removeTransferModule(std::string hash)
|
||||
bool ftDataMultiplex::removeTransferModule(const RsFileHash& hash)
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
|
||||
std::map<std::string, ftClient>::iterator it;
|
||||
std::map<RsFileHash, ftClient>::iterator it;
|
||||
if (mClients.end() == (it = mClients.find(hash)))
|
||||
{
|
||||
/* error */
|
||||
|
@ -111,7 +111,7 @@ bool ftDataMultiplex::removeTransferModule(std::string hash)
|
|||
// With the current action, the next server request will re-create the server as
|
||||
// a ftFileProvider.
|
||||
//
|
||||
std::map<std::string, ftFileProvider*>::iterator sit = mServers.find(hash) ;
|
||||
std::map<RsFileHash, ftFileProvider*>::iterator sit = mServers.find(hash) ;
|
||||
|
||||
if(sit != mServers.end())
|
||||
mServers.erase(sit);
|
||||
|
@ -120,10 +120,10 @@ bool ftDataMultiplex::removeTransferModule(std::string hash)
|
|||
}
|
||||
|
||||
|
||||
bool ftDataMultiplex::FileUploads(std::list<std::string> &hashs)
|
||||
bool ftDataMultiplex::FileUploads(std::list<RsFileHash> &hashs)
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
std::map<std::string, ftFileProvider *>::iterator sit;
|
||||
std::map<RsFileHash, ftFileProvider *>::iterator sit;
|
||||
for(sit = mServers.begin(); sit != mServers.end(); sit++)
|
||||
{
|
||||
hashs.push_back(sit->first);
|
||||
|
@ -131,10 +131,10 @@ bool ftDataMultiplex::FileUploads(std::list<std::string> &hashs)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::FileDownloads(std::list<std::string> &hashs)
|
||||
bool ftDataMultiplex::FileDownloads(std::list<RsFileHash> &hashs)
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
std::map<std::string, ftClient>::iterator cit;
|
||||
std::map<RsFileHash, ftClient>::iterator cit;
|
||||
for(cit = mClients.begin(); cit != mClients.end(); cit++)
|
||||
{
|
||||
hashs.push_back(cit->first);
|
||||
|
@ -143,7 +143,7 @@ bool ftDataMultiplex::FileDownloads(std::list<std::string> &hashs)
|
|||
}
|
||||
|
||||
|
||||
bool ftDataMultiplex::FileDetails(const std::string &hash, FileSearchFlags hintsflag, FileInfo &info)
|
||||
bool ftDataMultiplex::FileDetails(const RsFileHash &hash, FileSearchFlags hintsflag, FileInfo &info)
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::FileDetails(";
|
||||
|
@ -155,7 +155,7 @@ bool ftDataMultiplex::FileDetails(const std::string &hash, FileSearchFlags hi
|
|||
|
||||
if(hintsflag & RS_FILE_HINTS_DOWNLOAD)
|
||||
{
|
||||
std::map<std::string, ftClient>::iterator cit;
|
||||
std::map<RsFileHash, ftClient>::iterator cit;
|
||||
if (mClients.end() != (cit = mClients.find(hash)))
|
||||
{
|
||||
|
||||
|
@ -173,7 +173,7 @@ bool ftDataMultiplex::FileDetails(const std::string &hash, FileSearchFlags hi
|
|||
|
||||
if(hintsflag & RS_FILE_HINTS_UPLOAD)
|
||||
{
|
||||
std::map<std::string, ftFileProvider *>::iterator sit;
|
||||
std::map<RsFileHash, ftFileProvider *>::iterator sit;
|
||||
sit = mServers.find(hash);
|
||||
if (sit != mServers.end())
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ bool ftDataMultiplex::FileDetails(const std::string &hash, FileSearchFlags hi
|
|||
/*************** SEND INTERFACE (calls ftDataSend) *******************/
|
||||
|
||||
/* Client Send */
|
||||
bool ftDataMultiplex::sendDataRequest(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize)
|
||||
bool ftDataMultiplex::sendDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize)
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::sendDataRequest() Client Send";
|
||||
|
@ -214,7 +214,7 @@ bool ftDataMultiplex::sendDataRequest(const RsPeerId& peerId, const std::string&
|
|||
}
|
||||
|
||||
/* Server Send */
|
||||
bool ftDataMultiplex::sendData(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data)
|
||||
bool ftDataMultiplex::sendData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data)
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::sendData() Server Send";
|
||||
|
@ -227,7 +227,7 @@ bool ftDataMultiplex::sendData(const RsPeerId& peerId, const std::string& hash,
|
|||
/*************** RECV INTERFACE (provides ftDataRecv) ****************/
|
||||
|
||||
/* Client Recv */
|
||||
bool ftDataMultiplex::recvData(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data)
|
||||
bool ftDataMultiplex::recvData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data)
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::recvData() Client Recv";
|
||||
|
@ -242,7 +242,7 @@ bool ftDataMultiplex::recvData(const RsPeerId& peerId, const std::string& hash,
|
|||
|
||||
|
||||
/* Server Recv */
|
||||
bool ftDataMultiplex::recvDataRequest(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize)
|
||||
bool ftDataMultiplex::recvDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize)
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::recvDataRequest() Server Recv";
|
||||
|
@ -256,7 +256,7 @@ bool ftDataMultiplex::recvDataRequest(const RsPeerId& peerId, const std::string&
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::recvChunkMapRequest(const RsPeerId& peerId, const std::string& hash,bool is_client)
|
||||
bool ftDataMultiplex::recvChunkMapRequest(const RsPeerId& peerId, const RsFileHash& hash,bool is_client)
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::recvChunkMapRequest() Server Recv";
|
||||
|
@ -273,7 +273,7 @@ bool ftDataMultiplex::recvChunkMapRequest(const RsPeerId& peerId, const std::str
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::recvSingleChunkCRCRequest(const RsPeerId& peerId, const std::string& hash,uint32_t chunk_number)
|
||||
bool ftDataMultiplex::recvSingleChunkCRCRequest(const RsPeerId& peerId, const RsFileHash& hash,uint32_t chunk_number)
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::recvChunkMapRequest() Server Recv";
|
||||
|
@ -406,7 +406,7 @@ bool ftDataMultiplex::doWork()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::recvSingleChunkCRC(const RsPeerId& peerId, const std::string& hash,uint32_t chunk_number,const Sha1CheckSum& crc)
|
||||
bool ftDataMultiplex::recvSingleChunkCRC(const RsPeerId& peerId, const RsFileHash& hash,uint32_t chunk_number,const Sha1CheckSum& crc)
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
|
||||
|
@ -425,7 +425,7 @@ bool ftDataMultiplex::recvSingleChunkCRC(const RsPeerId& peerId, const std::stri
|
|||
|
||||
// update the cache: get size from the client.
|
||||
|
||||
std::map<std::string, ftClient>::iterator it = mClients.find(hash);
|
||||
std::map<RsFileHash, ftClient>::iterator it = mClients.find(hash);
|
||||
|
||||
if(it == mClients.end())
|
||||
{
|
||||
|
@ -456,9 +456,9 @@ bool ftDataMultiplex::dispatchReceivedChunkCheckSum()
|
|||
|
||||
uint32_t MAX_CHECKSUM_CHECK_PER_FILE = 25 ;
|
||||
|
||||
for(std::map<std::string,Sha1CacheEntry>::iterator it(_cached_sha1maps.begin());it!=_cached_sha1maps.end();)
|
||||
for(std::map<RsFileHash,Sha1CacheEntry>::iterator it(_cached_sha1maps.begin());it!=_cached_sha1maps.end();)
|
||||
{
|
||||
std::map<std::string, ftClient>::iterator itc = mClients.find(it->first);
|
||||
std::map<RsFileHash, ftClient>::iterator itc = mClients.find(it->first);
|
||||
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::dispatchReceivedChunkCheckSum(): treating hash " << it->first << std::endl;
|
||||
|
@ -470,7 +470,7 @@ bool ftDataMultiplex::dispatchReceivedChunkCheckSum()
|
|||
std::cerr << "ftDataMultiplex::dispatchReceivedChunkCheckSum() ERROR: No matching Client for hash. This is probably a late answer. Dropping the hash. Hash=" << it->first << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<std::string,Sha1CacheEntry>::iterator tmp(it) ;
|
||||
std::map<RsFileHash,Sha1CacheEntry>::iterator tmp(it) ;
|
||||
++tmp ;
|
||||
_cached_sha1maps.erase(it) ;
|
||||
it = tmp ;
|
||||
|
@ -503,13 +503,13 @@ bool ftDataMultiplex::dispatchReceivedChunkCheckSum()
|
|||
// - an uploader has sent his chunk map, so we need to store it in the corresponding ftFileProvider
|
||||
// - a source for a download has sent his chunk map, so we need to send it to the corresponding ftFileCreator.
|
||||
//
|
||||
bool ftDataMultiplex::recvChunkMap(const RsPeerId& peerId, const std::string& hash,const CompressedChunkMap& compressed_map,bool client)
|
||||
bool ftDataMultiplex::recvChunkMap(const RsPeerId& peerId, const RsFileHash& hash,const CompressedChunkMap& compressed_map,bool client)
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
|
||||
if(client) // is the chunk map for a client, or for a server ?
|
||||
{
|
||||
std::map<std::string, ftClient>::iterator it = mClients.find(hash);
|
||||
std::map<RsFileHash, ftClient>::iterator it = mClients.find(hash);
|
||||
|
||||
if(it == mClients.end())
|
||||
{
|
||||
|
@ -531,7 +531,7 @@ bool ftDataMultiplex::recvChunkMap(const RsPeerId& peerId, const std::string& ha
|
|||
}
|
||||
else
|
||||
{
|
||||
std::map<std::string, ftFileProvider *>::iterator it = mServers.find(hash) ;
|
||||
std::map<RsFileHash, ftFileProvider *>::iterator it = mServers.find(hash) ;
|
||||
|
||||
if(it == mServers.end())
|
||||
{
|
||||
|
@ -549,14 +549,14 @@ bool ftDataMultiplex::recvChunkMap(const RsPeerId& peerId, const std::string& ha
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::handleRecvClientChunkMapRequest(const RsPeerId& peerId, const std::string& hash)
|
||||
bool ftDataMultiplex::handleRecvClientChunkMapRequest(const RsPeerId& peerId, const RsFileHash& hash)
|
||||
{
|
||||
CompressedChunkMap cmap ;
|
||||
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
|
||||
std::map<std::string, ftClient>::iterator it = mClients.find(hash);
|
||||
std::map<RsFileHash, ftClient>::iterator it = mClients.find(hash);
|
||||
|
||||
if(it == mClients.end())
|
||||
{
|
||||
|
@ -581,7 +581,7 @@ bool ftDataMultiplex::handleRecvClientChunkMapRequest(const RsPeerId& peerId, co
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::handleRecvChunkCrcRequest(const RsPeerId& peerId, const std::string& hash, uint32_t chunk_number)
|
||||
bool ftDataMultiplex::handleRecvChunkCrcRequest(const RsPeerId& peerId, const RsFileHash& hash, uint32_t chunk_number)
|
||||
{
|
||||
// look into the sha1sum cache
|
||||
|
||||
|
@ -614,7 +614,7 @@ bool ftDataMultiplex::handleRecvChunkCrcRequest(const RsPeerId& peerId, const st
|
|||
return true ;
|
||||
}
|
||||
|
||||
std::map<std::string, ftFileProvider *>::iterator it ;
|
||||
std::map<RsFileHash, ftFileProvider *>::iterator it ;
|
||||
std::string filename ;
|
||||
uint64_t filesize =0;
|
||||
found = true ;
|
||||
|
@ -705,10 +705,10 @@ bool ftDataMultiplex::handleRecvChunkCrcRequest(const RsPeerId& peerId, const st
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::handleRecvServerChunkMapRequest(const RsPeerId& peerId, const std::string& hash)
|
||||
bool ftDataMultiplex::handleRecvServerChunkMapRequest(const RsPeerId& peerId, const RsFileHash& hash)
|
||||
{
|
||||
CompressedChunkMap cmap ;
|
||||
std::map<std::string, ftFileProvider *>::iterator it ;
|
||||
std::map<RsFileHash, ftFileProvider *>::iterator it ;
|
||||
bool found = true ;
|
||||
|
||||
{
|
||||
|
@ -754,13 +754,13 @@ bool ftDataMultiplex::handleRecvServerChunkMapRequest(const RsPeerId& peerId, co
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::handleRecvData(const RsPeerId& peerId, const std::string& hash, uint64_t /*size*/, uint64_t offset, uint32_t chunksize, void *data)
|
||||
bool ftDataMultiplex::handleRecvData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t /*size*/, uint64_t offset, uint32_t chunksize, void *data)
|
||||
{
|
||||
ftTransferModule *transfer_module = NULL ;
|
||||
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
std::map<std::string, ftClient>::iterator it;
|
||||
std::map<RsFileHash, ftClient>::iterator it;
|
||||
if (mClients.end() == (it = mClients.find(hash)))
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
|
@ -785,12 +785,12 @@ bool ftDataMultiplex::handleRecvData(const RsPeerId& peerId, const std::string&
|
|||
|
||||
|
||||
/* called by ftTransferModule */
|
||||
bool ftDataMultiplex::handleRecvDataRequest(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize)
|
||||
bool ftDataMultiplex::handleRecvDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize)
|
||||
{
|
||||
/**** Find Files *****/
|
||||
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
std::map<std::string, ftClient>::iterator cit;
|
||||
std::map<RsFileHash, ftClient>::iterator cit;
|
||||
if (mOwnId == peerId)
|
||||
{
|
||||
/* own requests must be passed to Servers */
|
||||
|
@ -809,7 +809,7 @@ bool ftDataMultiplex::handleRecvDataRequest(const RsPeerId& peerId, const std::s
|
|||
return true;
|
||||
}
|
||||
|
||||
std::map<std::string, ftFileProvider *>::iterator sit;
|
||||
std::map<RsFileHash, ftFileProvider *>::iterator sit;
|
||||
if (mServers.end() != (sit = mServers.find(hash)))
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
|
@ -831,7 +831,7 @@ bool ftDataMultiplex::handleRecvDataRequest(const RsPeerId& peerId, const std::s
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::locked_handleServerRequest(ftFileProvider *provider, const RsPeerId& peerId, const std::string& hash, uint64_t size,
|
||||
bool ftDataMultiplex::locked_handleServerRequest(ftFileProvider *provider, const RsPeerId& peerId, const RsFileHash& hash, uint64_t size,
|
||||
uint64_t offset, uint32_t chunksize)
|
||||
{
|
||||
if(chunksize > uint32_t(10*1024*1024))
|
||||
|
@ -872,13 +872,13 @@ bool ftDataMultiplex::locked_handleServerRequest(ftFileProvider *provider, const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::getClientChunkMap(const std::string& upload_hash,const RsPeerId& peerId,CompressedChunkMap& cmap)
|
||||
bool ftDataMultiplex::getClientChunkMap(const RsFileHash& upload_hash,const RsPeerId& peerId,CompressedChunkMap& cmap)
|
||||
{
|
||||
bool too_old = false;
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
|
||||
std::map<std::string,ftFileProvider *>::iterator sit = mServers.find(upload_hash);
|
||||
std::map<RsFileHash,ftFileProvider *>::iterator sit = mServers.find(upload_hash);
|
||||
|
||||
if(mServers.end() == sit)
|
||||
return false ;
|
||||
|
@ -894,11 +894,11 @@ bool ftDataMultiplex::getClientChunkMap(const std::string& upload_hash,const RsP
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::sendChunkMapRequest(const RsPeerId& peer_id,const std::string& hash,bool is_client)
|
||||
bool ftDataMultiplex::sendChunkMapRequest(const RsPeerId& peer_id,const RsFileHash& hash,bool is_client)
|
||||
{
|
||||
return mDataSend->sendChunkMapRequest(peer_id,hash,is_client);
|
||||
}
|
||||
bool ftDataMultiplex::sendSingleChunkCRCRequests(const std::string& hash, const std::vector<uint32_t>& to_ask)
|
||||
bool ftDataMultiplex::sendSingleChunkCRCRequests(const RsFileHash& hash, const std::vector<uint32_t>& to_ask)
|
||||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
|
||||
|
@ -930,7 +930,7 @@ void ftDataMultiplex::handlePendingCrcRequests()
|
|||
// With this, only active sources are querried.
|
||||
//
|
||||
|
||||
for(std::map<std::string,Sha1CacheEntry>::iterator it(_cached_sha1maps.begin());it!=_cached_sha1maps.end();++it)
|
||||
for(std::map<RsFileHash,Sha1CacheEntry>::iterator it(_cached_sha1maps.begin());it!=_cached_sha1maps.end();++it)
|
||||
for(std::map<uint32_t,std::pair<time_t,ChunkCheckSumSourceList> >::iterator it2(it->second._to_ask.begin());it2!=it->second._to_ask.end();++it2)
|
||||
if(it2->second.first + MAX_CHECKING_CHUNK_WAIT_DELAY < now) // is the last request old enough?
|
||||
{
|
||||
|
@ -939,7 +939,7 @@ void ftDataMultiplex::handlePendingCrcRequests()
|
|||
#endif
|
||||
// 0 - ask which sources can be used for this chunk
|
||||
//
|
||||
std::map<std::string,ftClient>::const_iterator it4(mClients.find(it->first)) ;
|
||||
std::map<RsFileHash,ftClient>::const_iterator it4(mClients.find(it->first)) ;
|
||||
|
||||
if(it4 == mClients.end())
|
||||
continue ;
|
||||
|
@ -1011,7 +1011,7 @@ void ftDataMultiplex::deleteUnusedServers()
|
|||
//scan the uploads list in ftdatamultiplex and delete the items which time out
|
||||
time_t now = time(NULL);
|
||||
|
||||
for(std::map<std::string, ftFileProvider *>::iterator sit(mServers.begin());sit != mServers.end();)
|
||||
for(std::map<RsFileHash, ftFileProvider *>::iterator sit(mServers.begin());sit != mServers.end();)
|
||||
if(sit->second->purgeOldPeers(now,10))
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
|
@ -1030,7 +1030,7 @@ void ftDataMultiplex::deleteUnusedServers()
|
|||
std::cerr << "ftDataMultiplex::deleteUnusedServers(): " << (void*)sit->second << " was not deleted because it's also a file creator." << std::endl ;
|
||||
#endif
|
||||
|
||||
std::map<std::string, ftFileProvider *>::iterator tmp(sit);
|
||||
std::map<RsFileHash, ftFileProvider *>::iterator tmp(sit);
|
||||
++tmp ;
|
||||
|
||||
mServers.erase(sit);
|
||||
|
@ -1041,7 +1041,7 @@ void ftDataMultiplex::deleteUnusedServers()
|
|||
++sit ;
|
||||
}
|
||||
|
||||
bool ftDataMultiplex::handleSearchRequest(const RsPeerId& peerId, const std::string& hash)
|
||||
bool ftDataMultiplex::handleSearchRequest(const RsPeerId& peerId, const RsFileHash& hash)
|
||||
{
|
||||
#ifdef MPLEX_DEBUG
|
||||
std::cerr << "ftDataMultiplex::handleSearchRequest(";
|
||||
|
@ -1082,7 +1082,7 @@ bool ftDataMultiplex::handleSearchRequest(const RsPeerId& peerId, const std::str
|
|||
std::cerr << "ftDataMultiplex::handleSearchRequest(";
|
||||
std::cerr << " Found Local File, sharing...";
|
||||
#endif
|
||||
std::map<std::string,ftFileProvider*>::const_iterator it = mServers.find(hash) ;
|
||||
std::map<RsFileHash,ftFileProvider*>::const_iterator it = mServers.find(hash) ;
|
||||
ftFileProvider *provider ;
|
||||
|
||||
if(it == mServers.end())
|
||||
|
@ -1113,7 +1113,7 @@ bool ftDataMultiplex::handleSearchRequest(const RsPeerId& peerId, const std::str
|
|||
{
|
||||
RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/
|
||||
|
||||
std::map<std::string,ftClient>::const_iterator it(mClients.find(hash)) ;
|
||||
std::map<RsFileHash,ftClient>::const_iterator it(mClients.find(hash)) ;
|
||||
|
||||
if(it != mClients.end())
|
||||
{
|
||||
|
|
|
@ -63,14 +63,14 @@ class ftRequest
|
|||
{
|
||||
public:
|
||||
|
||||
ftRequest(uint32_t type, const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunk, void *data);
|
||||
ftRequest(uint32_t type, const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunk, void *data);
|
||||
|
||||
ftRequest()
|
||||
:mType(0), mSize(0), mOffset(0), mChunk(0), mData(NULL) { return; }
|
||||
|
||||
uint32_t mType;
|
||||
SSLIdType mPeerId;
|
||||
std::string mHash;
|
||||
RsPeerId mPeerId;
|
||||
RsFileHash mHash;
|
||||
uint64_t mSize;
|
||||
uint64_t mOffset;
|
||||
uint32_t mChunk;
|
||||
|
@ -93,17 +93,17 @@ class ftDataMultiplex: public ftDataRecv, public RsQueueThread
|
|||
|
||||
public:
|
||||
|
||||
ftDataMultiplex(const SSLIdType& ownId, ftDataSend *server, ftSearch *search);
|
||||
ftDataMultiplex(const RsPeerId& ownId, ftDataSend *server, ftSearch *search);
|
||||
|
||||
/* ftController Interface */
|
||||
bool addTransferModule(ftTransferModule *mod, ftFileCreator *f);
|
||||
bool removeTransferModule(std::string hash);
|
||||
bool removeTransferModule(const RsFileHash& hash);
|
||||
|
||||
/* data interface */
|
||||
/* get Details of File Transfers */
|
||||
bool FileUploads(std::list<std::string> &hashs);
|
||||
bool FileDownloads(std::list<std::string> &hashs);
|
||||
bool FileDetails(const std::string &hash, FileSearchFlags hintsflag, FileInfo &info);
|
||||
bool FileUploads(std::list<RsFileHash> &hashs);
|
||||
bool FileDownloads(std::list<RsFileHash> &hashs);
|
||||
bool FileDetails(const RsFileHash &hash, FileSearchFlags hintsflag, FileInfo &info);
|
||||
|
||||
void deleteUnusedServers() ;
|
||||
void handlePendingCrcRequests() ;
|
||||
|
@ -112,39 +112,39 @@ class ftDataMultiplex: public ftDataRecv, public RsQueueThread
|
|||
/*************** SEND INTERFACE (calls ftDataSend) *******************/
|
||||
|
||||
/* Client Send */
|
||||
bool sendDataRequest(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
bool sendDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
|
||||
/* Server Send */
|
||||
bool sendData(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
bool sendData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
|
||||
/* Server/client Send */
|
||||
bool sendChunkMapRequest(const SSLIdType& peerId, const std::string& hash,bool is_client) ;
|
||||
bool sendChunkMapRequest(const RsPeerId& peerId, const RsFileHash& hash,bool is_client) ;
|
||||
|
||||
|
||||
/* called from a separate thread */
|
||||
bool sendSingleChunkCRCRequests(const std::string& hash, const std::vector<uint32_t>& to_ask) ;
|
||||
bool sendSingleChunkCRCRequests(const RsFileHash& hash, const std::vector<uint32_t>& to_ask) ;
|
||||
|
||||
bool dispatchReceivedChunkCheckSum() ;
|
||||
|
||||
/*************** RECV INTERFACE (provides ftDataRecv) ****************/
|
||||
|
||||
/* Client Recv */
|
||||
virtual bool recvData(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
virtual bool recvData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
/* Server Recv */
|
||||
virtual bool recvDataRequest(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
virtual bool recvDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
|
||||
/// Receive a request for a chunk map
|
||||
virtual bool recvChunkMapRequest(const SSLIdType& peer_id,const std::string& hash,bool is_client) ;
|
||||
virtual bool recvChunkMapRequest(const RsPeerId& peer_id,const RsFileHash& hash,bool is_client) ;
|
||||
/// Receive a chunk map
|
||||
virtual bool recvChunkMap(const SSLIdType& peer_id,const std::string& hash,const CompressedChunkMap& cmap,bool is_client) ;
|
||||
virtual bool recvChunkMap(const RsPeerId& peer_id,const RsFileHash& hash,const CompressedChunkMap& cmap,bool is_client) ;
|
||||
|
||||
virtual bool recvSingleChunkCRCRequest(const SSLIdType& peer_id,const std::string& hash,uint32_t chunk_id) ;
|
||||
virtual bool recvSingleChunkCRC(const SSLIdType& peer_id,const std::string& hash,uint32_t chunk_id,const Sha1CheckSum& sum) ;
|
||||
virtual bool recvSingleChunkCRCRequest(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_id) ;
|
||||
virtual bool recvSingleChunkCRC(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_id,const Sha1CheckSum& sum) ;
|
||||
|
||||
// Returns the chunk map from the file uploading client. Also initiates a chunk map request if this
|
||||
// map is too old. This supposes that the caller will ask again in a few seconds.
|
||||
//
|
||||
bool getClientChunkMap(const std::string& upload_hash,const SSLIdType& peer_id,CompressedChunkMap& map) ;
|
||||
bool getClientChunkMap(const RsFileHash& upload_hash,const RsPeerId& peer_id,CompressedChunkMap& map) ;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -155,26 +155,25 @@ class ftDataMultiplex: public ftDataRecv, public RsQueueThread
|
|||
private:
|
||||
|
||||
/* Handling Job Queues */
|
||||
bool handleRecvData(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
bool handleRecvDataRequest(const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
bool handleSearchRequest(const SSLIdType& peerId, const std::string& hash);
|
||||
bool handleRecvClientChunkMapRequest(const SSLIdType& peerId, const std::string& hash) ;
|
||||
bool handleRecvServerChunkMapRequest(const SSLIdType& peerId, const std::string& hash) ;
|
||||
bool handleRecvChunkCrcRequest(const SSLIdType& peerId, const std::string& hash,uint32_t chunk_id) ;
|
||||
bool handleRecvData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
bool handleRecvDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
bool handleSearchRequest(const RsPeerId& peerId, const RsFileHash& hash);
|
||||
bool handleRecvClientChunkMapRequest(const RsPeerId& peerId, const RsFileHash& hash) ;
|
||||
bool handleRecvServerChunkMapRequest(const RsPeerId& peerId, const RsFileHash& hash) ;
|
||||
bool handleRecvChunkCrcRequest(const RsPeerId& peerId, const RsFileHash& hash,uint32_t chunk_id) ;
|
||||
|
||||
/* We end up doing the actual server job here */
|
||||
bool locked_handleServerRequest(ftFileProvider *provider, const SSLIdType& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
bool locked_handleServerRequest(ftFileProvider *provider, const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
|
||||
RsMutex dataMtx;
|
||||
|
||||
std::map<std::string, ftClient> mClients;
|
||||
std::map<std::string, ftFileProvider *> mServers;
|
||||
std::map<RsFileHash, ftClient> mClients;
|
||||
std::map<RsFileHash, ftFileProvider *> mServers;
|
||||
|
||||
std::list<ftRequest> mRequestQueue;
|
||||
std::list<ftRequest> mSearchQueue;
|
||||
// std::map<std::string, time_t> mUnknownHashs;
|
||||
|
||||
std::map<std::string,Sha1CacheEntry> _cached_sha1maps ; // one cache entry per file hash. Handled dynamically.
|
||||
std::map<RsFileHash,Sha1CacheEntry> _cached_sha1maps ; // one cache entry per file hash. Handled dynamically.
|
||||
|
||||
ftDataSend *mDataSend;
|
||||
ftSearch *mSearch;
|
||||
|
|
|
@ -37,7 +37,7 @@ ftFiStore::ftFiStore(CacheStrapper *cs, CacheTransfer *cft, p3PeerMgr *pm,
|
|||
return;
|
||||
}
|
||||
|
||||
bool ftFiStore::search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
bool ftFiStore::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
{
|
||||
/* could use hintflags to specify which bits of fileinfo to use additionally.
|
||||
eg. hintflags & FT_SEARCH_PEER_ID, then only return matching peers + hash.
|
||||
|
@ -128,11 +128,11 @@ ftFiMonitor::ftFiMonitor(CacheStrapper *cs,std::string cachedir, const RsPeerId&
|
|||
return;
|
||||
}
|
||||
|
||||
bool ftFiMonitor::search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
bool ftFiMonitor::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
{
|
||||
return search(hash,hintflags,RsPeerId(),info) ;
|
||||
}
|
||||
bool ftFiMonitor::search(const std::string &hash, FileSearchFlags hintflags, const RsPeerId& peer_id,FileInfo &info) const
|
||||
bool ftFiMonitor::search(const RsFileHash &hash, FileSearchFlags hintflags, const RsPeerId& peer_id,FileInfo &info) const
|
||||
{
|
||||
#ifdef DB_DEBUG
|
||||
std::cerr << "ftFiMonitor::search(" << hash << "," << hintflags;
|
||||
|
@ -385,7 +385,7 @@ ftCacheStrapper::ftCacheStrapper(p3LinkMgr *lm)
|
|||
}
|
||||
|
||||
/* overloaded search function */
|
||||
bool ftCacheStrapper::search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
bool ftCacheStrapper::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
{
|
||||
/* remove unused parameter warnings */
|
||||
(void) hintflags;
|
||||
|
|
|
@ -52,7 +52,7 @@ class ftFiStore: public FileIndexStore, public ftSearch
|
|||
RsPeerId ownid, std::string cachedir);
|
||||
|
||||
/* overloaded search function */
|
||||
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
};
|
||||
|
||||
class ftFiMonitor: public FileIndexMonitor, public ftSearch, public p3Config
|
||||
|
@ -61,8 +61,8 @@ class ftFiMonitor: public FileIndexMonitor, public ftSearch, public p3Config
|
|||
ftFiMonitor(CacheStrapper *cs,std::string cachedir, const RsPeerId& pid,const std::string& config_dir);
|
||||
|
||||
/* overloaded search function */
|
||||
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
virtual bool search(const std::string &hash, FileSearchFlags hintflags, const RsPeerId& peer_id, FileInfo &info) const;
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, const RsPeerId& peer_id, FileInfo &info) const;
|
||||
|
||||
/* overloaded set dirs enables config indication */
|
||||
virtual void setSharedDirectories(const std::list<SharedDirInfo>& dirList);
|
||||
|
@ -94,7 +94,7 @@ class ftCacheStrapper: public CacheStrapper, public ftSearch
|
|||
ftCacheStrapper(p3LinkMgr *cm);
|
||||
|
||||
/* overloaded search function */
|
||||
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ void ftExtraList::hashAFile()
|
|||
* If the File is alreay Hashed, then just add it in.
|
||||
**/
|
||||
|
||||
bool ftExtraList::addExtraFile(std::string path, std::string hash,
|
||||
bool ftExtraList::addExtraFile(std::string path, const RsFileHash& hash,
|
||||
uint64_t size, uint32_t period, TransferRequestFlags flags)
|
||||
{
|
||||
#ifdef DEBUG_ELIST
|
||||
|
@ -180,7 +180,7 @@ bool ftExtraList::addExtraFile(std::string path, std::string hash,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftExtraList::removeExtraFile(std::string hash, TransferRequestFlags flags)
|
||||
bool ftExtraList::removeExtraFile(const RsFileHash& hash, TransferRequestFlags flags)
|
||||
{
|
||||
/* remove unused parameter warnings */
|
||||
(void) flags;
|
||||
|
@ -195,7 +195,7 @@ bool ftExtraList::removeExtraFile(std::string hash, TransferRequestFlags flags)
|
|||
|
||||
RsStackMutex stack(extMutex);
|
||||
|
||||
std::map<std::string, FileDetails>::iterator it;
|
||||
std::map<RsFileHash, FileDetails>::iterator it;
|
||||
it = mFiles.find(hash);
|
||||
if (it == mFiles.end())
|
||||
{
|
||||
|
@ -209,12 +209,12 @@ bool ftExtraList::removeExtraFile(std::string hash, TransferRequestFlags flags)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftExtraList::moveExtraFile(std::string fname, std::string hash, uint64_t /*size*/,
|
||||
bool ftExtraList::moveExtraFile(std::string fname, const RsFileHash &hash, uint64_t /*size*/,
|
||||
std::string destpath)
|
||||
{
|
||||
RsStackMutex stack(extMutex);
|
||||
|
||||
std::map<std::string, FileDetails>::iterator it;
|
||||
std::map<RsFileHash, FileDetails>::iterator it;
|
||||
it = mFiles.find(hash);
|
||||
if (it == mFiles.end())
|
||||
{
|
||||
|
@ -246,10 +246,10 @@ bool ftExtraList::cleanupOldFiles()
|
|||
|
||||
time_t now = time(NULL);
|
||||
|
||||
std::list<std::string> toRemove;
|
||||
std::list<std::string>::iterator rit;
|
||||
std::list<RsFileHash> toRemove;
|
||||
std::list<RsFileHash>::iterator rit;
|
||||
|
||||
std::map<std::string, FileDetails>::iterator it;
|
||||
std::map<RsFileHash, FileDetails>::iterator it;
|
||||
for(it = mFiles.begin(); it != mFiles.end(); it++)
|
||||
{
|
||||
/* check timestamps */
|
||||
|
@ -317,12 +317,12 @@ bool ftExtraList::hashExtraFileDone(std::string path, FileInfo &info)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
{
|
||||
/* Find in the path->hash map */
|
||||
RsStackMutex stack(extMutex);
|
||||
|
||||
std::map<std::string, std::string>::iterator it;
|
||||
std::map<std::string, RsFileHash>::iterator it;
|
||||
if (mHashedList.end() == (it = mHashedList.find(path)))
|
||||
{
|
||||
return false;
|
||||
|
@ -336,7 +336,7 @@ bool ftExtraList::hashExtraFileDone(std::string path, FileInfo &info)
|
|||
* Search Function - used by File Transfer
|
||||
*
|
||||
**/
|
||||
bool ftExtraList::search(const std::string &hash, FileSearchFlags /*hintflags*/, FileInfo &info) const
|
||||
bool ftExtraList::search(const RsFileHash &hash, FileSearchFlags /*hintflags*/, FileInfo &info) const
|
||||
{
|
||||
|
||||
#ifdef DEBUG_ELIST
|
||||
|
@ -345,7 +345,7 @@ bool ftExtraList::search(const std::string &hash, FileSearchFlags /*hintflags
|
|||
#endif
|
||||
|
||||
/* find hash */
|
||||
std::map<std::string, FileDetails>::const_iterator fit;
|
||||
std::map<RsFileHash, FileDetails>::const_iterator fit;
|
||||
if (mFiles.end() == (fit = mFiles.find(hash)))
|
||||
{
|
||||
return false;
|
||||
|
@ -397,7 +397,7 @@ bool ftExtraList::saveList(bool &cleanup, std::list<RsItem *>& sList)
|
|||
RsStackMutex stack(extMutex);
|
||||
|
||||
|
||||
std::map<std::string, FileDetails>::const_iterator it;
|
||||
std::map<RsFileHash, FileDetails>::const_iterator it;
|
||||
for(it = mFiles.begin(); it != mFiles.end(); it++)
|
||||
{
|
||||
RsFileConfigItem *fi = new RsFileConfigItem();
|
||||
|
|
|
@ -90,7 +90,7 @@ class FileDetails
|
|||
std::list<std::string> sources;
|
||||
std::string path;
|
||||
std::string fname;
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
uint64_t size;
|
||||
#endif
|
||||
|
||||
|
@ -117,11 +117,11 @@ class ftExtraList: public RsThread, public p3Config, public ftSearch
|
|||
* If the File is alreay Hashed, then just add it in.
|
||||
**/
|
||||
|
||||
bool addExtraFile(std::string path, std::string hash,
|
||||
bool addExtraFile(std::string path, const RsFileHash &hash,
|
||||
uint64_t size, uint32_t period, TransferRequestFlags flags);
|
||||
|
||||
bool removeExtraFile(std::string hash, TransferRequestFlags flags);
|
||||
bool moveExtraFile(std::string fname, std::string hash, uint64_t size,
|
||||
bool removeExtraFile(const RsFileHash& hash, TransferRequestFlags flags);
|
||||
bool moveExtraFile(std::string fname, const RsFileHash& hash, uint64_t size,
|
||||
std::string destpath);
|
||||
|
||||
|
||||
|
@ -138,7 +138,7 @@ bool hashExtraFileDone(std::string path, FileInfo &info);
|
|||
* implementation of ftSearch.
|
||||
*
|
||||
**/
|
||||
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
|
||||
/***
|
||||
* Thread Main Loop
|
||||
|
@ -165,8 +165,8 @@ bool cleanupEntry(std::string path, TransferRequestFlags flags);
|
|||
|
||||
std::list<FileDetails> mToHash;
|
||||
|
||||
std::map<std::string, std::string> mHashedList; /* path -> hash ( not saved ) */
|
||||
std::map<std::string, FileDetails> mFiles;
|
||||
std::map<std::string, RsFileHash> mHashedList; /* path -> hash ( not saved ) */
|
||||
std::map<RsFileHash, FileDetails> mFiles;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
*
|
||||
***********************************************************/
|
||||
|
||||
ftFileCreator::ftFileCreator(const std::string& path, uint64_t size, const std::string& hash,bool assume_availability)
|
||||
ftFileCreator::ftFileCreator(const std::string& path, uint64_t size, const RsFileHash& hash,bool assume_availability)
|
||||
: ftFileProvider(path,size,hash), chunkMap(size,assume_availability)
|
||||
{
|
||||
/*
|
||||
|
@ -617,7 +617,7 @@ bool ftFileCreator::finished()
|
|||
return chunkMap.isComplete() ;
|
||||
}
|
||||
|
||||
bool ftFileCreator::hashReceivedData(std::string& hash)
|
||||
bool ftFileCreator::hashReceivedData(RsFileHash& hash)
|
||||
{
|
||||
#ifdef FILE_DEBUG
|
||||
std::cerr << "file creator asked for hashing received data " << file_name << std::endl;
|
||||
|
|
|
@ -47,7 +47,7 @@ class ftFileCreator: public ftFileProvider
|
|||
{
|
||||
public:
|
||||
|
||||
ftFileCreator(const std::string& savepath, uint64_t size, const std::string& hash,bool assume_availability);
|
||||
ftFileCreator(const std::string& savepath, uint64_t size, const RsFileHash& hash,bool assume_availability);
|
||||
|
||||
~ftFileCreator();
|
||||
|
||||
|
@ -69,7 +69,7 @@ class ftFileCreator: public ftFileProvider
|
|||
// long time. Therefore, we must pay attention not to call this function
|
||||
// at a time file_name nor hash can be modified, which is quite easy.
|
||||
|
||||
bool hashReceivedData(std::string& hash) ;
|
||||
bool hashReceivedData(RsFileHash& hash) ;
|
||||
|
||||
// Sets all chunks to checking state
|
||||
//
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
static const time_t UPLOAD_CHUNK_MAPS_TIME = 20 ; // time to ask for a new chunkmap from uploaders in seconds.
|
||||
|
||||
ftFileProvider::ftFileProvider(const std::string& path, uint64_t size, const std::string& hash)
|
||||
ftFileProvider::ftFileProvider(const std::string& path, uint64_t size, const RsFileHash& hash)
|
||||
: mSize(size), hash(hash), file_name(path), fd(NULL), ftcMutex("ftFileProvider")
|
||||
{
|
||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||
|
@ -53,7 +53,7 @@ bool ftFileProvider::fileOk()
|
|||
return (fd != NULL);
|
||||
}
|
||||
|
||||
std::string ftFileProvider::getHash()
|
||||
RsFileHash ftFileProvider::getHash()
|
||||
{
|
||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||
return hash;
|
||||
|
|
|
@ -38,12 +38,12 @@
|
|||
class ftFileProvider
|
||||
{
|
||||
public:
|
||||
ftFileProvider(const std::string& path, uint64_t size, const std::string& hash);
|
||||
ftFileProvider(const std::string& path, uint64_t size, const RsFileHash& hash);
|
||||
virtual ~ftFileProvider();
|
||||
|
||||
virtual bool getFileData(const SSLIdType& peer_id,uint64_t offset, uint32_t &chunk_size, void *data);
|
||||
virtual bool FileDetails(FileInfo &info);
|
||||
std::string getHash();
|
||||
RsFileHash getHash();
|
||||
uint64_t getFileSize();
|
||||
bool fileOk();
|
||||
|
||||
|
@ -61,14 +61,14 @@ class ftFileProvider
|
|||
//
|
||||
bool purgeOldPeers(time_t now,uint32_t max_duration) ;
|
||||
|
||||
const std::string& fileHash() const { return hash ; }
|
||||
const RsFileHash& fileHash() const { return hash ; }
|
||||
const std::string& fileName() const { return file_name ; }
|
||||
uint64_t fileSize() const { return mSize ; }
|
||||
protected:
|
||||
virtual int initializeFileAttrs(); /* does for both */
|
||||
|
||||
uint64_t mSize;
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
std::string file_name;
|
||||
FILE *fd;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ bool ftFileSearch::addSearchMode(ftSearch *search, FileSearchFlags hintflags)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ftFileSearch::search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
bool ftFileSearch::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
{
|
||||
uint32_t hints, i;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class ftFileSearch: public ftSearch
|
|||
ftFileSearch();
|
||||
|
||||
bool addSearchMode(ftSearch *search, FileSearchFlags hintflags);
|
||||
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -42,12 +42,12 @@ class ftSearch
|
|||
public:
|
||||
ftSearch() { return; }
|
||||
virtual ~ftSearch() { return; }
|
||||
virtual bool search(const std::string & /*hash*/, FileSearchFlags /*hintflags*/,const std::string& /*peer_id*/, FileInfo & /*info*/) const
|
||||
virtual bool search(const RsFileHash & /*hash*/, FileSearchFlags /*hintflags*/,const RsPeerId& /*peer_id*/, FileInfo & /*info*/) const
|
||||
{
|
||||
std::cerr << "Non overloaded search method called!!!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const = 0;
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -241,38 +241,23 @@ bool ftServer::ResumeTransfers()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftServer::checkHash(const std::string& hash,std::string& error_string)
|
||||
bool ftServer::checkHash(const RsFileHash& hash,std::string& error_string)
|
||||
{
|
||||
static const uint32_t HASH_LENGTH = 40 ;
|
||||
|
||||
if(hash.length() != HASH_LENGTH)
|
||||
{
|
||||
rs_sprintf(error_string, "Line too long : %u chars, %ld expected.", hash.length(), HASH_LENGTH) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
for(uint32_t i=0;i<hash.length();++i)
|
||||
if(!((hash[i] > 47 && hash[i] < 58) || (hash[i] > 96 && hash[i] < 103)))
|
||||
{
|
||||
rs_sprintf(error_string, "unexpected char code=%d '%c'", (int)hash[i], hash[i]) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool ftServer::alreadyHaveFile(const std::string& hash, FileInfo &info)
|
||||
bool ftServer::alreadyHaveFile(const RsFileHash& hash, FileInfo &info)
|
||||
{
|
||||
return mFtController->alreadyHaveFile(hash, info);
|
||||
}
|
||||
|
||||
bool ftServer::FileRequest(const std::string& fname, const std::string& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<RsPeerId>& srcIds)
|
||||
bool ftServer::FileRequest(const std::string& fname, const RsFileHash& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<RsPeerId>& srcIds)
|
||||
{
|
||||
std::string error_string ;
|
||||
|
||||
if(!checkHash(hash,error_string))
|
||||
{
|
||||
RsServer::notify()->notifyErrorMsg(0,0,"Error handling hash \""+hash+"\". This hash appears to be invalid(Error string=\""+error_string+"\"). This is probably due an bad handling of strings.") ;
|
||||
RsServer::notify()->notifyErrorMsg(0,0,"Error handling hash \""+hash.toStdString()+"\". This hash appears to be invalid(Error string=\""+error_string+"\"). This is probably due an bad handling of strings.") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
@ -284,15 +269,15 @@ bool ftServer::FileRequest(const std::string& fname, const std::string& hash, ui
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftServer::setDestinationName(const std::string& hash,const std::string& name)
|
||||
bool ftServer::setDestinationName(const RsFileHash& hash,const std::string& name)
|
||||
{
|
||||
return mFtController->setDestinationName(hash,name);
|
||||
}
|
||||
bool ftServer::setDestinationDirectory(const std::string& hash,const std::string& directory)
|
||||
bool ftServer::setDestinationDirectory(const RsFileHash& hash,const std::string& directory)
|
||||
{
|
||||
return mFtController->setDestinationDirectory(hash,directory);
|
||||
}
|
||||
bool ftServer::setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s)
|
||||
bool ftServer::setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy s)
|
||||
{
|
||||
return mFtController->setChunkStrategy(hash,s);
|
||||
}
|
||||
|
@ -312,7 +297,7 @@ FileChunksInfo::ChunkStrategy ftServer::defaultChunkStrategy()
|
|||
{
|
||||
return mFtController->defaultChunkStrategy() ;
|
||||
}
|
||||
bool ftServer::FileCancel(const std::string& hash)
|
||||
bool ftServer::FileCancel(const RsFileHash& hash)
|
||||
{
|
||||
// Remove from both queue and ftController, by default.
|
||||
//
|
||||
|
@ -321,7 +306,7 @@ bool ftServer::FileCancel(const std::string& hash)
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftServer::FileControl(const std::string& hash, uint32_t flags)
|
||||
bool ftServer::FileControl(const RsFileHash& hash, uint32_t flags)
|
||||
{
|
||||
return mFtController->FileControl(hash, flags);
|
||||
}
|
||||
|
@ -347,17 +332,17 @@ uint32_t ftServer::getQueueSize()
|
|||
return mFtController->getQueueSize() ;
|
||||
}
|
||||
/* Control of Downloads Priority. */
|
||||
bool ftServer::changeQueuePosition(const std::string hash, QueueMove mv)
|
||||
bool ftServer::changeQueuePosition(const RsFileHash& hash, QueueMove mv)
|
||||
{
|
||||
mFtController->moveInQueue(hash,mv) ;
|
||||
return true ;
|
||||
}
|
||||
bool ftServer::changeDownloadSpeed(const std::string hash, int speed)
|
||||
bool ftServer::changeDownloadSpeed(const RsFileHash& hash, int speed)
|
||||
{
|
||||
mFtController->setPriority(hash, (DwlSpeed)speed);
|
||||
return true ;
|
||||
}
|
||||
bool ftServer::getDownloadSpeed(const std::string hash, int & speed)
|
||||
bool ftServer::getDownloadSpeed(const RsFileHash& hash, int & speed)
|
||||
{
|
||||
DwlSpeed _speed;
|
||||
int ret = mFtController->getPriority(hash, _speed);
|
||||
|
@ -366,12 +351,12 @@ bool ftServer::getDownloadSpeed(const std::string hash, int & speed)
|
|||
|
||||
return ret;
|
||||
}
|
||||
bool ftServer::clearDownload(const std::string /*hash*/)
|
||||
bool ftServer::clearDownload(const RsFileHash& /*hash*/)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool ftServer::FileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info)
|
||||
bool ftServer::FileDownloadChunksDetails(const RsFileHash& hash,FileChunksInfo& info)
|
||||
{
|
||||
return mFtController->getFileDownloadChunksDetails(hash,info);
|
||||
}
|
||||
|
@ -402,24 +387,24 @@ std::string ftServer::getPartialsDirectory()
|
|||
/************************* Other Access ************************/
|
||||
/***************************************************************/
|
||||
|
||||
bool ftServer::FileDownloads(std::list<std::string> &hashs)
|
||||
bool ftServer::FileDownloads(std::list<RsFileHash> &hashs)
|
||||
{
|
||||
return mFtController->FileDownloads(hashs);
|
||||
/* this only contains downloads.... not completed */
|
||||
//return mFtDataplex->FileDownloads(hashs);
|
||||
}
|
||||
|
||||
bool ftServer::FileUploadChunksDetails(const std::string& hash,const RsPeerId& peer_id,CompressedChunkMap& cmap)
|
||||
bool ftServer::FileUploadChunksDetails(const RsFileHash& hash,const RsPeerId& peer_id,CompressedChunkMap& cmap)
|
||||
{
|
||||
return mFtDataplex->getClientChunkMap(hash,peer_id,cmap);
|
||||
}
|
||||
|
||||
bool ftServer::FileUploads(std::list<std::string> &hashs)
|
||||
bool ftServer::FileUploads(std::list<RsFileHash> &hashs)
|
||||
{
|
||||
return mFtDataplex->FileUploads(hashs);
|
||||
}
|
||||
|
||||
bool ftServer::FileDetails(const std::string &hash, FileSearchFlags hintflags, FileInfo &info)
|
||||
bool ftServer::FileDetails(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info)
|
||||
{
|
||||
if (hintflags & RS_FILE_HINTS_DOWNLOAD)
|
||||
if(mFtController->FileDetails(hash, info))
|
||||
|
@ -483,7 +468,7 @@ void ftServer::removeVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualP
|
|||
mFtController->removeFileSource(hash,virtual_peer_id) ;
|
||||
}
|
||||
|
||||
bool ftServer::handleTunnelRequest(const std::string& hash,const RsPeerId& peer_id)
|
||||
bool ftServer::handleTunnelRequest(const RsFileHash& hash,const RsPeerId& peer_id)
|
||||
{
|
||||
FileInfo info ;
|
||||
bool res = FileDetails(hash, RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_SPEC_ONLY | RS_FILE_HINTS_DOWNLOAD, info);
|
||||
|
@ -515,13 +500,13 @@ bool ftServer::handleTunnelRequest(const std::string& hash,const RsPeerId& peer_
|
|||
/******************* ExtraFileList Access **********************/
|
||||
/***************************************************************/
|
||||
|
||||
bool ftServer::ExtraFileAdd(std::string fname, std::string hash, uint64_t size,
|
||||
bool ftServer::ExtraFileAdd(std::string fname, const RsFileHash& hash, uint64_t size,
|
||||
uint32_t period, TransferRequestFlags flags)
|
||||
{
|
||||
return mFtExtra->addExtraFile(fname, hash, size, period, flags);
|
||||
}
|
||||
|
||||
bool ftServer::ExtraFileRemove(std::string hash, TransferRequestFlags flags)
|
||||
bool ftServer::ExtraFileRemove(const RsFileHash& hash, TransferRequestFlags flags)
|
||||
{
|
||||
return mFtExtra->removeExtraFile(hash, flags);
|
||||
}
|
||||
|
@ -536,7 +521,7 @@ bool ftServer::ExtraFileStatus(std::string localpath, FileInfo &info)
|
|||
return mFtExtra->hashExtraFileDone(localpath, info);
|
||||
}
|
||||
|
||||
bool ftServer::ExtraFileMove(std::string fname, std::string hash, uint64_t size,
|
||||
bool ftServer::ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size,
|
||||
std::string destpath)
|
||||
{
|
||||
return mFtExtra->moveExtraFile(fname, hash, size, destpath);
|
||||
|
@ -872,7 +857,7 @@ bool ftServer::loadConfigMap(std::map<std::string, std::string> &/*configMap*/)
|
|||
/***************************************************************/
|
||||
|
||||
/* Client Send */
|
||||
bool ftServer::sendDataRequest(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize)
|
||||
bool ftServer::sendDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize)
|
||||
{
|
||||
#ifdef SERVER_DEBUG
|
||||
std::cerr << "ftServer::sendDataRequest() to peer " << peerId << " for hash " << hash << ", offset=" << offset << ", chunk size="<< chunksize << std::endl;
|
||||
|
@ -910,7 +895,7 @@ bool ftServer::sendDataRequest(const RsPeerId& peerId, const std::string& hash,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ftServer::sendChunkMapRequest(const RsPeerId& peerId,const std::string& hash,bool is_client)
|
||||
bool ftServer::sendChunkMapRequest(const RsPeerId& peerId,const RsFileHash& hash,bool is_client)
|
||||
{
|
||||
#ifdef SERVER_DEBUG
|
||||
std::cerr << "ftServer::sendChunkMapRequest() to peer " << peerId << " for hash " << hash << std::endl;
|
||||
|
@ -939,7 +924,7 @@ bool ftServer::sendChunkMapRequest(const RsPeerId& peerId,const std::string& has
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftServer::sendChunkMap(const RsPeerId& peerId,const std::string& hash,const CompressedChunkMap& map,bool is_client)
|
||||
bool ftServer::sendChunkMap(const RsPeerId& peerId,const RsFileHash& hash,const CompressedChunkMap& map,bool is_client)
|
||||
{
|
||||
#ifdef SERVER_DEBUG
|
||||
std::cerr << "ftServer::sendChunkMap() to peer " << peerId << " for hash " << hash << std::endl;
|
||||
|
@ -970,7 +955,7 @@ bool ftServer::sendChunkMap(const RsPeerId& peerId,const std::string& hash,const
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftServer::sendSingleChunkCRCRequest(const RsPeerId& peerId,const std::string& hash,uint32_t chunk_number)
|
||||
bool ftServer::sendSingleChunkCRCRequest(const RsPeerId& peerId,const RsFileHash& hash,uint32_t chunk_number)
|
||||
{
|
||||
#ifdef SERVER_DEBUG
|
||||
std::cerr << "ftServer::sendSingleCRCRequest() to peer " << peerId << " for hash " << hash << ", chunk number=" << chunk_number << std::endl;
|
||||
|
@ -1001,7 +986,7 @@ bool ftServer::sendSingleChunkCRCRequest(const RsPeerId& peerId,const std::strin
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool ftServer::sendSingleChunkCRC(const RsPeerId& peerId,const std::string& hash,uint32_t chunk_number,const Sha1CheckSum& crc)
|
||||
bool ftServer::sendSingleChunkCRC(const RsPeerId& peerId,const RsFileHash& hash,uint32_t chunk_number,const Sha1CheckSum& crc)
|
||||
{
|
||||
#ifdef SERVER_DEBUG
|
||||
std::cerr << "ftServer::sendSingleCRC() to peer " << peerId << " for hash " << hash << ", chunk number=" << chunk_number << std::endl;
|
||||
|
@ -1035,7 +1020,7 @@ bool ftServer::sendSingleChunkCRC(const RsPeerId& peerId,const std::string& hash
|
|||
}
|
||||
|
||||
/* Server Send */
|
||||
bool ftServer::sendData(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t baseoffset, uint32_t chunksize, void *data)
|
||||
bool ftServer::sendData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t baseoffset, uint32_t chunksize, void *data)
|
||||
{
|
||||
/* create a packet */
|
||||
/* push to networking part */
|
||||
|
@ -1132,7 +1117,7 @@ bool ftServer::sendData(const RsPeerId& peerId, const std::string& hash, uint64_
|
|||
// Dont delete the item. The client (p3turtle) is doing it after calling this.
|
||||
//
|
||||
void ftServer::receiveTurtleData(RsTurtleGenericTunnelItem *i,
|
||||
const std::string& hash,
|
||||
const RsFileHash& hash,
|
||||
const RsPeerId& virtual_peer_id,
|
||||
RsTurtleGenericTunnelItem::Direction direction)
|
||||
{
|
||||
|
|
|
@ -102,12 +102,12 @@ class ftServer: public p3Service, public RsFiles, public ftDataSend, public RsTu
|
|||
|
||||
// Checks that the given hash is well formed. Used to chase
|
||||
// string bugs.
|
||||
static bool checkHash(const std::string& hash,std::string& error_string) ;
|
||||
static bool checkHash(const RsFileHash& hash,std::string& error_string) ;
|
||||
|
||||
// Implements RsTurtleClientService
|
||||
//
|
||||
virtual bool handleTunnelRequest(const std::string& hash,const RsPeerId& peer_id) ;
|
||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const std::string& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||
virtual bool handleTunnelRequest(const RsFileHash& hash,const RsPeerId& peer_id) ;
|
||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||
virtual RsTurtleGenericTunnelItem *deserialiseItem(void *data,uint32_t size) const ;
|
||||
|
||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||
|
@ -129,14 +129,14 @@ class ftServer: public p3Service, public RsFiles, public ftDataSend, public RsTu
|
|||
/***
|
||||
* Control of Downloads
|
||||
***/
|
||||
virtual bool alreadyHaveFile(const std::string& hash, FileInfo &info);
|
||||
virtual bool FileRequest(const std::string& fname, const std::string& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<RsPeerId>& srcIds);
|
||||
virtual bool FileCancel(const std::string& hash);
|
||||
virtual bool FileControl(const std::string& hash, uint32_t flags);
|
||||
virtual bool alreadyHaveFile(const RsFileHash& hash, FileInfo &info);
|
||||
virtual bool FileRequest(const std::string& fname, const RsFileHash& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<RsPeerId>& srcIds);
|
||||
virtual bool FileCancel(const RsFileHash& hash);
|
||||
virtual bool FileControl(const RsFileHash& hash, uint32_t flags);
|
||||
virtual bool FileClearCompleted();
|
||||
virtual bool setDestinationDirectory(const std::string& hash,const std::string& new_path) ;
|
||||
virtual bool setDestinationName(const std::string& hash,const std::string& new_name) ;
|
||||
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s) ;
|
||||
virtual bool setDestinationDirectory(const RsFileHash& hash,const std::string& new_path) ;
|
||||
virtual bool setDestinationName(const RsFileHash& hash,const std::string& new_name) ;
|
||||
virtual bool setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy s) ;
|
||||
virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) ;
|
||||
virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() ;
|
||||
virtual uint32_t freeDiskSpaceLimit() const ;
|
||||
|
@ -150,30 +150,30 @@ class ftServer: public p3Service, public RsFiles, public ftDataSend, public RsTu
|
|||
virtual void setMinPrioritizedTransfers(uint32_t s) ;
|
||||
virtual uint32_t getQueueSize() ;
|
||||
virtual void setQueueSize(uint32_t s) ;
|
||||
virtual bool changeQueuePosition(const std::string hash, QueueMove queue_mv);
|
||||
virtual bool changeDownloadSpeed(const std::string hash, int speed);
|
||||
virtual bool getDownloadSpeed(const std::string hash, int & speed);
|
||||
virtual bool clearDownload(const std::string hash);
|
||||
virtual bool changeQueuePosition(const RsFileHash& hash, QueueMove queue_mv);
|
||||
virtual bool changeDownloadSpeed(const RsFileHash& hash, int speed);
|
||||
virtual bool getDownloadSpeed(const RsFileHash& hash, int & speed);
|
||||
virtual bool clearDownload(const RsFileHash& hash);
|
||||
//virtual void getDwlDetails(std::list<DwlDetails> & details);
|
||||
|
||||
/***
|
||||
* Download/Upload Details
|
||||
***/
|
||||
virtual bool FileDownloads(std::list<std::string> &hashs);
|
||||
virtual bool FileUploads(std::list<std::string> &hashs);
|
||||
virtual bool FileDetails(const std::string &hash, FileSearchFlags hintflags, FileInfo &info);
|
||||
virtual bool FileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info) ;
|
||||
virtual bool FileUploadChunksDetails(const std::string& hash,const RsPeerId& peer_id,CompressedChunkMap& map) ;
|
||||
virtual bool FileDownloads(std::list<RsFileHash> &hashs);
|
||||
virtual bool FileUploads(std::list<RsFileHash> &hashs);
|
||||
virtual bool FileDetails(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info);
|
||||
virtual bool FileDownloadChunksDetails(const RsFileHash& hash,FileChunksInfo& info) ;
|
||||
virtual bool FileUploadChunksDetails(const RsFileHash& hash,const RsPeerId& peer_id,CompressedChunkMap& map) ;
|
||||
|
||||
|
||||
/***
|
||||
* Extra List Access
|
||||
***/
|
||||
virtual bool ExtraFileAdd(std::string fname, std::string hash, uint64_t size, uint32_t period, TransferRequestFlags flags);
|
||||
virtual bool ExtraFileRemove(std::string hash, TransferRequestFlags flags);
|
||||
virtual bool ExtraFileAdd(std::string fname, const RsFileHash& hash, uint64_t size, uint32_t period, TransferRequestFlags flags);
|
||||
virtual bool ExtraFileRemove(const RsFileHash& hash, TransferRequestFlags flags);
|
||||
virtual bool ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags);
|
||||
virtual bool ExtraFileStatus(std::string localpath, FileInfo &info);
|
||||
virtual bool ExtraFileMove(std::string fname, std::string hash, uint64_t size, std::string destpath);
|
||||
virtual bool ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath);
|
||||
|
||||
|
||||
/***
|
||||
|
@ -230,12 +230,12 @@ class ftServer: public p3Service, public RsFiles, public ftDataSend, public RsTu
|
|||
/*************** Data Transfer Interface ***********************/
|
||||
/***************************************************************/
|
||||
public:
|
||||
virtual bool sendData(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
virtual bool sendDataRequest(const RsPeerId& peerId, const std::string& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
virtual bool sendChunkMapRequest(const RsPeerId& peer_id,const std::string& hash,bool is_client) ;
|
||||
virtual bool sendChunkMap(const RsPeerId& peer_id,const std::string& hash,const CompressedChunkMap& cmap,bool is_client) ;
|
||||
virtual bool sendSingleChunkCRCRequest(const RsPeerId& peer_id,const std::string& hash,uint32_t chunk_number) ;
|
||||
virtual bool sendSingleChunkCRC(const RsPeerId& peer_id,const std::string& hash,uint32_t chunk_number,const Sha1CheckSum& crc) ;
|
||||
virtual bool sendData(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
|
||||
virtual bool sendDataRequest(const RsPeerId& peerId, const RsFileHash& hash, uint64_t size, uint64_t offset, uint32_t chunksize);
|
||||
virtual bool sendChunkMapRequest(const RsPeerId& peer_id,const RsFileHash& hash,bool is_client) ;
|
||||
virtual bool sendChunkMap(const RsPeerId& peer_id,const RsFileHash& hash,const CompressedChunkMap& cmap,bool is_client) ;
|
||||
virtual bool sendSingleChunkCRCRequest(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_number) ;
|
||||
virtual bool sendSingleChunkCRC(const RsPeerId& peer_id,const RsFileHash& hash,uint32_t chunk_number,const Sha1CheckSum& crc) ;
|
||||
|
||||
/*************** Internal Transfer Fns *************************/
|
||||
virtual int tick();
|
||||
|
|
|
@ -553,14 +553,14 @@ class HashThread: public RsThread
|
|||
#ifdef FT_DEBUG
|
||||
std::cerr << "hash thread is running for file " << std::endl;
|
||||
#endif
|
||||
std::string tmphash ;
|
||||
RsFileHash tmphash ;
|
||||
_m->hashReceivedData(tmphash) ;
|
||||
|
||||
RsStackMutex stack(_hashThreadMtx) ;
|
||||
_hash = tmphash ;
|
||||
_finished = true ;
|
||||
}
|
||||
std::string hash()
|
||||
RsFileHash hash()
|
||||
{
|
||||
RsStackMutex stack(_hashThreadMtx) ;
|
||||
return _hash ;
|
||||
|
@ -574,7 +574,7 @@ class HashThread: public RsThread
|
|||
RsMutex _hashThreadMtx ;
|
||||
ftFileCreator *_m ;
|
||||
bool _finished ;
|
||||
std::string _hash ;
|
||||
RsFileHash _hash ;
|
||||
};
|
||||
|
||||
bool ftTransferModule::checkFile()
|
||||
|
@ -607,7 +607,7 @@ bool ftTransferModule::checkFile()
|
|||
return false ;
|
||||
}
|
||||
|
||||
std::string check_hash( _hash_thread->hash() ) ;
|
||||
RsFileHash check_hash( _hash_thread->hash() ) ;
|
||||
|
||||
_hash_thread->join(); // allow releasing of resources when finished.
|
||||
|
||||
|
|
|
@ -111,9 +111,9 @@ public:
|
|||
};
|
||||
|
||||
ftFileStatus():hash(""),stat(PQIFILE_INIT) {}
|
||||
ftFileStatus(std::string hash_in):hash(hash_in),stat(PQIFILE_INIT) {}
|
||||
ftFileStatus(const RsFileHash& hash_in):hash(hash_in),stat(PQIFILE_INIT) {}
|
||||
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
Status stat;
|
||||
};
|
||||
|
||||
|
@ -147,8 +147,8 @@ public:
|
|||
|
||||
int tick();
|
||||
|
||||
std::string hash() { return mHash; }
|
||||
uint64_t size() { return mSize; }
|
||||
const RsFileHash& hash() const { return mHash; }
|
||||
uint64_t size() const { return mSize; }
|
||||
|
||||
//internal used functions
|
||||
bool queryInactive();
|
||||
|
@ -175,7 +175,7 @@ private:
|
|||
ftDataMultiplex *mMultiplexor;
|
||||
ftController *mFtController;
|
||||
|
||||
std::string mHash;
|
||||
RsFileHash mHash;
|
||||
uint64_t mSize;
|
||||
|
||||
RsMutex tfMtx; /* below is mutex protected */
|
||||
|
|
|
@ -40,7 +40,7 @@ p3LinkMgr *RsPluginManager::_linkmgr = NULL ;
|
|||
typedef RsPlugin *(*RetroSharePluginEntry)(void) ;
|
||||
RsPluginHandler *rsPlugins ;
|
||||
|
||||
RsPluginManager::RsPluginManager(const std::string& hash)
|
||||
RsPluginManager::RsPluginManager(const RsFileHash &hash)
|
||||
: p3Config(CONFIG_TYPE_PLUGINS),_current_executable_hash(hash)
|
||||
{
|
||||
_allow_all_plugins = false ;
|
||||
|
@ -48,7 +48,7 @@ RsPluginManager::RsPluginManager(const std::string& hash)
|
|||
|
||||
void RsPluginManager::loadConfiguration()
|
||||
{
|
||||
std::string dummyHash = "dummyHash";
|
||||
RsFileHash dummyHash ;
|
||||
p3Config::loadConfiguration(dummyHash);
|
||||
}
|
||||
|
||||
|
@ -81,9 +81,9 @@ bool RsPluginManager::acceptablePluginName(const std::string& name)
|
|||
#endif
|
||||
}
|
||||
|
||||
void RsPluginManager::disablePlugin(const std::string& hash)
|
||||
void RsPluginManager::disablePlugin(const RsFileHash& hash)
|
||||
{
|
||||
std::set<std::string>::iterator it = _accepted_hashes.find(hash) ;
|
||||
std::set<RsFileHash>::iterator it = _accepted_hashes.find(hash) ;
|
||||
|
||||
if(it != _accepted_hashes.end())
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ void RsPluginManager::disablePlugin(const std::string& hash)
|
|||
}
|
||||
}
|
||||
|
||||
void RsPluginManager::enablePlugin(const std::string& hash)
|
||||
void RsPluginManager::enablePlugin(const RsFileHash& hash)
|
||||
{
|
||||
if(_accepted_hashes.find(hash) == _accepted_hashes.end())
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ void RsPluginManager::enablePlugin(const std::string& hash)
|
|||
_accepted_hashes.insert(hash) ;
|
||||
IndicateConfigChanged() ;
|
||||
}
|
||||
std::set<std::string>::const_iterator it(_rejected_hashes.find(hash)) ;
|
||||
std::set<RsFileHash>::const_iterator it(_rejected_hashes.find(hash)) ;
|
||||
|
||||
if(it != _rejected_hashes.end())
|
||||
{
|
||||
|
@ -183,7 +183,7 @@ void RsPluginManager::stopPlugins()
|
|||
}
|
||||
}
|
||||
|
||||
void RsPluginManager::getPluginStatus(int i,uint32_t& status,std::string& file_name,std::string& hash,uint32_t& svn_revision,std::string& error_string) const
|
||||
void RsPluginManager::getPluginStatus(int i,uint32_t& status,std::string& file_name,RsFileHash &hash,uint32_t& svn_revision,std::string& error_string) const
|
||||
{
|
||||
if((uint32_t)i >= _plugins.size())
|
||||
return ;
|
||||
|
@ -267,7 +267,7 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name)
|
|||
if(!_allow_all_plugins)
|
||||
{
|
||||
if(_accepted_hashes.find(pinfo.file_hash) == _accepted_hashes.end() && _rejected_hashes.find(pinfo.file_hash) == _rejected_hashes.end() )
|
||||
if(!RsServer::notify()->askForPluginConfirmation(pinfo.file_name,pinfo.file_hash))
|
||||
if(!RsServer::notify()->askForPluginConfirmation(pinfo.file_name,pinfo.file_hash.toStdString()))
|
||||
_rejected_hashes.insert(pinfo.file_hash) ; // accepted hashes are treated at the end, for security.
|
||||
|
||||
if(_rejected_hashes.find(pinfo.file_hash) != _rejected_hashes.end() )
|
||||
|
@ -435,11 +435,11 @@ void RsPluginManager::addConfigurations(p3ConfigMgr *ConfigMgr)
|
|||
|
||||
bool RsPluginManager::loadList(std::list<RsItem*>& list)
|
||||
{
|
||||
std::set<std::string> accepted_hash_candidates ;
|
||||
std::set<std::string> rejected_hash_candidates ;
|
||||
std::set<RsFileHash> accepted_hash_candidates ;
|
||||
std::set<RsFileHash> rejected_hash_candidates ;
|
||||
|
||||
std::cerr << "RsPluginManager::loadList(): " << std::endl;
|
||||
std::string reference_executable_hash = "" ;
|
||||
RsFileHash reference_executable_hash ;
|
||||
|
||||
std::list<RsItem *>::iterator it;
|
||||
for(it = list.begin(); it != list.end(); it++)
|
||||
|
@ -463,12 +463,12 @@ bool RsPluginManager::loadList(std::list<RsItem*>& list)
|
|||
}
|
||||
else if((*kit).key == "ACCEPTED")
|
||||
{
|
||||
accepted_hash_candidates.insert((*kit).value) ;
|
||||
accepted_hash_candidates.insert(RsFileHash((*kit).value)) ;
|
||||
std::cerr << " Accepted hash: " << (*kit).value << std::endl;
|
||||
}
|
||||
else if((*kit).key == "REJECTED")
|
||||
{
|
||||
rejected_hash_candidates.insert((*kit).value) ;
|
||||
rejected_hash_candidates.insert(RsFileHash((*kit).value)) ;
|
||||
std::cerr << " Rejected hash: " << (*kit).value << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -501,22 +501,22 @@ bool RsPluginManager::saveList(bool& cleanup, std::list<RsItem*>& list)
|
|||
witem->tlvkvs.pairs.push_back(kv) ;
|
||||
|
||||
kv.key = "REFERENCE_EXECUTABLE_HASH" ;
|
||||
kv.value = _current_executable_hash ;
|
||||
kv.value = _current_executable_hash.toStdString() ;
|
||||
witem->tlvkvs.pairs.push_back(kv) ;
|
||||
|
||||
std::cerr << " Saving current executable hash: " << kv.value << std::endl;
|
||||
|
||||
// now push accepted and rejected hashes.
|
||||
|
||||
for(std::set<std::string>::const_iterator it(_accepted_hashes.begin());it!=_accepted_hashes.end();++it)
|
||||
for(std::set<RsFileHash>::const_iterator it(_accepted_hashes.begin());it!=_accepted_hashes.end();++it)
|
||||
{
|
||||
witem->tlvkvs.pairs.push_back( RsTlvKeyValue( "ACCEPTED", *it ) ) ;
|
||||
witem->tlvkvs.pairs.push_back( RsTlvKeyValue( "ACCEPTED", (*it).toStdString() ) ) ;
|
||||
std::cerr << " " << *it << " : " << "ACCEPTED" << std::endl;
|
||||
}
|
||||
|
||||
for(std::set<std::string>::const_iterator it(_rejected_hashes.begin());it!=_rejected_hashes.end();++it)
|
||||
for(std::set<RsFileHash>::const_iterator it(_rejected_hashes.begin());it!=_rejected_hashes.end();++it)
|
||||
{
|
||||
witem->tlvkvs.pairs.push_back( RsTlvKeyValue( "REJECTED", *it ) ) ;
|
||||
witem->tlvkvs.pairs.push_back( RsTlvKeyValue( "REJECTED", (*it).toStdString() ) ) ;
|
||||
std::cerr << " " << *it << " : " << "REJECTED" << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class PluginInfo
|
|||
|
||||
// Information related to the file. Do not require the plugin to be loaded nor the DSO to be openned.
|
||||
//
|
||||
std::string file_hash ;
|
||||
RsFileHash file_hash ;
|
||||
std::string file_name ;
|
||||
|
||||
// Information coming from directly loaded symbols. The plugin is responsible for providing them.
|
||||
|
@ -38,7 +38,7 @@ class PluginInfo
|
|||
class RsPluginManager: public RsPluginHandler, public p3Config
|
||||
{
|
||||
public:
|
||||
RsPluginManager(const std::string& current_executable_sha1_hash) ;
|
||||
RsPluginManager(const RsFileHash& current_executable_sha1_hash) ;
|
||||
virtual ~RsPluginManager() {}
|
||||
|
||||
// ------------ Derived from RsPluginHandler ----------------//
|
||||
|
@ -46,9 +46,9 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
|||
virtual int nbPlugins() const { return _plugins.size() ; }
|
||||
virtual RsPlugin *plugin(int i) { return _plugins[i].plugin ; }
|
||||
virtual const std::vector<std::string>& getPluginDirectories() const { return _plugin_directories ; }
|
||||
virtual void getPluginStatus(int i, uint32_t& status,std::string& file_name, std::string& hash,uint32_t& svn_revision,std::string& error_string) const ;
|
||||
virtual void enablePlugin(const std::string& hash) ;
|
||||
virtual void disablePlugin(const std::string& hash) ;
|
||||
virtual void getPluginStatus(int i, uint32_t& status,std::string& file_name, RsFileHash& hash,uint32_t& svn_revision,std::string& error_string) const ;
|
||||
virtual void enablePlugin(const RsFileHash& hash) ;
|
||||
virtual void disablePlugin(const RsFileHash &hash) ;
|
||||
|
||||
virtual void slowTickPlugins(time_t sec) ;
|
||||
virtual const std::string& getLocalCacheDir() const ;
|
||||
|
@ -101,7 +101,7 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
|||
private:
|
||||
bool loadPlugin(RsPlugin *) ;
|
||||
bool loadPlugin(const std::string& shared_library_name) ;
|
||||
std::string hashPlugin(const std::string& shared_library_name) ;
|
||||
RsFileHash hashPlugin(const std::string& shared_library_name) ;
|
||||
|
||||
std::vector<PluginInfo> _plugins ;
|
||||
|
||||
|
@ -114,9 +114,9 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
|||
// - if different => flush all plugin hashes from cache
|
||||
// - if equal,
|
||||
//
|
||||
std::set<std::string> _accepted_hashes ; // accepted hash values for reference executable hash.
|
||||
std::set<std::string> _rejected_hashes ; // rejected hash values for reference executable hash.
|
||||
std::string _current_executable_hash ; // At all times, the list of accepted plugins should be related to the current hash of the executable.
|
||||
std::set<RsFileHash> _accepted_hashes ; // accepted hash values for reference executable hash.
|
||||
std::set<RsFileHash> _rejected_hashes ; // rejected hash values for reference executable hash.
|
||||
RsFileHash _current_executable_hash ; // At all times, the list of accepted plugins should be related to the current hash of the executable.
|
||||
bool _allow_all_plugins ;
|
||||
|
||||
static std::string _plugin_entry_symbol ;
|
||||
|
|
|
@ -132,7 +132,7 @@ void p3ConfigMgr::loadConfiguration()
|
|||
void p3ConfigMgr::loadConfig()
|
||||
{
|
||||
std::map<uint32_t, pqiConfig *>::iterator cit;
|
||||
std::string dummyHash = "dummyHash";
|
||||
RsFileHash dummyHash ;
|
||||
for (cit = configs.begin(); cit != configs.end(); cit++)
|
||||
{
|
||||
#ifdef CONFIG_DEBUG
|
||||
|
@ -194,7 +194,7 @@ p3Config::p3Config(uint32_t t)
|
|||
}
|
||||
|
||||
|
||||
bool p3Config::loadConfiguration(std::string &loadHash)
|
||||
bool p3Config::loadConfiguration(RsFileHash &loadHash)
|
||||
{
|
||||
return loadConfig();
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ virtual ~pqiConfig();
|
|||
* @param loadHash This is the hash that will be compared to confirm saved configuration has not
|
||||
* been tampered with
|
||||
*/
|
||||
virtual bool loadConfiguration(std::string &loadHash) = 0;
|
||||
virtual bool loadConfiguration(RsFileHash &loadHash) = 0;
|
||||
|
||||
/**
|
||||
* save configuration of object
|
||||
|
@ -266,7 +266,7 @@ class p3Config: public pqiConfig
|
|||
|
||||
p3Config(uint32_t t);
|
||||
|
||||
virtual bool loadConfiguration(std::string &loadHash);
|
||||
virtual bool loadConfiguration(RsFileHash &loadHash);
|
||||
virtual bool saveConfiguration();
|
||||
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ class StringExpression: public Expression
|
|||
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
protected:
|
||||
bool evalStr(std::string &str);
|
||||
bool evalStr(const std::string &str);
|
||||
|
||||
enum StringOperator Op;
|
||||
std::list<std::string> terms;
|
||||
|
|
|
@ -117,18 +117,18 @@ class RsFiles
|
|||
* Control of Downloads.
|
||||
***/
|
||||
|
||||
virtual bool alreadyHaveFile(const std::string& hash, FileInfo &info) = 0;
|
||||
virtual bool alreadyHaveFile(const RsFileHash& hash, FileInfo &info) = 0;
|
||||
/// Returns false is we already have the file. Otherwise, initiates the dl and returns true.
|
||||
virtual bool FileRequest(const std::string& fname, const std::string& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<SSLIdType>& srcIds) = 0;
|
||||
virtual bool FileCancel(const std::string& hash) = 0;
|
||||
virtual bool setDestinationDirectory(const std::string& hash,const std::string& new_path) = 0;
|
||||
virtual bool setDestinationName(const std::string& hash,const std::string& new_name) = 0;
|
||||
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy) = 0;
|
||||
virtual bool FileRequest(const std::string& fname, const RsFileHash& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<RsPeerId>& srcIds) = 0;
|
||||
virtual bool FileCancel(const RsFileHash& hash) = 0;
|
||||
virtual bool setDestinationDirectory(const RsFileHash& hash,const std::string& new_path) = 0;
|
||||
virtual bool setDestinationName(const RsFileHash& hash,const std::string& new_name) = 0;
|
||||
virtual bool setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy) = 0;
|
||||
virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) = 0;
|
||||
virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() = 0;
|
||||
virtual uint32_t freeDiskSpaceLimit() const =0;
|
||||
virtual void setFreeDiskSpaceLimit(uint32_t size_in_mb) =0;
|
||||
virtual bool FileControl(const std::string& hash, uint32_t flags) = 0;
|
||||
virtual bool FileControl(const RsFileHash& hash, uint32_t flags) = 0;
|
||||
virtual bool FileClearCompleted() = 0;
|
||||
|
||||
/***
|
||||
|
@ -138,48 +138,47 @@ class RsFiles
|
|||
virtual void setMinPrioritizedTransfers(uint32_t s) = 0 ;
|
||||
virtual uint32_t getQueueSize() = 0 ;
|
||||
virtual void setQueueSize(uint32_t s) = 0 ;
|
||||
virtual bool changeQueuePosition(const std::string hash, QueueMove mv) = 0;
|
||||
virtual bool changeDownloadSpeed(const std::string hash, int speed) = 0;
|
||||
virtual bool getDownloadSpeed(const std::string hash, int & speed) = 0;
|
||||
virtual bool clearDownload(const std::string hash) = 0;
|
||||
virtual bool changeQueuePosition(const RsFileHash& hash, QueueMove mv) = 0;
|
||||
virtual bool changeDownloadSpeed(const RsFileHash& hash, int speed) = 0;
|
||||
virtual bool getDownloadSpeed(const RsFileHash& hash, int & speed) = 0;
|
||||
virtual bool clearDownload(const RsFileHash& hash) = 0;
|
||||
// virtual void getDwlDetails(std::list<DwlDetails> & details) = 0;
|
||||
|
||||
/***
|
||||
* Download / Upload Details.
|
||||
***/
|
||||
virtual bool FileDownloads(std::list<std::string> &hashs) = 0;
|
||||
virtual bool FileUploads(std::list<std::string> &hashs) = 0;
|
||||
virtual bool FileDetails(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) = 0;
|
||||
virtual bool FileDownloads(std::list<RsFileHash> &hashs) = 0;
|
||||
virtual bool FileUploads(std::list<RsFileHash> &hashs) = 0;
|
||||
virtual bool FileDetails(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) = 0;
|
||||
|
||||
/// Gives chunk details about the downloaded file with given hash.
|
||||
virtual bool FileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info) = 0 ;
|
||||
virtual bool FileDownloadChunksDetails(const RsFileHash& hash,FileChunksInfo& info) = 0 ;
|
||||
|
||||
/// details about the upload with given hash
|
||||
virtual bool FileUploadChunksDetails(const std::string& hash,const SSLIdType& peer_id,CompressedChunkMap& map) = 0 ;
|
||||
virtual bool FileUploadChunksDetails(const RsFileHash& hash,const RsPeerId& peer_id,CompressedChunkMap& map) = 0 ;
|
||||
|
||||
/***
|
||||
* Extra List Access
|
||||
***/
|
||||
//virtual bool ExtraFileAdd(std::string fname, std::string hash, uint64_t size, uint32_t period, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileRemove(std::string hash, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileRemove(const RsFileHash& hash, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileStatus(std::string localpath, FileInfo &info) = 0;
|
||||
virtual bool ExtraFileMove(std::string fname, std::string hash, uint64_t size,
|
||||
std::string destpath) = 0;
|
||||
virtual bool ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath) = 0;
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* Directory Listing / Search Interface
|
||||
*/
|
||||
virtual int RequestDirDetails(const SSLIdType& uid, const std::string& path, DirDetails &details) = 0;
|
||||
virtual int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details) = 0;
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) = 0;
|
||||
virtual uint32_t getType(void *ref,FileSearchFlags flags) = 0;
|
||||
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags) = 0;
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const SSLIdType& peer_id) = 0;
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0;
|
||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags) = 0;
|
||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const SSLIdType& peer_id) = 0;
|
||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0;
|
||||
|
||||
/***
|
||||
* Utility Functions.
|
||||
|
|
|
@ -69,7 +69,7 @@ template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> c
|
|||
{
|
||||
t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> temp = t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>(str);
|
||||
|
||||
for(int i = 0; i < ID_SIZE_IN_BYTES; i++)
|
||||
for(uint32_t i = 0; i < ID_SIZE_IN_BYTES; i++)
|
||||
this->bytes[i] = temp.toByteArray()[i];
|
||||
}
|
||||
|
||||
|
|
|
@ -186,9 +186,9 @@ class RsPluginHandler
|
|||
virtual int nbPlugins() const = 0 ;
|
||||
virtual RsPlugin *plugin(int i) = 0 ;
|
||||
virtual const std::vector<std::string>& getPluginDirectories() const = 0;
|
||||
virtual void getPluginStatus(int i,uint32_t& status,std::string& file_name,std::string& file_hash,uint32_t& svn_revision,std::string& error_string) const = 0 ;
|
||||
virtual void enablePlugin(const std::string& hash) = 0;
|
||||
virtual void disablePlugin(const std::string& hash) = 0;
|
||||
virtual void getPluginStatus(int i,uint32_t& status,std::string& file_name,RsFileHash& file_hash,uint32_t& svn_revision,std::string& error_string) const = 0 ;
|
||||
virtual void enablePlugin(const RsFileHash& hash) = 0;
|
||||
virtual void disablePlugin(const RsFileHash& hash) = 0;
|
||||
|
||||
virtual void allowAllPlugins(bool b) = 0 ;
|
||||
virtual bool getAllowAllPlugins() const = 0 ;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "retroshare/rsids.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
|
||||
class LinearizedExpression ;
|
||||
class RsTurtleClientService ;
|
||||
|
@ -48,7 +48,7 @@ typedef uint32_t TurtleRequestId ;
|
|||
|
||||
struct TurtleFileInfo
|
||||
{
|
||||
std::string hash ;
|
||||
RsFileHash hash ;
|
||||
std::string name ;
|
||||
uint64_t size ;
|
||||
};
|
||||
|
@ -110,12 +110,12 @@ class RsTurtle
|
|||
// tunnels for the given hash. The download should be driven by the file
|
||||
// transfer module by calling ftServer::FileRequest().
|
||||
//
|
||||
virtual void monitorTunnels(const std::string& file_hash,RsTurtleClientService *client_service) = 0 ;
|
||||
virtual void monitorTunnels(const RsFileHash& file_hash,RsTurtleClientService *client_service) = 0 ;
|
||||
|
||||
// Tells the turtle router to stop handling tunnels for the given file hash. Traditionally this should
|
||||
// be called after calling ftServer::fileCancel().
|
||||
//
|
||||
virtual void stopMonitoringTunnels(const std::string& file_hash) = 0 ;
|
||||
virtual void stopMonitoringTunnels(const RsFileHash& file_hash) = 0 ;
|
||||
|
||||
/// Adds a client tunnel service. This means that the service will be added
|
||||
/// to the list of services that might respond to tunnel requests.
|
||||
|
|
|
@ -90,7 +90,7 @@ class TransferInfo
|
|||
{
|
||||
public:
|
||||
/**** Need Some of these Fields ****/
|
||||
SSLIdType peerId;
|
||||
RsPeerId peerId;
|
||||
std::string name; /* if has alternative name? */
|
||||
double tfRate; /* kbytes */
|
||||
int status; /* FT_STATE_... */
|
||||
|
@ -200,7 +200,7 @@ class FileInfo
|
|||
int searchId; /* 0 if none */
|
||||
std::string path;
|
||||
std::string fname;
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
std::string ext;
|
||||
|
||||
uint64_t size;
|
||||
|
@ -241,9 +241,9 @@ class DirDetails
|
|||
|
||||
void *ref;
|
||||
uint8_t type;
|
||||
SSLIdType id;
|
||||
RsPeerId id;
|
||||
std::string name;
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
std::string path;
|
||||
uint64_t count;
|
||||
uint32_t age;
|
||||
|
@ -257,9 +257,9 @@ class DirDetails
|
|||
class FileDetail
|
||||
{
|
||||
public:
|
||||
SSLIdType id;
|
||||
RsPeerId id;
|
||||
std::string name;
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
std::string path;
|
||||
uint64_t size;
|
||||
uint32_t age;
|
||||
|
@ -386,14 +386,14 @@ typedef t_CRCMap<Sha1CheckSum> Sha1Map ;
|
|||
class DwlDetails {
|
||||
public:
|
||||
DwlDetails() { return; }
|
||||
DwlDetails(std::string fname, std::string hash, int count, std::string dest,
|
||||
DwlDetails(const std::string& fname, const RsFileHash& hash, int count, std::string dest,
|
||||
uint32_t flags, std::list<std::string> srcIds, uint32_t queue_pos)
|
||||
: fname(fname), hash(hash), count(count), dest(dest), flags(flags),
|
||||
srcIds(srcIds), queue_position(queue_pos), retries(0) { return; }
|
||||
|
||||
/* download details */
|
||||
std::string fname;
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
int count;
|
||||
std::string dest;
|
||||
uint32_t flags;
|
||||
|
|
|
@ -86,7 +86,7 @@ class RsInitConfig
|
|||
{
|
||||
public:
|
||||
|
||||
static std::string main_executable_hash;
|
||||
static RsFileHash main_executable_hash;
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
static bool portable;
|
||||
|
@ -143,7 +143,7 @@ const int p3facestartupzone = 47238;
|
|||
static const std::string configLogFileName = "retro.log";
|
||||
static const int SSLPWD_LEN = 64;
|
||||
|
||||
std::string RsInitConfig::main_executable_hash;
|
||||
RsFileHash RsInitConfig::main_executable_hash;
|
||||
|
||||
rs_lock_handle_t RsInitConfig::lockHandle;
|
||||
|
||||
|
|
|
@ -1530,12 +1530,12 @@ uint32_t RsCacheConfigSerialiser::size(RsItem *i)
|
|||
uint32_t s = 8; // to store calculated size, initiailize with size of header
|
||||
|
||||
|
||||
s += GetTlvStringSize(item->pid);
|
||||
s += item->pid.serial_size();
|
||||
s += 2; /* cachetypeid */
|
||||
s += 2; /* cachesubid */
|
||||
s += GetTlvStringSize(item->path);
|
||||
s += GetTlvStringSize(item->name);
|
||||
s += GetTlvStringSize(item->hash);
|
||||
s += item->hash.serial_size();
|
||||
s += 8; /* size */
|
||||
s += 4; /* recvd */
|
||||
|
||||
|
@ -1567,12 +1567,12 @@ bool RsCacheConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *size)
|
|||
|
||||
/* add the mandatory parts first */
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->pid);
|
||||
ok &= item->pid.serialise(data, tlvsize, offset) ;
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->cachetypeid);
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->cachesubid);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PATH, item->path);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_HASH_SHA1, item->hash);
|
||||
ok &= item->hash.serialise(data, tlvsize, offset) ;
|
||||
ok &= setRawUInt64(data, tlvsize, &offset, item->size);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->recvd);
|
||||
|
||||
|
@ -1620,12 +1620,12 @@ RsItem *RsCacheConfigSerialiser::deserialise(void *data, uint32_t *size)
|
|||
|
||||
/* get mandatory parts first */
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->pid);
|
||||
ok &= item->pid.deserialise(data, rssize, offset) ;
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->cachetypeid));
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->cachesubid));
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PATH, item->path);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_HASH_SHA1, item->hash);
|
||||
ok &= item->hash.deserialise(data, rssize, offset) ;
|
||||
ok &= getRawUInt64(data, rssize, &offset, &(item->size));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->recvd));
|
||||
|
||||
|
|
|
@ -201,13 +201,13 @@ virtual ~RsCacheConfig();
|
|||
virtual void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
std::string pid; /* Mandatory */
|
||||
RsPeerId pid; /* Mandatory */
|
||||
uint16_t cachetypeid; /* Mandatory */
|
||||
uint16_t cachesubid; /* Mandatory */
|
||||
|
||||
std::string path; /* Mandatory */
|
||||
std::string name; /* Mandatory */
|
||||
std::string hash; /* Mandatory */
|
||||
RsFileHash hash; /* Mandatory */
|
||||
uint64_t size; /* Mandatory */
|
||||
|
||||
uint32_t recvd; /* Mandatory */
|
||||
|
@ -254,7 +254,7 @@ class RsFileTransfer: public RsItem
|
|||
RsTlvFileItem file;
|
||||
RsTlvPeerIdSet allPeerIds;
|
||||
|
||||
SSLIdType cPeerId;
|
||||
RsPeerId cPeerId;
|
||||
|
||||
uint16_t state;
|
||||
uint16_t in;
|
||||
|
|
|
@ -176,7 +176,7 @@ uint32_t RsFileTransferChunkMapRequestItem::serial_size()
|
|||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += 1 ; // is_client
|
||||
s += GetTlvStringSize(hash) ; // hash
|
||||
s += hash.serial_size() ; // hash
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ uint32_t RsFileTransferChunkMapItem::serial_size()
|
|||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += 1 ; // is_client
|
||||
s += GetTlvStringSize(hash) ; // hash
|
||||
s += hash.serial_size() ; // hash
|
||||
s += 4 ; // compressed map size
|
||||
s += 4 * compressed_map._map.size() ; // compressed chunk map
|
||||
|
||||
|
@ -193,7 +193,7 @@ uint32_t RsFileTransferChunkMapItem::serial_size()
|
|||
uint32_t RsFileTransferSingleChunkCrcItem::serial_size()
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += GetTlvStringSize(hash) ; // hash
|
||||
s += hash.serial_size() ; // hash
|
||||
s += 4 ; // chunk number
|
||||
s += 20 ; // sha1
|
||||
|
||||
|
@ -202,7 +202,7 @@ uint32_t RsFileTransferSingleChunkCrcItem::serial_size()
|
|||
uint32_t RsFileTransferSingleChunkCrcRequestItem::serial_size()
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += GetTlvStringSize(hash) ; // hash
|
||||
s += hash.serial_size() ; // hash
|
||||
s += 4 ; // chunk number
|
||||
|
||||
return s;
|
||||
|
@ -267,7 +267,7 @@ bool RsFileTransferChunkMapRequestItem::serialise(void *data, uint32_t& pktsize)
|
|||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt8(data, tlvsize, &offset, is_client);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, hash);
|
||||
ok &= hash.serialise(data, tlvsize, offset) ;
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
|
@ -286,7 +286,7 @@ bool RsFileTransferSingleChunkCrcRequestItem::serialise(void *data, uint32_t& pk
|
|||
return false ;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, hash);
|
||||
ok &= hash.serialise(data, tlvsize, offset) ;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, chunk_number) ;
|
||||
|
||||
if (offset != tlvsize)
|
||||
|
@ -306,7 +306,7 @@ bool RsFileTransferSingleChunkCrcItem::serialise(void *data, uint32_t& pktsize)
|
|||
return false ;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, hash);
|
||||
ok &= hash.serialise(data, tlvsize, offset) ;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, chunk_number) ;
|
||||
|
||||
setRawSha1(data,tlvsize,&offset,check_sum) ;
|
||||
|
@ -335,7 +335,7 @@ bool RsFileTransferChunkMapItem::serialise(void *data, uint32_t& pktsize)
|
|||
|
||||
/* add mandatory parts first */
|
||||
ok &= setRawUInt8(data, tlvsize, &offset, is_client);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, hash);
|
||||
ok &= hash.serialise(data, tlvsize, offset) ;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, compressed_map._map.size());
|
||||
|
||||
for(uint32_t i=0;i<compressed_map._map.size();++i)
|
||||
|
@ -517,7 +517,7 @@ RsFileTransferItem *RsFileTransferSerialiser::deserialise_RsFileTransferChunkMap
|
|||
offset += 8;
|
||||
uint8_t tmp ;
|
||||
ok &= getRawUInt8(data, rssize, &offset, &tmp); item->is_client = tmp;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->hash); // file hash
|
||||
ok &= item->hash.deserialise(data, rssize, offset) ; // File hash
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
|
@ -675,7 +675,7 @@ RsFileTransferItem *RsFileTransferSerialiser::deserialise_RsFileTransferChunkMap
|
|||
offset += 8;
|
||||
uint8_t tmp ;
|
||||
ok &= getRawUInt8(data, rssize, &offset, &tmp); item->is_client = tmp;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->hash); // file hash
|
||||
ok &= item->hash.deserialise(data, rssize, offset) ; // File hash
|
||||
uint32_t size =0;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &size);
|
||||
|
||||
|
@ -731,7 +731,7 @@ RsFileTransferItem *RsFileTransferSerialiser::deserialise_RsFileTransferSingleCh
|
|||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->hash); // file hash
|
||||
ok &= item->hash.deserialise(data, rssize, offset) ;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->chunk_number));
|
||||
|
||||
if (offset != rssize)
|
||||
|
@ -777,7 +777,7 @@ RsFileTransferItem *RsFileTransferSerialiser::deserialise_RsFileTransferSingleCh
|
|||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->hash); // file hash
|
||||
ok &= item->hash.deserialise(data, rssize, offset) ;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->chunk_number));
|
||||
getRawSha1(data,rssize,&offset,item->check_sum) ;
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ class RsFileTransferChunkMapRequestItem: public RsFileTransferItem
|
|||
// Private data part.
|
||||
//
|
||||
bool is_client ; // is the request for a client, or a server ?
|
||||
std::string hash ; // hash of the file for which we request the chunk map
|
||||
RsFileHash hash ; // hash of the file for which we request the chunk map
|
||||
};
|
||||
|
||||
class RsFileTransferChunkMapItem: public RsFileTransferItem
|
||||
|
@ -149,7 +149,7 @@ class RsFileTransferChunkMapItem: public RsFileTransferItem
|
|||
// Private data part.
|
||||
//
|
||||
bool is_client ; // is the request for a client, or a server ?
|
||||
std::string hash ; // hash of the file for which we request the chunk map
|
||||
RsFileHash hash ; // hash of the file for which we request the chunk map
|
||||
CompressedChunkMap compressed_map ; // Chunk map of the file.
|
||||
};
|
||||
|
||||
|
@ -169,7 +169,7 @@ class RsFileTransferSingleChunkCrcRequestItem: public RsFileTransferItem
|
|||
|
||||
// Private data part.
|
||||
//
|
||||
std::string hash ; // hash of the file for which we request the crc
|
||||
RsFileHash hash ; // hash of the file for which we request the crc
|
||||
uint32_t chunk_number ; // chunk number
|
||||
};
|
||||
|
||||
|
@ -189,7 +189,7 @@ class RsFileTransferSingleChunkCrcItem: public RsFileTransferItem
|
|||
|
||||
// Private data part.
|
||||
//
|
||||
std::string hash ; // hash of the file for which we request the chunk map
|
||||
RsFileHash hash ; // hash of the file for which we request the chunk map
|
||||
uint32_t chunk_number ;
|
||||
Sha1CheckSum check_sum ; // CRC32 map of the file.
|
||||
};
|
||||
|
|
|
@ -430,7 +430,7 @@ uint32_t RsPrivateChatMsgConfigItem::serial_size()
|
|||
uint32_t RsPrivateChatDistantInviteConfigItem::serial_size()
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += GetTlvStringSize(hash);
|
||||
s += hash.serial_size();
|
||||
s += GetTlvStringSize(encrypted_radix64_string);
|
||||
s += destination_pgp_id.serial_size();
|
||||
s += 16; /* aes_key */
|
||||
|
@ -845,7 +845,7 @@ bool RsPrivateChatDistantInviteConfigItem::serialise(void *data, uint32_t& pktsi
|
|||
offset += 8;
|
||||
|
||||
/* add mandatory parts first */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_KEY, hash);
|
||||
ok &= hash.serialise(data, tlvsize, offset) ;
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, encrypted_radix64_string);
|
||||
ok &= destination_pgp_id.serialise(data, tlvsize, offset);
|
||||
|
||||
|
@ -1252,7 +1252,7 @@ RsPrivateChatDistantInviteConfigItem::RsPrivateChatDistantInviteConfigItem(void
|
|||
bool ok = true ;
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_KEY, hash);
|
||||
ok &= hash.deserialise(data, rssize, offset) ;
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, encrypted_radix64_string);
|
||||
ok &= destination_pgp_id.serialise(data, rssize, offset);
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ class RsPrivateChatDistantInviteConfigItem: public RsChatItem
|
|||
virtual uint32_t serial_size() ; // deserialise is handled using a constructor
|
||||
|
||||
unsigned char aes_key[16] ;
|
||||
std::string hash ;
|
||||
RsFileHash hash ;
|
||||
std::string encrypted_radix64_string ;
|
||||
PGPIdType destination_pgp_id ;
|
||||
uint32_t time_of_validity ;
|
||||
|
|
|
@ -56,7 +56,7 @@ uint32_t RsTlvFileItem::TlvSize()
|
|||
{
|
||||
uint32_t s = TLV_HEADER_SIZE; /* header */
|
||||
s += 8; /* filesize */
|
||||
s += GetTlvStringSize(hash);
|
||||
s += hash.serial_size() ;
|
||||
#ifdef TLV_FI_DEBUG
|
||||
std::cerr << "RsTlvFileItem::TlvSize() 8 + Hash: " << s << std::endl;
|
||||
#endif
|
||||
|
@ -163,7 +163,7 @@ bool RsTlvFileItem::SetTlv(void *data, uint32_t size, uint32_t *offset)
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
ok &= SetTlvString(data, tlvend, offset, TLV_TYPE_STR_HASH_SHA1, hash);
|
||||
ok &= hash.serialise(data, tlvend, *offset) ;
|
||||
|
||||
|
||||
#ifdef TLV_FI_DEBUG
|
||||
|
@ -285,7 +285,7 @@ bool RsTlvFileItem::GetTlv(void *data, uint32_t size, uint32_t *offset)
|
|||
|
||||
/* get mandatory parts first */
|
||||
ok &= getRawUInt64(data, tlvend, offset, &filesize);
|
||||
ok &= GetTlvString(data, tlvend, offset, TLV_TYPE_STR_HASH_SHA1, hash);
|
||||
ok &= hash.deserialise(data, tlvend, *offset) ;
|
||||
|
||||
/* while there is more TLV (optional part) */
|
||||
while((*offset) + 2 < tlvend)
|
||||
|
|
|
@ -243,7 +243,7 @@ virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset); /* deseria
|
|||
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
||||
|
||||
uint64_t filesize; /// Mandatory: size of file to be downloaded
|
||||
std::string hash; /// Mandatory: to find file
|
||||
RsFileHash hash; /// Mandatory: to find file
|
||||
std::string name; /// Optional: name of file
|
||||
std::string path; /// Optional: path on host computer
|
||||
uint32_t pop; /// Optional: Popularity of file
|
||||
|
|
|
@ -3072,7 +3072,7 @@ void p3ChatService::cleanLobbyCaches()
|
|||
sendConnectionChallenge(*it) ;
|
||||
}
|
||||
|
||||
bool p3ChatService::handleTunnelRequest(const std::string& hash,const RsPeerId& /*peer_id*/)
|
||||
bool p3ChatService::handleTunnelRequest(const RsFileHash& hash,const RsPeerId& /*peer_id*/)
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -3172,7 +3172,7 @@ void p3ChatService::addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtua
|
|||
|
||||
// Notify the GUI that the tunnel is up.
|
||||
//
|
||||
RsServer::notify()->notifyChatStatus(hash,"tunnel is up again!",true) ;
|
||||
RsServer::notify()->notifyChatStatus(hash.toStdString(),"tunnel is up again!",true) ;
|
||||
}
|
||||
|
||||
void p3ChatService::removeVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id)
|
||||
|
@ -3180,7 +3180,7 @@ void p3ChatService::removeVirtualPeer(const TurtleFileHash& hash,const TurtleVir
|
|||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<std::string,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||
std::map<RsFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||
|
||||
if(it == _distant_chat_peers.end())
|
||||
{
|
||||
|
@ -3190,8 +3190,8 @@ void p3ChatService::removeVirtualPeer(const TurtleFileHash& hash,const TurtleVir
|
|||
|
||||
it->second.status = RS_DISTANT_CHAT_STATUS_TUNNEL_DN ;
|
||||
}
|
||||
RsServer::notify()->notifyChatStatus(hash,"tunnel is down...",true) ;
|
||||
RsServer::notify()->notifyPeerStatusChanged(hash,RS_STATUS_OFFLINE) ;
|
||||
RsServer::notify()->notifyChatStatus(hash.toStdString(),"tunnel is down...",true) ;
|
||||
RsServer::notify()->notifyPeerStatusChanged(hash.toStdString(),RS_STATUS_OFFLINE) ;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DISTANT_CHAT
|
||||
|
@ -3207,7 +3207,7 @@ static void printBinaryData(void *data,uint32_t size)
|
|||
}
|
||||
#endif
|
||||
|
||||
void p3ChatService::receiveTurtleData( RsTurtleGenericTunnelItem *gitem,const std::string& hash,
|
||||
void p3ChatService::receiveTurtleData( RsTurtleGenericTunnelItem *gitem,const RsFileHash& hash,
|
||||
const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction /*direction*/)
|
||||
{
|
||||
#ifdef DEBUG_DISTANT_CHAT
|
||||
|
@ -3238,7 +3238,7 @@ void p3ChatService::receiveTurtleData( RsTurtleGenericTunnelItem *gitem,const st
|
|||
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
std::map<std::string,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||
std::map<RsFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||
|
||||
if(it == _distant_chat_peers.end())
|
||||
{
|
||||
|
@ -3400,7 +3400,7 @@ bool p3ChatService::createDistantChatInvite(const PGPIdType& pgp_id,time_t time_
|
|||
|
||||
// Create a random hash for that invite.
|
||||
//
|
||||
std::string hash = Sha1CheckSum::random().toStdString() ;
|
||||
RsFileHash hash = RsFileHash::random();
|
||||
|
||||
#ifdef DEBUG_DISTANT_CHAT
|
||||
std::cerr << "Created new distant chat invite: " << std::endl;
|
||||
|
@ -3516,7 +3516,7 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
|||
#ifdef DEBUG_DISTANT_CHAT
|
||||
std::cerr << "Signature successfuly verified!" << std::endl;
|
||||
#endif
|
||||
TurtleFileHash hash = Sha1CheckSum(data).toStdString() ;
|
||||
TurtleFileHash hash(data);
|
||||
pid = virtualPeerIdFromHash(hash) ;
|
||||
|
||||
startClientDistantChatConnection(hash,pgp_id,data+DISTANT_CHAT_HASH_SIZE) ;
|
||||
|
@ -3549,7 +3549,7 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
|||
|
||||
error_code = signature_checked ? RS_DISTANT_CHAT_ERROR_NO_ERROR : RS_DISTANT_CHAT_ERROR_UNKNOWN_KEY;
|
||||
|
||||
RsServer::notify()->AddPopupMessage(RS_POPUP_CHAT, hash, "Distant peer", "Conversation starts...");
|
||||
RsServer::notify()->AddPopupMessage(RS_POPUP_CHAT, hash.toStdString(), "Distant peer", "Conversation starts...");
|
||||
|
||||
// Save config, since a new invite was added.
|
||||
//
|
||||
|
@ -3566,7 +3566,7 @@ bool p3ChatService::initiateDistantChatConnexion(const DistantChatPeerId& pid,ui
|
|||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<std::string,DistantChatInvite>::iterator it = _distant_chat_invites.find(hash) ;
|
||||
std::map<RsFileHash,DistantChatInvite>::iterator it = _distant_chat_invites.find(hash) ;
|
||||
|
||||
if(it == _distant_chat_invites.end())
|
||||
{
|
||||
|
@ -3581,13 +3581,13 @@ bool p3ChatService::initiateDistantChatConnexion(const DistantChatPeerId& pid,ui
|
|||
|
||||
startClientDistantChatConnection(hash,pgp_id,aes_key) ;
|
||||
|
||||
RsServer::notify()->AddPopupMessage(RS_POPUP_CHAT, hash, "Distant peer", "Conversation starts...");
|
||||
RsServer::notify()->AddPopupMessage(RS_POPUP_CHAT, hash.toStdString(), "Distant peer", "Conversation starts...");
|
||||
|
||||
error_code = RS_DISTANT_CHAT_ERROR_NO_ERROR ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
void p3ChatService::startClientDistantChatConnection(const std::string& hash,const PGPIdType& pgp_id,const unsigned char *aes_key_buf)
|
||||
void p3ChatService::startClientDistantChatConnection(const RsFileHash& hash,const PGPIdType& pgp_id,const unsigned char *aes_key_buf)
|
||||
{
|
||||
DistantChatPeerInfo info ;
|
||||
|
||||
|
@ -3656,7 +3656,7 @@ TurtleFileHash p3ChatService::hashFromVirtualPeerId(const DistantChatPeerId& pid
|
|||
if(DistantChatPeerId::SIZE_IN_BYTES < Sha1CheckSum::SIZE_IN_BYTES)
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": Serious inconsistency error." << std::endl;
|
||||
|
||||
return Sha1CheckSum(pid.toByteArray()).toStdString() ;
|
||||
return Sha1CheckSum(pid.toByteArray());
|
||||
}
|
||||
bool p3ChatService::getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites)
|
||||
{
|
||||
|
@ -3709,7 +3709,7 @@ bool p3ChatService::closeDistantChatConnexion(const DistantChatPeerId& pid)
|
|||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<std::string,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||
std::map<RsFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||
|
||||
if(it == _distant_chat_peers.end()) // server side. Nothing to do.
|
||||
{
|
||||
|
@ -3735,7 +3735,7 @@ bool p3ChatService::closeDistantChatConnexion(const DistantChatPeerId& pid)
|
|||
sendTurtleData(cs) ; // that needs to be done off-mutex!
|
||||
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
std::map<std::string,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||
std::map<RsFileHash,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||
|
||||
if(it == _distant_chat_peers.end()) // server side. Nothing to do.
|
||||
{
|
||||
|
|
|
@ -372,13 +372,13 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||
|
||||
// Overloaded from RsTurtleClientService
|
||||
|
||||
virtual bool handleTunnelRequest(const std::string& hash,const RsPeerId& peer_id) ;
|
||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const std::string& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||
virtual bool handleTunnelRequest(const RsFileHash &hash,const RsPeerId& peer_id) ;
|
||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
||||
void markDistantChatAsClosed(const TurtleVirtualPeerId& vpid) ;
|
||||
void startClientDistantChatConnection(const std::string& hash,const PGPIdType& pgp_id,const unsigned char *aes_key_buf) ;
|
||||
bool findHashForVirtualPeerId(const TurtleVirtualPeerId& pid,std::string& hash) ;
|
||||
void startClientDistantChatConnection(const RsFileHash& hash,const PGPIdType& pgp_id,const unsigned char *aes_key_buf) ;
|
||||
bool findHashForVirtualPeerId(const TurtleVirtualPeerId& pid,RsFileHash& hash) ;
|
||||
|
||||
// Utility functions
|
||||
|
||||
|
|
|
@ -261,10 +261,10 @@ int p3turtle::tick()
|
|||
//
|
||||
void p3turtle::locked_addDistantPeer(const TurtleFileHash&,TurtleTunnelId tid)
|
||||
{
|
||||
unsigned char tmp[SSLIdType::SIZE_IN_BYTES] ;
|
||||
unsigned char tmp[RsPeerId::SIZE_IN_BYTES] ;
|
||||
|
||||
((uint32_t*)tmp)[0] = tid ;
|
||||
SSLIdType virtual_peer_id(tmp) ;
|
||||
RsPeerId virtual_peer_id(tmp) ;
|
||||
|
||||
_virtual_peers[virtual_peer_id] = tid ;
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
|
@ -603,7 +603,7 @@ void p3turtle::locked_closeTunnel(TurtleTunnelId tid,std::vector<std::pair<RsTur
|
|||
_local_tunnels.erase(it) ;
|
||||
}
|
||||
|
||||
void p3turtle::stopMonitoringTunnels(const std::string& hash)
|
||||
void p3turtle::stopMonitoringTunnels(const RsFileHash& hash)
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -721,7 +721,7 @@ uint32_t p3turtle::generatePersonalFilePrint(const TurtleFileHash& hash,uint32_t
|
|||
// The only important thing is that the saem couple (hash,SSL id) produces the same tunnel
|
||||
// id. The result uses a boolean to allow generating non symmetric tunnel ids.
|
||||
|
||||
std::string buff(hash + mLinkMgr->getOwnId().toStdString()) ;
|
||||
std::string buff(hash.toStdString() + mLinkMgr->getOwnId().toStdString()) ;
|
||||
uint32_t res = seed ;
|
||||
uint32_t decal = 0 ;
|
||||
|
||||
|
@ -869,7 +869,7 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item)
|
|||
}
|
||||
res_item->result.push_back(result.front()) ;
|
||||
|
||||
item_size += 8 /* size */ + result.front().hash.size() + result.front().name.size() ;
|
||||
item_size += 8 /* size */ + result.front().hash.serial_size() + result.front().name.size() ;
|
||||
result.pop_front() ;
|
||||
|
||||
if(item_size > RSTURTLE_MAX_SEARCH_RESPONSE_SIZE || result.empty())
|
||||
|
@ -893,13 +893,13 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item)
|
|||
|
||||
if(item->depth < TURTLE_MAX_SEARCH_DEPTH || random_bypass)
|
||||
{
|
||||
std::list<SSLIdType> onlineIds ;
|
||||
std::list<RsPeerId> onlineIds ;
|
||||
mLinkMgr->getOnlineList(onlineIds);
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " Looking for online peers" << std::endl ;
|
||||
#endif
|
||||
|
||||
for(std::list<SSLIdType>::const_iterator it(onlineIds.begin());it!=onlineIds.end();++it)
|
||||
for(std::list<RsPeerId>::const_iterator it(onlineIds.begin());it!=onlineIds.end();++it)
|
||||
{
|
||||
if(!(RS_SERVICE_PERM_TURTLE & rsPeers->servicePermissionFlags(*it)))
|
||||
continue ;
|
||||
|
@ -1086,8 +1086,8 @@ void p3turtle::handleRecvGenericTunnelItem(RsTurtleGenericTunnelItem *item)
|
|||
std::cerr << "p3Turtle: received Generic tunnel item:" << std::endl ;
|
||||
item->print(std::cerr,1) ;
|
||||
#endif
|
||||
std::string hash ;
|
||||
SSLIdType vpid ;
|
||||
RsFileHash hash ;
|
||||
RsPeerId vpid ;
|
||||
RsTurtleClientService *service ;
|
||||
|
||||
if(!getTunnelServiceInfo(item->tunnelId(),vpid,hash,service))
|
||||
|
@ -1096,7 +1096,7 @@ void p3turtle::handleRecvGenericTunnelItem(RsTurtleGenericTunnelItem *item)
|
|||
service->receiveTurtleData(item,hash,vpid,item->travelingDirection()) ;
|
||||
}
|
||||
|
||||
bool p3turtle::getTunnelServiceInfo(TurtleTunnelId tunnel_id,SSLIdType& vpid,std::string& hash,RsTurtleClientService *& service)
|
||||
bool p3turtle::getTunnelServiceInfo(TurtleTunnelId tunnel_id,RsPeerId& vpid,RsFileHash& hash,RsTurtleClientService *& service)
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -1126,7 +1126,7 @@ bool p3turtle::getTunnelServiceInfo(TurtleTunnelId tunnel_id,SSLIdType& vpid,std
|
|||
|
||||
// Now sort out the case of client vs. server side items.
|
||||
//
|
||||
SSLIdType ownid = mLinkMgr->getOwnId() ;
|
||||
RsPeerId ownid = mLinkMgr->getOwnId() ;
|
||||
|
||||
if(tunnel.local_src == ownid)
|
||||
{
|
||||
|
@ -1162,7 +1162,7 @@ bool p3turtle::getTunnelServiceInfo(TurtleTunnelId tunnel_id,SSLIdType& vpid,std
|
|||
}
|
||||
// Send a data request into the correct tunnel for the given file hash
|
||||
//
|
||||
void p3turtle::sendTurtleData(const SSLIdType& virtual_peer_id,RsTurtleGenericTunnelItem *item)
|
||||
void p3turtle::sendTurtleData(const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem *item)
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -1190,7 +1190,7 @@ void p3turtle::sendTurtleData(const SSLIdType& virtual_peer_id,RsTurtleGenericTu
|
|||
|
||||
item->tunnel_id = tunnel_id ; // we should randomly select a tunnel, or something more clever.
|
||||
|
||||
SSLIdType ownid = mLinkMgr->getOwnId() ;
|
||||
RsPeerId ownid = mLinkMgr->getOwnId() ;
|
||||
uint32_t ss = item->serial_size() ;
|
||||
|
||||
if(item->shouldStampTunnel())
|
||||
|
@ -1223,14 +1223,14 @@ void p3turtle::sendTurtleData(const SSLIdType& virtual_peer_id,RsTurtleGenericTu
|
|||
sendItem(item) ;
|
||||
}
|
||||
|
||||
bool p3turtle::isTurtlePeer(const SSLIdType& peer_id) const
|
||||
bool p3turtle::isTurtlePeer(const RsPeerId& peer_id) const
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
return _virtual_peers.find(peer_id) != _virtual_peers.end() ;
|
||||
}
|
||||
|
||||
SSLIdType p3turtle::getTurtlePeerId(TurtleTunnelId tid) const
|
||||
RsPeerId p3turtle::getTurtlePeerId(TurtleTunnelId tid) const
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -1244,7 +1244,7 @@ SSLIdType p3turtle::getTurtlePeerId(TurtleTunnelId tid) const
|
|||
return it->second.vpid ;
|
||||
}
|
||||
|
||||
bool p3turtle::isOnline(const SSLIdType& peer_id) const
|
||||
bool p3turtle::isOnline(const RsPeerId& peer_id) const
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -1469,13 +1469,13 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item)
|
|||
|
||||
if(item->depth < TURTLE_MAX_SEARCH_DEPTH || random_bypass)
|
||||
{
|
||||
std::list<SSLIdType> onlineIds ;
|
||||
std::list<RsPeerId> onlineIds ;
|
||||
mLinkMgr->getOnlineList(onlineIds);
|
||||
|
||||
for(std::list<SSLIdType>::iterator it(onlineIds.begin());it!=onlineIds.end();)
|
||||
for(std::list<RsPeerId>::iterator it(onlineIds.begin());it!=onlineIds.end();)
|
||||
if(!(RS_SERVICE_PERM_TURTLE & rsPeers->servicePermissionFlags(*it)))
|
||||
{
|
||||
std::list<SSLIdType>::iterator tmp = it++ ;
|
||||
std::list<RsPeerId>::iterator tmp = it++ ;
|
||||
onlineIds.erase(tmp) ;
|
||||
}
|
||||
else
|
||||
|
@ -1499,7 +1499,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item)
|
|||
std::cerr << " Forwarding tunnel request: Looking for online peers" << std::endl ;
|
||||
#endif
|
||||
|
||||
for(std::list<SSLIdType>::const_iterator it(onlineIds.begin());it!=onlineIds.end();++it)
|
||||
for(std::list<RsPeerId>::const_iterator it(onlineIds.begin());it!=onlineIds.end();++it)
|
||||
{
|
||||
uint32_t linkType = mLinkMgr->getLinkType(*it);
|
||||
|
||||
|
@ -1544,7 +1544,7 @@ void p3turtle::handleTunnelResult(RsTurtleTunnelOkItem *item)
|
|||
{
|
||||
bool new_tunnel = false ;
|
||||
TurtleFileHash new_hash ;
|
||||
SSLIdType new_vpid ;
|
||||
RsPeerId new_vpid ;
|
||||
RsTurtleClientService *service = NULL ;
|
||||
|
||||
{
|
||||
|
@ -1819,7 +1819,7 @@ TurtleRequestId p3turtle::turtleSearch(const LinearizedExpression& expr)
|
|||
return id ;
|
||||
}
|
||||
|
||||
void p3turtle::monitorTunnels(const std::string& hash,RsTurtleClientService *client_service)
|
||||
void p3turtle::monitorTunnels(const RsFileHash& hash,RsTurtleClientService *client_service)
|
||||
{
|
||||
{
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
|
@ -1875,7 +1875,7 @@ void p3turtle::returnSearchResult(RsTurtleSearchResultItem *item)
|
|||
/// Warning: this function should never be called while the turtle mutex is locked.
|
||||
/// Otherwize this is a possible source of cross-lock with the File mutex.
|
||||
//
|
||||
bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,const SSLIdType& peer_id,RsTurtleClientService *& service)
|
||||
bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,const RsPeerId& peer_id,RsTurtleClientService *& service)
|
||||
{
|
||||
if(_registered_services.empty())
|
||||
std::cerr << "Turtle router has no services registered. Tunnel requests cannot be handled." << std::endl;
|
||||
|
@ -1953,7 +1953,7 @@ void p3turtle::getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const
|
|||
float distance_to_maximum = std::min(100.0f,info.tr_up_Bps/(float)(TUNNEL_REQUEST_PACKET_SIZE*_max_tr_up_rate)) ;
|
||||
info.forward_probabilities.clear() ;
|
||||
|
||||
std::list<SSLIdType> onlineIds ;
|
||||
std::list<RsPeerId> onlineIds ;
|
||||
mLinkMgr->getOnlineList(onlineIds);
|
||||
|
||||
int nb_online_ids = onlineIds.size() ;
|
||||
|
@ -1992,7 +1992,7 @@ void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
|
|||
|
||||
std::vector<std::string>& hashes(hashes_info.back()) ;
|
||||
|
||||
hashes.push_back(it->first) ;
|
||||
hashes.push_back(it->first.toStdString()) ;
|
||||
//hashes.push_back(it->second.name) ;
|
||||
hashes.push_back("Name not available") ;
|
||||
hashes.push_back(printNumber(it->second.tunnels.size())) ;
|
||||
|
@ -2019,7 +2019,7 @@ void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
|
|||
else
|
||||
tunnel.push_back(it->second.local_dst.toStdString());
|
||||
|
||||
tunnel.push_back(it->second.hash) ;
|
||||
tunnel.push_back(it->second.hash.toStdString()) ;
|
||||
tunnel.push_back(printNumber(now-it->second.time_stamp) + " secs ago") ;
|
||||
tunnel.push_back(printFloatNumber(it->second.speed_Bps,true)) ;
|
||||
}
|
||||
|
|
|
@ -250,12 +250,12 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
|||
// This function should be called in addition to ftServer::FileRequest() so that the turtle router
|
||||
// automatically provide tunnels for the file to download.
|
||||
//
|
||||
virtual void monitorTunnels(const std::string& file_hash,RsTurtleClientService *client_service) ;
|
||||
virtual void monitorTunnels(const RsFileHash& file_hash,RsTurtleClientService *client_service) ;
|
||||
|
||||
/// This should be called when canceling a file download, so that the turtle router stops
|
||||
/// handling tunnels for this file.
|
||||
///
|
||||
virtual void stopMonitoringTunnels(const std::string& file_hash) ;
|
||||
virtual void stopMonitoringTunnels(const RsFileHash& file_hash) ;
|
||||
|
||||
/// Adds a client tunnel service. This means that the service will be added
|
||||
/// to the list of services that might respond to tunnel requests.
|
||||
|
@ -352,7 +352,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
|||
|
||||
/// specific routing functions for handling particular packets.
|
||||
void handleRecvGenericTunnelItem(RsTurtleGenericTunnelItem *item);
|
||||
bool getTunnelServiceInfo(TurtleTunnelId, SSLIdType& virtual_peer_id, std::string& hash, RsTurtleClientService*&) ;
|
||||
bool getTunnelServiceInfo(TurtleTunnelId, SSLIdType& virtual_peer_id, RsFileHash& hash, RsTurtleClientService*&) ;
|
||||
|
||||
// following functions should go to ftServer
|
||||
void handleSearchRequest(RsTurtleSearchRequestItem *item);
|
||||
|
|
|
@ -60,7 +60,7 @@ uint32_t RsTurtleSearchResultItem::serial_size()
|
|||
for(std::list<TurtleFileInfo>::const_iterator it(result.begin());it!=result.end();++it)
|
||||
{
|
||||
s += 8 ; // file size
|
||||
s += GetTlvStringSize(it->hash) ; // file hash
|
||||
s += it->hash.serial_size(); // file hash
|
||||
s += GetTlvStringSize(it->name) ; // file name
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ uint32_t RsTurtleOpenTunnelItem::serial_size()
|
|||
uint32_t s = 0 ;
|
||||
|
||||
s += 8 ; // header
|
||||
s += GetTlvStringSize(file_hash) ; // file hash
|
||||
s += file_hash.serial_size() ; // file hash
|
||||
s += 4 ; // tunnel request id
|
||||
s += 4 ; // partial tunnel id
|
||||
s += 2 ; // depth
|
||||
|
@ -334,7 +334,7 @@ bool RsTurtleSearchResultItem::serialize(void *data,uint32_t& pktsize)
|
|||
for(std::list<TurtleFileInfo>::const_iterator it(result.begin());it!=result.end();++it)
|
||||
{
|
||||
ok &= setRawUInt64(data, tlvsize, &offset, it->size); // file size
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_HASH_SHA1, it->hash); // file hash
|
||||
ok &= it->hash.serialise(data, tlvsize, offset); // file hash
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, it->name); // file name
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ RsTurtleSearchResultItem::RsTurtleSearchResultItem(void *data,uint32_t pktsize)
|
|||
TurtleFileInfo f ;
|
||||
|
||||
ok &= getRawUInt64(data, pktsize, &offset, &(f.size)); // file size
|
||||
ok &= GetTlvString(data, pktsize, &offset, TLV_TYPE_STR_HASH_SHA1, f.hash); // file hash
|
||||
ok &= f.hash.deserialise(data, pktsize, offset); // file hash
|
||||
ok &= GetTlvString(data, pktsize, &offset, TLV_TYPE_STR_NAME, f.name); // file name
|
||||
|
||||
result.push_back(f) ;
|
||||
|
@ -412,7 +412,7 @@ bool RsTurtleOpenTunnelItem::serialize(void *data,uint32_t& pktsize)
|
|||
|
||||
/* add mandatory parts first */
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_HASH_SHA1, file_hash); // file hash
|
||||
ok &= file_hash.serialise(data, tlvsize, offset); // file hash
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, request_id);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, partial_tunnel_id);
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, depth);
|
||||
|
@ -441,7 +441,7 @@ RsTurtleOpenTunnelItem::RsTurtleOpenTunnelItem(void *data,uint32_t pktsize)
|
|||
/* add mandatory parts first */
|
||||
|
||||
bool ok = true ;
|
||||
ok &= GetTlvString(data, pktsize, &offset, TLV_TYPE_STR_HASH_SHA1, file_hash); // file hash
|
||||
ok &= file_hash.deserialise(data, pktsize, offset); // file hash
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &request_id);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &partial_tunnel_id) ;
|
||||
ok &= getRawUInt16(data, pktsize, &offset, &depth);
|
||||
|
|
|
@ -46,7 +46,7 @@ class RsTurtleClientService
|
|||
// The output info_string is used by the turtle router to display info about tunnels it manages. It is
|
||||
// not passed to the tunnel.
|
||||
|
||||
virtual bool handleTunnelRequest(const std::string& /*hash*/,const SSLIdType& /*peer_id*/) { return false ; }
|
||||
virtual bool handleTunnelRequest(const RsFileHash& /*hash*/,const RsPeerId& /*peer_id*/) { return false ; }
|
||||
|
||||
// This method is called by the turtle router to send data that comes out of a turtle tunnel.
|
||||
// The turtle router stays responsible for the memory management of data. Most of the time the
|
||||
|
@ -66,7 +66,7 @@ class RsTurtleClientService
|
|||
// By default (if not overloaded), the method will just free the data, as any subclass should do as well.
|
||||
// Note: p3turtle stays owner of the item, so the client should not delete it!
|
||||
//
|
||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem */*item*/,const std::string& /*hash*/,const SSLIdType& /*virtual_peer_id*/,RsTurtleGenericTunnelItem::Direction /*direction*/)
|
||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem */*item*/,const RsFileHash& /*hash*/,const RsPeerId& /*virtual_peer_id*/,RsTurtleGenericTunnelItem::Direction /*direction*/)
|
||||
{
|
||||
std::cerr << "!!!!!! Received Data from turtle router, but the client service is not handling it !!!!!!!!!!" << std::endl ;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
#include "retroshare/rsturtle.h"
|
||||
|
||||
typedef SSLIdType TurtlePeerId ;
|
||||
typedef SSLIdType TurtleVirtualPeerId ;
|
||||
typedef std::string TurtleFileHash ;
|
||||
typedef RsPeerId TurtlePeerId ;
|
||||
typedef RsPeerId TurtleVirtualPeerId ;
|
||||
typedef RsFileHash TurtleFileHash ;
|
||||
typedef std::string TurtleFileName ;
|
||||
|
||||
typedef TurtleRequestId TurtleSearchRequestId ;
|
||||
|
|
|
@ -624,7 +624,7 @@ bool RsDirUtil::cleanupDirectoryFaster(const std::string& cleandir, const std::
|
|||
|
||||
/* slightly nicer helper function */
|
||||
bool RsDirUtil::hashFile(const std::string& filepath,
|
||||
std::string &name, std::string &hash, uint64_t &size)
|
||||
std::string &name, RsFileHash &hash, uint64_t &size)
|
||||
{
|
||||
if (getFileHash(filepath, hash, size))
|
||||
{
|
||||
|
@ -640,7 +640,7 @@ bool RsDirUtil::hashFile(const std::string& filepath,
|
|||
#include <iomanip>
|
||||
|
||||
/* Function to hash, and get details of a file */
|
||||
bool RsDirUtil::getFileHash(const std::string& filepath, std::string &hash, uint64_t &size, RsThread *thread /*= NULL*/)
|
||||
bool RsDirUtil::getFileHash(const std::string& filepath, RsFileHash &hash, uint64_t &size, RsThread *thread /*= NULL*/)
|
||||
{
|
||||
FILE *fd;
|
||||
int len;
|
||||
|
|
|
@ -92,8 +92,8 @@ bool checkCreateDirectory(const std::string& dir);
|
|||
bool cleanupDirectory(const std::string& dir, const std::set<std::string> &keepFiles);
|
||||
bool cleanupDirectoryFaster(const std::string& dir, const std::set<std::string> &keepFiles);
|
||||
|
||||
bool hashFile(const std::string& filepath, std::string &name, std::string &hash, uint64_t &size);
|
||||
bool getFileHash(const std::string& filepath,std::string &hash, uint64_t &size, RsThread *thread = NULL);
|
||||
bool hashFile(const std::string& filepath, std::string &name, RsFileHash &hash, uint64_t &size);
|
||||
bool getFileHash(const std::string& filepath,RsFileHash &hash, uint64_t &size, RsThread *thread = NULL);
|
||||
|
||||
Sha1CheckSum sha1sum(const uint8_t *data,uint32_t size) ;
|
||||
|
||||
|
@ -124,11 +124,9 @@ bool checkWideDirectory(std::wstring dir);
|
|||
bool checkWideCreateDirectory(std::wstring dir);
|
||||
bool cleanupWideDirectory(std::wstring dir, std::list<std::wstring> keepFiles);
|
||||
|
||||
bool hashWideFile(std::wstring filepath,
|
||||
std::wstring &name, std::string &hash, uint64_t &size);
|
||||
bool hashWideFile(std::wstring filepath,std::wstring &name, RsFileHash &hash, uint64_t &size);
|
||||
|
||||
bool getWideFileHash(std::wstring filepath,
|
||||
std::string &hash, uint64_t &size);
|
||||
bool getWideFileHash(std::wstring filepath, RsFileHash &hash, uint64_t &size);
|
||||
|
||||
FILE *rs_fopen(const char* filename, const char* mode);
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ DetailsDialog::show()
|
|||
}
|
||||
}
|
||||
|
||||
void DetailsDialog::setFileHash(const std::string & hash)
|
||||
void DetailsDialog::setFileHash(const RsFileHash & hash)
|
||||
{
|
||||
dynamic_cast<FileTransferInfoWidget*>(ui.fileTransferInfoWidget->widget())->setFileHash(hash) ;
|
||||
|
||||
|
@ -108,7 +108,7 @@ void DetailsDialog::setFileHash(const std::string & hash)
|
|||
return ;
|
||||
|
||||
RetroShareLink link ;
|
||||
link.createFile(QString::fromUtf8(nfo.fname.c_str()),nfo.size,QString::fromStdString(nfo.hash)) ;
|
||||
link.createFile(QString::fromUtf8(nfo.fname.c_str()),nfo.size,QString::fromStdString(nfo.hash.toStdString())) ;
|
||||
|
||||
ui.Linktext->setText(link.toString()) ;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include "ui_DetailsDialog.h"
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
class FileChunksInfo ;
|
||||
|
||||
|
@ -37,7 +38,7 @@ public:
|
|||
/** Default destructor */
|
||||
~DetailsDialog() {}
|
||||
|
||||
void setFileHash(const std::string& hash) ;
|
||||
void setFileHash(const RsFileHash &hash) ;
|
||||
|
||||
public slots:
|
||||
/** Overloaded QWidget.show */
|
||||
|
@ -52,7 +53,7 @@ private:
|
|||
|
||||
class QStandardItemModel *CommentsModel;
|
||||
|
||||
std::string _file_hash ;
|
||||
RsFileHash _file_hash ;
|
||||
|
||||
|
||||
/** Qt Designer generated object */
|
||||
|
|
|
@ -248,7 +248,7 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info
|
|||
y += block_sep ;
|
||||
y += text_height ; painter->drawText(20,y,tr("Destination folder") + ":") ; painter->drawText(tab_size,y,QString::fromUtf8(nfo.path.c_str())) ;
|
||||
y += block_sep ;
|
||||
y += text_height ; painter->drawText(20,y,tr("File hash") + ":") ; painter->drawText(tab_size,y,QString::fromStdString(nfo.hash)) ;
|
||||
y += text_height ; painter->drawText(20,y,tr("File hash") + ":") ; painter->drawText(tab_size,y,QString::fromStdString(nfo.hash.toStdString())) ;
|
||||
y += block_sep ;
|
||||
y += text_height ; painter->drawText(20,y,tr("File size") + ":") ; painter->drawText(tab_size,y,QString::number(info.file_size) + " " + tr("bytes") + " " + "(" + misc::friendlyUnit(info.file_size) + ")") ;
|
||||
y += block_sep ;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QPainter>
|
||||
#include <QBitmap>
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
class FileChunksInfo ;
|
||||
class FileInfo ;
|
||||
|
@ -36,7 +37,7 @@ class FileTransferInfoWidget : public RsAutoUpdatePage
|
|||
public:
|
||||
FileTransferInfoWidget(QWidget * parent = 0, Qt::WindowFlags f = 0 );
|
||||
|
||||
void setFileHash(const std::string& hash) { _file_hash = hash ; }
|
||||
void setFileHash(const RsFileHash& hash) { _file_hash = hash ; }
|
||||
|
||||
virtual void updateDisplay() ; // update from RsAutoUpdateWidget
|
||||
protected:
|
||||
|
@ -57,6 +58,6 @@ private:
|
|||
QPixmap notDownloadPixmap;
|
||||
QPixmap checkingPixmap;
|
||||
|
||||
std::string _file_hash ;
|
||||
RsFileHash _file_hash ;
|
||||
};
|
||||
|
||||
|
|
|
@ -621,7 +621,7 @@ void TransfersDialog::processSettings(bool bLoad)
|
|||
|
||||
void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
|
||||
{
|
||||
std::set<std::string> items;
|
||||
std::set<RsFileHash> items;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
bool single = (items.size() == 1) ;
|
||||
|
@ -677,7 +677,7 @@ void TransfersDialog::downloadListCustomPopupMenu( QPoint /*point*/ )
|
|||
if ( lst[i].column() == 0)
|
||||
{
|
||||
//Get Info for current item
|
||||
if (rsFiles->FileDetails(getID(lst[i].row(), DLListModel).toStdString(), RS_FILE_HINTS_DOWNLOAD, info))
|
||||
if (rsFiles->FileDetails(RsFileHash(getID(lst[i].row(), DLListModel).toStdString()), RS_FILE_HINTS_DOWNLOAD, info))
|
||||
{
|
||||
/*const uint32_t FT_STATE_FAILED = 0x0000 ;
|
||||
const uint32_t FT_STATE_OKAY = 0x0001 ;
|
||||
|
@ -852,7 +852,7 @@ void TransfersDialog::uploadsListCustomPopupMenu( QPoint /*point*/ )
|
|||
{
|
||||
std::cerr << "TransfersDialog::uploadsListCustomPopupMenu()" << std::endl;
|
||||
|
||||
std::set<std::string> items;
|
||||
std::set<RsFileHash> items;
|
||||
getULSelectedItems(&items, NULL);
|
||||
|
||||
bool single = (items.size() == 1);
|
||||
|
@ -885,10 +885,10 @@ void TransfersDialog::chooseDestinationDirectory()
|
|||
if(dest_dir.isNull())
|
||||
return ;
|
||||
|
||||
std::set<std::string> items ;
|
||||
std::set<RsFileHash> items ;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
for(std::set<std::string>::const_iterator it(items.begin());it!=items.end();++it)
|
||||
for(std::set<RsFileHash>::const_iterator it(items.begin());it!=items.end();++it)
|
||||
{
|
||||
std::cerr << "Setting new directory " << dest_dir.toUtf8().data() << " to file " << *it << std::endl;
|
||||
rsFiles->setDestinationDirectory(*it,dest_dir.toUtf8().data() ) ;
|
||||
|
@ -898,10 +898,10 @@ void TransfersDialog::setDestinationDirectory()
|
|||
{
|
||||
std::string dest_dir(qobject_cast<QAction*>(sender())->data().toString().toUtf8().data()) ;
|
||||
|
||||
std::set<std::string> items ;
|
||||
std::set<RsFileHash> items ;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
for(std::set<std::string>::const_iterator it(items.begin());it!=items.end();++it)
|
||||
for(std::set<RsFileHash>::const_iterator it(items.begin());it!=items.end();++it)
|
||||
{
|
||||
std::cerr << "Setting new directory " << dest_dir << " to file " << *it << std::endl;
|
||||
rsFiles->setDestinationDirectory(*it,dest_dir) ;
|
||||
|
@ -910,7 +910,7 @@ void TransfersDialog::setDestinationDirectory()
|
|||
|
||||
int TransfersDialog::addItem(int row, const FileInfo &fileInfo)
|
||||
{
|
||||
QString fileHash = QString::fromStdString(fileInfo.hash);
|
||||
QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
|
||||
double fileDlspeed = (fileInfo.downloadStatus == FT_STATE_DOWNLOADING) ? (fileInfo.tfRate * 1024.0) : 0.0;
|
||||
|
||||
QString status;
|
||||
|
@ -951,7 +951,7 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo)
|
|||
if (fileInfo.downloadStatus == FT_STATE_COMPLETE)
|
||||
file = QFileInfo(QString::fromUtf8(fileInfo.path.c_str()), QString::fromUtf8(fileInfo.fname.c_str()));
|
||||
else
|
||||
file = QFileInfo(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()), QString::fromUtf8(fileInfo.hash.c_str()));
|
||||
file = QFileInfo(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()), QString::fromUtf8(fileInfo.hash.toStdString().c_str()));
|
||||
|
||||
/*Get Last Access on File */
|
||||
if (file.exists())
|
||||
|
@ -1232,12 +1232,12 @@ void TransfersDialog::insertTransfers()
|
|||
ui.downloadList->setSortingEnabled(false);
|
||||
|
||||
/* get the download lists */
|
||||
std::list<std::string> downHashes;
|
||||
std::list<RsFileHash> downHashes;
|
||||
rsFiles->FileDownloads(downHashes);
|
||||
|
||||
/* build set for quick search */
|
||||
std::set<std::string> hashs;
|
||||
std::list<std::string>::iterator it;
|
||||
std::set<RsFileHash> hashs;
|
||||
std::list<RsFileHash>::iterator it;
|
||||
for (it = downHashes.begin(); it != downHashes.end(); ++it) {
|
||||
hashs.insert(*it);
|
||||
}
|
||||
|
@ -1246,10 +1246,10 @@ void TransfersDialog::insertTransfers()
|
|||
|
||||
int rowCount = DLListModel->rowCount();
|
||||
int row ;
|
||||
std::set<std::string>::iterator hashIt;
|
||||
std::set<RsFileHash>::iterator hashIt;
|
||||
|
||||
for (row = 0; row < rowCount; ) {
|
||||
std::string hash = DLListModel->item(row, COLUMN_ID)->data(Qt::UserRole).toString().toStdString();
|
||||
RsFileHash hash ( DLListModel->item(row, COLUMN_ID)->data(Qt::UserRole).toString().toStdString());
|
||||
|
||||
hashIt = hashs.find(hash);
|
||||
if (hashIt == hashs.end()) {
|
||||
|
@ -1306,7 +1306,7 @@ void TransfersDialog::insertTransfers()
|
|||
|
||||
// Now show upload hashes
|
||||
//
|
||||
std::list<std::string> upHashes;
|
||||
std::list<RsFileHash> upHashes;
|
||||
rsFiles->FileUploads(upHashes);
|
||||
|
||||
RsPeerId ownId = rsPeers->getOwnId();
|
||||
|
@ -1328,7 +1328,7 @@ void TransfersDialog::insertTransfers()
|
|||
if (pit->peerId == ownId) //don't display transfer to ourselves
|
||||
continue ;
|
||||
|
||||
QString fileHash = QString::fromStdString(info.hash);
|
||||
QString fileHash = QString::fromStdString(info.hash.toStdString());
|
||||
QString fileName = QString::fromUtf8(info.fname.c_str());
|
||||
QString source = getPeerName(pit->peerId);
|
||||
|
||||
|
@ -1425,8 +1425,8 @@ void TransfersDialog::cancel()
|
|||
{
|
||||
bool first = true;
|
||||
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
if (first) {
|
||||
|
@ -1472,8 +1472,8 @@ void TransfersDialog::copyLink ()
|
|||
{
|
||||
QList<RetroShareLink> links ;
|
||||
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
|
@ -1483,7 +1483,7 @@ void TransfersDialog::copyLink ()
|
|||
}
|
||||
|
||||
RetroShareLink link;
|
||||
if (link.createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash))) {
|
||||
if (link.createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash.toStdString()))) {
|
||||
links.push_back(link) ;
|
||||
}
|
||||
}
|
||||
|
@ -1495,8 +1495,8 @@ void TransfersDialog::ulCopyLink ()
|
|||
{
|
||||
QList<RetroShareLink> links ;
|
||||
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getULSelectedItems(&items, NULL);
|
||||
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
|
@ -1506,7 +1506,7 @@ void TransfersDialog::ulCopyLink ()
|
|||
}
|
||||
|
||||
RetroShareLink link;
|
||||
if (link.createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash))) {
|
||||
if (link.createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash.toStdString()))) {
|
||||
links.push_back(link) ;
|
||||
}
|
||||
}
|
||||
|
@ -1530,7 +1530,7 @@ void TransfersDialog::showDetailsDialog()
|
|||
|
||||
void TransfersDialog::updateDetailsDialog()
|
||||
{
|
||||
std::string file_hash ;
|
||||
RsFileHash file_hash ;
|
||||
std::set<int> rows;
|
||||
std::set<int>::iterator it;
|
||||
getSelectedItems(NULL, &rows);
|
||||
|
@ -1538,7 +1538,7 @@ void TransfersDialog::updateDetailsDialog()
|
|||
if (rows.size()) {
|
||||
int row = *rows.begin();
|
||||
|
||||
file_hash = getID(row, DLListModel).toStdString();
|
||||
file_hash = RsFileHash(getID(row, DLListModel).toStdString());
|
||||
}
|
||||
|
||||
detailsDialog()->setFileHash(file_hash);
|
||||
|
@ -1549,7 +1549,7 @@ void TransfersDialog::pasteLink()
|
|||
RSLinkClipboard::process(RetroShareLink::TYPE_FILE);
|
||||
}
|
||||
|
||||
void TransfersDialog::getSelectedItems(std::set<std::string> *ids, std::set<int> *rows)
|
||||
void TransfersDialog::getSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows)
|
||||
{
|
||||
if (ids == NULL && rows == NULL) {
|
||||
return;
|
||||
|
@ -1584,8 +1584,8 @@ void TransfersDialog::getSelectedItems(std::set<std::string> *ids, std::set<int>
|
|||
if (isParentSelected || isChildSelected) {
|
||||
if (ids) {
|
||||
QStandardItem *id = DLListModel->item(i, COLUMN_ID);
|
||||
ids->insert(id->data(Qt::DisplayRole).toString().toStdString());
|
||||
ids->insert(id->data(Qt::UserRole ).toString().toStdString());
|
||||
ids->insert(RsFileHash(id->data(Qt::DisplayRole).toString().toStdString()));
|
||||
ids->insert(RsFileHash(id->data(Qt::UserRole ).toString().toStdString()));
|
||||
}
|
||||
if (rows) {
|
||||
rows->insert(i);
|
||||
|
@ -1594,7 +1594,7 @@ void TransfersDialog::getSelectedItems(std::set<std::string> *ids, std::set<int>
|
|||
}
|
||||
}
|
||||
|
||||
void TransfersDialog::getULSelectedItems(std::set<std::string> *ids, std::set<int> *rows)
|
||||
void TransfersDialog::getULSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows)
|
||||
{
|
||||
if (ids == NULL && rows == NULL) {
|
||||
return;
|
||||
|
@ -1609,7 +1609,7 @@ void TransfersDialog::getULSelectedItems(std::set<std::string> *ids, std::set<in
|
|||
foreach(index, indexes) {
|
||||
if (ids) {
|
||||
QStandardItem *id = ULListModel->item(index.row(), COLUMN_UHASH);
|
||||
ids->insert(id->data(Qt::DisplayRole).toString().toStdString());
|
||||
ids->insert(RsFileHash(id->data(Qt::DisplayRole).toString().toStdString()));
|
||||
}
|
||||
if (rows) {
|
||||
rows->insert(index.row());
|
||||
|
@ -1623,8 +1623,8 @@ bool TransfersDialog::controlTransferFile(uint32_t flags)
|
|||
{
|
||||
bool result = true;
|
||||
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
result &= rsFiles->FileControl(*it, flags);
|
||||
|
@ -1653,8 +1653,8 @@ void TransfersDialog::openFolderTransfer()
|
|||
{
|
||||
FileInfo info;
|
||||
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||
|
@ -1683,8 +1683,8 @@ void TransfersDialog::ulOpenFolder()
|
|||
{
|
||||
FileInfo info;
|
||||
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getULSelectedItems(&items, NULL);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info)) continue;
|
||||
|
@ -1710,8 +1710,8 @@ void TransfersDialog::previewTransfer()
|
|||
{
|
||||
FileInfo info;
|
||||
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||
|
@ -1726,7 +1726,7 @@ void TransfersDialog::previewTransfer()
|
|||
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
||||
fileInfo = QFileInfo(QString::fromUtf8(info.path.c_str()), QString::fromUtf8(info.fname.c_str()));
|
||||
} else {
|
||||
fileInfo = QFileInfo(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()), QString::fromUtf8(info.hash.c_str()));
|
||||
fileInfo = QFileInfo(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()), QString::fromUtf8(info.hash.toStdString().c_str()));
|
||||
|
||||
QString linkName = QFileInfo(QDir::temp(), QString::fromUtf8(info.fname.c_str())).absoluteFilePath();
|
||||
if (QFile::link(fileInfo.absoluteFilePath(), linkName)) {
|
||||
|
@ -1760,8 +1760,8 @@ void TransfersDialog::openTransfer()
|
|||
{
|
||||
FileInfo info;
|
||||
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||
|
@ -1819,8 +1819,8 @@ void TransfersDialog::chunkProgressive()
|
|||
}
|
||||
void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
||||
{
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
for (it = items.begin(); it != items.end(); it ++) {
|
||||
|
@ -1860,8 +1860,8 @@ void TransfersDialog::priorityQueueBottom()
|
|||
|
||||
void TransfersDialog::changeSpeed(int speed)
|
||||
{
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
for (it = items.begin(); it != items.end(); it ++)
|
||||
|
@ -1890,7 +1890,7 @@ static bool checkFileName(const QString& name)
|
|||
|
||||
void TransfersDialog::renameFile()
|
||||
{
|
||||
std::set<std::string> items;
|
||||
std::set<RsFileHash> items;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
if(items.size() != 1)
|
||||
|
@ -1899,7 +1899,7 @@ void TransfersDialog::renameFile()
|
|||
return ;
|
||||
}
|
||||
|
||||
std::string hash = *(items.begin()) ;
|
||||
RsFileHash hash = *(items.begin()) ;
|
||||
|
||||
FileInfo info ;
|
||||
if (!rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, info))
|
||||
|
@ -1925,8 +1925,8 @@ void TransfersDialog::renameFile()
|
|||
void TransfersDialog::changeQueuePosition(QueueMove mv)
|
||||
{
|
||||
// std::cerr << "In changeQueuePosition (gui)"<< std::endl ;
|
||||
std::set<std::string> items;
|
||||
std::set<std::string>::iterator it;
|
||||
std::set<RsFileHash> items;
|
||||
std::set<RsFileHash>::iterator it;
|
||||
getSelectedItems(&items, NULL);
|
||||
|
||||
for (it = items.begin(); it != items.end(); it ++)
|
||||
|
@ -1943,7 +1943,7 @@ void TransfersDialog::clearcompleted()
|
|||
|
||||
void TransfersDialog::showFileDetails()
|
||||
{
|
||||
std::string file_hash ;
|
||||
RsFileHash file_hash ;
|
||||
int nb_select = 0 ;
|
||||
|
||||
for(int i = 0; i <= DLListModel->rowCount(); i++)
|
||||
|
@ -1953,7 +1953,7 @@ void TransfersDialog::showFileDetails()
|
|||
++nb_select ;
|
||||
}
|
||||
if(nb_select != 1)
|
||||
detailsDialog()->setFileHash("") ;
|
||||
detailsDialog()->setFileHash(RsFileHash()) ;
|
||||
else
|
||||
detailsDialog()->setFileHash(file_hash) ;
|
||||
|
||||
|
|
|
@ -218,8 +218,8 @@ private:
|
|||
bool m_bProcessSettings;
|
||||
void processSettings(bool bLoad);
|
||||
|
||||
void getSelectedItems(std::set<std::string> *ids, std::set<int> *rows);
|
||||
void getULSelectedItems(std::set<std::string> *ids, std::set<int> *rows);
|
||||
void getSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows);
|
||||
void getULSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows);
|
||||
bool controlTransferFile(uint32_t flags);
|
||||
void changePriority(int priority);
|
||||
void setChunkStrategy(FileChunksInfo::ChunkStrategy s) ;
|
||||
|
|
|
@ -821,7 +821,7 @@ void FriendsDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
|
|||
HashedFile& hashedFile = *it;
|
||||
RetroShareLink link;
|
||||
|
||||
if (!link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId().toStdString())))
|
||||
if (!link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash.toStdString()),QString::fromStdString(rsPeers->getOwnId().toStdString())))
|
||||
continue;
|
||||
|
||||
mesgString += link.toHtmlSize();
|
||||
|
|
|
@ -1074,10 +1074,10 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s
|
|||
// Note: for directories, the returned hash, is the peer id, so if we collect
|
||||
// dirs, we need to be a bit more conservative for the
|
||||
|
||||
if(already_in.find(details->hash+details->name) == already_in.end())
|
||||
if(already_in.find(details->hash.toStdString()+details->name) == already_in.end())
|
||||
{
|
||||
file_details.push_back(*details) ;
|
||||
already_in.insert(details->hash+details->name) ;
|
||||
already_in.insert(details->hash.toStdString()+details->name) ;
|
||||
}
|
||||
}
|
||||
#ifdef RDM_DEBUG
|
||||
|
@ -1199,8 +1199,8 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
|
|||
/* extract from each the member text */
|
||||
QString text;
|
||||
QModelIndexList::const_iterator it;
|
||||
std::map<std::string, uint64_t> drags;
|
||||
std::map<std::string, uint64_t>::iterator dit;
|
||||
std::map<RsFileHash, uint64_t> drags;
|
||||
std::map<RsFileHash, uint64_t>::iterator dit;
|
||||
|
||||
for(it = indexes.begin(); it != indexes.end(); it++)
|
||||
{
|
||||
|
@ -1239,7 +1239,7 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
|
|||
|
||||
drags[details->hash] = details->count;
|
||||
|
||||
QString line = QString("%1/%2/%3/").arg(QString::fromUtf8(details->name.c_str()), QString::fromStdString(details->hash), QString::number(details->count));
|
||||
QString line = QString("%1/%2/%3/").arg(QString::fromUtf8(details->name.c_str()), QString::fromStdString(details->hash.toStdString()), QString::number(details->count));
|
||||
|
||||
if (RemoteMode)
|
||||
{
|
||||
|
|
|
@ -920,7 +920,7 @@ QString RetroShareLink::toHtmlSize() const
|
|||
|
||||
if (type() == TYPE_FILE && RsCollectionFile::isCollectionFile(name())) {
|
||||
FileInfo finfo;
|
||||
if (rsFiles->FileDetails(hash().toStdString(), RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL, finfo)) {
|
||||
if (rsFiles->FileDetails(RsFileHash(hash().toStdString()), RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL, finfo)) {
|
||||
RsCollectionFile collection;
|
||||
if (collection.load(QString::fromUtf8(finfo.path.c_str()), false)) {
|
||||
size += QString(" [%1]").arg(misc::friendlyUnit(collection.size()));
|
||||
|
@ -1312,7 +1312,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
|||
// Get a list of available direct sources, in case the file is browsable only.
|
||||
//
|
||||
FileInfo finfo ;
|
||||
rsFiles->FileDetails(link.hash().toStdString(), RS_FILE_HINTS_REMOTE, finfo) ;
|
||||
rsFiles->FileDetails(RsFileHash(link.hash().toStdString()), RS_FILE_HINTS_REMOTE, finfo) ;
|
||||
|
||||
for(std::list<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
|
||||
{
|
||||
|
@ -1333,7 +1333,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
|||
flag |= RSLINK_PROCESS_NOTIFY_BAD_CHARS ;
|
||||
}
|
||||
|
||||
if (rsFiles->FileRequest(cleanname.toUtf8().constData(), link.hash().toStdString(), link.size(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) {
|
||||
if (rsFiles->FileRequest(cleanname.toUtf8().constData(), RsFileHash(link.hash().toStdString()), link.size(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) {
|
||||
fileAdded.append(link.name());
|
||||
} else {
|
||||
fileExist.append(link.name());
|
||||
|
|
|
@ -325,7 +325,7 @@ void SearchDialog::searchtableWidgetCostumPopupMenu( QPoint /*point*/ )
|
|||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void SearchDialog::getSourceFriendsForHash(const std::string& hash,std::list<RsPeerId>& srcIds)
|
||||
void SearchDialog::getSourceFriendsForHash(const RsFileHash& hash,std::list<RsPeerId>& srcIds)
|
||||
{
|
||||
std::cerr << "Searching sources for file " << hash << std::endl ;
|
||||
srcIds.clear();
|
||||
|
@ -361,7 +361,7 @@ void SearchDialog::download()
|
|||
std::cerr << std::endl;
|
||||
std::list<RsPeerId> srcIds;
|
||||
|
||||
std::string hash = item->text(SR_HASH_COL).toStdString();
|
||||
RsFileHash hash ( item->text(SR_HASH_COL).toStdString());
|
||||
getSourceFriendsForHash(hash,srcIds) ;
|
||||
|
||||
if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toUtf8().constData(), hash, (item->text(SR_SIZE_COL)).toULongLong(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds))
|
||||
|
@ -388,7 +388,7 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString
|
|||
+ "/" + base + "/";
|
||||
QString cleanPath = QDir::cleanPath(path);
|
||||
|
||||
std::string hash = item->text(SR_HASH_COL).toStdString();
|
||||
RsFileHash hash ( item->text(SR_HASH_COL).toStdString());
|
||||
|
||||
getSourceFriendsForHash(hash,srcIds) ;
|
||||
|
||||
|
@ -792,7 +792,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
|
|||
/* translate search result for a file */
|
||||
|
||||
child->setText(SR_NAME_COL, QString::fromUtf8(dir.name.c_str()));
|
||||
child->setText(SR_HASH_COL, QString::fromStdString(dir.hash));
|
||||
child->setText(SR_HASH_COL, QString::fromStdString(dir.hash.toStdString()));
|
||||
child->setText(SR_SIZE_COL, QString::number(dir.count));
|
||||
child->setData(SR_SIZE_COL, ROLE_SORT, (qulonglong) dir.count);
|
||||
child->setText(SR_AGE_COL, QString::number(dir.age));
|
||||
|
@ -818,7 +818,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
|
|||
|
||||
child->setIcon(SR_NAME_COL, QIcon(IMAGE_DIRECTORY));
|
||||
child->setText(SR_NAME_COL, QString::fromUtf8(dir.name.c_str()));
|
||||
child->setText(SR_HASH_COL, QString::fromStdString(dir.hash));
|
||||
child->setText(SR_HASH_COL, QString::fromStdString(dir.hash.toStdString()));
|
||||
child->setText(SR_SIZE_COL, QString::number(dir.count));
|
||||
child->setData(SR_SIZE_COL, ROLE_SORT, (qulonglong) dir.count);
|
||||
child->setText(SR_AGE_COL, QString::number(dir.age));
|
||||
|
@ -886,7 +886,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
|
|||
|
||||
child->setIcon(SR_NAME_COL, QIcon(IMAGE_DIRECTORY));
|
||||
child->setText(SR_NAME_COL, QString::fromUtf8(dir.name.c_str()));
|
||||
child->setText(SR_HASH_COL, QString::fromStdString(dir.hash));
|
||||
child->setText(SR_HASH_COL, QString::fromStdString(dir.hash.toStdString()));
|
||||
child->setText(SR_SIZE_COL, QString::number(dir.count));
|
||||
child->setData(SR_SIZE_COL, ROLE_SORT, (qulonglong) dir.count);
|
||||
child->setText(SR_AGE_COL, QString::number(dir.min_age));
|
||||
|
@ -990,7 +990,7 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
|||
int anonymousSource = 0;
|
||||
QString modifiedResult;
|
||||
|
||||
QList<QTreeWidgetItem*> itms = ui.searchResultWidget->findItems(QString::fromStdString(file.hash),Qt::MatchExactly,SR_HASH_COL) ;
|
||||
QList<QTreeWidgetItem*> itms = ui.searchResultWidget->findItems(QString::fromStdString(file.hash.toStdString()),Qt::MatchExactly,SR_HASH_COL) ;
|
||||
|
||||
for(QList<QTreeWidgetItem*>::const_iterator it(itms.begin());it!=itms.end();++it)
|
||||
if((*it)->text(SR_SEARCH_ID_COL) == sid_hexa)
|
||||
|
@ -1058,7 +1058,7 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s
|
|||
|
||||
QTreeWidgetItem *item = new RSTreeWidgetItem(compareResultRole);
|
||||
item->setText(SR_NAME_COL, QString::fromUtf8(file.name.c_str()));
|
||||
item->setText(SR_HASH_COL, QString::fromStdString(file.hash));
|
||||
item->setText(SR_HASH_COL, QString::fromStdString(file.hash.toStdString()));
|
||||
|
||||
setIconAndType(item, QString::fromUtf8(file.name.c_str()));
|
||||
|
||||
|
@ -1342,7 +1342,7 @@ void SearchDialog::openFolderSearch()
|
|||
|
||||
if (item.at(0)->data(SR_DATA_COL, SR_ROLE_LOCAL).toBool()){
|
||||
QString strFileID = item.at(0)->text(SR_HASH_COL);
|
||||
if (rsFiles->FileDetails(strFileID.toStdString(), RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_SPEC_ONLY, info)){
|
||||
if (rsFiles->FileDetails(RsFileHash(strFileID.toStdString()), RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_SPEC_ONLY, info)){
|
||||
/* make path for downloaded or downloading files */
|
||||
QFileInfo qinfo;
|
||||
std::string path;
|
||||
|
|
|
@ -114,7 +114,7 @@ private:
|
|||
void insertDirectory(const QString &txt, qulonglong searchId, const DirDetails &dir);
|
||||
void setIconAndType(QTreeWidgetItem *item, const QString& filename);
|
||||
void downloadDirectory(const QTreeWidgetItem *item, const QString &base);
|
||||
void getSourceFriendsForHash(const std::string& hash,std::list<RsPeerId> &srcIds);
|
||||
void getSourceFriendsForHash(const RsFileHash &hash,std::list<RsPeerId> &srcIds);
|
||||
|
||||
/** the advanced search dialog instance */
|
||||
AdvancedSearchDialog * advSearchDialog;
|
||||
|
|
|
@ -528,7 +528,7 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
|||
continue;
|
||||
|
||||
RetroShareLink link;
|
||||
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.c_str())) {
|
||||
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) {
|
||||
urls.push_back(link) ;
|
||||
}
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
|||
else
|
||||
{
|
||||
RetroShareLink link;
|
||||
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.c_str())) {
|
||||
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) {
|
||||
urls.push_back(link) ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -878,9 +878,9 @@ void ChatWidget::fileHashingFinished(QList<HashedFile> hashedFiles)
|
|||
RetroShareLink link;
|
||||
|
||||
if(mDefaultExtraFileFlags & RS_FILE_REQ_ANONYMOUS_ROUTING)
|
||||
link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash));
|
||||
link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash.toStdString()));
|
||||
else
|
||||
link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash),QString::fromStdString(rsPeers->getOwnId().toStdString()));
|
||||
link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash.toStdString()),QString::fromStdString(rsPeers->getOwnId().toStdString()));
|
||||
|
||||
if (hashedFile.flag & HashedFile::Picture) {
|
||||
message += QString("<img src=\"file:///%1\" width=\"100\" height=\"100\">").arg(hashedFile.filepath);
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
QString filename;
|
||||
QString filepath;
|
||||
uint64_t size;
|
||||
std::string hash;
|
||||
RsFileHash hash;
|
||||
Flags flag;
|
||||
|
||||
public:
|
||||
|
|
|
@ -227,7 +227,7 @@ void RsCollectionDialog::download()
|
|||
if(!QDir(QApplication::applicationDirPath()).mkpath(cleanPath))
|
||||
QMessageBox::warning(NULL,QObject::tr("Unable to make path"),QObject::tr("Unable to make path:")+"<br> "+cleanPath) ;
|
||||
|
||||
rsFiles->FileRequest(dlinfo.name.toUtf8().constData(), dlinfo.hash.toUtf8().constData(), dlinfo.size, cleanPath.toUtf8().constData(), RS_FILE_REQ_ANONYMOUS_ROUTING, std::list<RsPeerId>());
|
||||
rsFiles->FileRequest(dlinfo.name.toUtf8().constData(), RsFileHash(dlinfo.hash.toStdString()), dlinfo.size, cleanPath.toUtf8().constData(), RS_FILE_REQ_ANONYMOUS_ROUTING, std::list<RsPeerId>());
|
||||
}
|
||||
else
|
||||
std::cerr<<"Skipping file : " << dlinfo.name.toStdString() << std::endl;
|
||||
|
|
|
@ -118,7 +118,7 @@ void RsCollectionFile::recursAddElements(QDomDocument& doc,const DirDetails& det
|
|||
QDomElement f = doc.createElement("File") ;
|
||||
|
||||
f.setAttribute(QString("name"),QString::fromUtf8(details.name.c_str())) ;
|
||||
f.setAttribute(QString("sha1"),QString::fromStdString(details.hash)) ;
|
||||
f.setAttribute(QString("sha1"),QString::fromStdString(details.hash.toStdString())) ;
|
||||
f.setAttribute(QString("size"),QString::number(details.count)) ;
|
||||
|
||||
e.appendChild(f) ;
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
const uint32_t AFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */
|
||||
|
||||
/** Constructor */
|
||||
AttachFileItem::AttachFileItem(const std::string& hash, const QString& name, uint64_t size, uint32_t flags,TransferRequestFlags tflags, const std::string& srcId)
|
||||
AttachFileItem::AttachFileItem(const RsFileHash& hash, const QString& name, uint64_t size, uint32_t flags,TransferRequestFlags tflags, const std::string& srcId)
|
||||
:QWidget(NULL), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId),mFlags(tflags)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
|
|
|
@ -47,9 +47,9 @@ class AttachFileItem : public QWidget, private Ui::AttachFileItem
|
|||
public:
|
||||
/** Default Constructor */
|
||||
AttachFileItem(const QString& localpath,TransferRequestFlags flags);
|
||||
AttachFileItem(const std::string& hash, const QString& name, uint64_t size, uint32_t flags,TransferRequestFlags tflags, const std::string& srcId);
|
||||
AttachFileItem(const RsFileHash& hash, const QString& name, uint64_t size, uint32_t flags,TransferRequestFlags tflags, const std::string& srcId);
|
||||
|
||||
const std::string& FileHash() { return mFileHash; }
|
||||
const RsFileHash& FileHash() { return mFileHash; }
|
||||
const QString& FileName() { return mFileName; }
|
||||
uint64_t FileSize() { return mFileSize; }
|
||||
const QString& FilePath() { return mPath; }
|
||||
|
@ -68,7 +68,7 @@ private:
|
|||
void Setup();
|
||||
|
||||
QString mPath;
|
||||
std::string mFileHash;
|
||||
RsFileHash mFileHash;
|
||||
QString mFileName;
|
||||
uint64_t mFileSize;
|
||||
std::string mSrcId;
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
const uint32_t SFI_DEFAULT_PERIOD = (30 * 3600 * 24); /* 30 Days */
|
||||
|
||||
/** Constructor */
|
||||
SubFileItem::SubFileItem(const std::string &hash, const std::string &name, const std::string &path, uint64_t size, uint32_t flags, const RsPeerId &srcId)
|
||||
SubFileItem::SubFileItem(const RsFileHash &hash, const std::string &name, const std::string &path, uint64_t size, uint32_t flags, const RsPeerId &srcId)
|
||||
:QWidget(NULL), mPath(path), mFileHash(hash), mFileName(name), mFileSize(size), mSrcId(srcId)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
|
@ -709,12 +709,12 @@ void SubFileItem::mediatype()
|
|||
|
||||
void SubFileItem::copyLink()
|
||||
{
|
||||
if (mFileName.empty() || mFileHash.empty()) {
|
||||
if (mFileName.empty() || mFileHash.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RetroShareLink link;
|
||||
if (link.createFile(QString::fromUtf8(mFileName.c_str()), mFileSize, QString::fromStdString(mFileHash))) {
|
||||
if (link.createFile(QString::fromUtf8(mFileName.c_str()), mFileSize, QString::fromStdString(mFileHash.toStdString()))) {
|
||||
QList<RetroShareLink> urls;
|
||||
urls.push_back(link);
|
||||
RSLinkClipboard::copyLinks(urls);
|
||||
|
|
|
@ -56,11 +56,11 @@ class SubFileItem : public QWidget, private Ui::SubFileItem
|
|||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
SubFileItem(const std::string &hash, const std::string &name, const std::string &path, uint64_t size, uint32_t flags, const RsPeerId &srcId);
|
||||
SubFileItem(const RsFileHash &hash, const std::string &name, const std::string &path, uint64_t size, uint32_t flags, const RsPeerId &srcId);
|
||||
|
||||
void smaller();
|
||||
|
||||
std::string FileHash() { return mFileHash; }
|
||||
RsFileHash FileHash() { return mFileHash; }
|
||||
std::string FileName() { return mFileName; }
|
||||
uint64_t FileSize() { return mFileSize; }
|
||||
std::string FilePath() { return mPath; }
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
void Setup();
|
||||
|
||||
std::string mPath;
|
||||
std::string mFileHash;
|
||||
RsFileHash mFileHash;
|
||||
std::string mFileName;
|
||||
uint64_t mFileSize;
|
||||
RsPeerId mSrcId;
|
||||
|
|
|
@ -745,7 +745,7 @@ void MessageComposer::addFile(const FileInfo &fileInfo)
|
|||
|
||||
item->setText(COLUMN_FILE_NAME, QString::fromUtf8(fileInfo.fname.c_str()));
|
||||
item->setText(COLUMN_FILE_SIZE, misc::friendlyUnit(fileInfo.size));
|
||||
item->setText(COLUMN_FILE_HASH, QString::fromStdString(fileInfo.hash));
|
||||
item->setText(COLUMN_FILE_HASH, QString::fromStdString(fileInfo.hash.toStdString()));
|
||||
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
|
||||
item->setCheckState(COLUMN_FILE_CHECKED, Qt::Checked);
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ void MessageWidget::fill(const std::string &msgId)
|
|||
QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||
item->setText(COLUMN_FILE_NAME, QString::fromUtf8(it->fname.c_str()));
|
||||
item->setText(COLUMN_FILE_SIZE, QString::number(it->size));
|
||||
item->setText(COLUMN_FILE_HASH, QString::fromStdString(it->hash));
|
||||
item->setText(COLUMN_FILE_HASH, QString::fromStdString(it->hash.toStdString()));
|
||||
|
||||
/* add to the list */
|
||||
items.append(item);
|
||||
|
|
|
@ -805,7 +805,7 @@ void NotifyQt::UpdateGUI()
|
|||
if (popupflags & RS_POPUP_DOWNLOAD)
|
||||
{
|
||||
/* id = file hash */
|
||||
toaster = new Toaster(new DownloadToaster(id, QString::fromUtf8(title.c_str())));
|
||||
toaster = new Toaster(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str())));
|
||||
}
|
||||
break;
|
||||
case RS_POPUP_CHAT:
|
||||
|
@ -944,7 +944,7 @@ void NotifyQt::testToaster(uint notifyFlags, /*RshareSettings::enumToasterPositi
|
|||
toaster = new Toaster(new OnlineToaster(id));
|
||||
break;
|
||||
case RS_POPUP_DOWNLOAD:
|
||||
toaster = new Toaster(new DownloadToaster(id.toStdString(), title));
|
||||
toaster = new Toaster(new DownloadToaster(RsFileHash::random(), title));
|
||||
break;
|
||||
case RS_POPUP_CHAT:
|
||||
toaster = new Toaster(new ChatToaster(id, message));
|
||||
|
|
|
@ -47,7 +47,8 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags)
|
|||
{
|
||||
std::cerr << " Adding new page." << std::endl;
|
||||
|
||||
std::string file_name, file_hash, error_string ;
|
||||
std::string file_name, error_string ;
|
||||
RsFileHash file_hash ;
|
||||
uint32_t status ;
|
||||
uint32_t svn_revision ;
|
||||
|
||||
|
@ -104,7 +105,7 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WindowFlags flags)
|
|||
|
||||
PluginItem *item = new PluginItem(pluginVersion, i,pluginTitle,pluginDescription,status_string,
|
||||
QString::fromStdString(file_name),
|
||||
QString::fromStdString(file_hash),QString::fromStdString(error_string),
|
||||
QString::fromStdString(file_hash.toStdString()),QString::fromStdString(error_string),
|
||||
plugin_icon) ;
|
||||
|
||||
ui._pluginsLayout->insertWidget(0,item) ;
|
||||
|
@ -182,14 +183,14 @@ void PluginsPage::enablePlugin(const QString& hash)
|
|||
{
|
||||
std::cerr << "Switching status of plugin " << hash.toStdString() << " to enable" << std::endl;
|
||||
|
||||
rsPlugins->enablePlugin(hash.toStdString()) ;
|
||||
rsPlugins->enablePlugin(RsFileHash(hash.toStdString()) );
|
||||
}
|
||||
|
||||
void PluginsPage::disablePlugin(const QString& hash)
|
||||
{
|
||||
std::cerr << "Switching status of plugin " << hash.toStdString() << " to disable " << std::endl;
|
||||
|
||||
rsPlugins->disablePlugin(hash.toStdString()) ;
|
||||
rsPlugins->disablePlugin(RsFileHash(hash.toStdString())) ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
DownloadToaster::DownloadToaster(const std::string &hash, const QString &name) : QWidget(NULL)
|
||||
DownloadToaster::DownloadToaster(const RsFileHash &hash, const QString &name) : QWidget(NULL)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
|
|
|
@ -24,19 +24,20 @@
|
|||
#define DOWNLOADTOASTER_H
|
||||
|
||||
#include "ui_DownloadToaster.h"
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
class DownloadToaster : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DownloadToaster(const std::string &hash, const QString &name);
|
||||
DownloadToaster(const RsFileHash &hash, const QString &name);
|
||||
|
||||
private slots:
|
||||
void play();
|
||||
|
||||
private:
|
||||
std::string fileHash;
|
||||
RsFileHash fileHash;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::DownloadToaster ui;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue