mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-09 09:35:32 -04:00
First shot of file sharing permissions. Compiles, but needs some testing/debugging.
- added type-safe flags in retroshare/rsflags.h. This should be used to make new flags types in order to prevent mixing flags up in function prototypes. - group handling is left to rsPeers. We'll move it to rsCircles later. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-FileSharingPermissions@5754 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
03d4936b12
commit
dc82cee700
27 changed files with 567 additions and 336 deletions
|
@ -63,27 +63,29 @@ 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 TransferInfoFlags RS_FILE_HINTS_CACHE = 0x00000001;
|
||||
const TransferInfoFlags RS_FILE_HINTS_EXTRA = 0x00000002;
|
||||
const TransferInfoFlags RS_FILE_HINTS_LOCAL = 0x00000004;
|
||||
const TransferInfoFlags RS_FILE_HINTS_REMOTE = 0x00000008;
|
||||
const TransferInfoFlags RS_FILE_HINTS_DOWNLOAD = 0x00000010;
|
||||
const TransferInfoFlags RS_FILE_HINTS_UPLOAD = 0x00000020;
|
||||
const TransferInfoFlags RS_FILE_HINTS_NETWORK_WIDE = 0x00000080;// anonymously shared over network
|
||||
const TransferInfoFlags RS_FILE_HINTS_BROWSABLE = 0x00000100;// browsable by friends
|
||||
const TransferInfoFlags RS_FILE_HINTS_PERMISSION_MASK = 0x00000180;// OR of the last two flags. Used to filter out.
|
||||
|
||||
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;
|
||||
// Flags used when requesting a transfer
|
||||
//
|
||||
const TransferInfoFlags RS_FILE_HINTS_ANONYMOUS_ROUTING = 0x00000040; // Use to ask turtle router to download the file.
|
||||
const TransferInfoFlags RS_FILE_HINTS_ASSUME_AVAILABILITY = 0x00000200; // Assume full source availability. Used for cache files.
|
||||
const TransferInfoFlags RS_FILE_HINTS_MEDIA = 0x00001000;
|
||||
const TransferInfoFlags RS_FILE_HINTS_BACKGROUND = 0x00002000; // To download slowly.
|
||||
const TransferInfoFlags RS_FILE_HINTS_SPEC_ONLY = 0x01000000;
|
||||
const TransferInfoFlags RS_FILE_HINTS_NO_SEARCH = 0x02000000; // disable searching for potential direct sources.
|
||||
|
||||
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_NETWORK_WIDE_OTHERS = 0x00000080; // anonymously shared over network
|
||||
const uint32_t RS_FILE_HINTS_BROWSABLE_OTHERS = 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_NETWORK_WIDE_GROUPS = 0x00000400; // anonymously shared over network
|
||||
const uint32_t RS_FILE_HINTS_BROWSABLE_GROUPS = 0x00000800; // browsable by friends
|
||||
const uint32_t RS_FILE_HINTS_MEDIA = 0x00001000;
|
||||
const uint32_t RS_FILE_HINTS_BACKGROUND = 0x00002000; // To download slowly.
|
||||
|
||||
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 */
|
||||
|
||||
|
@ -94,6 +96,7 @@ struct SharedDirInfo
|
|||
std::string filename ;
|
||||
std::string virtualname ;
|
||||
uint32_t shareflags ; // RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE
|
||||
std::list<std::string> parent_groups ;
|
||||
};
|
||||
|
||||
class RsFiles
|
||||
|
@ -113,7 +116,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, TransferInfoFlags 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;
|
||||
|
@ -141,7 +144,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, TransferInfoFlags hintflags, FileInfo &info) = 0;
|
||||
|
||||
/// Gives chunk details about the downloaded file with given hash.
|
||||
virtual bool FileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info) = 0 ;
|
||||
|
@ -152,11 +155,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, TransferInfoFlags flags) = 0;
|
||||
virtual bool ExtraFileRemove(std::string hash, TransferInfoFlags flags) = 0;
|
||||
virtual bool ExtraFileHash(std::string localpath, uint32_t period, TransferInfoFlags 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;
|
||||
|
@ -168,11 +169,13 @@ class RsFiles
|
|||
*/
|
||||
virtual int RequestDirDetails(const std::string& uid, const std::string& path, DirDetails &details) = 0;
|
||||
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) = 0;
|
||||
virtual uint32_t getType(void *ref,uint32_t flags) = 0;
|
||||
virtual int RequestDirDetails(void *ref, DirDetails &details, FileStorageFlags flags) = 0;
|
||||
virtual uint32_t getType(void *ref,TransferInfoFlags flags) = 0;
|
||||
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags) = 0;
|
||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags,const std::string& peer_id) = 0;
|
||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t flags) = 0;
|
||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t flags,const std::string& peer_id) = 0;
|
||||
|
||||
/***
|
||||
* Utility Functions.
|
||||
|
|
29
libretroshare/src/retroshare/rsflags.h
Normal file
29
libretroshare/src/retroshare/rsflags.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <stdint.h>
|
||||
|
||||
template<int n> class t_RsFlags32
|
||||
{
|
||||
public:
|
||||
t_RsFlags32() {}
|
||||
|
||||
t_RsFlags32(uint32_t N) : _bits(N) {}
|
||||
operator uint32_t() const { return _bits ; }
|
||||
|
||||
t_RsFlags32<n> operator| (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits | f._bits) ; }
|
||||
t_RsFlags32<n> operator^ (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits ^ f._bits) ; }
|
||||
t_RsFlags32<n> operator& (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits & f._bits) ; }
|
||||
|
||||
t_RsFlags32<n> operator|=(const t_RsFlags32<n>& f) { _bits |= f._bits ; return *this ;}
|
||||
t_RsFlags32<n> operator^=(const t_RsFlags32<n>& f) { _bits ^= f._bits ; return *this ;}
|
||||
t_RsFlags32<n> operator&=(const t_RsFlags32<n>& f) { _bits &= f._bits ; return *this ;}
|
||||
|
||||
t_RsFlags32<n> operator~() const { return t_RsFlags32<n>(~_bits) ; }
|
||||
private:
|
||||
uint32_t _bits ;
|
||||
};
|
||||
|
||||
#define TRANSFER_INFO_FLAGS_TAG 0x8133ea
|
||||
#define FILE_STORAGE_FLAGS_TAG 0x184738
|
||||
|
||||
typedef t_RsFlags32<TRANSFER_INFO_FLAGS_TAG> TransferInfoFlags ;
|
||||
typedef t_RsFlags32<FILE_STORAGE_FLAGS_TAG > FileStorageFlags ; // 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 TransferInfoFlags 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,16 +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;
|
||||
const FileStorageFlags DIR_FLAGS_CHILDREN = 0x0004;
|
||||
|
||||
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.
|
||||
TransferInfoFlags 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_OTHERS 0x0008
|
||||
#define DIR_FLAGS_BROWSABLE_OTHERS 0x0010
|
||||
#define DIR_FLAGS_NETWORK_WIDE_GROUPS 0x0020
|
||||
#define DIR_FLAGS_BROWSABLE_GROUPS 0x0040
|
||||
|
||||
class DirStub
|
||||
{
|
||||
|
@ -281,11 +291,11 @@ 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> groups; // parent groups for the shared directory
|
||||
std::list<std::string> parent_groups; // parent groups for the shared directory
|
||||
};
|
||||
|
||||
class FileDetail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue