From bcd67a865192a5b4212f748e692af1548d6094e6 Mon Sep 17 00:00:00 2001 From: drbob Date: Sun, 2 Dec 2012 19:01:51 +0000 Subject: [PATCH] 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 --- libretroshare/src/services/p3wiki.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libretroshare/src/services/p3wiki.cc b/libretroshare/src/services/p3wiki.cc index 9b3f01aa4..ea13ef672 100644 --- a/libretroshare/src/services/p3wiki.cc +++ b/libretroshare/src/services/p3wiki.cc @@ -407,6 +407,30 @@ bool generateNextDummyPage(const RsGxsMessageId &threadId, const int lines, cons } +#include + +std::string chooseRandomAuthorId() +{ + /* chose a random Id to sign with */ + std::list ownIds; + std::list::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() { if (mAboutActive) @@ -437,6 +461,7 @@ void p3Wiki::dummyTick() page.mMeta.mGroupId = groupId; page.mPage = "Baseline page... a placeholder for About Wiki"; page.mMeta.mMsgName = "About RsWiki"; + page.mMeta.mAuthorId = chooseRandomAuthorId(); submitSnapshot(mAboutToken, page); mAboutLines++; @@ -459,6 +484,7 @@ void p3Wiki::dummyTick() RsWikiSnapshot page; page.mMeta.mMsgName = "About RsWiki"; + page.mMeta.mAuthorId = chooseRandomAuthorId(); if (!generateNextDummyPage(mAboutThreadId, mAboutLines, msgId, about_txt, about_len, page)) { std::cerr << "About Pages Done"; @@ -502,6 +528,7 @@ void p3Wiki::dummyTick() page.mMeta.mGroupId = groupId; page.mPage = "Baseline page... a placeholder for Improv Wiki"; page.mMeta.mMsgName = "Improv RsWiki"; + page.mMeta.mAuthorId = chooseRandomAuthorId(); submitSnapshot(mImprovToken, page); mImprovLines++; @@ -524,6 +551,7 @@ void p3Wiki::dummyTick() RsWikiSnapshot page; page.mMeta.mMsgName = "Improv RsWiki"; + page.mMeta.mAuthorId = chooseRandomAuthorId(); if (!generateNextDummyPage(mImprovThreadId, mImprovLines, msgId, improvements_txt, improvements_len, page)) { std::cerr << "Improv Pages Done";