Added first pass at new RsIdentity service.

* Updated rgixs with new interfaces. (tentative)
 * Switched rsIdentity to GXS basis.
 * Added Subscribe Function to rsGxsIfaceImpl + return false to functions.
 
This code needs to be reviewed by chris ASAP, to see how it fits into the whole structure.
This code is currently not compiled, or compilable.




git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5677 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-10-14 18:32:33 +00:00
parent b35645a0ea
commit 1ec5c7fe69
6 changed files with 321 additions and 420 deletions

View File

@ -60,6 +60,131 @@
*/
/******
* More notes. The ideas above have been crystalised somewhat.
*
* The Identity service will now serve two roles:
* 1) validating msgs.
* 2) reputation of identity.
*
* The identity will be equivalent to a Group Definition.
* and the reputation contained in the group's messages.
*
*
* Group
* MetaData:
* Public Key
* Signatures. (Admin & optional GPG).
* RealData:
* Nickname.
* GPGHash
*
* The GPGHash will allow people to identify the real gpg user behind the identity.
* We must make sure that the Hash input has enough entropy that it cannot be brute-forced (e.g. like password hashes).
*
* The Identity service only has to provide hooks to access the Keys for each group.
* All the key definitions are exactly the same as for GroupMetaData.
*
* The Interface is split into three parts.
* 1) Internal interface used by GXS to verify signatures.
* 2) Internal interface used by GXS to help decide if we get a message or not.
* 3) External interface to access nicknames, generate new identities etc.
*
* The actual implementation will cache frequently used keys and nicknames,
* as these will be used very frequently.
*****/
typedef std::string GxsId;
typedef std::string PeerId;
// External Interface -
class RsIdentityService
{
enum IdentityType { Pseudonym, Signed, Anonymous };
virtual bool loadId(const GxsId &id) = 0;
virtual bool getNickname(const GxsId &id, std::string &nickname) = 0;
virtual bool createKey(RsGixsProfile& profile, uint32_t type) = 0; /* fills in mKeyId, and signature */
virtual RsGixsProfile* getProfile(const KeyRef& keyref) = 0;
// modify reputation.
};
/* Identity Interface for GXS Message Verification.
*/
class RsGixs
{
public:
// Key related interface - used for validating msgs and groups.
/*!
* Use to query a whether given key is available by its key reference
* @param keyref the keyref of key that is being checked for
* @return true if available, false otherwise
*/
virtual bool haveKey(const GxsId &id) = 0;
/*!
* Use to query whether private key member of the given key reference is available
* @param keyref the KeyRef of the key being checked for
* @return true if private key is held here, false otherwise
*/
virtual bool havePrivateKey(const GxsId &id) = 0;
// The fetchKey has an optional peerList.. this is people that had the msg with the signature.
// These same people should have the identity - so we ask them first.
/*!
* Use to request a given key reference
* @param keyref the KeyRef of the key being requested
* @return will
*/
virtual bool requestKey(const GxsId &id, const std::list<PeerId> &peers) = 0;
/*!
* Retrieves a key identity
* @param keyref
* @return a pointer to a valid profile if successful, otherwise NULL
*
*/
virtual int getKey(const GxsId &id, TlvSecurityKey &key) = 0;
virtual int getPrivateKey(const GxsId &id, TlvSecurityKey &key) = 0; // For signing outgoing messages.
};
class RsGixsReputation
{
public:
// get Reputation.
virtual bool getReputation(const GxsId &id, const GixsReputation &rep) = 0;
};
/*** This Class pulls all the GXS Interfaces together ****/
class RsGxsIdExchange: public RsGenExchange, public RsGixsReputation, public RsGixs
{
public:
RsGxsIdExchange() { return; }
virtual ~RsGxsIdExchange() { return; }
};
// BELOW IS OLD - WILL DELETE SHORTLY
#if 0
/*!
* Storage class for private and public publish keys
*
@ -227,5 +352,7 @@ public:
};
#endif // END OF #if 0
#endif // RSGIXS_H

View File

@ -29,12 +29,14 @@ bool RsGxsIfaceImpl::getGroupList(const uint32_t &token,
std::list<RsGxsGroupId> &groupIds)
{
return false;
}
bool RsGxsIfaceImpl::getMsgList(const uint32_t &token,
GxsMsgIdResult& msgIds)
{
return false;
}
/* Generic Summary */
@ -42,20 +44,31 @@ bool RsGxsIfaceImpl::getGroupSummary(const uint32_t &token,
std::list<RsGroupMetaData> &groupInfo)
{
return false;
}
bool RsGxsIfaceImpl::getMsgSummary(const uint32_t &token,
GxsMsgMetaMap &msgInfo)
{
return false;
}
bool RsGxsIfaceImpl::subscribeToAlbum(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe)
{
return false;
}
bool RsGxsIfaceImpl::acknowledgeMsg(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
{
return false;
}
bool RsGxsIfaceImpl::acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId)
{
return false;
}

View File

@ -23,26 +23,66 @@ public:
/** Requests **/
/*!
*
* @param grpIds
*/
void groupsChanged(std::list<RsGxsGroupId>& grpIds);
/*!
*
* @param msgs
*/
void msgsChanged(std::map<RsGxsGroupId,
std::vector<RsGxsMessageId> >& msgs);
RsTokenService* getTokenService();
/* Generic Lists */
/*!
*
* @param token token to be redeemed for this request
* @param groupIds the ids return for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getGroupList(const uint32_t &token,
std::list<RsGxsGroupId> &groupIds);
/*!
* @param token token to be redeemed for this request
* @param msgIds the ids return for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getMsgList(const uint32_t &token,
GxsMsgIdResult& msgIds);
/* Generic Summary */
/*!
* @param token token to be redeemed for group summary request
* @param groupInfo the ids returned for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getGroupSummary(const uint32_t &token,
std::list<RsGroupMetaData> &groupInfo);
/*!
* @param token token to be redeemed for message summary request
* @param msgInfo the message metadata returned for given request token
* @return false if request token is invalid, check token status for error report
*/
bool getMsgSummary(const uint32_t &token,
GxsMsgMetaMap &msgInfo);
/*!
* subscribes to group, and returns token which can be used
* to be acknowledged to get group Id
* @param token token to redeem for acknowledgement
* @param grpId the id of the group to subscribe to
*/
virtual bool subscribeToAlbum(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe);
/*!
* This allows the client service to acknowledge that their msgs has
* been created/modified and retrieve the create/modified msg ids

View File

@ -11,8 +11,6 @@ CONFIG += test_voip
# GXS Stuff.
CONFIG += newcache
CONFIG += newservices
#CONFIG += newcache
#CONFIG += newservices
# Beware: All data of the stripped services are lost
DEFINES *= PQI_DISABLE_TUNNEL

View File

@ -10,7 +10,7 @@
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -29,336 +29,7 @@
#include <inttypes.h>
#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.
* The requests can be generic, but the reponses are service specific (dependent on data types).
*/
// This bit will be filled out over time.
#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
// Status Filtering... should it be a different Option Field.
#define RS_TOKREQOPT_GROUP_UPDATED 0x0100 // GROUPLIST: Groups that have been updated.
#define RS_TOKREQOPT_MSG_UPDATED 0x0200 // MSGLIST: Msg that have been updated from specified groups.
#define RS_TOKREQOPT_MSG_UPDATED 0x0200 // MSGLIST: Msg that have been updated from specified groups.
// 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
#define RS_TOKREQ_ANSTYPE_ACK 0x0004
class RsTokReqOptions
{
public:
RsTokReqOptions()
{
mOptions = 0;
mStatusFilter = 0; mStatusMask = 0;
mFlagsFilter = 0; mFlagsMask = 0;
mSubscribeFilter = 0;
mBefore = 0; mAfter = 0;
}
uint32_t mOptions;
// Request specific matches with Group / Message Status.
// Should be usable with any Options... applied afterwards.
uint32_t mStatusFilter;
uint32_t mStatusMask;
// MsgFlags or GroupsFlags, depends on Request.
uint32_t mFlagsFilter;
uint32_t mFlagsMask;
uint32_t mSubscribeFilter; // Only for Groups.
// Time range... again applied after Options.
time_t mBefore;
time_t mAfter;
};
/*********************************************************
* Documentation for Groups Definitions.
*
* A Group is defined by:
* - TWO RSA Keys. (Admin Key & Publish Key)
* - Publish TS: Used to select the latest definition.
*
* - Operating Mode:
* - Circle (Public, External, Private).
* - Publish Mode: Encrypted / All-Signed / Only ThreadHead / None Required.
* - AuthorId: GPG Required / Any Required / Only if no Publish Signature.
*
* - Description:
* - Name & Description.
* - Optional AuthorId.
*
* Most of this information is contained inside the GroupMetaData.
* except for Actual Admin / Publish Keys, which are maintained internally.
*
*******
* - Group Definition must be signed by Admin Key, otherwise invalid.
* - Circle Definition controls distribution of Group and Messages, see section on this for more details.
* - Public parts of Keys are distributed with Definition.
* - Private parts can be distributed to select people via alternative channels.
* - A Message Requires at least one signature: publish or Author. This signature will be used as MsgId.
*
* Groups will operate in the following modes:
* 1) Public Forum: PublishMode = None Required, AuthorId: Required.
* 2) Closed Forum: PublishMode = All-Signed, AuthorId: Required.
* 3) Private Forum: PublishMode = Encrypted, AuthorId: Required.
*
* 4) Anon Channel: PublishMode = All-Signed, AuthorId: None.
* 5) Anon Channel with Comments: PublishMode = Only ThreadHead, AuthorId: If No Publish Signature.
* 6) Private Channel: PublishMode = Encrypted.
*
* 7) Personal Photos - with comments: PublishMode = Only ThreadHead, AuthorId: Required.
* 8) Personal Photos - no comments: PublishMode = All-Signed, AuthorId: Required.
*
* 9 ) Public Wiki: PublishMode = None Required, AuthorId: Required.
* 10) Closed Wiki: PublishMode = All-Signed, AuthorId: Required.
* 11) Private Wiki: PublishMode = Encrypted, AuthorId: Required.
*
* 12) Twitter: PublishMode = Only ThreadHead, AuthorId: Required.
*
* 13) Posted: PublishMode = None Required, AuthorId: Required.
*
*
******
*
* Additionally to this information. The MetaData also contains several fields which can
* be used to store local information for the benefit of the service.
*
* In Particular: MsgStatus & GroupStatus inform the service if the user has read the message or if anything has changed.
*
***/
// Control of Publish Signatures.
#define RSGXS_GROUP_SIGN_PUBLISH_MASK 0x000000ff
#define RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED 0x00000001
#define RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED 0x00000002
#define RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD 0x00000004
#define RSGXS_GROUP_SIGN_PUBLISH_NONEREQ 0x00000008
// Author Signature.
#define RSGXS_GROUP_SIGN_AUTHOR_MASK 0x0000ff00
#define RSGXS_GROUP_SIGN_AUTHOR_GPG 0x00000100
#define RSGXS_GROUP_SIGN_AUTHOR_REQUIRED 0x00000200
#define RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN 0x00000400
#define RSGXS_GROUP_SIGN_AUTHOR_NONE 0x00000800
// NB: That one signature is required...
// so some combinations are not possible. e.g.
// SIGN_PUBLISH_NONEREQ && SIGN_AUTHOR_NONE is not allowed.
// SIGN_PUBLISH_THREADHEAD && SIGN_AUTHOR_NONE is also invalid.
#define RSGXS_GROUP_SIGN_RESERVED_MASK 0xffff0000
// STATUS FLAGS: There is space here for Service specific flags - if they so desire.
//
// Msgs: UNREAD_BY_USER & PROCESSED are useful.
// Groups: NEW_MESSAGES & GROUP_UPDATED.
#define RSGXS_MSG_STATUS_MASK 0x0000000f
#define RSGXS_MSG_STATUS_READ 0x00000001 // New or Not New
#define RSGXS_MSG_STATUS_UNREAD_BY_USER 0x00000002
#define RSGXS_MSG_STATUS_UNPROCESSED 0x00000004 // By the Service.
#define RSGXS_MSG_STATUS_SERVICE_MASK 0xffff0000
#define RSGXS_GROUP_STATUS_MASK 0x0000000f
#define RSGXS_GROUP_STATUS_UPDATED 0x00000001
#define RSGXS_GROUP_STATUS_NEWGROUP 0x00000002
#define RSGXS_GROUP_STATUS_NEWMSG 0x00000004
#define RSGXS_GROUP_STATUS_SERVICE_MASK 0xffff0000
// Subscription Flags. (LOCAL)
#define RSGXS_GROUP_SUBSCRIBE_MASK 0x0000000f
#define RSGXS_GROUP_SUBSCRIBE_ADMIN 0x00000001
#define RSGXS_GROUP_SUBSCRIBE_PUBLISH 0x00000002
#define RSGXS_GROUP_SUBSCRIBE_SUBSCRIBED 0x00000004
#define RSGXS_GROUP_SUBSCRIBE_MONITOR 0x00000008
// Some MACROS for EASE OF USE. (USED BY FORUMSV2 At the moment.
#define IS_MSG_UNREAD(status) ((status & RSGXS_MSG_STATUS_READ) == 0 || (status & RSGXS_MSG_STATUS_UNREAD_BY_USER))
#define IS_GROUP_ADMIN(subscribeFlags) (subscribeFlags & RSGXS_GROUP_SUBSCRIBE_ADMIN)
#define IS_GROUP_SUBSCRIBED(subscribeFlags) (subscribeFlags & (RSGXS_GROUP_SUBSCRIBE_ADMIN | RSGXS_GROUP_SUBSCRIBE_SUBSCRIBED))
#define RSGXS_MAX_SERVICE_STRING 200 // Sensible limit for dbase usage.
#include "serialiser/rsgxsitems.h"
//class RsGroupMetaData
//{
// public:
//
// RsGroupMetaData()
// {
// mGroupFlags = 0;
// mSignFlags = 0;
// mSubscribeFlags = 0;
//
// mPop = 0;
// mMsgCount = 0;
// mLastPost = 0;
// mGroupStatus = 0;
//
// //mPublishTs = 0;
// }
//
// std::string mGroupId;
// std::string mGroupName;
// uint32_t mGroupFlags; // Service Specific Options ????
// uint32_t mSignFlags; // Combination of RSGXS_GROUP_SIGN_PUBLISH_MASK & RSGXS_GROUP_SIGN_AUTHOR_MASK.
//
// time_t mPublishTs; // Mandatory.
// std::string mAuthorId; // Optional.
//
// // 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;
//
// std::string mServiceString; // Service Specific Free-Form extra storage.
//};
//
//
//
//
//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? (Optional Service Specific - e.g. flag MsgType)
//
// // BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
// // normally READ / UNREAD flags. LOCAL Data.
// uint32_t mMsgStatus;
// time_t mChildTs;
//
// std::string mServiceString; // Service Specific Free-Form extra storage.
//
//};
std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta);
std::ostream &operator<<(std::ostream &out, const RsMsgMetaData &meta);
class RsTokenService
{
public:
RsTokenService() { return; }
virtual ~RsTokenService() { return; }
/* changed? */
virtual bool updated() = 0;
/* Data Requests */
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 */
/* 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 */
// Groups Changed is now part of requestGroupInfo request.
//virtual bool groupsChanged(std::list<std::string> &groupIds) = 0;
// Message/Group Status - is retrived via requests...
// These operations could have a token, but for the moment we are going to assume
// they are async and always succeed - (or fail silently).
virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask) = 0;
virtual bool setGroupStatus(const std::string &grpId, const uint32_t status, const uint32_t statusMask) = 0;
virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask) = 0;
virtual bool setMessageServiceString(const std::string &msgId, const std::string &str) = 0;
virtual bool setGroupServiceString(const std::string &grpId, const std::string &str) = 0;
// (FUTURE WORK).
virtual bool groupRestoreKeys(const std::string &groupId) = 0;
virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers) = 0;
};
#include "rsgxsservice.h"
/* The Main Interface Class - for information about your Peers */
class RsIdentity;
@ -391,7 +62,13 @@ class RsIdGroup
uint32_t mIdType;
std::string mGpgIdHash; // SHA(KeyId + Gpg Fingerprint) -> can only be IDed if GPG known.
// SHA(KeyId + Gpg Fingerprint) -> can only be IDed if GPG known.
// The length of the input must be long enough to make brute force search implausible.
// Easy to do 1e9 SHA-1 hash computations per second on a GPU.
// We will need a minimum of 256 bits, ideally 1024 bits or 2048 bits.
std::string mGpgIdHash;
// NOTE: These cannot be transmitted as part of underlying messages....
// Must use ServiceString.
@ -425,6 +102,7 @@ class RsIdMsg
std::ostream &operator<<(std::ostream &out, const RsIdGroup &meta);
std::ostream &operator<<(std::ostream &out, const RsIdMsg &meta);
typedef std::map<RsGxsGroupId, std::vector<RsIdMsg> > IdMsgResult;
#if 0
@ -456,24 +134,97 @@ class RsIdOpinion
#endif
class RsIdentity: public RsTokenService
class RsIdentity: public RsGxsIfaceImpl
{
public:
RsIdentity() { return; }
virtual ~RsIdentity() { return; }
public:
RsIdentity(RsGenExchange *gxs): RsGxsIfaceImpl(gxs) { return; }
virtual ~RsIdentity() { return; }
/* Specific Service Data */
/*!
* @param token token to be redeemed for album request
* @param album the album returned for given request token
* @return false if request token is invalid, check token status for error report
*/
// virtual bool getAlbum(const uint32_t &token, std::vector<RsPhotoAlbum> &album) = 0;
/*!
* @param token token to be redeemed for photo request
* @param photo the photo returned for given request token
* @return false if request token is invalid, check token status for error report
*/
// virtual bool getPhoto(const uint32_t &token,
// PhotoResult &photo) = 0;
/* details are updated in album - to choose Album ID, and storage path */
/*!
* @param token token to be redeemed for photo request
* @param photo the photo returned for given request token
* @return false if request token is invalid, check token status for error report
*/
// virtual bool getPhotoComment(const uint32_t &token,
// PhotoCommentResult& comments) = 0;
/*!
* submits album, which returns a token that needs
* to be acknowledge to get album grp id
* @param token token to redeem for acknowledgement
* @param album album to be submitted
*/
// virtual bool submitAlbumDetails(uint32_t& token, RsPhotoAlbum &album) = 0;
/*!
* submits photo, which returns a token that needs
* to be acknowledged to get photo msg-grp id pair
* @param token token to redeem for acknowledgement
* @param photo photo to be submitted
*/
// virtual bool submitPhoto(uint32_t& token, RsPhotoPhoto &photo) = 0;
/*!
* submits photo comment, which returns a token that needs
* to be acknowledged to get photo msg-grp id pair
* The mParentId needs to be set to an existing msg for which
* commenting is enabled
* @param token token to redeem for acknowledgement
* @param comment comment to be submitted
*/
// virtual bool submitComment(uint32_t& token, RsPhotoComment &photo) = 0;
/********************************************************************************************/
/********************************************************************************************/
/********************************************************************************************/
/********************************************************************************************/
/********************************************************************************************/
// For Other Services....
// It should be impossible for them to get a message which we don't have the identity.
// Its a major error if we don't have the identity.
// We cache all identities, and provide alternative (instantaneous)
// functions to extract info, rather than the standard Token system.
virtual bool getNickname(const RsId &id, std::string &nickname) = 0;
virtual bool getIdDetails(const RsId &id, RsIdentityDetails &details) = 0;
virtual bool getOwnIds(std::list<RsId> &ownIds) = 0;
//
virtual bool submitOpinion(uint32_t& token, RsIdOpinion &opinion) = 0;
virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params) = 0;
/* INCLUDES INTERFACE FROM RS TOKEN SERVICE */
//////////////////////////////////////////////////////////////////////////////
// Specific RsIdentity Functions....
/* 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 getGroupData(const uint32_t &token, RsIdGroup &group) = 0;
//virtual bool getMsgData(const uint32_t &token, RsIdMsg &msg) = 0;
virtual bool createGroup(uint32_t &token, RsIdGroup &group, bool isNew) = 0;
virtual bool createMsg(uint32_t &token, RsIdMsg &msg, bool isNew) = 0;
//virtual bool createGroup(uint32_t &token, RsIdGroup &group, bool isNew) = 0;
//virtual bool createMsg(uint32_t &token, RsIdMsg &msg, bool isNew) = 0;
/* In the Identity System - You don't access the Messages Directly.
* as they represent idividuals opinions....
@ -530,6 +281,4 @@ virtual bool updateOpinion(RsIdOpinion &opinion) = 0;
};
#endif
#endif // RETROSHARE_IDENTITY_GUI_INTERFACE_H

View File

@ -7,7 +7,7 @@
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -39,24 +39,7 @@
*
*/
class IdDataProxy: public GxsDataProxy
{
public:
bool getGroup(const std::string &id, RsIdGroup &group);
bool getMsg(const std::string &id, RsIdMsg &msg);
bool addGroup(const RsIdGroup &group);
bool addMsg(const RsIdMsg &msg);
/* These Functions must be overloaded to complete the service */
virtual bool convertGroupToMetaData(void *groupData, RsGroupMetaData &meta);
virtual bool convertMsgToMetaData(void *msgData, RsMsgMetaData &meta);
};
// INTERNAL DATA TYPES...
// INTERNAL DATA TYPES.
// Describes data stored in GroupServiceString.
class IdRepCumulScore
{
@ -86,60 +69,53 @@ public:
#define ID_LOCAL_STATUS_FULL_CALC_FLAG 0x00010000
#define ID_LOCAL_STATUS_INC_CALC_FLAG 0x00020000
class p3IdService: public p3GxsDataService, public RsIdentity
// Not sure exactly what should be inherited here?
// Chris - please correct as necessary.
class p3IdService: public RsIdentity, public RsGxsIdExchange
{
public:
p3IdService(RsGeneralDataService* gds, RsNetworkExchangeService* nes);
p3IdService(uint16_t type);
virtual int tick();
public:
virtual int internal_tick(); // needed for background processing.
/* changed? */
virtual bool updated();
/* General Interface is provided by RsIdentity / RsGxsIfaceImpl. */
/* From RsTokenService */
/* Data Requests */
virtual bool requestGroupInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
virtual bool requestMsgInfo( uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
virtual bool requestMsgRelatedInfo(uint32_t &token, uint32_t ansType, const RsTokReqOptions &opts, const std::list<std::string> &msgIds);
/* Data Specific Interface */
/* Generic Lists */
virtual bool getGroupList( const uint32_t &token, std::list<std::string> &groupIds);
virtual bool getMsgList( const uint32_t &token, std::list<std::string> &msgIds);
/* TODO */
/* Generic Summary */
virtual bool getGroupSummary( const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
virtual bool getMsgSummary( const uint32_t &token, std::list<RsMsgMetaData> &msgInfo);
/* Actual Data -> specific to Interface */
virtual bool getGroupData(const uint32_t &token, RsIdGroup &group);
virtual bool getMsgData(const uint32_t &token, RsIdMsg &msg);
/**************** RsGixs Implementation
* Notes:
* Interface is only suggestion at the moment, will be changed as necessary.
* Results should be cached / preloaded for maximum speed.
*
*/
virtual bool haveKey(const GxsId &id);
virtual bool havePrivateKey(const GxsId &id);
virtual bool requestKey(const GxsId &id, const std::list<PeerId> &peers);
virtual int getKey(const GxsId &id, TlvSecurityKey &key);
virtual int getPrivateKey(const GxsId &id, TlvSecurityKey &key);
/* Poll */
virtual uint32_t requestStatus(const uint32_t token);
/* Cancel Request */
virtual bool cancelRequest(const uint32_t &token);
//////////////////////////////////////////////////////////////////////////////
virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask);
virtual bool setGroupStatus(const std::string &groupId, const uint32_t status, const uint32_t statusMask);
virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask);
virtual bool setMessageServiceString(const std::string &msgId, const std::string &str);
virtual bool setGroupServiceString(const std::string &grpId, const std::string &str);
virtual bool groupRestoreKeys(const std::string &groupId);
virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
virtual bool createGroup(uint32_t &token, RsIdGroup &group, bool isNew);
virtual bool createMsg(uint32_t &token, RsIdMsg &msg, bool isNew);
/**************** RsGixsReputation Implementation
* Notes:
* Again should be cached if possible.
*/
// get Reputation.
virtual bool getReputation(const GxsId &id, const GixsReputation &rep);
private:
/************************************************************************
* Below is the background task for processing opinions => reputations
*
*/
virtual void generateDummyData();
std::string genRandomId();
@ -157,8 +133,6 @@ std::string genRandomId();
bool encodeIdGroupCache(std::string &str, const IdGroupServiceStrData &data);
bool extractIdGroupCache(std::string &str, IdGroupServiceStrData &data);
IdDataProxy *mIdProxy;
RsMutex mIdMtx;
/***** below here is locked *****/
@ -170,17 +144,17 @@ std::string genRandomId();
std::map<std::string, RsGroupMetaData> mBgGroupMap;
std::list<std::string> mBgFullCalcGroups;
bool mUpdated;
#if 0
std::map<std::string, RsIdData> mIds;
std::map<std::string, std::map<std::string, RsIdOpinion> > mOpinions;
/************************************************************************
* Other Data that is protected by the Mutex.
*/
std::map<std::string, RsIdReputation> mReputations; // this is created locally.
#endif
std::vector<RsGxsGroupChange*> mGroupChange;
std::vector<RsGxsMsgChange*> mMsgChange;
};
#endif
#endif // P3_IDENTITY_SERVICE_HEADER