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

@ -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