Added random AuthorId to Dummy Wiki pages.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5928 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-12-02 19:01:51 +00:00
parent 700c6e316e
commit bcd67a8651

View File

@ -407,6 +407,30 @@ bool generateNextDummyPage(const RsGxsMessageId &threadId, const int lines, cons
} }
#include <retroshare/rsidentity.h>
std::string chooseRandomAuthorId()
{
/* 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++);
std::string answer;
if (it != ownIds.end())
{
answer = *it;
}
return answer;
}
void p3Wiki::dummyTick() void p3Wiki::dummyTick()
{ {
if (mAboutActive) if (mAboutActive)
@ -437,6 +461,7 @@ void p3Wiki::dummyTick()
page.mMeta.mGroupId = groupId; page.mMeta.mGroupId = groupId;
page.mPage = "Baseline page... a placeholder for About Wiki"; page.mPage = "Baseline page... a placeholder for About Wiki";
page.mMeta.mMsgName = "About RsWiki"; page.mMeta.mMsgName = "About RsWiki";
page.mMeta.mAuthorId = chooseRandomAuthorId();
submitSnapshot(mAboutToken, page); submitSnapshot(mAboutToken, page);
mAboutLines++; mAboutLines++;
@ -459,6 +484,7 @@ void p3Wiki::dummyTick()
RsWikiSnapshot page; RsWikiSnapshot page;
page.mMeta.mMsgName = "About RsWiki"; page.mMeta.mMsgName = "About RsWiki";
page.mMeta.mAuthorId = chooseRandomAuthorId();
if (!generateNextDummyPage(mAboutThreadId, mAboutLines, msgId, about_txt, about_len, page)) if (!generateNextDummyPage(mAboutThreadId, mAboutLines, msgId, about_txt, about_len, page))
{ {
std::cerr << "About Pages Done"; std::cerr << "About Pages Done";
@ -502,6 +528,7 @@ void p3Wiki::dummyTick()
page.mMeta.mGroupId = groupId; page.mMeta.mGroupId = groupId;
page.mPage = "Baseline page... a placeholder for Improv Wiki"; page.mPage = "Baseline page... a placeholder for Improv Wiki";
page.mMeta.mMsgName = "Improv RsWiki"; page.mMeta.mMsgName = "Improv RsWiki";
page.mMeta.mAuthorId = chooseRandomAuthorId();
submitSnapshot(mImprovToken, page); submitSnapshot(mImprovToken, page);
mImprovLines++; mImprovLines++;
@ -524,6 +551,7 @@ void p3Wiki::dummyTick()
RsWikiSnapshot page; RsWikiSnapshot page;
page.mMeta.mMsgName = "Improv RsWiki"; page.mMeta.mMsgName = "Improv RsWiki";
page.mMeta.mAuthorId = chooseRandomAuthorId();
if (!generateNextDummyPage(mImprovThreadId, mImprovLines, msgId, improvements_txt, improvements_len, page)) if (!generateNextDummyPage(mImprovThreadId, mImprovLines, msgId, improvements_txt, improvements_len, page))
{ {
std::cerr << "Improv Pages Done"; std::cerr << "Improv Pages Done";