mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-24 23:15:41 -04:00
Added Identity Info retrieval to rsIdentities.
This is now pretty much complete for Phase 1 of GXS. Still todo: - PGPHash signatures. - Reputations. - Added two helper classes GxsTokenQueue: similar to TokenQueue, but for libretroshare & RsTickEvent: schedule one shot events, and basic stats. - Reorganised/simplified p3IdService using these two classes. - Added fns to load/reload a list of Own Identities. - Improved the Cache to store all GUI required Info. - Updater retroshare/rsidentity.h with new Identity interface. - added fns to update Cache from internal background tasks. - Modified RsMemCache to support replace operation. - Found nasty Bug that caused PGPHASHes not to match & Patched same bug in GXS. - added generic CacheArbitration. - Added AuthorIds to dummy Forum messages. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5848 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6e349749d0
commit
c6e6d444bf
13 changed files with 1096 additions and 491 deletions
|
@ -26,6 +26,8 @@
|
|||
#include "services/p3gxsforums.h"
|
||||
#include "serialiser/rsgxsforumitems.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
|
||||
|
||||
#include "gxs/rsgxsflags.h"
|
||||
#include <stdio.h>
|
||||
|
@ -41,6 +43,8 @@
|
|||
RsGxsForums *rsGxsForums = NULL;
|
||||
|
||||
|
||||
#define FORUM_TESTEVENT_DUMMYDATA 0x0001
|
||||
#define DUMMYDATA_PERIOD 60 // long enough for some RsIdentities to be generated.
|
||||
|
||||
/********************************************************************************/
|
||||
/******************* Startup / Tick ******************************************/
|
||||
|
@ -51,6 +55,7 @@ p3GxsForums::p3GxsForums(RsGeneralDataService *gds, RsNetworkExchangeService *ne
|
|||
{
|
||||
// For Dummy Msgs.
|
||||
mGenActive = false;
|
||||
RsTickEvent::schedule_in(FORUM_TESTEVENT_DUMMYDATA, DUMMYDATA_PERIOD);
|
||||
}
|
||||
|
||||
void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
|
@ -61,6 +66,7 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
void p3GxsForums::service_tick()
|
||||
{
|
||||
dummy_tick();
|
||||
RsTickEvent::tick_events();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -400,6 +406,28 @@ bool p3GxsForums::generateMessage(uint32_t &token, const RsGxsGroupId &grpId, co
|
|||
msg.mMeta.mThreadId = threadId;
|
||||
msg.mMeta.mParentId = parentId;
|
||||
|
||||
/* chose a random Id to sign with */
|
||||
std::list<RsGxsId> ownIds;
|
||||
std::list<RsGxsId>::iterator it;
|
||||
|
||||
rsIdentity->getOwnIds(ownIds);
|
||||
|
||||
uint32_t idx = (uint32_t) (ownIds.size() * RSRandom::random_f32());
|
||||
int i = 0;
|
||||
for(it = ownIds.begin(); (it != ownIds.end()) && (i < idx); it++, i++);
|
||||
|
||||
if (it != ownIds.end())
|
||||
{
|
||||
std::cerr << "p3GxsForums::generateMessage() Author: " << *it;
|
||||
std::cerr << std::endl;
|
||||
msg.mMeta.mAuthorId = *it;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3GxsForums::generateMessage() No Author!";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
createMsg(token, msg);
|
||||
|
||||
return true;
|
||||
|
@ -417,3 +445,25 @@ bool p3GxsForums::generateGroup(uint32_t &token, std::string groupName)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Overloaded from RsTickEvent for Event callbacks.
|
||||
void p3GxsForums::handle_event(uint32_t event_type)
|
||||
{
|
||||
std::cerr << "p3GxsForums::handle_event(" << event_type << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// stuff.
|
||||
switch(event_type)
|
||||
{
|
||||
case FORUM_TESTEVENT_DUMMYDATA:
|
||||
generateDummyData();
|
||||
break;
|
||||
|
||||
default:
|
||||
/* error */
|
||||
std::cerr << "p3GxsForums::handle_event() Unknown Event Type: " << event_type;
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "retroshare/rsgxsforums.h"
|
||||
#include "gxs/rsgenexchange.h"
|
||||
|
||||
#include "util/rstickevent.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
@ -37,7 +39,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
class p3GxsForums: public RsGenExchange, public RsGxsForums
|
||||
class p3GxsForums: public RsGenExchange, public RsGxsForums,
|
||||
public RsTickEvent /* only needed for testing - remove after */
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -66,9 +69,14 @@ virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgI
|
|||
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group);
|
||||
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg);
|
||||
|
||||
virtual bool generateDummyData();
|
||||
|
||||
// Overloaded from RsTickEvent.
|
||||
virtual void handle_event(uint32_t event_type);
|
||||
|
||||
private:
|
||||
|
||||
virtual bool generateDummyData();
|
||||
|
||||
std::string genRandomId();
|
||||
|
||||
void dummy_tick();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -31,10 +31,13 @@
|
|||
#include "gxs/rsgenexchange.h" // GXS service.
|
||||
#include "gxs/rsgixs.h" // Internal Interfaces.
|
||||
|
||||
#include "gxs/gxstokenqueue.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "util/rsmemcache.h"
|
||||
#include "util/rstickevent.h"
|
||||
|
||||
#include "pqi/authgpg.h"
|
||||
|
||||
|
@ -132,31 +135,33 @@ class RsGxsIdCache
|
|||
RsGxsIdCache();
|
||||
RsGxsIdCache(const RsGxsIdGroupItem *item, const RsTlvSecurityKey &in_pkey);
|
||||
|
||||
RsGxsId id;
|
||||
std::string name;
|
||||
RsTlvSecurityKey pubkey;
|
||||
double reputation;
|
||||
time_t lastUsedTs;
|
||||
void updateServiceString(std::string serviceString);
|
||||
|
||||
RsIdentityDetails details;
|
||||
RsTlvSecurityKey pubkey;
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
class LruData
|
||||
{
|
||||
public:
|
||||
RsGxsId key;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// Not sure exactly what should be inherited here?
|
||||
// Chris - please correct as necessary.
|
||||
|
||||
class p3IdService: public RsGxsIdExchange, public RsIdentity
|
||||
class p3IdService: public RsGxsIdExchange, public RsIdentity,
|
||||
public GxsTokenQueue, public RsTickEvent
|
||||
{
|
||||
public:
|
||||
p3IdService(RsGeneralDataService* gds, RsNetworkExchangeService* nes);
|
||||
|
||||
|
||||
virtual void service_tick(); // needed for background processing.
|
||||
|
||||
|
||||
|
@ -174,12 +179,20 @@ virtual bool createMsg(uint32_t& token, RsGxsIdOpinion &opinion);
|
|||
|
||||
/**************** RsIdentity External Interface.
|
||||
* Notes:
|
||||
*
|
||||
* All the data is cached together for the moment - We should probably
|
||||
* seperate and sort this out.
|
||||
*
|
||||
* Also need to handle Cache updates / invalidation from internal changes.
|
||||
*
|
||||
*/
|
||||
|
||||
virtual bool getNickname(const RsGxsId &id, std::string &nickname);
|
||||
//virtual bool getNickname(const RsGxsId &id, std::string &nickname);
|
||||
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details);
|
||||
virtual bool getOwnIds(std::list<RsGxsId> &ownIds);
|
||||
|
||||
|
||||
|
||||
//
|
||||
virtual bool submitOpinion(uint32_t& token, RsIdOpinion &opinion);
|
||||
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms);
|
||||
|
@ -208,6 +221,13 @@ virtual int getPrivateKey(const RsGxsId &id, RsTlvSecurityKey &key);
|
|||
virtual bool getReputation(const RsGxsId &id, const GixsReputation &rep);
|
||||
|
||||
|
||||
|
||||
// Overloaded from GxsTokenQueue for Request callbacks.
|
||||
virtual void handleResponse(uint32_t token, uint32_t req_type);
|
||||
|
||||
// Overloaded from RsTickEvent.
|
||||
virtual void handle_event(uint32_t event_type);
|
||||
|
||||
protected:
|
||||
|
||||
/** Notifications **/
|
||||
|
@ -226,20 +246,27 @@ virtual void service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& key
|
|||
|
||||
bool cache_request_load(const RsGxsId &id);
|
||||
bool cache_start_load();
|
||||
bool cache_check_loading();
|
||||
bool cache_load_for_token(uint32_t token);
|
||||
|
||||
bool cache_store(const RsGxsIdGroupItem *item);
|
||||
bool cache_update_if_cached(const RsGxsId &id, std::string serviceString);
|
||||
|
||||
// Mutex protected.
|
||||
|
||||
time_t mCacheLoad_LastCycle;
|
||||
int mCacheLoad_Status;
|
||||
std::list<RsGxsId> mCacheLoad_ToCache;
|
||||
std::list<uint32_t> mCacheLoad_Tokens;
|
||||
|
||||
// Switching to RsMemCache for Key Caching.
|
||||
RsMemCache<RsGxsId, RsGxsIdCache> mPublicKeyCache;
|
||||
RsMemCache<RsGxsId, RsGxsIdCache> mPrivateKeyCache;
|
||||
|
||||
/************************************************************************
|
||||
* Refreshing own Ids.
|
||||
*
|
||||
*/
|
||||
bool cache_request_ownids();
|
||||
bool cache_load_ownids(uint32_t token);
|
||||
|
||||
std::list<RsGxsId> mOwnIds;
|
||||
|
||||
/************************************************************************
|
||||
* Test fns for Caching.
|
||||
|
@ -247,20 +274,14 @@ virtual void service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& key
|
|||
*/
|
||||
bool cachetest_tick();
|
||||
bool cachetest_getlist();
|
||||
bool cachetest_request();
|
||||
|
||||
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
|
||||
|
||||
time_t mCacheTest_LastTs;
|
||||
bool mCacheTest_Active;
|
||||
uint32_t mCacheTest_Token;
|
||||
|
||||
bool cachetest_handlerequest(uint32_t token);
|
||||
|
||||
/************************************************************************
|
||||
* for processing background tasks that use the serviceString.
|
||||
* - must be mutually exclusive to avoid clashes.
|
||||
*/
|
||||
int scheduling_tick();
|
||||
bool CacheArbitration(uint32_t mode);
|
||||
void CacheArbitrationDone(uint32_t mode);
|
||||
|
||||
bool mBgSchedule_Active;
|
||||
uint32_t mBgSchedule_Mode;
|
||||
|
@ -270,19 +291,13 @@ virtual void service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& key
|
|||
*
|
||||
*/
|
||||
bool pgphash_start();
|
||||
bool pgphash_continue();
|
||||
|
||||
bool pgphash_getlist();
|
||||
bool pgphash_request();
|
||||
bool pgphash_handlerequest(uint32_t token);
|
||||
bool pgphash_process();
|
||||
|
||||
bool checkId(const RsGxsIdGroup &grp, PGPIdType &pgp_id);
|
||||
void getPgpIdList();
|
||||
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
|
||||
|
||||
time_t mHashPgp_LastTs;
|
||||
bool mHashPgp_SearchActive;
|
||||
uint32_t mHashPgp_Token;
|
||||
/* MUTEX PROTECTED DATA (mIdMtx - maybe should use a 2nd?) */
|
||||
|
||||
std::map<PGPIdType, PGPFingerprintType> mPgpFingerprintMap;
|
||||
std::list<RsGxsIdGroup> mGroupsToProcess;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue