merge of branch v0.6-idclean 7180

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7187 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2014-03-17 20:56:06 +00:00
parent 7815efb16f
commit 0f29d28b1b
397 changed files with 6503 additions and 5702 deletions

View file

@ -27,6 +27,7 @@
*/
#include <inttypes.h>
#include <retroshare/rstypes.h>
#include <string>
#include <list>
#include <map>
@ -35,10 +36,6 @@
class RsServerConfig;
extern RsServerConfig *rsConfig;
#define RSNET_NETWORK_UNKNOWN 1
#define RSNET_NETWORK_RESTARTING 2
#define RSNET_NETWORK_OFFLINE 3
@ -188,7 +185,7 @@ class RsConfigNetStatus
}
std::string ownId;
RsPeerId ownId;
std::string ownName;
std::string localAddr;
@ -242,7 +239,7 @@ virtual int getConfigNetStatus(RsConfigNetStatus &status) = 0;
//virtual int getConfigStartup(RsConfigStartup &params) = 0;
virtual int getTotalBandwidthRates(RsConfigDataRates &rates) = 0;
virtual int getAllBandwidthRates(std::map<std::string, RsConfigDataRates> &ratemap) = 0;
virtual int getAllBandwidthRates(std::map<RsPeerId, RsConfigDataRates> &ratemap) = 0;
/* From RsInit */

View file

@ -29,6 +29,7 @@
#include <inttypes.h>
#include <string>
#include <list>
#include <retroshare/rstypes.h>
/* The Main Interface Class - for information about your Peers */
class RsDht;
@ -110,7 +111,7 @@ class RsDhtNetPeer
RsDhtNetPeer();
std::string mDhtId;
std::string mRsId;
RsPeerId mRsId;
uint32_t mPeerType;
uint32_t mDhtState;
@ -167,8 +168,8 @@ virtual ~RsDht() { return; }
virtual uint32_t getNetState(uint32_t type) = 0;
virtual int getDhtPeers(int lvl, std::list<RsDhtPeer> &peers) = 0;
virtual int getNetPeerList(std::list<std::string> &peerIds) = 0;
virtual int getNetPeerStatus(std::string peerId, RsDhtNetPeer &status) = 0;
virtual int getNetPeerList(std::list<RsPeerId> &peerIds) = 0;
virtual int getNetPeerStatus(const RsPeerId& peerId, RsDhtNetPeer &status) = 0;
virtual int getRelayEnds(std::list<RsDhtRelayEnd> &relayEnds) = 0;
virtual int getRelayProxies(std::list<RsDhtRelayProxy> &relayProxies) = 0;

View file

@ -30,6 +30,7 @@
#include <string>
#include <list>
#include <map>
#include <retroshare/rstypes.h>
/* The Main Interface Class - for information about your Peers */
class RsDisc;
@ -42,9 +43,9 @@ class RsDisc
RsDisc() { return; }
virtual ~RsDisc() { return; }
virtual bool getDiscFriends(const std::string &id, std::list<std::string>& friends) = 0;
virtual bool getDiscPgpFriends(const std::string &pgpid, std::list<std::string>& gpg_friends) = 0;
virtual bool getPeerVersion(const std::string &id, std::string &versions) = 0;
virtual bool getDiscFriends(const RsPeerId &id, std::list<RsPeerId>& friends) = 0;
virtual bool getDiscPgpFriends(const RsPgpId &pgpid, std::list<RsPgpId>& gpg_friends) = 0;
virtual bool getPeerVersion(const RsPeerId &id, std::string &versions) = 0;
virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount) = 0;
};

View file

@ -158,7 +158,7 @@ class StringExpression: public Expression
virtual void linearize(LinearizedExpression& e) const ;
protected:
bool evalStr(std::string &str);
bool evalStr(const std::string &str);
enum StringOperator Op;
std::list<std::string> terms;

View file

@ -117,18 +117,18 @@ class RsFiles
* Control of Downloads.
***/
virtual bool alreadyHaveFile(const std::string& hash, FileInfo &info) = 0;
virtual bool alreadyHaveFile(const RsFileHash& 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, TransferRequestFlags flags, const std::list<std::string>& srcIds) = 0;
virtual bool FileCancel(const std::string& hash) = 0;
virtual bool setDestinationDirectory(const std::string& hash,const std::string& new_path) = 0;
virtual bool setDestinationName(const std::string& hash,const std::string& new_name) = 0;
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy) = 0;
virtual bool FileRequest(const std::string& fname, const RsFileHash& hash, uint64_t size, const std::string& dest, TransferRequestFlags flags, const std::list<RsPeerId>& srcIds) = 0;
virtual bool FileCancel(const RsFileHash& hash) = 0;
virtual bool setDestinationDirectory(const RsFileHash& hash,const std::string& new_path) = 0;
virtual bool setDestinationName(const RsFileHash& hash,const std::string& new_name) = 0;
virtual bool setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy) = 0;
virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) = 0;
virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() = 0;
virtual uint32_t freeDiskSpaceLimit() const =0;
virtual void setFreeDiskSpaceLimit(uint32_t size_in_mb) =0;
virtual bool FileControl(const std::string& hash, uint32_t flags) = 0;
virtual bool FileControl(const RsFileHash& hash, uint32_t flags) = 0;
virtual bool FileClearCompleted() = 0;
/***
@ -138,48 +138,47 @@ class RsFiles
virtual void setMinPrioritizedTransfers(uint32_t s) = 0 ;
virtual uint32_t getQueueSize() = 0 ;
virtual void setQueueSize(uint32_t s) = 0 ;
virtual bool changeQueuePosition(const std::string hash, QueueMove mv) = 0;
virtual bool changeDownloadSpeed(const std::string hash, int speed) = 0;
virtual bool getDownloadSpeed(const std::string hash, int & speed) = 0;
virtual bool clearDownload(const std::string hash) = 0;
virtual bool changeQueuePosition(const RsFileHash& hash, QueueMove mv) = 0;
virtual bool changeDownloadSpeed(const RsFileHash& hash, int speed) = 0;
virtual bool getDownloadSpeed(const RsFileHash& hash, int & speed) = 0;
virtual bool clearDownload(const RsFileHash& hash) = 0;
// virtual void getDwlDetails(std::list<DwlDetails> & details) = 0;
/***
* Download / Upload Details.
***/
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, FileSearchFlags hintflags, FileInfo &info) = 0;
virtual bool FileDownloads(std::list<RsFileHash> &hashs) = 0;
virtual bool FileUploads(std::list<RsFileHash> &hashs) = 0;
virtual bool FileDetails(const RsFileHash &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 ;
virtual bool FileDownloadChunksDetails(const RsFileHash& hash,FileChunksInfo& info) = 0 ;
/// details about the upload with given hash
virtual bool FileUploadChunksDetails(const std::string& hash,const std::string& peer_id,CompressedChunkMap& map) = 0 ;
virtual bool FileUploadChunksDetails(const RsFileHash& hash,const RsPeerId& peer_id,CompressedChunkMap& map) = 0 ;
/***
* Extra List Access
***/
//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 ExtraFileRemove(const RsFileHash& 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;
virtual bool ExtraFileMove(std::string fname, const RsFileHash& hash, uint64_t size, std::string destpath) = 0;
/***
* Directory Listing / Search Interface
*/
virtual int RequestDirDetails(const std::string& uid, const std::string& path, DirDetails &details) = 0;
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 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 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 std::string& peer_id) = 0;
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,FileSearchFlags flags,const RsPeerId& peer_id) = 0;
/***
* Utility Functions.

View file

@ -113,7 +113,7 @@ virtual bool updateGroup(uint32_t &token, RsGxsChannelGroup &group) = 0;
// File Interface
virtual bool ExtraFileHash(const std::string &path, std::string filename) = 0;
virtual bool ExtraFileRemove(const std::string &hash) = 0;
virtual bool ExtraFileRemove(const RsFileHash &hash) = 0;
};

View file

@ -31,6 +31,12 @@
#include <list>
#include <set>
#include "retroshare/rstypes.h"
//typedef std::string RsGxsCircleId;
//typedef RsPgpId RsPgpId;
//typedef std::string RsCircleInternalId;
#include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h"
@ -41,11 +47,8 @@
class RsGxsCircles;
extern RsGxsCircles *rsGxsCircles;
typedef std::string RsGxsCircleId;
typedef std::string RsPeerId; // SSL ID.
typedef std::string RsPgpId;
typedef std::string RsCircleInternalId;
typedef RsPgpId RsPgpId;
//typedef RsGxsCircleId RsCircleInternalId;
#define GXS_CIRCLE_TYPE_PUBLIC 0x0001
#define GXS_CIRCLE_TYPE_EXTERNAL 0x0002
@ -66,7 +69,7 @@ public:
// BELOW IS NOT SERIALISED - BUT MUST BE STORED LOCALLY BY GXS. (If YOUREYESONLY)
RsPeerId mOriginator;
RsCircleInternalId mInternalCircle; // if Originator == ownId, otherwise blank.
RsGxsCircleId mInternalCircle; // if Originator == ownId, otherwise blank.
};

View file

@ -37,7 +37,7 @@ class RsGxsFile
public:
RsGxsFile();
std::string mName;
std::string mHash;
RsFileHash mHash;
uint64_t mSize;
//std::string mPath;
};

View file

@ -238,7 +238,6 @@ public:
return mGxs->getGroupStatistic(token, stats);
}
/*!
* This determines the reputation threshold messages need to surpass in order
* for it to be accepted by local user from remote source

View file

@ -13,9 +13,12 @@
#include <string>
#include <inttypes.h>
#include <retroshare/rstypes.h>
typedef std::string RsGxsGroupId;
typedef std::string RsGxsMessageId;
typedef GXSGroupId RsGxsGroupId;
typedef Sha1CheckSum RsGxsMessageId;
typedef GXSId RsGxsId;
typedef GXSCircleId RsGxsCircleId;
typedef std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > GxsMsgIdResult;
typedef std::pair<RsGxsGroupId, RsGxsMessageId> RsGxsGrpMsgIdPair;
@ -53,21 +56,21 @@ public:
void operator =(const RsGxsGrpMetaData& rGxsMeta);
std::string mGroupId;
RsGxsGroupId mGroupId;
std::string mGroupName;
uint32_t mGroupFlags;
uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK.
time_t mPublishTs; // Mandatory.
std::string mAuthorId; // Optional.
RsGxsId mAuthorId; // Optional.
// for circles
std::string mCircleId;
RsGxsCircleId mCircleId;
uint32_t mCircleType;
// other stuff.
uint32_t mAuthenFlags;
std::string mParentGrpId;
RsGxsGroupId mParentGrpId;
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
@ -79,8 +82,8 @@ public:
uint32_t mGroupStatus;
std::string mServiceString; // Service Specific Free-Form extra storage.
std::string mOriginator;
std::string mInternalCircle;
RsPeerId mOriginator;
RsGxsCircleId mInternalCircle;
};
@ -103,14 +106,14 @@ public:
void operator =(const RsGxsMsgMetaData& rGxsMeta);
std::string mGroupId;
std::string mMsgId;
RsGxsGroupId mGroupId;
RsGxsMessageId mMsgId;
std::string mThreadId;
std::string mParentId;
std::string mOrigMsgId;
RsGxsMessageId mThreadId;
RsGxsMessageId mParentId;
RsGxsMessageId mOrigMsgId;
std::string mAuthorId;
RsGxsId mAuthorId;
std::string mMsgName;
time_t mPublishTs;
@ -173,7 +176,7 @@ public:
// expand as support is added for other utypes
enum UpdateType { DESCRIPTION, NAME };
RsGxsGroupUpdateMeta(const std::string& groupId) : mGroupId(groupId) {}
RsGxsGroupUpdateMeta(const RsGxsGroupId& groupId) : mGroupId(groupId) {}
typedef std::map<UpdateType, std::string> GxsMetaUpdate;
@ -194,12 +197,12 @@ public:
bool removeUpdateType(UpdateType utype){ return mUpdates.erase(utype) == 1; }
const GxsMetaUpdate* getUpdates() const { return &mUpdates; }
const std::string& getGroupId() const { return mGroupId; }
const RsGxsGroupId& getGroupId() const { return mGroupId; }
private:
GxsMetaUpdate mUpdates;
std::string mGroupId;
RsGxsGroupId mGroupId;
};
#endif /* RSGXSIFACETYPES_H_ */

View file

@ -2,8 +2,11 @@
#define RSGXSSERVICE_H
#include "retroshare/rsgxsifacetypes.h"
#include "retroshare/rstokenservice.h"
class RsMsgMetaData ;
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMetaMap;

View file

@ -33,6 +33,7 @@ extern RsHistory *rsHistory;
#include <string>
#include <inttypes.h>
#include <list>
#include "retroshare/rstypes.h"
//! data object for message history
/*!
@ -55,9 +56,9 @@ public:
public:
uint32_t msgId;
std::string chatPeerId;
RsPeerId chatPeerId;
bool incoming;
std::string peerId;
RsPeerId peerId;
std::string peerName;
uint32_t sendTime;
uint32_t recvTime;
@ -71,10 +72,10 @@ public:
class RsHistory
{
public:
virtual bool getMessages(const std::string &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
virtual bool getMessages(const RsPeerId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
virtual void clear(const std::string &chatPeerId) = 0;
virtual void clear(const RsPeerId &chatPeerId) = 0;
virtual bool getEnable(uint32_t chat_type) = 0;
virtual void setEnable(uint32_t chat_type, bool enable) = 0;

View file

@ -32,6 +32,7 @@
#include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsids.h"
/* The Main Interface Class - for information about your Peers */
class RsIdentity;
@ -103,7 +104,7 @@ class RsGxsIdGroup
// Not Serialised - for GUI's benefit.
bool mPgpKnown;
std::string mPgpId;
RsPgpId mPgpId;
GxsReputation mReputation;
};
@ -112,8 +113,6 @@ std::ostream &operator<<(std::ostream &out, const RsGxsIdGroup &group);
// DATA TYPE FOR EXTERNAL INTERFACE.
typedef std::string RsGxsId; // TMP. =>
class RsRecognTag
{
public:
@ -160,7 +159,7 @@ class RsIdentityDetails
// PGP Stuff.
bool mPgpLinked;
bool mPgpKnown;
std::string mPgpId;
RsPgpId mPgpId;
// Recogn details.
std::list<RsRecognTag> mRecognTags;

View file

@ -0,0 +1,232 @@
// This class aims at defining a generic ID type that is a list of bytes. It
// can be converted into a hexadecial string for printing, mainly) or for
// compatibility with old methods.
//
// To use this class, derive your own ID type from it. Examples include:
//
// class RsPgpId: public t_RsGenericIdType<8>
// {
// [..]
// };
//
// class PGPFingerprintType: public t_RsGenericIdType<20>
// {
// [..]
// };
//
// With this, there is no implicit conversion between subtypes, and therefore ID mixup
// is impossible.
//
// A simpler way to make ID types is to
// typedef t_RsGenericIdType<MySize> MyType ;
//
// ID Types with different lengths will be incompatible on compilation.
//
// Warning: never store references to a t_RsGenericIdType accross threads, since the
// cached string convertion is not thread safe.
//
#pragma once
#include <stdexcept>
#include <string>
#include <iostream>
#include <ostream>
#include <string.h>
#include <stdint.h>
#include <util/rsrandom.h>
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> class t_RsGenericIdType
{
public:
t_RsGenericIdType()
{
memset(bytes,0,ID_SIZE_IN_BYTES) ; // by default, ids are set to null()
}
virtual ~t_RsGenericIdType() {}
// Explicit constructor from a hexadecimal string
//
explicit t_RsGenericIdType(const std::string& hex_string) ;
// Explicit constructor from a byte array. The array should have size at least ID_SIZE_IN_BYTES
//
explicit t_RsGenericIdType(const unsigned char bytes[]) ;
// Explicit constructor from a different type, checking that the sizes are compatible.
// This is used for conversions such as
//
// GroupId -> CircleId
// GroupId -> GxsId
//
template<bool UPPER_CASE2,uint32_t UNIQUE_IDENTIFIER2>
explicit t_RsGenericIdType(const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE2,UNIQUE_IDENTIFIER2>& id)
{
memcpy(bytes,id.toByteArray(),ID_SIZE_IN_BYTES) ;
}
// Random initialization. Can be useful for testing.
//
static t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> random()
{
t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> id ;
for(uint32_t i=0;i<ID_SIZE_IN_BYTES;++i)
id.bytes[i] = RSRandom::random_u32() & 0xff ;
return id ;
}
inline void operator=(const std::string& str)
{
t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER> temp = t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>(str);
for(uint32_t i = 0; i < ID_SIZE_IN_BYTES; i++)
this->bytes[i] = temp.toByteArray()[i];
}
inline void clear() { bzero(bytes,SIZE_IN_BYTES) ; }
// Converts to a std::string using cached value.
//
const unsigned char *toByteArray() const { return &bytes[0] ; }
static const uint32_t SIZE_IN_BYTES = ID_SIZE_IN_BYTES ;
inline bool operator==(const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>& fp) const { return !memcmp(bytes,fp.bytes,ID_SIZE_IN_BYTES) ; }
inline bool operator!=(const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>& fp) const { return !!memcmp(bytes,fp.bytes,ID_SIZE_IN_BYTES); }
inline bool operator< (const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>& fp) const { return (memcmp(bytes,fp.bytes,ID_SIZE_IN_BYTES) < 0) ; }
inline bool isNull() const
{
for(uint32_t i=0;i<SIZE_IN_BYTES;++i)
if(bytes[i] != 0)
return false ;
return true ;
}
friend std::ostream& operator<<(std::ostream& out,const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>& id)
{
return out << id.toStdString(UPPER_CASE) ;
}
inline std::string toStdString() const { return toStdString(UPPER_CASE) ; }
inline uint32_t serial_size() const { return SIZE_IN_BYTES ; }
bool serialise(void *data,uint32_t pktsize,uint32_t& offset) const
{
if(offset + SIZE_IN_BYTES > pktsize)
return false ;
memcpy(&((uint8_t*)data)[offset],bytes,SIZE_IN_BYTES) ;
offset += SIZE_IN_BYTES ;
return true ;
}
bool deserialise(void *data,uint32_t pktsize,uint32_t& offset)
{
if(offset + SIZE_IN_BYTES > pktsize)
return false ;
memcpy(bytes,&((uint8_t*)data)[offset],SIZE_IN_BYTES) ;
offset += SIZE_IN_BYTES ;
return true ;
}
private:
std::string toStdString(bool upper_case) const ;
unsigned char bytes[ID_SIZE_IN_BYTES] ;
};
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> std::string t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>::toStdString(bool upper_case) const
{
static const char outh[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } ;
static const char outl[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' } ;
std::string res(ID_SIZE_IN_BYTES*2,' ') ;
for(uint32_t j = 0; j < ID_SIZE_IN_BYTES; j++)
if(upper_case)
{
res[2*j ] = outh[ (bytes[j]>>4) ] ;
res[2*j+1] = outh[ bytes[j] & 0xf ] ;
}
else
{
res[2*j ] = outl[ (bytes[j]>>4) ] ;
res[2*j+1] = outl[ bytes[j] & 0xf ] ;
}
return res ;
}
void chris_test();
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>::t_RsGenericIdType(const std::string& s)
{
try
{
int n=0;
if(s.length() != ID_SIZE_IN_BYTES*2)
{
throw std::runtime_error("t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string in constructor has wrong size.") ;
chris_test();
}
for(uint32_t i = 0; i < ID_SIZE_IN_BYTES; ++i)
{
bytes[i] = 0 ;
for(int k=0;k<2;++k)
{
char b = s[n++] ;
if(b >= 'A' && b <= 'F')
bytes[i] += (b-'A'+10) << 4*(1-k) ;
else if(b >= 'a' && b <= 'f')
bytes[i] += (b-'a'+10) << 4*(1-k) ;
else if(b >= '0' && b <= '9')
bytes[i] += (b-'0') << 4*(1-k) ;
else
throw std::runtime_error("t_RsGenericIdType<>::t_RsGenericIdType(std::string&): supplied string is not purely hexadecimal") ;
}
}
}
catch(std::exception& e)
{
std::cerr << e.what() << std::endl;
chris_test();
clear() ;
}
}
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER> t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>::t_RsGenericIdType(const unsigned char *mem)
{
if(mem == NULL)
memset(bytes,0,ID_SIZE_IN_BYTES) ;
else
memcpy(bytes,mem,ID_SIZE_IN_BYTES) ;
}
static const int SSL_ID_SIZE = 16 ; // = CERTSIGNLEN
static const int CERT_SIGN_LEN = 16 ; // = CERTSIGNLEN
static const int PGP_KEY_ID_SIZE = 8 ;
static const int PGP_KEY_FINGERPRINT_SIZE = 20 ;
static const int SHA1_SIZE = 20 ;
// These constants are random, but should be different, in order to make the various IDs incompatible with each other.
//
static const uint32_t RS_GENERIC_ID_SSL_ID_TYPE = 0x0001 ;
static const uint32_t RS_GENERIC_ID_PGP_ID_TYPE = 0x0002 ;
static const uint32_t RS_GENERIC_ID_SHA1_ID_TYPE = 0x0003 ;
static const uint32_t RS_GENERIC_ID_PGP_FINGERPRINT_TYPE = 0x0004 ;
static const uint32_t RS_GENERIC_ID_GXS_GROUP_ID_TYPE = 0x0005 ;
static const uint32_t RS_GENERIC_ID_GXS_ID_TYPE = 0x0006 ;
static const uint32_t RS_GENERIC_ID_GXS_MSG_ID_TYPE = 0x0007 ;
static const uint32_t RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE = 0x0008 ;
typedef t_RsGenericIdType< SSL_ID_SIZE , false, RS_GENERIC_ID_SSL_ID_TYPE> SSLIdType ;
typedef t_RsGenericIdType< PGP_KEY_ID_SIZE , true, RS_GENERIC_ID_PGP_ID_TYPE> PGPIdType ;
typedef t_RsGenericIdType< SHA1_SIZE , false, RS_GENERIC_ID_SHA1_ID_TYPE> Sha1CheckSum ;
typedef t_RsGenericIdType< PGP_KEY_FINGERPRINT_SIZE, true, RS_GENERIC_ID_PGP_FINGERPRINT_TYPE> PGPFingerprintType ;
typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_GROUP_ID_TYPE > GXSGroupId ;
typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_ID_TYPE > GXSId ;
typedef t_RsGenericIdType< CERT_SIGN_LEN , false, RS_GENERIC_ID_GXS_CIRCLE_ID_TYPE > GXSCircleId ;

View file

@ -77,7 +77,7 @@ class RsControl /* The Main Interface Class - for controlling the server */
/****************************************/
virtual bool getPeerCryptoDetails(const std::string& ssl_id,RsPeerCryptoParams& params) = 0;
virtual bool getPeerCryptoDetails(const RsPeerId& ssl_id,RsPeerCryptoParams& params) = 0;
protected:
RsControl() {} // should not be used, hence it's private.

View file

@ -45,6 +45,7 @@
#include <list>
#include <map>
#include <vector>
#include <retroshare/rstypes.h>
/*!
* Initialisation Class (not publicly disclosed to RsIFace)
@ -136,26 +137,26 @@ namespace RsAccounts
std::string AccountDirectory();
// PGP Accounts.
int GetPGPLogins(std::list<std::string> &pgpIds);
int GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email);
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString);
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, std::string &errString);
// PGP Support Functions.
bool ExportIdentity(const std::string& fname,const std::string& pgp_id) ;
bool ImportIdentity(const std::string& fname,std::string& imported_pgp_id,std::string& import_error) ;
bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
bool CopyGnuPGKeyrings() ;
// Rs Accounts
bool SelectAccount(const std::string &id);
bool SelectAccount(const RsPeerId& id);
bool GetPreferredAccountId(std::string &id);
bool GetAccountIds(std::list<std::string> &ids);
bool GetAccountDetails(const std::string &id,
std::string &gpgId, std::string &gpgName,
bool GetPreferredAccountId(RsPeerId &id);
bool GetAccountIds(std::list<RsPeerId> &ids);
bool GetAccountDetails(const RsPeerId &id,
RsPgpId &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location);
bool GenerateSSLCertificate(const std::string& name, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, std::string &sslId, std::string &errString);
bool GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
};

View file

@ -85,20 +85,23 @@ const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE( 0x00000001 ) ;
typedef uint64_t ChatLobbyId ;
typedef uint64_t ChatLobbyMsgId ;
typedef std::string ChatLobbyNickName ;
typedef std::string ChatLobbyNickName ;
typedef RsPeerId DistantChatPeerId ;
typedef RsPeerId DistantMsgPeerId ;
class MessageInfo
{
public:
MessageInfo() {}
std::string msgId;
std::string srcId;
RsPeerId srcId;
unsigned int msgflags;
std::list<std::string> msgto;
std::list<std::string> msgcc;
std::list<std::string> msgbcc;
std::list<RsPeerId> msgto;
std::list<RsPeerId> msgcc;
std::list<RsPeerId> msgbcc;
std::string title;
std::string msg;
@ -119,7 +122,7 @@ class MsgInfoSummary
MsgInfoSummary() {}
std::string msgId;
std::string srcId;
RsPeerId srcId;
uint32_t msgflags;
@ -170,7 +173,7 @@ public:
class ChatInfo
{
public:
std::string rsid;
RsPeerId rsid;
std::string peer_nickname;
unsigned int chatflags;
uint32_t sendTime;
@ -182,7 +185,7 @@ class ChatLobbyInvite
{
public:
ChatLobbyId lobby_id ;
std::string peer_id ;
RsPeerId peer_id ;
std::string lobby_name ;
std::string lobby_topic ;
uint32_t lobby_privacy_level ;
@ -196,7 +199,7 @@ class VisibleChatLobbyRecord
ChatLobbyId lobby_id ; // unique id of the lobby
std::string lobby_name ; // name to use for this lobby
std::string lobby_topic ; // topic to use for this lobby
std::set<std::string> participating_friends ; // list of direct friend who participate.
std::set<RsPeerId> participating_friends ; // list of direct friend who participate.
uint32_t total_number_of_peers ; // total number of particpating peers. Might not be
time_t last_report_time ; // last time the lobby was reported.
@ -210,7 +213,7 @@ class ChatLobbyInfo
ChatLobbyId lobby_id ; // unique id of the lobby
std::string lobby_name ; // name to use for this lobby
std::string lobby_topic ; // topic to use for this lobby
std::set<std::string> participating_friends ; // list of direct friend who participate. Used to broadcast sent messages.
std::set<RsPeerId> participating_friends ; // list of direct friend who participate. Used to broadcast sent messages.
std::string nick_name ; // nickname to use for this lobby
uint32_t lobby_privacy_level ; // see RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC / RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE
@ -220,9 +223,9 @@ class ChatLobbyInfo
struct DistantChatInviteInfo
{
std::string hash ; // hash to contact the invite and refer to it.
DistantChatPeerId pid ; // pid to contact the invite and refer to it.
std::string encrypted_radix64_string ; // encrypted radix string used to for the chat link
std::string destination_pgp_id ; // pgp is of the destination of the chat link
RsPgpId destination_pgp_id ; // pgp is of the destination of the chat link
time_t time_of_validity ; // time when te invite becomes unusable
uint32_t invite_flags ; // used to keep track of wether signature was ok or not.
};
@ -237,8 +240,8 @@ extern RsMsgs *rsMsgs;
struct DistantOfflineMessengingInvite
{
std::string issuer_pgp_id ;
std::string hash ;
RsPgpId issuer_pgp_id ;
Sha1CheckSum hash ;
time_t time_of_validity ;
};
@ -284,35 +287,37 @@ virtual bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set) =
virtual bool resetMessageStandardTagTypes(MsgTagType& tags) = 0;
/* private distant messages */
/****************************************/
/* Private distant messages */
/****************************************/
virtual bool createDistantOfflineMessengingInvite(time_t validity_time_stamp, std::string& hash)=0 ;
virtual bool createDistantOfflineMessengingInvite(time_t validity_time_stamp, DistantMsgPeerId& hash)=0 ;
virtual bool getDistantOfflineMessengingInvites(std::vector<DistantOfflineMessengingInvite>& invites) = 0 ;
virtual void enableDistantMessaging(bool b) = 0;
virtual bool distantMessagingEnabled() = 0;
virtual bool getDistantMessageHash(const std::string& pgp_id, std::string& hash) = 0;
virtual bool getDistantMessagePeerId(const RsPgpId& pgp_id, DistantMsgPeerId& peerId) = 0;
/****************************************/
/* Chat */
/****************************************/
virtual bool sendPublicChat(const std::string& msg) = 0;
virtual bool sendPrivateChat(const std::string& id, const std::string& msg) = 0;
virtual bool sendPrivateChat(const RsPeerId& id, const std::string& msg) = 0;
virtual int getPublicChatQueueCount() = 0;
virtual bool getPublicChatQueue(std::list<ChatInfo> &chats) = 0;
virtual int getPrivateChatQueueCount(bool incoming) = 0;
virtual bool getPrivateChatQueueIds(bool incoming, std::list<std::string> &ids) = 0;
virtual bool getPrivateChatQueue(bool incoming, const std::string& id, std::list<ChatInfo> &chats) = 0;
virtual bool clearPrivateChatQueue(bool incoming, const std::string& id) = 0;
virtual bool getPrivateChatQueueIds(bool incoming, std::list<RsPeerId> &ids) = 0;
virtual bool getPrivateChatQueue(bool incoming, const RsPeerId& id, std::list<ChatInfo> &chats) = 0;
virtual bool clearPrivateChatQueue(bool incoming, const RsPeerId& id) = 0;
virtual void sendStatusString(const std::string& id,const std::string& status_string) = 0 ;
virtual void sendStatusString(const RsPeerId& id,const std::string& status_string) = 0 ;
virtual void sendGroupChatStatusString(const std::string& status_string) = 0 ;
virtual void setCustomStateString(const std::string& status_string) = 0 ;
virtual std::string getCustomStateString() = 0 ;
virtual std::string getCustomStateString(const std::string& peer_id) = 0 ;
virtual std::string getCustomStateString(const RsPeerId& peer_id) = 0 ;
// get avatar data for peer pid
virtual void getAvatarData(const std::string& pid,unsigned char *& data,int& size) = 0 ;
virtual void getAvatarData(const RsPeerId& pid,unsigned char *& data,int& size) = 0 ;
// set own avatar data
virtual void setOwnAvatarData(const unsigned char *data,int size) = 0 ;
virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
@ -322,11 +327,11 @@ virtual void getOwnAvatarData(unsigned char *& data,int& size) = 0 ;
/****************************************/
virtual bool joinVisibleChatLobby(const ChatLobbyId& lobby_id) = 0 ;
virtual bool isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id) = 0;
virtual bool getVirtualPeerId(const ChatLobbyId& lobby_id,std::string& vpid) = 0;
virtual bool isLobbyId(const RsPeerId& virtual_peer_id,ChatLobbyId& lobby_id) = 0;
virtual bool getVirtualPeerId(const ChatLobbyId& lobby_id,RsPeerId& vpid) = 0;
virtual void getChatLobbyList(std::list<ChatLobbyInfo>& cl_info) = 0;
virtual void getListOfNearbyChatLobbies(std::vector<VisibleChatLobbyRecord>& public_lobbies) = 0 ;
virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const std::string& peer_id) = 0;
virtual void invitePeerToLobby(const ChatLobbyId& lobby_id,const RsPeerId& peer_id) = 0;
virtual bool acceptLobbyInvite(const ChatLobbyId& id) = 0 ;
virtual void denyLobbyInvite(const ChatLobbyId& id) = 0 ;
virtual void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) = 0;
@ -337,19 +342,19 @@ virtual bool setDefaultNickNameForChatLobby(const std::string& nick) = 0;
virtual bool getDefaultNickNameForChatLobby(std::string& nick) = 0 ;
virtual void setLobbyAutoSubscribe(const ChatLobbyId& lobby_id, const bool autoSubscribe) = 0 ;
virtual bool getLobbyAutoSubscribe(const ChatLobbyId& lobby_id) = 0 ;
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<std::string>& invited_friends,uint32_t lobby_privacy_type) = 0 ;
virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::string& lobby_topic,const std::list<RsPeerId>& invited_friends,uint32_t lobby_privacy_type) = 0 ;
/****************************************/
/* Distant chat */
/****************************************/
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
virtual bool createDistantChatInvite(const RsPgpId& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) = 0;
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) = 0;
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) = 0;
virtual bool closeDistantChatConnexion(const std::string& hash) = 0;
virtual bool removeDistantChatInvite(const std::string& hash) = 0 ;
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,DistantChatPeerId& pid,uint32_t& error_code) = 0;
virtual bool initiateDistantChatConnexion(const DistantChatPeerId& pid,uint32_t& error_code) = 0;
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,uint32_t& status,RsPgpId& pgp_id) = 0;
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid) = 0;
virtual bool removeDistantChatInvite(const DistantChatPeerId& pid) = 0 ;
};

View file

@ -32,6 +32,7 @@
#include <retroshare/rstypes.h>
#include <retroshare/rsfiles.h>
#include <retroshare/rsids.h>
/* The Main Interface Class - for information about your Peers
* A peer is another RS instance, means associated with an SSL certificate
@ -186,18 +187,19 @@ class RsPeerDetails
/* Auth details */
bool isOnlyGPGdetail;
std::string id;
std::string gpg_id;
RsPeerId id;
RsPgpId gpg_id;
std::string name;
std::string email;
std::string location;
std::string org;
std::string issuer;
RsPgpId issuer;
std::string fpr; /* pgp fingerprint */
std::string authcode;
std::list<std::string> gpgSigners;
PGPFingerprintType fpr; /* pgp fingerprint */
std::string authcode; // (cyril) what is this used for ?????
std::list<RsPgpId> gpgSigners;
uint32_t trustLvl;
uint32_t validLvl;
@ -272,7 +274,7 @@ public:
std::string name;
uint32_t flag;
std::list<std::string> peerIds;
std::list<RsPgpId> peerIds;
};
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
@ -289,54 +291,53 @@ class RsPeers
virtual bool OthersChanged() = 0;
/* Peer Details (Net & Auth) */
virtual std::string getOwnId() = 0;
virtual const RsPeerId& getOwnId() = 0;
virtual bool haveSecretKey(const std::string& gpg_id) = 0 ;
virtual bool haveSecretKey(const RsPgpId& gpg_id) = 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 getOnlineList(std::list<RsPeerId> &ssl_ids) = 0;
virtual bool getFriendList(std::list<RsPeerId> &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 RsPeerId &ssl_id) = 0;
virtual bool isFriend(const RsPeerId &ssl_id) = 0;
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0; //
virtual std::string getPeerName(const RsPeerId &ssl_id) = 0;
virtual std::string getGPGName(const RsPgpId& gpg_id) = 0;
virtual bool getPeerDetails(const RsPeerId& ssl_id, RsPeerDetails &d) = 0;
virtual bool getGPGDetails(const RsPgpId& gpg_id, RsPeerDetails &d) = 0;
/* 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 const RsPgpId& getGPGOwnId() = 0;
virtual RsPgpId getGPGId(const RsPeerId& sslid) = 0; //return the gpg id of the given ssl id
virtual bool isKeySupported(const RsPgpId& gpg_ids) = 0;
virtual bool getGPGAcceptedList(std::list<RsPgpId> &gpg_ids) = 0;
virtual bool getGPGSignedList(std::list<RsPgpId> &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<RsPgpId> &gpg_ids) = 0;
virtual bool getGPGAllList(std::list<RsPgpId> &gpg_ids) = 0;
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId>& ids) = 0;
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0;
/* Add/Remove Friends */
virtual bool addFriend(const std::string &ssl_id, const std::string &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL) = 0;
virtual bool removeFriend(const std::string &ssl_or_gpg_id) = 0;
virtual bool removeFriendLocation(const std::string &sslId) = 0;
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_SERVICE_PERM_ALL) = 0;
virtual bool removeFriend(const RsPgpId& pgp_id) = 0;
virtual bool removeFriendLocation(const RsPeerId& sslId) = 0;
/* keyring management */
virtual bool removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code)=0 ;
virtual bool removeKeysFromPGPKeyring(const std::list<RsPgpId>& pgp_ids,std::string& backup_file,uint32_t& error_code)=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 connectAttempt(const RsPeerId& ssl_id) = 0;
virtual bool setLocation(const RsPeerId &ssl_id, const std::string &location) = 0;//location is shown in the gui to differentiate ssl certs
virtual bool setHiddenNode(const std::string &id, const std::string &hidden_node_address) = 0;
virtual bool setHiddenNode(const std::string &id, const std::string &address, uint16_t port) = 0;
virtual bool setHiddenNode(const RsPeerId &id, const std::string &hidden_node_address) = 0;
virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) = 0;
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, uint16_t vs_disc, uint16_t vs_dht) = 0;
virtual bool setLocalAddress(const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setExtAddress( const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setDynDNS(const RsPeerId &id, const std::string &addr) = 0;
virtual bool setNetworkMode(const RsPeerId &ssl_id, uint32_t netMode) = 0;
virtual bool setVisState(const RsPeerId &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0;
virtual bool getProxyServer(std::string &addr, uint16_t &port) = 0;
virtual bool setProxyServer(const std::string &addr, const uint16_t port) = 0;
@ -346,24 +347,25 @@ class RsPeers
virtual bool getAllowServerIPDetermination() = 0 ;
/* Auth Stuff */
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures) = 0;
virtual bool GetPGPBase64StringAndCheckSum(const std::string& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0 ;
virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) = 0;
virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) = 0;
virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0 ;
virtual std::string GetRetroshareInvite(bool include_signatures) = 0;
virtual bool hasExportMinimal() = 0 ;
// Add keys to the keyring
virtual bool loadCertificateFromString(const std::string& cert, std::string& ssl_id,std::string& pgp_id, std::string& error_string) = 0;
virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, 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,uint32_t& error_code) = 0;
// Certificate utils
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 saveCertificateToFile(const RsPeerId& id, const std::string &fname) = 0;
virtual std::string saveCertificateToString(const RsPeerId &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 RsPgpId &gpg_id) = 0;
virtual bool trustGPGCertificate(const RsPgpId &gpg_id, uint32_t trustlvl) = 0;
/* Group Stuff */
virtual bool addGroup(RsGroupInfo &groupInfo) = 0;
@ -372,8 +374,8 @@ class RsPeers
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;
virtual bool assignPeerToGroup(const std::string &groupId, const RsPgpId& peerId, bool assign) = 0;
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<RsPgpId> &peerIds, bool assign) = 0;
/* Group sharing permission */
@ -386,13 +388,13 @@ class RsPeers
// ... 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;
virtual FileSearchFlags computePeerPermissionFlags(const RsPeerId& peer_id,FileStorageFlags file_sharing_flags,const std::list<std::string>& file_parent_groups) = 0;
/* Service permission flags */
virtual ServicePermissionFlags servicePermissionFlags(const std::string& gpg_id) = 0;
virtual ServicePermissionFlags servicePermissionFlags_sslid(const std::string& ssl_id) = 0;
virtual void setServicePermissionFlags(const std::string& gpg_id,const ServicePermissionFlags& flags) = 0;
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) = 0;
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) = 0;
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) = 0;
};
#endif

View file

@ -186,9 +186,9 @@ class RsPluginHandler
virtual int nbPlugins() const = 0 ;
virtual RsPlugin *plugin(int i) = 0 ;
virtual const std::vector<std::string>& getPluginDirectories() const = 0;
virtual void getPluginStatus(int i,uint32_t& status,std::string& file_name,std::string& file_hash,uint32_t& svn_revision,std::string& error_string) const = 0 ;
virtual void enablePlugin(const std::string& hash) = 0;
virtual void disablePlugin(const std::string& hash) = 0;
virtual void getPluginStatus(int i,uint32_t& status,std::string& file_name,RsFileHash& file_hash,uint32_t& svn_revision,std::string& error_string) const = 0 ;
virtual void enablePlugin(const RsFileHash& hash) = 0;
virtual void disablePlugin(const RsFileHash& hash) = 0;
virtual void allowAllPlugins(bool b) = 0 ;
virtual bool getAllowAllPlugins() const = 0 ;

View file

@ -29,6 +29,7 @@
#include <inttypes.h>
#include <string>
#include <list>
#include <retroshare/rstypes.h>
/* The Main Interface Class - for information about your Peers */
class RsRtt;
@ -56,7 +57,7 @@ class RsRtt
RsRtt() { return; }
virtual ~RsRtt() { return; }
virtual uint32_t getPongResults(std::string id, int n, std::list<RsRttPongResult> &results) = 0;
virtual uint32_t getPongResults(const RsPeerId& id, int n, std::list<RsRttPongResult> &results) = 0;
};

