Merged branch that provide group-based file permissions.

Now users can sort peers into groups in the friend list, and attribute flags and parent groups to the
directories in the share manager.

Flags are B-B-N, meaning in order:
- browsable for peers in the parent groups
- browsable for everyone
- network wide for everyone
Backward compatibility makes previously BN flags been interpreted as -BN, meaning browsable/network wide for everyone.

Be careful with this new feature. It has been tested, but it's a bit early to rely on it for highly sensitive data.

The merge also includes a significant improvement of the naming of flags with incompatible types
which should sort out some existing bugs as well, since inconsistencies in flag usage have been
found during the process.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5787 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-11-07 20:03:16 +00:00
commit 6edb9eb4f8
64 changed files with 1389 additions and 824 deletions

View File

@ -66,7 +66,7 @@
//#define DISABLE_BAD_PEER_FILTER 1
//#define USE_HISTORY 1
#define USE_HISTORY 1
#define HISTORY_PERIOD 60
@ -806,10 +806,10 @@ void bdNode::msgout_ping(bdId *id, bdToken *transId)
// THIS IS CRASHING HISTORY.
// LIKELY ID is not always valid!
// Either PotentialPeers or Out-Of-Date Peers.
//registerOutgoingMsg(id, transId, BITDHT_MSG_TYPE_PING);
registerOutgoingMsg(id, transId, BITDHT_MSG_TYPE_PING);
bdId dupId(*id);
registerOutgoingMsg(&dupId, transId, BITDHT_MSG_TYPE_PING);
//bdId dupId(*id);
//registerOutgoingMsg(&dupId, transId, BITDHT_MSG_TYPE_PING);
/* create string */
char msg[10240];

View File

@ -92,38 +92,70 @@ bool CacheSource::loadLocalCache(const CacheData &data)
}
/* control Caches available */
bool CacheSource::refreshCache(const CacheData &data)
bool CacheSource::refreshCache(const CacheData &data,const std::list<std::string>& destination_peers)
{
lockData(); /* LOCK MUTEX */
bool ret = false;
if (data.cid.type == getCacheType())
{
int subid = 0;
if (isMultiCache())
{
subid = data.cid.subid;
}
RsStackMutex mtx(cMutex); /* LOCK MUTEX */
/* Backup the old Caches */
CacheSet::const_iterator it;
if (caches.end() != (it = caches.find(subid)))
if (data.cid.type == getCacheType())
{
mOldCaches[it->second.hash] = it->second;
}
int subid = 0;
if (isMultiCache())
{
subid = data.cid.subid;
}
/* store new cache */
caches[subid] = data;
ret = true;
/* Backup the old Caches */
CacheSet::const_iterator it;
if (caches.end() != (it = caches.find(subid)))
{
mOldCaches[it->second.hash] = it->second;
}
/* store new cache */
caches[subid] = data;
ret = true;
}
}
unlockData(); /* UNLOCK MUTEX */
if (mStrapper) /* allow testing without full feedback */
mStrapper->refreshCache(data,destination_peers);
return ret;
}
bool CacheSource::refreshCache(const CacheData &data)
{
bool ret = false;
{
RsStackMutex mtx(cMutex); /* LOCK MUTEX */
if (data.cid.type == getCacheType())
{
int subid = 0;
if (isMultiCache())
{
subid = data.cid.subid;
}
/* Backup the old Caches */
CacheSet::const_iterator it;
if (caches.end() != (it = caches.find(subid)))
{
mOldCaches[it->second.hash] = it->second;
}
/* store new cache */
caches[subid] = data;
ret = true;
}
}
if (mStrapper) /* allow testing without full feedback */
mStrapper->refreshCache(data);
return ret;
}
}
bool CacheSource::clearCache(CacheId id)
{
lockData(); /* LOCK MUTEX */
@ -567,6 +599,26 @@ void CacheStrapper::statusChange(const std::list<pqipeer> &plist)
/**************** from pqimonclient ********************/
void CacheStrapper::refreshCache(const CacheData &data,const std::list<std::string>& destination_peers)
{
/* we've received an update
* send to all online peers + self
*/
#ifdef CS_DEBUG
std::cerr << "CacheStrapper::refreshCache() : " << data << std::endl;
#endif
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
for(std::list<std::string>::const_iterator it = destination_peers.begin(); it != destination_peers.end(); ++it)
{
#ifdef CS_DEBUG
std::cerr << "CacheStrapper::refreshCache() Send To: " << *it << std::endl;
#endif
mCacheUpdates.push_back(std::make_pair(*it, data));
}
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
}
void CacheStrapper::refreshCache(const CacheData &data)
{
@ -578,26 +630,12 @@ void CacheStrapper::refreshCache(const CacheData &data)
#endif
std::list<std::string> ids;
std::list<std::string>::iterator it;
mLinkMgr->getOnlineList(ids);
ids.push_back(mLinkMgr->getOwnId()) ;
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
for(it = ids.begin(); it != ids.end(); it++)
{
#ifdef CS_DEBUG
std::cerr << "CacheStrapper::refreshCache() Send To: " << *it << std::endl;
#endif
mCacheUpdates.push_back(std::make_pair(*it, data));
}
mCacheUpdates.push_back(std::make_pair(mLinkMgr->getOwnId(), data));
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
refreshCache(data,ids) ;
}
void CacheStrapper::refreshCacheStore(const CacheData & /* data */ )
{
/* indicate to save data */

View File

@ -181,7 +181,8 @@ class CacheSource
virtual bool loadLocalCache(const CacheData &data);
/* control Caches available */
bool refreshCache(const CacheData &data);
bool refreshCache(const CacheData &data,const std::list<std::string>& destination_peers);
bool refreshCache(const CacheData &data);
bool clearCache(CacheId id);
/* get private data */
@ -394,11 +395,12 @@ virtual void statusChange(const std::list<pqipeer> &plist);
/* Feedback from CacheSources */
/*!
* send data to peers online and selfe
* send data to peers online and self
* @param data
*
*/
void refreshCache(const CacheData &data);
void refreshCache(const CacheData &data,const std::list<std::string>& destination_peers); // specify a particular list of destination peers (self not added!)
/*!
* forces config savelist

View File

@ -30,6 +30,7 @@
#include "serialiser/rsserviceids.h"
#include "retroshare/rsiface.h"
#include "retroshare/rsnotify.h"
#include "retroshare/rspeers.h"
#include "util/folderiterator.h"
#include <errno.h>
@ -266,7 +267,7 @@ FileIndexMonitor::~FileIndexMonitor()
/* Data cleanup - TODO */
}
int FileIndexMonitor::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags)
int FileIndexMonitor::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const std::string& peer_id)
{
results.clear();
std::list<FileEntry *> firesults;
@ -276,10 +277,10 @@ int FileIndexMonitor::SearchKeywords(std::list<std::string> keywords, std::list<
fi.searchTerms(keywords, firesults);
}
return filterResults(firesults,results,flags) ;
return filterResults(firesults,results,flags,peer_id) ;
}
int FileIndexMonitor::SearchBoolExp(Expression *exp, std::list<DirDetails>& results,uint32_t flags) const
int FileIndexMonitor::SearchBoolExp(Expression *exp, std::list<DirDetails>& results,FileSearchFlags flags,const std::string& peer_id) const
{
results.clear();
std::list<FileEntry *> firesults;
@ -289,38 +290,50 @@ int FileIndexMonitor::SearchBoolExp(Expression *exp, std::list<DirDetails>& resu
fi.searchBoolExp(exp, firesults);
}
return filterResults(firesults,results,flags) ;
return filterResults(firesults,results,flags,peer_id) ;
}
int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,uint32_t flags) const
int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const std::string& peer_id) const
{
#ifdef 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<FileEntry*>::const_iterator rit(firesults.begin()); rit != firesults.end(); ++rit)
{
DirDetails cdetails ;
RequestDirDetails (*rit,cdetails,0);
RequestDirDetails (*rit,cdetails,FileSearchFlags(0u));
#ifdef FIM_DEBUG
std::cerr << "Filtering candidate " << (*rit)->name << ", flags=" << cdetails.flags ;
std::cerr << "Filtering candidate " << (*rit)->name << ", flags=" << cdetails.flags << ", peer=" << peer_id ;
#endif
if (cdetails.type == DIR_TYPE_FILE && ( cdetails.flags & flags & (DIR_FLAGS_BROWSABLE | DIR_FLAGS_NETWORK_WIDE)) > 0)
if(!peer_id.empty())
{
cdetails.id = "Local";
results.push_back(cdetails);
FileSearchFlags permission_flags = rsPeers->computePeerPermissionFlags(peer_id,cdetails.flags,cdetails.parent_groups) ;
if (cdetails.type == DIR_TYPE_FILE && ( permission_flags & flags ))
{
cdetails.id = "Local";
results.push_back(cdetails);
#ifdef FIM_DEBUG
std::cerr << ": kept" << std::endl ;
std::cerr << ": kept" << std::endl ;
#endif
}
#ifdef FIM_DEBUG
else
std::cerr << ": discarded" << std::endl ;
#endif
}
#ifdef FIM_DEBUG
else
std::cerr << ": discarded" << std::endl ;
#endif
results.push_back(cdetails);
}
return !results.empty() ;
}
bool FileIndexMonitor::findLocalFile(std::string hash,uint32_t hint_flags, std::string &fullpath, uint64_t &size) const
bool FileIndexMonitor::findLocalFile(std::string hash,FileSearchFlags hint_flags, const std::string& 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;
@ -340,12 +353,16 @@ bool FileIndexMonitor::findLocalFile(std::string hash,uint32_t hint_flags, std::
FileEntry *fe = results.front();
DirEntry *de = fe->parent; /* all files must have a valid parent! */
uint32_t share_flags = locked_findShareFlags(fe) ;
locked_findShareFlagsAndParentGroups(fe,storage_flags,parent_groups) ;
// turn share flags into hint flags
FileSearchFlags shflh = peer_id.empty()?(RS_FILE_HINTS_BROWSABLE|RS_FILE_HINTS_NETWORK_WIDE):rsPeers->computePeerPermissionFlags(peer_id,storage_flags,parent_groups) ;
#ifdef FIM_DEBUG
std::cerr << "FileIndexMonitor::findLocalFile: Filtering candidate " << fe->name << ", flags=" << share_flags << ", hint_flags=" << hint_flags << std::endl ;
std::cerr << "FileIndexMonitor::findLocalFile: Filtering candidate " << fe->name << ", flags=" << storage_flags << ", hint_flags=" << hint_flags << ", peer_id = " << peer_id << std::endl ;
#endif
if((share_flags & hint_flags & (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE)) > 0)
if(peer_id.empty() || (shflh & hint_flags))
{
#ifdef FIM_DEBUG
std::cerr << "FileIndexMonitor::findLocalFile() Found Name: " << fe->name << std::endl;
@ -423,7 +440,11 @@ bool FileIndexMonitor::loadLocalCache(const CacheData &data) /* called with sto
/* More error checking needed here! */
std::string name = data.name ; // this trick allows to load the complete file. Not the one being shared.
std::string name = data.name ;
name[name.length()-4] = 'r' ;// this trick allows to load the complete file. Not the one being shared.
name[name.length()-3] = 's' ;
name[name.length()-2] = 'f' ;
name[name.length()-1] = 'c' ;
if ((ok = fi.loadIndex(data.path + '/' + name, "", data.size)))
@ -445,17 +466,18 @@ bool FileIndexMonitor::loadLocalCache(const CacheData &data) /* called with sto
fi.updateMaxModTime() ;
}
#ifdef REMOVED
if (ok)
{
return updateCache(data);
}
#endif
return false;
}
bool FileIndexMonitor::updateCache(const CacheData &data) /* we call this one */
bool FileIndexMonitor::updateCache(const CacheData &data,const std::list<std::string>& destination_peers) /* we call this one */
{
return refreshCache(data);
return refreshCache(data,destination_peers);
}
@ -514,13 +536,13 @@ void FileIndexMonitor::run()
updateCycle();
#ifdef FIM_DEBUG
{
RsStackMutex mtx(fiMutex) ;
std::cerr <<"*********** FileIndex **************" << std::endl ;
fi.printFileIndex(std::cerr) ;
std::cerr <<"************** END *****************" << std::endl ;
std::cerr << std::endl ;
}
// {
// RsStackMutex mtx(fiMutex) ;
// std::cerr <<"*********** FileIndex **************" << std::endl ;
// fi.printFileIndex(std::cerr) ;
// std::cerr <<"************** END *****************" << std::endl ;
// std::cerr << std::endl ;
// }
#endif
}
}
@ -801,7 +823,7 @@ void FileIndexMonitor::updateCycle()
#ifdef FIM_DEBUG
/* print out the new directory structure */
fi.printFileIndex(std::cerr);
// fi.printFileIndex(std::cerr);
#endif
/* now if we have changed things -> restore file/hash it/and
* tell the CacheSource
@ -986,67 +1008,107 @@ void FileIndexMonitor::locked_saveFileIndexes()
std::string path = getCacheDir();
// Two files are saved: one with only browsable dirs, which will be shared by the cache system,
// and one with the complete file collection.
// Multiple files are saved: for every kind of peers, the set of browsable files will be different. A specific file is
// prepared for all situations, and shared by all peers having the same situation.
//
// A complete file collection is also saved, and serves as memory for the FileIndexMonitor system.
//
std::string tmpname_browsable;
rs_sprintf(tmpname_browsable, "fc-own-%ld.rsfb", time(NULL));
std::string fname_browsable = path + "/" + tmpname_browsable;
std::string tmpname_total;
rs_sprintf(tmpname_total, "fc-own-%ld.rsfc", time(NULL));
std::string fname_total = path + "/" + tmpname_total;
#ifdef FIM_DEBUG
std::cerr << "FileIndexMonitor::updateCycle() FileIndex modified ... updating";
std::cerr << std::endl;
std::cerr << "FileIndexMonitor::updateCycle() saving browsable file list to: " << fname_browsable << std::endl ;
std::cerr << "FileIndexMonitor::updateCycle() saving total file list to to: " << fname_total << std::endl ;
std::cerr << "FileIndexMonitor::updateCycle() FileIndex modified ... updating" << std::endl;
#endif
// Make for each peer the list of forbidden shared directories. Make a separate cache file for each different set.
// 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<std::string> online_ids ;
rsPeers->getOnlineList(online_ids);
std::string calchash;
uint64_t size;
std::map<std::set<std::string>, std::list<std::string> > peers_per_directory_combination ;
std::cerr << "About to save, with the following restrictions:" << std::endl ;
std::set<std::string> forbidden_dirs ;
for(std::map<std::string,SharedDirInfo>::const_iterator it(directoryMap.begin());it!=directoryMap.end();++it)
for(std::list<std::string>::const_iterator it(online_ids.begin());it!=online_ids.end();++it)
{
std::cerr << " dir=" << it->first << " : " ;
if((it->second.shareflags & RS_FILE_HINTS_BROWSABLE) == 0)
std::cerr << "About to save, with the following restrictions:" << std::endl ;
std::cerr << "Peer : " << *it << std::endl;
std::set<std::string> forbidden_dirs ;
for(std::map<std::string,SharedDirInfo>::const_iterator dit(directoryMap.begin());dit!=directoryMap.end();++dit)
{
std::cerr << "forbidden" << std::endl;
forbidden_dirs.insert(it->first) ;
}
else
std::cerr << "autorized" << std::endl;
}
uint64_t sizetmp ;
fi.saveIndex(fname_total, calchash, sizetmp,std::set<std::string>()); // save all files
fi.saveIndex(fname_browsable, calchash, size,forbidden_dirs); // save only browsable files
if(size > 0)
{
#ifdef FIM_DEBUG
std::cerr << "FileIndexMonitor::updateCycle() saved with hash:" << calchash;
std::cerr << std::endl;
std::cerr << " dir=" << dit->first << ", " ;
std::cerr << "parent groups: " ;
for(std::list<std::string>::const_iterator mit(dit->second.parent_groups.begin());mit!=dit->second.parent_groups.end();++mit)
std::cerr << (*mit) << ", " ;
std::cerr << std::endl;;
#endif
/* should clean up the previous cache.... */
FileSearchFlags permission_flags = rsPeers->computePeerPermissionFlags(*it,dit->second.shareflags,dit->second.parent_groups) ;
/* flag as new info */
CacheData data;
data.pid = fi.root->id;
data.cid.type = getCacheType();
data.cid.subid = 0;
data.path = path;
data.name = tmpname_browsable;
data.hash = calchash;
data.size = size;
data.recvd = time(NULL);
if(!(permission_flags & RS_FILE_HINTS_BROWSABLE))
{
std::cerr << "forbidden" << std::endl;
forbidden_dirs.insert(dit->first) ;
}
else
std::cerr << "autorized" << std::endl;
}
updateCache(data);
peers_per_directory_combination[forbidden_dirs].push_back(*it) ;
}
std::string ownId = rsPeers->getOwnId() ;
peers_per_directory_combination[std::set<std::string>()].push_back(ownId) ; // add full configuration to self, i.e. no forbidden directories.
int n=0 ;
time_t now = time(NULL) ;
for(std::map<std::set<std::string>, std::list<std::string> >::const_iterator it(peers_per_directory_combination.begin());
it!=peers_per_directory_combination.end();++it,++n)
{
std::string tmpname_browsable;
if(it->first.empty())
rs_sprintf(tmpname_browsable, "fc-own-%ld.rsfc",now,n);
else
rs_sprintf(tmpname_browsable, "fc-own-%ld.%04d",now,n);
std::string fname_browsable = path + "/" + tmpname_browsable;
#ifdef FIM_DEBUG
std::cerr << "Sending file list: " << std::endl;
std::cerr << " filename : " << tmpname_browsable << std::endl;
std::cerr << " to peers : " << std::endl;
for(std::list<std::string>::const_iterator itt(it->second.begin());itt!= it->second.end();++itt)
std::cerr << " " << *itt << std::endl;
std::cerr << " forbidden : " << std::endl;
for(std::set<std::string>::const_iterator itt(it->first.begin());itt!= it->first.end();++itt)
std::cerr << " " << *itt << std::endl;
#endif
std::string hash ;
uint64_t size ;
fi.saveIndex(fname_browsable, hash, size,it->first); // save only browsable files
if(size > 0)
{
#ifdef FIM_DEBUG
std::cerr << "FileIndexMonitor::updateCycle() saved with hash:" << hash << std::endl;
#endif
/* should clean up the previous cache.... */
/* flag as new info */
CacheData data;
data.pid = fi.root->id;
data.cid.type = getCacheType();
data.cid.subid = 0;
data.path = path;
data.name = tmpname_browsable;
data.hash = hash;
data.size = size;
data.recvd = time(NULL);
updateCache(data,it->second);
}
}
#ifdef FIM_DEBUG
@ -1073,6 +1135,7 @@ void FileIndexMonitor::updateShareFlags(const SharedDirInfo& dir)
{
std::cerr << "** Updating to " << (*it).shareflags << "!!" << std::endl ;
(*it).shareflags = dir.shareflags ;
(*it).parent_groups = dir.parent_groups ;
break ;
}
}
@ -1084,6 +1147,7 @@ void FileIndexMonitor::updateShareFlags(const SharedDirInfo& dir)
{
std::cerr << "** Updating from " << it->second.shareflags << "!!" << std::endl ;
(*it).second.shareflags = dir.shareflags ;
(*it).second.parent_groups = dir.parent_groups ;
fimods = true ;
break ;
}
@ -1295,7 +1359,7 @@ uint32_t FileIndexMonitor::getType(void *ref) const
return fi.getType(ref) ;
}
int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) const
int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) const
{
/* remove unused parameter warnings */
(void) flags;
@ -1335,7 +1399,7 @@ int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, uint32_t
details.hash = "";
details.path = "root";
details.age = 0;
details.flags = 0;
details.flags.clear() ;
details.min_age = 0 ;
return true ;
@ -1353,18 +1417,15 @@ int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, uint32_t
if(ref != NULL)
{
FileEntry *file = (FileEntry *) ref;
uint32_t share_flags = locked_findShareFlags(file) ;
details.flags |= (( (share_flags & RS_FILE_HINTS_BROWSABLE )>0)?DIR_FLAGS_BROWSABLE :0) ;
details.flags |= (( (share_flags & RS_FILE_HINTS_NETWORK_WIDE)>0)?DIR_FLAGS_NETWORK_WIDE:0) ;
locked_findShareFlagsAndParentGroups(file,details.flags,details.parent_groups) ;
}
return true ;
}
uint32_t FileIndexMonitor::locked_findShareFlags(FileEntry *file) const
void FileIndexMonitor::locked_findShareFlagsAndParentGroups(FileEntry *file,FileStorageFlags& flags,std::list<std::string>& parent_groups) const
{
uint32_t flags = 0 ;
flags.clear() ;
static const FileStorageFlags PERMISSION_MASK = DIR_FLAGS_BROWSABLE_OTHERS | DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | DIR_FLAGS_NETWORK_WIDE_GROUPS ;
DirEntry *dir = dynamic_cast<DirEntry*>(file) ;
if(dir == NULL)
@ -1384,13 +1445,16 @@ uint32_t FileIndexMonitor::locked_findShareFlags(FileEntry *file) const
if(it == directoryMap.end())
std::cerr << "*********** ERROR *********** In " << __PRETTY_FUNCTION__ << std::endl ;
else
flags = it->second.shareflags & (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE) ;
{
flags = it->second.shareflags ;
flags &= PERMISSION_MASK ;
flags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // Disabling this flag for now, because it has inconsistent effects.
parent_groups = it->second.parent_groups ;
}
#ifdef FIM_DEBUG2
std::cerr << "flags = " << flags << std::endl ;
#endif
}
return flags ;
}

View File

@ -111,10 +111,12 @@ class FileIndexMonitor: public CacheSource, public RsThread
virtual ~FileIndexMonitor();
/* external interface for filetransfer */
bool findLocalFile(std::string hash,uint32_t f, std::string &fullpath, uint64_t &size) const;
int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags) ;
int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,uint32_t flags) const ;
int filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,uint32_t flags) const ;
bool findLocalFile(std::string hash,FileSearchFlags flags,const std::string& 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 std::string& peer_id) ;
int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,FileSearchFlags flags,const std::string& peer_id) const ;
int filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,FileSearchFlags flags,const std::string& peer_id) const ;
/* external interface for local access to files */
@ -124,7 +126,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
/* Interacting with CacheSource */
/* overloaded from CacheSource */
virtual bool loadLocalCache(const CacheData &data); /* called with stored data */
bool updateCache(const CacheData &data); /* we call when we have a new cache for others */
bool updateCache(const CacheData &data,const std::list<std::string>& dest_peers); /* we call when we have a new cache for others */
/* the FileIndexMonitor inner workings */
@ -134,7 +136,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
void updateCycle();
// Interface for browsing dir hirarchy
int RequestDirDetails(void*, DirDetails&, uint32_t) const ;
int RequestDirDetails(void*, DirDetails&, FileSearchFlags) const ;
uint32_t getType(void*) const ;
int RequestDirDetails(const std::string& path, DirDetails &details) const ;
@ -169,7 +171,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
void locked_saveFileIndexes() ;
// Finds the share flags associated with this file entry.
uint32_t locked_findShareFlags(FileEntry *fe) const ;
void locked_findShareFlagsAndParentGroups(FileEntry *fe,FileStorageFlags& shareflags,std::list<std::string>& parent_groups) const ;
std::string locked_findRealRoot(std::string base) const;

View File

@ -1346,7 +1346,7 @@ bool FileIndex::extractData(void *ref,DirDetails& details)
details.ref = file;
details.hash = file->hash;
details.age = now - file->modtime;
details.flags = 0;//file->pop;
details.flags.clear() ;
/* find parent pointer, and row */
details.parent = file->parent ;

View File

@ -101,6 +101,7 @@ virtual int print(std::string &out);
/* References for easy manipulation */
DirEntry *parent;
int row;
std::list<std::string> parent_groups ;
};
/******************************************************************************************

View File

@ -23,6 +23,7 @@
#include "dbase/fistore.h"
#include "retroshare/rsexpr.h"
#include "retroshare/rsfiles.h"
#include "serialiser/rsserviceids.h"
#include "pqi/p3peermgr.h"
@ -200,7 +201,7 @@ int FileIndexStore::RequestDirDetails(const std::string& uid, const std::string&
#endif
}
int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) const
int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) const
{
/* remove unused parameter warnings */
(void) flags;
@ -258,7 +259,7 @@ int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t f
details.path = "";
details.count = indices.size();
details.age = 0;
details.flags = 0;
details.flags.clear() ;
details.min_age = 0;
unlockData();
@ -329,7 +330,7 @@ int FileIndexStore::SearchHash(std::string hash, std::list<FileDetail> &results)
}
int FileIndexStore::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags) const
int FileIndexStore::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags) const
{
lockData();
std::map<RsPeerId, FileIndex *>::const_iterator pit;
@ -341,7 +342,7 @@ int FileIndexStore::SearchKeywords(std::list<std::string> keywords, std::list<Di
#ifdef FIS_DEBUG
std::cerr << "FileIndexStore::SearchKeywords()" << std::endl;
#endif
if(flags & DIR_FLAGS_REMOTE)
if(flags & RS_FILE_HINTS_REMOTE)
for(pit = indices.begin(); pit != indices.end(); pit++)
{
firesults.clear();
@ -359,7 +360,7 @@ int FileIndexStore::SearchKeywords(std::list<std::string> keywords, std::list<Di
}
}
if(flags & DIR_FLAGS_LOCAL)
if(flags & RS_FILE_HINTS_LOCAL)
if (localindex)
{
firesults.clear();

View File

@ -75,7 +75,7 @@ virtual int loadCache(const CacheData &data); /* actual load, once data availa
int SearchHash(std::string hash, std::list<FileDetail> &results) const;
/* Search Interface - For Search Interface */
int SearchKeywords(std::list<std::string> terms, std::list<DirDetails> &results,uint32_t flags) const;
int SearchKeywords(std::list<std::string> terms, std::list<DirDetails> &results,FileSearchFlags flags) const;
/* Search Interface - for Adv Search Interface */
int searchBoolExp(Expression * exp, std::list<DirDetails> &results) const;
@ -83,7 +83,7 @@ virtual int loadCache(const CacheData &data); /* actual load, once data availa
/* Search Interface - For Directory Access */
int RequestDirDetails(const std::string& uid, const std::string& path, DirDetails &details) const;
int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) const;
int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) const;
uint32_t getType(void *ref) const ;
private:

View File

@ -83,7 +83,7 @@ ftFileControl::ftFileControl()
ftFileControl::ftFileControl(std::string fname,
std::string tmppath, std::string dest,
uint64_t size, std::string hash, uint32_t flags,
uint64_t size, std::string hash, TransferRequestFlags flags,
ftFileCreator *fc, ftTransferModule *tm)
:mName(fname), mCurrentPath(tmppath), mDestination(dest),
mTransfer(tm), mCreator(fc), mState(DOWNLOADING), mHash(hash),
@ -127,7 +127,7 @@ bool ftController::getFileDownloadChunksDetails(const std::string& hash,FileChun
if(it != mDownloads.end())
{
it->second->mCreator->getChunkMap(info) ;
info.flags = it->second->mFlags ;
//info.flags = it->second->mFlags ;
return true ;
}
@ -143,7 +143,7 @@ bool ftController::getFileDownloadChunksDetails(const std::string& hash,FileChun
info.file_size = it->second->mSize ;
info.strategy = mDefaultChunkStrategy ;
info.chunk_size = ChunkMap::CHUNKMAP_FIXED_CHUNK_SIZE ;
info.flags = it->second->mFlags ;
//info.flags = it->second->mFlags ;
uint32_t nb_chunks = it->second->mSize/ChunkMap::CHUNKMAP_FIXED_CHUNK_SIZE ;
if(it->second->mSize % ChunkMap::CHUNKMAP_FIXED_CHUNK_SIZE != 0)
++nb_chunks ;
@ -327,7 +327,7 @@ void ftController::cleanCacheDownloads()
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
for(std::map<std::string,ftFileControl*>::iterator it(mDownloads.begin());it!=mDownloads.end();++it)
if (((it->second)->mFlags & RS_FILE_HINTS_CACHE) && it->second->mState != ftFileControl::DOWNLOADING)
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
{
#ifdef CONTROL_DEBUG
@ -429,7 +429,7 @@ void ftController::checkDownloadQueue()
for(uint32_t p=0;p<_queue.size();++p)
{
if(p < _min_prioritized_transfers)
if(_queue[p]->mFlags & RS_FILE_HINTS_CACHE) // cache file. add to potential move list
if(_queue[p]->mFlags & RS_FILE_REQ_CACHE) // cache file. add to potential move list
to_move_before.push_back(p) ;
else
++user_transfers ; // count one more user file in the prioritized range.
@ -438,7 +438,7 @@ void ftController::checkDownloadQueue()
if(to_move_after.size() + user_transfers >= _min_prioritized_transfers) // we caught enough transfers to move back to the top of the queue.
break ;
if(!(_queue[p]->mFlags & RS_FILE_HINTS_CACHE)) // non cache file. add to potential move list
if(!(_queue[p]->mFlags & RS_FILE_REQ_CACHE)) // non cache file. add to potential move list
to_move_after.push_back(p) ;
}
}
@ -471,7 +471,7 @@ void ftController::locked_addToQueue(ftFileControl* ftfc,int add_strategy)
// This is costly, so only use this in case we really need it.
//
uint32_t pos =0;
while(pos < _queue.size() && (pos < _min_prioritized_transfers || (_queue[pos]->mFlags & RS_FILE_HINTS_CACHE)>0) )
while(pos < _queue.size() && (pos < _min_prioritized_transfers || (_queue[pos]->mFlags & RS_FILE_REQ_CACHE)>0) )
++pos ;
_queue.push_back(NULL) ;
@ -622,7 +622,7 @@ void ftController::locked_checkQueueElement(uint32_t pos)
_queue[pos]->mState = ftFileControl::DOWNLOADING ;
if(_queue[pos]->mFlags & RS_FILE_HINTS_NETWORK_WIDE)
if(_queue[pos]->mFlags & RS_FILE_REQ_ANONYMOUS_ROUTING)
mTurtle->monitorFileTunnels(_queue[pos]->mName,_queue[pos]->mHash,_queue[pos]->mSize) ;
}
@ -631,7 +631,7 @@ void ftController::locked_checkQueueElement(uint32_t pos)
_queue[pos]->mState = ftFileControl::QUEUED ;
_queue[pos]->mCreator->closeFile() ;
if(_queue[pos]->mFlags & RS_FILE_HINTS_NETWORK_WIDE)
if(_queue[pos]->mFlags & RS_FILE_REQ_ANONYMOUS_ROUTING)
mTurtle->stopMonitoringFileTunnels(_queue[pos]->mHash) ;
}
}
@ -766,8 +766,8 @@ bool ftController::completeFile(std::string hash)
uint64_t size = 0;
uint32_t state = 0;
uint32_t period = 0;
uint32_t flags = 0;
uint32_t extraflags = 0;
TransferRequestFlags flags ;
TransferRequestFlags extraflags ;
uint32_t completeCount = 0;
{
@ -855,7 +855,7 @@ bool ftController::completeFile(std::string hash)
size = fc->mSize;
state = fc->mState;
period = 30 * 24 * 3600; /* 30 days */
extraflags = 0;
extraflags.clear() ;
#ifdef CONTROL_DEBUG
std::cerr << "CompleteFile(): size = " << size << std::endl ;
@ -866,7 +866,7 @@ bool ftController::completeFile(std::string hash)
locked_queueRemove(it->second->mQueuePosition) ;
/* switch map */
if (!(fc->mFlags & RS_FILE_HINTS_CACHE)) /* clean up completed cache files automatically */
if (!(fc->mFlags & RS_FILE_REQ_CACHE)) /* clean up completed cache files automatically */
{
mCompleted[fc->mHash] = fc;
completeCount = mCompleted.size();
@ -875,7 +875,7 @@ bool ftController::completeFile(std::string hash)
mDownloads.erase(it);
if(flags & RS_FILE_HINTS_NETWORK_WIDE)
if(flags & RS_FILE_REQ_ANONYMOUS_ROUTING)
mTurtle->stopMonitoringFileTunnels(hash_to_suppress) ;
} /******* UNLOCKED ********/
@ -887,13 +887,13 @@ bool ftController::completeFile(std::string hash)
/* If it has a callback - do it now */
if(flags & ( RS_FILE_HINTS_CACHE | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_MEDIA))
if(flags & ( RS_FILE_REQ_CACHE | RS_FILE_REQ_EXTRA))// | RS_FILE_HINTS_MEDIA))
{
#ifdef CONTROL_DEBUG
std::cerr << "ftController::completeFile() doing Callback, callbackflags:" << (flags & ( RS_FILE_HINTS_CACHE | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_MEDIA)) ;
std::cerr << "ftController::completeFile() doing Callback, callbackflags:" << (flags & ( RS_FILE_HINTS_CACHE | RS_FILE_HINTS_EXTRA ));//| RS_FILE_HINTS_MEDIA)) ;
std::cerr << std::endl;
#endif
if(flags & RS_FILE_HINTS_CACHE)
if(flags & RS_FILE_REQ_CACHE)
{
/* callback */
if (state == ftFileControl::COMPLETED)
@ -915,7 +915,7 @@ bool ftController::completeFile(std::string hash)
}
}
if(flags & RS_FILE_HINTS_EXTRA)
if(flags & RS_FILE_REQ_EXTRA)
{
#ifdef CONTROL_DEBUG
std::cerr << "ftController::completeFile() adding to ExtraList";
@ -925,13 +925,13 @@ bool ftController::completeFile(std::string hash)
mExtraList->addExtraFile(path, hash, size, period, extraflags);
}
if(flags & RS_FILE_HINTS_MEDIA)
{
#ifdef CONTROL_DEBUG
std::cerr << "ftController::completeFile() NULL MEDIA callback";
std::cerr << std::endl;
#endif
}
// if(flags & RS_FILE_HINTS_MEDIA)
// {
//#ifdef CONTROL_DEBUG
// std::cerr << "ftController::completeFile() NULL MEDIA callback";
// std::cerr << std::endl;
//#endif
// }
}
else
{
@ -942,7 +942,7 @@ bool ftController::completeFile(std::string hash)
}
/* Notify GUI */
if ((flags & RS_FILE_HINTS_CACHE) == 0) {
if ((flags & RS_FILE_REQ_CACHE) == 0) {
pqiNotify *notify = getPqiNotify();
if (notify) {
notify->AddPopupMessage(RS_POPUP_DOWNLOAD, hash, name, "");
@ -994,7 +994,7 @@ bool ftController::handleAPendingRequest()
std::cerr << "Requesting pending hash " << req.mHash << std::endl ;
#endif
FileRequest(req.mName, req.mHash, req.mSize, req.mDest, req.mFlags, req.mSrcIds);
FileRequest(req.mName, req.mHash, req.mSize, req.mDest, TransferRequestFlags(req.mFlags), req.mSrcIds);
{
// See whether there is a pendign chunk map recorded for this hash.
@ -1043,14 +1043,14 @@ bool ftController::alreadyHaveFile(const std::string& hash, FileInfo &info)
return true ;
// check for file lists
if (mSearch->search(hash, RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_SPEC_ONLY, info))
if (mSearch->search(hash, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_SPEC_ONLY, info))
return true ;
return false ;
}
bool ftController::FileRequest(const std::string& fname, const std::string& hash,
uint64_t size, const std::string& dest, uint32_t flags,
uint64_t size, const std::string& dest, TransferRequestFlags flags,
const std::list<std::string> &_srcIds)
{
std::list<std::string> srcIds(_srcIds) ;
@ -1129,7 +1129,7 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
#endif
uint32_t rate = 0;
if (flags & RS_FILE_HINTS_BACKGROUND)
if (flags & RS_FILE_REQ_BACKGROUND)
rate = FT_CNTRL_SLOW_RATE;
else
rate = FT_CNTRL_STANDARD_RATE;
@ -1191,12 +1191,12 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
}
} /******* UNLOCKED ********/
if(!(flags & RS_FILE_HINTS_NO_SEARCH))
if(!(flags & RS_FILE_REQ_NO_SEARCH))
{
/* do a source search - for any extra sources */
// add sources only in direct mode
//
if((flags & RS_FILE_HINTS_BROWSABLE) && mSearch->search(hash, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info))
if(/* (flags & RS_FILE_HINTS_BROWSABLE) && */ mSearch->search(hash, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info))
{
/* do something with results */
#ifdef CONTROL_DEBUG
@ -1242,10 +1242,10 @@ bool ftController::FileRequest(const std::string& fname, const std::string& has
// We check that flags are consistent.
if(flags & RS_FILE_HINTS_NETWORK_WIDE)
if(flags & RS_FILE_REQ_ANONYMOUS_ROUTING)
mTurtle->monitorFileTunnels(fname,hash,size) ;
bool assume_availability = flags & RS_FILE_HINTS_CACHE ; // assume availability for cache files
bool assume_availability = flags & RS_FILE_REQ_CACHE ; // assume availability for cache files
ftFileCreator *fc = new ftFileCreator(savepath, size, hash,assume_availability);
ftTransferModule *tm = new ftTransferModule(fc, mDataplex,this);
@ -1623,7 +1623,7 @@ bool ftController::FileDetails(const std::string &hash, FileInfo &info)
/* extract details */
info.hash = hash;
info.fname = it->second->mName;
info.flags = it->second->mFlags;
info.transfer_info_flags = it->second->mFlags ;
info.priority = SPEED_NORMAL ;
RsDirUtil::removeTopDir(it->second->mDestination, info.path); /* remove fname */
info.queue_position = it->second->mQueuePosition ;
@ -1859,7 +1859,7 @@ bool ftController::RequestCacheFile(RsPeerId id, std::string path, std::string h
return false ;
}
FileRequest(hash, hash, size, path, RS_FILE_HINTS_CACHE | RS_FILE_HINTS_NO_SEARCH, ids);
FileRequest(hash, hash, size, path, RS_FILE_REQ_CACHE | RS_FILE_REQ_NO_SEARCH, ids);
return true;
}
@ -1959,7 +1959,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
/* ignore cache files. As this is small files, better download them again from scratch at restart.*/
if (fit->second->mFlags & RS_FILE_HINTS_CACHE)
if (fit->second->mFlags & RS_FILE_REQ_CACHE)
{
#ifdef CONTROL_DEBUG
std::cerr << "ftcontroller::saveList(): Not saving (callback) file entry " << fit->second->mName << ", " << fit->second->mHash << ", " << fit->second->mSize << std::endl ;
@ -1983,7 +1983,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
rft->file.hash = fit->second->mHash;
rft->file.filesize = fit->second->mSize;
RsDirUtil::removeTopDir(fit->second->mDestination, rft->file.path); /* remove fname */
rft->flags = fit->second->mFlags;
rft->flags = fit->second->mFlags.toUInt32();
rft->state = fit->second->mState;
fit->second->mTransfer->getFileSources(rft->allPeerIds.ids);
@ -2032,7 +2032,7 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
rft->file.hash = pit->mHash;
rft->file.filesize = pit->mSize;
RsDirUtil::removeTopDir(pit->mDest, rft->file.path); /* remove fname */
rft->flags = pit->mFlags;
rft->flags = pit->mFlags.toUInt32();
rft->allPeerIds.ids = pit->mSrcIds;
}
@ -2093,7 +2093,7 @@ bool ftController::loadList(std::list<RsItem *>& load)
#ifdef CONTROL_DEBUG
std::cerr << "ftController::loadList(): requesting " << rsft->file.name << ", " << rsft->file.hash << ", " << rsft->file.filesize << std::endl ;
#endif
FileRequest(rsft->file.name, rsft->file.hash, rsft->file.filesize, rsft->file.path, rsft->flags, rsft->allPeerIds.ids);
FileRequest(rsft->file.name, rsft->file.hash, rsft->file.filesize, rsft->file.path, TransferRequestFlags(rsft->flags), rsft->allPeerIds.ids);
{
RsStackMutex mtx(ctrlMutex) ;

View File

@ -73,7 +73,7 @@ class ftFileControl
ftFileControl();
ftFileControl(std::string fname, std::string tmppath, std::string dest,
uint64_t size, std::string hash, uint32_t flags,
uint64_t size, std::string hash, TransferRequestFlags flags,
ftFileCreator *fc, ftTransferModule *tm);
std::string mName;
@ -84,7 +84,7 @@ class ftFileControl
uint32_t mState;
std::string mHash;
uint64_t mSize;
uint32_t mFlags;
TransferRequestFlags mFlags;
time_t mCreateTime;
uint32_t mQueuePriority ;
uint32_t mQueuePosition ;
@ -94,7 +94,7 @@ class ftPendingRequest
{
public:
ftPendingRequest(const std::string& fname, const std::string& hash,
uint64_t size, const std::string& dest, uint32_t flags,
uint64_t size, const std::string& dest, TransferRequestFlags flags,
const std::list<std::string> &srcIds)
: mName(fname), mHash(hash), mSize(size),
mDest(dest), mFlags(flags),mSrcIds(srcIds) { return; }
@ -105,7 +105,7 @@ class ftPendingRequest
std::string mHash;
uint64_t mSize;
std::string mDest;
uint32_t mFlags;
TransferRequestFlags mFlags;
std::list<std::string> mSrcIds;
};
@ -129,7 +129,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
/***************************************************************/
bool FileRequest(const std::string& fname, const std::string& hash,
uint64_t size, const std::string& dest, uint32_t flags,
uint64_t size, const std::string& dest, TransferRequestFlags flags,
const std::list<std::string> &sourceIds);
/// Do we already have this file, either in download or in file lists ?

View File

@ -142,7 +142,7 @@ bool ftDataMultiplex::FileDownloads(std::list<std::string> &hashs)
}
bool ftDataMultiplex::FileDetails(const std::string &hash, uint32_t hintsflag, FileInfo &info)
bool ftDataMultiplex::FileDetails(const std::string &hash, FileSearchFlags hintsflag, FileInfo &info)
{
#ifdef MPLEX_DEBUG
std::cerr << "ftDataMultiplex::FileDetails(";
@ -1309,18 +1309,19 @@ bool ftDataMultiplex::handleSearchRequest(const std::string& peerId, const std::
* the network wide and browsable flags are needed, otherwise results get filtered.
* For tunnel creation, the check of browsable/network wide flag is already done, so
* if we get a file download packet here, the source is already allowed to download it.
* That is why we don't call the search function with a peer id.
*
*/
FileInfo info;
uint32_t hintflags = RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY ;
FileSearchFlags hintflags = RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY ;
if(rsTurtle->isTurtlePeer(peerId))
hintflags |= RS_FILE_HINTS_NETWORK_WIDE ;
else
hintflags |= RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_CACHE ;
hintflags |= RS_FILE_HINTS_CACHE ;
if (mSearch->search(hash, hintflags, info))
if(mSearch->search(hash, hintflags, info))
{
/* setup a new provider */

View File

@ -104,7 +104,7 @@ class ftDataMultiplex: public ftDataRecv, public RsQueueThread
/* 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, uint32_t hintsflag, FileInfo &info);
bool FileDetails(const std::string &hash, FileSearchFlags hintsflag, FileInfo &info);
void deleteUnusedServers() ;
void handlePendingCrcRequests() ;

View File

@ -37,7 +37,7 @@ ftFiStore::ftFiStore(CacheStrapper *cs, CacheTransfer *cft, NotifyBase *cb_in,p3
return;
}
bool ftFiStore::search(const std::string &hash, uint32_t hintflags, FileInfo &info) const
bool ftFiStore::search(const std::string &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,12 @@ ftFiMonitor::ftFiMonitor(CacheStrapper *cs,NotifyBase *cb_in, std::string cached
return;
}
bool ftFiMonitor::search(const std::string &hash, uint32_t hintflags, FileInfo &info) const
bool ftFiMonitor::search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const
{
return search(hash,hintflags,"",info) ;
}
bool ftFiMonitor::search(const std::string &hash, FileSearchFlags hintflags, const std::string& peer_id,FileInfo &info) const
{
uint64_t fsize;
std::string path;
#ifdef DB_DEBUG
std::cerr << "ftFiMonitor::search(" << hash << "," << hintflags;
std::cerr << ")";
@ -142,9 +143,10 @@ bool ftFiMonitor::search(const std::string &hash, uint32_t hintflags, FileInfo &
// Setup search flags according to hintflags. Originally flags was 0. I (cyril) don't know
// why we don't just pass hintflags there, so I tried to keep the idea.
//
uint32_t flags = hintflags & (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE);
FileSearchFlags flags = hintflags ;
flags &= (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE);
if(findLocalFile(hash, flags, path, fsize))
if(findLocalFile(hash, flags,peer_id,info.path, info.size,info.storage_permission_flags,info.parent_groups))
{
/* fill in details */
#ifdef DB_DEBUG
@ -153,10 +155,7 @@ bool ftFiMonitor::search(const std::string &hash, uint32_t hintflags, FileInfo &
std::cerr << " = " << hash << "," << fsize;
std::cerr << std::endl;
#endif
info.size = fsize;
info.fname = RsDirUtil::getTopDir(path);
info.path = path;
info.fname = RsDirUtil::getTopDir(info.path);
return true;
}
@ -241,7 +240,8 @@ bool ftFiMonitor::saveList(bool &cleanup, std::list<RsItem *>& sList)
RsFileConfigItem *fi = new RsFileConfigItem();
fi->file.path = (*it).filename ;
fi->file.name = (*it).virtualname ;
fi->flags = (*it).shareflags ;
fi->flags = (*it).shareflags.toUInt32() ;
fi->parent_groups = (*it).parent_groups ;
sList.push_back(fi);
}
@ -288,6 +288,7 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
/* for each item, check it exists ....
* - remove any that are dead (or flag?)
*/
static const FileStorageFlags PERMISSION_MASK = DIR_FLAGS_BROWSABLE_OTHERS | DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | DIR_FLAGS_NETWORK_WIDE_GROUPS ;
#ifdef DEBUG_ELIST
std::cerr << "ftFiMonitor::loadList()";
@ -341,7 +342,10 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
SharedDirInfo info ;
info.filename = RsDirUtil::convertPathToUnix(fi->file.path);
info.virtualname = fi->file.name;
info.shareflags = fi->flags & (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE) ;
info.parent_groups = fi->parent_groups;
info.shareflags = FileStorageFlags(fi->flags) ;
info.shareflags &= PERMISSION_MASK ;
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
dirList.push_back(info) ;
}
@ -353,6 +357,11 @@ bool ftFiMonitor::loadList(std::list<RsItem *>& load)
void ftFiMonitor::updateShareFlags(const SharedDirInfo& info)
{
std::cerr << "Updating share flags:" << std::endl;
std::cerr << " Directory : " << info.filename << std::endl;
std::cerr << " Virtual : " << info.virtualname << std::endl;
std::cerr << " Flags : " << info.shareflags << std::endl;
FileIndexMonitor::updateShareFlags(info);
/* flag for config */
@ -376,7 +385,7 @@ ftCacheStrapper::ftCacheStrapper(p3LinkMgr *lm)
}
/* overloaded search function */
bool ftCacheStrapper::search(const std::string &hash, uint32_t hintflags, FileInfo &info) const
bool ftCacheStrapper::search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const
{
/* remove unused parameter warnings */
(void) hintflags;

View File

@ -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, uint32_t hintflags, FileInfo &info) const;
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
};
class ftFiMonitor: public FileIndexMonitor, public ftSearch, public p3Config
@ -61,7 +61,8 @@ class ftFiMonitor: public FileIndexMonitor, public ftSearch, public p3Config
ftFiMonitor(CacheStrapper *cs,NotifyBase *cb_in, std::string cachedir, std::string pid,const std::string& config_dir);
/* overloaded search function */
virtual bool search(const std::string &hash, uint32_t hintflags, FileInfo &info) const;
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
virtual bool search(const std::string &hash, FileSearchFlags hintflags, const std::string& peer_id, FileInfo &info) const;
/* overloaded set dirs enables config indication */
virtual void setSharedDirectories(const std::list<SharedDirInfo>& dirList);
@ -93,7 +94,7 @@ class ftCacheStrapper: public CacheStrapper, public ftSearch
ftCacheStrapper(p3LinkMgr *cm);
/* overloaded search function */
virtual bool search(const std::string &hash, uint32_t hintflags, FileInfo &info) const;
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
};

View File

@ -146,7 +146,7 @@ void ftExtraList::hashAFile()
**/
bool ftExtraList::addExtraFile(std::string path, std::string hash,
uint64_t size, uint32_t period, uint32_t flags)
uint64_t size, uint32_t period, TransferRequestFlags flags)
{
#ifdef DEBUG_ELIST
std::cerr << "ftExtraList::addExtraFile() path: " << path;
@ -177,7 +177,7 @@ bool ftExtraList::addExtraFile(std::string path, std::string hash,
return true;
}
bool ftExtraList::removeExtraFile(std::string hash, uint32_t flags)
bool ftExtraList::removeExtraFile(std::string hash, TransferRequestFlags flags)
{
/* remove unused parameter warnings */
(void) flags;
@ -273,12 +273,12 @@ bool ftExtraList::cleanupOldFiles()
}
bool ftExtraList::cleanupEntry(std::string /*path*/, uint32_t flags)
bool ftExtraList::cleanupEntry(std::string /*path*/, TransferRequestFlags flags)
{
if (flags & RS_FILE_CONFIG_CLEANUP_DELETE)
{
/* Delete the file? - not yet! */
}
// if (flags & RS_FILE_CONFIG_CLEANUP_DELETE)
// {
// /* Delete the file? - not yet! */
// }
return true;
}
@ -287,7 +287,7 @@ bool ftExtraList::cleanupEntry(std::string /*path*/, uint32_t flags)
* file is removed after period.
**/
bool ftExtraList::hashExtraFile(std::string path, uint32_t period, uint32_t flags)
bool ftExtraList::hashExtraFile(std::string path, uint32_t period, TransferRequestFlags flags)
{
#ifdef DEBUG_ELIST
std::cerr << "ftExtraList::hashExtraFile() path: " << path;
@ -326,14 +326,14 @@ bool ftExtraList::hashExtraFileDone(std::string path, FileInfo &info)
}
hash = it->second;
}
return search(hash, 0, info);
return search(hash, FileSearchFlags(0), info);
}
/***
* Search Function - used by File Transfer
*
**/
bool ftExtraList::search(const std::string &hash, uint32_t /*hintflags*/, FileInfo &info) const
bool ftExtraList::search(const std::string &hash, FileSearchFlags /*hintflags*/, FileInfo &info) const
{
#ifdef DEBUG_ELIST
@ -396,7 +396,7 @@ bool ftExtraList::saveList(bool &cleanup, std::list<RsItem *>& sList)
fi->file.hash = (it->second).info.hash;
fi->file.filesize = (it->second).info.size;
fi->file.age = (it->second).info.age;
fi->flags = (it->second).flags;
fi->flags = (it->second).flags.toUInt32();
sList.push_back(fi);
}
@ -444,7 +444,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
if (ts > (time_t)fi->file.age)
{
/* to old */
cleanupEntry(fi->file.path, fi->flags);
cleanupEntry(fi->file.path, TransferRequestFlags(fi->flags));
delete (*it);
continue ;
}
@ -461,7 +461,7 @@ bool ftExtraList::loadList(std::list<RsItem *>& load)
details.info.hash = fi->file.hash;
details.info.size = fi->file.filesize;
details.info.age = fi->file.age; /* time that we remove it. */
details.flags = fi->flags;
details.flags = TransferRequestFlags(fi->flags);
/* stick it in the available queue */
mFiles[details.info.hash] = details;

View File

@ -65,38 +65,38 @@
class FileDetails
{
public:
FileDetails()
{
return;
}
FileDetails()
{
return;
}
FileDetails(std::string path, uint32_t p, uint32_t f)
{
info.path = path;
period = p;
flags = f;
}
FileDetails(FileInfo &i, uint32_t p, uint32_t f)
{
info = i;
period = p;
flags = f;
}
FileDetails(std::string path, uint32_t p, TransferRequestFlags f)
{
info.path = path;
period = p;
flags = f;
}
FileInfo info;
FileDetails(FileInfo &i, uint32_t p, TransferRequestFlags f)
{
info = i;
period = p;
flags = f;
}
FileInfo info;
#if 0 /*** WHAT IS NEEDED ***/
std::list<std::string> sources;
std::string path;
std::string fname;
std::string hash;
uint64_t size;
std::list<std::string> sources;
std::string path;
std::string fname;
std::string hash;
uint64_t size;
#endif
uint32_t start;
uint32_t period;
uint32_t flags;
uint32_t start;
uint32_t period;
TransferRequestFlags flags;
};
const uint32_t FT_DETAILS_CLEANUP = 0x0100; /* remove when it expires */
@ -118,9 +118,9 @@ class ftExtraList: public RsThread, public p3Config, public ftSearch
**/
bool addExtraFile(std::string path, std::string hash,
uint64_t size, uint32_t period, uint32_t flags);
uint64_t size, uint32_t period, TransferRequestFlags flags);
bool removeExtraFile(std::string hash, uint32_t flags);
bool removeExtraFile(std::string hash, TransferRequestFlags flags);
bool moveExtraFile(std::string fname, std::string hash, uint64_t size,
std::string destpath);
@ -130,7 +130,7 @@ bool moveExtraFile(std::string fname, std::string hash, uint64_t size,
* file is removed after period.
**/
bool hashExtraFile(std::string path, uint32_t period, uint32_t flags);
bool hashExtraFile(std::string path, uint32_t period, TransferRequestFlags flags);
bool hashExtraFileDone(std::string path, FileInfo &info);
/***
@ -138,7 +138,7 @@ bool hashExtraFileDone(std::string path, FileInfo &info);
* implementation of ftSearch.
*
**/
virtual bool search(const std::string &hash, uint32_t hintflags, FileInfo &info) const;
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
/***
* Thread Main Loop
@ -159,7 +159,7 @@ virtual bool loadList(std::list<RsItem *>& load);
/* Worker Functions */
void hashAFile();
bool cleanupOldFiles();
bool cleanupEntry(std::string path, uint32_t flags);
bool cleanupEntry(std::string path, TransferRequestFlags flags);
mutable RsMutex extMutex;

View File

@ -39,9 +39,9 @@ ftFileSearch::ftFileSearch()
}
}
bool ftFileSearch::addSearchMode(ftSearch *search, uint32_t hintflags)
bool ftFileSearch::addSearchMode(ftSearch *search, FileSearchFlags hintflags)
{
hintflags &= 0x00ffffff;
hintflags &= FileSearchFlags(0x000000ff);
#ifdef DEBUG_SEARCH
std::cerr << "ftFileSearch::addSearchMode() : " << hintflags;
@ -51,7 +51,7 @@ bool ftFileSearch::addSearchMode(ftSearch *search, uint32_t hintflags)
uint32_t i;
for (i = 0; i < MAX_SEARCHS; i++)
{
uint32_t hints = hintflags >> i;
uint32_t hints = hintflags.toUInt32() >> i;
if (hints & 0x0001)
{
/* has the flag */
@ -75,7 +75,7 @@ bool ftFileSearch::addSearchMode(ftSearch *search, uint32_t hintflags)
return false;
}
bool ftFileSearch::search(const std::string &hash, uint32_t hintflags, FileInfo &info) const
bool ftFileSearch::search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const
{
uint32_t hints, i;
@ -87,7 +87,7 @@ bool ftFileSearch::search(const std::string &hash, uint32_t hintflags, FileInfo
for (i = 0; i < MAX_SEARCHS; i++)
{
hints = hintflags >> i;
hints = hintflags.toUInt32() >> i;
if (hints & 0x0001)
{
/* has the flag */
@ -140,7 +140,7 @@ bool ftFileSearch::search(const std::string &hash, uint32_t hintflags, FileInfo
*/
for (i = 0; i < MAX_SEARCHS; i++)
{
hints = hintflags >> i;
hints = hintflags.toUInt32() >> i;
if (hints & 0x0001)
{
continue;
@ -180,7 +180,7 @@ bool ftFileSearch::search(const std::string &hash, uint32_t hintflags, FileInfo
}
bool ftSearchDummy::search(std::string /*hash*/, uint32_t hintflags, FileInfo &/*info*/) const
bool ftSearchDummy::search(std::string /*hash*/, FileSearchFlags hintflags, FileInfo &/*info*/) const
{
/* remove unused parameter warnings */
(void) hintflags;

View File

@ -44,8 +44,8 @@ class ftFileSearch: public ftSearch
ftFileSearch();
bool addSearchMode(ftSearch *search, uint32_t hintflags);
virtual bool search(const std::string &hash, uint32_t hintflags, FileInfo &info) const;
bool addSearchMode(ftSearch *search, FileSearchFlags hintflags);
virtual bool search(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) const;
private:

View File

@ -40,10 +40,14 @@ class ftSearch
{
public:
ftSearch() { return; }
virtual ~ftSearch() { return; }
virtual bool search(const std::string &hash, uint32_t hintflags, FileInfo &info) const = 0;
ftSearch() { return; }
virtual ~ftSearch() { return; }
virtual bool search(const std::string &hash, FileSearchFlags hintflags,const std::string& 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;
};
@ -54,7 +58,7 @@ class ftSearchDummy: public ftSearch
ftSearchDummy() { return; }
virtual ~ftSearchDummy() { return; }
virtual bool search(std::string hash, uint32_t hintflags, FileInfo &info) const;
virtual bool search(std::string hash, FileSearchFlags hintflags, FileInfo &info) const;
};
#endif

View File

@ -270,7 +270,7 @@ bool ftServer::alreadyHaveFile(const std::string& 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, uint32_t flags, const std::list<std::string>& srcIds)
bool ftServer::FileRequest(const std::string& fname, const std::string& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<std::string>& srcIds)
{
std::string error_string ;
@ -415,7 +415,7 @@ bool ftServer::FileUploads(std::list<std::string> &hashs)
return mFtDataplex->FileUploads(hashs);
}
bool ftServer::FileDetails(const std::string &hash, uint32_t hintflags, FileInfo &info)
bool ftServer::FileDetails(const std::string &hash, FileSearchFlags hintflags, FileInfo &info)
{
if (hintflags & RS_FILE_HINTS_DOWNLOAD)
if(mFtController->FileDetails(hash, info))
@ -429,7 +429,7 @@ bool ftServer::FileDetails(const std::string &hash, uint32_t hintflags, FileInfo
// file, we skip the call to fileDetails() for efficiency reasons.
//
FileInfo info2 ;
if( (!(info.flags & RS_FILE_HINTS_CACHE)) && mFtController->FileDetails(hash, info2))
if( (!(info.transfer_info_flags & RS_FILE_REQ_CACHE)) && mFtController->FileDetails(hash, info2))
info.fname = info2.fname ;
return true ;
@ -447,17 +447,17 @@ bool ftServer::FileDetails(const std::string &hash, uint32_t hintflags, FileInfo
/***************************************************************/
bool ftServer::ExtraFileAdd(std::string fname, std::string hash, uint64_t size,
uint32_t period, uint32_t flags)
uint32_t period, TransferRequestFlags flags)
{
return mFtExtra->addExtraFile(fname, hash, size, period, flags);
}
bool ftServer::ExtraFileRemove(std::string hash, uint32_t flags)
bool ftServer::ExtraFileRemove(std::string hash, TransferRequestFlags flags)
{
return mFtExtra->removeExtraFile(hash, flags);
}
bool ftServer::ExtraFileHash(std::string localpath, uint32_t period, uint32_t flags)
bool ftServer::ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags)
{
return mFtExtra->hashExtraFile(localpath, period, flags);
}
@ -497,7 +497,7 @@ int ftServer::RequestDirDetails(const std::string& uid, const std::string& path,
return mFiStore->RequestDirDetails(uid, path, details);
}
int ftServer::RequestDirDetails(void *ref, DirDetails &details, uint32_t flags)
int ftServer::RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags)
{
#ifdef SERVER_DEBUG
std::cerr << "ftServer::RequestDirDetails(ref:" << ref;
@ -511,12 +511,12 @@ int ftServer::RequestDirDetails(void *ref, DirDetails &details, uint32_t flags)
}
#endif
if(flags & DIR_FLAGS_LOCAL)
if(flags & RS_FILE_HINTS_LOCAL)
return mFiMon->RequestDirDetails(ref, details, flags);
else
return mFiStore->RequestDirDetails(ref, details, flags);
}
uint32_t ftServer::getType(void *ref, uint32_t flags)
uint32_t ftServer::getType(void *ref, FileSearchFlags flags)
{
#ifdef SERVER_DEBUG
std::cerr << "ftServer::RequestDirDetails(ref:" << ref;
@ -530,7 +530,7 @@ uint32_t ftServer::getType(void *ref, uint32_t flags)
}
#endif
if(flags & DIR_FLAGS_LOCAL)
if(flags & RS_FILE_HINTS_LOCAL)
return mFiMon->getType(ref);
else
return mFiStore->getType(ref);
@ -540,7 +540,15 @@ uint32_t ftServer::getType(void *ref, uint32_t flags)
/***************************************************************/
int ftServer::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags)
int ftServer::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags)
{
if(flags & RS_FILE_HINTS_LOCAL)
return mFiMon->SearchKeywords(keywords, results,flags,"");
else
return mFiStore->SearchKeywords(keywords, results,flags);
return 0 ;
}
int ftServer::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const std::string& peer_id)
{
#ifdef SERVER_DEBUG
std::cerr << "ftServer::SearchKeywords()";
@ -553,16 +561,24 @@ int ftServer::SearchKeywords(std::list<std::string> keywords, std::list<DirDetai
}
#endif
if(flags & DIR_FLAGS_LOCAL)
return mFiMon->SearchKeywords(keywords, results,flags);
if(flags & RS_FILE_HINTS_LOCAL)
return mFiMon->SearchKeywords(keywords, results,flags,peer_id);
else
return mFiStore->SearchKeywords(keywords, results,flags);
}
int ftServer::SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t flags)
int ftServer::SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags)
{
if(flags & DIR_FLAGS_LOCAL)
return mFiMon->SearchBoolExp(exp,results,flags) ;
if(flags & RS_FILE_HINTS_LOCAL)
return mFiMon->SearchBoolExp(exp,results,flags,"") ;
else
return mFiStore->searchBoolExp(exp, results);
return 0 ;
}
int ftServer::SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const std::string& peer_id)
{
if(flags & RS_FILE_HINTS_LOCAL)
return mFiMon->SearchBoolExp(exp,results,flags,peer_id) ;
else
return mFiStore->searchBoolExp(exp, results);
}
@ -731,7 +747,7 @@ bool ftServer::shareDownloadDirectory(bool share)
/* Share */
SharedDirInfo inf ;
inf.filename = mFtController->getDownloadDirectory();
inf.shareflags = RS_FILE_HINTS_NETWORK_WIDE ;
inf.shareflags = DIR_FLAGS_NETWORK_WIDE_OTHERS ;
return addSharedDirectory(inf);
}

View File

@ -125,7 +125,7 @@ ftController *getController() const { return mFtController ; }
* 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, uint32_t flags, const std::list<std::string>& srcIds);
virtual bool FileRequest(const std::string& fname, const std::string& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<std::string>& srcIds);
virtual bool FileCancel(const std::string& hash);
virtual bool FileControl(const std::string& hash, uint32_t flags);
virtual bool FileClearCompleted();
@ -154,7 +154,7 @@ virtual bool clearDownload(const std::string hash);
***/
virtual bool FileDownloads(std::list<std::string> &hashs);
virtual bool FileUploads(std::list<std::string> &hashs);
virtual bool FileDetails(const std::string &hash, uint32_t hintflags, FileInfo &info);
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 std::string& peer_id,CompressedChunkMap& map) ;
@ -162,25 +162,24 @@ virtual bool FileUploadChunksDetails(const std::string& hash,const std::string&
/***
* Extra List Access
***/
virtual bool ExtraFileAdd(std::string fname, std::string hash, uint64_t size,
uint32_t period, uint32_t flags);
virtual bool ExtraFileRemove(std::string hash, uint32_t flags);
virtual bool ExtraFileHash(std::string localpath,
uint32_t period, uint32_t flags);
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 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, std::string hash, uint64_t size, std::string destpath);
/***
* Directory Listing / Search Interface
***/
virtual int RequestDirDetails(const std::string& uid, const std::string& path, DirDetails &details);
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags);
virtual uint32_t getType(void *ref,uint32_t flags) ;
virtual int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags);
virtual uint32_t getType(void *ref,FileSearchFlags flags) ;
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags);
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t flags);
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags);
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const std::string& peer_id);
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags);
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const std::string& peer_id);
/***
* Utility Functions

View File

@ -63,23 +63,32 @@ const uint32_t RS_FILE_PEER_OFFLINE = 0x00002000;
*
*/
const uint32_t RS_FILE_HINTS_MASK = 0x00ffffff;
// Flags used when requesting info about transfers, mostly to filter out the result.
//
const FileSearchFlags RS_FILE_HINTS_CACHE ( 0x00000001 );
const FileSearchFlags RS_FILE_HINTS_EXTRA ( 0x00000002 );
const FileSearchFlags RS_FILE_HINTS_LOCAL ( 0x00000004 );
const FileSearchFlags RS_FILE_HINTS_REMOTE ( 0x00000008 );
const FileSearchFlags RS_FILE_HINTS_DOWNLOAD ( 0x00000010 );
const FileSearchFlags RS_FILE_HINTS_UPLOAD ( 0x00000020 );
const FileSearchFlags RS_FILE_HINTS_SPEC_ONLY ( 0x01000000 );
const uint32_t RS_FILE_HINTS_CACHE = 0x00000001;
const uint32_t RS_FILE_HINTS_EXTRA = 0x00000002;
const uint32_t RS_FILE_HINTS_LOCAL = 0x00000004;
const uint32_t RS_FILE_HINTS_REMOTE = 0x00000008;
const uint32_t RS_FILE_HINTS_DOWNLOAD = 0x00000010;
const uint32_t RS_FILE_HINTS_UPLOAD = 0x00000020;
const FileSearchFlags RS_FILE_HINTS_NETWORK_WIDE ( 0x00000080 );// anonymously shared over network
const FileSearchFlags RS_FILE_HINTS_BROWSABLE ( 0x00000100 );// browsable by friends
const FileSearchFlags RS_FILE_HINTS_PERMISSION_MASK ( 0x00000180 );// OR of the last two flags. Used to filter out.
const uint32_t RS_FILE_HINTS_NETWORK_WIDE = 0x00000080; // anonymously shared over network
const uint32_t RS_FILE_HINTS_BROWSABLE = 0x00000100; // browsable by friends
const uint32_t RS_FILE_HINTS_ASSUME_AVAILABILITY = 0x00000200; // Assume full source availability. Used for cache files.
const uint32_t RS_FILE_HINTS_MEDIA = 0x00001000;
const uint32_t RS_FILE_HINTS_BACKGROUND = 0x00002000; // To download slowly.
// Flags used when requesting a transfer
//
const TransferRequestFlags RS_FILE_REQ_ANONYMOUS_ROUTING ( 0x00000040 ); // Use to ask turtle router to download the file.
const TransferRequestFlags RS_FILE_REQ_ASSUME_AVAILABILITY ( 0x00000200 ); // Assume full source availability. Used for cache files.
const TransferRequestFlags RS_FILE_REQ_CACHE ( 0x00000400 ); // Assume full source availability. Used for cache files.
const TransferRequestFlags RS_FILE_REQ_EXTRA ( 0x00000800 );
const TransferRequestFlags RS_FILE_REQ_MEDIA ( 0x00001000 );
const TransferRequestFlags RS_FILE_REQ_BACKGROUND ( 0x00002000 ); // To download slowly.
const TransferRequestFlags RS_FILE_REQ_NO_SEARCH ( 0x02000000 ); // disable searching for potential direct sources.
const uint32_t RS_FILE_HINTS_SPEC_ONLY = 0x01000000;
const uint32_t RS_FILE_HINTS_NO_SEARCH = 0x02000000;
// const uint32_t RS_FILE_HINTS_SHARE_FLAGS_MASK = RS_FILE_HINTS_NETWORK_WIDE_OTHERS | RS_FILE_HINTS_BROWSABLE_OTHERS
// | RS_FILE_HINTS_NETWORK_WIDE_GROUPS | RS_FILE_HINTS_BROWSABLE_GROUPS ;
/* Callback Codes */
@ -89,7 +98,8 @@ struct SharedDirInfo
{
std::string filename ;
std::string virtualname ;
uint32_t shareflags ; // RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE
FileStorageFlags shareflags ; // DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | ...
std::list<std::string> parent_groups ;
};
class RsFiles
@ -109,7 +119,7 @@ class RsFiles
virtual bool alreadyHaveFile(const std::string& 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, uint32_t flags, const std::list<std::string>& srcIds) = 0;
virtual bool FileRequest(const std::string& fname, const std::string& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<std::string>& srcIds) = 0;
virtual bool FileCancel(const std::string& hash) = 0;
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy) = 0;
virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) = 0;
@ -137,7 +147,7 @@ class RsFiles
***/
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, uint32_t hintflags, FileInfo &info) = 0;
virtual bool FileDetails(const std::string &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 ;
@ -148,11 +158,9 @@ class RsFiles
/***
* Extra List Access
***/
virtual bool ExtraFileAdd(std::string fname, std::string hash, uint64_t size,
uint32_t period, uint32_t flags) = 0;
virtual bool ExtraFileRemove(std::string hash, uint32_t flags) = 0;
virtual bool ExtraFileHash(std::string localpath,
uint32_t period, uint32_t flags) = 0;
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 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;
@ -163,12 +171,13 @@ class RsFiles
* Directory Listing / Search Interface
*/
virtual int RequestDirDetails(const std::string& 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 RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) = 0;
virtual uint32_t getType(void *ref,uint32_t flags) = 0;
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags) = 0;
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t 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 std::string& 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 std::string& peer_id) = 0;
/***
* Utility Functions.

View File

@ -0,0 +1,64 @@
#pragma once
#include <stdint.h>
// This class provides a representation for flags that can be combined with bitwise
// operations. However, because the class is templated with an id, it's not possible to
// mixup flags belonging to different classes. This avoids many bugs due to confusion of flags types
// that occur when all flags are uint32_t values.
//
// To use this class, define an ID that is different than other flags classes, and do a typedef:
//
// #define TRANSFER_INFO_FLAGS_TAG 0x8133ea
// typedef t_RsFlags32<TRANSFER_INFO_FLAGS_TAG> TransferInfoFlags ;
//
// Implementation details:
// - we cannot have at the same time a implicit contructor from uint32_t and a bool operator, otherwise c++
// mixes up operators and transforms flags into booleans before combining them further.
//
// So I decided to have:
// - an explicit constructor from uint32_t
// - an implicit bool operator, that allows test like if(flags & FLAGS_VALUE)
//
template<int n> class t_RsFlags32
{
public:
inline t_RsFlags32() { _bits=0; }
inline explicit t_RsFlags32(uint32_t N) : _bits(N) {} // allows initialization from a set of uint32_t
inline t_RsFlags32<n> operator| (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits | f._bits) ; }
inline t_RsFlags32<n> operator^ (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits ^ f._bits) ; }
inline bool operator!=(const t_RsFlags32<n>& f) const { return _bits != f._bits ; }
inline bool operator& (const t_RsFlags32<n>& f) const { return (_bits & f._bits)>0 ; }
inline t_RsFlags32<n> operator|=(const t_RsFlags32<n>& f) { _bits |= f._bits ; return *this ;}
inline t_RsFlags32<n> operator^=(const t_RsFlags32<n>& f) { _bits ^= f._bits ; return *this ;}
inline t_RsFlags32<n> operator&=(const t_RsFlags32<n>& f) { _bits &= f._bits ; return *this ;}
inline t_RsFlags32<n> operator~() const { return t_RsFlags32<n>(~_bits) ; }
//inline explicit operator bool() const { return _bits>0; }
inline uint32_t toUInt32() const { return _bits ; }
void clear() { _bits = 0 ; }
friend std::ostream& operator<<(std::ostream& o,const t_RsFlags32<n>& f) // friendly print with 0 and I
{
for(int i=31;i>=0;--i) { o << ( (f._bits&(1<<i))?"I":"0") ; if(i%8==0) o << " " ; }
return o ;
}
private:
uint32_t _bits ;
};
#define FLAGS_TAG_FILE_SEARCH 0xf29ba5
#define FLAGS_TAG_PERMISSION 0x8133ea
#define FLAGS_TAG_TRANSFER_REQS 0x4228af
#define FLAGS_TAG_FILE_STORAGE 0x184738
typedef t_RsFlags32<FLAGS_TAG_PERMISSION> FilePermissionFlags ;
typedef t_RsFlags32<FLAGS_TAG_TRANSFER_REQS> TransferRequestFlags ;
typedef t_RsFlags32<FLAGS_TAG_FILE_STORAGE > FileStorageFlags ; // this makes it a uint32_t class incompatible with other flag class
typedef t_RsFlags32<FLAGS_TAG_FILE_SEARCH > FileSearchFlags ; // this makes it a uint32_t class incompatible with other flag class

View File

@ -30,6 +30,9 @@
#include <string>
#include <list>
#include <retroshare/rstypes.h>
#include <retroshare/rsfiles.h>
/* The Main Interface Class - for information about your Peers
* A peer is another RS instance, means associated with an SSL certificate
* A same GPG person can have multiple peer running with different SSL certs signed by the same GPG key
@ -210,88 +213,101 @@ class RsPeers
{
public:
RsPeers() { return; }
virtual ~RsPeers() { return; }
RsPeers() { return; }
virtual ~RsPeers() { return; }
/* Updates ... */
virtual bool FriendsChanged() = 0;
virtual bool OthersChanged() = 0;
/* Updates ... */
virtual bool FriendsChanged() = 0;
virtual bool OthersChanged() = 0;
/* Peer Details (Net & Auth) */
virtual std::string getOwnId() = 0;
/* Peer Details (Net & Auth) */
virtual std::string getOwnId() = 0;
virtual bool getOnlineList(std::list<std::string> &ssl_ids) = 0;
virtual bool getFriendList(std::list<std::string> &ssl_ids) = 0;
//virtual bool getOthersList(std::list<std::string> &ssl_ids) = 0;
virtual bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount, bool ssl) = 0;
virtual bool getOnlineList(std::list<std::string> &ssl_ids) = 0;
virtual bool getFriendList(std::list<std::string> &ssl_ids) = 0;
//virtual bool getOthersList(std::list<std::string> &ssl_ids) = 0;
virtual bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount, bool ssl) = 0;
virtual bool isOnline(const std::string &ssl_id) = 0;
virtual bool isFriend(const std::string &ssl_id) = 0;
virtual bool isGPGAccepted(const std::string &gpg_id_is_friend) = 0; //
virtual std::string getPeerName(const std::string &ssl_or_gpg_id) = 0;
virtual std::string getGPGName(const std::string &gpg_id) = 0;
virtual bool getPeerDetails(const std::string &ssl_or_gpg_id, RsPeerDetails &d) = 0; //get Peer detail accept SSL and PGP certs
virtual bool isOnline(const std::string &ssl_id) = 0;
virtual bool isFriend(const std::string &ssl_id) = 0;
virtual bool isGPGAccepted(const std::string &gpg_id_is_friend) = 0; //
virtual std::string getPeerName(const std::string &ssl_or_gpg_id) = 0;
virtual std::string getGPGName(const std::string &gpg_id) = 0;
virtual bool getPeerDetails(const std::string &ssl_or_gpg_id, RsPeerDetails &d) = 0; //get Peer detail accept SSL and PGP certs
/* Using PGP Ids */
virtual std::string getGPGOwnId() = 0;
virtual std::string getGPGId(const std::string &sslid_or_gpgid) = 0; //return the gpg id of the given gpg or ssl id
virtual bool isKeySupported(const std::string& gpg_ids) = 0;
virtual bool getGPGAcceptedList(std::list<std::string> &gpg_ids) = 0;
virtual bool getGPGSignedList(std::list<std::string> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
virtual bool getGPGValidList(std::list<std::string> &gpg_ids) = 0;
virtual bool getGPGAllList(std::list<std::string> &gpg_ids) = 0;
virtual bool getGPGDetails(const std::string &gpg_id, RsPeerDetails &d) = 0;
virtual bool getAssociatedSSLIds(const std::string &gpg_id, std::list<std::string> &ids) = 0;
virtual std::string getGPGOwnId() = 0;
virtual std::string getGPGId(const std::string &sslid_or_gpgid) = 0; //return the gpg id of the given gpg or ssl id
virtual bool isKeySupported(const std::string& gpg_ids) = 0;
virtual bool getGPGAcceptedList(std::list<std::string> &gpg_ids) = 0;
virtual bool getGPGSignedList(std::list<std::string> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
virtual bool getGPGValidList(std::list<std::string> &gpg_ids) = 0;
virtual bool getGPGAllList(std::list<std::string> &gpg_ids) = 0;
virtual bool getGPGDetails(const std::string &gpg_id, RsPeerDetails &d) = 0;
virtual bool getAssociatedSSLIds(const std::string &gpg_id, std::list<std::string> &ids) = 0;
/* Add/Remove Friends */
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id) = 0;
virtual bool removeFriend(const std::string &ssl_or_gpg_id) = 0;
virtual bool removeFriendLocation(const std::string &sslId) = 0;
/* Add/Remove Friends */
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id) = 0;
virtual bool removeFriend(const std::string &ssl_or_gpg_id) = 0;
virtual bool removeFriendLocation(const std::string &sslId) = 0;
/* Network Stuff */
virtual bool connectAttempt(const std::string &ssl_id) = 0;
virtual bool setLocation(const std::string &ssl_id, const std::string &location) = 0;//location is shown in the gui to differentiate ssl certs
virtual bool setLocalAddress(const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setExtAddress( const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setDynDNS(const std::string &id, const std::string &addr) = 0;
virtual bool setNetworkMode(const std::string &ssl_id, uint32_t netMode) = 0;
virtual bool setVisState(const std::string &ssl_id, uint32_t vis) = 0;
/* Network Stuff */
virtual bool connectAttempt(const std::string &ssl_id) = 0;
virtual bool setLocation(const std::string &ssl_id, const std::string &location) = 0;//location is shown in the gui to differentiate ssl certs
virtual bool setLocalAddress(const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setExtAddress( const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setDynDNS(const std::string &id, const std::string &addr) = 0;
virtual bool setNetworkMode(const std::string &ssl_id, uint32_t netMode) = 0;
virtual bool setVisState(const std::string &ssl_id, uint32_t vis) = 0;
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;
virtual void allowTunnelConnection(bool) = 0;
virtual bool getAllowServerIPDetermination() = 0 ;
virtual bool getAllowTunnelConnection() = 0 ;
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;
virtual void allowTunnelConnection(bool) = 0;
virtual bool getAllowServerIPDetermination() = 0 ;
virtual bool getAllowTunnelConnection() = 0 ;
/* Auth Stuff */
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format = false) = 0;
virtual bool GetPGPBase64StringAndCheckSum(const std::string& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0 ;
virtual std::string GetRetroshareInvite(bool include_signatures,bool old_format = false) = 0;
virtual bool hasExportMinimal() = 0 ;
/* Auth Stuff */
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format = false) = 0;
virtual bool GetPGPBase64StringAndCheckSum(const std::string& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0 ;
virtual std::string GetRetroshareInvite(bool include_signatures,bool old_format = false) = 0;
virtual bool hasExportMinimal() = 0 ;
// Add keys to the keyring
virtual bool loadCertificateFromFile(const std::string &fname, std::string &ssl_id, std::string &gpg_id) = 0;
virtual bool loadCertificateFromString(const std::string &cert, std::string &ssl_id, std::string &gpg_id) = 0;
// Add keys to the keyring
virtual bool loadCertificateFromFile(const std::string &fname, std::string &ssl_id, std::string &gpg_id) = 0;
virtual bool loadCertificateFromString(const std::string &cert, std::string &ssl_id, std::string &gpg_id) = 0;
// Gets the GPG details, but does not add the key to the keyring.
virtual bool loadDetailsFromStringCert(const std::string& certGPG, RsPeerDetails &pd,std::string& error_string) = 0;
// Gets the GPG details, but does not add the key to the keyring.
virtual bool loadDetailsFromStringCert(const std::string& certGPG, RsPeerDetails &pd,std::string& error_string) = 0;
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code) = 0;
virtual bool saveCertificateToFile(const std::string &id, const std::string &fname) = 0;
virtual std::string saveCertificateToString(const std::string &id) = 0;
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code) = 0;
virtual bool saveCertificateToFile(const std::string &id, const std::string &fname) = 0;
virtual std::string saveCertificateToString(const std::string &id) = 0;
virtual bool signGPGCertificate(const std::string &gpg_id) = 0;
virtual bool trustGPGCertificate(const std::string &gpg_id, uint32_t trustlvl) = 0;
virtual bool signGPGCertificate(const std::string &gpg_id) = 0;
virtual bool trustGPGCertificate(const std::string &gpg_id, uint32_t trustlvl) = 0;
/* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool removeGroup(const std::string &groupId) = 0;
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
// groupId == "" && assign == false -> remove from all groups
virtual bool assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign) = 0;
/* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool removeGroup(const std::string &groupId) = 0;
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
// groupId == "" && assign == false -> remove from all groups
virtual bool assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign) = 0;
/* Group sharing permission */
// Given
// - the peer id
// - the permission flags of a given hash, e.g. a combination of
// RS_DIR_FLAGS_NETWORK_WIDE_OTHERS, RS_DIR_FLAGS_NETWORK_WIDE_GROUPS, RS_DIR_FLAGS_BROWSABLE_OTHERS and RS_DIR_FLAGS_BROWSABLE_GROUPS
// - the parent groups of the file
//
// ... computes the sharing file permission hint flags set for this peer, that is a combination of
// RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE.
//
virtual FileSearchFlags computePeerPermissionFlags(const std::string& peer_id,FileStorageFlags file_sharing_flags,const std::list<std::string>& file_parent_groups) = 0;
};

View File

@ -34,6 +34,8 @@
#include <string>
#include <stdint.h>
#include <retroshare/rsflags.h>
#define USE_NEW_CHUNK_CHECKING_CODE
typedef std::string RsCertId;
@ -94,54 +96,6 @@ enum DwlSpeed { SPEED_LOW = 0x00,
class FileInfo
{
/* old BaseInfo Entries */
public:
FileInfo() :flags(0), mId(0) { return; }
RsCertId id; /* key for matching everything */
int flags; /* INFO_TAG above */
/* allow this to be tweaked by the GUI Model */
mutable unsigned int mId; /* (GUI) Model Id -> unique number */
/* Old FileInfo Entries */
public:
static const int kRsFiStatusNone = 0;
static const int kRsFiStatusStall = 1;
static const int kRsFiStatusProgress = 2;
static const int kRsFiStatusDone = 2;
/* FileInfo(); */
int searchId; /* 0 if none */
std::string path;
std::string fname;
std::string hash;
std::string ext;
uint64_t size;
uint64_t avail; /* how much we have */
int status;
double rank;
int age;
uint32_t queue_position ;
/* Transfer Stuff */
uint64_t transfered;
double tfRate; /* in kbytes */
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
std::list<TransferInfo> peers;
DwlSpeed priority ;
time_t lastTS;
};
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
/* matched to the uPnP states */
#define UPNP_STATE_UNINITIALISED 0
@ -248,14 +202,72 @@ class SearchRequest
* (TODO)
*/
#define DIR_FLAGS_LOCAL 0x1000
#define DIR_FLAGS_REMOTE 0x2000
const FileStorageFlags DIR_FLAGS_PARENT ( 0x0001 );
const FileStorageFlags DIR_FLAGS_DETAILS ( 0x0002 ); // apparently unused
const FileStorageFlags DIR_FLAGS_CHILDREN ( 0x0004 ); // apparently unused
const FileStorageFlags DIR_FLAGS_NETWORK_WIDE_OTHERS ( 0x0080 ); // Flags for directory sharing permissions. The last
const FileStorageFlags DIR_FLAGS_BROWSABLE_OTHERS ( 0x0100 ); // one should be the OR of the all four flags.
const FileStorageFlags DIR_FLAGS_NETWORK_WIDE_GROUPS ( 0x0200 );
const FileStorageFlags DIR_FLAGS_BROWSABLE_GROUPS ( 0x0400 );
const FileStorageFlags DIR_FLAGS_PERMISSIONS_MASK ( DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_OTHERS
| DIR_FLAGS_NETWORK_WIDE_GROUPS | DIR_FLAGS_BROWSABLE_GROUPS );
const FileStorageFlags DIR_FLAGS_LOCAL ( 0x1000 );
const FileStorageFlags DIR_FLAGS_REMOTE ( 0x2000 );
class FileInfo
{
/* old BaseInfo Entries */
public:
FileInfo() : mId(0) { return; }
RsCertId id; /* key for matching everything */
FileStorageFlags storage_permission_flags; // Combination of the four RS_DIR_FLAGS_*. Updated when the file is a local stored file.
TransferRequestFlags transfer_info_flags ; // various flags from RS_FILE_HINTS_*
/* allow this to be tweaked by the GUI Model */
mutable unsigned int mId; /* (GUI) Model Id -> unique number */
/* Old FileInfo Entries */
public:
static const int kRsFiStatusNone = 0;
static const int kRsFiStatusStall = 1;
static const int kRsFiStatusProgress = 2;
static const int kRsFiStatusDone = 2;
/* FileInfo(); */
int searchId; /* 0 if none */
std::string path;
std::string fname;
std::string hash;
std::string ext;
uint64_t size;
uint64_t avail; /* how much we have */
int status;
double rank;
int age;
uint32_t queue_position ;
/* Transfer Stuff */
uint64_t transfered;
double tfRate; /* in kbytes */
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
std::list<TransferInfo> peers;
DwlSpeed priority ;
time_t lastTS;
std::list<std::string> parent_groups ;
};
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
#define DIR_FLAGS_PARENT 0x0001
#define DIR_FLAGS_DETAILS 0x0002
#define DIR_FLAGS_CHILDREN 0x0004
#define DIR_FLAGS_NETWORK_WIDE 0x0008
#define DIR_FLAGS_BROWSABLE 0x0010
class DirStub
{
@ -279,22 +291,23 @@ class DirDetails
std::string path;
uint64_t count;
uint32_t age;
uint32_t flags;
FileStorageFlags flags;
uint32_t min_age ; // minimum age of files in this subtree
std::list<DirStub> children;
std::list<std::string> parent_groups; // parent groups for the shared directory
};
class FileDetail
{
public:
std::string id;
std::string name;
std::string hash;
std::string path;
uint64_t size;
uint32_t age;
uint32_t rank;
std::string id;
std::string name;
std::string hash;
std::string path;
uint64_t size;
uint32_t age;
uint32_t rank;
};
class CompressedChunkMap ;
@ -314,7 +327,6 @@ class FileChunksInfo
uint64_t file_size ; // real size of the file
uint32_t chunk_size ; // size of chunks
uint32_t flags ;
uint32_t strategy ;
// dl state of chunks. Only the last chunk may have size < chunk_size

View File

@ -1100,6 +1100,43 @@ bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<std
return mPeerMgr->assignPeersToGroup(groupId, peerIds, assign);
}
FileSearchFlags p3Peers::computePeerPermissionFlags(const std::string& peer_ssl_id,
FileStorageFlags share_flags,
const std::list<std::string>& directory_parent_groups)
{
// We should be able to do that in O(1), using groups based on packs of bits.
//
// But for now, because the implementation of groups is not totally decided yet, we revert to this
// very simple algorithm.
//
bool found = false ;
std::string pgp_id = getGPGId(peer_ssl_id) ;
for(std::list<std::string>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it)
{
RsGroupInfo info ;
if(!getGroupInfo(*it,info))
{
std::cerr << "(EE) p3Peers::computePeerPermissionFlags: no group named " << *it << ": cannot get info." << std::endl;
continue ;
}
for(std::list<std::string>::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2)
if(*it2 == pgp_id)
found = true ;
}
bool network_wide = (share_flags & DIR_FLAGS_NETWORK_WIDE_OTHERS) ;//|| ( (share_flags & DIR_FLAGS_NETWORK_WIDE_GROUPS) && found) ;
bool browsable = (share_flags & DIR_FLAGS_BROWSABLE_OTHERS) || ( (share_flags & DIR_FLAGS_BROWSABLE_GROUPS) && found) ;
FileSearchFlags final_flags ;
if(network_wide) final_flags |= RS_FILE_HINTS_NETWORK_WIDE ;
if(browsable ) final_flags |= RS_FILE_HINTS_BROWSABLE ;
return final_flags ;
}
RsPeerDetails::RsPeerDetails()
:isOnlyGPGdetail(false),

View File

@ -121,6 +121,7 @@ virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign);
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign);
virtual FileSearchFlags computePeerPermissionFlags(const std::string& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
private:
p3LinkMgr *mLinkMgr;

View File

@ -170,20 +170,24 @@ void RsFileConfigItem::clear()
file.TlvClear();
flags = 0;
parent_groups.clear() ;
}
std::ostream &RsFileConfigItem::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsFileConfigItem", indent);
printRsItemBase(out, "RsFileConfigItem", indent);
uint16_t int_Indent = indent + 2;
file.print(out, int_Indent);
printIndent(out, int_Indent);
out << "flags: " << flags << std::endl;
printIndent(out, int_Indent); out << "flags: " << flags << std::endl;
printIndent(out, int_Indent); out << "groups:" ;
printRsItemEnd(out, "RsFileConfigItem", indent);
return out;
for(std::list<std::string>::const_iterator it(parent_groups.begin());it!=parent_groups.end();++it)
out << (*it) << " " ;
out << std::endl;
printRsItemEnd(out, "RsFileConfigItem", indent);
return out;
}
/*************************************************************************/
@ -348,7 +352,10 @@ uint32_t RsFileConfigSerialiser::sizeFileItem(RsFileConfigItem *item)
{
uint32_t s = 8; /* header */
s += item->file.TlvSize();
s += 4;
s += 4; // flags
for(std::list<std::string>::const_iterator it(item->parent_groups.begin());it!=item->parent_groups.end();++it) // parent groups
s += GetTlvStringSize(*it);
return s;
}
@ -377,9 +384,11 @@ bool RsFileConfigSerialiser::serialiseFileItem(RsFileConfigItem *item, void
/* add mandatory parts first */
ok &= item->file.SetTlv(data, tlvsize, &offset);
ok &= setRawUInt32(data, tlvsize, &offset, item->flags);
for(std::list<std::string>::const_iterator it(item->parent_groups.begin());ok && it!=item->parent_groups.end();++it) // parent groups
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GROUPID, *it);
if (offset != tlvsize)
{
ok = false;
@ -427,6 +436,15 @@ RsFileConfigItem *RsFileConfigSerialiser::deserialiseFileItem(void *data, uint32
ok &= item->file.GetTlv(data, rssize, &offset);
ok &= getRawUInt32(data, rssize, &offset, &(item->flags));
while(offset < rssize)
{
std::string tmp ;
if(GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GROUPID, tmp))
item->parent_groups.push_back(tmp) ;
else
break ;
}
if (offset != rssize)
{
/* error */

View File

@ -300,6 +300,7 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
RsTlvFileItem file;
uint32_t flags;
std::list<std::string> parent_groups ;
};
/**************************************************************************/

View File

@ -475,8 +475,7 @@ bool p3Channels::channelExtraFileHash(const std::string &path, const std::string
// reverse string buff for correct file name
fname.append(fnameBuff.rbegin(), fnameBuff.rend());
uint32_t flags = RS_FILE_HINTS_NETWORK_WIDE;
TransferRequestFlags flags = RS_FILE_REQ_ANONYMOUS_ROUTING;
// then hash file and get file info too
@ -490,14 +489,15 @@ bool p3Channels::channelExtraFileHash(const std::string &path, const std::string
}
bool p3Channels::channelExtraFileRemove(const std::string &hash, const std::string &chId){
uint32_t flags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_EXTRA;
bool p3Channels::channelExtraFileRemove(const std::string &hash, const std::string &chId)
{
TransferRequestFlags tflags = RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA;
FileSearchFlags sflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_EXTRA;
/* remove copy from channels directory */
FileInfo fInfo;
mRsFiles->FileDetails(hash, flags, fInfo);
mRsFiles->FileDetails(hash, sflags, fInfo);
std::string chPath = mChannelsDir + "/" + chId + "/" + fInfo.fname;
if(remove(chPath.c_str()) == 0){
@ -509,8 +509,7 @@ bool p3Channels::channelExtraFileRemove(const std::string &hash, const std::stri
<< chPath.c_str() << std::endl;
}
return mRsFiles->ExtraFileRemove(hash, flags);
return mRsFiles->ExtraFileRemove(hash, tflags);
}
@ -835,7 +834,7 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, con
std::string channelname = grpId;
std::string localpath;
uint32_t flags;
TransferRequestFlags flags;
// send to download directory if file is private
// We also add explicit sources only if the channel is private. Otherwise we DL in network wide mode
@ -846,14 +845,14 @@ bool p3Channels::locked_eventDuplicateMsg(GroupInfo *grp, RsDistribMsg *msg, con
if(chanPrivate)
{
localpath = mChannelsDir;
flags = RS_FILE_HINTS_BACKGROUND | RS_FILE_HINTS_EXTRA;
flags = RS_FILE_REQ_BACKGROUND | RS_FILE_REQ_EXTRA;
srcIds.push_back(id);
}
else
{
localpath = ""; // forces dl to default directory
flags = RS_FILE_HINTS_BACKGROUND | RS_FILE_HINTS_NETWORK_WIDE;
flags = RS_FILE_REQ_BACKGROUND | RS_FILE_REQ_ANONYMOUS_ROUTING;
}
/* download it ... and flag for ExtraList

View File

@ -1840,7 +1840,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item)
#ifdef P3TURTLE_DEBUG
std::cerr << " Request not from us. Performing local search" << std::endl ;
#endif
found = (_sharing_strategy != SHARE_FRIENDS_ONLY || item->depth < 2) && performLocalHashSearch(item->file_hash,info) ;
found = (_sharing_strategy != SHARE_FRIENDS_ONLY || item->depth < 2) && performLocalHashSearch(item->file_hash,item->PeerId(),info) ;
}
{
@ -2092,7 +2092,7 @@ void RsTurtleStringSearchRequestItem::performLocalSearch(std::list<TurtleFileInf
std::cerr << "Performing rsFiles->search()" << std::endl ;
#endif
// now, search!
rsFiles->SearchKeywords(words, initialResults,DIR_FLAGS_LOCAL | DIR_FLAGS_NETWORK_WIDE);
rsFiles->SearchKeywords(words, initialResults,RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE,PeerId());
#ifdef P3TURTLE_DEBUG
std::cerr << initialResults.size() << " matches found." << std::endl ;
@ -2130,12 +2130,20 @@ void RsTurtleRegExpSearchRequestItem::performLocalSearch(std::list<TurtleFileInf
return ;
// now, search!
rsFiles->SearchBoolExp(exp,initialResults,DIR_FLAGS_LOCAL | DIR_FLAGS_NETWORK_WIDE);
rsFiles->SearchBoolExp(exp,initialResults,RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE,PeerId());
result.clear() ;
for(std::list<DirDetails>::const_iterator it(initialResults.begin());it!=initialResults.end();++it)
{
// retain only file type
if (it->type == DIR_TYPE_DIR)
{
#ifdef P3TURTLE_DEBUG
std::cerr << " Skipping directory " << it->name << std::endl ;
#endif
continue;
}
TurtleFileInfo i ;
i.hash = it->hash ;
i.size = it->count ;
@ -2276,9 +2284,31 @@ 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,FileInfo& info)
bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,const std::string& peer_id,FileInfo& info)
{
return rsFiles->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);
bool res = rsFiles->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);
#ifdef P3TURTLE_DEBUG
std::cerr << "p3turtle: performing local hash search for hash " << hash << std::endl;
if(res)
{
std::cerr << "Found hash: " << std::endl;
std::cerr << " hash = " << hash << std::endl;
std::cerr << " peer = " << peer_id << std::endl;
std::cerr << " flags = " << info.storage_permission_flags << std::endl;
std::cerr << " local = " << rsFiles->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) << std::endl;
std::cerr << " groups= " ; for(std::list<std::string>::const_iterator it(info.parent_groups.begin());it!=info.parent_groups.end();++it) std::cerr << (*it) << ", " ; std::cerr << std::endl;
std::cerr << " clear = " << rsPeers->computePeerPermissionFlags(peer_id,info.storage_permission_flags,info.parent_groups) << std::endl;
}
#endif
// The call to computeHashPeerClearance() return a combination of RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE
// This is an additional computation cost, but the way it's written here, it's only called when res is true.
//
res = res && (RS_FILE_HINTS_NETWORK_WIDE & rsPeers->computePeerPermissionFlags(peer_id,info.storage_permission_flags,info.parent_groups)) ;
return res ;
}
static std::string printFloatNumber(float num,bool friendly=false)

View File

@ -213,7 +213,7 @@ class TurtleFileHashInfo
// p3Config | ConfigChanged() | used to load/save .cfg file for turtle variales.
// -----------+------------------+------------------------------------------------------
//
class p3turtle: public p3Service, /*public pqiMonitor,*/ public RsTurtle,/* public ftSearch */ public p3Config
class p3turtle: public p3Service, public RsTurtle, public p3Config
{
public:
p3turtle(p3LinkMgr *lm,ftServer *m);
@ -371,8 +371,8 @@ class p3turtle: public p3Service, /*public pqiMonitor,*/ public RsTurtle,/* publ
/// Returns a search result upwards (possibly to the gui)
void returnSearchResult(RsTurtleSearchResultItem *item) ;
/// Returns true if the file with given hash is hosted locally.
virtual bool performLocalHashSearch(const TurtleFileHash& hash,FileInfo& info) ;
/// Returns true if the file with given hash is hosted locally, and accessible in anonymous mode the supplied peer.
virtual bool performLocalHashSearch(const TurtleFileHash& hash,const std::string& client_peer_id,FileInfo& info) ;
//--------------------------- Local variables --------------------------------//

View File

@ -261,8 +261,8 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info
y += text_height ; painter->drawText(20,y,tr("Chunk strategy") + ":") ; painter->drawText(tab_size,y,(info.strategy==FileChunksInfo::CHUNK_STRATEGY_RANDOM)?"Random":"Streaming") ;
y += block_sep ;
y += text_height ; painter->drawText(20,y,tr("Transfer type") + ":") ;
if(info.flags & RS_FILE_HINTS_NETWORK_WIDE) painter->drawText(tab_size,y,tr("Anonymous F2F")) ;
if(info.flags & RS_FILE_HINTS_ASSUME_AVAILABILITY) painter->drawText(tab_size,y,tr("Direct friend transfer / Availability assumed")) ;
if(nfo.transfer_info_flags & RS_FILE_REQ_ANONYMOUS_ROUTING) painter->drawText(tab_size,y,tr("Anonymous F2F")) ;
if(nfo.transfer_info_flags & RS_FILE_REQ_ASSUME_AVAILABILITY) painter->drawText(tab_size,y,tr("Direct friend transfer / Availability assumed")) ;
y += text_height ;
y += block_sep ;

View File

@ -31,6 +31,7 @@
#include <retroshare/rsfiles.h>
#include <retroshare/rsiface.h>
#include <retroshare/rspeers.h>
#include <retroshare/rstypes.h>
#include "settings/rsharesettings.h"
@ -211,7 +212,7 @@ void QuickStartWizard::on_pushButtonSharesAdd_clicked()
{
SharedDirInfo sdi ;
sdi.filename = dir ;
sdi.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
sdi.shareflags = DIR_FLAGS_BROWSABLE_OTHERS | DIR_FLAGS_NETWORK_WIDE_OTHERS ;
rsFiles->addSharedDirectory(sdi);
@ -307,8 +308,8 @@ void QuickStartWizard::loadShare()
QCheckBox *cb1 = new QCheckBox ;
QCheckBox *cb2 = new QCheckBox ;
cb1->setChecked( (*it).shareflags & RS_FILE_HINTS_NETWORK_WIDE ) ;
cb2->setChecked( (*it).shareflags & RS_FILE_HINTS_BROWSABLE ) ;
cb1->setChecked( (*it).shareflags & DIR_FLAGS_NETWORK_WIDE_OTHERS ) ;
cb2->setChecked( (*it).shareflags & DIR_FLAGS_BROWSABLE_OTHERS ) ;
cb1->setToolTip(QString("If checked, the share is anonymously shared to anybody.")) ;
cb2->setToolTip(QString("If checked, the share is browsable by your friends.")) ;
@ -339,11 +340,11 @@ void QuickStartWizard::updateFlags(bool b)
for(it = dirs.begin(); it != dirs.end(); it++,++row)
{
std::cerr << "Looking for row=" << row << ", file=" << (*it).filename << ", flags=" << (*it).shareflags << std::endl ;
uint32_t current_flags = 0 ;
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,1)))->isChecked()? RS_FILE_HINTS_NETWORK_WIDE:0 ;
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,2)))->isChecked()? RS_FILE_HINTS_BROWSABLE:0 ;
FileStorageFlags current_flags(0u) ;
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,1)))->isChecked()? DIR_FLAGS_NETWORK_WIDE_OTHERS:(FileStorageFlags)0u ;
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,2)))->isChecked()? DIR_FLAGS_BROWSABLE_OTHERS :(FileStorageFlags)0u ;
if( (*it).shareflags ^ current_flags )
if( ((*it).shareflags ^ current_flags).toUInt32() )
{
(*it).shareflags = current_flags ;
rsFiles->updateShareFlags(*it) ; // modifies the flags

View File

@ -91,11 +91,7 @@ bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const
void *ref = parent.internalPointer();
DirDetails details;
uint32_t flags = DIR_FLAGS_CHILDREN;
if (RemoteMode)
flags |= DIR_FLAGS_REMOTE;
else
flags |= DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (!requestDirDetails(ref, details, flags))
{
@ -152,11 +148,7 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const
void *ref = (parent.isValid())? parent.internalPointer() : NULL ;
DirDetails details;
uint32_t flags = DIR_FLAGS_CHILDREN;
if (RemoteMode)
flags |= DIR_FLAGS_REMOTE;
else
flags |= DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (!requestDirDetails(ref, details, flags))
{
@ -202,16 +194,28 @@ int FlatStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
{
return 5;
}
QString RetroshareDirModel::getFlagsString(uint32_t flags)
QString RetroshareDirModel::getFlagsString(FileStorageFlags flags)
{
switch(flags & (DIR_FLAGS_NETWORK_WIDE|DIR_FLAGS_BROWSABLE))
char str[11] = "- - -" ;
if(flags & DIR_FLAGS_BROWSABLE_GROUPS) str[0] = 'B' ;
//if(flags & DIR_FLAGS_NETWORK_WIDE_GROUPS) str[3] = 'N' ;
if(flags & DIR_FLAGS_BROWSABLE_OTHERS) str[3] = 'B' ;
if(flags & DIR_FLAGS_NETWORK_WIDE_OTHERS) str[6] = 'N' ;
return QString(str) ;
}
QString RetroshareDirModel::getGroupsString(const std::list<std::string>& groups)
{
QString groups_str ;
for(std::list<std::string>::const_iterator it(groups.begin());it!=groups.end();)
{
case DIR_FLAGS_NETWORK_WIDE: return tr("Anonymous") ;
case DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE: return tr("Anonymous and browsable by friends") ;
case DIR_FLAGS_BROWSABLE: return tr("Only browsable by friends") ;
default:
return QString() ;
groups_str += QString::fromStdString(*it) ;
if(++it != groups.end())
groups_str += ", " ;
}
return groups_str ;
}
QString RetroshareDirModel::getAgeIndicatorString(const DirDetails &details) const
@ -320,13 +324,16 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
return misc::userFriendlyDuration(details.age);
case 3:
return getFlagsString(details.flags);
// case 4:
// {
// QString ind("");
// if (ageIndicator != IND_ALWAYS)
// ind = getAgeIndicatorString(details);
// return ind;
// }
case 4:
{
QString ind("");
if (ageIndicator != IND_ALWAYS)
ind = getAgeIndicatorString(details);
return ind;
}
return getGroupsString(details.parent_groups) ;
default:
return tr("FILE");
}
@ -348,6 +355,9 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
return misc::userFriendlyDuration(details.min_age);
case 3:
return getFlagsString(details.flags);
case 4:
return getGroupsString(details.parent_groups) ;
default:
return tr("DIR");
}
@ -359,7 +369,7 @@ QString FlatStyle_RDM::computeDirectoryPath(const DirDetails& details) const
{
QString dir ;
DirDetails det(details) ;
uint32_t flags = (RemoteMode)?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if(!requestDirDetails(det.parent,det,flags))
return QString();
@ -500,11 +510,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
int coln = index.column();
DirDetails details;
uint32_t flags = DIR_FLAGS_DETAILS;
if (RemoteMode)
flags |= DIR_FLAGS_REMOTE;
else
flags |= DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (!requestDirDetails(ref, details, flags))
return QVariant();
@ -564,12 +570,8 @@ void RetroshareDirModel::getAgeIndicatorRec(DirDetails &details, QString &ret) c
for (it = details.children.begin(); it != details.children.end(); it++) {
void *ref = it->ref;
DirDetails childDetails;
uint32_t flags;
if (RemoteMode)
flags |= DIR_FLAGS_REMOTE;
else
flags |= DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (requestDirDetails(ref, childDetails, flags) && ret == tr(""))
getAgeIndicatorRec(childDetails, ret);
@ -612,7 +614,10 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
else
return tr("Share Type");
case 4:
return tr("What's new");
if (RemoteMode)
return tr("What's new");
else
return tr("Groups");
}
return QString("Column %1").arg(section);
}
@ -683,11 +688,7 @@ QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent
********/
DirDetails details;
uint32_t flags = DIR_FLAGS_CHILDREN;
if (RemoteMode)
flags |= DIR_FLAGS_REMOTE;
else
flags |= DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (!requestDirDetails(ref, details, flags))
{
@ -766,7 +767,7 @@ QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
void *ref = index.internalPointer();
DirDetails details;
uint32_t flags = (RemoteMode)?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (!requestDirDetails(ref, details, flags))
{
@ -817,11 +818,7 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
void *ref = index.internalPointer();
DirDetails details;
uint32_t flags = DIR_FLAGS_DETAILS;
if (RemoteMode)
flags |= DIR_FLAGS_REMOTE;
else
flags |= DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (!requestDirDetails(ref, details, flags))
return Qt::ItemIsSelectable; // Error.
@ -871,7 +868,7 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
#endif
}
bool RetroshareDirModel::requestDirDetails(void *ref,DirDetails& details,uint32_t flags) const
bool RetroshareDirModel::requestDirDetails(void *ref,DirDetails& details,FileSearchFlags flags) const
{
// We should use a cache instead of calling RsFiles::RequestDirDetails(), which is very costly
// due to some pointer checking crap.
@ -929,7 +926,7 @@ void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
std::list<std::string> srcIds;
srcIds.push_back(details.id);
rsFiles -> FileRequest(details.name, details.hash,
details.count, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds);
details.count, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
}
/* if it is a dir, copy all files included*/
else if (details.type == DIR_TYPE_DIR)
@ -950,7 +947,7 @@ void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int pr
QString cleanPath = QDir::cleanPath(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()) + "/" + QString::fromUtf8(dirDetails.path.substr(prefixLen).c_str()));
srcIds.push_back(dirDetails.id);
rsFiles->FileRequest(dirDetails.name, dirDetails.hash, dirDetails.count, cleanPath.toUtf8().constData(), RS_FILE_HINTS_NETWORK_WIDE, srcIds);
rsFiles->FileRequest(dirDetails.name, dirDetails.hash, dirDetails.count, cleanPath.toUtf8().constData(), RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
}
else if (dirDetails.type & DIR_TYPE_DIR)
{
@ -965,7 +962,7 @@ void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int pr
if (!it->ref) continue;
DirDetails subDirDetails;
uint32_t flags = DIR_FLAGS_CHILDREN | DIR_FLAGS_REMOTE;
FileSearchFlags flags = RS_FILE_HINTS_REMOTE ;
if (!requestDirDetails(it->ref, subDirDetails, flags)) continue;
@ -987,20 +984,10 @@ void RetroshareDirModel::getDirDetailsFromSelect (const QModelIndexList &list, s
void *ref = it -> internalPointer();
DirDetails details;
uint32_t flags = DIR_FLAGS_DETAILS;
if (RemoteMode)
{
flags |= DIR_FLAGS_REMOTE;
}
else
{
flags |= DIR_FLAGS_LOCAL;
}
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (!requestDirDetails(ref, details, flags))
{
continue;
}
dirVec.push_back(details);
}
@ -1035,12 +1022,7 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s
void *ref = it -> internalPointer();
DirDetails details;
uint32_t flags = DIR_FLAGS_DETAILS;
if (RemoteMode)
flags |= DIR_FLAGS_REMOTE;
else
flags |= DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (!requestDirDetails(ref, details, flags))
continue;
@ -1136,10 +1118,8 @@ void RetroshareDirModel::getFilePaths(const QModelIndexList &list, std::list<std
void *ref = it -> internalPointer();
DirDetails details;
uint32_t flags = DIR_FLAGS_DETAILS;
flags |= DIR_FLAGS_LOCAL;
if (!requestDirDetails(ref, details, flags))
if (!requestDirDetails(ref, details, RS_FILE_HINTS_LOCAL))
{
#ifdef RDM_DEBUG
std::cerr << "getFilePaths() Bad Request" << std::endl;
@ -1193,15 +1173,7 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
void *ref = it -> internalPointer();
DirDetails details;
uint32_t flags = DIR_FLAGS_DETAILS;
if (RemoteMode)
{
flags |= DIR_FLAGS_REMOTE;
}
else
{
flags |= DIR_FLAGS_LOCAL;
}
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
if (!requestDirDetails(ref, details, flags))
{
@ -1278,7 +1250,7 @@ int RetroshareDirModel::getType ( const QModelIndex & index ) const
//if (RemoteMode) // only local files can be opened
// return ;
uint32_t flags = RemoteMode?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
FileSearchFlags flags = (RemoteMode)?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL;
return rsFiles->getType(index.internalPointer(),flags);
}
@ -1327,10 +1299,9 @@ void FlatStyle_RDM::updateRefs()
std::cerr << "FlatStyle_RDM::postMods(): poped ref " << ref << std::endl;
#endif
_ref_stack.pop_back() ;
uint32_t flags = DIR_FLAGS_DETAILS;
DirDetails details ;
if (requestDirDetails(ref, details, flags))
if (requestDirDetails(ref, details, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_REMOTE))
{
if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons.
_ref_entries.push_back(std::pair<void*,QString>(ref,computeDirectoryPath(details)));

View File

@ -26,6 +26,7 @@
#include <QIcon>
#include <vector>
#include <stdint.h>
#include <retroshare/rstypes.h>
class DirDetails;
@ -65,7 +66,7 @@ class RetroshareDirModel : public QAbstractItemModel
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
bool requestDirDetails(void *ref,DirDetails& details,uint32_t flags) const;
bool requestDirDetails(void *ref,DirDetails& details,FileSearchFlags flags) const;
void update() ;
public:
@ -79,7 +80,8 @@ class RetroshareDirModel : public QAbstractItemModel
void treeStyle();
void downloadDirectory(const DirDetails & details, int prefixLen);
static QString getFlagsString(uint32_t) ;
static QString getFlagsString(FileStorageFlags f) ;
static QString getGroupsString(const std::list<std::string>&) ;
QString getAgeIndicatorString(const DirDetails &) const;
void getAgeIndicatorRec(DirDetails &details, QString &ret) const;

View File

@ -973,7 +973,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
srcIds.push_back((*it).peerId) ;
}
if (rsFiles->FileRequest(link.name().toUtf8().constData(), link.hash().toStdString(), link.size(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) {
if (rsFiles->FileRequest(link.name().toUtf8().constData(), link.hash().toStdString(), link.size(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds)) {
fileAdded.append(link.name());
} else {
fileExist.append(link.name());

View File

@ -353,7 +353,7 @@ void SearchDialog::download()
std::string 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_HINTS_NETWORK_WIDE, srcIds))
if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toUtf8().constData(), hash, (item->text(SR_SIZE_COL)).toULongLong(), "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds))
attemptDownloadLocal = true ;
else
{
@ -384,7 +384,7 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString
rsFiles->FileRequest(item->text(SR_NAME_COL).toUtf8().constData(),
hash,
item->text(SR_SIZE_COL).toULongLong(),
cleanPath.toUtf8().constData(),RS_FILE_HINTS_NETWORK_WIDE, srcIds);
cleanPath.toUtf8().constData(),RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
std::cout << "SearchDialog::downloadDirectory(): "\
"issuing file request from search dialog: -"
@ -607,7 +607,7 @@ void SearchDialog::advancedSearch(Expression* expression)
// The text "bool exp" should be replaced by an appropriate text describing the actual search.
initSearchResult("bool exp",req_id, ui.FileTypeComboBox->currentIndex(), true) ;
rsFiles -> SearchBoolExp(expression, results, DIR_FLAGS_REMOTE | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE);
rsFiles -> SearchBoolExp(expression, results, RS_FILE_HINTS_REMOTE);// | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE);
/* abstraction to allow reusee of tree rendering code */
resultsToTree(advSearchDialog->getSearchAsString(),req_id, results);
@ -689,7 +689,7 @@ void SearchDialog::searchKeywords(const QString& keywords)
{
std::list<DirDetails> initialResults;
rsFiles->SearchBoolExp(&exprs, initialResults, DIR_FLAGS_REMOTE) ;
rsFiles->SearchBoolExp(&exprs, initialResults, RS_FILE_HINTS_REMOTE) ;
/* which extensions do we use? */
DirDetails dd;
@ -705,7 +705,7 @@ void SearchDialog::searchKeywords(const QString& keywords)
{
std::list<DirDetails> initialResults;
rsFiles->SearchBoolExp(&exprs, initialResults, DIR_FLAGS_LOCAL | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE) ;
rsFiles->SearchBoolExp(&exprs, initialResults, RS_FILE_HINTS_LOCAL);// | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE) ;
/* which extensions do we use? */
DirDetails dd;
@ -859,7 +859,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons
/* go through all children directories/files for a recursive call */
for (std::list<DirStub>::const_iterator it(dir.children.begin()); it != dir.children.end(); it ++) {
DirDetails details;
rsFiles->RequestDirDetails(it->ref, details, 0);
rsFiles->RequestDirDetails(it->ref, details, FileSearchFlags(0u));
insertDirectory(txt, searchId, details, child);
}
}

View File

@ -21,11 +21,19 @@
#include "ShareDialog.h"
#include <retroshare/rsfiles.h>
#include <retroshare/rstypes.h>
#include <QContextMenuEvent>
#include <QFileDialog>
#include <QMessageBox>
#include <QLayout>
#include <QTextEdit>
#include <QComboBox>
#include <QSizePolicy>
#include <QGroupBox>
#include <gui/common/GroupSelectionBox.h>
#include <gui/common/GroupFlagsWidget.h>
/** Default constructor */
ShareDialog::ShareDialog(std::string filename, QWidget *parent, Qt::WFlags flags)
@ -43,16 +51,43 @@ ShareDialog::ShareDialog(std::string filename, QWidget *parent, Qt::WFlags flags
ui.okButton->setEnabled(false);
if (filename.empty()) {
ui.networkwideCheckBox->setChecked(true);
} else {
/* edit exisiting share */
QVBoxLayout *vbox = new QVBoxLayout() ;
QHBoxLayout *hb2 = new QHBoxLayout() ;
hb2->addWidget(new QLabel(tr("Share flags and groups: "))) ;
groupflagsbox = new GroupFlagsWidget(ui.shareflags_GB) ;
groupflagsbox->setFlags(DIR_FLAGS_NETWORK_WIDE_OTHERS) ; // default value
messageBox = new QTextEdit(ui.shareflags_GB) ;
messageBox->setReadOnly(true) ;
messageBox->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred)) ;
hb2->addWidget(groupflagsbox) ;
vbox->addLayout(hb2) ;
vbox->addWidget(messageBox) ;
QHBoxLayout *hbox = new QHBoxLayout() ;
groupselectionbox = new GroupSelectionBox(ui.shareflags_GB);
hbox->addLayout(vbox) ;
hbox->addWidget(groupselectionbox) ;
ui.shareflags_GB->setLayout(hbox) ;
updateInfoMessage() ;
connect(groupselectionbox,SIGNAL(itemSelectionChanged()),this,SLOT(updateInfoMessage())) ;
connect(groupflagsbox,SIGNAL(flagsChanged(FileStorageFlags)),this,SLOT(updateInfoMessage())) ;
if (!filename.empty())
{
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
std::list<SharedDirInfo>::const_iterator it;
for (it = dirs.begin(); it != dirs.end(); it++) {
if (it->filename == filename) {
if (it->filename == filename)
{
/* fill dialog */
ui.okButton->setEnabled(true);
@ -61,14 +96,20 @@ ShareDialog::ShareDialog(std::string filename, QWidget *parent, Qt::WFlags flags
ui.browseButton->setDisabled(true);
ui.virtualpath_lineEdit->setText(QString::fromUtf8(it->virtualname.c_str()));
ui.browsableCheckBox->setChecked(it->shareflags & RS_FILE_HINTS_BROWSABLE);
ui.networkwideCheckBox->setChecked(it->shareflags & RS_FILE_HINTS_NETWORK_WIDE);
groupflagsbox->setFlags(it->shareflags) ;
groupselectionbox->setSelectedGroups(it->parent_groups) ;
break;
}
}
}
}
void ShareDialog::updateInfoMessage()
{
messageBox->setText(GroupFlagsWidget::groupInfoString(groupflagsbox->flags(),groupselectionbox->selectedGroups())) ;
}
void ShareDialog::browseDirectory()
{
/* select a dir*/
@ -88,20 +129,16 @@ void ShareDialog::addDirectory()
SharedDirInfo sdi ;
sdi.filename = ui.localpath_lineEdit->text().toUtf8().constData();
sdi.virtualname = ui.virtualpath_lineEdit->text().toUtf8().constData();
sdi.shareflags = groupflagsbox->flags() ;
sdi.parent_groups = groupselectionbox->selectedGroups() ;
sdi.shareflags = 0;
if (ui.browsableCheckBox->isChecked()) {
sdi.shareflags |= RS_FILE_HINTS_BROWSABLE ;
}
if (ui.networkwideCheckBox->isChecked()) {
sdi.shareflags |= RS_FILE_HINTS_NETWORK_WIDE;
}
if (ui.localpath_lineEdit->isEnabled()) {
if (ui.localpath_lineEdit->isEnabled())
{
/* add new share */
rsFiles->addSharedDirectory(sdi);
} else {
}
else
{
/* edit exisiting share */
bool found = false;
@ -115,13 +152,15 @@ void ShareDialog::addDirectory()
if (it->virtualname != sdi.virtualname) {
/* virtual name changed, remove shared directory and add it again */
rsFiles->removeSharedDirectory(it->filename);
rsFiles->addSharedDirectory(sdi);
break;
}
if (it->shareflags ^ sdi.shareflags) {
if (it->shareflags != sdi.shareflags || it->parent_groups != sdi.parent_groups) {
/* modifies the flags */
it->shareflags = sdi.shareflags;
it->parent_groups = sdi.parent_groups;
rsFiles->updateShareFlags(*it);
break;
}

View File

@ -26,22 +26,30 @@
#include "ui_ShareDialog.h"
class GroupFlagsWidget ;
class GroupSelectionBox ;
class QTextEdit ;
class ShareDialog : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
/** Default constructor */
ShareDialog( std::string filename, QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
public:
/** Default constructor */
ShareDialog( std::string filename, QWidget *parent = 0, Qt::WFlags flags = 0);
private slots:
void browseDirectory();
void addDirectory();
private slots:
void browseDirectory();
void addDirectory();
void updateInfoMessage() ;
private:
/** Qt Designer generated object */
Ui::ShareDialog ui;
private:
/** Qt Designer generated object */
Ui::ShareDialog ui;
GroupSelectionBox *groupselectionbox ;
GroupFlagsWidget *groupflagsbox ;
QTextEdit *messageBox ;
};
#endif

View File

@ -35,6 +35,9 @@
<property name="lineWidth">
<number>1</number>
</property>
<zorder>groupBox</zorder>
<zorder>frame_2</zorder>
<zorder>groupBox</zorder>
</widget>
</item>
<item row="1" column="0">
@ -45,17 +48,14 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="topMargin">
<number>6</number>
</property>
<item row="0" column="0" colspan="6">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Share Folder</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label">
@ -108,101 +108,87 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Share Flags</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="browsableCheckBox">
<property name="toolTip">
<string>Browseable by Friends</string>
</property>
<property name="text">
<string>Browsable</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="networkwideCheckBox">
<property name="toolTip">
<string>Anonymous shared Network Wide</string>
</property>
<property name="text">
<string>Network Wide</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="okButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="text">
<string>OK</string>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="shareflags_GB">
<property name="title">
<string>Share Flags</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="3">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>191</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="okButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="text">
<string>OK</string>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>191</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>

View File

@ -27,10 +27,12 @@
#include <QUrl>
#include <retroshare/rsfiles.h>
#include <retroshare/rstypes.h>
#include "ShareManager.h"
#include "ShareDialog.h"
#include "settings/rsharesettings.h"
#include <gui/common/GroupFlagsWidget.h>
/* Images for context menu icons */
#define IMAGE_CANCEL ":/images/delete.png"
@ -38,9 +40,8 @@
#define COLUMN_PATH 0
#define COLUMN_VIRTUALNAME 1
#define COLUMN_NETWORKWIDE 2
#define COLUMN_BROWSABLE 3
#define COLUMN_COUNT 3
#define COLUMN_SHARE_FLAGS 2
#define COLUMN_GROUPS 3
ShareManager *ShareManager::_instance = NULL ;
@ -73,15 +74,12 @@ ShareManager::ShareManager()
QHeaderView* header = ui.shareddirList->horizontalHeader();
header->setResizeMode( COLUMN_PATH, QHeaderView::Stretch);
header->setResizeMode(COLUMN_NETWORKWIDE, QHeaderView::Fixed);
header->setResizeMode(COLUMN_BROWSABLE, QHeaderView::Fixed);
//header->setResizeMode(COLUMN_NETWORKWIDE, QHeaderView::Fixed);
//header->setResizeMode(COLUMN_BROWSABLE, QHeaderView::Fixed);
header->setHighlightSections(false);
ui.shareddirList->setRangeSelected(QTableWidgetSelectionRange(0, 0, 0, COLUMN_COUNT), true);
setAcceptDrops(true);
setAttribute(Qt::WA_DeleteOnClose, true);
}
@ -124,79 +122,35 @@ void ShareManager::load()
/* set new row count */
listWidget->setRowCount(dirs.size());
connect(this,SIGNAL(itemClicked(QTableWidgetItem*)),this,SLOT(updateFlags(QTableWidgetItem*))) ;
#ifndef USE_COMBOBOX
QString ToolTips [2] = { tr("If checked, the share is anonymously shared to anybody."),
tr("If checked, the share is browsable by your friends.") };
int Flags [2] = { RS_FILE_HINTS_NETWORK_WIDE, RS_FILE_HINTS_BROWSABLE };
#endif
int row=0 ;
for(it = dirs.begin(); it != dirs.end(); it++,++row)
{
listWidget->setItem(row, COLUMN_PATH, new QTableWidgetItem(QString::fromUtf8((*it).filename.c_str())));
listWidget->setItem(row, COLUMN_VIRTUALNAME, new QTableWidgetItem(QString::fromUtf8((*it).virtualname.c_str())));
#ifdef USE_COMBOBOX
QComboBox *cb = new QComboBox ;
cb->addItem(QString("Network Wide")) ;
cb->addItem(QString("Browsable")) ;
cb->addItem(QString("Universal")) ;
GroupFlagsWidget *widget = new GroupFlagsWidget(NULL,(*it).shareflags);
cb->setToolTip(QString("Decide here whether this directory is\n* Network Wide: \tanonymously shared over the network (including your friends)\n* Browsable: \tbrowsable by your friends\n* Universal: \t\tboth")) ;
listWidget->setRowHeight(row, 32);
listWidget->setCellWidget(row, COLUMN_SHARE_FLAGS, widget);
// TODO
// - set combobox current value depending on what rsFiles reports.
// - use a signal mapper to get the correct row that contains the combo box sending the signal:
// mapper = new SignalMapper(this) ;
//
// for(all cb)
// {
// signalMapper->setMapping(cb,...)
// }
//
int index = 0 ;
index += ((*it).shareflags & RS_FILE_HINTS_NETWORK_WIDE) > 0 ;
index += (((*it).shareflags & RS_FILE_HINTS_BROWSABLE) > 0) * 2 ;
listWidget->setCellWidget(row,1,cb);
QString group_string ;
int n=0;
for(std::list<std::string>::const_iterator it2((*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2,++n)
{
if(n>0)
group_string += ", " ;
if(index < 1 || index > 3)
std::cerr << "******* ERROR IN FILE SHARING FLAGS. Flags = " << (*it).shareflags << " ***********" << std::endl ;
else
index-- ;
group_string += QString::fromStdString(*it2) ;
}
cb->setCurrentIndex(index) ;
#else
int col;
for (col = 0; col <= 1; col++) {
QModelIndex index = listWidget->model()->index(row, col + COLUMN_NETWORKWIDE, QModelIndex());
QWidget* widget = dynamic_cast<QWidget*>(listWidget->indexWidget(index));
QCheckBox* cb = NULL;
if (widget) {
cb = dynamic_cast<QCheckBox*>(widget->children().front());
}
if (cb == NULL) {
QWidget* widget = new QWidget;
listWidget->setItem(row, COLUMN_GROUPS, new QTableWidgetItem(group_string)) ;
listWidget->item(row,COLUMN_GROUPS)->setBackgroundColor(QColor(183,236,181)) ;
cb = new QCheckBox(widget);
cb->setToolTip(ToolTips [col]);
QHBoxLayout* layout = new QHBoxLayout(widget);
layout->addWidget(cb, 0, Qt::AlignCenter);
layout->setSpacing(0);
layout->setContentsMargins(10, 0, 0, 0); // to be centered
widget->setLayout(layout);
listWidget->setCellWidget(row, col + COLUMN_NETWORKWIDE, widget);
QObject::connect(cb, SIGNAL(toggled(bool)), this, SLOT(updateFlags(bool))) ;
}
cb->setChecked((*it).shareflags & Flags [col]);
}
#endif
connect(widget,SIGNAL(flagsChanged(FileStorageFlags)),this,SLOT(updateFlags())) ;
}
listWidget->setColumnWidth(COLUMN_SHARE_FLAGS,132) ;
//ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));
listWidget->update(); /* update display */
@ -225,12 +179,12 @@ void ShareManager::showYourself()
}
}
void ShareManager::updateFlags(bool b)
void ShareManager::updateFlags()
{
if(isLoading)
return ;
std::cerr << "Updating flags (b=" << b << ") !!!" << std::endl ;
std::cerr << "Updating flags" << std::endl;
std::list<SharedDirInfo>::iterator it;
std::list<SharedDirInfo> dirs;
@ -239,17 +193,15 @@ void ShareManager::updateFlags(bool b)
int row=0 ;
for(it = dirs.begin(); it != dirs.end(); it++,++row)
{
std::cerr << "Looking for row=" << row << ", file=" << (*it).filename << ", flags=" << (*it).shareflags << std::endl ;
uint32_t current_flags = 0 ;
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,COLUMN_NETWORKWIDE)->children().front()))->isChecked()? RS_FILE_HINTS_NETWORK_WIDE:0 ;
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,COLUMN_BROWSABLE)->children().front()))->isChecked()? RS_FILE_HINTS_BROWSABLE:0 ;
//std::cerr << "Looking for row=" << row << ", file=" << (*it).filename << ", flags=" << (*it).shareflags << std::endl ;
FileStorageFlags current_flags = (dynamic_cast<GroupFlagsWidget*>(ui.shareddirList->cellWidget(row,COLUMN_SHARE_FLAGS)))->flags() ;
if( (*it).shareflags ^ current_flags )
if( (*it).shareflags != current_flags )
{
(*it).shareflags = current_flags ;
rsFiles->updateShareFlags(*it) ; // modifies the flags
std::cout << "Updating share flags for directory " << (*it).filename << std::endl ;
std::cout << "Updating share flags for directory " << (*it).filename << " to " << current_flags << std::endl ;
}
}
}
@ -357,7 +309,7 @@ void ShareManager::dropEvent(QDropEvent *event)
sdi.filename = localpath.toUtf8().constData();
sdi.virtualname.clear();
sdi.shareflags = 0;
sdi.shareflags.clear() ;
/* add new share */
rsFiles->addSharedDirectory(sdi);

View File

@ -59,7 +59,7 @@ private slots:
void showShareDialog();
void editShareDirectory();
void removeShareDirectory();
void updateFlags(bool);
void updateFlags();
private:
static ShareManager *_instance;

View File

@ -81,14 +81,23 @@ p, li { white-space: pre-wrap; }
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>100</number>
<number>128</number>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
@ -108,7 +117,7 @@ p, li { white-space: pre-wrap; }
</column>
<column>
<property name="text">
<string>Network Wide</string>
<string>Share flags</string>
</property>
<property name="toolTip">
<string comment="If activated, the share is anonymously accessible to anybody"/>
@ -116,7 +125,7 @@ p, li { white-space: pre-wrap; }
</column>
<column>
<property name="text">
<string>Browsable</string>
<string>Parent groups</string>
</property>
<property name="toolTip">
<string comment="If checked, the share is browsable by your friends"/>

View File

@ -157,17 +157,12 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
/* Set header resize modes and initial section sizes */
QHeaderView * l_header = ui.localDirTreeView->header () ;
// l_header->setResizeMode (0, QHeaderView::Interactive);
// l_header->setResizeMode (1, QHeaderView::Fixed);
// l_header->setResizeMode (2, QHeaderView::Interactive);
// l_header->setResizeMode (3, QHeaderView::Interactive);
// l_header->setResizeMode (4, QHeaderView::Interactive);
l_header->resizeSection ( 0, 490 );
l_header->resizeSection ( 1, 70 );
l_header->resizeSection ( 2, 100 );
l_header->resizeSection ( 3, 100 );
// l_header->resizeSection ( 4, 100 );
l_header->resizeSection ( 4, 100 );
l_header->setStretchLastSection(false);
// l_header->setHighlightSections(false);
@ -210,7 +205,7 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
// Hide columns after loading the settings
ui.remoteDirTreeView->setColumnHidden(3,false) ;
ui.remoteDirTreeView->setColumnHidden(4,true) ;
ui.localDirTreeView->setColumnHidden(4,true) ;
ui.localDirTreeView->setColumnHidden(4,false) ;
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -468,11 +463,7 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
const DirStub& dirStub = *cit;
DirDetails details;
uint32_t flags = DIR_FLAGS_DETAILS;
if (remote)
flags |= DIR_FLAGS_REMOTE;
else
flags |= DIR_FLAGS_LOCAL;
FileSearchFlags flags = remote?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
// do not recursive copy sub dirs.
if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE)

View File

@ -945,7 +945,7 @@ void TransfersDialog::insertTransfers()
continue;
}
if ((fileInfo.flags & RS_FILE_HINTS_CACHE) && !showCacheTransfers) {
if ((fileInfo.transfer_info_flags & RS_FILE_REQ_CACHE) && !showCacheTransfers) {
// if file transfer is a cache file index file, don't show it
DLListModel->removeRow(row);
rowCount = DLListModel->rowCount();
@ -971,7 +971,7 @@ void TransfersDialog::insertTransfers()
continue;
}
if ((fileInfo.flags & RS_FILE_HINTS_CACHE) && !showCacheTransfers) {
if ((fileInfo.transfer_info_flags & RS_FILE_REQ_CACHE) && !showCacheTransfers) {
//if file transfer is a cache file index file, don't show it
continue;
}
@ -998,7 +998,7 @@ void TransfersDialog::insertTransfers()
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info))
continue;
if((info.flags & RS_FILE_HINTS_CACHE) && showCacheTransfers)
if((info.transfer_info_flags & RS_FILE_REQ_CACHE) && showCacheTransfers)
continue ;
std::list<TransferInfo>::iterator pit;

View File

@ -0,0 +1,174 @@
#include <QHBoxLayout>
#include <QSizePolicy>
#include "GroupFlagsWidget.h"
#include <retroshare/rsfiles.h>
#define FLAGS_GROUP_NETWORK_WIDE_ICON ":images/anonymous_128_green.png"
#define FLAGS_GROUP_BROWSABLE_ICON ":images/browsable_128_green.png"
#define FLAGS_GROUP_UNCHECKED ":images/blank_128_green.png"
#define FLAGS_OTHER_NETWORK_WIDE_ICON ":images/anonymous_128_blue.png"
#define FLAGS_OTHER_BROWSABLE_ICON ":images/browsable_128_blue.png"
#define FLAGS_OTHER_UNCHECKED ":images/blank_128_blue.png"
#define INDEX_GROUP_BROWSABLE 0
#define INDEX_GROUP_NETWORK_W 1
#define INDEX_OTHER_BROWSABLE 2
#define INDEX_OTHER_NETWORK_W 3
#define INDEX_GROUP_UNCHECKED 4
#define INDEX_OTHER_UNCHECKED 5
QString GroupFlagsWidget::_tooltips_on[4] = {
QObject::tr("Directory is browsable for friends from parent groups"),
QObject::tr("Directory is accessible by anonymous tunnels from friends from parent groups"),
QObject::tr("Directory is browsable for any friend"),
QObject::tr("Directory is accessible by anonymous tunnels from any friend")
};
QString GroupFlagsWidget::_tooltips_off[4] = {
QObject::tr(""),
QObject::tr(""),
QObject::tr(""),
QObject::tr("")
};
GroupFlagsWidget::GroupFlagsWidget(QWidget *parent,FileStorageFlags flags)
: QWidget(parent)
{
_layout = new QHBoxLayout(this) ;
setMinimumSize(128,32) ;
setMaximumSize(128,32) ;
setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
_icons[INDEX_GROUP_BROWSABLE] = new QIcon(FLAGS_GROUP_BROWSABLE_ICON) ;
_icons[INDEX_GROUP_NETWORK_W] = new QIcon(FLAGS_GROUP_NETWORK_WIDE_ICON) ;
_icons[INDEX_OTHER_BROWSABLE] = new QIcon(FLAGS_OTHER_BROWSABLE_ICON) ;
_icons[INDEX_OTHER_NETWORK_W] = new QIcon(FLAGS_OTHER_NETWORK_WIDE_ICON) ;
_icons[INDEX_GROUP_UNCHECKED] = new QIcon(FLAGS_GROUP_UNCHECKED) ;
_icons[INDEX_OTHER_UNCHECKED] = new QIcon(FLAGS_OTHER_UNCHECKED) ;
setLayout(_layout) ;
_flags[0] = DIR_FLAGS_BROWSABLE_GROUPS ;
_flags[1] = DIR_FLAGS_NETWORK_WIDE_GROUPS ;
_flags[2] = DIR_FLAGS_BROWSABLE_OTHERS ;
_flags[3] = DIR_FLAGS_NETWORK_WIDE_OTHERS ;
for(int i=0;i<4;++i)
{
_buttons[i] = new QPushButton(this) ;
_buttons[i]->setCheckable(true) ;
_buttons[i]->setChecked(flags & _flags[i]) ;
_buttons[i]->setIconSize(QSize(32,32));
update_button_state(_buttons[i]->isChecked(),i) ;
_layout->addWidget(_buttons[i]) ;
}
_buttons[INDEX_GROUP_NETWORK_W]->setHidden(true);
connect(_buttons[INDEX_GROUP_NETWORK_W],SIGNAL(toggled(bool)),this,SLOT(update_GN_button(bool))) ;
connect(_buttons[INDEX_OTHER_NETWORK_W],SIGNAL(toggled(bool)),this,SLOT(update_ON_button(bool))) ;
connect(_buttons[INDEX_GROUP_BROWSABLE],SIGNAL(toggled(bool)),this,SLOT(update_GB_button(bool))) ;
connect(_buttons[INDEX_OTHER_BROWSABLE],SIGNAL(toggled(bool)),this,SLOT(update_OB_button(bool))) ;
_layout->setSpacing(0);
_layout->setContentsMargins(0, 0, 0, 0);
_layout->update() ;
}
void GroupFlagsWidget::updated()
{
emit flagsChanged(flags()) ;
}
FileStorageFlags GroupFlagsWidget::flags() const
{
FileStorageFlags flags ;
for(int i=0;i<4;++i)
if(_buttons[i]->isChecked()) flags |= _flags[i] ;
flags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ;
return flags ;
}
void GroupFlagsWidget::setFlags(FileStorageFlags flags)
{
for(int i=0;i<4;++i)
{
_buttons[i]->setChecked(flags & _flags[i]) ;
update_button_state(_buttons[i]->isChecked(),i) ;
}
}
void GroupFlagsWidget::update_button_state(bool b,int button_id)
{
if(b)
{
_buttons[button_id]->setIcon(*_icons[button_id]) ;
_buttons[button_id]->setToolTip(_tooltips_on[button_id]) ;
}
else if(button_id == INDEX_GROUP_NETWORK_W || button_id == INDEX_GROUP_BROWSABLE)
{
_buttons[button_id]->setIcon(*_icons[INDEX_GROUP_UNCHECKED]) ;
_buttons[button_id]->setToolTip(_tooltips_off[button_id]) ;
}
else
{
_buttons[button_id]->setIcon(*_icons[INDEX_OTHER_UNCHECKED]) ;
_buttons[button_id]->setToolTip(_tooltips_off[button_id]) ;
}
}
QString GroupFlagsWidget::groupInfoString(FileStorageFlags flags,const std::list<std::string>& groups)
{
// makes a string that explains how files are shared / visible.
QString res ;
QString groups_string ;
for(std::list<std::string>::const_iterator it(groups.begin());it!=groups.end();++it)
{
if(it != groups.begin())
groups_string += ", " ;
groups_string += QString::fromStdString(*it) ;
}
if(flags & DIR_FLAGS_BROWSABLE_OTHERS)
res += tr("All your friends can browse this directory\n") ;
else if(flags & DIR_FLAGS_BROWSABLE_GROUPS)
if(!groups.empty())
res += tr("Only friends in groups ") + groups_string + tr(" can browse this directory\n") ;
else
res += tr("No one can browse this directory\n") ;
else
res += tr("No one can browse this directory\n") ;
if(flags & DIR_FLAGS_NETWORK_WIDE_OTHERS)
res += tr("All your friends can relay anonymous tunnels to this directory") ;
else if(flags & DIR_FLAGS_NETWORK_WIDE_GROUPS)
res += tr("Only friends in groups ") + groups_string + tr(" can relay anonymous tunnels to this directory") ;
else
res += tr("No one can anonymously access this directory.") ;
//if(flags.toUInt32() == 0)
// res += tr("No friends can access nor see this directory.") ;
return res ;
}
void GroupFlagsWidget::update_GN_button(bool b) { update_button_state(b,INDEX_GROUP_NETWORK_W) ; updated() ; }
void GroupFlagsWidget::update_GB_button(bool b) { update_button_state(b,INDEX_GROUP_BROWSABLE) ; updated() ; }
void GroupFlagsWidget::update_ON_button(bool b) { update_button_state(b,INDEX_OTHER_NETWORK_W) ; updated() ; }
void GroupFlagsWidget::update_OB_button(bool b) { update_button_state(b,INDEX_OTHER_BROWSABLE) ; updated() ; }
GroupFlagsWidget::~GroupFlagsWidget()
{
for(int i=0;i<4;++i)
{
delete _buttons[i] ;
delete _icons[i] ;
}
delete _icons[INDEX_GROUP_UNCHECKED] ;
delete _icons[INDEX_OTHER_UNCHECKED] ;
}

View File

@ -0,0 +1,43 @@
#pragma once
#include <stdint.h>
#include <QPushButton>
#include <QFrame>
#include <retroshare/rsflags.h>
class GroupFlagsWidget: public QWidget
{
Q_OBJECT
public:
GroupFlagsWidget(QWidget *parent,FileStorageFlags flags = FileStorageFlags(0u)) ;
virtual ~GroupFlagsWidget() ;
FileStorageFlags flags() const ;
void setFlags(FileStorageFlags flags) ;
static QString groupInfoString(FileStorageFlags flags,const std::list<std::string>& groups) ;
public slots:
void updated() ;
protected slots:
void update_GN_button(bool) ;
void update_GB_button(bool) ;
void update_ON_button(bool) ;
void update_OB_button(bool) ;
signals:
void flagsChanged(FileStorageFlags) const ;
private:
void update_button_state(bool b,int id) ;
QPushButton *_buttons[4] ;
QLayout *_layout ;
QIcon *_icons[6] ;
FileStorageFlags _flags[4] ;
static QString _tooltips_on[4] ;
static QString _tooltips_off[4] ;
};

View File

@ -0,0 +1,43 @@
#include <retroshare/rspeers.h>
#include "GroupSelectionBox.h"
GroupSelectionBox::GroupSelectionBox(QWidget *parent)
: QListWidget(parent)
{
setSelectionMode(QAbstractItemView::ExtendedSelection) ;
// Fill with available groups
std::list<RsGroupInfo> lst ;
rsPeers->getGroupInfoList(lst) ;
for(std::list<RsGroupInfo>::const_iterator it(lst.begin());it!=lst.end();++it)
addItem(QString::fromStdString(it->id)) ;
for(int i=0;i<count();++i)
item(i)->setBackgroundColor(QColor(183,236,181)) ;
}
std::list<std::string> GroupSelectionBox::selectedGroups() const
{
QList<QListWidgetItem*> selected_items = selectedItems() ;
std::list<std::string> out ;
for(QList<QListWidgetItem*>::const_iterator it(selected_items.begin());it!=selected_items.end();++it)
{
out.push_back((*it)->text().toStdString()) ;
std::cerr << "Addign selected item " << out.back() << std::endl;
}
return out ;
}
void GroupSelectionBox::setSelectedGroups(const std::list<std::string>& group_ids)
{
for(std::list<std::string>::const_iterator it(group_ids.begin());it!=group_ids.end();++it)
{
QList<QListWidgetItem*> lst = findItems(QString::fromStdString(*it),Qt::MatchExactly) ;
setCurrentItem(*lst.begin(),QItemSelectionModel::Select) ;
}
}

View File

@ -0,0 +1,11 @@
#include <QListWidget>
class GroupSelectionBox: public QListWidget
{
public:
GroupSelectionBox(QWidget *parent) ;
std::list<std::string> selectedGroups() const ;
void setSelectedGroups(const std::list<std::string>& selected_group_ids) ;
};

View File

@ -217,7 +217,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_HINTS_NETWORK_WIDE, std::list<std::string>());
rsFiles->FileRequest(dlinfo.name.toUtf8().constData(), dlinfo.hash.toUtf8().constData(), dlinfo.size, cleanPath.toUtf8().constData(), RS_FILE_REQ_ANONYMOUS_ROUTING, std::list<std::string>());
}
else
std::cerr<<"Skipping file : " << dlinfo.name.toStdString() << std::endl;

View File

@ -110,7 +110,7 @@ void RsCollectionFile::recursAddElements(QDomDocument& doc,const DirDetails& det
continue;
DirDetails subDirDetails;
uint32_t flags = DIR_FLAGS_CHILDREN | DIR_FLAGS_LOCAL;
FileSearchFlags flags = RS_FILE_HINTS_LOCAL;
if (!rsFiles->RequestDirDetails(it->ref, subDirDetails, flags))
continue;

View File

@ -100,7 +100,7 @@ AttachFileItem::AttachFileItem(const QString& path)
mType = AFI_TYPE_ATTACH;
/* ask for Files to hash/prepare it for us */
if ((!rsFiles) || (!rsFiles->ExtraFileHash(path.toUtf8().constData(), AFI_DEFAULT_PERIOD, 0)))
if ((!rsFiles) || (!rsFiles->ExtraFileHash(path.toUtf8().constData(), AFI_DEFAULT_PERIOD, TransferRequestFlags(0u))))
{
mMode = AFI_STATE_ERROR;
}
@ -123,7 +123,7 @@ void AttachFileItem::Setup()
if (mMode == AFI_STATE_REMOTE)
{
FileInfo fi;
uint32_t hintflags = RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY;
FileSearchFlags hintflags = RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY;
/* look up path */
if (rsFiles->FileDetails(mFileHash, hintflags, fi))
@ -194,7 +194,7 @@ void AttachFileItem::updateItemStatic()
if (mPath == "")
{
FileInfo fi;
uint32_t hintflags = RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_LOCAL
FileSearchFlags hintflags = RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_LOCAL
| RS_FILE_HINTS_SPEC_ONLY;
/* look up path */
@ -350,7 +350,7 @@ void AttachFileItem::updateItem()
}
else
{
uint32_t hintflags = 0;
FileSearchFlags hintflags(0u);
switch(mMode)
{
case AFI_STATE_REMOTE:

View File

@ -182,7 +182,7 @@ void SubFileItem::updateItemStatic()
if (mPath == "")
{
FileInfo fi;
uint32_t hintflags = RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY | RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE;
FileSearchFlags hintflags = RS_FILE_HINTS_UPLOAD | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_SPEC_ONLY | RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE;
/* look up path */
if (!rsFiles->FileDetails(mFileHash, hintflags, fi))
@ -364,7 +364,7 @@ void SubFileItem::updateItem()
}
else
{
uint32_t hintflags = 0;
FileSearchFlags hintflags(0u) ;
switch(mMode)
{
case SFI_STATE_REMOTE:
@ -544,7 +544,7 @@ void SubFileItem::cancel()
if (((mType == SFI_TYPE_ATTACH) || (mType == SFI_TYPE_CHANNEL)) && (mFlag & SFI_FLAG_CREATE))
{
hide();
rsFiles->ExtraFileRemove(FileHash(), RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_EXTRA);
rsFiles->ExtraFileRemove(FileHash(), RS_FILE_REQ_ANONYMOUS_ROUTING | RS_FILE_REQ_EXTRA);
mPath = "";
}
else
@ -559,7 +559,7 @@ void SubFileItem::cancel()
void SubFileItem::play()
{
FileInfo info;
uint32_t flags = RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE;
FileSearchFlags flags = RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE;
if (!rsFiles->FileDetails( mFileHash, flags, info))
@ -612,7 +612,7 @@ void SubFileItem::download()
if (mSrcId != "")
sources.push_back(mSrcId);
rsFiles->FileRequest(mFileName, mFileHash, mFileSize, "", RS_FILE_HINTS_NETWORK_WIDE, sources);
rsFiles->FileRequest(mFileName, mFileHash, mFileSize, "", RS_FILE_REQ_ANONYMOUS_ROUTING, sources);
downloadButton->setEnabled(false);

View File

@ -1,5 +1,11 @@
<RCC>
<qresource prefix="/" >
<file>images/anonymous_128_green.png</file>
<file>images/anonymous_128_blue.png</file>
<file>images/browsable_128_green.png</file>
<file>images/browsable_128_blue.png</file>
<file>images/blank_128_green.png</file>
<file>images/blank_128_blue.png</file>
<file>images/splash.png</file>
<file>images/help/addafriend.png</file>
<file>images/help/addfriendkey.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -323,7 +323,7 @@ void MessageWidget::getcurrentrecommended()
const FileInfo& fi(it->second) ;
std::cout << "Requesting file " << fi.fname << ", size=" << fi.size << ", hash=" << fi.hash << std::endl ;
if (rsFiles->FileRequest(fi.fname, fi.hash, fi.size, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds) == false) {
if (rsFiles->FileRequest(fi.fname, fi.hash, fi.size, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds) == false) {
QMessageBox mb(QObject::tr("File Request canceled"), QObject::tr("The following has not been added to your download list, because you already have it:\n ") + QString::fromUtf8(fi.fname.c_str()), QMessageBox::Critical, QMessageBox::Ok, 0, 0);
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
mb.exec();
@ -347,7 +347,7 @@ void MessageWidget::getallrecommended()
std::cerr << "MessageWidget::getallrecommended() Calling File Request" << std::endl;
std::list<std::string> srcIds;
srcIds.push_back(msgInfo.srcId);
rsFiles->FileRequest(it->fname, it->hash, it->size, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds);
rsFiles->FileRequest(it->fname, it->hash, it->size, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
}
}

View File

@ -357,6 +357,8 @@ HEADERS += rshare.h \
gui/common/rwindow.h \
gui/common/html.h \
gui/common/AvatarDefs.h \
gui/common/GroupFlagsWidget.h \
gui/common/GroupSelectionBox.h \
gui/common/StatusDefs.h \
gui/common/TagDefs.h \
gui/common/GroupDefs.h \
@ -619,6 +621,8 @@ SOURCES += main.cpp \
gui/common/rwindow.cpp \
gui/common/html.cpp \
gui/common/AvatarDefs.cpp \
gui/common/GroupFlagsWidget.cpp \
gui/common/GroupSelectionBox.cpp \
gui/common/StatusDefs.cpp \
gui/common/TagDefs.cpp \
gui/common/GroupDefs.cpp \