mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
* Got GxsCircles running in libretroshare.
- Completed serialiser. - added dummy interface fns. & cleaned-up other linking issues. - Added into rsinit.cc * Improved GxsIdentity DummyData to fake Ids from friends - #define to enable, must be switched off for real usage. - cleaned up rsIdentity interface. - removed genDummyData from public interface. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5915 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
44d32626bc
commit
4438303d55
@ -642,13 +642,11 @@ HEADERS += retroshare/rsgame.h
|
||||
|
||||
# GxsCircles Service
|
||||
HEADERS += services/p3gxscircles.h \
|
||||
|
||||
# serialiser/rsgxscircleitems.h
|
||||
# retroshare/rsgxscircles.h \
|
||||
serialiser/rsgxscircleitems.h \
|
||||
retroshare/rsgxscircles.h \
|
||||
|
||||
SOURCES += services/p3gxscircles.cc \
|
||||
|
||||
# serialiser/rsgxscircleitems.cc \
|
||||
serialiser/rsgxscircleitems.cc \
|
||||
|
||||
# GxsForums Service
|
||||
HEADERS += retroshare/rsgxsforums.h \
|
||||
|
@ -85,6 +85,7 @@ class RsGxsCircleMsg
|
||||
|
||||
// Signature by user signifying that they want to be part of the group.
|
||||
// maybe Phase 3.
|
||||
std::string stuff;
|
||||
};
|
||||
|
||||
|
||||
|
@ -206,62 +206,6 @@ 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;
|
||||
|
||||
/********************************************************************************************/
|
||||
/********************************************************************************************/
|
||||
/********************************************************************************************/
|
||||
/********************************************************************************************/
|
||||
/********************************************************************************************/
|
||||
|
||||
@ -284,61 +228,9 @@ virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms) = 0;
|
||||
/* Specific Service Data */
|
||||
/* We expose these initially for testing / GUI purposes.
|
||||
*/
|
||||
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 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.
|
||||
*/
|
||||
|
||||
/* So we will want to cache much of the identity stuff, so that we have quick access to the results.
|
||||
* The following bits of data will not use the request/response interface, and should be available immediately.
|
||||
*
|
||||
* ID => Nickname, knownGPG, reputation.
|
||||
*
|
||||
* This will require quite a bit of data...
|
||||
* 20 Bytes + 50 + 1 + 4 Bytes? (< 100 Bytes).
|
||||
* x 10,000 IDs. => ~1 MB of cache (Good).
|
||||
* x 100,000 IDs. => ~10 MB of cache (Good).
|
||||
* x 1,000,000 IDs. => ~100 MB of cache (Too Big).
|
||||
*
|
||||
* We also need to store quick access to your OwnIds.
|
||||
*/
|
||||
|
||||
//virtual uint32_t getIdDetails(const std::string &id, std::string &nickname, bool &isGpgKnown,
|
||||
// uint32_t &ownOpinion, float &reputation);
|
||||
//virtual uint32_t getOwnIds(std::list<std::string> &ownIds);
|
||||
//virtual bool setOpinion(const std::string &id, uint32_t opinion);
|
||||
|
||||
|
||||
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;
|
||||
virtual bool requestIdReputations(uint32_t &token, const std::list<std::string> &ids) = 0;
|
||||
virtual bool requestIdPeerOpinion(uint32_t &token, const std::string &aboutId, const std::string &peerId) = 0;
|
||||
//virtual bool requestIdGpgDetails(uint32_t &token, const std::list<std::string> &ids) = 0;
|
||||
|
||||
/* Poll */
|
||||
virtual uint32_t requestStatus(const uint32_t token) = 0;
|
||||
|
||||
/* Retrieve Data */
|
||||
virtual bool getIdentityList(const uint32_t token, std::list<std::string> &ids) = 0;
|
||||
virtual bool getIdentity(const uint32_t token, RsIdData &data) = 0;
|
||||
virtual bool getIdReputation(const uint32_t token, RsIdReputation &reputation) = 0;
|
||||
virtual bool getIdPeerOpinion(const uint32_t token, RsIdOpinion &opinion) = 0;
|
||||
|
||||
/* Updates */
|
||||
virtual bool updateIdentity(RsIdData &data) = 0;
|
||||
virtual bool updateOpinion(RsIdOpinion &opinion) = 0;
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // RETROSHARE_IDENTITY_GUI_INTERFACE_H
|
||||
|
@ -1825,6 +1825,7 @@ RsTurtle *rsTurtle = NULL ;
|
||||
|
||||
#ifdef ENABLE_GXS_SERVICES
|
||||
#include "services/p3idservice.h"
|
||||
#include "services/p3gxscircles.h"
|
||||
#include "services/p3wiki.h"
|
||||
#include "services/p3posted.h"
|
||||
#include "services/p3photoservice.h"
|
||||
@ -2315,6 +2316,22 @@ int RsServer::StartupRetroShare()
|
||||
RsGxsNetService* gxsid_ns = new RsGxsNetService(
|
||||
RS_SERVICE_GXSV1_TYPE_GXSID, gxsid_ds, nxsMgr, mGxsIdService);
|
||||
|
||||
/**** GxsCircle service ****/
|
||||
|
||||
p3GxsCircles *mGxsCircles = NULL;
|
||||
|
||||
RsGeneralDataService* gxscircles_ds = new RsDataService(currGxsDir + "/", "gxscircles_db",
|
||||
RS_SERVICE_GXSV1_TYPE_GXSCIRCLE, NULL);
|
||||
|
||||
gxscircles_ds->resetDataStore();
|
||||
|
||||
// init gxs services
|
||||
mGxsCircles = new p3GxsCircles(gxscircles_ds, NULL, mGxsIdService);
|
||||
|
||||
// create GXS Circle service
|
||||
RsGxsNetService* gxscircles_ns = new RsGxsNetService(
|
||||
RS_SERVICE_GXSV1_TYPE_GXSCIRCLE, gxscircles_ds, nxsMgr, mGxsCircles);
|
||||
|
||||
|
||||
#if ENABLE_OTHER_GXS_SERVICES
|
||||
/**** Photo service ****/
|
||||
@ -2424,6 +2441,7 @@ int RsServer::StartupRetroShare()
|
||||
/*** start up GXS core runner ***/
|
||||
#if ENABLE_OTHER_GXS_SERVICES
|
||||
createThread(*mGxsIdService);
|
||||
createThread(*mGxsCircles);
|
||||
createThread(*mPhoto);
|
||||
createThread(*mPosted);
|
||||
createThread(*mWiki);
|
||||
@ -2433,6 +2451,7 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
// cores ready start up GXS net servers
|
||||
createThread(*gxsid_ns);
|
||||
createThread(*gxscircles_ns);
|
||||
#if ENABLE_OTHER_GXS_SERVICES
|
||||
createThread(*photo_ns);
|
||||
createThread(*posted_ns);
|
||||
@ -2443,6 +2462,7 @@ int RsServer::StartupRetroShare()
|
||||
|
||||
// now add to p3service
|
||||
pqih->addService(gxsid_ns);
|
||||
pqih->addService(gxscircles_ns);
|
||||
#if ENABLE_OTHER_GXS_SERVICES
|
||||
pqih->addService(photo_ns);
|
||||
pqih->addService(posted_ns);
|
||||
@ -2713,6 +2733,7 @@ int RsServer::StartupRetroShare()
|
||||
// Testing of new cache system interfaces.
|
||||
|
||||
rsIdentity = mGxsIdService;
|
||||
rsGxsCircles = mGxsCircles;
|
||||
#if ENABLE_OTHER_GXS_SERVICES
|
||||
rsWiki = mWiki;
|
||||
rsPosted = mPosted;
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "rswireitems.h"
|
||||
#include "rsgxscircleitems.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
|
||||
@ -107,16 +107,36 @@ RsItem* RsGxsCircleSerialiser::deserialise(void* data, uint32_t* size)
|
||||
|
||||
void RsGxsCircleGroupItem::clear()
|
||||
{
|
||||
group.mDescription.clear();
|
||||
gxsIdSet.TlvClear();
|
||||
subCircleSet.TlvClear();
|
||||
}
|
||||
|
||||
bool RsGxsCircleGroupItem::convertFrom(const RsGxsCircleGroup &group)
|
||||
{
|
||||
clear();
|
||||
|
||||
meta = group.mMeta;
|
||||
gxsIdSet.ids = group.mInvitedMembers;
|
||||
subCircleSet.ids = group.mSubCircles;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsCircleGroupItem::convertTo(RsGxsCircleGroup &group) const
|
||||
{
|
||||
group.mMeta = meta;
|
||||
group.mInvitedMembers = gxsIdSet.ids;
|
||||
group.mSubCircles = subCircleSet.ids;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& RsGxsCircleGroupItem::print(std::ostream& out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsCircleGroupItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "Description: " << group.mDescription << std::endl;
|
||||
gxsIdSet.print(out, int_Indent);
|
||||
subCircleSet.print(out, int_Indent);
|
||||
|
||||
printRsItemEnd(out ,"RsGxsCircleGroupItem", indent);
|
||||
return out;
|
||||
@ -125,11 +145,10 @@ std::ostream& RsGxsCircleGroupItem::print(std::ostream& out, uint16_t indent)
|
||||
|
||||
uint32_t RsGxsCircleSerialiser::sizeGxsCircleGroupItem(RsGxsCircleGroupItem *item)
|
||||
{
|
||||
|
||||
const RsCircleGroup& group = item->group;
|
||||
uint32_t s = 8; // header
|
||||
|
||||
s += GetTlvStringSize(group.mDescription);
|
||||
s += item->gxsIdSet.TlvSize();
|
||||
s += item->subCircleSet.TlvSize();
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -162,7 +181,8 @@ bool RsGxsCircleSerialiser::serialiseGxsCircleGroupItem(RsGxsCircleGroupItem *it
|
||||
offset += 8;
|
||||
|
||||
/* GxsCircleGroupItem */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 1, item->group.mDescription);
|
||||
ok &= item->gxsIdSet.SetTlv(data, tlvsize, &offset);
|
||||
ok &= item->subCircleSet.SetTlv(data, tlvsize, &offset);
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
@ -222,7 +242,8 @@ RsGxsCircleGroupItem* RsGxsCircleSerialiser::deserialiseGxsCircleGroupItem(void
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, 1, item->group.mDescription);
|
||||
ok &= item->gxsIdSet.GetTlv(data, rssize, &offset);
|
||||
ok &= item->subCircleSet.GetTlv(data, rssize, &offset);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
@ -255,8 +276,7 @@ RsGxsCircleGroupItem* RsGxsCircleSerialiser::deserialiseGxsCircleGroupItem(void
|
||||
|
||||
void RsGxsCircleMsgItem::clear()
|
||||
{
|
||||
pulse.mPulseText.clear();
|
||||
pulse.mHashTags.clear();
|
||||
msg.stuff.clear();
|
||||
}
|
||||
|
||||
std::ostream& RsGxsCircleMsgItem::print(std::ostream& out, uint16_t indent)
|
||||
@ -265,10 +285,7 @@ std::ostream& RsGxsCircleMsgItem::print(std::ostream& out, uint16_t indent)
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "Page: " << pulse.mPulseText << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "HashTags: " << pulse.mHashTags << std::endl;
|
||||
out << "Stuff: " << msg.stuff << std::endl;
|
||||
|
||||
printRsItemEnd(out ,"RsGxsCircleMsgItem", indent);
|
||||
return out;
|
||||
@ -278,11 +295,10 @@ std::ostream& RsGxsCircleMsgItem::print(std::ostream& out, uint16_t indent)
|
||||
uint32_t RsGxsCircleSerialiser::sizeGxsCircleMsgItem(RsGxsCircleMsgItem *item)
|
||||
{
|
||||
|
||||
const RsCircleMsg& pulse = item->pulse;
|
||||
const RsGxsCircleMsg &msg = item->msg;
|
||||
uint32_t s = 8; // header
|
||||
|
||||
s += GetTlvStringSize(pulse.mPulseText);
|
||||
s += GetTlvStringSize(pulse.mHashTags);
|
||||
s += GetTlvStringSize(msg.stuff);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -315,8 +331,7 @@ bool RsGxsCircleSerialiser::serialiseGxsCircleMsgItem(RsGxsCircleMsgItem *item,
|
||||
offset += 8;
|
||||
|
||||
/* GxsCircleMsgItem */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 1, item->pulse.mPulseText);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 1, item->pulse.mHashTags);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 1, item->msg.stuff);
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
@ -376,8 +391,7 @@ RsGxsCircleMsgItem* RsGxsCircleSerialiser::deserialiseGxsCircleMsgItem(void *dat
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, 1, item->pulse.mPulseText);
|
||||
ok &= GetTlvString(data, rssize, &offset, 1, item->pulse.mHashTags);
|
||||
ok &= GetTlvString(data, rssize, &offset, 1, item->msg.stuff);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
|
@ -38,20 +38,29 @@
|
||||
const uint8_t RS_PKT_SUBTYPE_GXSCIRCLE_GROUP_ITEM = 0x02;
|
||||
const uint8_t RS_PKT_SUBTYPE_GXSCIRCLE_MSG_ITEM = 0x03;
|
||||
|
||||
const uint16_t GXSCIRCLE_GXSIDSET = 0x0001;
|
||||
const uint16_t GXSCIRCLE_SUBCIRCLESET = 0x0002;
|
||||
|
||||
class RsGxsCircleGroupItem : public RsGxsGrpItem
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
RsGxsCircleGroupItem(): RsGxsGrpItem(RS_SERVICE_GXSV1_TYPE_GXSCIRCLE,
|
||||
RS_PKT_SUBTYPE_GXSCIRCLE_GROUP_ITEM) { return;}
|
||||
RS_PKT_SUBTYPE_GXSCIRCLE_GROUP_ITEM),
|
||||
gxsIdSet(GXSCIRCLE_GXSIDSET),
|
||||
subCircleSet(GXSCIRCLE_SUBCIRCLESET) { return;}
|
||||
virtual ~RsGxsCircleGroupItem() { return;}
|
||||
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
bool convertFrom(const RsGxsCircleGroup &group);
|
||||
bool convertTo(RsGxsCircleGroup &group) const;
|
||||
|
||||
RsGxsCircleGroup group;
|
||||
// DIFFERENT FROM OTHER ONES, as stupid serialisation otherwise.
|
||||
RsTlvStringSet gxsIdSet;
|
||||
RsTlvStringSet subCircleSet;
|
||||
};
|
||||
|
||||
class RsGxsCircleMsgItem : public RsGxsMsgItem
|
||||
|
@ -137,6 +137,31 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
/******************* RsCircles Interface ***************************************/
|
||||
/********************************************************************************/
|
||||
|
||||
void p3GxsCircles::createLocalCircle()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void p3GxsCircles::addToLocalCircle()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void p3GxsCircles::removeFromLocalCircle()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void p3GxsCircles::getLocalCirclePeers()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void p3GxsCircles::getListOfLocalCircles()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
bool p3GxsCircles:: getNickname(const RsGxsId &id, std::string &nickname)
|
||||
@ -181,35 +206,8 @@ bool p3GxsCircles:: getOwnIds(std::list<RsGxsId> &ownIds)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
bool p3GxsCircles::submitOpinion(uint32_t& token, RsIdOpinion &opinion)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3GxsCircles::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
||||
{
|
||||
|
||||
RsGxsIdGroup id;
|
||||
|
||||
id.mMeta.mGroupName = params.nickname;
|
||||
if (params.isPgpLinked)
|
||||
{
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
}
|
||||
else
|
||||
{
|
||||
id.mMeta.mGroupFlags = 0;
|
||||
}
|
||||
|
||||
createGroup(token, id);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/********************************************************************************/
|
||||
/******************* RsGixs Interface ***************************************/
|
||||
/********************************************************************************/
|
||||
@ -269,8 +267,8 @@ bool p3GxsCircles::getGroupData(const uint32_t &token, std::vector<RsGxsCircleGr
|
||||
for(; vit != grpData.end(); vit++)
|
||||
{
|
||||
RsGxsCircleGroupItem* item = dynamic_cast<RsGxsCircleGroupItem*>(*vit);
|
||||
RsGxsCircleGroup group = item->group;
|
||||
group.mMeta = item->meta;
|
||||
RsGxsCircleGroup group;
|
||||
item->convertTo(group);
|
||||
|
||||
// If its cached - add that info (TODO).
|
||||
groups.push_back(group);
|
||||
@ -287,8 +285,7 @@ bool p3GxsCircles::getGroupData(const uint32_t &token, std::vector<RsGxsCircleGr
|
||||
bool p3GxsCircles::createGroup(uint32_t& token, RsGxsCircleGroup &group)
|
||||
{
|
||||
RsGxsCircleGroupItem* item = new RsGxsCircleGroupItem();
|
||||
item->group = group;
|
||||
item->meta = group.mMeta;
|
||||
item->convertFrom(group);
|
||||
RsGenExchange::publishGroup(token, item);
|
||||
return true;
|
||||
}
|
||||
@ -688,8 +685,8 @@ bool p3GxsCircles::cache_load_for_token(uint32_t token)
|
||||
for(; vit != grpData.end(); vit++)
|
||||
{
|
||||
RsGxsCircleGroupItem *item = dynamic_cast<RsGxsCircleGroupItem*>(*vit);
|
||||
RsGxsCircleGroup group = item->group;
|
||||
group.mMeta = item->meta;
|
||||
RsGxsCircleGroup group;
|
||||
item->convertTo(group);
|
||||
|
||||
std::cerr << "p3GxsCircles::cache_load_for_token() Loaded Id with Meta: ";
|
||||
std::cerr << item->meta;
|
||||
@ -1204,19 +1201,33 @@ void p3GxsCircles::generateDummyData()
|
||||
/************************************************************************************/
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsGxsIdGroup &grp)
|
||||
std::ostream &operator<<(std::ostream &out, const RsGxsCircleGroup &grp)
|
||||
{
|
||||
out << "RsGxsIdGroup: Meta: " << grp.mMeta;
|
||||
out << " PgpIdHash: " << grp.mPgpIdHash;
|
||||
out << " PgpIdSign: [binary]"; // << grp.mPgpIdSign;
|
||||
out << "RsGxsCircleGroup: Meta: " << grp.mMeta;
|
||||
out << "InvitedMembers: ";
|
||||
out << std::endl;
|
||||
|
||||
std::list<RsGxsId>::const_iterator it;
|
||||
std::list<RsGxsCircleId>::const_iterator sit;
|
||||
for(it = grp.mInvitedMembers.begin();
|
||||
it != grp.mInvitedMembers.begin(); it++)
|
||||
{
|
||||
out << "\t" << *it;
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
for(sit = grp.mSubCircles.begin();
|
||||
sit != grp.mSubCircles.begin(); sit++)
|
||||
{
|
||||
out << "\t" << *it;
|
||||
out << std::endl;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsGxsIdOpinion &opinion)
|
||||
std::ostream &operator<<(std::ostream &out, const RsGxsCircleMsg &msg)
|
||||
{
|
||||
out << "RsGxsIdOpinion: Meta: " << opinion.mMeta;
|
||||
out << "RsGxsCircleMsg: Meta: " << msg.mMeta;
|
||||
out << std::endl;
|
||||
|
||||
return out;
|
||||
|
@ -39,6 +39,9 @@
|
||||
/****
|
||||
* #define ID_DEBUG 1
|
||||
****/
|
||||
#define GXSID_GEN_DUMMY_DATA 1
|
||||
|
||||
|
||||
|
||||
#define ID_REQUEST_LIST 0x0001
|
||||
#define ID_REQUEST_IDENTITY 0x0002
|
||||
@ -91,6 +94,15 @@ RsIdentity *rsIdentity = NULL;
|
||||
|
||||
#define GXSID_EVENT_CACHETEST 0x1000
|
||||
|
||||
#define GXSID_EVENT_DUMMYDATA 0x2000
|
||||
#define GXSID_EVENT_DUMMY_OWNIDS 0x2001
|
||||
#define GXSID_EVENT_DUMMY_PGPID 0x2002
|
||||
#define GXSID_EVENT_DUMMY_UNKNOWN_PGPID 0x2003
|
||||
#define GXSID_EVENT_DUMMY_PSEUDOID 0x2004
|
||||
|
||||
|
||||
/* delays */
|
||||
|
||||
#define CACHETEST_PERIOD 60
|
||||
|
||||
#define OWNID_RELOAD_DELAY 10
|
||||
@ -121,6 +133,11 @@ p3IdService::p3IdService(RsGeneralDataService *gds, RsNetworkExchangeService *ne
|
||||
RsTickEvent::schedule_in(GXSID_EVENT_PGPHASH, PGPHASH_PERIOD);
|
||||
RsTickEvent::schedule_in(GXSID_EVENT_REPUTATION, REPUTATION_PERIOD);
|
||||
RsTickEvent::schedule_now(GXSID_EVENT_CACHEOWNIDS);
|
||||
|
||||
#ifdef GXSID_GEN_DUMMY_DATA
|
||||
RsTickEvent::schedule_now(GXSID_EVENT_DUMMYDATA);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1129,6 +1146,7 @@ typedef t_RsGenericIdType<SHA_DIGEST_LENGTH> GxsIdPgpHash;
|
||||
static void calcPGPHash(const RsGxsId &id, const PGPFingerprintType &pgp, GxsIdPgpHash &hash);
|
||||
|
||||
|
||||
// Must Use meta.
|
||||
void p3IdService::service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet)
|
||||
{
|
||||
RsGxsIdGroupItem *item = dynamic_cast<RsGxsIdGroupItem *>(grpItem);
|
||||
@ -1163,19 +1181,61 @@ void p3IdService::service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet
|
||||
|
||||
/********************* TEMP HACK UNTIL GXS FILLS IN GROUP_ID *****************/
|
||||
|
||||
// SANITY CHECK.
|
||||
if (item->group.mMeta.mAuthorId != item->meta.mAuthorId)
|
||||
{
|
||||
std::cerr << "p3IdService::service_CreateGroup() AuthorId mismatch(";
|
||||
std::cerr << item->group.mMeta.mAuthorId;
|
||||
std::cerr << " vs ";
|
||||
std::cerr << item->meta.mAuthorId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
if (item->group.mMeta.mGroupId != item->meta.mGroupId)
|
||||
{
|
||||
std::cerr << "p3IdService::service_CreateGroup() GroupId mismatch(";
|
||||
std::cerr << item->group.mMeta.mGroupId;
|
||||
std::cerr << " vs ";
|
||||
std::cerr << item->meta.mGroupId;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
|
||||
if (item->group.mMeta.mGroupFlags != item->meta.mGroupFlags)
|
||||
{
|
||||
std::cerr << "p3IdService::service_CreateGroup() GroupFlags mismatch(";
|
||||
std::cerr << item->group.mMeta.mGroupFlags;
|
||||
std::cerr << " vs ";
|
||||
std::cerr << item->meta.mGroupFlags;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::cerr << "p3IdService::service_CreateGroup() for : " << item->group.mMeta.mGroupId;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3IdService::service_CreateGroup() Alt GroupId : " << item->meta.mGroupId;
|
||||
std::cerr << std::endl;
|
||||
|
||||
#ifdef GXSID_GEN_DUMMY_DATA
|
||||
if ((item->group.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) && (item->group.mMeta.mAuthorId != ""))
|
||||
#else
|
||||
if (item->group.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
#endif
|
||||
{
|
||||
/* create the hash */
|
||||
GxsIdPgpHash hash;
|
||||
|
||||
/* */
|
||||
PGPFingerprintType ownFinger;
|
||||
#ifdef GXSID_GEN_DUMMY_DATA
|
||||
PGPIdType ownId(item->group.mMeta.mAuthorId);
|
||||
#else
|
||||
PGPIdType ownId(AuthGPG::getAuthGPG()->getGPGOwnId());
|
||||
#endif
|
||||
|
||||
if (!AuthGPG::getAuthGPG()->getKeyFingerprint(ownId,ownFinger))
|
||||
{
|
||||
@ -1215,6 +1275,12 @@ void p3IdService::service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet
|
||||
|
||||
}
|
||||
|
||||
// Enforce no AuthorId.
|
||||
item->meta.mAuthorId = "";
|
||||
item->group.mMeta.mAuthorId = "";
|
||||
// copy meta data to be sure its all the same.
|
||||
//item->group.mMeta = item->meta;
|
||||
|
||||
// Reload in a little bit.
|
||||
// HACK to get it to work.
|
||||
RsTickEvent::schedule_in(GXSID_EVENT_CACHEOWNIDS, OWNID_RELOAD_DELAY);
|
||||
@ -1567,131 +1633,168 @@ void calcPGPHash(const RsGxsId &id, const PGPFingerprintType &pgp, GxsIdPgpHash
|
||||
/************************************************************************************/
|
||||
/************************************************************************************/
|
||||
|
||||
std::string p3IdService::genRandomId()
|
||||
|
||||
std::string p3IdService::genRandomId(int len)
|
||||
{
|
||||
std::string randomId;
|
||||
for(int i = 0; i < 20; i++)
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
randomId += (char) ('a' + (RSRandom::random_u32() % 26));
|
||||
int val = RSRandom::random_u32() % 16;
|
||||
if (val < 10)
|
||||
{
|
||||
randomId += (char) ('0' + val);
|
||||
}
|
||||
else
|
||||
{
|
||||
randomId += (char) ('a' + (val - 10));
|
||||
}
|
||||
}
|
||||
|
||||
return randomId;
|
||||
}
|
||||
|
||||
#define MAX_KNOWN_PGPIDS 50
|
||||
#define MAX_UNKNOWN_PGPIDS 50
|
||||
#define MAX_PSEUDOIDS 100
|
||||
|
||||
#define DUMMY_GXSID_DELAY 5
|
||||
|
||||
void p3IdService::generateDummyData()
|
||||
{
|
||||
|
||||
generateDummy_OwnIds();
|
||||
|
||||
time_t age = 0;
|
||||
for(int i = 0; i < MAX_KNOWN_PGPIDS; i++)
|
||||
{
|
||||
age += DUMMY_GXSID_DELAY;
|
||||
RsTickEvent::schedule_in(GXSID_EVENT_DUMMY_PGPID, age);
|
||||
}
|
||||
|
||||
for(int i = 0; i < MAX_PSEUDOIDS; i++)
|
||||
{
|
||||
age += DUMMY_GXSID_DELAY;
|
||||
RsTickEvent::schedule_in(GXSID_EVENT_DUMMY_PSEUDOID, age);
|
||||
}
|
||||
|
||||
for(int i = 0; i < MAX_UNKNOWN_PGPIDS; i++)
|
||||
{
|
||||
age += DUMMY_GXSID_DELAY;
|
||||
RsTickEvent::schedule_in(GXSID_EVENT_DUMMY_UNKNOWN_PGPID, age);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void p3IdService::generateDummy_OwnIds()
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
/* grab all the gpg ids... and make some ids */
|
||||
|
||||
std::list<std::string> gpgids;
|
||||
std::list<std::string>::iterator it;
|
||||
|
||||
rsPeers->getGPGAllList(gpgids);
|
||||
|
||||
std::string ownId = rsPeers->getGPGOwnId();
|
||||
gpgids.push_back(ownId);
|
||||
|
||||
// generate some ownIds.
|
||||
int genCount = 0;
|
||||
int i;
|
||||
for(it = gpgids.begin(); it != gpgids.end(); it++)
|
||||
{
|
||||
/* create one or two for each one */
|
||||
int nIds = 1 + (RSRandom::random_u32() % 2);
|
||||
|
||||
int nIds = 2 + (RSRandom::random_u32() % 2);
|
||||
for(i = 0; i < nIds; i++)
|
||||
{
|
||||
RsGxsIdGroup id;
|
||||
|
||||
RsPeerDetails details;
|
||||
|
||||
//id.mKeyId = genRandomId();
|
||||
id.mMeta.mGroupId = genRandomId();
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
id.mPgpIdHash = genRandomId();
|
||||
id.mPgpIdSign = genRandomId();
|
||||
|
||||
if (rsPeers->getPeerDetails(*it, details))
|
||||
// HACK FOR DUMMY GENERATION.
|
||||
id.mMeta.mAuthorId = ownId;
|
||||
if (rsPeers->getPeerDetails(ownId, details))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << details.name << "_" << i + 1;
|
||||
|
||||
//id.mNickname = out.str();
|
||||
id.mMeta.mGroupName = out.str();
|
||||
}
|
||||
|
||||
uint32_t dummyToken = 0;
|
||||
createGroup(dummyToken, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void p3IdService::generateDummy_FriendPGP()
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// Now Generate for friends.
|
||||
std::list<std::string> gpgids;
|
||||
std::list<std::string>::iterator it;
|
||||
rsPeers->getGPGAllList(gpgids);
|
||||
|
||||
RsGxsIdGroup id;
|
||||
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
|
||||
int idx = RSRandom::random_f32() * (gpgids.size() - 1);
|
||||
it = gpgids.begin();
|
||||
for(int j = 0; j < idx; j++, it++);
|
||||
|
||||
// HACK FOR DUMMY GENERATION.
|
||||
id.mMeta.mAuthorId = *it;
|
||||
|
||||
RsPeerDetails details;
|
||||
if (rsPeers->getPeerDetails(*it, details))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << details.name << "_" << RSRandom::random_u32() % 1000;
|
||||
id.mMeta.mGroupName = out.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "p3IdService::generateDummyData() missing" << std::endl;
|
||||
std::cerr << "p3IdService::generateDummy_FriendPGP() missing" << std::endl;
|
||||
std::cerr << std::endl;
|
||||
|
||||
//id.mNickname = genRandomId();
|
||||
id.mMeta.mGroupName = genRandomId();
|
||||
}
|
||||
|
||||
uint32_t dummyToken = 0;
|
||||
createGroup(dummyToken, id);
|
||||
}
|
||||
|
||||
// LIMIT - AS GENERATION IS BROKEN.
|
||||
#define MAX_TEST_GEN 5
|
||||
if (++genCount > MAX_TEST_GEN)
|
||||
|
||||
void p3IdService::generateDummy_UnknownPGP()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
#define MAX_RANDOM_GPGIDS 10 //1000
|
||||
#define MAX_RANDOM_PSEUDOIDS 50 //5000
|
||||
|
||||
int nFakeGPGs = (RSRandom::random_u32() % MAX_RANDOM_GPGIDS);
|
||||
int nFakePseudoIds = (RSRandom::random_u32() % MAX_RANDOM_PSEUDOIDS);
|
||||
|
||||
/* make some fake gpg ids */
|
||||
for(i = 0; i < nFakeGPGs; i++)
|
||||
{
|
||||
RsGxsIdGroup id;
|
||||
|
||||
RsPeerDetails details;
|
||||
|
||||
id.mMeta.mGroupName = genRandomId();
|
||||
|
||||
id.mMeta.mGroupId = genRandomId();
|
||||
// FAKE DATA.
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
id.mPgpIdHash = genRandomId();
|
||||
id.mPgpIdSign = genRandomId();
|
||||
|
||||
uint32_t dummyToken = 0;
|
||||
createGroup(dummyToken, id);
|
||||
}
|
||||
|
||||
/* make lots of pseudo ids */
|
||||
for(i = 0; i < nFakePseudoIds; i++)
|
||||
{
|
||||
RsGxsIdGroup id;
|
||||
|
||||
RsPeerDetails details;
|
||||
|
||||
id.mPgpIdHash = genRandomId(40);
|
||||
id.mPgpIdSign = genRandomId(40);
|
||||
id.mMeta.mGroupName = genRandomId();
|
||||
|
||||
id.mMeta.mGroupId = genRandomId();
|
||||
id.mMeta.mGroupFlags = 0;
|
||||
id.mPgpIdHash = "";
|
||||
id.mPgpIdSign = "";
|
||||
|
||||
|
||||
uint32_t dummyToken = 0;
|
||||
createGroup(dummyToken, id);
|
||||
}
|
||||
|
||||
//mUpdated = true;
|
||||
|
||||
return;
|
||||
void p3IdService::generateDummy_UnknownPseudo()
|
||||
{
|
||||
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
RsGxsIdGroup id;
|
||||
|
||||
// FAKE DATA.
|
||||
id.mMeta.mGroupFlags = 0;
|
||||
id.mMeta.mGroupName = genRandomId();
|
||||
|
||||
uint32_t dummyToken = 0;
|
||||
createGroup(dummyToken, id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string rsIdTypeToString(uint32_t idtype)
|
||||
{
|
||||
std::string str;
|
||||
@ -2462,6 +2565,26 @@ void p3IdService::handle_event(uint32_t event_type, const std::string &elabel)
|
||||
pgphash_process();
|
||||
break;
|
||||
|
||||
case GXSID_EVENT_DUMMYDATA:
|
||||
generateDummyData();
|
||||
break;
|
||||
|
||||
case GXSID_EVENT_DUMMY_OWNIDS:
|
||||
generateDummy_OwnIds();
|
||||
break;
|
||||
|
||||
case GXSID_EVENT_DUMMY_PGPID:
|
||||
generateDummy_FriendPGP();
|
||||
break;
|
||||
|
||||
case GXSID_EVENT_DUMMY_UNKNOWN_PGPID:
|
||||
generateDummy_UnknownPGP();
|
||||
break;
|
||||
|
||||
case GXSID_EVENT_DUMMY_PSEUDOID:
|
||||
generateDummy_UnknownPseudo();
|
||||
break;
|
||||
|
||||
default:
|
||||
/* error */
|
||||
std::cerr << "p3IdService::handle_event() Unknown Event Type: " << event_type;
|
||||
|
@ -307,8 +307,12 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
||||
*/
|
||||
|
||||
virtual void generateDummyData();
|
||||
void generateDummy_OwnIds();
|
||||
void generateDummy_FriendPGP();
|
||||
void generateDummy_UnknownPGP();
|
||||
void generateDummy_UnknownPseudo();
|
||||
|
||||
std::string genRandomId();
|
||||
std::string genRandomId(int len = 20);
|
||||
|
||||
bool reputation_start();
|
||||
bool reputation_continue();
|
||||
|
Loading…
Reference in New Issue
Block a user