mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-27 07:47:03 -05:00
* Switch wiki dummy pages to use RsTickEvent.
* Add extra dummy page showing Markdown formatting. * Reduced number of dummy Ids generated. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5961 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b54e1d4bc4
commit
5be03af4cd
@ -131,9 +131,6 @@ virtual bool submitCollection(uint32_t &token, RsWikiCollection &collection) = 0
|
|||||||
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot) = 0;
|
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot) = 0;
|
||||||
virtual bool submitComment(uint32_t &token, RsWikiComment &comment) = 0;
|
virtual bool submitComment(uint32_t &token, RsWikiComment &comment) = 0;
|
||||||
|
|
||||||
// for testing only.
|
|
||||||
virtual void generateDummyData() = 0;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1653,9 +1653,9 @@ std::string p3IdService::genRandomId(int len)
|
|||||||
return randomId;
|
return randomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_KNOWN_PGPIDS 50
|
#define MAX_KNOWN_PGPIDS 20
|
||||||
#define MAX_UNKNOWN_PGPIDS 50
|
#define MAX_UNKNOWN_PGPIDS 20
|
||||||
#define MAX_PSEUDOIDS 100
|
#define MAX_PSEUDOIDS 20
|
||||||
|
|
||||||
#define DUMMY_GXSID_DELAY 5
|
#define DUMMY_GXSID_DELAY 5
|
||||||
|
|
||||||
|
@ -34,20 +34,35 @@
|
|||||||
|
|
||||||
RsWiki *rsWiki = NULL;
|
RsWiki *rsWiki = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #define WIKI_GEN_DUMMY_DATA 1
|
||||||
|
**/
|
||||||
|
|
||||||
|
#define WIKI_GEN_DUMMY_DATA 1
|
||||||
|
|
||||||
|
#define WIKI_EVENT_DUMMYTICK 0x0001
|
||||||
|
#define WIKI_EVENT_DUMMYSTART 0x0002
|
||||||
|
|
||||||
|
#define DUMMYSTART_PERIOD 60 // some time for dummyIds to be generated.
|
||||||
|
#define DUMMYTICK_PERIOD 3
|
||||||
|
|
||||||
p3Wiki::p3Wiki(RsGeneralDataService* gds, RsNetworkExchangeService* nes)
|
p3Wiki::p3Wiki(RsGeneralDataService* gds, RsNetworkExchangeService* nes)
|
||||||
:RsGenExchange(gds, nes, new RsGxsWikiSerialiser(), RS_SERVICE_GXSV1_TYPE_WIKI), RsWiki(this)
|
:RsGenExchange(gds, nes, new RsGxsWikiSerialiser(), RS_SERVICE_GXSV1_TYPE_WIKI), RsWiki(this)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// Setup of dummy Pages.
|
// Setup of dummy Pages.
|
||||||
mAboutActive = false;
|
mAboutActive = false;
|
||||||
mImprovActive = false;
|
mImprovActive = false;
|
||||||
|
mMarkdownActive = false;
|
||||||
|
|
||||||
|
#ifdef WIKI_GEN_DUMMY_DATA
|
||||||
|
RsTickEvent::schedule_in(WIKI_EVENT_DUMMYSTART, DUMMYSTART_PERIOD);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3Wiki::service_tick()
|
void p3Wiki::service_tick()
|
||||||
{
|
{
|
||||||
dummyTick();
|
RsTickEvent::tick_events();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,8 +355,49 @@ const std::string improvements_txt[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const int markdown_len = 34;
|
||||||
|
const std::string markdown_txt[] = {
|
||||||
|
"# An Example of Markdown Editing.",
|
||||||
|
"",
|
||||||
|
"Markdown is quite simple to use, and allows simple HTML.",
|
||||||
|
"",
|
||||||
|
"## Some Blocks below an H2 heading.",
|
||||||
|
"",
|
||||||
|
" * Firstly, we can put a link [in here][]",
|
||||||
|
" * Secondly, as you can see we're in a list.",
|
||||||
|
" * Thirdly, I don't know.",
|
||||||
|
"",
|
||||||
|
"### A Sub (H3) heading.",
|
||||||
|
"",
|
||||||
|
"#### If we want to get into the very small details. (H6).",
|
||||||
|
"",
|
||||||
|
" A bit of code.",
|
||||||
|
" This is a lit",
|
||||||
|
" foreach(in loop)",
|
||||||
|
" a++",
|
||||||
|
" Double quoted stuff.",
|
||||||
|
"",
|
||||||
|
"Or it can be indented like this:",
|
||||||
|
"",
|
||||||
|
"> A block of indented stuff looks like this",
|
||||||
|
"> > With double indenting and ",
|
||||||
|
"> > > triple indenting possible too",
|
||||||
|
"",
|
||||||
|
"Images can be embedded, but thats somethinng to work on in the future.",
|
||||||
|
"",
|
||||||
|
"Sadly it doesn't support tables or div's or anything that complex.",
|
||||||
|
"",
|
||||||
|
"Keep it simple and help write good wiki pages, thx.",
|
||||||
|
"",
|
||||||
|
"[in here]: http://example.com/ \"Optional Title Here\"",
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void p3Wiki::generateDummyData()
|
void p3Wiki::generateDummyData()
|
||||||
{
|
{
|
||||||
|
std::cerr << "p3Wiki::generateDummyData()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
#define GEN_COLLECTIONS 0
|
#define GEN_COLLECTIONS 0
|
||||||
|
|
||||||
@ -369,11 +425,20 @@ void p3Wiki::generateDummyData()
|
|||||||
|
|
||||||
submitCollection(mImprovToken, wiki);
|
submitCollection(mImprovToken, wiki);
|
||||||
|
|
||||||
|
wiki.mMeta.mGroupFlags = 0;
|
||||||
|
wiki.mMeta.mGroupName = "RsWiki Markdown";
|
||||||
|
|
||||||
|
submitCollection(mMarkdownToken, wiki);
|
||||||
|
|
||||||
mAboutLines = 0;
|
mAboutLines = 0;
|
||||||
mImprovLines = 0;
|
mImprovLines = 0;
|
||||||
|
mMarkdownLines = 0;
|
||||||
|
|
||||||
mAboutActive = true;
|
mAboutActive = true;
|
||||||
mImprovActive = true;
|
mImprovActive = true;
|
||||||
|
mMarkdownActive = true;
|
||||||
|
|
||||||
|
RsTickEvent::schedule_in(WIKI_EVENT_DUMMYTICK, DUMMYTICK_PERIOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -566,9 +631,109 @@ void p3Wiki::dummyTick()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (mMarkdownActive)
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wiki::dummyTick() MarkdownActive";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
uint32_t status = RsGenExchange::getTokenService()->requestStatus(mMarkdownToken);
|
||||||
|
|
||||||
|
if (status == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wiki::dummyTick() MarkdownActive, Lines: " << mMarkdownLines;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
if (mMarkdownLines == 0)
|
||||||
|
{
|
||||||
|
/* get the group Id */
|
||||||
|
RsGxsGroupId groupId;
|
||||||
|
if (!acknowledgeTokenGrp(mMarkdownToken, groupId))
|
||||||
|
{
|
||||||
|
std::cerr << " ERROR ";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
mMarkdownActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create baseline snapshot */
|
||||||
|
RsWikiSnapshot page;
|
||||||
|
page.mMeta.mGroupId = groupId;
|
||||||
|
page.mPage = "Baseline page... a placeholder for Markdown Wiki";
|
||||||
|
page.mMeta.mMsgName = "Markdown RsWiki";
|
||||||
|
page.mMeta.mAuthorId = chooseRandomAuthorId();
|
||||||
|
|
||||||
|
submitSnapshot(mMarkdownToken, page);
|
||||||
|
mMarkdownLines++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* get the msg Id, and generate next snapshot */
|
||||||
|
RsGxsGrpMsgIdPair msgId;
|
||||||
|
if (!acknowledgeTokenMsg(mMarkdownToken, msgId))
|
||||||
|
{
|
||||||
|
std::cerr << " ERROR ";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
mMarkdownActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mMarkdownLines == 1)
|
||||||
|
{
|
||||||
|
mMarkdownThreadId = msgId.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsWikiSnapshot page;
|
||||||
|
page.mMeta.mMsgName = "Markdown RsWiki";
|
||||||
|
page.mMeta.mAuthorId = chooseRandomAuthorId();
|
||||||
|
if (!generateNextDummyPage(mMarkdownThreadId, mMarkdownLines, msgId, markdown_txt, markdown_len, page))
|
||||||
|
{
|
||||||
|
std::cerr << "Markdown Pages Done";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
mMarkdownActive = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mMarkdownLines++;
|
||||||
|
submitSnapshot(mMarkdownToken, page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((mAboutActive) || (mImprovActive) || (mMarkdownActive))
|
||||||
|
{
|
||||||
|
/* reschedule next one */
|
||||||
|
RsTickEvent::schedule_in(WIKI_EVENT_DUMMYTICK, DUMMYTICK_PERIOD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Overloaded from RsTickEvent for Event callbacks.
|
||||||
|
void p3Wiki::handle_event(uint32_t event_type, const std::string &elabel)
|
||||||
|
{
|
||||||
|
std::cerr << "p3Wiki::handle_event(" << event_type << ")";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
// stuff.
|
||||||
|
switch(event_type)
|
||||||
|
{
|
||||||
|
case WIKI_EVENT_DUMMYSTART:
|
||||||
|
generateDummyData();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIKI_EVENT_DUMMYTICK:
|
||||||
|
dummyTick();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* error */
|
||||||
|
std::cerr << "p3Wiki::handle_event() Unknown Event Type: " << event_type;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "retroshare/rswiki.h"
|
#include "retroshare/rswiki.h"
|
||||||
#include "gxs/rsgenexchange.h"
|
#include "gxs/rsgenexchange.h"
|
||||||
|
|
||||||
|
#include "util/rstickevent.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -38,7 +40,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class p3Wiki: public RsGenExchange, public RsWiki
|
class p3Wiki: public RsGenExchange, public RsWiki,
|
||||||
|
public RsTickEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
p3Wiki(RsGeneralDataService* gds, RsNetworkExchangeService* nes);
|
p3Wiki(RsGeneralDataService* gds, RsNetworkExchangeService* nes);
|
||||||
@ -47,6 +50,9 @@ protected:
|
|||||||
|
|
||||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) ;
|
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) ;
|
||||||
|
|
||||||
|
// Overloaded from RsTickEvent.
|
||||||
|
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void service_tick();
|
virtual void service_tick();
|
||||||
@ -62,7 +68,6 @@ virtual bool submitCollection(uint32_t &token, RsWikiCollection &collection);
|
|||||||
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot);
|
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot);
|
||||||
virtual bool submitComment(uint32_t &token, RsWikiComment &comment);
|
virtual bool submitComment(uint32_t &token, RsWikiComment &comment);
|
||||||
|
|
||||||
virtual void generateDummyData();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -70,6 +75,8 @@ std::string genRandomId();
|
|||||||
// RsMutex mWikiMtx;
|
// RsMutex mWikiMtx;
|
||||||
|
|
||||||
|
|
||||||
|
virtual void generateDummyData();
|
||||||
|
|
||||||
// Dummy Stuff.
|
// Dummy Stuff.
|
||||||
void dummyTick();
|
void dummyTick();
|
||||||
|
|
||||||
@ -82,6 +89,11 @@ std::string genRandomId();
|
|||||||
uint32_t mImprovToken;
|
uint32_t mImprovToken;
|
||||||
int mImprovLines;
|
int mImprovLines;
|
||||||
RsGxsMessageId mImprovThreadId;
|
RsGxsMessageId mImprovThreadId;
|
||||||
|
|
||||||
|
bool mMarkdownActive;
|
||||||
|
uint32_t mMarkdownToken;
|
||||||
|
int mMarkdownLines;
|
||||||
|
RsGxsMessageId mMarkdownThreadId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user