mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-11 14:56:09 -05:00
commit
e2d9238ded
3 changed files with 97 additions and 40 deletions
|
|
@ -122,9 +122,9 @@ RsRegularExpression::Expression* ExpressionWidget::getRsExpression()
|
||||||
highVal = exprParamElem->getIntHighValue();
|
highVal = exprParamElem->getIntHighValue();
|
||||||
if (lowVal >highVal)
|
if (lowVal >highVal)
|
||||||
{
|
{
|
||||||
lowVal = lowVal^highVal; // csoler: wow, that is some style!
|
auto tmp=lowVal;
|
||||||
highVal = lowVal^highVal;
|
lowVal = highVal;
|
||||||
lowVal = lowVal^highVal;
|
highVal = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,10 +150,32 @@ RsRegularExpression::Expression* ExpressionWidget::getRsExpression()
|
||||||
wordList);
|
wordList);
|
||||||
break;
|
break;
|
||||||
case DateSearch:
|
case DateSearch:
|
||||||
if (inRangedConfig) {
|
switch(exprCondElem->getRelOperator()) // we need to convert expressions so that the delta is 1 day (i.e. 86400 secs)
|
||||||
expr = new RsRegularExpression::DateExpression(exprCondElem->getRelOperator(), checkedConversion(lowVal), checkedConversion(highVal));
|
{
|
||||||
} else {
|
// The conditions below account for 3 things:
|
||||||
expr = new RsRegularExpression::DateExpression(exprCondElem->getRelOperator(), checkedConversion(exprParamElem->getIntValue()));
|
// - the swap between variables in rsexpr.h:214
|
||||||
|
// - the swap of variables when calling getRelOperator() (See guiexprelement.cpp:166)
|
||||||
|
// - the fact that some comparisions in the unit of days may add 86400 seconds.
|
||||||
|
|
||||||
|
default:
|
||||||
|
case RsRegularExpression::Equals:
|
||||||
|
expr = new RsRegularExpression::DateExpression(RsRegularExpression::InRange, checkedConversion(exprParamElem->getIntValue()), checkedConversion(86400+exprParamElem->getIntValue()));
|
||||||
|
break;
|
||||||
|
case RsRegularExpression::InRange:
|
||||||
|
expr = new RsRegularExpression::DateExpression(RsRegularExpression::InRange, checkedConversion(lowVal), 86400+checkedConversion(highVal));
|
||||||
|
break;
|
||||||
|
case RsRegularExpression::Greater: // means we expect file.date() < some day D. So file.date() < D, meaning Exp=Greater
|
||||||
|
expr = new RsRegularExpression::DateExpression(RsRegularExpression::Greater,checkedConversion(exprParamElem->getIntValue()));
|
||||||
|
break;
|
||||||
|
case RsRegularExpression::SmallerEquals: // means we expect file.date() >= some day D. So file.date() >= D, meaning Exp=SmallerEquals
|
||||||
|
expr = new RsRegularExpression::DateExpression(RsRegularExpression::SmallerEquals,checkedConversion(exprParamElem->getIntValue()));
|
||||||
|
break;
|
||||||
|
case RsRegularExpression::Smaller: // means we expect file.date() > some day D. So file.date() >= D+86400, meaning Exp=SmallerEquals
|
||||||
|
expr = new RsRegularExpression::DateExpression(RsRegularExpression::SmallerEquals, checkedConversion(86400+exprParamElem->getIntValue()-1));
|
||||||
|
break;
|
||||||
|
case RsRegularExpression::GreaterEquals: // means we expect file.date() <= some day D. So file.date() < D+86400, meaning Exp=Greater
|
||||||
|
expr = new RsRegularExpression::DateExpression(RsRegularExpression::Greater, checkedConversion(86400+exprParamElem->getIntValue()));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PopSearch:
|
case PopSearch:
|
||||||
|
|
@ -174,11 +196,33 @@ RsRegularExpression::Expression* ExpressionWidget::getRsExpression()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint64_t s = exprParamElem->getIntValue() ;
|
uint64_t s = exprParamElem->getIntValue() ;
|
||||||
|
auto cond = exprCondElem->getRelOperator();
|
||||||
|
bool MB = false;
|
||||||
|
|
||||||
if(s >= (uint64_t)(1024*1024*1024))
|
if(s >= (uint64_t)(1024*1024*1024))
|
||||||
expr = new RsRegularExpression::SizeExpressionMB(exprCondElem->getRelOperator(), (int)(s/(1024*1024))) ;
|
{
|
||||||
|
MB=true;
|
||||||
|
s >>= 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific case for Equal operator, which we convert to a range, so as to avoid matching arbitrary digits
|
||||||
|
|
||||||
|
if(cond == RsRegularExpression::Equals)
|
||||||
|
{
|
||||||
|
// Now compute a proper interval. There is no optimal solution, so we aim for the simplest: add/remove 20% of the initial value.
|
||||||
|
|
||||||
|
if(MB)
|
||||||
|
expr = new RsRegularExpression::SizeExpressionMB(RsRegularExpression::InRange, (int)(s*0.8) , (int)(s*1.2));
|
||||||
else
|
else
|
||||||
expr = new RsRegularExpression::SizeExpression(exprCondElem->getRelOperator(), (int)s) ;
|
expr = new RsRegularExpression::SizeExpression(RsRegularExpression::InRange, (int)(s*0.8) , (int)(s*1.2));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(MB)
|
||||||
|
expr = new RsRegularExpression::SizeExpressionMB(cond, (int)s);
|
||||||
|
else
|
||||||
|
expr = new RsRegularExpression::SizeExpression(cond, (int)s) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -155,18 +155,19 @@ void GuiExprElement::initialiseOptionsLists()
|
||||||
|
|
||||||
/* W A R N I N G !!!!
|
/* W A R N I N G !!!!
|
||||||
the cb elements correspond to their inverse rel op counterparts in rsexpr.h due to the nature of
|
the cb elements correspond to their inverse rel op counterparts in rsexpr.h due to the nature of
|
||||||
the implementation.there
|
the implementation.
|
||||||
For example consider "size greater than 100kb" selected in the GUI.
|
For example consider "size greater than 100kb" selected in the GUI.
|
||||||
The rsexpr.cc impl returns true if the CONDITION specified is greater than the file size passed as argument
|
The rsexpr.cc impl returns true if the CONDITION specified is greater than the file size passed as argument
|
||||||
as rsexpr iterates through the files. So, the user wants files that are greater than 100kb but the impl returns
|
as rsexpr iterates through the files. So, the user wants files that are greater than 100kb but the impl returns
|
||||||
files where the condition is greater than the file size i.e. files whose size is less than or equal to the condition
|
files where the condition is greater than the file size i.e. files whose size is less than to the condition
|
||||||
Therefore we invert the mapping of rel conditions here to match the behaviour of the impl.
|
Therefore we invert the mapping of rel conditions here to match the behaviour of the impl.
|
||||||
|
Also the Equal nature of comparisons should be kept, since = is symmetric.
|
||||||
*/
|
*/
|
||||||
GuiExprElement::relConditionIndexMap[GuiExprElement::LT_INDEX] = RsRegularExpression::GreaterEquals;
|
GuiExprElement::relConditionIndexMap[GuiExprElement::LT_INDEX] = RsRegularExpression::Greater;
|
||||||
GuiExprElement::relConditionIndexMap[GuiExprElement::LTE_INDEX] = RsRegularExpression::Greater;
|
GuiExprElement::relConditionIndexMap[GuiExprElement::LTE_INDEX] = RsRegularExpression::GreaterEquals;
|
||||||
GuiExprElement::relConditionIndexMap[GuiExprElement::EQUAL_INDEX] = RsRegularExpression::Equals;
|
GuiExprElement::relConditionIndexMap[GuiExprElement::EQUAL_INDEX] = RsRegularExpression::Equals;
|
||||||
GuiExprElement::relConditionIndexMap[GuiExprElement::GTE_INDEX] = RsRegularExpression::Smaller;
|
GuiExprElement::relConditionIndexMap[GuiExprElement::GTE_INDEX] = RsRegularExpression::SmallerEquals;
|
||||||
GuiExprElement::relConditionIndexMap[GuiExprElement::GT_INDEX] = RsRegularExpression::SmallerEquals;
|
GuiExprElement::relConditionIndexMap[GuiExprElement::GT_INDEX] = RsRegularExpression::Smaller;
|
||||||
GuiExprElement::relConditionIndexMap[GuiExprElement::RANGE_INDEX] = RsRegularExpression::InRange;
|
GuiExprElement::relConditionIndexMap[GuiExprElement::RANGE_INDEX] = RsRegularExpression::InRange;
|
||||||
|
|
||||||
// the string to index map
|
// the string to index map
|
||||||
|
|
|
||||||
|
|
@ -947,23 +947,35 @@ bool Rshare::loadCertificate(const RsPeerId &accountId, bool autoLogin)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string lockFile;
|
std::string lockFile;
|
||||||
int retVal = RsInit::LockAndLoadCertificates(autoLogin, lockFile);
|
RsInit::LoadCertificateStatus retVal = RsInit::LockAndLoadCertificates(autoLogin, lockFile);
|
||||||
switch (retVal) {
|
|
||||||
case 0: break;
|
switch (retVal)
|
||||||
case 1: QMessageBox::warning( 0,
|
{
|
||||||
|
case RsInit::OK:
|
||||||
|
break;
|
||||||
|
case RsInit::ERR_ALREADY_RUNNING: QMessageBox::warning( nullptr,
|
||||||
QObject::tr("Multiple instances"),
|
QObject::tr("Multiple instances"),
|
||||||
QObject::tr("Another RetroShare using the same profile is "
|
QObject::tr("Another RetroShare using the same profile is "
|
||||||
"already running on your system. Please close "
|
"already running on your system. Please close "
|
||||||
"that instance first\n Lock file:\n") +
|
"that instance first\n Lock file:\n") +
|
||||||
QString::fromUtf8(lockFile.c_str()));
|
QString::fromUtf8(lockFile.c_str()));
|
||||||
return false;
|
return false;
|
||||||
case 2: QMessageBox::critical( 0,
|
case RsInit::ERR_CANT_ACQUIRE_LOCK: QMessageBox::critical( nullptr,
|
||||||
QObject::tr("Multiple instances"),
|
QObject::tr("Multiple instances"),
|
||||||
QObject::tr("An unexpected error occurred when Retroshare "
|
QObject::tr("An unexpected error occurred when Retroshare "
|
||||||
"tried to acquire the single instance lock\n Lock file:\n") +
|
"tried to acquire the single instance lock\n Lock file:\n") +
|
||||||
QString::fromUtf8(lockFile.c_str()));
|
QString::fromUtf8(lockFile.c_str()));
|
||||||
return false;
|
return false;
|
||||||
case 3:
|
case RsInit::ERR_CERT_CRYPTO_IS_TOO_WEAK: QMessageBox::critical( nullptr,
|
||||||
|
QObject::tr("Old certificate"),
|
||||||
|
QObject::tr("This node uses old certificate settings that are considered too "
|
||||||
|
"weak by your current OpenSSL library version. You need to create a new node "
|
||||||
|
"possibly using the same profile."));
|
||||||
|
return false;
|
||||||
|
case RsInit::ERR_CANNOT_CONFIGURE_TOR: QMessageBox::critical( nullptr,
|
||||||
|
QObject::tr("Tor error"),
|
||||||
|
QObject::tr("Cannot run/configure Tor. Make sure it is installed on your system."));
|
||||||
|
return false;
|
||||||
// case 3: QMessageBox::critical( 0,
|
// case 3: QMessageBox::critical( 0,
|
||||||
// QObject::tr("Login Failure"),
|
// QObject::tr("Login Failure"),
|
||||||
// QObject::tr("Maybe password is wrong") );
|
// QObject::tr("Maybe password is wrong") );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue