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:
Phenom 2018-05-12 14:31:17 +02:00
parent 57cff61873
commit f12cd5774d
9 changed files with 120 additions and 58 deletions

View File

@ -1476,7 +1476,7 @@ bool ftController::setPartialsDirectory(std::string path)
path = RsDirUtil::convertPathToUnix(path);
if (path.find(mDownloadPath) == std::string::npos) {
if (path.find(mDownloadPath) != std::string::npos) {
return false;
}
@ -1485,7 +1485,7 @@ bool ftController::setPartialsDirectory(std::string path)
std::list<SharedDirInfo> dirs;
rsFiles->getSharedDirectories(dirs);
for (it = dirs.begin(); it != dirs.end(); ++it) {
if (path.find((*it).filename) == std::string::npos) {
if (path.find((*it).filename) != std::string::npos) {
return false;
}
}

View File

@ -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()

View File

@ -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();

View File

@ -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;

View File

@ -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;
}

View File

@ -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();
std::string dir = qdir.toUtf8().constData();
if(!dir.empty())
rsFiles->setDownloadDirectory(dir);
{
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);

View File

@ -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;
}

View File

@ -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;
}