mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
commit
ba7cf4995b
@ -86,7 +86,9 @@ public:
|
||||
EXPR_SIZE_MB = 8 } token ;
|
||||
|
||||
static Expression *toExpr(const LinearizedExpression& e) ;
|
||||
|
||||
|
||||
std::string GetStrings();
|
||||
|
||||
private:
|
||||
static Expression *toExpr(const LinearizedExpression& e,int&,int&,int&) ;
|
||||
static void readStringExpr(const LinearizedExpression& e,int& n_ints,int& n_strings,std::list<std::string>& strings,bool& b,StringOperator& op) ;
|
||||
|
@ -59,6 +59,7 @@ struct TurtleRequestDisplayInfo
|
||||
RsPeerId source_peer_id ; // Peer that relayed the request
|
||||
uint32_t age ; // Age in seconds
|
||||
uint32_t depth ; // Depth of the request. Might be altered.
|
||||
std::string keywords;
|
||||
};
|
||||
|
||||
class TurtleTrafficStatisticsInfo
|
||||
|
@ -907,6 +907,7 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item)
|
||||
req.origin = item->PeerId() ;
|
||||
req.time_stamp = time(NULL) ;
|
||||
req.depth = item->depth ;
|
||||
req.keywords = item->GetKeywords() ;
|
||||
|
||||
// If it's not for us, perform a local search. If something found, forward the search result back.
|
||||
|
||||
@ -2101,6 +2102,7 @@ void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
|
||||
info.source_peer_id = it->second.origin ;
|
||||
info.age = now - it->second.time_stamp ;
|
||||
info.depth = it->second.depth ;
|
||||
info.keywords = it->second.keywords ;
|
||||
|
||||
search_reqs_info.push_back(info) ;
|
||||
}
|
||||
|
@ -172,6 +172,7 @@ class TurtleRequestInfo
|
||||
uint32_t time_stamp ; // last time the tunnel was actually used. Used for cleaning old tunnels.
|
||||
int depth ; // depth of the request. Used to optimize tunnel length.
|
||||
std::set<uint32_t> responses; // responses to this request. Useful to avoid spamming tunnel responses.
|
||||
std::string keywords;
|
||||
};
|
||||
|
||||
class TurtleTunnel
|
||||
|
@ -71,7 +71,9 @@ class RsTurtleSearchRequestItem: public RsTurtleItem
|
||||
virtual RsTurtleSearchRequestItem *clone() const = 0 ; // used for cloning in routing methods
|
||||
|
||||
virtual void performLocalSearch(std::list<TurtleFileInfo>&) const = 0 ; // abstracts the search method
|
||||
|
||||
|
||||
virtual std::string GetKeywords() = 0;
|
||||
|
||||
uint32_t request_id ; // randomly generated request id.
|
||||
uint16_t depth ; // Used for limiting search depth.
|
||||
};
|
||||
@ -82,7 +84,9 @@ class RsTurtleStringSearchRequestItem: public RsTurtleSearchRequestItem
|
||||
RsTurtleStringSearchRequestItem() : RsTurtleSearchRequestItem(RS_TURTLE_SUBTYPE_STRING_SEARCH_REQUEST) {}
|
||||
|
||||
std::string match_string ; // string to match
|
||||
|
||||
|
||||
std::string GetKeywords() { return match_string; }
|
||||
|
||||
virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleStringSearchRequestItem(*this) ; }
|
||||
virtual void performLocalSearch(std::list<TurtleFileInfo>&) const ;
|
||||
|
||||
@ -99,6 +103,14 @@ class RsTurtleRegExpSearchRequestItem: public RsTurtleSearchRequestItem
|
||||
|
||||
RsRegularExpression::LinearizedExpression expr ; // Reg Exp in linearised mode
|
||||
|
||||
std::string GetKeywords()
|
||||
{
|
||||
RsRegularExpression::Expression *ex = RsRegularExpression::LinearizedExpression::toExpr(expr);
|
||||
std::string exs = ex->toStdString();
|
||||
delete ex;
|
||||
return exs;
|
||||
}
|
||||
|
||||
virtual RsTurtleSearchRequestItem *clone() const { return new RsTurtleRegExpSearchRequestItem(*this) ; }
|
||||
virtual void performLocalSearch(std::list<TurtleFileInfo>&) const ;
|
||||
|
||||
|
@ -225,6 +225,17 @@ void LinearizedExpression::readStringExpr(const LinearizedExpression& e,int& n_i
|
||||
strings.push_back(e._strings[n_strings++]) ;
|
||||
}
|
||||
|
||||
std::string LinearizedExpression::GetStrings()
|
||||
{
|
||||
std::string str;
|
||||
for (std::vector<std::string>::const_iterator i = this->_strings.begin(); i != this->_strings.end(); ++i)
|
||||
{
|
||||
str += *i;
|
||||
str += " ";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
Expression *LinearizedExpression::toExpr(const LinearizedExpression& e,int& n_tok,int& n_ints,int& n_strings)
|
||||
{
|
||||
LinearizedExpression::token tok = static_cast<LinearizedExpression::token>(e._tokens[n_tok++]) ;
|
||||
|
@ -795,8 +795,7 @@ void SearchDialog::advancedSearch(RsRegularExpression::Expression* expression)
|
||||
TurtleRequestId req_id = rsTurtle->turtleSearch(e) ;
|
||||
|
||||
// This will act before turtle results come to the interface, thanks to the signals scheduling policy.
|
||||
// The text "bool exp" should be replaced by an appropriate text describing the actual search.
|
||||
initSearchResult("bool exp",req_id, ui.FileTypeComboBox->currentIndex(), true) ;
|
||||
initSearchResult(QString::fromStdString(e.GetStrings()),req_id, ui.FileTypeComboBox->currentIndex(), true) ;
|
||||
|
||||
rsFiles -> SearchBoolExp(expression, results, RS_FILE_HINTS_REMOTE);// | DIR_FLAGS_NETWORK_WIDE | DIR_FLAGS_BROWSABLE);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "TurtleRouterDialog.h"
|
||||
#include <QPainter>
|
||||
#include <QStylePainter>
|
||||
#include <algorithm> // for sort
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
@ -70,6 +71,10 @@ void TurtleRouterDialog::processSettings(bool bLoad)
|
||||
|
||||
}
|
||||
|
||||
bool sr_Compare( TurtleRequestDisplayInfo m1, TurtleRequestDisplayInfo m2)
|
||||
{
|
||||
return m1.age < m2.age;
|
||||
}
|
||||
|
||||
void TurtleRouterDialog::updateDisplay()
|
||||
{
|
||||
@ -79,7 +84,9 @@ void TurtleRouterDialog::updateDisplay()
|
||||
std::vector<TurtleRequestDisplayInfo > tunnel_reqs_info ;
|
||||
|
||||
rsTurtle->getInfo(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;
|
||||
|
||||
|
||||
std::sort(search_reqs_info.begin(),search_reqs_info.end(),sr_Compare) ;
|
||||
|
||||
updateTunnelRequests(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;
|
||||
|
||||
}
|
||||
@ -162,8 +169,8 @@ void TurtleRouterDialog::updateTunnelRequests( const std::vector<std::vector<std
|
||||
|
||||
for(uint i=0;i<search_reqs_info.size();++i)
|
||||
{
|
||||
QString str = tr("Request id: %1\t from [%2]\t %3 secs ago").arg(search_reqs_info[i].request_id,0,16).arg(getPeerName(search_reqs_info[i].source_peer_id)).arg(search_reqs_info[i].age);
|
||||
|
||||
QString str = tr("Request id: %1\t %3 secs ago\t from %2\t %4").arg(search_reqs_info[i].request_id,0,16).arg(getPeerName(search_reqs_info[i].source_peer_id), -25).arg(search_reqs_info[i].age).arg(QString::fromUtf8(search_reqs_info[i].keywords.c_str(),search_reqs_info[i].keywords.length()));
|
||||
|
||||
stl.clear() ;
|
||||
stl.push_back(str) ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user