mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
Expose /rsFiles/requestDirDetails via JSON API
This method is useful to browse own shared directries, or directries shared by friends whith browseable permission
This commit is contained in:
parent
2139090f5d
commit
c05c376351
@ -1083,16 +1083,6 @@ int p3FileDatabase::RequestDirDetails(void *ref, DirDetails& d, FileSearchFlags
|
||||
return true;
|
||||
}
|
||||
|
||||
int p3FileDatabase::RequestDirDetails(const RsPeerId &/*uid*/, const std::string &/*path*/, DirDetails &/*details*/) const
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
//int p3FileDatabase::RequestDirDetails(const std::string& path, DirDetails &details) const
|
||||
//{
|
||||
// NOT_IMPLEMENTED();
|
||||
// return 0;
|
||||
//}
|
||||
uint32_t p3FileDatabase::getType(void *ref) const
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
|
@ -698,11 +698,6 @@ bool ftServer::ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t
|
||||
/******************** Directory Listing ************************/
|
||||
/***************************************************************/
|
||||
|
||||
int ftServer::RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details)
|
||||
{
|
||||
return mFileDatabase->RequestDirDetails(uid, path, details);
|
||||
}
|
||||
|
||||
bool ftServer::findChildPointer(void *ref, int row, void *& result, FileSearchFlags flags)
|
||||
{
|
||||
return mFileDatabase->findChildPointer(ref,row,result,flags) ;
|
||||
@ -711,6 +706,12 @@ int ftServer::RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags
|
||||
{
|
||||
return mFileDatabase->RequestDirDetails(ref,details,flags) ;
|
||||
}
|
||||
|
||||
bool ftServer::requestDirDetails( DirDetails& details, std::uintptr_t handle,
|
||||
FileSearchFlags flags )
|
||||
{
|
||||
return RequestDirDetails(reinterpret_cast<void*>(handle), details, flags);
|
||||
}
|
||||
uint32_t ftServer::getType(void *ref, FileSearchFlags /* flags */)
|
||||
{
|
||||
return mFileDatabase->getType(ref) ;
|
||||
|
@ -189,8 +189,13 @@ public:
|
||||
/***
|
||||
* Directory Listing / Search Interface
|
||||
***/
|
||||
virtual int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details);
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags);
|
||||
|
||||
/// @see RsFiles::RequestDirDetails
|
||||
virtual bool requestDirDetails(
|
||||
DirDetails &details, std::uintptr_t handle = 0,
|
||||
FileSearchFlags flags = RS_FILE_HINTS_LOCAL );
|
||||
|
||||
virtual bool findChildPointer(void *ref, int row, void *& result, FileSearchFlags flags) ;
|
||||
virtual uint32_t getType(void *ref,FileSearchFlags flags) ;
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
|
||||
#include "rstypes.h"
|
||||
#include "serialiser/rsserializable.h"
|
||||
@ -423,13 +424,32 @@ public:
|
||||
virtual bool ExtraFileStatus(std::string localpath, FileInfo &info) = 0;
|
||||
virtual bool ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Request directory details, subsequent multiple call may be used to
|
||||
* explore a whole directory tree.
|
||||
* @jsonapi{development}
|
||||
* @param[out] details Storage for directory details
|
||||
* @param[in] handle element handle 0 for root, pass the content of
|
||||
* DirDetails::child[x].ref after first call to explore deeper, be aware
|
||||
* that is not a real pointer but an index used internally by RetroShare.
|
||||
* @param[in] flags file search flags RS_FILE_HINTS_*
|
||||
* @return false if error occurred, true otherwise
|
||||
*/
|
||||
virtual bool requestDirDetails(
|
||||
DirDetails &details, std::uintptr_t handle = 0,
|
||||
FileSearchFlags flags = RS_FILE_HINTS_LOCAL ) = 0;
|
||||
|
||||
/***
|
||||
* Directory Listing / Search Interface
|
||||
*/
|
||||
virtual int RequestDirDetails(const RsPeerId& uid, const std::string& path, DirDetails &details) = 0;
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, FileSearchFlags flags) = 0;
|
||||
/**
|
||||
* Kept for retrocompatibility, it was originally written for easier
|
||||
* interaction with Qt. As soon as you can, you should prefer to use the
|
||||
* version of this methodn which take `std::uintptr_t handle` as paramether.
|
||||
*/
|
||||
virtual int RequestDirDetails(
|
||||
void* handle, DirDetails& details, FileSearchFlags flags ) = 0;
|
||||
|
||||
virtual bool findChildPointer(void *ref, int row, void *& result, FileSearchFlags flags) =0;
|
||||
virtual uint32_t getType(void *ref,FileSearchFlags flags) = 0;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
template<int n> class t_RsFlags32
|
||||
{
|
||||
public:
|
||||
inline t_RsFlags32() { _bits=0; }
|
||||
inline t_RsFlags32() : _bits(0) {}
|
||||
inline explicit t_RsFlags32(uint32_t N) : _bits(N) {} // allows initialization from a set of uint32_t
|
||||
|
||||
inline t_RsFlags32<n> operator| (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits | f._bits) ; }
|
||||
|
@ -257,17 +257,39 @@ struct FileInfo : RsSerializable
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const FileInfo& info);
|
||||
|
||||
class DirStub
|
||||
/**
|
||||
* Pointers in this class have no real meaning as pointers, they are used as
|
||||
* indexes, internally by retroshare.
|
||||
*/
|
||||
struct DirStub : RsSerializable
|
||||
{
|
||||
public:
|
||||
DirStub() : type(DIR_TYPE_UNKNOWN), ref(nullptr) {}
|
||||
|
||||
uint8_t type;
|
||||
std::string name;
|
||||
void *ref;
|
||||
|
||||
/// @see RsSerializable
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RS_SERIAL_PROCESS(type);
|
||||
RS_SERIAL_PROCESS(name);
|
||||
std::uintptr_t& handle(reinterpret_cast<std::uintptr_t&>(ref));
|
||||
RS_SERIAL_PROCESS(handle);
|
||||
}
|
||||
};
|
||||
|
||||
class DirDetails
|
||||
/**
|
||||
* Pointers in this class have no real meaning as pointers, they are used as
|
||||
* indexes, internally by retroshare.
|
||||
*/
|
||||
struct DirDetails : RsSerializable
|
||||
{
|
||||
public:
|
||||
DirDetails() : parent(nullptr), prow(0), ref(nullptr),
|
||||
type(DIR_TYPE_UNKNOWN), count(0), mtime(0), max_mtime(0) {}
|
||||
|
||||
|
||||
void* parent;
|
||||
int prow; /* parent row */
|
||||
|
||||
@ -284,6 +306,28 @@ public:
|
||||
|
||||
std::vector<DirStub> children;
|
||||
std::list<RsNodeGroupId> parent_groups; // parent groups for the shared directory
|
||||
|
||||
/// @see RsSerializable
|
||||
void serial_process(RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
std::uintptr_t& parentHandle(reinterpret_cast<std::uintptr_t&>(parent));
|
||||
RS_SERIAL_PROCESS(parentHandle);
|
||||
RS_SERIAL_PROCESS(prow);
|
||||
std::uintptr_t& handle(reinterpret_cast<std::uintptr_t&>(ref));
|
||||
RS_SERIAL_PROCESS(handle);
|
||||
RS_SERIAL_PROCESS(type);
|
||||
RS_SERIAL_PROCESS(id);
|
||||
RS_SERIAL_PROCESS(name);
|
||||
RS_SERIAL_PROCESS(hash);
|
||||
RS_SERIAL_PROCESS(path);
|
||||
RS_SERIAL_PROCESS(count);
|
||||
RS_SERIAL_PROCESS(mtime);
|
||||
RS_SERIAL_PROCESS(flags);
|
||||
RS_SERIAL_PROCESS(max_mtime);
|
||||
RS_SERIAL_PROCESS(children);
|
||||
RS_SERIAL_PROCESS(parent_groups);
|
||||
}
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const DirDetails& details);
|
||||
|
Loading…
Reference in New Issue
Block a user