Major Rewrite of the New Cache Based Services.

- Defined a generalised Group/Msg retrieval interface (RsTokenService), which is defined in rsidentity.h
	- Defined MetaData for both Groups and Messages (not finalised yet).
	- Implemented a general Data Backend for Local Testing of interface - inside p3gxsservice.cc
	- Modified services to use this temporary backend.
	- Added Wire and ForumV2 services.

Still lots to do:
	- work out request options.
	- finalise metadata.
	- group permissions.
	- identities



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5219 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-06-14 00:27:28 +00:00
parent 441a51757f
commit 4ba7130884
20 changed files with 4163 additions and 1116 deletions

View file

@ -30,6 +30,8 @@
#include <string>
#include <list>
// FLAGS WILL BE REUSED FROM RSDISTRIB -> FOR NOW.
#include <retroshare/rsdistrib.h>
/********** Generic Token Request Interface ***********************
* This is packaged here, as most TokenServices will require ID Services too.
@ -37,12 +39,33 @@
*/
// This bit will be filled out over time.
#define RS_TOKREQOPT_MSG_VERSIONS 0x0001
#define RS_TOKREQOPT_MSG_ORIGMSG 0x0002
#define RS_TOKREQOPT_MSG_LATEST 0x0003
#define RS_TOKREQOPT_MSG_VERSIONS 0x0001 // MSGRELATED: Returns All MsgIds with OrigMsgId = MsgId.
#define RS_TOKREQOPT_MSG_ORIGMSG 0x0002 // MSGLIST: All Unique OrigMsgIds in a Group.
#define RS_TOKREQOPT_MSG_LATEST 0x0004 // MSGLIST: All Latest MsgIds in Group. MSGRELATED: Latest MsgIds for Input Msgs.
#define RS_TOKREQOPT_MSG_THREAD 0x0010 // MSGRELATED: All Msgs in Thread. MSGLIST: All Unique Thread Ids in Group.
#define RS_TOKREQOPT_MSG_PARENT 0x0020 // MSGRELATED: All Children Msgs.
#define RS_TOKREQOPT_MSG_AUTHOR 0x0040 // MSGLIST: Messages from this AuthorId
// Read Status.
#define RS_TOKREQOPT_READ 0x0001
#define RS_TOKREQOPT_UNREAD 0x0002
#define RS_TOKREQ_ANSTYPE_LIST 0x0001
#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002
#define RS_TOKREQ_ANSTYPE_DATA 0x0003
// TEMP FLAGS... TO FIX.
#define RSGXS_MSG_STATUS_MASK 0x000f
#define RSGXS_MSG_STATUS_READ 0x0001
#define RSGXS_MSG_STATUS_UNREAD_BY_USER 0x0002
#define RS_TOKREQOPT_MSG_THREAD 0x0004
#define RS_TOKREQOPT_MSG_PARENT 0x0005
class RsTokReqOptions
{
@ -54,6 +77,80 @@ class RsTokReqOptions
time_t mAfter;
};
class RsGroupMetaData
{
public:
RsGroupMetaData()
{
mGroupFlags = 0;
mSubscribeFlags = 0;
mPop = 0;
mMsgCount = 0;
mLastPost = 0;
mGroupStatus = 0;
}
std::string mGroupId;
std::string mGroupName;
uint32_t mGroupFlags;
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
uint32_t mSubscribeFlags;
uint32_t mPop; // HOW DO WE DO THIS NOW.
uint32_t mMsgCount; // ???
time_t mLastPost; // ???
uint32_t mGroupStatus;
};
class RsMsgMetaData
{
public:
RsMsgMetaData()
{
mPublishTs = 0;
mMsgFlags = 0;
mMsgStatus = 0;
mChildTs = 0;
}
std::string mGroupId;
std::string mMsgId;
std::string mThreadId;
std::string mParentId;
std::string mOrigMsgId;
std::string mAuthorId;
std::string mMsgName;
time_t mPublishTs;
uint32_t mMsgFlags; // Whats this for?
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
// normally READ / UNREAD flags. LOCAL Data.
uint32_t mMsgStatus;
time_t mChildTs;
};
std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta);
std::ostream &operator<<(std::ostream &out, const RsMsgMetaData &meta);
class RsTokenService
{
public:
@ -62,16 +159,45 @@ class RsTokenService
virtual ~RsTokenService() { return; }
/* Data Requests */
virtual bool requestGroupList( uint32_t &token, const RsTokReqOptions &opts) = 0;
virtual bool requestMsgList( uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &groupIds) = 0;
virtual bool requestMsgRelatedList(uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &msgIds) = 0;
virtual bool requestGroupInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds) = 0;
virtual bool requestMsgInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds) = 0;
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &msgIds) = 0;
/* Generic Lists */
virtual bool getGroupList( const uint32_t &token, std::list<std::string> &groupIds) = 0;
virtual bool getMsgList( const uint32_t &token, std::list<std::string> &msgIds) = 0;
/* Generic Summary */
virtual bool getGroupSummary( const uint32_t &token, std::list<RsGroupMetaData> &groupInfo) = 0;
virtual bool getMsgSummary( const uint32_t &token, std::list<RsMsgMetaData> &msgInfo) = 0;
/* Actual Data -> specific to Interface */
virtual bool requestGroupData( uint32_t &token, const std::list<std::string> &groupIds) = 0;
virtual bool requestMsgData( uint32_t &token, const std::list<std::string> &msgIds) = 0;
/* Poll */
virtual uint32_t requestStatus(const uint32_t token) = 0;
/* Cancel Request */
virtual bool cancelRequest(const uint32_t &token) = 0;
//////////////////////////////////////////////////////////////////////////////
/* Functions from Forums -> need to be implemented generically */
virtual bool groupsChanged(std::list<std::string> &groupIds) = 0;
// Get Message Status - is retrived via MessageSummary.
virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask) = 0;
//
virtual bool groupSubscribe(const std::string &groupId, bool subscribe) = 0;
virtual bool groupRestoreKeys(const std::string &groupId) = 0;
virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers) = 0;
};
@ -95,12 +221,16 @@ extern RsIdentity *rsIdentity;
std::string rsIdTypeToString(uint32_t idtype);
class RsIdData
class RsIdGroup
{
public:
std::string mNickname;
std::string mKeyId;
RsGroupMetaData mMeta;
// In GroupMetaData.
//std::string mNickname; (mGroupName)
//std::string mKeyId; (mGroupId)
uint32_t mIdType;
@ -112,6 +242,27 @@ class RsIdData
std::string mGpgEmail; // if known.
};
class RsIdMsg
{
public:
RsMsgMetaData mMeta;
// In MsgMetaData.
//std::string mKeyId; (mGroupId)
//std::string mPeerId; (mAuthorId) ???
int mRating;
int mPeersRating;
std::string mComment;
};
#if 0
class RsIdReputation
{
public:
@ -137,8 +288,10 @@ class RsIdOpinion
std::string mComment;
};
#endif
class RsIdentity
class RsIdentity: public RsTokenService
{
public:
@ -149,8 +302,30 @@ virtual ~RsIdentity() { return; }
/* changed? */
virtual bool updated() = 0;
/* Interface now a request / poll / answer system */
/* INCLUDES INTERFACE FROM RS TOKEN SERVICE */
//////////////////////////////////////////////////////////////////////////////
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, RsIdGroup &group) = 0;
virtual bool getMsgData(const uint32_t &token, RsIdMsg &msg) = 0;
virtual bool createGroup(RsIdGroup &group) = 0;
virtual bool createMsg(RsIdMsg &msg) = 0;
/* In the Identity System - You don't access the Messages Directly.
* as they represent idividuals opinions....
* This is reflected in the TokenService calls returning false.
*
* Below is the additional interface to look at reputation.
*/
virtual void generateDummyData() = 0;
#if 0
/* Data Requests */
virtual bool requestIdentityList(uint32_t &token) = 0;
virtual bool requestIdentities(uint32_t &token, const std::list<std::string> &ids) = 0;
@ -171,8 +346,8 @@ virtual bool getIdPeerOpinion(const uint32_t token, RsIdOpinion &opinion) = 0;
virtual bool updateIdentity(RsIdData &data) = 0;
virtual bool updateOpinion(RsIdOpinion &opinion) = 0;
/* TEMP */
virtual void generateDummyData() = 0;
#endif
};