mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-03 11:54:30 -04:00
Merged branch that provide group-based file permissions.
Now users can sort peers into groups in the friend list, and attribute flags and parent groups to the directories in the share manager. Flags are B-B-N, meaning in order: - browsable for peers in the parent groups - browsable for everyone - network wide for everyone Backward compatibility makes previously BN flags been interpreted as -BN, meaning browsable/network wide for everyone. Be careful with this new feature. It has been tested, but it's a bit early to rely on it for highly sensitive data. The merge also includes a significant improvement of the naming of flags with incompatible types which should sort out some existing bugs as well, since inconsistencies in flag usage have been found during the process. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5787 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
6edb9eb4f8
64 changed files with 1389 additions and 824 deletions
|
@ -63,23 +63,32 @@ const uint32_t RS_FILE_PEER_OFFLINE = 0x00002000;
|
|||
*
|
||||
*/
|
||||
|
||||
const uint32_t RS_FILE_HINTS_MASK = 0x00ffffff;
|
||||
// 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_DOWNLOAD ( 0x00000010 );
|
||||
const FileSearchFlags RS_FILE_HINTS_UPLOAD ( 0x00000020 );
|
||||
const FileSearchFlags RS_FILE_HINTS_SPEC_ONLY ( 0x01000000 );
|
||||
|
||||
const uint32_t RS_FILE_HINTS_CACHE = 0x00000001;
|
||||
const uint32_t RS_FILE_HINTS_EXTRA = 0x00000002;
|
||||
const uint32_t RS_FILE_HINTS_LOCAL = 0x00000004;
|
||||
const uint32_t RS_FILE_HINTS_REMOTE = 0x00000008;
|
||||
const uint32_t RS_FILE_HINTS_DOWNLOAD = 0x00000010;
|
||||
const uint32_t RS_FILE_HINTS_UPLOAD = 0x00000020;
|
||||
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 uint32_t RS_FILE_HINTS_NETWORK_WIDE = 0x00000080; // anonymously shared over network
|
||||
const uint32_t RS_FILE_HINTS_BROWSABLE = 0x00000100; // browsable by friends
|
||||
const uint32_t RS_FILE_HINTS_ASSUME_AVAILABILITY = 0x00000200; // Assume full source availability. Used for cache files.
|
||||
const uint32_t RS_FILE_HINTS_MEDIA = 0x00001000;
|
||||
const uint32_t RS_FILE_HINTS_BACKGROUND = 0x00002000; // To download slowly.
|
||||
// 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_EXTRA ( 0x00000800 );
|
||||
const TransferRequestFlags RS_FILE_REQ_MEDIA ( 0x00001000 );
|
||||
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_SPEC_ONLY = 0x01000000;
|
||||
const uint32_t RS_FILE_HINTS_NO_SEARCH = 0x02000000;
|
||||
// const uint32_t RS_FILE_HINTS_SHARE_FLAGS_MASK = RS_FILE_HINTS_NETWORK_WIDE_OTHERS | RS_FILE_HINTS_BROWSABLE_OTHERS
|
||||
// | RS_FILE_HINTS_NETWORK_WIDE_GROUPS | RS_FILE_HINTS_BROWSABLE_GROUPS ;
|
||||
|
||||
/* Callback Codes */
|
||||
|
||||
|
@ -89,7 +98,8 @@ struct SharedDirInfo
|
|||
{
|
||||
std::string filename ;
|
||||
std::string virtualname ;
|
||||
uint32_t shareflags ; // RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE
|
||||
FileStorageFlags shareflags ; // DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | ...
|
||||
std::list<std::string> parent_groups ;
|
||||
};
|
||||
|
||||
class RsFiles
|
||||
|
@ -109,7 +119,7 @@ class RsFiles
|
|||
|
||||
virtual bool alreadyHaveFile(const std::string& hash, FileInfo &info) = 0;
|
||||
/// Returns false is we already have the file. Otherwise, initiates the dl and returns true.
|
||||
virtual bool FileRequest(const std::string& fname, const std::string& hash, uint64_t size, const std::string& dest, uint32_t flags, const std::list<std::string>& srcIds) = 0;
|
||||
virtual bool FileRequest(const std::string& fname, const std::string& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<std::string>& srcIds) = 0;
|
||||
virtual bool FileCancel(const std::string& hash) = 0;
|
||||
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy) = 0;
|
||||
virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) = 0;
|
||||
|
@ -137,7 +147,7 @@ class RsFiles
|
|||
***/
|
||||
virtual bool FileDownloads(std::list<std::string> &hashs) = 0;
|
||||
virtual bool FileUploads(std::list<std::string> &hashs) = 0;
|
||||
virtual bool FileDetails(const std::string &hash, uint32_t hintflags, FileInfo &info) = 0;
|
||||
virtual bool FileDetails(const std::string &hash, FileSearchFlags hintflags, FileInfo &info) = 0;
|
||||
|
||||
/// Gives chunk details about the downloaded file with given hash.
|
||||
virtual bool FileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info) = 0 ;
|
||||
|
@ -148,11 +158,9 @@ class RsFiles
|
|||
/***
|
||||
* Extra List Access
|
||||
***/
|
||||
virtual bool ExtraFileAdd(std::string fname, std::string hash, uint64_t size,
|
||||
uint32_t period, uint32_t flags) = 0;
|
||||
virtual bool ExtraFileRemove(std::string hash, uint32_t flags) = 0;
|
||||
virtual bool ExtraFileHash(std::string localpath,
|
||||
uint32_t period, uint32_t flags) = 0;
|
||||
virtual bool ExtraFileAdd(std::string fname, std::string hash, uint64_t size, uint32_t period, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileRemove(std::string hash, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileHash(std::string localpath, uint32_t period, TransferRequestFlags flags) = 0;
|
||||
virtual bool ExtraFileStatus(std::string localpath, FileInfo &info) = 0;
|
||||
virtual bool ExtraFileMove(std::string fname, std::string hash, uint64_t size,
|
||||
std::string destpath) = 0;
|
||||
|
@ -163,12 +171,13 @@ class RsFiles
|
|||
* Directory Listing / Search Interface
|
||||
*/
|
||||
virtual int RequestDirDetails(const std::string& 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 int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) = 0;
|
||||
virtual uint32_t getType(void *ref,uint32_t flags) = 0;
|
||||
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags) = 0;
|
||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t 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 std::string& 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 std::string& peer_id) = 0;
|
||||
|
||||
/***
|
||||
* Utility Functions.
|
||||
|
|
64
libretroshare/src/retroshare/rsflags.h
Normal file
64
libretroshare/src/retroshare/rsflags.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// This class provides a representation for flags that can be combined with bitwise
|
||||
// operations. However, because the class is templated with an id, it's not possible to
|
||||
// mixup flags belonging to different classes. This avoids many bugs due to confusion of flags types
|
||||
// that occur when all flags are uint32_t values.
|
||||
//
|
||||
// To use this class, define an ID that is different than other flags classes, and do a typedef:
|
||||
//
|
||||
// #define TRANSFER_INFO_FLAGS_TAG 0x8133ea
|
||||
// typedef t_RsFlags32<TRANSFER_INFO_FLAGS_TAG> TransferInfoFlags ;
|
||||
//
|
||||
// Implementation details:
|
||||
// - we cannot have at the same time a implicit contructor from uint32_t and a bool operator, otherwise c++
|
||||
// mixes up operators and transforms flags into booleans before combining them further.
|
||||
//
|
||||
// So I decided to have:
|
||||
// - an explicit constructor from uint32_t
|
||||
// - an implicit bool operator, that allows test like if(flags & FLAGS_VALUE)
|
||||
//
|
||||
template<int n> class t_RsFlags32
|
||||
{
|
||||
public:
|
||||
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) ; }
|
||||
inline t_RsFlags32<n> operator^ (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits ^ f._bits) ; }
|
||||
|
||||
inline bool operator!=(const t_RsFlags32<n>& f) const { return _bits != f._bits ; }
|
||||
inline bool operator& (const t_RsFlags32<n>& f) const { return (_bits & f._bits)>0 ; }
|
||||
|
||||
inline t_RsFlags32<n> operator|=(const t_RsFlags32<n>& f) { _bits |= f._bits ; return *this ;}
|
||||
inline t_RsFlags32<n> operator^=(const t_RsFlags32<n>& f) { _bits ^= f._bits ; return *this ;}
|
||||
inline t_RsFlags32<n> operator&=(const t_RsFlags32<n>& f) { _bits &= f._bits ; return *this ;}
|
||||
|
||||
inline t_RsFlags32<n> operator~() const { return t_RsFlags32<n>(~_bits) ; }
|
||||
|
||||
//inline explicit operator bool() const { return _bits>0; }
|
||||
inline uint32_t toUInt32() const { return _bits ; }
|
||||
|
||||
void clear() { _bits = 0 ; }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& o,const t_RsFlags32<n>& f) // friendly print with 0 and I
|
||||
{
|
||||
for(int i=31;i>=0;--i) { o << ( (f._bits&(1<<i))?"I":"0") ; if(i%8==0) o << " " ; }
|
||||
return o ;
|
||||
}
|
||||
private:
|
||||
uint32_t _bits ;
|
||||
};
|
||||
|
||||
#define FLAGS_TAG_FILE_SEARCH 0xf29ba5
|
||||
#define FLAGS_TAG_PERMISSION 0x8133ea
|
||||
#define FLAGS_TAG_TRANSFER_REQS 0x4228af
|
||||
#define FLAGS_TAG_FILE_STORAGE 0x184738
|
||||
|
||||
typedef t_RsFlags32<FLAGS_TAG_PERMISSION> FilePermissionFlags ;
|
||||
typedef t_RsFlags32<FLAGS_TAG_TRANSFER_REQS> TransferRequestFlags ;
|
||||
typedef t_RsFlags32<FLAGS_TAG_FILE_STORAGE > FileStorageFlags ; // this makes it a uint32_t class incompatible with other flag class
|
||||
typedef t_RsFlags32<FLAGS_TAG_FILE_SEARCH > FileSearchFlags ; // this makes it a uint32_t class incompatible with other flag class
|
||||
|
|
@ -30,6 +30,9 @@
|
|||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
/* The Main Interface Class - for information about your Peers
|
||||
* A peer is another RS instance, means associated with an SSL certificate
|
||||
* A same GPG person can have multiple peer running with different SSL certs signed by the same GPG key
|
||||
|
@ -210,88 +213,101 @@ class RsPeers
|
|||
{
|
||||
public:
|
||||
|
||||
RsPeers() { return; }
|
||||
virtual ~RsPeers() { return; }
|
||||
RsPeers() { return; }
|
||||
virtual ~RsPeers() { return; }
|
||||
|
||||
/* Updates ... */
|
||||
virtual bool FriendsChanged() = 0;
|
||||
virtual bool OthersChanged() = 0;
|
||||
/* Updates ... */
|
||||
virtual bool FriendsChanged() = 0;
|
||||
virtual bool OthersChanged() = 0;
|
||||
|
||||
/* Peer Details (Net & Auth) */
|
||||
virtual std::string getOwnId() = 0;
|
||||
/* Peer Details (Net & Auth) */
|
||||
virtual std::string getOwnId() = 0;
|
||||
|
||||
virtual bool getOnlineList(std::list<std::string> &ssl_ids) = 0;
|
||||
virtual bool getFriendList(std::list<std::string> &ssl_ids) = 0;
|
||||
//virtual bool getOthersList(std::list<std::string> &ssl_ids) = 0;
|
||||
virtual bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount, bool ssl) = 0;
|
||||
virtual bool getOnlineList(std::list<std::string> &ssl_ids) = 0;
|
||||
virtual bool getFriendList(std::list<std::string> &ssl_ids) = 0;
|
||||
//virtual bool getOthersList(std::list<std::string> &ssl_ids) = 0;
|
||||
virtual bool getPeerCount (unsigned int *pnFriendCount, unsigned int *pnnOnlineCount, bool ssl) = 0;
|
||||
|
||||
virtual bool isOnline(const std::string &ssl_id) = 0;
|
||||
virtual bool isFriend(const std::string &ssl_id) = 0;
|
||||
virtual bool isGPGAccepted(const std::string &gpg_id_is_friend) = 0; //
|
||||
virtual std::string getPeerName(const std::string &ssl_or_gpg_id) = 0;
|
||||
virtual std::string getGPGName(const std::string &gpg_id) = 0;
|
||||
virtual bool getPeerDetails(const std::string &ssl_or_gpg_id, RsPeerDetails &d) = 0; //get Peer detail accept SSL and PGP certs
|
||||
virtual bool isOnline(const std::string &ssl_id) = 0;
|
||||
virtual bool isFriend(const std::string &ssl_id) = 0;
|
||||
virtual bool isGPGAccepted(const std::string &gpg_id_is_friend) = 0; //
|
||||
virtual std::string getPeerName(const std::string &ssl_or_gpg_id) = 0;
|
||||
virtual std::string getGPGName(const std::string &gpg_id) = 0;
|
||||
virtual bool getPeerDetails(const std::string &ssl_or_gpg_id, RsPeerDetails &d) = 0; //get Peer detail accept SSL and PGP certs
|
||||
|
||||
/* Using PGP Ids */
|
||||
virtual std::string getGPGOwnId() = 0;
|
||||
virtual std::string getGPGId(const std::string &sslid_or_gpgid) = 0; //return the gpg id of the given gpg or ssl id
|
||||
virtual bool isKeySupported(const std::string& gpg_ids) = 0;
|
||||
virtual bool getGPGAcceptedList(std::list<std::string> &gpg_ids) = 0;
|
||||
virtual bool getGPGSignedList(std::list<std::string> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
|
||||
virtual bool getGPGValidList(std::list<std::string> &gpg_ids) = 0;
|
||||
virtual bool getGPGAllList(std::list<std::string> &gpg_ids) = 0;
|
||||
virtual bool getGPGDetails(const std::string &gpg_id, RsPeerDetails &d) = 0;
|
||||
virtual bool getAssociatedSSLIds(const std::string &gpg_id, std::list<std::string> &ids) = 0;
|
||||
virtual std::string getGPGOwnId() = 0;
|
||||
virtual std::string getGPGId(const std::string &sslid_or_gpgid) = 0; //return the gpg id of the given gpg or ssl id
|
||||
virtual bool isKeySupported(const std::string& gpg_ids) = 0;
|
||||
virtual bool getGPGAcceptedList(std::list<std::string> &gpg_ids) = 0;
|
||||
virtual bool getGPGSignedList(std::list<std::string> &gpg_ids) = 0;//friends that we accpet to connect with but we don't want to sign their gpg key
|
||||
virtual bool getGPGValidList(std::list<std::string> &gpg_ids) = 0;
|
||||
virtual bool getGPGAllList(std::list<std::string> &gpg_ids) = 0;
|
||||
virtual bool getGPGDetails(const std::string &gpg_id, RsPeerDetails &d) = 0;
|
||||
virtual bool getAssociatedSSLIds(const std::string &gpg_id, std::list<std::string> &ids) = 0;
|
||||
|
||||
/* Add/Remove Friends */
|
||||
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id) = 0;
|
||||
virtual bool removeFriend(const std::string &ssl_or_gpg_id) = 0;
|
||||
virtual bool removeFriendLocation(const std::string &sslId) = 0;
|
||||
/* Add/Remove Friends */
|
||||
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id) = 0;
|
||||
virtual bool removeFriend(const std::string &ssl_or_gpg_id) = 0;
|
||||
virtual bool removeFriendLocation(const std::string &sslId) = 0;
|
||||
|
||||
/* Network Stuff */
|
||||
virtual bool connectAttempt(const std::string &ssl_id) = 0;
|
||||
virtual bool setLocation(const std::string &ssl_id, const std::string &location) = 0;//location is shown in the gui to differentiate ssl certs
|
||||
virtual bool setLocalAddress(const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
|
||||
virtual bool setExtAddress( const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
|
||||
virtual bool setDynDNS(const std::string &id, const std::string &addr) = 0;
|
||||
virtual bool setNetworkMode(const std::string &ssl_id, uint32_t netMode) = 0;
|
||||
virtual bool setVisState(const std::string &ssl_id, uint32_t vis) = 0;
|
||||
/* Network Stuff */
|
||||
virtual bool connectAttempt(const std::string &ssl_id) = 0;
|
||||
virtual bool setLocation(const std::string &ssl_id, const std::string &location) = 0;//location is shown in the gui to differentiate ssl certs
|
||||
virtual bool setLocalAddress(const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
|
||||
virtual bool setExtAddress( const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
|
||||
virtual bool setDynDNS(const std::string &id, const std::string &addr) = 0;
|
||||
virtual bool setNetworkMode(const std::string &ssl_id, uint32_t netMode) = 0;
|
||||
virtual bool setVisState(const std::string &ssl_id, uint32_t vis) = 0;
|
||||
|
||||
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
|
||||
virtual void allowServerIPDetermination(bool) = 0;
|
||||
virtual void allowTunnelConnection(bool) = 0;
|
||||
virtual bool getAllowServerIPDetermination() = 0 ;
|
||||
virtual bool getAllowTunnelConnection() = 0 ;
|
||||
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
|
||||
virtual void allowServerIPDetermination(bool) = 0;
|
||||
virtual void allowTunnelConnection(bool) = 0;
|
||||
virtual bool getAllowServerIPDetermination() = 0 ;
|
||||
virtual bool getAllowTunnelConnection() = 0 ;
|
||||
|
||||
/* Auth Stuff */
|
||||
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format = false) = 0;
|
||||
virtual bool GetPGPBase64StringAndCheckSum(const std::string& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0 ;
|
||||
virtual std::string GetRetroshareInvite(bool include_signatures,bool old_format = false) = 0;
|
||||
virtual bool hasExportMinimal() = 0 ;
|
||||
/* Auth Stuff */
|
||||
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format = false) = 0;
|
||||
virtual bool GetPGPBase64StringAndCheckSum(const std::string& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0 ;
|
||||
virtual std::string GetRetroshareInvite(bool include_signatures,bool old_format = false) = 0;
|
||||
virtual bool hasExportMinimal() = 0 ;
|
||||
|
||||
// Add keys to the keyring
|
||||
virtual bool loadCertificateFromFile(const std::string &fname, std::string &ssl_id, std::string &gpg_id) = 0;
|
||||
virtual bool loadCertificateFromString(const std::string &cert, std::string &ssl_id, std::string &gpg_id) = 0;
|
||||
// Add keys to the keyring
|
||||
virtual bool loadCertificateFromFile(const std::string &fname, std::string &ssl_id, std::string &gpg_id) = 0;
|
||||
virtual bool loadCertificateFromString(const std::string &cert, std::string &ssl_id, std::string &gpg_id) = 0;
|
||||
|
||||
// Gets the GPG details, but does not add the key to the keyring.
|
||||
virtual bool loadDetailsFromStringCert(const std::string& certGPG, RsPeerDetails &pd,std::string& error_string) = 0;
|
||||
// Gets the GPG details, but does not add the key to the keyring.
|
||||
virtual bool loadDetailsFromStringCert(const std::string& certGPG, RsPeerDetails &pd,std::string& error_string) = 0;
|
||||
|
||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code) = 0;
|
||||
virtual bool saveCertificateToFile(const std::string &id, const std::string &fname) = 0;
|
||||
virtual std::string saveCertificateToString(const std::string &id) = 0;
|
||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,int& error_code) = 0;
|
||||
virtual bool saveCertificateToFile(const std::string &id, const std::string &fname) = 0;
|
||||
virtual std::string saveCertificateToString(const std::string &id) = 0;
|
||||
|
||||
virtual bool signGPGCertificate(const std::string &gpg_id) = 0;
|
||||
virtual bool trustGPGCertificate(const std::string &gpg_id, uint32_t trustlvl) = 0;
|
||||
virtual bool signGPGCertificate(const std::string &gpg_id) = 0;
|
||||
virtual bool trustGPGCertificate(const std::string &gpg_id, uint32_t trustlvl) = 0;
|
||||
|
||||
/* Group Stuff */
|
||||
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool removeGroup(const std::string &groupId) = 0;
|
||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
||||
// groupId == "" && assign == false -> remove from all groups
|
||||
virtual bool assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign) = 0;
|
||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign) = 0;
|
||||
/* Group Stuff */
|
||||
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool editGroup(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool removeGroup(const std::string &groupId) = 0;
|
||||
virtual bool getGroupInfo(const std::string &groupId, RsGroupInfo &groupInfo) = 0;
|
||||
virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList) = 0;
|
||||
// groupId == "" && assign == false -> remove from all groups
|
||||
virtual bool assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign) = 0;
|
||||
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign) = 0;
|
||||
|
||||
/* Group sharing permission */
|
||||
|
||||
// Given
|
||||
// - the peer id
|
||||
// - the permission flags of a given hash, e.g. a combination of
|
||||
// RS_DIR_FLAGS_NETWORK_WIDE_OTHERS, RS_DIR_FLAGS_NETWORK_WIDE_GROUPS, RS_DIR_FLAGS_BROWSABLE_OTHERS and RS_DIR_FLAGS_BROWSABLE_GROUPS
|
||||
// - the parent groups of the file
|
||||
//
|
||||
// ... computes the sharing file permission hint flags set for this peer, that is a combination of
|
||||
// RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE.
|
||||
//
|
||||
virtual FileSearchFlags computePeerPermissionFlags(const std::string& peer_id,FileStorageFlags file_sharing_flags,const std::list<std::string>& file_parent_groups) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <retroshare/rsflags.h>
|
||||
|
||||
#define USE_NEW_CHUNK_CHECKING_CODE
|
||||
|
||||
typedef std::string RsCertId;
|
||||
|
@ -94,54 +96,6 @@ enum DwlSpeed { SPEED_LOW = 0x00,
|
|||
|
||||
|
||||
|
||||
class FileInfo
|
||||
{
|
||||
/* old BaseInfo Entries */
|
||||
public:
|
||||
|
||||
FileInfo() :flags(0), mId(0) { return; }
|
||||
RsCertId id; /* key for matching everything */
|
||||
int flags; /* INFO_TAG above */
|
||||
|
||||
/* allow this to be tweaked by the GUI Model */
|
||||
mutable unsigned int mId; /* (GUI) Model Id -> unique number */
|
||||
|
||||
/* Old FileInfo Entries */
|
||||
public:
|
||||
|
||||
static const int kRsFiStatusNone = 0;
|
||||
static const int kRsFiStatusStall = 1;
|
||||
static const int kRsFiStatusProgress = 2;
|
||||
static const int kRsFiStatusDone = 2;
|
||||
|
||||
/* FileInfo(); */
|
||||
|
||||
int searchId; /* 0 if none */
|
||||
std::string path;
|
||||
std::string fname;
|
||||
std::string hash;
|
||||
std::string ext;
|
||||
|
||||
uint64_t size;
|
||||
uint64_t avail; /* how much we have */
|
||||
int status;
|
||||
|
||||
double rank;
|
||||
int age;
|
||||
uint32_t queue_position ;
|
||||
|
||||
/* Transfer Stuff */
|
||||
uint64_t transfered;
|
||||
double tfRate; /* in kbytes */
|
||||
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
||||
std::list<TransferInfo> peers;
|
||||
|
||||
DwlSpeed priority ;
|
||||
time_t lastTS;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
||||
|
||||
|
||||
/* matched to the uPnP states */
|
||||
#define UPNP_STATE_UNINITIALISED 0
|
||||
|
@ -248,14 +202,72 @@ class SearchRequest
|
|||
* (TODO)
|
||||
*/
|
||||
|
||||
#define DIR_FLAGS_LOCAL 0x1000
|
||||
#define DIR_FLAGS_REMOTE 0x2000
|
||||
const FileStorageFlags DIR_FLAGS_PARENT ( 0x0001 );
|
||||
const FileStorageFlags DIR_FLAGS_DETAILS ( 0x0002 ); // apparently unused
|
||||
const FileStorageFlags DIR_FLAGS_CHILDREN ( 0x0004 ); // apparently unused
|
||||
|
||||
const FileStorageFlags DIR_FLAGS_NETWORK_WIDE_OTHERS ( 0x0080 ); // Flags for directory sharing permissions. The last
|
||||
const FileStorageFlags DIR_FLAGS_BROWSABLE_OTHERS ( 0x0100 ); // one should be the OR of the all four flags.
|
||||
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 );
|
||||
|
||||
const FileStorageFlags DIR_FLAGS_LOCAL ( 0x1000 );
|
||||
const FileStorageFlags DIR_FLAGS_REMOTE ( 0x2000 );
|
||||
|
||||
class FileInfo
|
||||
{
|
||||
/* old BaseInfo Entries */
|
||||
public:
|
||||
|
||||
FileInfo() : mId(0) { return; }
|
||||
RsCertId id; /* key for matching everything */
|
||||
|
||||
FileStorageFlags storage_permission_flags; // Combination of the four RS_DIR_FLAGS_*. Updated when the file is a local stored file.
|
||||
TransferRequestFlags transfer_info_flags ; // various flags from RS_FILE_HINTS_*
|
||||
|
||||
/* allow this to be tweaked by the GUI Model */
|
||||
mutable unsigned int mId; /* (GUI) Model Id -> unique number */
|
||||
|
||||
/* Old FileInfo Entries */
|
||||
public:
|
||||
|
||||
static const int kRsFiStatusNone = 0;
|
||||
static const int kRsFiStatusStall = 1;
|
||||
static const int kRsFiStatusProgress = 2;
|
||||
static const int kRsFiStatusDone = 2;
|
||||
|
||||
/* FileInfo(); */
|
||||
|
||||
int searchId; /* 0 if none */
|
||||
std::string path;
|
||||
std::string fname;
|
||||
std::string hash;
|
||||
std::string ext;
|
||||
|
||||
uint64_t size;
|
||||
uint64_t avail; /* how much we have */
|
||||
int status;
|
||||
|
||||
double rank;
|
||||
int age;
|
||||
uint32_t queue_position ;
|
||||
|
||||
/* Transfer Stuff */
|
||||
uint64_t transfered;
|
||||
double tfRate; /* in kbytes */
|
||||
uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */
|
||||
std::list<TransferInfo> peers;
|
||||
|
||||
DwlSpeed priority ;
|
||||
time_t lastTS;
|
||||
|
||||
std::list<std::string> parent_groups ;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const FileInfo &info);
|
||||
|
||||
#define DIR_FLAGS_PARENT 0x0001
|
||||
#define DIR_FLAGS_DETAILS 0x0002
|
||||
#define DIR_FLAGS_CHILDREN 0x0004
|
||||
#define DIR_FLAGS_NETWORK_WIDE 0x0008
|
||||
#define DIR_FLAGS_BROWSABLE 0x0010
|
||||
|
||||
class DirStub
|
||||
{
|
||||
|
@ -279,22 +291,23 @@ class DirDetails
|
|||
std::string path;
|
||||
uint64_t count;
|
||||
uint32_t age;
|
||||
uint32_t flags;
|
||||
FileStorageFlags flags;
|
||||
uint32_t min_age ; // minimum age of files in this subtree
|
||||
|
||||
std::list<DirStub> children;
|
||||
std::list<std::string> parent_groups; // parent groups for the shared directory
|
||||
};
|
||||
|
||||
class FileDetail
|
||||
{
|
||||
public:
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string hash;
|
||||
std::string path;
|
||||
uint64_t size;
|
||||
uint32_t age;
|
||||
uint32_t rank;
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string hash;
|
||||
std::string path;
|
||||
uint64_t size;
|
||||
uint32_t age;
|
||||
uint32_t rank;
|
||||
};
|
||||
|
||||
class CompressedChunkMap ;
|
||||
|
@ -314,7 +327,6 @@ class FileChunksInfo
|
|||
|
||||
uint64_t file_size ; // real size of the file
|
||||
uint32_t chunk_size ; // size of chunks
|
||||
uint32_t flags ;
|
||||
uint32_t strategy ;
|
||||
|
||||
// dl state of chunks. Only the last chunk may have size < chunk_size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue