mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
Added user type interogation of tokenQueue
fix for posteditem serialisation added voting to gui, but no feedback yet post and topic generation code added for testing git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5945 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
694885963e
commit
de757cfcae
16 changed files with 621 additions and 318 deletions
|
@ -291,7 +291,7 @@ bool RsGxsPostedSerialiser::serialiseGxsPostedVoteItem(RsGxsPostedVoteItem* item
|
|||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->mVote.mDirection);
|
||||
ok &= setRawUInt8(data, tlvsize, &offset, item->mVote.mDirection);
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "p3posted.h"
|
||||
#include "gxs/rsgxsflags.h"
|
||||
#include "serialiser/rsposteditems.h"
|
||||
|
||||
#define NUM_TOPICS_TO_GENERATE 7
|
||||
#define NUM_POSTS_TO_GENERATE 8
|
||||
#define NUM_VOTES_TO_GENERATE 23
|
||||
|
||||
const uint32_t RsPosted::FLAG_MSGTYPE_COMMENT = 0x0001;
|
||||
const uint32_t RsPosted::FLAG_MSGTYPE_POST = 0x0002;
|
||||
const uint32_t RsPosted::FLAG_MSGTYPE_VOTE = 0x0004;
|
||||
|
@ -29,7 +34,7 @@ RsPostedVote::RsPostedVote(const RsGxsPostedVoteItem& item)
|
|||
|
||||
p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes)
|
||||
: RsGenExchange(gds, nes, new RsGxsPostedSerialiser(), RS_SERVICE_GXSV1_TYPE_POSTED), RsPosted(this), mPostedMutex("Posted"),
|
||||
mTokenService(NULL)
|
||||
mTokenService(NULL), mGeneratingTopics(true), mGeneratingPosts(false)
|
||||
{
|
||||
mTokenService = RsGenExchange::getTokenService();
|
||||
}
|
||||
|
@ -41,6 +46,118 @@ void p3Posted::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
|
||||
void p3Posted::service_tick()
|
||||
{
|
||||
generateTopics();
|
||||
|
||||
//generatePosts();
|
||||
}
|
||||
|
||||
void p3Posted::generatePosts()
|
||||
{
|
||||
if(mGeneratingPosts)
|
||||
{
|
||||
// request topics then chose at random which one to use to generate a post about
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS;
|
||||
mTokenService->requestGroupInfo(token, 0, opts);
|
||||
double timeDelta = 2.; // slow tick
|
||||
while(mTokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
#ifndef WINDOWS_SYS
|
||||
usleep((int) (timeDelta * 1000000));
|
||||
#else
|
||||
Sleep((int) (timeDelta * 1000));
|
||||
#endif
|
||||
}
|
||||
|
||||
std::list<RsGxsGroupId> grpIds;
|
||||
RsGenExchange::getGroupList(token, grpIds);
|
||||
|
||||
|
||||
// for each group generate NUM_POSTS_TO_GENERATE posts
|
||||
std::list<RsGxsGroupId>::iterator lit = grpIds.begin();
|
||||
|
||||
for(; lit != grpIds.end(); lit++)
|
||||
{
|
||||
RsGxsGroupId& grpId = *lit;
|
||||
|
||||
std::vector<uint32_t> tokens;
|
||||
|
||||
for(int i=0; i < NUM_POSTS_TO_GENERATE; i++)
|
||||
{
|
||||
std::ostringstream ostrm;
|
||||
ostrm << i;
|
||||
std::string link = "link" + ostrm.str();
|
||||
|
||||
RsPostedPost post;
|
||||
post.mLink = link;
|
||||
post.mNotes = link;
|
||||
post.mMeta.mMsgName = link;
|
||||
post.mMeta.mGroupId = grpId;
|
||||
|
||||
submitPost(token, post);
|
||||
tokens.push_back(token);
|
||||
}
|
||||
|
||||
while(!tokens.empty())
|
||||
{
|
||||
std::vector<uint32_t>::iterator vit = tokens.begin();
|
||||
|
||||
for(; vit != tokens.end(); )
|
||||
{
|
||||
if(mTokenService->requestStatus(*vit) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
vit = tokens.erase(vit);
|
||||
else
|
||||
vit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// stop generating posts after acknowledging all the ones you created
|
||||
mGeneratingPosts = false;
|
||||
}
|
||||
}
|
||||
|
||||
void p3Posted::generateTopics()
|
||||
{
|
||||
if(mGeneratingTopics)
|
||||
{
|
||||
std::vector<uint32_t> tokens;
|
||||
|
||||
for(int i=0; i < NUM_TOPICS_TO_GENERATE; i++)
|
||||
{
|
||||
std::ostringstream strm;
|
||||
strm << i;
|
||||
std::string topicName = "Topic " + strm.str();
|
||||
|
||||
RsPostedGroup topic;
|
||||
topic.mMeta.mGroupName = topicName;
|
||||
|
||||
uint32_t token;
|
||||
submitGroup(token, topic);
|
||||
tokens.push_back(token);
|
||||
}
|
||||
|
||||
|
||||
while(!tokens.empty())
|
||||
{
|
||||
std::vector<uint32_t>::iterator vit = tokens.begin();
|
||||
|
||||
for(; vit != tokens.end(); )
|
||||
{
|
||||
if(mTokenService->requestStatus(*vit) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
vit = tokens.erase(vit);
|
||||
else
|
||||
vit++;
|
||||
}
|
||||
}
|
||||
|
||||
mGeneratingTopics = false;
|
||||
mGeneratingPosts = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,21 @@ protected:
|
|||
|
||||
void service_tick();
|
||||
|
||||
public:
|
||||
|
||||
void generateTopics();
|
||||
/*!
|
||||
* Exists solely for testing
|
||||
*/
|
||||
void generatePosts();
|
||||
|
||||
/*!
|
||||
* Exists solely for testing
|
||||
* Generates random votes to existing posts
|
||||
* in the system
|
||||
*/
|
||||
void generateVotes();
|
||||
|
||||
public:
|
||||
|
||||
bool getGroup(const uint32_t &token, std::vector<RsPostedGroup> &group);
|
||||
|
@ -132,6 +147,11 @@ private:
|
|||
|
||||
RsTokenService* mTokenService;
|
||||
RsMutex mPostedMutex;
|
||||
|
||||
|
||||
// for data generation
|
||||
|
||||
bool mGeneratingPosts, mGeneratingTopics;
|
||||
};
|
||||
|
||||
#endif // P3POSTED_H
|
||||
|
|
|
@ -20,7 +20,16 @@ void GenExchangeTester::setUp()
|
|||
|
||||
RsGixsDummy* gixsDummy = new RsGixsDummy("incoming", "outgoing");
|
||||
|
||||
mTestService = new GenExchangeTestService(mDataStore, mNxs, gixsDummy, 0);
|
||||
uint32_t serviceAuthenPolicy = 0;
|
||||
|
||||
uint8_t flag = 0;
|
||||
|
||||
flag = GXS_SERV::MSG_AUTHEN_ROOT_PUBLISH_SIGN;
|
||||
RsGenExchange::setAuthenPolicyFlag(flag, serviceAuthenPolicy,
|
||||
RsGenExchange::RESTRICTED_GRP_BITS);
|
||||
|
||||
|
||||
mTestService = new GenExchangeTestService(mDataStore, mNxs, gixsDummy, serviceAuthenPolicy);
|
||||
mTokenService = mTestService->getTokenService();
|
||||
mTestService->start();
|
||||
}
|
||||
|
|
|
@ -49,6 +49,12 @@ public:
|
|||
bool testGrpMetaModRequest();
|
||||
bool testMsgMetaModRequest();
|
||||
|
||||
|
||||
// testing verification (publish).
|
||||
// Strategy is
|
||||
// inject a group which you only have the public signature for
|
||||
// The injection can be done via
|
||||
|
||||
private:
|
||||
|
||||
// to be called at start
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue