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:
csoler 2009-08-03 19:43:52 +00:00
parent aa1658245c
commit f9dc3b223b
19 changed files with 512 additions and 313 deletions

View File

@ -39,9 +39,9 @@
#include <openssl/sha.h> #include <openssl/sha.h>
#include <stdio.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) FileIndexMonitor::FileIndexMonitor(CacheStrapper *cs, NotifyBase *cb_in,std::string cachedir, std::string pid)
:CacheSource(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cachedir), fi(pid), :CacheSource(RS_SERVICE_TYPE_FILE_INDEX, false, cs, cachedir), fi(pid),
@ -59,7 +59,7 @@ FileIndexMonitor::~FileIndexMonitor()
return; return;
} }
bool FileIndexMonitor::findLocalFile(std::string hash, bool FileIndexMonitor::findLocalFile(std::string hash,uint32_t flags,
std::string &fullpath, uint64_t &size) const std::string &fullpath, uint64_t &size) const
{ {
std::list<FileEntry *> results; std::list<FileEntry *> results;
@ -602,13 +602,45 @@ void FileIndexMonitor::updateCycle()
cb->notifyHashingInfo("") ; 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 */ /* 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 #ifdef FIM_DEBUG
std::cerr << "FileIndexMonitor::setSharedDirectories() :\n"; std::cerr << "FileIndexMonitor::setSharedDirectories() :\n";
#endif #endif
@ -617,12 +649,12 @@ void FileIndexMonitor::setSharedDirectories(std::list<std::string> dirs)
{ {
#ifdef FIM_DEBUG #ifdef FIM_DEBUG
std::cerr << "\t" << *it; std::cerr << "\t" << (*it).filename;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
/* check if dir exists before adding in */ /* check if dir exists before adding in */
std::string path = (*it); std::string path = (*it).filename;
DIR *dir = opendir(path.c_str()); DIR *dir = opendir(path.c_str());
if (!dir) if (!dir)
{ {
@ -633,41 +665,37 @@ void FileIndexMonitor::setSharedDirectories(std::list<std::string> dirs)
} }
else else
{ {
checkeddirs.push_back(path); checkeddirs.push_back(*it);
} }
closedir(dir); closedir(dir);
} }
fiMutex.lock(); { /* LOCKED DIRS */ {
RsStackMutex stack(fiMutex) ;/* LOCKED DIRS */
pendingDirs = true; pendingDirs = true;
pendingDirList = checkeddirs; pendingDirList = checkeddirs;
}
} fiMutex.unlock(); /* UNLOCKED DIRS */
} }
/* interface */ /* 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 */ /* must provide pendingDirs, as other parts depend on instanteous response */
if (pendingDirs) if (pendingDirs)
{
dirs = pendingDirList; dirs = pendingDirList;
}
else else
{ {
/* get actual list (not pending stuff) */ /* get actual list (not pending stuff) */
std::map<std::string, std::string>::const_iterator it; std::map<std::string, SharedDirInfo>::const_iterator it;
for(it = directoryMap.begin(); it != directoryMap.end(); it++) for(it = directoryMap.begin(); it != directoryMap.end(); it++)
{ dirs.push_back(it->second) ;
dirs.push_back(it->second);
} }
} }
} fiMutex.unlock(); /* UNLOCKED DIRS */
} }
@ -718,12 +746,12 @@ bool FileIndexMonitor::internal_setSharedDirectories()
directoryMap.clear(); directoryMap.clear();
/* iterate through the directories */ /* iterate through the directories */
std::list<std::string>::iterator it; std::list<SharedDirInfo>::iterator it;
std::map<std::string, std::string>::const_iterator cit; std::map<std::string, SharedDirInfo>::const_iterator cit;
for(it = pendingDirList.begin(); it != pendingDirList.end(); it++) for(it = pendingDirList.begin(); it != pendingDirList.end(); it++)
{ {
/* get the head directory */ /* get the head directory */
std::string root_dir = *it; std::string root_dir = (*it).filename;
std::string top_dir = RsDirUtil::getTopDir(root_dir); std::string top_dir = RsDirUtil::getTopDir(root_dir);
/* if unique -> add, else add modifier */ /* if unique -> add, else add modifier */
@ -741,7 +769,7 @@ bool FileIndexMonitor::internal_setSharedDirectories()
{ {
unique = true; unique = true;
/* add it! */ /* add it! */
directoryMap[tst_dir.c_str()] = root_dir; directoryMap[tst_dir.c_str()] = *it;
#ifdef FIM_DEBUG #ifdef FIM_DEBUG
std::cerr << "Added [" << tst_dir << "] => " << root_dir << std::endl; std::cerr << "Added [" << tst_dir << "] => " << root_dir << std::endl;
#endif #endif
@ -774,7 +802,7 @@ std::string FileIndexMonitor::locked_findRealRoot(std::string rootdir) const
/**** MUST ALREADY BE LOCKED ****/ /**** MUST ALREADY BE LOCKED ****/
std::string realroot = ""; 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))) if (directoryMap.end()== (cit=directoryMap.find(rootdir)))
{ {
std::cerr << "FileIndexMonitor::locked_findRealRoot() Invalid RootDir: "; std::cerr << "FileIndexMonitor::locked_findRealRoot() Invalid RootDir: ";
@ -782,7 +810,7 @@ std::string FileIndexMonitor::locked_findRealRoot(std::string rootdir) const
} }
else else
{ {
realroot = cit->second; realroot = cit->second.filename;
} }
return realroot; return realroot;

View File

@ -27,6 +27,7 @@
#include "dbase/cachestrapper.h" #include "dbase/cachestrapper.h"
#include "dbase/findex.h" #include "dbase/findex.h"
#include "util/rsthreads.h" #include "util/rsthreads.h"
#include "rsiface/rsfiles.h"
/****************************************************************************************** /******************************************************************************************
* The Local Monitoring Class: FileIndexMonitor. * The Local Monitoring Class: FileIndexMonitor.
@ -66,45 +67,49 @@ class NotifyBase ;
* FileIndexMonitor * 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 class FileIndexMonitor: public CacheSource, public RsThread
{ {
public: public:
FileIndexMonitor(CacheStrapper *cs, NotifyBase *cb_in, std::string cachedir, std::string pid); FileIndexMonitor(CacheStrapper *cs, NotifyBase *cb_in, std::string cachedir, std::string pid);
virtual ~FileIndexMonitor(); virtual ~FileIndexMonitor();
/* external interface for filetransfer */ /* external interface for filetransfer */
bool findLocalFile(std::string hash, std::string &fullpath, uint64_t &size) const; bool findLocalFile(std::string hash,uint32_t f, std::string &fullpath, uint64_t &size) const;
/* external interface for local access to files */ /* external interface for local access to files */
bool convertSharedFilePath(std::string path, std::string &fullpath); bool convertSharedFilePath(std::string path, std::string &fullpath);
/* Interacting with CacheSource */ /* Interacting with CacheSource */
/* overloaded from CacheSource */ /* overloaded from CacheSource */
virtual bool loadLocalCache(const CacheData &data); /* called with stored data */ 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); /* we call when we have a new cache for others */
/* the FileIndexMonitor inner workings */ /* the FileIndexMonitor inner workings */
//virtual void run(std::string& currentJob); /* overloaded from RsThread */ //virtual void run(std::string& currentJob); /* overloaded from RsThread */
//void updateCycle(std::string& currentJob); //void updateCycle(std::string& currentJob);
virtual void run(); /* overloaded from RsThread */ virtual void run(); /* overloaded from RsThread */
void updateCycle(); void updateCycle();
virtual void setSharedDirectories(std::list<std::string> dirs); virtual void setSharedDirectories(std::list<SharedDirInfo> dirs);
void getSharedDirectories(std::list<std::string> &dirs); void getSharedDirectories(std::list<SharedDirInfo>& dirs);
void updateShareFlags(const SharedDirInfo& info) ;
void setPeriod(int insecs); void setPeriod(int insecs);
void forceDirectoryCheck(); void forceDirectoryCheck();
bool inDirectoryCheck(); bool inDirectoryCheck();
/* util fns */ /* util fns */
private: private:
/* the mutex should be locked before calling... these. */ /* the mutex should be locked before calling... these. */
std::string locked_findRealRoot(std::string base) const; std::string locked_findRealRoot(std::string base) const;
bool hashFile(std::string path, FileEntry &fi); /* To Implement */ bool hashFile(std::string path, FileEntry &fi); /* To Implement */
/* data */ /* data */
@ -113,7 +118,7 @@ bool hashFile(std::string path, FileEntry &fi); /* To Implement */
FileIndex fi; FileIndex fi;
int updatePeriod; int updatePeriod;
std::map<std::string, std::string> directoryMap; /* used by findRealRoot */ std::map<std::string, SharedDirInfo> directoryMap; /* used by findRealRoot */
/* flags to kick - if we were busy or sleeping */ /* flags to kick - if we were busy or sleeping */
bool pendingDirs; bool pendingDirs;
@ -123,7 +128,7 @@ bool hashFile(std::string path, FileEntry &fi); /* To Implement */
bool mForceCheck; bool mForceCheck;
bool mInCheck; bool mInCheck;
std::list<std::string> pendingDirList; std::list<SharedDirInfo> pendingDirList;
bool internal_setSharedDirectories(); bool internal_setSharedDirectories();
NotifyBase *cb ; NotifyBase *cb ;

View File

@ -136,7 +136,10 @@ bool ftFiMonitor::search(std::string hash, uint64_t size, uint32_t hintflags, Fi
std::cerr << std::endl; std::cerr << std::endl;
#endif #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 */ /* fill in details */
#ifdef DB_DEBUG #ifdef DB_DEBUG
@ -184,15 +187,16 @@ std::list<RsItem *> ftFiMonitor::saveList(bool &cleanup)
#endif #endif
/* get list of directories */ /* get list of directories */
std::list<std::string> dirList; std::list<SharedDirInfo> dirList;
std::list<std::string>::iterator it; std::list<SharedDirInfo>::iterator it;
getSharedDirectories(dirList); getSharedDirectories(dirList);
for(it = dirList.begin(); it != dirList.end(); it++) for(it = dirList.begin(); it != dirList.end(); it++)
{ {
RsFileConfigItem *fi = new RsFileConfigItem(); RsFileConfigItem *fi = new RsFileConfigItem();
fi->file.path = *it; fi->file.path = (*it).filename ;
fi->flags = (*it).shareflags ;
sList.push_back(fi); sList.push_back(fi);
} }
@ -214,7 +218,7 @@ bool ftFiMonitor::loadList(std::list<RsItem *> load)
time_t ts = time(NULL); time_t ts = time(NULL);
std::list<std::string> dirList; std::list<SharedDirInfo> dirList;
std::list<RsItem *>::iterator it; std::list<RsItem *>::iterator it;
for(it = load.begin(); it != load.end(); it++) for(it = load.begin(); it != load.end(); it++)
@ -228,7 +232,11 @@ bool ftFiMonitor::loadList(std::list<RsItem *> load)
/* ensure that it exists? */ /* 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 */ /* set directories */
@ -236,7 +244,15 @@ bool ftFiMonitor::loadList(std::list<RsItem *> load)
return true; 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); FileIndexMonitor::setSharedDirectories(dirList);

View File

@ -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; virtual bool search(std::string hash, uint64_t size, uint32_t hintflags, FileInfo &info) const;
/* overloaded set dirs enables config indication */ /* 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 * Configuration - store shared directories

View File

@ -246,6 +246,8 @@ bool ftServer::FileRequest(std::string fname, std::string hash, uint64_t size,
// dest, flags, srcIds); // dest, flags, srcIds);
const DwlDetails details(fname, hash, size, dest, flags, srcIds, Normal); const DwlDetails details(fname, hash, size, dest, flags, srcIds, Normal);
mFtDwlQueue->insertDownload(details); mFtDwlQueue->insertDownload(details);
return true ;
} }
bool ftServer::FileCancel(std::string hash) bool ftServer::FileCancel(std::string hash)
@ -471,32 +473,46 @@ bool ftServer::InDirectoryCheck()
return mFiMon->inDirectoryCheck(); return mFiMon->inDirectoryCheck();
} }
bool ftServer::getSharedDirectories(std::list<std::string> &dirs) bool ftServer::getSharedDirectories(std::list<SharedDirInfo> &dirs)
{ {
mFiMon->getSharedDirectories(dirs); mFiMon->getSharedDirectories(dirs);
return true; return true;
} }
bool ftServer::setSharedDirectories(std::list<std::string> &dirs) bool ftServer::setSharedDirectories(std::list<SharedDirInfo> &dirs)
{ {
mFiMon->setSharedDirectories(dirs); mFiMon->setSharedDirectories(dirs);
return true; 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); 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); dirList.push_back(dir);
mFiMon->setSharedDirectories(dirList); mFiMon->setSharedDirectories(dirList);
return true; return true;
} }
bool ftServer::updateShareFlags(const SharedDirInfo& info)
{
mFiMon->updateShareFlags(info);
return true ;
}
bool ftServer::removeSharedDirectory(std::string dir) bool ftServer::removeSharedDirectory(std::string dir)
{ {
std::list<std::string> dirList; std::list<SharedDirInfo> dirList;
std::list<std::string>::iterator it; std::list<SharedDirInfo>::iterator it;
#ifdef SERVER_DEBUG #ifdef SERVER_DEBUG
std::cerr << "ftServer::removeSharedDirectory(" << dir << ")"; std::cerr << "ftServer::removeSharedDirectory(" << dir << ")";
@ -509,13 +525,14 @@ bool ftServer::removeSharedDirectory(std::string dir)
for(it = dirList.begin(); it != dirList.end(); it++) for(it = dirList.begin(); it != dirList.end(); it++)
{ {
std::cerr << "ftServer::removeSharedDirectory()"; std::cerr << "ftServer::removeSharedDirectory()";
std::cerr << " existing: " << *it; std::cerr << " existing: " << (*it).filename;
std::cerr << std::endl; std::cerr << std::endl;
} }
#endif #endif
if (dirList.end() == (it = for(it = dirList.begin();it!=dirList.end() && (*it).filename != dir;++it) ;
std::find(dirList.begin(), dirList.end(), dir)))
if(it == dirList.end())
{ {
#ifdef SERVER_DEBUG #ifdef SERVER_DEBUG
std::cerr << "ftServer::removeSharedDirectory()"; std::cerr << "ftServer::removeSharedDirectory()";
@ -551,8 +568,11 @@ bool ftServer::getShareDownloadDirectory()
bool ftServer::shareDownloadDirectory() bool ftServer::shareDownloadDirectory()
{ {
std::string dir = mFtController->getDownloadDirectory(); SharedDirInfo inf ;
return addSharedDirectory(dir); inf.filename = mFtController->getDownloadDirectory();
inf.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
return addSharedDirectory(inf);
} }
bool ftServer::unshareDownloadDirectory() bool ftServer::unshareDownloadDirectory()

View File

@ -175,9 +175,10 @@ virtual void setPartialsDirectory(std::string path);
virtual std::string getDownloadDirectory(); virtual std::string getDownloadDirectory();
virtual std::string getPartialsDirectory(); virtual std::string getPartialsDirectory();
virtual bool getSharedDirectories(std::list<std::string> &dirs); virtual bool getSharedDirectories(std::list<SharedDirInfo> &dirs);
virtual bool setSharedDirectories(std::list<std::string> &dirs); virtual bool setSharedDirectories(std::list<SharedDirInfo> &dirs);
virtual bool addSharedDirectory(std::string dir); 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 bool removeSharedDirectory(std::string dir);
virtual void setShareDownloadDirectory(bool value); virtual void setShareDownloadDirectory(bool value);

View File

@ -66,10 +66,15 @@ const uint32_t RS_FILE_HINTS_CACHE = 0x00000001;
const uint32_t RS_FILE_HINTS_EXTRA = 0x00000002; const uint32_t RS_FILE_HINTS_EXTRA = 0x00000002;
const uint32_t RS_FILE_HINTS_LOCAL = 0x00000004; const uint32_t RS_FILE_HINTS_LOCAL = 0x00000004;
const uint32_t RS_FILE_HINTS_REMOTE = 0x00000008; const uint32_t RS_FILE_HINTS_REMOTE = 0x00000008;
const uint32_t RS_FILE_HINTS_DOWNLOAD= 0x00000010; const uint32_t RS_FILE_HINTS_DOWNLOAD = 0x00000010;
const uint32_t RS_FILE_HINTS_UPLOAD = 0x00000020; const uint32_t RS_FILE_HINTS_UPLOAD = 0x00000020;
const uint32_t RS_FILE_HINTS_TURTLE = 0x00000040; 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_SPEC_ONLY = 0x01000000;
const uint32_t RS_FILE_HINTS_NO_SEARCH = 0x02000000; 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_EXTRA = 0x0002;
const uint32_t CB_CODE_MEDIA = 0x0004; 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 class RsFiles
{ {
@ -161,8 +171,9 @@ virtual void setPartialsDirectory(std::string path) = 0;
virtual std::string getDownloadDirectory() = 0; virtual std::string getDownloadDirectory() = 0;
virtual std::string getPartialsDirectory() = 0; virtual std::string getPartialsDirectory() = 0;
virtual bool getSharedDirectories(std::list<std::string> &dirs) = 0; virtual bool getSharedDirectories(std::list<SharedDirInfo> &dirs) = 0;
virtual bool addSharedDirectory(std::string dir) = 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 bool removeSharedDirectory(std::string dir) = 0;
virtual void setShareDownloadDirectory(bool value) = 0; virtual void setShareDownloadDirectory(bool value) = 0;

View File

@ -153,7 +153,7 @@ bool SetRedirectAndTest(struct UPNPUrls * urls,
#else #else
/* The lease parameter is also gone in minupnpc 1.0 */ /* The lease parameter is also gone in minupnpc 1.0 */
r = UPNP_AddPortMapping(urls->controlURL, data->servicetype, r = UPNP_AddPortMapping(urls->controlURL, data->servicetype,
eport, iport, iaddr, 0, proto); eport, iport, iaddr,0, 0, proto);
#endif #endif
#endif #endif

View File

@ -192,9 +192,7 @@ void LibraryDialog::StopRename()
void LibraryDialog::CallShareFilesBtn_library() void LibraryDialog::CallShareFilesBtn_library()
{ {
static ShareManager* sharemanager = new ShareManager(this); ShareManager::showYourself();
sharemanager->show();
} }
void LibraryDialog::CallTileViewBtn_library() void LibraryDialog::CallTileViewBtn_library()

View File

@ -450,9 +450,7 @@ void MainWindow::addFriend()
/** Shows Share Manager */ /** Shows Share Manager */
void MainWindow::openShareManager() void MainWindow::openShareManager()
{ {
static ShareManager* sharemanager = new ShareManager(this); ShareManager::showYourself();
sharemanager->show();
} }
/** Creates and displays the Configuration dialog with the current page set to /** Creates and displays the Configuration dialog with the current page set to

View File

@ -370,8 +370,7 @@ void MessengerWindow::showMessagesPopup()
/** Shows Share Manager */ /** Shows Share Manager */
void MessengerWindow::openShareManager() void MessengerWindow::openShareManager()
{ {
static ShareManager* sharemanager = new ShareManager(this); ShareManager::showYourself();
sharemanager->show();
} }

View File

@ -23,6 +23,7 @@
#include <rshare.h> #include <rshare.h>
#include "rsiface/rsfiles.h" #include "rsiface/rsfiles.h"
#include "DirectoriesDialog.h" #include "DirectoriesDialog.h"
#include "gui/ShareManager.h"
#include <algorithm> #include <algorithm>
@ -36,14 +37,16 @@ DirectoriesDialog::DirectoriesDialog(QWidget *parent)
/* Create RshareSettings object */ /* Create RshareSettings object */
_settings = new RshareSettings(); _settings = new RshareSettings();
connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( addShareDirectory() ) ); // connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( addShareDirectory() ) );
connect(ui.removeButton, SIGNAL(clicked( bool ) ), this , SLOT( removeShareDirectory() ) ); // connect(ui.removeButton, SIGNAL(clicked( bool ) ), this , SLOT( removeShareDirectory() ) );
connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) ); connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) ); connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(shareDownloadDirectory(int))); 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.addButton->setToolTip(tr("Add a Share Directory"));
ui.removeButton->setToolTip(tr("Remove Shared Directory")); ui.removeButton->setToolTip(tr("Remove Shared Directory"));
#endif
ui.incomingButton->setToolTip(tr("Browse")); ui.incomingButton->setToolTip(tr("Browse"));
ui.partialButton->setToolTip(tr("Browse")); ui.partialButton->setToolTip(tr("Browse"));
@ -62,23 +65,33 @@ DirectoriesDialog::DirectoriesDialog(QWidget *parent)
#endif #endif
} }
void DirectoriesDialog::editDirectories()
{
ShareManager::showYourself() ;
}
/** Saves the changes on this page */ /** Saves the changes on this page */
bool bool DirectoriesDialog::save(QString &errmsg)
DirectoriesDialog::save(QString &errmsg)
{ {
/* this is usefull especially when shared incoming files is /* this is usefull especially when shared incoming files is
* default option and when the user don't check/uncheck the * default option and when the user don't check/uncheck the
* checkBox, so no signal is emitted to update the shared list */ * checkBox, so no signal is emitted to update the shared list */
if (ui.checkBox->isChecked()) if (ui.checkBox->isChecked())
{ {
std::list<std::string>::const_iterator it; std::list<SharedDirInfo>::const_iterator it;
std::list<std::string> dirs; std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(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())
{ {
rsFiles->shareDownloadDirectory(); found=true ;
break ;
} }
if(!found)
rsFiles->shareDownloadDirectory();
rsFiles->setShareDownloadDirectory(true); rsFiles->setShareDownloadDirectory(true);
} }
else else
@ -93,8 +106,8 @@ DirectoriesDialog::save(QString &errmsg)
/** Loads the settings for this page */ /** Loads the settings for this page */
void DirectoriesDialog::load() void DirectoriesDialog::load()
{ {
std::list<std::string>::const_iterator it; std::list<SharedDirInfo>::const_iterator it;
std::list<std::string> dirs; std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs); rsFiles->getSharedDirectories(dirs);
/* get a link to the table */ /* get a link to the table */
@ -106,7 +119,7 @@ void DirectoriesDialog::load()
for(it = dirs.begin(); it != dirs.end(); it++) for(it = dirs.begin(); it != dirs.end(); it++)
{ {
/* (0) Dir Name */ /* (0) Dir Name */
listWidget->addItem(QString::fromStdString(*it)); listWidget->addItem(QString::fromStdString((*it).filename));
} }
ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory())); ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));
@ -115,6 +128,7 @@ void DirectoriesDialog::load()
listWidget->update(); /* update display */ listWidget->update(); /* update display */
} }
#ifdef TO_REMOVE
void DirectoriesDialog::addShareDirectory() void DirectoriesDialog::addShareDirectory()
{ {
@ -147,6 +161,7 @@ void DirectoriesDialog::removeShareDirectory()
load(); load();
} }
} }
#endif
void DirectoriesDialog::setIncomingDirectory() void DirectoriesDialog::setIncomingDirectory()
{ {
@ -159,14 +174,19 @@ void DirectoriesDialog::setIncomingDirectory()
rsFiles->setDownloadDirectory(dir); rsFiles->setDownloadDirectory(dir);
if (ui.checkBox->isChecked()) if (ui.checkBox->isChecked())
{ {
std::list<std::string>::const_iterator it; std::list<SharedDirInfo>::const_iterator it;
std::list<std::string> dirs; std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(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())
{ {
rsFiles->shareDownloadDirectory(); found=true ;
break ;
} }
if(!found)
rsFiles->shareDownloadDirectory();
} }
} }
load(); load();
@ -189,14 +209,20 @@ void DirectoriesDialog::shareDownloadDirectory(int state)
{ {
if (state == Qt::Checked) if (state == Qt::Checked)
{ {
std::list<std::string>::const_iterator it; std::list<SharedDirInfo>::const_iterator it;
std::list<std::string> dirs; std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(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())
{ {
rsFiles->shareDownloadDirectory(); found=true ;
break ;
} }
if(!found)
rsFiles->shareDownloadDirectory();
rsFiles->setShareDownloadDirectory(true); rsFiles->setShareDownloadDirectory(true);
} }
else else

View File

@ -44,9 +44,11 @@ public:
void load(); void load();
private slots: private slots:
#ifdef TO_REMOVE
void addShareDirectory(); void addShareDirectory();
void removeShareDirectory(); void removeShareDirectory();
#endif
void editDirectories() ;
void setIncomingDirectory(); void setIncomingDirectory();
void setPartialsDirectory(); void setPartialsDirectory();
void shareDownloadDirectory(int state); void shareDownloadDirectory(int state);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>452</width> <width>483</width>
<height>349</height> <height>337</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -509,102 +509,6 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </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"> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
@ -695,14 +599,48 @@
</layout> </layout>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>incomingDir</tabstop> <tabstop>incomingDir</tabstop>
<tabstop>incomingButton</tabstop> <tabstop>incomingButton</tabstop>
<tabstop>dirList</tabstop> <tabstop>dirList</tabstop>
<tabstop>addButton</tabstop>
<tabstop>removeButton</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../images.qrc"/> <include location="../images.qrc"/>

View File

@ -24,16 +24,20 @@
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>
#include <QCheckBox>
#include <QCursor> #include <QCursor>
#include <QPoint> #include <QPoint>
#include <QMouseEvent> #include <QMouseEvent>
#include <QPixmap> #include <QPixmap>
#include <QMessageBox> #include <QMessageBox>
#include <QComboBox>
/* Images for context menu icons */ /* Images for context menu icons */
#define IMAGE_CANCEL ":/images/delete.png" #define IMAGE_CANCEL ":/images/delete.png"
ShareManager *ShareManager::_instance = NULL ;
/** Default constructor */ /** Default constructor */
ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags) ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags) : QDialog(parent, flags)
@ -75,27 +79,82 @@ void ShareManager::shareddirListCostumPopupMenu( QPoint point )
/** Loads the settings for this page */ /** Loads the settings for this page */
void ShareManager::load() void ShareManager::load()
{ {
std::list<std::string>::const_iterator it; std::list<SharedDirInfo>::const_iterator it;
std::list<std::string> dirs; std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs); rsFiles->getSharedDirectories(dirs);
/* get a link to the table */ /* get a link to the table */
QListWidget *listWidget = ui.shareddirList; QTableWidget *listWidget = ui.shareddirList;
/* remove old items ??? */ /* 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->insertRow(row) ;
listWidget->addItem(QString::fromStdString(*it)); 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())); //ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));
listWidget->update(); /* update display */ listWidget->update(); /* update display */
}
void ShareManager::showYourself()
{
if(_instance == NULL)
_instance = new ShareManager(NULL,0) ;
_instance->show() ;
} }
void ShareManager::addShareDirectory() void ShareManager::addShareDirectory()
@ -112,22 +171,55 @@ void ShareManager::addShareDirectory()
std::string dir = qdir.toStdString(); std::string dir = qdir.toStdString();
if (dir != "") 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(); load();
messageBoxOk(tr("Shared Directory Added!")); 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() void ShareManager::removeShareDirectory()
{ {
/* id current dir */ /* id current dir */
/* ask for removal */ /* ask for removal */
QListWidget *listWidget = ui.shareddirList; QTableWidget *listWidget = ui.shareddirList;
QListWidgetItem *qdir = listWidget -> currentItem(); int row = listWidget -> currentRow();
QTableWidgetItem *qdir = listWidget->item(row,0) ;
QString queryWrn; QString queryWrn;
queryWrn.clear(); 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 (qdir)
{ {
if ((QMessageBox::question(this, tr("Warning!"),queryWrn,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok) if ((QMessageBox::question(this, tr("Warning!"),queryWrn,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok)

View File

@ -32,7 +32,10 @@ class ShareManager : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
static void showYourself() ;
private:
/** Default constructor */ /** Default constructor */
ShareManager( QWidget *parent = 0, Qt::WFlags flags = 0); ShareManager( QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */ /** Default destructor */
@ -53,10 +56,12 @@ private slots:
void addShareDirectory(); void addShareDirectory();
void removeShareDirectory(); void removeShareDirectory();
void updateFlags(bool);
private: private:
static ShareManager *_instance ;
/** Define the popup menus for the Context menu */ /** Define the popup menus for the Context menu */
QMenu* contextMnu; QMenu* contextMnu;

View File

@ -1,92 +1,139 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShareManager</class> <class>ShareManager</class>
<widget class="QDialog" name="ShareManager" > <widget class="QDialog" name="ShareManager">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>492</width> <width>607</width>
<height>370</height> <height>370</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>RetroShare Share Manager</string> <string>RetroShare Share Manager</string>
</property> </property>
<property name="windowIcon" > <property name="windowIcon">
<iconset resource="images.qrc" >:/images/rstray3.png</iconset> <iconset resource="images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout">
<item row="0" column="0" colspan="4" > <item row="0" column="0" colspan="4">
<layout class="QGridLayout" > <layout class="QGridLayout">
<item row="0" column="0" > <item row="0" column="0">
<widget class="QLabel" name="piclabel" > <widget class="QLabel" name="piclabel">
<property name="minimumSize" > <property name="minimumSize">
<size> <size>
<width>48</width> <width>48</width>
<height>48</height> <height>48</height>
</size> </size>
</property> </property>
<property name="maximumSize" > <property name="maximumSize">
<size> <size>
<width>48</width> <width>48</width>
<height>48</height> <height>48</height>
</size> </size>
</property> </property>
<property name="text" > <property name="text">
<string/> <string/>
</property> </property>
<property name="pixmap" > <property name="pixmap">
<pixmap resource="images.qrc" >:/images/fileshare48.png</pixmap> <pixmap resource="images.qrc">:/images/fileshare48.png</pixmap>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" > <item row="0" column="1">
<widget class="QLabel" name="label_2" > <widget class="QLabel" name="label_2">
<property name="text" > <property name="text">
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css"> <string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:16pt; font-weight:600; color:#32cd32;">Share Manager&lt;/span>&lt;/p> &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt; font-weight:600; color:#32cd32;&quot;&gt;Share Manager&lt;/span&gt;&lt;/p&gt;
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;">&lt;span style=" font-size:10pt;">Add a new Folder to Share with your Friends or remove a Shared Folder.&lt;/span>&lt;/p>&lt;/body>&lt;/html></string> &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Add a new Folder to Share with your Friends or remove a Shared Folder.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0" colspan="4" > <item row="1" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox" > <widget class="QGroupBox" name="groupBox">
<property name="title" > <property name="title">
<string>Shared Folder Manager</string> <string>Shared Folder Manager</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QVBoxLayout" name="verticalLayout">
<item row="0" column="0" > <item>
<widget class="QListWidget" name="shareddirList" > <widget class="QTableWidget" name="shareddirList">
<property name="contextMenuPolicy" > <property name="selectionMode">
<enum>Qt::CustomContextMenu</enum> <enum>QAbstractItemView::SingleSelection</enum>
</property> </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> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0" > <item row="2" column="0">
<widget class="QPushButton" name="addButton" > <widget class="QPushButton" name="addButton">
<property name="minimumSize" > <property name="minimumSize">
<size> <size>
<width>27</width> <width>27</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize" > <property name="maximumSize">
<size> <size>
<width>200</width> <width>200</width>
<height>200</height> <height>200</height>
</size> </size>
</property> </property>
<property name="text" > <property name="text">
<string>Add</string> <string>Add</string>
</property> </property>
<property name="iconSize" > <property name="iconSize">
<size> <size>
<width>24</width> <width>24</width>
<height>24</height> <height>24</height>
@ -94,24 +141,24 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" > <item row="2" column="1">
<widget class="QPushButton" name="removeButton" > <widget class="QPushButton" name="removeButton">
<property name="minimumSize" > <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize" > <property name="maximumSize">
<size> <size>
<width>200</width> <width>200</width>
<height>200</height> <height>200</height>
</size> </size>
</property> </property>
<property name="text" > <property name="text">
<string>Remove</string> <string>Remove</string>
</property> </property>
<property name="iconSize" > <property name="iconSize">
<size> <size>
<width>16</width> <width>16</width>
<height>16</height> <height>16</height>
@ -119,12 +166,12 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2" > <item row="2" column="2">
<spacer> <spacer>
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>101</width> <width>101</width>
<height>20</height> <height>20</height>
@ -132,20 +179,20 @@ p, li { white-space: pre-wrap; }
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="3" > <item row="2" column="3">
<widget class="QDialogButtonBox" name="buttonBox" > <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons" > <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="images.qrc" /> <include location="images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -66,10 +66,15 @@ const uint32_t RS_FILE_HINTS_CACHE = 0x00000001;
const uint32_t RS_FILE_HINTS_EXTRA = 0x00000002; const uint32_t RS_FILE_HINTS_EXTRA = 0x00000002;
const uint32_t RS_FILE_HINTS_LOCAL = 0x00000004; const uint32_t RS_FILE_HINTS_LOCAL = 0x00000004;
const uint32_t RS_FILE_HINTS_REMOTE = 0x00000008; const uint32_t RS_FILE_HINTS_REMOTE = 0x00000008;
const uint32_t RS_FILE_HINTS_DOWNLOAD= 0x00000010; const uint32_t RS_FILE_HINTS_DOWNLOAD = 0x00000010;
const uint32_t RS_FILE_HINTS_UPLOAD = 0x00000020; const uint32_t RS_FILE_HINTS_UPLOAD = 0x00000020;
const uint32_t RS_FILE_HINTS_TURTLE = 0x00000040; 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_SPEC_ONLY = 0x01000000;
const uint32_t RS_FILE_HINTS_NO_SEARCH = 0x02000000; 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_EXTRA = 0x0002;
const uint32_t CB_CODE_MEDIA = 0x0004; 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 class RsFiles
{ {
@ -161,8 +171,9 @@ virtual void setPartialsDirectory(std::string path) = 0;
virtual std::string getDownloadDirectory() = 0; virtual std::string getDownloadDirectory() = 0;
virtual std::string getPartialsDirectory() = 0; virtual std::string getPartialsDirectory() = 0;
virtual bool getSharedDirectories(std::list<std::string> &dirs) = 0; virtual bool getSharedDirectories(std::list<SharedDirInfo> &dirs) = 0;
virtual bool addSharedDirectory(std::string dir) = 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 bool removeSharedDirectory(std::string dir) = 0;
virtual void setShareDownloadDirectory(bool value) = 0; virtual void setShareDownloadDirectory(bool value) = 0;

View File

@ -44,6 +44,7 @@ const uint32_t RS_POPUP_MSG = 0x0001;
const uint32_t RS_POPUP_CHAT = 0x0002; const uint32_t RS_POPUP_CHAT = 0x0002;
const uint32_t RS_POPUP_CALL = 0x0004; const uint32_t RS_POPUP_CALL = 0x0004;
const uint32_t RS_POPUP_CONNECT = 0x0008; 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 /* CHAT flags are here - so they are in the same place as
* other Notify flags... not used by libretroshare though * other Notify flags... not used by libretroshare though