View file

@ -34,6 +34,7 @@ extern RsStatus *rsStatus;
#include <string>
#include <inttypes.h>
#include <list>
#include <retroshare/rstypes.h>
const uint32_t RS_STATUS_OFFLINE = 0x0000;
@ -58,7 +59,7 @@ class StatusInfo
}
public:
std::string id;
RsPeerId id;
uint32_t status;
time_t time_stamp; /// for owner time set, and for their peers time sent
};
@ -88,7 +89,7 @@ class RsStatus
* This retrieves the status info one peer
* @param statusInfo is populated with client's peer's status
*/
virtual bool getStatus(const std::string &id, StatusInfo &statusInfo) = 0;
virtual bool getStatus(const RsPeerId &id, StatusInfo &statusInfo) = 0;
/**
* send the client's status to his/her peers
@ -96,7 +97,7 @@ class RsStatus
* @param status the status of the peers
* @return will return false if status info does not belong to client
*/
virtual bool sendStatus(const std::string &id, uint32_t status) = 0;
virtual bool sendStatus(const RsPeerId &id, uint32_t status) = 0;
};

View file

@ -33,6 +33,8 @@
#include <list>
#include <vector>
#include "retroshare/rstypes.h"
class LinearizedExpression ;
class RsTurtleClientService ;
@ -46,7 +48,7 @@ typedef uint32_t TurtleRequestId ;
struct TurtleFileInfo
{
std::string hash ;
RsFileHash hash ;
std::string name ;
uint64_t size ;
};
@ -54,7 +56,7 @@ struct TurtleFileInfo
struct TurtleRequestDisplayInfo
{
uint32_t request_id ; // Id of the request
std::string source_peer_id ; // Peer that relayed the request
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.
};
@ -108,12 +110,12 @@ class RsTurtle
// tunnels for the given hash. The download should be driven by the file
// transfer module by calling ftServer::FileRequest().
//
virtual void monitorTunnels(const std::string& file_hash,RsTurtleClientService *client_service) = 0 ;
virtual void monitorTunnels(const RsFileHash& file_hash,RsTurtleClientService *client_service) = 0 ;
// Tells the turtle router to stop handling tunnels for the given file hash. Traditionally this should
// be called after calling ftServer::fileCancel().
//
virtual void stopMonitoringTunnels(const std::string& file_hash) = 0 ;
virtual void stopMonitoringTunnels(const RsFileHash& file_hash) = 0 ;
/// Adds a client tunnel service. This means that the service will be added
/// to the list of services that might respond to tunnel requests.
@ -134,7 +136,7 @@ class RsTurtle
virtual void getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const = 0;
// Convenience function.
virtual bool isTurtlePeer(const std::string& peer_id) const = 0 ;
virtual bool isTurtlePeer(const RsPeerId& peer_id) const = 0 ;
// Hardcore handles
virtual void setMaxTRForwardRate(int max_tr_up_rate) = 0 ;

