mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 17:36:19 -05:00
Started implementing flags to handle the sharing mode.
What works: - the gui shows the flags in ShareManager - the flags are loaded/saved to ft_shared.cfg and passed on to FileIndexMonitor What does not work yet: - the flags are not accounted for yet by FileIndexMonitor In addition: - simplified the directories dialog in Preferences, so that it calls the ShareManager instead of dupplicating the directories management code that becomes larger. - setup the ShareManager to be a singleton, so as to coherently call it from different places. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1486 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
aa1658245c
commit
f9dc3b223b
@ -39,9 +39,9 @@
|
||||
#include <openssl/sha.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/***********
|
||||
* #define FIM_DEBUG 1
|
||||
***********/
|
||||
//***********
|
||||
#define FIM_DEBUG 1
|
||||
// ***********/
|
||||
|
||||
FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, NotifyBase *cb_in,std::string cachedir, std::string pid)
|
||||
:CacheSource(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cachedir), fi(pid),
|
||||
@ -59,7 +59,7 @@ FileIndexMonitor::~FileIndexMonitor()
|
||||
return;
|
||||
}
|
||||
|
||||
bool FileIndexMonitor::findLocalFile(std::string hash,
|
||||
bool FileIndexMonitor::findLocalFile(std::string hash,uint32_t flags,
|
||||
std::string &fullpath, uint64_t &size) const
|
||||
{
|
||||
std::list<FileEntry *> results;
|
||||
@ -602,13 +602,45 @@ void FileIndexMonitor::updateCycle()
|
||||
cb->notifyHashingInfo("") ;
|
||||
}
|
||||
|
||||
void FileIndexMonitor::updateShareFlags(const SharedDirInfo& dir)
|
||||
{
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "*** FileIndexMonitor: Updating flags for " << dir.filename << " to " << dir.shareflags << std::endl ;
|
||||
#endif
|
||||
{
|
||||
RsStackMutex stack(fiMutex) ; /* LOCKED DIRS */
|
||||
|
||||
if(pendingDirs)
|
||||
for(std::list<SharedDirInfo>::iterator it(pendingDirList.begin());it!=pendingDirList.end();++it)
|
||||
{
|
||||
std::cerr << "** testing pending dir " << (*it).filename << std::endl ;
|
||||
if((*it).filename == dir.filename)
|
||||
{
|
||||
std::cerr << "** Updating to " << (*it).shareflags << "!!" << std::endl ;
|
||||
(*it).shareflags = dir.shareflags ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else
|
||||
for(std::map<std::string,SharedDirInfo>::iterator it(directoryMap.begin());it!=directoryMap.end();++it)
|
||||
{
|
||||
std::cerr << "** testing " << (*it).second.filename << std::endl ;
|
||||
if((*it).second.filename == dir.filename)
|
||||
{
|
||||
std::cerr << "** Updating from " << it->second.shareflags << "!!" << std::endl ;
|
||||
(*it).second.shareflags = dir.shareflags ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* interface */
|
||||
void FileIndexMonitor::setSharedDirectories(std::list<std::string> dirs)
|
||||
void FileIndexMonitor::setSharedDirectories(std::list<SharedDirInfo> dirs)
|
||||
{
|
||||
|
||||
std::list<std::string> checkeddirs;
|
||||
std::list<SharedDirInfo> checkeddirs;
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::setSharedDirectories() :\n";
|
||||
#endif
|
||||
@ -617,12 +649,12 @@ void FileIndexMonitor::setSharedDirectories(std::list<std::string> dirs)
|
||||
{
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "\t" << *it;
|
||||
std::cerr << "\t" << (*it).filename;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* check if dir exists before adding in */
|
||||
std::string path = (*it);
|
||||
std::string path = (*it).filename;
|
||||
DIR *dir = opendir(path.c_str());
|
||||
if (!dir)
|
||||
{
|
||||
@ -633,41 +665,37 @@ void FileIndexMonitor::setSharedDirectories(std::list<std::string> dirs)
|
||||
}
|
||||
else
|
||||
{
|
||||
checkeddirs.push_back(path);
|
||||
checkeddirs.push_back(*it);
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
fiMutex.lock(); { /* LOCKED DIRS */
|
||||
{
|
||||
RsStackMutex stack(fiMutex) ;/* LOCKED DIRS */
|
||||
|
||||
pendingDirs = true;
|
||||
pendingDirList = checkeddirs;
|
||||
|
||||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
pendingDirs = true;
|
||||
pendingDirList = checkeddirs;
|
||||
}
|
||||
}
|
||||
|
||||
/* interface */
|
||||
void FileIndexMonitor::getSharedDirectories(std::list<std::string> &dirs)
|
||||
void FileIndexMonitor::getSharedDirectories(std::list<SharedDirInfo> &dirs)
|
||||
{
|
||||
fiMutex.lock(); { /* LOCKED DIRS */
|
||||
{
|
||||
RsStackMutex stack(fiMutex) ; /* LOCKED DIRS */
|
||||
|
||||
/* must provide pendingDirs, as other parts depend on instanteous response */
|
||||
if (pendingDirs)
|
||||
{
|
||||
dirs = pendingDirList;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* get actual list (not pending stuff) */
|
||||
std::map<std::string, std::string>::const_iterator it;
|
||||
for(it = directoryMap.begin(); it != directoryMap.end(); it++)
|
||||
/* must provide pendingDirs, as other parts depend on instanteous response */
|
||||
if (pendingDirs)
|
||||
dirs = pendingDirList;
|
||||
else
|
||||
{
|
||||
dirs.push_back(it->second);
|
||||
/* get actual list (not pending stuff) */
|
||||
std::map<std::string, SharedDirInfo>::const_iterator it;
|
||||
|
||||
for(it = directoryMap.begin(); it != directoryMap.end(); it++)
|
||||
dirs.push_back(it->second) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} fiMutex.unlock(); /* UNLOCKED DIRS */
|
||||
}
|
||||
|
||||
|
||||
@ -718,12 +746,12 @@ bool FileIndexMonitor::internal_setSharedDirectories()
|
||||
directoryMap.clear();
|
||||
|
||||
/* iterate through the directories */
|
||||
std::list<std::string>::iterator it;
|
||||
std::map<std::string, std::string>::const_iterator cit;
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
std::map<std::string, SharedDirInfo>::const_iterator cit;
|
||||
for(it = pendingDirList.begin(); it != pendingDirList.end(); it++)
|
||||
{
|
||||
/* get the head directory */
|
||||
std::string root_dir = *it;
|
||||
std::string root_dir = (*it).filename;
|
||||
std::string top_dir = RsDirUtil::getTopDir(root_dir);
|
||||
|
||||
/* if unique -> add, else add modifier */
|
||||
@ -741,7 +769,7 @@ bool FileIndexMonitor::internal_setSharedDirectories()
|
||||
{
|
||||
unique = true;
|
||||
/* add it! */
|
||||
directoryMap[tst_dir.c_str()] = root_dir;
|
||||
directoryMap[tst_dir.c_str()] = *it;
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "Added [" << tst_dir << "] => " << root_dir << std::endl;
|
||||
#endif
|
||||
@ -774,7 +802,7 @@ std::string FileIndexMonitor::locked_findRealRoot(std::string rootdir) const
|
||||
/**** MUST ALREADY BE LOCKED ****/
|
||||
std::string realroot = "";
|
||||
|
||||
std::map<std::string, std::string>::const_iterator cit;
|
||||
std::map<std::string, SharedDirInfo>::const_iterator cit;
|
||||
if (directoryMap.end()== (cit=directoryMap.find(rootdir)))
|
||||
{
|
||||
std::cerr << "FileIndexMonitor::locked_findRealRoot() Invalid RootDir: ";
|
||||
@ -782,7 +810,7 @@ std::string FileIndexMonitor::locked_findRealRoot(std::string rootdir) const
|
||||
}
|
||||
else
|
||||
{
|
||||
realroot = cit->second;
|
||||
realroot = cit->second.filename;
|
||||
}
|
||||
|
||||
return realroot;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "dbase/cachestrapper.h"
|
||||
#include "dbase/findex.h"
|
||||
#include "util/rsthreads.h"
|
||||
#include "rsiface/rsfiles.h"
|
||||
|
||||
/******************************************************************************************
|
||||
* The Local Monitoring Class: FileIndexMonitor.
|
||||
@ -66,67 +67,71 @@ class NotifyBase ;
|
||||
* FileIndexMonitor
|
||||
*****************************************************************************************/
|
||||
|
||||
static const uint32_t RS_SHARED_FLAGS_PUBLIC = 0x0001 ;
|
||||
static const uint32_t RS_SHARED_FLAGS_ANONYM = 0x0002 ;
|
||||
|
||||
class FileIndexMonitor: public CacheSource, public RsThread
|
||||
{
|
||||
public:
|
||||
FileIndexMonitor(CacheStrapper *cs, NotifyBase *cb_in, std::string cachedir, std::string pid);
|
||||
virtual ~FileIndexMonitor();
|
||||
FileIndexMonitor(CacheStrapper *cs, NotifyBase *cb_in, std::string cachedir, std::string pid);
|
||||
virtual ~FileIndexMonitor();
|
||||
|
||||
/* external interface for filetransfer */
|
||||
bool findLocalFile(std::string hash, std::string &fullpath, uint64_t &size) const;
|
||||
/* external interface for filetransfer */
|
||||
bool findLocalFile(std::string hash,uint32_t f, std::string &fullpath, uint64_t &size) const;
|
||||
|
||||
/* external interface for local access to files */
|
||||
bool convertSharedFilePath(std::string path, std::string &fullpath);
|
||||
/* external interface for local access to files */
|
||||
bool convertSharedFilePath(std::string path, std::string &fullpath);
|
||||
|
||||
|
||||
/* 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 */
|
||||
/* 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 */
|
||||
|
||||
|
||||
/* the FileIndexMonitor inner workings */
|
||||
//virtual void run(std::string& currentJob); /* overloaded from RsThread */
|
||||
//void updateCycle(std::string& currentJob);
|
||||
virtual void run(); /* overloaded from RsThread */
|
||||
void updateCycle();
|
||||
/* the FileIndexMonitor inner workings */
|
||||
//virtual void run(std::string& currentJob); /* overloaded from RsThread */
|
||||
//void updateCycle(std::string& currentJob);
|
||||
virtual void run(); /* overloaded from RsThread */
|
||||
void updateCycle();
|
||||
|
||||
virtual void setSharedDirectories(std::list<std::string> dirs);
|
||||
void getSharedDirectories(std::list<std::string> &dirs);
|
||||
virtual void setSharedDirectories(std::list<SharedDirInfo> dirs);
|
||||
void getSharedDirectories(std::list<SharedDirInfo>& dirs);
|
||||
void updateShareFlags(const SharedDirInfo& info) ;
|
||||
|
||||
void setPeriod(int insecs);
|
||||
void forceDirectoryCheck();
|
||||
bool inDirectoryCheck();
|
||||
void setPeriod(int insecs);
|
||||
void forceDirectoryCheck();
|
||||
bool inDirectoryCheck();
|
||||
|
||||
/* util fns */
|
||||
/* util fns */
|
||||
|
||||
private:
|
||||
|
||||
/* the mutex should be locked before calling... these. */
|
||||
std::string locked_findRealRoot(std::string base) const;
|
||||
bool hashFile(std::string path, FileEntry &fi); /* To Implement */
|
||||
/* the mutex should be locked before calling... these. */
|
||||
std::string locked_findRealRoot(std::string base) const;
|
||||
bool hashFile(std::string path, FileEntry &fi); /* To Implement */
|
||||
|
||||
/* data */
|
||||
/* data */
|
||||
|
||||
mutable RsMutex fiMutex;
|
||||
mutable RsMutex fiMutex;
|
||||
|
||||
FileIndex fi;
|
||||
FileIndex fi;
|
||||
|
||||
int updatePeriod;
|
||||
std::map<std::string, std::string> directoryMap; /* used by findRealRoot */
|
||||
int updatePeriod;
|
||||
std::map<std::string, SharedDirInfo> directoryMap; /* used by findRealRoot */
|
||||
|
||||
/* flags to kick - if we were busy or sleeping */
|
||||
bool pendingDirs;
|
||||
bool pendingForceCacheWrite;
|
||||
/* flags to kick - if we were busy or sleeping */
|
||||
bool pendingDirs;
|
||||
bool pendingForceCacheWrite;
|
||||
|
||||
/* flags to force Check, to tell if we're in check */
|
||||
bool mForceCheck;
|
||||
bool mInCheck;
|
||||
/* flags to force Check, to tell if we're in check */
|
||||
bool mForceCheck;
|
||||
bool mInCheck;
|
||||
|
||||
std::list<std::string> pendingDirList;
|
||||
bool internal_setSharedDirectories();
|
||||
std::list<SharedDirInfo> pendingDirList;
|
||||
bool internal_setSharedDirectories();
|
||||
|
||||
NotifyBase *cb ;
|
||||
NotifyBase *cb ;
|
||||
};
|
||||
|
||||
|
||||
|
@ -136,7 +136,10 @@ bool ftFiMonitor::search(std::string hash, uint64_t size, uint32_t hintflags, Fi
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (findLocalFile(hash, path, fsize))
|
||||
// setup search flags according to hintflags
|
||||
uint32_t flags = 0;
|
||||
|
||||
if(findLocalFile(hash, flags, path, fsize))
|
||||
{
|
||||
/* fill in details */
|
||||
#ifdef DB_DEBUG
|
||||
@ -184,15 +187,16 @@ std::list<RsItem *> ftFiMonitor::saveList(bool &cleanup)
|
||||
#endif
|
||||
|
||||
/* get list of directories */
|
||||
std::list<std::string> dirList;
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<SharedDirInfo> dirList;
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
|
||||
getSharedDirectories(dirList);
|
||||
|
||||
for(it = dirList.begin(); it != dirList.end(); it++)
|
||||
{
|
||||
RsFileConfigItem *fi = new RsFileConfigItem();
|
||||
fi->file.path = *it;
|
||||
fi->file.path = (*it).filename ;
|
||||
fi->flags = (*it).shareflags ;
|
||||
|
||||
sList.push_back(fi);
|
||||
}
|
||||
@ -214,7 +218,7 @@ bool ftFiMonitor::loadList(std::list<RsItem *> load)
|
||||
|
||||
time_t ts = time(NULL);
|
||||
|
||||
std::list<std::string> dirList;
|
||||
std::list<SharedDirInfo> dirList;
|
||||
|
||||
std::list<RsItem *>::iterator it;
|
||||
for(it = load.begin(); it != load.end(); it++)
|
||||
@ -228,7 +232,11 @@ bool ftFiMonitor::loadList(std::list<RsItem *> load)
|
||||
|
||||
/* ensure that it exists? */
|
||||
|
||||
dirList.push_back(fi->file.path);
|
||||
SharedDirInfo info ;
|
||||
info.filename = fi->file.path;
|
||||
info.shareflags = fi->flags & (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE) ;
|
||||
|
||||
dirList.push_back(info) ;
|
||||
}
|
||||
|
||||
/* set directories */
|
||||
@ -236,7 +244,15 @@ bool ftFiMonitor::loadList(std::list<RsItem *> load)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ftFiMonitor::setSharedDirectories(std::list<std::string> dirList)
|
||||
void ftFiMonitor::updateShareFlags(const SharedDirInfo& info)
|
||||
{
|
||||
FileIndexMonitor::updateShareFlags(info);
|
||||
|
||||
/* flag for config */
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
|
||||
void ftFiMonitor::setSharedDirectories(std::list<SharedDirInfo> dirList)
|
||||
{
|
||||
FileIndexMonitor::setSharedDirectories(dirList);
|
||||
|
||||
|
@ -60,7 +60,8 @@ class ftFiMonitor: public FileIndexMonitor, public ftSearch, public p3Config
|
||||
virtual bool search(std::string hash, uint64_t size, uint32_t hintflags, FileInfo &info) const;
|
||||
|
||||
/* overloaded set dirs enables config indication */
|
||||
virtual void setSharedDirectories(std::list<std::string> dirList);
|
||||
virtual void setSharedDirectories(std::list<SharedDirInfo> dirList);
|
||||
virtual void updateShareFlags(const SharedDirInfo& info) ;
|
||||
|
||||
/***
|
||||
* Configuration - store shared directories
|
||||
|
@ -246,6 +246,8 @@ bool ftServer::FileRequest(std::string fname, std::string hash, uint64_t size,
|
||||
// dest, flags, srcIds);
|
||||
const DwlDetails details(fname, hash, size, dest, flags, srcIds, Normal);
|
||||
mFtDwlQueue->insertDownload(details);
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool ftServer::FileCancel(std::string hash)
|
||||
@ -471,32 +473,46 @@ bool ftServer::InDirectoryCheck()
|
||||
return mFiMon->inDirectoryCheck();
|
||||
}
|
||||
|
||||
bool ftServer::getSharedDirectories(std::list<std::string> &dirs)
|
||||
bool ftServer::getSharedDirectories(std::list<SharedDirInfo> &dirs)
|
||||
{
|
||||
mFiMon->getSharedDirectories(dirs);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ftServer::setSharedDirectories(std::list<std::string> &dirs)
|
||||
bool ftServer::setSharedDirectories(std::list<SharedDirInfo> &dirs)
|
||||
{
|
||||
mFiMon->setSharedDirectories(dirs);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ftServer::addSharedDirectory(std::string dir)
|
||||
bool ftServer::addSharedDirectory(SharedDirInfo dir)
|
||||
{
|
||||
std::list<std::string> dirList;
|
||||
std::list<SharedDirInfo> dirList;
|
||||
mFiMon->getSharedDirectories(dirList);
|
||||
|
||||
// check that the directory is not already in the list.
|
||||
for(std::list<SharedDirInfo>::const_iterator it(dirList.begin());it!=dirList.end();++it)
|
||||
if((*it).filename == dir.filename)
|
||||
return false ;
|
||||
|
||||
// ok then, add the shared directory.
|
||||
dirList.push_back(dir);
|
||||
|
||||
mFiMon->setSharedDirectories(dirList);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ftServer::updateShareFlags(const SharedDirInfo& info)
|
||||
{
|
||||
mFiMon->updateShareFlags(info);
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool ftServer::removeSharedDirectory(std::string dir)
|
||||
{
|
||||
std::list<std::string> dirList;
|
||||
std::list<std::string>::iterator it;
|
||||
std::list<SharedDirInfo> dirList;
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
|
||||
#ifdef SERVER_DEBUG
|
||||
std::cerr << "ftServer::removeSharedDirectory(" << dir << ")";
|
||||
@ -509,13 +525,14 @@ bool ftServer::removeSharedDirectory(std::string dir)
|
||||
for(it = dirList.begin(); it != dirList.end(); it++)
|
||||
{
|
||||
std::cerr << "ftServer::removeSharedDirectory()";
|
||||
std::cerr << " existing: " << *it;
|
||||
std::cerr << " existing: " << (*it).filename;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dirList.end() == (it =
|
||||
std::find(dirList.begin(), dirList.end(), dir)))
|
||||
for(it = dirList.begin();it!=dirList.end() && (*it).filename != dir;++it) ;
|
||||
|
||||
if(it == dirList.end())
|
||||
{
|
||||
#ifdef SERVER_DEBUG
|
||||
std::cerr << "ftServer::removeSharedDirectory()";
|
||||
@ -551,8 +568,11 @@ bool ftServer::getShareDownloadDirectory()
|
||||
|
||||
bool ftServer::shareDownloadDirectory()
|
||||
{
|
||||
std::string dir = mFtController->getDownloadDirectory();
|
||||
return addSharedDirectory(dir);
|
||||
SharedDirInfo inf ;
|
||||
inf.filename = mFtController->getDownloadDirectory();
|
||||
inf.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
|
||||
|
||||
return addSharedDirectory(inf);
|
||||
}
|
||||
|
||||
bool ftServer::unshareDownloadDirectory()
|
||||
|
@ -175,9 +175,10 @@ virtual void setPartialsDirectory(std::string path);
|
||||
virtual std::string getDownloadDirectory();
|
||||
virtual std::string getPartialsDirectory();
|
||||
|
||||
virtual bool getSharedDirectories(std::list<std::string> &dirs);
|
||||
virtual bool setSharedDirectories(std::list<std::string> &dirs);
|
||||
virtual bool addSharedDirectory(std::string dir);
|
||||
virtual bool getSharedDirectories(std::list<SharedDirInfo> &dirs);
|
||||
virtual bool setSharedDirectories(std::list<SharedDirInfo> &dirs);
|
||||
virtual bool addSharedDirectory(SharedDirInfo dir);
|
||||
virtual bool updateShareFlags(const SharedDirInfo& dir); // updates the flags. The directory should already exist !
|
||||
virtual bool removeSharedDirectory(std::string dir);
|
||||
|
||||
virtual void setShareDownloadDirectory(bool value);
|
||||
|
@ -62,14 +62,19 @@ const uint32_t RS_FILE_PEER_OFFLINE = 0x00002000;
|
||||
|
||||
const uint32_t RS_FILE_HINTS_MASK = 0x00ffffff;
|
||||
|
||||
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 uint32_t RS_FILE_HINTS_TURTLE = 0x00000040;
|
||||
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 uint32_t RS_FILE_HINTS_TURTLE = 0x00000040;
|
||||
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_SHARED_DIR_ANONYMOUS = 0x01 ;
|
||||
//const uint32_t RS_SHARED_DIR_BROWSABLE = 0x02 ;
|
||||
//const uint32_t RS_SHARED_DIR_UNIVERSAL = 0x03 ;
|
||||
|
||||
const uint32_t RS_FILE_HINTS_SPEC_ONLY = 0x01000000;
|
||||
const uint32_t RS_FILE_HINTS_NO_SEARCH = 0x02000000;
|
||||
@ -86,6 +91,11 @@ const uint32_t CB_CODE_CACHE = 0x0001;
|
||||
const uint32_t CB_CODE_EXTRA = 0x0002;
|
||||
const uint32_t CB_CODE_MEDIA = 0x0004;
|
||||
|
||||
struct SharedDirInfo
|
||||
{
|
||||
std::string filename ;
|
||||
uint32_t shareflags ; // RS_FILE_HINTS_ANONYMOUS | RS_FILE_HINTS_BROWSABLE
|
||||
};
|
||||
|
||||
class RsFiles
|
||||
{
|
||||
@ -161,8 +171,9 @@ virtual void setPartialsDirectory(std::string path) = 0;
|
||||
virtual std::string getDownloadDirectory() = 0;
|
||||
virtual std::string getPartialsDirectory() = 0;
|
||||
|
||||
virtual bool getSharedDirectories(std::list<std::string> &dirs) = 0;
|
||||
virtual bool addSharedDirectory(std::string dir) = 0;
|
||||
virtual bool getSharedDirectories(std::list<SharedDirInfo> &dirs) = 0;
|
||||
virtual bool addSharedDirectory(SharedDirInfo dir) = 0;
|
||||
virtual bool updateShareFlags(const SharedDirInfo& dir) = 0; // updates the flags. The directory should already exist !
|
||||
virtual bool removeSharedDirectory(std::string dir) = 0;
|
||||
|
||||
virtual void setShareDownloadDirectory(bool value) = 0;
|
||||
|
@ -153,7 +153,7 @@ bool SetRedirectAndTest(struct UPNPUrls * urls,
|
||||
#else
|
||||
/* The lease parameter is also gone in minupnpc 1.0 */
|
||||
r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
|
||||
eport, iport, iaddr, 0, proto);
|
||||
eport, iport, iaddr,0, 0, proto);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -192,9 +192,7 @@ void LibraryDialog::StopRename()
|
||||
|
||||
void LibraryDialog::CallShareFilesBtn_library()
|
||||
{
|
||||
static ShareManager* sharemanager = new ShareManager(this);
|
||||
sharemanager->show();
|
||||
|
||||
ShareManager::showYourself();
|
||||
}
|
||||
|
||||
void LibraryDialog::CallTileViewBtn_library()
|
||||
|
@ -450,9 +450,7 @@ void MainWindow::addFriend()
|
||||
/** Shows Share Manager */
|
||||
void MainWindow::openShareManager()
|
||||
{
|
||||
static ShareManager* sharemanager = new ShareManager(this);
|
||||
sharemanager->show();
|
||||
|
||||
ShareManager::showYourself();
|
||||
}
|
||||
|
||||
/** Creates and displays the Configuration dialog with the current page set to
|
||||
|
@ -370,8 +370,7 @@ void MessengerWindow::showMessagesPopup()
|
||||
/** Shows Share Manager */
|
||||
void MessengerWindow::openShareManager()
|
||||
{
|
||||
static ShareManager* sharemanager = new ShareManager(this);
|
||||
sharemanager->show();
|
||||
ShareManager::showYourself();
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <rshare.h>
|
||||
#include "rsiface/rsfiles.h"
|
||||
#include "DirectoriesDialog.h"
|
||||
#include "gui/ShareManager.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -36,14 +37,16 @@ DirectoriesDialog::DirectoriesDialog(QWidget *parent)
|
||||
/* Create RshareSettings object */
|
||||
_settings = new RshareSettings();
|
||||
|
||||
connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( addShareDirectory() ) );
|
||||
connect(ui.removeButton, SIGNAL(clicked( bool ) ), this , SLOT( removeShareDirectory() ) );
|
||||
// connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( addShareDirectory() ) );
|
||||
// connect(ui.removeButton, SIGNAL(clicked( bool ) ), this , SLOT( removeShareDirectory() ) );
|
||||
connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
|
||||
connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
|
||||
connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(shareDownloadDirectory(int)));
|
||||
|
||||
connect(ui.editButton, SIGNAL(clicked()), this, SLOT(editDirectories()));
|
||||
#ifdef TO_REMOVE
|
||||
ui.addButton->setToolTip(tr("Add a Share Directory"));
|
||||
ui.removeButton->setToolTip(tr("Remove Shared Directory"));
|
||||
#endif
|
||||
ui.incomingButton->setToolTip(tr("Browse"));
|
||||
ui.partialButton->setToolTip(tr("Browse"));
|
||||
|
||||
@ -62,23 +65,33 @@ DirectoriesDialog::DirectoriesDialog(QWidget *parent)
|
||||
#endif
|
||||
}
|
||||
|
||||
void DirectoriesDialog::editDirectories()
|
||||
{
|
||||
ShareManager::showYourself() ;
|
||||
}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
bool
|
||||
DirectoriesDialog::save(QString &errmsg)
|
||||
bool DirectoriesDialog::save(QString &errmsg)
|
||||
{
|
||||
/* this is usefull especially when shared incoming files is
|
||||
* default option and when the user don't check/uncheck the
|
||||
* checkBox, so no signal is emitted to update the shared list */
|
||||
if (ui.checkBox->isChecked())
|
||||
{
|
||||
std::list<std::string>::const_iterator it;
|
||||
std::list<std::string> dirs;
|
||||
std::list<SharedDirInfo>::const_iterator it;
|
||||
std::list<SharedDirInfo> dirs;
|
||||
rsFiles->getSharedDirectories(dirs);
|
||||
|
||||
if (dirs.end() == std::find(dirs.begin(), dirs.end(), rsFiles->getDownloadDirectory()))
|
||||
{
|
||||
bool found = false ;
|
||||
for(std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it)
|
||||
if((*it).filename == rsFiles->getDownloadDirectory())
|
||||
{
|
||||
found=true ;
|
||||
break ;
|
||||
}
|
||||
if(!found)
|
||||
rsFiles->shareDownloadDirectory();
|
||||
}
|
||||
|
||||
rsFiles->setShareDownloadDirectory(true);
|
||||
}
|
||||
else
|
||||
@ -93,8 +106,8 @@ DirectoriesDialog::save(QString &errmsg)
|
||||
/** Loads the settings for this page */
|
||||
void DirectoriesDialog::load()
|
||||
{
|
||||
std::list<std::string>::const_iterator it;
|
||||
std::list<std::string> dirs;
|
||||
std::list<SharedDirInfo>::const_iterator it;
|
||||
std::list<SharedDirInfo> dirs;
|
||||
rsFiles->getSharedDirectories(dirs);
|
||||
|
||||
/* get a link to the table */
|
||||
@ -106,7 +119,7 @@ void DirectoriesDialog::load()
|
||||
for(it = dirs.begin(); it != dirs.end(); it++)
|
||||
{
|
||||
/* (0) Dir Name */
|
||||
listWidget->addItem(QString::fromStdString(*it));
|
||||
listWidget->addItem(QString::fromStdString((*it).filename));
|
||||
}
|
||||
|
||||
ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));
|
||||
@ -115,6 +128,7 @@ void DirectoriesDialog::load()
|
||||
listWidget->update(); /* update display */
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void DirectoriesDialog::addShareDirectory()
|
||||
{
|
||||
|
||||
@ -147,6 +161,7 @@ void DirectoriesDialog::removeShareDirectory()
|
||||
load();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void DirectoriesDialog::setIncomingDirectory()
|
||||
{
|
||||
@ -159,14 +174,19 @@ void DirectoriesDialog::setIncomingDirectory()
|
||||
rsFiles->setDownloadDirectory(dir);
|
||||
if (ui.checkBox->isChecked())
|
||||
{
|
||||
std::list<std::string>::const_iterator it;
|
||||
std::list<std::string> dirs;
|
||||
std::list<SharedDirInfo>::const_iterator it;
|
||||
std::list<SharedDirInfo> dirs;
|
||||
rsFiles->getSharedDirectories(dirs);
|
||||
|
||||
if (dirs.end() == std::find(dirs.begin(), dirs.end(), rsFiles->getDownloadDirectory()))
|
||||
{
|
||||
bool found = false ;
|
||||
for(std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it)
|
||||
if((*it).filename == rsFiles->getDownloadDirectory())
|
||||
{
|
||||
found=true ;
|
||||
break ;
|
||||
}
|
||||
if(!found)
|
||||
rsFiles->shareDownloadDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
load();
|
||||
@ -189,14 +209,20 @@ void DirectoriesDialog::shareDownloadDirectory(int state)
|
||||
{
|
||||
if (state == Qt::Checked)
|
||||
{
|
||||
std::list<std::string>::const_iterator it;
|
||||
std::list<std::string> dirs;
|
||||
std::list<SharedDirInfo>::const_iterator it;
|
||||
std::list<SharedDirInfo> dirs;
|
||||
rsFiles->getSharedDirectories(dirs);
|
||||
|
||||
if (dirs.end() == std::find(dirs.begin(), dirs.end(), rsFiles->getDownloadDirectory()))
|
||||
{
|
||||
bool found = false ;
|
||||
for(std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it)
|
||||
if((*it).filename == rsFiles->getDownloadDirectory())
|
||||
{
|
||||
found=true ;
|
||||
break ;
|
||||
}
|
||||
if(!found)
|
||||
rsFiles->shareDownloadDirectory();
|
||||
}
|
||||
|
||||
rsFiles->setShareDownloadDirectory(true);
|
||||
}
|
||||
else
|
||||
|
@ -44,9 +44,11 @@ public:
|
||||
void load();
|
||||
|
||||
private slots:
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void addShareDirectory();
|
||||
void removeShareDirectory();
|
||||
#endif
|
||||
void editDirectories() ;
|
||||
void setIncomingDirectory();
|
||||
void setPartialsDirectory();
|
||||
void shareDownloadDirectory(int state);
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>452</width>
|
||||
<height>349</height>
|
||||
<width>483</width>
|
||||
<height>337</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -509,102 +509,6 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Shared Directories</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0" rowspan="3">
|
||||
<widget class="QListWidget" name="dirList"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>34</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>34</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/directoryadd_24x24_shadow.png</normaloff>:/images/directoryadd_24x24_shadow.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="removeButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>34</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>34</width>
|
||||
<height>34</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/directoryremove_24x24_shadow.png</normaloff>:/images/directoryremove_24x24_shadow.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>71</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatically share incoming directory (Recommanded)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
@ -695,14 +599,48 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Shared Directories</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="dirList"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="editButton">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatically share incoming directory (Recommanded)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>incomingDir</tabstop>
|
||||
<tabstop>incomingButton</tabstop>
|
||||
<tabstop>dirList</tabstop>
|
||||
<tabstop>addButton</tabstop>
|
||||
<tabstop>removeButton</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
|
@ -24,16 +24,20 @@
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QCheckBox>
|
||||
#include <QCursor>
|
||||
#include <QPoint>
|
||||
#include <QMouseEvent>
|
||||
#include <QPixmap>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QComboBox>
|
||||
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_CANCEL ":/images/delete.png"
|
||||
|
||||
ShareManager *ShareManager::_instance = NULL ;
|
||||
|
||||
/** Default constructor */
|
||||
ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags)
|
||||
: QDialog(parent, flags)
|
||||
@ -75,27 +79,82 @@ void ShareManager::shareddirListCostumPopupMenu( QPoint point )
|
||||
/** Loads the settings for this page */
|
||||
void ShareManager::load()
|
||||
{
|
||||
std::list<std::string>::const_iterator it;
|
||||
std::list<std::string> dirs;
|
||||
std::list<SharedDirInfo>::const_iterator it;
|
||||
std::list<SharedDirInfo> dirs;
|
||||
rsFiles->getSharedDirectories(dirs);
|
||||
|
||||
/* get a link to the table */
|
||||
QListWidget *listWidget = ui.shareddirList;
|
||||
QTableWidget *listWidget = ui.shareddirList;
|
||||
|
||||
/* remove old items ??? */
|
||||
listWidget->clear();
|
||||
listWidget->clearContents() ;
|
||||
listWidget->setRowCount(0) ;
|
||||
|
||||
for(it = dirs.begin(); it != dirs.end(); it++)
|
||||
connect(this,SIGNAL(itemClicked(QTableWidgetItem*)),this,SLOT(updateFlags(QTableWidgetItem*))) ;
|
||||
|
||||
int row=0 ;
|
||||
for(it = dirs.begin(); it != dirs.end(); it++,++row)
|
||||
{
|
||||
/* (0) Dir Name */
|
||||
listWidget->addItem(QString::fromStdString(*it));
|
||||
listWidget->insertRow(row) ;
|
||||
listWidget->setItem(row,0,new QTableWidgetItem(QString::fromStdString((*it).filename)));
|
||||
#ifdef USE_COMBOBOX
|
||||
QComboBox *cb = new QComboBox ;
|
||||
cb->addItem(QString("Network Wide")) ;
|
||||
cb->addItem(QString("Browsable")) ;
|
||||
cb->addItem(QString("Universal")) ;
|
||||
|
||||
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")) ;
|
||||
|
||||
// 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);
|
||||
|
||||
if(index < 1 || index > 3)
|
||||
std::cerr << "******* ERROR IN FILE SHARING FLAGS. Flags = " << (*it).shareflags << " ***********" << std::endl ;
|
||||
else
|
||||
index-- ;
|
||||
|
||||
cb->setCurrentIndex(index) ;
|
||||
#else
|
||||
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->setToolTip(QString("If checked, the share is anonymously shared to anybody.")) ;
|
||||
cb2->setToolTip(QString("If checked, the share is browsable by your friends.")) ;
|
||||
|
||||
listWidget->setCellWidget(row,1,cb1);
|
||||
listWidget->setCellWidget(row,2,cb2);
|
||||
|
||||
QObject::connect(cb1,SIGNAL(toggled(bool)),this,SLOT(updateFlags(bool))) ;
|
||||
QObject::connect(cb2,SIGNAL(toggled(bool)),this,SLOT(updateFlags(bool))) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
//ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));
|
||||
|
||||
listWidget->update(); /* update display */
|
||||
}
|
||||
|
||||
void ShareManager::showYourself()
|
||||
{
|
||||
if(_instance == NULL)
|
||||
_instance = new ShareManager(NULL,0) ;
|
||||
|
||||
_instance->show() ;
|
||||
}
|
||||
|
||||
void ShareManager::addShareDirectory()
|
||||
@ -112,22 +171,55 @@ void ShareManager::addShareDirectory()
|
||||
std::string dir = qdir.toStdString();
|
||||
if (dir != "")
|
||||
{
|
||||
rsFiles->addSharedDirectory(dir);
|
||||
SharedDirInfo sdi ;
|
||||
sdi.filename = dir ;
|
||||
sdi.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
|
||||
|
||||
rsFiles->addSharedDirectory(sdi);
|
||||
|
||||
load();
|
||||
messageBoxOk(tr("Shared Directory Added!"));
|
||||
}
|
||||
}
|
||||
|
||||
void ShareManager::updateFlags(bool b)
|
||||
{
|
||||
std::cerr << "Updating flags (b=" << b << ") !!!" << std::endl ;
|
||||
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
std::list<SharedDirInfo> dirs;
|
||||
rsFiles->getSharedDirectories(dirs);
|
||||
|
||||
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,1)))->isChecked()? RS_FILE_HINTS_NETWORK_WIDE:0 ;
|
||||
current_flags |= (dynamic_cast<QCheckBox*>(ui.shareddirList->cellWidget(row,2)))->isChecked()? RS_FILE_HINTS_BROWSABLE:0 ;
|
||||
|
||||
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 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShareManager::removeShareDirectory()
|
||||
{
|
||||
/* id current dir */
|
||||
/* ask for removal */
|
||||
QListWidget *listWidget = ui.shareddirList;
|
||||
QListWidgetItem *qdir = listWidget -> currentItem();
|
||||
QTableWidget *listWidget = ui.shareddirList;
|
||||
int row = listWidget -> currentRow();
|
||||
QTableWidgetItem *qdir = listWidget->item(row,0) ;
|
||||
|
||||
QString queryWrn;
|
||||
queryWrn.clear();
|
||||
queryWrn.append(tr("Do You Want to Remove ? "));
|
||||
queryWrn.append(tr("Do you really want to stop sharing this directory ? "));
|
||||
|
||||
if (qdir)
|
||||
{
|
||||
if ((QMessageBox::question(this, tr("Warning!"),queryWrn,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok)
|
||||
|
@ -32,7 +32,10 @@ class ShareManager : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
static void showYourself() ;
|
||||
|
||||
private:
|
||||
/** Default constructor */
|
||||
ShareManager( QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
/** Default destructor */
|
||||
@ -53,10 +56,12 @@ private slots:
|
||||
|
||||
void addShareDirectory();
|
||||
void removeShareDirectory();
|
||||
void updateFlags(bool);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
static ShareManager *_instance ;
|
||||
|
||||
/** Define the popup menus for the Context menu */
|
||||
QMenu* contextMnu;
|
||||
|
@ -1,92 +1,139 @@
|
||||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ShareManager</class>
|
||||
<widget class="QDialog" name="ShareManager" >
|
||||
<property name="geometry" >
|
||||
<widget class="QDialog" name="ShareManager">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>492</width>
|
||||
<width>607</width>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>RetroShare Share Manager</string>
|
||||
</property>
|
||||
<property name="windowIcon" >
|
||||
<iconset resource="images.qrc" >:/images/rstray3.png</iconset>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" colspan="4" >
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="piclabel" >
|
||||
<property name="minimumSize" >
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0" colspan="4">
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="piclabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap" >
|
||||
<pixmap resource="images.qrc" >:/images/fileshare48.png</pixmap>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="images.qrc">:/images/fileshare48.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600; color:#32cd32;">Share Manager</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;"><span style=" font-size:10pt;">Add a new Folder to Share with your Friends or remove a Shared Folder.</span></p></body></html></string>
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600; color:#32cd32;">Share Manager</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;"><span style=" font-size:10pt;">Add a new Folder to Share with your Friends or remove a Shared Folder.</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="4" >
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<item row="1" column="0" colspan="4">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Shared Folder Manager</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QListWidget" name="shareddirList" >
|
||||
<property name="contextMenuPolicy" >
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="shareddirList">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>100</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>100</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Directory</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Network Wide</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string comment="If activated, the share is anonymously accessible to anybody"/>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Browsable</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string comment="If checked, the share is browsable by your friends"/>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QPushButton" name="addButton" >
|
||||
<property name="minimumSize" >
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>27</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
@ -94,24 +141,24 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QPushButton" name="removeButton" >
|
||||
<property name="minimumSize" >
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="removeButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
<property name="iconSize" >
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
@ -119,12 +166,12 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" >
|
||||
<item row="2" column="2">
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>101</width>
|
||||
<height>20</height>
|
||||
@ -132,20 +179,20 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="3" >
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="orientation" >
|
||||
<item row="2" column="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc" />
|
||||
<include location="images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -62,14 +62,19 @@ const uint32_t RS_FILE_PEER_OFFLINE = 0x00002000;
|
||||
|
||||
const uint32_t RS_FILE_HINTS_MASK = 0x00ffffff;
|
||||
|
||||
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 uint32_t RS_FILE_HINTS_TURTLE = 0x00000040;
|
||||
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 uint32_t RS_FILE_HINTS_TURTLE = 0x00000040;
|
||||
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_SHARED_DIR_ANONYMOUS = 0x01 ;
|
||||
//const uint32_t RS_SHARED_DIR_BROWSABLE = 0x02 ;
|
||||
//const uint32_t RS_SHARED_DIR_UNIVERSAL = 0x03 ;
|
||||
|
||||
const uint32_t RS_FILE_HINTS_SPEC_ONLY = 0x01000000;
|
||||
const uint32_t RS_FILE_HINTS_NO_SEARCH = 0x02000000;
|
||||
@ -86,6 +91,11 @@ const uint32_t CB_CODE_CACHE = 0x0001;
|
||||
const uint32_t CB_CODE_EXTRA = 0x0002;
|
||||
const uint32_t CB_CODE_MEDIA = 0x0004;
|
||||
|
||||
struct SharedDirInfo
|
||||
{
|
||||
std::string filename ;
|
||||
uint32_t shareflags ; // RS_FILE_HINTS_ANONYMOUS | RS_FILE_HINTS_BROWSABLE
|
||||
};
|
||||
|
||||
class RsFiles
|
||||
{
|
||||
@ -161,8 +171,9 @@ virtual void setPartialsDirectory(std::string path) = 0;
|
||||
virtual std::string getDownloadDirectory() = 0;
|
||||
virtual std::string getPartialsDirectory() = 0;
|
||||
|
||||
virtual bool getSharedDirectories(std::list<std::string> &dirs) = 0;
|
||||
virtual bool addSharedDirectory(std::string dir) = 0;
|
||||
virtual bool getSharedDirectories(std::list<SharedDirInfo> &dirs) = 0;
|
||||
virtual bool addSharedDirectory(SharedDirInfo dir) = 0;
|
||||
virtual bool updateShareFlags(const SharedDirInfo& dir) = 0; // updates the flags. The directory should already exist !
|
||||
virtual bool removeSharedDirectory(std::string dir) = 0;
|
||||
|
||||
virtual void setShareDownloadDirectory(bool value) = 0;
|
||||
|
@ -44,6 +44,7 @@ const uint32_t RS_POPUP_MSG = 0x0001;
|
||||
const uint32_t RS_POPUP_CHAT = 0x0002;
|
||||
const uint32_t RS_POPUP_CALL = 0x0004;
|
||||
const uint32_t RS_POPUP_CONNECT = 0x0008;
|
||||
const uint32_t RS_SYSTRAY_GROUP_MSG = 0x0010;
|
||||
|
||||
/* CHAT flags are here - so they are in the same place as
|
||||
* other Notify flags... not used by libretroshare though
|
||||
|
Loading…
Reference in New Issue
Block a user