mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-24 13:59:29 -04:00
Merge branch 'master' into android
This commit is contained in:
commit
ea42d822c2
257 changed files with 11438 additions and 22401 deletions
|
@ -1,6 +1,3 @@
|
|||
#ifndef RS_EXPRESSIONS_H
|
||||
#define RS_EXPRESSIONS_H
|
||||
|
||||
/*
|
||||
* rs-core/src/rsiface: rsexpr.h
|
||||
*
|
||||
|
@ -26,38 +23,41 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <stdint.h>
|
||||
#include "retroshare/rstypes.h"
|
||||
|
||||
/******************************************************************************************
|
||||
Enumerations defining the Operators usable in the Boolean search expressions
|
||||
******************************************************************************************/
|
||||
|
||||
|
||||
namespace RsRegularExpression
|
||||
{
|
||||
enum LogicalOperator{
|
||||
AndOp=0, /* exp AND exp */
|
||||
OrOp=1, /* exp OR exp */
|
||||
XorOp=2 /* exp XOR exp */
|
||||
AndOp=0, /* exp AND exp */
|
||||
OrOp=1, /* exp OR exp */
|
||||
XorOp=2 /* exp XOR exp */
|
||||
};
|
||||
|
||||
|
||||
/*Operators for String Queries*/
|
||||
/* Operators for String Queries */
|
||||
enum StringOperator{
|
||||
ContainsAnyStrings = 0, /* e.g. name contains any of 'conference' 'meeting' 'presentation' */
|
||||
ContainsAllStrings = 1, /* same as above except that it contains ALL of the strings */
|
||||
EqualsString = 2 /* exactly equal*/
|
||||
ContainsAnyStrings = 0, /* e.g. name contains any of 'conference' 'meeting' 'presentation' */
|
||||
ContainsAllStrings = 1, /* same as above except that it contains ALL of the strings */
|
||||
EqualsString = 2 /* exactly equal*/
|
||||
};
|
||||
|
||||
/*Relational operators ( >, <, >=, <=, == and InRange )*/
|
||||
/* Comparison operators ( >, <, >=, <=, == and InRange ) */
|
||||
enum RelOperator{
|
||||
Equals = 0,
|
||||
GreaterEquals = 1,
|
||||
Greater = 2,
|
||||
SmallerEquals = 3,
|
||||
Smaller = 4,
|
||||
InRange = 5 /* lower limit <= value <= upper limit*/
|
||||
Equals = 0,
|
||||
GreaterEquals = 1,
|
||||
Greater = 2,
|
||||
SmallerEquals = 3,
|
||||
Smaller = 4,
|
||||
InRange = 5 /* lower limit <= value <= upper limit*/
|
||||
};
|
||||
|
||||
/********************************************************************************************
|
||||
|
@ -69,26 +69,26 @@ class Expression ;
|
|||
|
||||
class LinearizedExpression
|
||||
{
|
||||
public:
|
||||
std::vector<uint8_t> _tokens ;
|
||||
std::vector<uint32_t> _ints ;
|
||||
std::vector<std::string> _strings ;
|
||||
public:
|
||||
std::vector<uint8_t> _tokens ;
|
||||
std::vector<uint32_t> _ints ;
|
||||
std::vector<std::string> _strings ;
|
||||
|
||||
typedef enum { EXPR_DATE= 0,
|
||||
EXPR_POP = 1,
|
||||
EXPR_SIZE= 2,
|
||||
EXPR_HASH= 3,
|
||||
EXPR_NAME= 4,
|
||||
EXPR_PATH= 5,
|
||||
EXPR_EXT = 6,
|
||||
EXPR_COMP= 7,
|
||||
EXPR_SIZE_MB=8 } token ;
|
||||
typedef enum { EXPR_DATE = 0,
|
||||
EXPR_POP = 1,
|
||||
EXPR_SIZE = 2,
|
||||
EXPR_HASH = 3,
|
||||
EXPR_NAME = 4,
|
||||
EXPR_PATH = 5,
|
||||
EXPR_EXT = 6,
|
||||
EXPR_COMP = 7,
|
||||
EXPR_SIZE_MB = 8 } token ;
|
||||
|
||||
static Expression *toExpr(const LinearizedExpression& e) ;
|
||||
static Expression *toExpr(const LinearizedExpression& e) ;
|
||||
|
||||
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) ;
|
||||
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) ;
|
||||
};
|
||||
|
||||
|
||||
|
@ -96,110 +96,122 @@ class LinearizedExpression
|
|||
Boolean Search Expression
|
||||
classes:
|
||||
|
||||
Expression: The base class of all expression typest
|
||||
CompoundExpression: The expression which uses a logical operator to combine
|
||||
the results of two expressions
|
||||
StringExpression: An expression which uses some sort of string comparison.
|
||||
RelExpression: A Relational Expression where > < >= <= == make sense.
|
||||
e.g. size date etc
|
||||
Expression: The base class of all expression typest
|
||||
CompoundExpression: The expression which uses a logical operator to combine
|
||||
the results of two expressions
|
||||
StringExpression: An expression which uses some sort of string comparison.
|
||||
RelExpression: A Relational Expression where > < >= <= == make sense.
|
||||
e.g. size date etc
|
||||
|
||||
******************************************************************************************/
|
||||
|
||||
class FileEntry;
|
||||
/*!
|
||||
* \brief The ExpFileEntry class
|
||||
* This is the base class the regular expressions can operate on. Derive it to fit your own needs!
|
||||
*/
|
||||
class ExpFileEntry
|
||||
{
|
||||
public:
|
||||
virtual const std::string& file_name() const =0;
|
||||
virtual uint64_t file_size() const =0;
|
||||
virtual time_t file_modtime() const =0;
|
||||
virtual uint32_t file_popularity() const =0;
|
||||
virtual std::string file_parent_path() const =0;
|
||||
virtual const RsFileHash& file_hash() const =0;
|
||||
};
|
||||
|
||||
class Expression
|
||||
{
|
||||
public:
|
||||
virtual bool eval (FileEntry *file) = 0;
|
||||
virtual ~Expression() {};
|
||||
public:
|
||||
virtual bool eval (const ExpFileEntry& file) = 0;
|
||||
virtual ~Expression() {};
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const = 0 ;
|
||||
virtual void linearize(LinearizedExpression& e) const = 0 ;
|
||||
};
|
||||
|
||||
|
||||
class CompoundExpression : public Expression
|
||||
{
|
||||
public:
|
||||
CompoundExpression( enum LogicalOperator op, Expression * exp1, Expression *exp2)
|
||||
: Lexp(exp1), Rexp(exp2), Op(op){ }
|
||||
public:
|
||||
CompoundExpression( enum LogicalOperator op, Expression * exp1, Expression *exp2)
|
||||
: Lexp(exp1), Rexp(exp2), Op(op){ }
|
||||
|
||||
bool eval (FileEntry *file) {
|
||||
if (Lexp == NULL or Rexp == NULL) {
|
||||
return false;
|
||||
}
|
||||
switch (Op){
|
||||
case AndOp:
|
||||
return Lexp->eval(file) && Rexp->eval(file);
|
||||
case OrOp:
|
||||
return Lexp->eval(file) || Rexp->eval(file);
|
||||
case XorOp:
|
||||
return Lexp->eval(file) ^ Rexp->eval(file);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
virtual ~CompoundExpression(){
|
||||
delete Lexp;
|
||||
delete Rexp;
|
||||
}
|
||||
bool eval (const ExpFileEntry& file) {
|
||||
if (Lexp == NULL or Rexp == NULL) {
|
||||
return false;
|
||||
}
|
||||
switch (Op){
|
||||
case AndOp:
|
||||
return Lexp->eval(file) && Rexp->eval(file);
|
||||
case OrOp:
|
||||
return Lexp->eval(file) || Rexp->eval(file);
|
||||
case XorOp:
|
||||
return Lexp->eval(file) ^ Rexp->eval(file);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
virtual ~CompoundExpression(){
|
||||
delete Lexp;
|
||||
delete Rexp;
|
||||
}
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
private:
|
||||
Expression *Lexp;
|
||||
Expression *Rexp;
|
||||
enum LogicalOperator Op;
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
private:
|
||||
Expression *Lexp;
|
||||
Expression *Rexp;
|
||||
enum LogicalOperator Op;
|
||||
|
||||
};
|
||||
|
||||
class StringExpression: public Expression
|
||||
{
|
||||
public:
|
||||
StringExpression(enum StringOperator op, std::list<std::string> &t, bool ic): Op(op),terms(t), IgnoreCase(ic){}
|
||||
public:
|
||||
StringExpression(enum StringOperator op, std::list<std::string> &t, bool ic): Op(op),terms(t), IgnoreCase(ic){}
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
protected:
|
||||
bool evalStr(const std::string &str);
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
protected:
|
||||
bool evalStr(const std::string &str);
|
||||
|
||||
enum StringOperator Op;
|
||||
std::list<std::string> terms;
|
||||
bool IgnoreCase;
|
||||
enum StringOperator Op;
|
||||
std::list<std::string> terms;
|
||||
bool IgnoreCase;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class RelExpression: public Expression
|
||||
{
|
||||
public:
|
||||
RelExpression(enum RelOperator op, T lv, T hv): Op(op), LowerValue(lv), HigherValue(hv) {}
|
||||
public:
|
||||
RelExpression(enum RelOperator op, T lv, T hv): Op(op), LowerValue(lv), HigherValue(hv) {}
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
protected:
|
||||
bool evalRel(T val);
|
||||
virtual void linearize(LinearizedExpression& e) const ;
|
||||
protected:
|
||||
bool evalRel(T val);
|
||||
|
||||
enum RelOperator Op;
|
||||
T LowerValue;
|
||||
T HigherValue;
|
||||
enum RelOperator Op;
|
||||
T LowerValue;
|
||||
T HigherValue;
|
||||
};
|
||||
|
||||
template<> void RelExpression<int>::linearize(LinearizedExpression& e) const ;
|
||||
|
||||
template <class T>
|
||||
bool RelExpression<T>::evalRel(T val) {
|
||||
switch (Op) {
|
||||
case Equals:
|
||||
return LowerValue == val;
|
||||
case GreaterEquals:
|
||||
return LowerValue >= val;
|
||||
case Greater:
|
||||
return LowerValue > val;
|
||||
case SmallerEquals:
|
||||
return LowerValue <= val;
|
||||
case Smaller:
|
||||
return LowerValue < val;
|
||||
case InRange:
|
||||
return (LowerValue <= val) && (val <= HigherValue);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
switch (Op) {
|
||||
case Equals:
|
||||
return LowerValue == val;
|
||||
case GreaterEquals:
|
||||
return LowerValue >= val;
|
||||
case Greater:
|
||||
return LowerValue > val;
|
||||
case SmallerEquals:
|
||||
return LowerValue <= val;
|
||||
case Smaller:
|
||||
return LowerValue < val;
|
||||
case InRange:
|
||||
return (LowerValue <= val) && (val <= HigherValue);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -212,12 +224,12 @@ Binary Predicate for Case Insensitive search
|
|||
*Factor locales in the comparison
|
||||
*/
|
||||
struct CompareCharIC :
|
||||
public std::binary_function< char , char , bool> {
|
||||
public std::binary_function< char , char , bool> {
|
||||
|
||||
bool operator () ( char ch1 , char ch2 ) const {
|
||||
return tolower( static_cast < unsigned char > (ch1) )
|
||||
== tolower( static_cast < unsigned char > (ch2) );
|
||||
}
|
||||
bool operator () ( char ch1 , char ch2 ) const {
|
||||
return tolower( static_cast < unsigned char > (ch1) )
|
||||
== tolower( static_cast < unsigned char > (ch2) );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -228,55 +240,55 @@ Some implementations of StringExpressions.
|
|||
|
||||
class NameExpression: public StringExpression
|
||||
{
|
||||
public:
|
||||
NameExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
|
||||
StringExpression(op,t,ic) {}
|
||||
bool eval(FileEntry *file);
|
||||
public:
|
||||
NameExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
|
||||
StringExpression(op,t,ic) {}
|
||||
bool eval(const ExpFileEntry& file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_NAME) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_NAME) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class PathExpression: public StringExpression {
|
||||
public:
|
||||
PathExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
|
||||
StringExpression(op,t,ic) {}
|
||||
bool eval(FileEntry *file);
|
||||
PathExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
|
||||
StringExpression(op,t,ic) {}
|
||||
bool eval(const ExpFileEntry& file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_PATH) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_PATH) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class ExtExpression: public StringExpression {
|
||||
public:
|
||||
ExtExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
|
||||
StringExpression(op,t,ic) {}
|
||||
bool eval(FileEntry *file);
|
||||
ExtExpression(enum StringOperator op, std::list<std::string> &t, bool ic):
|
||||
StringExpression(op,t,ic) {}
|
||||
bool eval(const ExpFileEntry& file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_EXT) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_EXT) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class HashExpression: public StringExpression {
|
||||
public:
|
||||
HashExpression(enum StringOperator op, std::list<std::string> &t):
|
||||
StringExpression(op,t, true) {}
|
||||
bool eval(FileEntry *file);
|
||||
HashExpression(enum StringOperator op, std::list<std::string> &t):
|
||||
StringExpression(op,t, true) {}
|
||||
bool eval(const ExpFileEntry& file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_HASH) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_HASH) ;
|
||||
StringExpression::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************************
|
||||
|
@ -286,62 +298,62 @@ Some implementations of Relational Expressions.
|
|||
|
||||
class DateExpression: public RelExpression<int>
|
||||
{
|
||||
public:
|
||||
DateExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
DateExpression(enum RelOperator op, int lv, int hv):
|
||||
RelExpression<int>(op,lv,hv) {}
|
||||
bool eval(FileEntry *file);
|
||||
public:
|
||||
DateExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
DateExpression(enum RelOperator op, int lv, int hv):
|
||||
RelExpression<int>(op,lv,hv) {}
|
||||
bool eval(const ExpFileEntry& file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_DATE) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_DATE) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class SizeExpression: public RelExpression<int>
|
||||
{
|
||||
public:
|
||||
SizeExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
SizeExpression(enum RelOperator op, int lv, int hv):
|
||||
RelExpression<int>(op,lv,hv) {}
|
||||
bool eval(FileEntry *file);
|
||||
public:
|
||||
SizeExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
SizeExpression(enum RelOperator op, int lv, int hv):
|
||||
RelExpression<int>(op,lv,hv) {}
|
||||
bool eval(const ExpFileEntry& file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_SIZE) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_SIZE) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
};
|
||||
|
||||
class SizeExpressionMB: public RelExpression<int>
|
||||
{
|
||||
public:
|
||||
SizeExpressionMB(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
SizeExpressionMB(enum RelOperator op, int lv, int hv):
|
||||
RelExpression<int>(op,lv,hv) {}
|
||||
bool eval(FileEntry *file);
|
||||
public:
|
||||
SizeExpressionMB(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
SizeExpressionMB(enum RelOperator op, int lv, int hv):
|
||||
RelExpression<int>(op,lv,hv) {}
|
||||
bool eval(const ExpFileEntry& file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_SIZE_MB) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_SIZE_MB) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
};
|
||||
class PopExpression: public RelExpression<int>
|
||||
{
|
||||
public:
|
||||
PopExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
PopExpression(enum RelOperator op, int lv, int hv): RelExpression<int>(op,lv,hv) {}
|
||||
PopExpression(const LinearizedExpression& e) ;
|
||||
bool eval(FileEntry *file);
|
||||
public:
|
||||
PopExpression(enum RelOperator op, int v): RelExpression<int>(op,v,v){}
|
||||
PopExpression(enum RelOperator op, int lv, int hv): RelExpression<int>(op,lv,hv) {}
|
||||
PopExpression(const LinearizedExpression& e) ;
|
||||
bool eval(const ExpFileEntry& file);
|
||||
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_POP) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
virtual void linearize(LinearizedExpression& e) const
|
||||
{
|
||||
e._tokens.push_back(LinearizedExpression::EXPR_POP) ;
|
||||
RelExpression<int>::linearize(e) ;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* RS_EXPRESSIONS_H */
|
||||
|
||||
|
|
|
@ -36,9 +36,7 @@
|
|||
class RsFiles;
|
||||
extern RsFiles *rsFiles;
|
||||
|
||||
class Expression;
|
||||
class CacheStrapper ;
|
||||
class CacheTransfer;
|
||||
namespace RsRegularExpression { class Expression; }
|
||||
|
||||
/* These are used mainly by ftController at the moment */
|
||||
const uint32_t RS_FILE_CTRL_PAUSE = 0x00000100;
|
||||
|
@ -65,26 +63,26 @@ const uint32_t RS_FILE_PEER_OFFLINE = 0x00002000;
|
|||
|
||||
// Flags used when requesting info about transfers, mostly to filter out the result.
|
||||
//
|
||||
const FileSearchFlags RS_FILE_HINTS_CACHE ( 0x00000001 );
|
||||
const FileSearchFlags RS_FILE_HINTS_EXTRA ( 0x00000002 );
|
||||
const FileSearchFlags RS_FILE_HINTS_LOCAL ( 0x00000004 );
|
||||
const FileSearchFlags RS_FILE_HINTS_REMOTE ( 0x00000008 );
|
||||
const FileSearchFlags RS_FILE_HINTS_CACHE_deprecated ( 0x00000001 );
|
||||
const FileSearchFlags RS_FILE_HINTS_EXTRA ( 0x00000002 );
|
||||
const FileSearchFlags RS_FILE_HINTS_LOCAL ( 0x00000004 );
|
||||
const FileSearchFlags RS_FILE_HINTS_REMOTE ( 0x00000008 );
|
||||
const FileSearchFlags RS_FILE_HINTS_DOWNLOAD ( 0x00000010 );
|
||||
const FileSearchFlags RS_FILE_HINTS_UPLOAD ( 0x00000020 );
|
||||
const FileSearchFlags RS_FILE_HINTS_SPEC_ONLY ( 0x01000000 );
|
||||
const FileSearchFlags RS_FILE_HINTS_UPLOAD ( 0x00000020 );
|
||||
const FileSearchFlags RS_FILE_HINTS_SPEC_ONLY ( 0x01000000 );
|
||||
|
||||
const FileSearchFlags RS_FILE_HINTS_NETWORK_WIDE ( 0x00000080 );// anonymously shared over network
|
||||
const FileSearchFlags RS_FILE_HINTS_BROWSABLE ( 0x00000100 );// browsable by friends
|
||||
const FileSearchFlags RS_FILE_HINTS_PERMISSION_MASK ( 0x00000180 );// OR of the last two flags. Used to filter out.
|
||||
const FileSearchFlags RS_FILE_HINTS_NETWORK_WIDE ( 0x00000080 );// anonymously shared over network
|
||||
const FileSearchFlags RS_FILE_HINTS_BROWSABLE ( 0x00000100 );// browsable by friends
|
||||
const FileSearchFlags RS_FILE_HINTS_PERMISSION_MASK ( 0x00000180 );// OR of the last two flags. Used to filter out.
|
||||
|
||||
// Flags used when requesting a transfer
|
||||
//
|
||||
const TransferRequestFlags RS_FILE_REQ_ANONYMOUS_ROUTING ( 0x00000040 ); // Use to ask turtle router to download the file.
|
||||
const TransferRequestFlags RS_FILE_REQ_ASSUME_AVAILABILITY ( 0x00000200 ); // Assume full source availability. Used for cache files.
|
||||
const TransferRequestFlags RS_FILE_REQ_CACHE ( 0x00000400 ); // Assume full source availability. Used for cache files.
|
||||
const TransferRequestFlags RS_FILE_REQ_CACHE_deprecated ( 0x00000400 ); // Assume full source availability. Used for cache files.
|
||||
const TransferRequestFlags RS_FILE_REQ_EXTRA ( 0x00000800 );
|
||||
const TransferRequestFlags RS_FILE_REQ_MEDIA ( 0x00001000 );
|
||||
const TransferRequestFlags RS_FILE_REQ_BACKGROUND ( 0x00002000 ); // To download slowly.
|
||||
const TransferRequestFlags RS_FILE_REQ_BACKGROUND ( 0x00002000 ); // To download slowly.
|
||||
const TransferRequestFlags RS_FILE_REQ_NO_SEARCH ( 0x02000000 ); // disable searching for potential direct sources.
|
||||
|
||||
// const uint32_t RS_FILE_HINTS_SHARE_FLAGS_MASK = RS_FILE_HINTS_NETWORK_WIDE_OTHERS | RS_FILE_HINTS_BROWSABLE_OTHERS
|
||||
|
@ -147,8 +145,6 @@ class RsFiles
|
|||
/***
|
||||
* Control of Downloads Priority.
|
||||
***/
|
||||
virtual uint32_t getMinPrioritizedTransfers() = 0 ;
|
||||
virtual void setMinPrioritizedTransfers(uint32_t s) = 0 ;
|
||||
virtual uint32_t getQueueSize() = 0 ;
|
||||
virtual void setQueueSize(uint32_t s) = 0 ;
|
||||
virtual bool changeQueuePosition(const RsFileHash& hash, QueueMove mv) = 0;
|
||||
|
@ -186,12 +182,13 @@ class RsFiles
|
|||
*/
|
||||
virtual int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details) = 0;
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) = 0;
|
||||
virtual uint32_t getType(void *ref,FileSearchFlags flags) = 0;
|
||||
virtual bool findChildPointer(void *ref, int row, void *& result, FileSearchFlags flags) =0;
|
||||
virtual uint32_t getType(void *ref,FileSearchFlags flags) = 0;
|
||||
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags) = 0;
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0;
|
||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags) = 0;
|
||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0;
|
||||
virtual int SearchBoolExp(RsRegularExpression::Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags) = 0;
|
||||
virtual int SearchBoolExp(RsRegularExpression::Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0;
|
||||
|
||||
/***
|
||||
* Utility Functions.
|
||||
|
@ -205,6 +202,8 @@ class RsFiles
|
|||
/***
|
||||
* Directory Control
|
||||
***/
|
||||
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 std::string getDownloadDirectory() = 0;
|
||||
|
@ -214,16 +213,11 @@ class RsFiles
|
|||
virtual bool addSharedDirectory(const 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 void setRememberHashFilesDuration(uint32_t days) = 0 ;
|
||||
virtual uint32_t rememberHashFilesDuration() const = 0 ;
|
||||
virtual void clearHashCache() = 0 ;
|
||||
virtual bool rememberHashFiles() const =0;
|
||||
virtual void setRememberHashFiles(bool) =0;
|
||||
virtual void setWatchPeriod(int minutes) =0;
|
||||
virtual int watchPeriod() const =0;
|
||||
|
||||
virtual CacheStrapper *getCacheStrapper() =0;
|
||||
virtual CacheTransfer *getCacheTransfer() =0;
|
||||
virtual void setWatchPeriod(int minutes) =0;
|
||||
virtual void setWatchEnabled(bool b) =0;
|
||||
virtual int watchPeriod() const =0;
|
||||
virtual bool watchEnabled() =0;
|
||||
|
||||
virtual bool getShareDownloadDirectory() = 0;
|
||||
virtual bool shareDownloadDirectory(bool share) = 0;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "retroshare/rstypes.h"
|
||||
|
||||
class LinearizedExpression ;
|
||||
namespace RsRegularExpression { class LinearizedExpression ; }
|
||||
class RsTurtleClientService ;
|
||||
|
||||
class RsTurtle;
|
||||
|
@ -102,7 +102,7 @@ class RsTurtle
|
|||
// as they come back.
|
||||
//
|
||||
virtual TurtleRequestId turtleSearch(const std::string& match_string) = 0 ;
|
||||
virtual TurtleRequestId turtleSearch(const LinearizedExpression& expr) = 0 ;
|
||||
virtual TurtleRequestId turtleSearch(const RsRegularExpression::LinearizedExpression& expr) = 0 ;
|
||||
|
||||
// Initiates tunnel handling for the given file hash. tunnels. Launches
|
||||
// an exception if an error occurs during the initialization process. The
|
||||
|
|
|
@ -138,6 +138,7 @@ public:
|
|||
|
||||
/********************** For FileCache Interface *****************/
|
||||
|
||||
#define DIR_TYPE_UNKNOWN 0x00
|
||||
#define DIR_TYPE_ROOT 0x01
|
||||
#define DIR_TYPE_PERSON 0x02
|
||||
#define DIR_TYPE_DIR 0x04
|
||||
|
@ -159,7 +160,7 @@ const FileStorageFlags DIR_FLAGS_BROWSABLE_OTHERS ( 0x0100 ); // one should
|
|||
const FileStorageFlags DIR_FLAGS_NETWORK_WIDE_GROUPS ( 0x0200 );
|
||||
const FileStorageFlags DIR_FLAGS_BROWSABLE_GROUPS ( 0x0400 );
|
||||
const FileStorageFlags DIR_FLAGS_PERMISSIONS_MASK ( DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_OTHERS
|
||||
| DIR_FLAGS_NETWORK_WIDE_GROUPS | DIR_FLAGS_BROWSABLE_GROUPS );
|
||||
| DIR_FLAGS_NETWORK_WIDE_GROUPS | DIR_FLAGS_BROWSABLE_GROUPS );
|
||||
|
||||
const FileStorageFlags DIR_FLAGS_LOCAL ( 0x1000 );
|
||||
const FileStorageFlags DIR_FLAGS_REMOTE ( 0x2000 );
|
||||
|
@ -214,8 +215,7 @@ class FileInfo
|
|||
std::list<RsNodeGroupId> parent_groups ;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const FileInfo& info);
|
||||
|
||||
class DirStub
|
||||
{
|
||||
|
@ -227,25 +227,27 @@ class DirStub
|
|||
|
||||
class DirDetails
|
||||
{
|
||||
public:
|
||||
void *parent;
|
||||
int prow; /* parent row */
|
||||
public:
|
||||
void *parent;
|
||||
int prow; /* parent row */
|
||||
|
||||
void *ref;
|
||||
uint8_t type;
|
||||
void *ref;
|
||||
uint8_t type;
|
||||
RsPeerId id;
|
||||
std::string name;
|
||||
std::string name;
|
||||
RsFileHash hash;
|
||||
std::string path;
|
||||
std::string path; // full path of the parent directory, when it is a file; full path of the dir otherwise.
|
||||
uint64_t count;
|
||||
uint32_t age;
|
||||
FileStorageFlags flags;
|
||||
uint32_t min_age ; // minimum age of files in this subtree
|
||||
|
||||
std::list<DirStub> children;
|
||||
std::vector<DirStub> children;
|
||||
std::list<RsNodeGroupId> parent_groups; // parent groups for the shared directory
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const DirDetails& details);
|
||||
|
||||
class FileDetail
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue