mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 15:09:33 -05:00
Fix Partial Dir Check
Add WrongValue StyleSheet property, when bad directory selected. Update QLineEdit with current setting so it's possible to see if something is modified. No need to restart.
This commit is contained in:
parent
57cff61873
commit
f12cd5774d
@ -1472,24 +1472,24 @@ bool ftController::setPartialsDirectory(std::string path)
|
||||
|
||||
/* check it is not a subdir of download / shared directories (BAD) - TODO */
|
||||
{
|
||||
RsStackMutex stack(ctrlMutex);
|
||||
RsStackMutex stack(ctrlMutex);
|
||||
|
||||
path = RsDirUtil::convertPathToUnix(path);
|
||||
path = RsDirUtil::convertPathToUnix(path);
|
||||
|
||||
if (path.find(mDownloadPath) == std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
if (path.find(mDownloadPath) != std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rsFiles) {
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
std::list<SharedDirInfo> dirs;
|
||||
rsFiles->getSharedDirectories(dirs);
|
||||
for (it = dirs.begin(); it != dirs.end(); ++it) {
|
||||
if (path.find((*it).filename) == std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rsFiles) {
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
std::list<SharedDirInfo> dirs;
|
||||
rsFiles->getSharedDirectories(dirs);
|
||||
for (it = dirs.begin(); it != dirs.end(); ++it) {
|
||||
if (path.find((*it).filename) != std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check if it exists */
|
||||
|
@ -175,8 +175,8 @@ class ftController: public RsTickingThread, public pqiServiceMonitor, public p3C
|
||||
void FileDownloads(std::list<RsFileHash> &hashs);
|
||||
|
||||
/* Directory Handling */
|
||||
bool setDownloadDirectory(std::string path);
|
||||
bool setPartialsDirectory(std::string path);
|
||||
bool setDownloadDirectory(std::string path);
|
||||
bool setPartialsDirectory(std::string path);
|
||||
std::string getDownloadDirectory();
|
||||
std::string getPartialsDirectory();
|
||||
bool FileDetails(const RsFileHash &hash, FileInfo &info);
|
||||
|
@ -23,35 +23,40 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsprint.h"
|
||||
#include "crypto/chacha20.h"
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
//const int ftserverzone = 29539;
|
||||
|
||||
#include "file_sharing/p3filelists.h"
|
||||
#include "ft/ftturtlefiletransferitem.h"
|
||||
#include "ft/ftserver.h"
|
||||
#include "ft/ftextralist.h"
|
||||
#include "ft/ftfilesearch.h"
|
||||
#include "ft/ftcontroller.h"
|
||||
#include "ft/ftfileprovider.h"
|
||||
#include "ft/ftdatamultiplex.h"
|
||||
//#include "ft/ftdwlqueue.h"
|
||||
#include "turtle/p3turtle.h"
|
||||
#include "pqi/p3notify.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "ft/ftextralist.h"
|
||||
#include "ft/ftfileprovider.h"
|
||||
#include "ft/ftfilesearch.h"
|
||||
#include "ft/ftserver.h"
|
||||
#include "ft/ftturtlefiletransferitem.h"
|
||||
|
||||
#include "pqi/pqi.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "pqi/p3notify.h"
|
||||
#include "pqi/pqi.h"
|
||||
|
||||
#include "retroshare/rstypes.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
#include "rsitems/rsfiletransferitems.h"
|
||||
#include "rsitems/rsserviceids.h"
|
||||
|
||||
#include "rsserver/p3face.h"
|
||||
#include "rsserver/rsaccounts.h"
|
||||
#include "turtle/p3turtle.h"
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsprint.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
|
||||
/***
|
||||
* #define SERVER_DEBUG 1
|
||||
* #define SERVER_DEBUG_CACHE 1
|
||||
@ -145,9 +150,19 @@ void ftServer::SetupFtServer()
|
||||
/* make Controller */
|
||||
mFtController = new ftController(mFtDataplex, mServiceCtrl, getServiceInfo().mServiceType);
|
||||
mFtController -> setFtSearchNExtra(mFtSearch, mFtExtra);
|
||||
std::string tmppath = ".";
|
||||
mFtController->setPartialsDirectory(tmppath);
|
||||
mFtController->setDownloadDirectory(tmppath);
|
||||
|
||||
std::string emergencySaveDir = rsAccounts->PathAccountDirectory();
|
||||
std::string emergencyPartialsDir = rsAccounts->PathAccountDirectory();
|
||||
if (emergencySaveDir != "")
|
||||
{
|
||||
emergencySaveDir += "/";
|
||||
emergencyPartialsDir += "/";
|
||||
}
|
||||
emergencySaveDir += "Downloads";
|
||||
emergencyPartialsDir += "Partials";
|
||||
|
||||
mFtController->setDownloadDirectory(emergencySaveDir);
|
||||
mFtController->setPartialsDirectory(emergencyPartialsDir);
|
||||
|
||||
/* complete search setup */
|
||||
mFtSearch->addSearchMode(mFtExtra, RS_FILE_HINTS_EXTRA);
|
||||
@ -412,9 +427,9 @@ void ftServer::requestDirUpdate(void *ref)
|
||||
}
|
||||
|
||||
/* Directory Handling */
|
||||
void ftServer::setDownloadDirectory(std::string path)
|
||||
bool ftServer::setDownloadDirectory(std::string path)
|
||||
{
|
||||
mFtController->setDownloadDirectory(path);
|
||||
return mFtController->setDownloadDirectory(path);
|
||||
}
|
||||
|
||||
std::string ftServer::getDownloadDirectory()
|
||||
@ -422,9 +437,9 @@ std::string ftServer::getDownloadDirectory()
|
||||
return mFtController->getDownloadDirectory();
|
||||
}
|
||||
|
||||
void ftServer::setPartialsDirectory(std::string path)
|
||||
bool ftServer::setPartialsDirectory(std::string path)
|
||||
{
|
||||
mFtController->setPartialsDirectory(path);
|
||||
return mFtController->setPartialsDirectory(path);
|
||||
}
|
||||
|
||||
std::string ftServer::getPartialsDirectory()
|
||||
|
@ -202,8 +202,8 @@ public:
|
||||
* Directory Handling
|
||||
***/
|
||||
virtual void requestDirUpdate(void *ref) ; // triggers the update of the given reference. Used when browsing.
|
||||
virtual void setDownloadDirectory(std::string path);
|
||||
virtual void setPartialsDirectory(std::string path);
|
||||
virtual bool setDownloadDirectory(std::string path);
|
||||
virtual bool setPartialsDirectory(std::string path);
|
||||
virtual std::string getDownloadDirectory();
|
||||
virtual std::string getPartialsDirectory();
|
||||
|
||||
|
@ -278,8 +278,8 @@ class RsFiles
|
||||
***/
|
||||
virtual void requestDirUpdate(void *ref) =0 ; // triggers the update of the given reference. Used when browsing.
|
||||
|
||||
virtual void setDownloadDirectory(std::string path) = 0;
|
||||
virtual void setPartialsDirectory(std::string path) = 0;
|
||||
virtual bool setDownloadDirectory(std::string path) = 0;
|
||||
virtual bool setPartialsDirectory(std::string path) = 0;
|
||||
virtual std::string getDownloadDirectory() = 0;
|
||||
virtual std::string getPartialsDirectory() = 0;
|
||||
|
||||
|
@ -244,9 +244,15 @@ OpModeStatus[opMode="Minimal"] {
|
||||
background: #FFCCCC;
|
||||
}
|
||||
|
||||
/*Property Values at end to overwrite other settings*/
|
||||
|
||||
[new=false] {
|
||||
background: #F8F8F8;
|
||||
}
|
||||
[new=true] {
|
||||
background: #DCECFD;
|
||||
}
|
||||
|
||||
[WrongValue="true"] {
|
||||
background-color: #FF8080;
|
||||
}
|
||||
|
@ -22,15 +22,17 @@
|
||||
#include "TransferPage.h"
|
||||
|
||||
#include "rshare.h"
|
||||
#include "gui/ShareManager.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
#include <QToolTip>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <util/misc.h>
|
||||
#include <gui/ShareManager.h>
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
TransferPage::TransferPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
@ -225,11 +227,23 @@ void TransferPage::setIncomingDirectory()
|
||||
return;
|
||||
}
|
||||
|
||||
ui.incomingDir->setText(qdir);
|
||||
std::string dir = ui.incomingDir->text().toUtf8().constData();
|
||||
|
||||
if(!dir.empty())
|
||||
rsFiles->setDownloadDirectory(dir);
|
||||
std::string dir = qdir.toUtf8().constData();
|
||||
if(!dir.empty())
|
||||
{
|
||||
if (!rsFiles->setDownloadDirectory(dir))
|
||||
{
|
||||
ui.incomingDir->setToolTip( tr("Invalid Input. Have you got the right to write on it?") );
|
||||
ui.incomingDir->setProperty("WrongValue", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.incomingDir->setToolTip( "" );
|
||||
ui.incomingDir->setProperty("WrongValue", false);
|
||||
}
|
||||
}
|
||||
ui.incomingDir->style()->unpolish(ui.incomingDir);
|
||||
ui.incomingDir->style()->polish( ui.incomingDir);
|
||||
whileBlocking(ui.incomingDir)->setText(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()));
|
||||
}
|
||||
|
||||
void TransferPage::setPartialsDirectory()
|
||||
@ -239,11 +253,25 @@ void TransferPage::setPartialsDirectory()
|
||||
return;
|
||||
}
|
||||
|
||||
ui.partialsDir->setText(qdir);
|
||||
std::string dir = ui.partialsDir->text().toUtf8().constData();
|
||||
std::string dir = qdir.toUtf8().constData();
|
||||
if (!dir.empty())
|
||||
rsFiles->setPartialsDirectory(dir);
|
||||
{
|
||||
if (!rsFiles->setPartialsDirectory(dir))
|
||||
{
|
||||
ui.partialsDir->setToolTip( tr("Invalid Input. It can't be an already shared directory.") );
|
||||
ui.partialsDir->setProperty("WrongValue", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.partialsDir->setToolTip( "" );
|
||||
ui.partialsDir->setProperty("WrongValue", false);
|
||||
}
|
||||
}
|
||||
ui.partialsDir->style()->unpolish(ui.partialsDir);
|
||||
ui.partialsDir->style()->polish( ui.partialsDir);
|
||||
whileBlocking(ui.partialsDir)->setText(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()));
|
||||
}
|
||||
|
||||
void TransferPage::toggleAutoCheckDirectories(bool b)
|
||||
{
|
||||
ui.autoCheckDirectoriesDelay_SB->setEnabled(b);
|
||||
|
@ -293,9 +293,16 @@ OpModeStatus[opMode="Minimal"] {
|
||||
background: #700000;
|
||||
}
|
||||
|
||||
/*Property Values at end to overwrite other settings*/
|
||||
|
||||
[new=false] {
|
||||
background: #202020;
|
||||
}
|
||||
[new=true] {
|
||||
background: #005000;
|
||||
}
|
||||
|
||||
[WrongValue=true] {
|
||||
background-color: #702020;
|
||||
}
|
||||
|
||||
|
@ -1126,9 +1126,15 @@ OpModeStatus[opMode="Minimal"] {
|
||||
background: #700000;
|
||||
}
|
||||
|
||||
/*Property Values at end to overwrite other settings*/
|
||||
|
||||
[new=false] {
|
||||
background: #202020;
|
||||
}
|
||||
[new=true] {
|
||||
background: #005000;
|
||||
}
|
||||
|
||||
[WrongValue="true"] {
|
||||
background-color: #702020;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user