View file

@ -33,16 +33,22 @@
#include <iostream>
#include <string>
#include <stdint.h>
#include <util/rsid.h>
#include <retroshare/rsids.h>
#include <retroshare/rsflags.h>
#define USE_NEW_CHUNK_CHECKING_CODE
typedef std::string RsCertId;
typedef std::string RsChanId;
typedef std::string RsMsgId;
typedef std::string RsAuthId;
// This adds a level of indirection to types, so we can easily change them if needed
//
//typedef std::string RsCertId; // unused
//typedef std::string RsChanId;
//typedef std::string RsMsgId;
//typedef std::string RsAuthId;
typedef SSLIdType RsPeerId ;
typedef PGPIdType RsPgpId ;
typedef Sha1CheckSum RsFileHash ;
const uint32_t FT_STATE_FAILED = 0x0000 ;
const uint32_t FT_STATE_OKAY = 0x0001 ;
@ -61,30 +67,11 @@ const uint32_t RS_CONFIG_DIRECTORY = 0x0002 ;
const uint32_t RS_PGP_DIRECTORY = 0x0003 ;
const uint32_t RS_DIRECTORY_COUNT = 0x0004 ;
//class Sha1CheckSum
//{
// public:
// Sha1CheckSum() {}
// explicit Sha1CheckSum(const uint8_t *twenty_bytes_digest) ; // inits form a 20-bytes digest.
// explicit Sha1CheckSum(const std::string& fourty_bytes_string) ; // inits form a 40 bytes hexadecimal string.
//
// static Sha1CheckSum random() ;
//
// std::string toStdString() const ;
//
// bool operator==(const Sha1CheckSum& s) const ;
// bool operator<(const Sha1CheckSum& s) const ;
//
// friend std::ostream& operator<<(std::ostream& out,const Sha1CheckSum& sum) { return out << sum.toStdString() ; }
//// private:
// uint32_t fourbytes[5] ;
//};
class TransferInfo
{
public:
/**** Need Some of these Fields ****/
std::string peerId;
RsPeerId peerId;
std::string name; /* if has alternative name? */
double tfRate; /* kbytes */
int status; /* FT_STATE_... */
@ -130,13 +117,13 @@ class Condition
std::string name;
};
class SearchRequest
{
public:
int searchId;
RsCertId toId; /* all zeros for everyone! */
std::list<Condition> tests;
};
//class SearchRequest // unused stuff.
//{
// public:
// int searchId;
// RsCertId toId; /* all zeros for everyone! */
// std::list<Condition> tests;
//};
/********************** For FileCache Interface *****************/
@ -173,7 +160,7 @@ class FileInfo
public:
FileInfo() : mId(0) { return; }
RsCertId id; /* key for matching everything */
// 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_*
@ -194,7 +181,7 @@ class FileInfo
int searchId; /* 0 if none */
std::string path;
std::string fname;
std::string hash;
RsFileHash hash;
std::string ext;
uint64_t size;
@ -235,9 +222,9 @@ class DirDetails
void *ref;
uint8_t type;
std::string id;
RsPeerId id;
std::string name;
std::string hash;
RsFileHash hash;
std::string path;
uint64_t count;
uint32_t age;
@ -251,9 +238,9 @@ class DirDetails
class FileDetail
{
public:
std::string id;
RsPeerId id;
std::string name;
std::string hash;
RsFileHash hash;
std::string path;
uint64_t size;
uint32_t age;
@ -272,7 +259,7 @@ class FileChunksInfo
{
uint32_t start ;
uint32_t size ;
std::string peer_id ;
RsPeerId peer_id ;
};
uint64_t file_size ; // real size of the file
@ -283,7 +270,7 @@ class FileChunksInfo
std::vector<ChunkState> chunks ;
// For each source peer, gives the compressed bit map of have/don't have sate
std::map<std::string, CompressedChunkMap> compressed_peer_availability_maps ;
std::map<RsPeerId, CompressedChunkMap> compressed_peer_availability_maps ;
// For each chunk (by chunk number), gives the completion of the chunk.
//
@ -380,14 +367,14 @@ typedef t_CRCMap<Sha1CheckSum> Sha1Map ;
class DwlDetails {
public:
DwlDetails() { return; }
DwlDetails(std::string fname, std::string hash, int count, std::string dest,
DwlDetails(const std::string& fname, const RsFileHash& hash, int count, std::string dest,
uint32_t flags, std::list<std::string> srcIds, uint32_t queue_pos)
: fname(fname), hash(hash), count(count), dest(dest), flags(flags),
srcIds(srcIds), queue_position(queue_pos), retries(0) { return; }
/* download details */
std::string fname;
std::string hash;
RsFileHash hash;
int count;
std::string dest;
uint32_t flags;