mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-19 06:20:44 -04:00
fixed compilation. Added missing functions, left blank
This commit is contained in:
parent
5b9fd74d85
commit
538a11fd14
5 changed files with 221 additions and 23 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "file_sharing/directory_updater.h"
|
||||
|
||||
#include "retroshare/rsids.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
#define P3FILELISTS_DEBUG() std::cerr << "p3FileLists: "
|
||||
|
||||
|
@ -13,8 +14,6 @@ static const uint32_t P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED = 0x0001 ;
|
|||
static const uint32_t P3FILELISTS_UPDATE_FLAG_LOCAL_DIRS_CHANGED = 0x0002 ;
|
||||
static const uint32_t P3FILELISTS_UPDATE_FLAG_REMOTE_DIRS_CHANGED = 0x0004 ;
|
||||
|
||||
#define NOT_IMPLEMENTED() { std::cerr << __PRETTY_FUNCTION__ << ": not implemented!" << std::endl; }
|
||||
|
||||
p3FileDatabase::p3FileDatabase(p3ServiceControl *mpeers)
|
||||
: mServCtrl(mpeers), mFLSMtx("p3FileLists")
|
||||
{
|
||||
|
@ -41,6 +40,10 @@ void p3FileDatabase::getSharedDirectories(std::list<SharedDirInfo>& shared_dirs)
|
|||
{
|
||||
mLocalSharedDirs->getSharedDirectoryList(shared_dirs) ;
|
||||
}
|
||||
void p3FileDatabase::updateShareFlags(const SharedDirInfo& info)
|
||||
{
|
||||
mLocalSharedDirs->updateShareFlags(info) ;
|
||||
}
|
||||
|
||||
p3FileDatabase::~p3FileDatabase()
|
||||
{
|
||||
|
@ -86,12 +89,26 @@ int p3FileDatabase::tick()
|
|||
// cleanup
|
||||
// - remove/delete shared file lists for people who are not friend anymore
|
||||
// -
|
||||
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void p3FileDatabase::startThreads()
|
||||
{
|
||||
std::cerr << "Starting hash cache thread..." ;
|
||||
|
||||
mHashCache->start();
|
||||
}
|
||||
void p3FileDatabase::stopThreads()
|
||||
{
|
||||
std::cerr << "Stopping hash cache thread..." ; std::cerr.flush() ;
|
||||
|
||||
mHashCache->fullstop();
|
||||
|
||||
std::cerr << "Done." << std::endl;
|
||||
}
|
||||
|
||||
void p3FileDatabase::tickWatchers()
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
|
@ -156,7 +173,7 @@ void p3FileDatabase::cleanup()
|
|||
{
|
||||
P3FILELISTS_DEBUG() << " adding missing remote dir entry for friend " << *it << std::endl;
|
||||
|
||||
mRemoteDirectories[*it] = new RemoteDirectoryStorage(*it);
|
||||
mRemoteDirectories[*it] = new RemoteDirectoryStorage(makeRemoteFileName(*it));
|
||||
|
||||
mUpdateFlags |= P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED ;
|
||||
}
|
||||
|
@ -165,11 +182,22 @@ void p3FileDatabase::cleanup()
|
|||
IndicateConfigChanged();
|
||||
}
|
||||
|
||||
std::string p3FileDatabase::makeRemoteFileName(const RsPeerId& pid) const
|
||||
{
|
||||
#warning we should use the default paths here. Ask p3config
|
||||
return "dirlist_"+pid.toStdString()+".txt" ;
|
||||
}
|
||||
|
||||
int p3FileDatabase::RequestDirDetails(void *ref, DirDetails&, FileSearchFlags) const
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
int p3FileDatabase::RequestDirDetails(const RsPeerId& uid,const std::string& path, DirDetails &details)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
int p3FileDatabase::RequestDirDetails(const std::string& path, DirDetails &details) const
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
|
@ -189,7 +217,6 @@ bool p3FileDatabase::inDirectoryCheck()
|
|||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void p3FileDatabase::setWatchPeriod(uint32_t seconds)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
|
@ -221,3 +248,94 @@ void p3FileDatabase::setRememberHashCache(bool)
|
|||
{
|
||||
NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
bool p3FileDatabase::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
|
||||
{
|
||||
std::list<EntryIndex> firesults;
|
||||
mLocalSharedDirs->searchHash(hash,firesults) ;
|
||||
|
||||
NOT_IMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
|
||||
int p3FileDatabase::SearchKeywords(const std::list<std::string>& keywords, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& client_peer_id)
|
||||
{
|
||||
std::list<EntryIndex> firesults;
|
||||
mLocalSharedDirs->searchTerms(keywords,firesults) ;
|
||||
|
||||
return filterResults(firesults,results,flags,client_peer_id) ;
|
||||
}
|
||||
int p3FileDatabase::SearchBoolExp(Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& client_peer_id) const
|
||||
{
|
||||
std::list<EntryIndex> firesults;
|
||||
mLocalSharedDirs->searchBoolExp(exp,firesults) ;
|
||||
|
||||
return filterResults(firesults,results,flags,client_peer_id) ;
|
||||
}
|
||||
bool p3FileDatabase::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
{
|
||||
if(hintflags & RS_FILE_HINTS_LOCAL)
|
||||
{
|
||||
std::list<EntryIndex> res;
|
||||
mLocalSharedDirs->searchHash(hash,res) ;
|
||||
|
||||
if(res.empty())
|
||||
return false;
|
||||
|
||||
EntryIndex indx = *res.begin() ; // no need to report dupicates
|
||||
|
||||
mLocalSharedDirs->getFileInfo(indx,info) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int p3FileDatabase::filterResults(const std::list<EntryIndex>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const RsPeerId& peer_id) const
|
||||
{
|
||||
results.clear();
|
||||
|
||||
#ifdef P3FILELISTS_DEBUG
|
||||
if((flags & ~RS_FILE_HINTS_PERMISSION_MASK) > 0)
|
||||
std::cerr << "(EE) ***** FileIndexMonitor:: Flags ERROR in filterResults!!" << std::endl;
|
||||
#endif
|
||||
/* translate/filter results */
|
||||
|
||||
for(std::list<EntryIndex>::const_iterator rit(firesults.begin()); rit != firesults.end(); ++rit)
|
||||
{
|
||||
DirDetails cdetails ;
|
||||
RequestDirDetails ((void*)*rit,cdetails,FileSearchFlags(0u));
|
||||
#ifdef P3FILELISTS_DEBUG
|
||||
std::cerr << "Filtering candidate " << (*rit) << ", flags=" << cdetails.flags << ", peer=" << peer_id ;
|
||||
#endif
|
||||
|
||||
if(!peer_id.isNull())
|
||||
{
|
||||
FileSearchFlags permission_flags = rsPeers->computePeerPermissionFlags(peer_id,cdetails.flags,cdetails.parent_groups) ;
|
||||
|
||||
if (cdetails.type == DIR_TYPE_FILE && ( permission_flags & flags ))
|
||||
{
|
||||
cdetails.id.clear() ;
|
||||
results.push_back(cdetails);
|
||||
#ifdef P3FILELISTS_DEBUG
|
||||
std::cerr << ": kept" << std::endl ;
|
||||
#endif
|
||||
}
|
||||
#ifdef P3FILELISTS_DEBUG
|
||||
else
|
||||
std::cerr << ": discarded" << std::endl ;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
results.push_back(cdetails);
|
||||
}
|
||||
|
||||
return !results.empty() ;
|
||||
}
|
||||
|
||||
bool p3FileDatabase::convertSharedFilePath(const std::string& path,std::string& fullpath)
|
||||
{
|
||||
return mLocalSharedDirs->convertSharedFilePath(path,fullpath) ;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue