Modified WikiPages service to Request / Response format in libretroshare.

As opposed to the previous ones, this ends up with a massively complicated set of data calls to build 
the tree of modifications... It suggests the need for a dbase cache of MetaData for both Groups and Msgs.

	- modified rsphoto/p3PhotoService interface to conform to 'developing style'
	- shifted fakeprocessrequests() to p3GxsService - as its generic.
	- added requestMsgRelatedList() request to allow searching for OrigMsgId, MsgVersions + LatestVersions.
	- added RsTokReqOptions class to allow fine tuning of requests.
	- major changes to p3WikiService to conform to new standard.
	




git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5204 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-06-08 22:03:09 +00:00
parent b94e6d9888
commit a27cecc522
9 changed files with 460 additions and 61 deletions

View File

@ -36,6 +36,24 @@
* The requests can be generic, but the reponses are service specific (dependent on data types).
*/
// This bit will be filled out over time.
#define RS_TOKREQOPT_MSG_VERSIONS 0x0001
#define RS_TOKREQOPT_MSG_ORIGMSG 0x0002
#define RS_TOKREQOPT_MSG_LATEST 0x0003
#define RS_TOKREQOPT_MSG_THREAD 0x0004
#define RS_TOKREQOPT_MSG_PARENT 0x0005
class RsTokReqOptions
{
public:
RsTokReqOptions() { mOptions = 0; mBefore = 0; mAfter = 0; }
uint32_t mOptions;
time_t mBefore;
time_t mAfter;
};
class RsTokenService
{
public:
@ -44,10 +62,12 @@ class RsTokenService
virtual ~RsTokenService() { return; }
/* Data Requests */
virtual bool requestGroupList(uint32_t &token) = 0;
virtual bool requestGroupData(uint32_t &token, const std::list<std::string> &ids) = 0;
virtual bool requestMsgList(uint32_t &token, const std::list<std::string> &ids) = 0;
virtual bool requestMsgData(uint32_t &token, const std::list<std::string> &ids) = 0;
virtual bool requestGroupList( uint32_t &token, const RsTokReqOptions &opts) = 0;
virtual bool requestMsgList( uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &groupIds) = 0;
virtual bool requestMsgRelatedList(uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &msgIds) = 0;
virtual bool requestGroupData( uint32_t &token, const std::list<std::string> &groupIds) = 0;
virtual bool requestMsgData( uint32_t &token, const std::list<std::string> &msgIds) = 0;
/* Poll */
virtual uint32_t requestStatus(const uint32_t token) = 0;

View File

@ -111,7 +111,31 @@ virtual ~RsPhoto() { return; }
/* changed? */
virtual bool updated() = 0;
/* Data Requests (from RsTokenService) */
//virtual bool requestGroupList( uint32_t &token, const RsTokReqOptions &opts) = 0;
//virtual bool requestMsgList( uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &groupIds) = 0;
//virtual bool requestMsgRelatedList(uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &msgIds) = 0;
//virtual bool requestGroupData( uint32_t &token, const std::list<std::string> &groupIds) = 0;
//virtual bool requestMsgData( uint32_t &token, const std::list<std::string> &msgIds) = 0;
/* Poll */
//virtual uint32_t requestStatus(const uint32_t token) = 0;
/* Generic List Data */
virtual bool getGroupList(const uint32_t &token, std::list<std::string> &groupIds) = 0;
virtual bool getMsgList(const uint32_t &token, std::list<std::string> &msgIds) = 0;
/* Specific Service Data */
virtual bool getAlbum(const uint32_t &token, RsPhotoAlbum &album) = 0;
virtual bool getPhoto(const uint32_t &token, RsPhotoPhoto &photo) = 0;
/* details are updated in album - to choose Album ID, and storage path */
virtual bool submitAlbumDetails(RsPhotoAlbum &album) = 0;
virtual bool submitPhoto(RsPhotoPhoto &photo) = 0;
#if 0
virtual bool requestAlbumList(uint32_t &token) = 0;
virtual bool requestPhotoList(uint32_t &token, const std::list<std::string> &albumids) = 0;
@ -121,23 +145,15 @@ virtual bool requestPhotos(uint32_t &token, const std::list<std::string> &photoi
virtual bool getAlbumList(const uint32_t &token, std::list<std::string> &albums) = 0;
virtual bool getPhotoList(const uint32_t &token, std::list<std::string> &photos) = 0;
virtual bool getAlbum(const uint32_t &token, RsPhotoAlbum &album) = 0;
virtual bool getPhoto(const uint32_t &token, RsPhotoPhoto &photo) = 0;
/* details are updated in album - to choose Album ID, and storage path */
virtual bool submitAlbumDetails(RsPhotoAlbum &album) = 0;
virtual bool submitPhoto(RsPhotoPhoto &photo) = 0;
/* Data Requests (from RsTokenService) */
virtual bool requestGroupList(uint32_t &token) { return requestAlbumList(token); }
virtual bool requestGroupData(uint32_t &token, const std::list<std::string> &ids) { return requestAlbums(token, ids); }
virtual bool requestMsgList(uint32_t &token, const std::list<std::string> &ids) { return requestPhotoList(token, ids); }
virtual bool requestMsgData(uint32_t &token, const std::list<std::string> &ids) { return requestPhotos(token, ids); }
#endif
/* Poll */
virtual uint32_t requestStatus(const uint32_t token) = 0;
};

View File

@ -30,6 +30,8 @@
#include <string>
#include <list>
#include <retroshare/rsidentity.h>
/* The Main Interface Class - for information about your Peers */
class RsWiki;
extern RsWiki *rsWiki;
@ -76,7 +78,7 @@ class RsWikiPage
std::string mHashTags;
};
class RsWiki
class RsWiki: public RsTokenService
{
public:
@ -86,16 +88,39 @@ virtual ~RsWiki() { return; }
/* changed? */
virtual bool updated() = 0;
/* Data Requests (from RsTokenService) */
//virtual bool requestGroupList( uint32_t &token, const RsTokReqOptions &opts) = 0;
//virtual bool requestMsgList( uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &groupIds) = 0;
//virtual bool requestMsgRelatedList(uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &msgIds) = 0;
//virtual bool requestGroupData( uint32_t &token, const std::list<std::string> &groupIds) = 0;
//virtual bool requestMsgData( uint32_t &token, const std::list<std::string> &msgIds) = 0;
/* Poll */
//virtual uint32_t requestStatus(const uint32_t token) = 0;
/* Generic List Data */
virtual bool getGroupList(const uint32_t &token, std::list<std::string> &groupIds) = 0;
virtual bool getMsgList(const uint32_t &token, std::list<std::string> &msgIds) = 0;
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, RsWikiGroup &group) = 0;
virtual bool getMsgData(const uint32_t &token, RsWikiPage &page) = 0;
/* details are updated in group - to choose GroupID */
virtual bool createGroup(RsWikiGroup &group) = 0;
virtual bool createPage(RsWikiPage &page) = 0;
#if 0
virtual bool getGroupList(std::list<std::string> &groups) = 0;
virtual bool getGroup(const std::string &groupid, RsWikiGroup &group) = 0;
virtual bool getPage(const std::string &pageid, RsWikiPage &page) = 0;
virtual bool getPageVersions(const std::string &origPageId, std::list<std::string> &pages) = 0;
virtual bool getOrigPageList(const std::string &groupid, std::list<std::string> &pageIds) = 0;
virtual bool getLatestPage(const std::string &origPageId, std::string &pageId) = 0;
/* details are updated in group - to choose GroupID */
virtual bool createGroup(RsWikiGroup &group) = 0;
virtual bool createPage(RsWikiPage &page) = 0;
#endif
};

View File

@ -193,3 +193,50 @@ bool p3GxsService::popRequestList(const uint32_t &token, std::string &id)
}
#define MAX_REQUEST_AGE 10
bool p3GxsService::fakeprocessrequests()
{
std::list<uint32_t>::iterator it;
std::list<uint32_t> tokens;
tokenList(tokens);
time_t now = time(NULL);
for(it = tokens.begin(); it != tokens.end(); it++)
{
uint32_t status;
uint32_t reqtype;
uint32_t token = *it;
time_t ts;
checkRequestStatus(token, status, reqtype, ts);
std::cerr << "p3GxsService::fakeprocessrequests() Token: " << token << " Status: " << status << " ReqType: " << reqtype << "Age: " << now - ts << std::endl;
if (status == GXS_REQUEST_STATUS_PENDING)
{
updateRequestStatus(token, GXS_REQUEST_STATUS_PARTIAL);
}
else if (status == GXS_REQUEST_STATUS_PARTIAL)
{
updateRequestStatus(token, GXS_REQUEST_STATUS_COMPLETE);
}
else if (status == GXS_REQUEST_STATUS_DONE)
{
std::cerr << "p3GxsService::fakeprocessrequests() Clearing Done Request Token: " << token;
std::cerr << std::endl;
clearRequest(token);
}
else if (now - ts > MAX_REQUEST_AGE)
{
std::cerr << "p3GxsService::fakeprocessrequests() Clearing Old Request Token: " << token;
std::cerr << std::endl;
clearRequest(token);
}
}
return true;
}

View File

@ -84,6 +84,7 @@ bool checkRequestStatus(const uint32_t &token, uint32_t &status, uint32_t &re
// special ones for testing (not in final design)
bool tokenList(std::list<uint32_t> &tokens);
bool popRequestList(const uint32_t &token, std::string &id);
bool fakeprocessrequests();
private:

View File

@ -40,10 +40,10 @@ PhotoAlbum::PhotoAlbum()
}
#endif
#define PHOTO_REQUEST_ALBUMLIST 1
#define PHOTO_REQUEST_PHOTOLIST 2
#define PHOTO_REQUEST_ALBUMS 3
#define PHOTO_REQUEST_PHOTOS 4
#define PHOTO_REQUEST_ALBUMLIST 0x0001
#define PHOTO_REQUEST_PHOTOLIST 0x0002
#define PHOTO_REQUEST_ALBUMS 0x0004
#define PHOTO_REQUEST_PHOTOS 0x0008
/********************************************************************************/
/******************* Startup / Tick ******************************************/
@ -80,11 +80,11 @@ bool p3PhotoService::updated()
}
bool p3PhotoService::requestAlbumList(uint32_t &token)
bool p3PhotoService::requestGroupList( uint32_t &token, const RsTokReqOptions &opts)
{
generateToken(token);
std::cerr << "p3PhotoService::requestAlbumList() gets Token: " << token << std::endl;
std::cerr << "p3PhotoService::requestGroupList() gets Token: " << token << std::endl;
std::list<std::string> ids;
storeRequest(token, GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_GROUPS | PHOTO_REQUEST_ALBUMLIST, ids);
@ -92,39 +92,43 @@ bool p3PhotoService::requestAlbumList(uint32_t &token)
return true;
}
bool p3PhotoService::requestPhotoList(uint32_t &token, const std::list<std::string> &albumids)
bool p3PhotoService::requestMsgList( uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &groupIds)
{
generateToken(token);
std::cerr << "p3PhotoService::requestPhotoList() gets Token: " << token << std::endl;
storeRequest(token, GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_MSGS | PHOTO_REQUEST_PHOTOLIST, albumids);
std::cerr << "p3PhotoService::requestMsgList() gets Token: " << token << std::endl;
storeRequest(token, GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_MSGS | PHOTO_REQUEST_PHOTOLIST, groupIds);
return true;
}
bool p3PhotoService::requestMsgRelatedList( uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &groupIds)
{
std::cerr << "p3PhotoService::requestMsgRelatedList() gets Token: " << token << std::endl;
return false;
}
bool p3PhotoService::requestAlbums(uint32_t &token, const std::list<std::string> &albumids)
bool p3PhotoService::requestGroupData(uint32_t &token, const std::list<std::string> &albumids)
{
generateToken(token);
std::cerr << "p3PhotoService::requestAlbums() gets Token: " << token << std::endl;
std::cerr << "p3PhotoService::requestGroupData() gets Token: " << token << std::endl;
storeRequest(token, GXS_REQUEST_TYPE_DATA | GXS_REQUEST_TYPE_GROUPS | PHOTO_REQUEST_ALBUMS, albumids);
return true;
}
bool p3PhotoService::requestPhotos(uint32_t &token, const std::list<std::string> &photoids)
bool p3PhotoService::requestMsgData(uint32_t &token, const std::list<std::string> &photoids)
{
generateToken(token);
std::cerr << "p3PhotoService::requestPhotos() gets Token: " << token << std::endl;
std::cerr << "p3PhotoService::requestMsgData() gets Token: " << token << std::endl;
storeRequest(token, GXS_REQUEST_TYPE_DATA | GXS_REQUEST_TYPE_MSGS | PHOTO_REQUEST_PHOTOS, photoids);
return true;
}
bool p3PhotoService::getAlbumList(const uint32_t &token, std::list<std::string> &albums)
bool p3PhotoService::getGroupList(const uint32_t &token, std::list<std::string> &groupIds)
{
uint32_t status;
uint32_t reqtype;
@ -133,24 +137,24 @@ bool p3PhotoService::getAlbumList(const uint32_t &token, std::list<std::string>
if (reqtype != (GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_GROUPS | PHOTO_REQUEST_ALBUMLIST))
{
std::cerr << "p3PhotoService::getAlbumList() ERROR Type Wrong" << std::endl;
std::cerr << "p3PhotoService::getGroupList() ERROR Type Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3PhotoService::getAlbumList() ERROR Status Incomplete" << std::endl;
std::cerr << "p3PhotoService::getGroupList() ERROR Status Incomplete" << std::endl;
return false;
}
bool ans = InternalgetAlbumList(albums);
bool ans = InternalgetAlbumList(groupIds);
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
return ans;
}
bool p3PhotoService::getPhotoList(const uint32_t &token, std::list<std::string> &photos)
bool p3PhotoService::getMsgList(const uint32_t &token, std::list<std::string> &msgIds)
{
uint32_t status;
uint32_t reqtype;
@ -159,13 +163,13 @@ bool p3PhotoService::getPhotoList(const uint32_t &token, std::list<std::string>
if (reqtype != (GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_MSGS | PHOTO_REQUEST_PHOTOLIST))
{
std::cerr << "p3PhotoService::getPhotoList() ERROR Type Wrong" << std::endl;
std::cerr << "p3PhotoService::getMsgList() ERROR Type Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3PhotoService::getPhotoList() ERROR Status Incomplete" << std::endl;
std::cerr << "p3PhotoService::getMsgList() ERROR Status Incomplete" << std::endl;
return false;
}
@ -177,7 +181,7 @@ bool p3PhotoService::getPhotoList(const uint32_t &token, std::list<std::string>
return false;
}
bool ans = InternalgetPhotoList(id, photos);
bool ans = InternalgetPhotoList(id, msgIds);
// Only one Album at a time -> so finish it!
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
@ -260,6 +264,7 @@ uint32_t p3PhotoService::requestStatus(const uint32_t token)
}
#if 0
#define MAX_REQUEST_AGE 60
bool p3PhotoService::fakeprocessrequests()
@ -304,6 +309,7 @@ bool p3PhotoService::fakeprocessrequests()
return true;
}
#endif

View File

@ -81,16 +81,22 @@ virtual int tick();
virtual bool updated();
/* Data Requests (from RsTokenService) */
virtual bool requestGroupList( uint32_t &token, const RsTokReqOptions &opts);
virtual bool requestMsgList( uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
virtual bool requestMsgRelatedList(uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &msgIds);
virtual bool requestAlbumList(uint32_t &token);
virtual bool requestPhotoList(uint32_t &token, const std::list<std::string> &albumids);
virtual bool requestGroupData( uint32_t &token, const std::list<std::string> &groupIds);
virtual bool requestMsgData( uint32_t &token, const std::list<std::string> &msgIds);
virtual bool requestAlbums(uint32_t &token, const std::list<std::string> &albumids);
virtual bool requestPhotos(uint32_t &token, const std::list<std::string> &photoids);
/* Poll */
virtual uint32_t requestStatus(const uint32_t token);
virtual bool getAlbumList(const uint32_t &token, std::list<std::string> &albums);
virtual bool getPhotoList(const uint32_t &token, std::list<std::string> &photos);
/* Generic List Data */
virtual bool getGroupList(const uint32_t &token, std::list<std::string> &groupIds);
virtual bool getMsgList(const uint32_t &token, std::list<std::string> &msgIds);
/* Specific Service Data */
virtual bool getAlbum(const uint32_t &token, RsPhotoAlbum &album);
virtual bool getPhoto(const uint32_t &token, RsPhotoPhoto &photo);
@ -98,10 +104,6 @@ virtual bool getPhoto(const uint32_t &token, RsPhotoPhoto &photo);
virtual bool submitAlbumDetails(RsPhotoAlbum &album);
virtual bool submitPhoto(RsPhotoPhoto &photo);
/* Poll */
virtual uint32_t requestStatus(const uint32_t token);
bool fakeprocessrequests();
bool InternalgetAlbumList(std::list<std::string> &album);
bool InternalgetPhotoList(const std::string &albumid, std::list<std::string> &photoIds);

View File

@ -33,13 +33,22 @@
RsWiki *rsWiki = NULL;
#define WIKI_REQUEST_GROUPLIST 0x0001
#define WIKI_REQUEST_MSGLIST 0x0002
#define WIKI_REQUEST_GROUPS 0x0004
#define WIKI_REQUEST_MSGS 0x0008
#define WIKI_REQUEST_PAGEVERSIONS 0x0010
#define WIKI_REQUEST_ORIGPAGE 0x0020
#define WIKI_REQUEST_LATESTPAGE 0x0040
/********************************************************************************/
/******************* Startup / Tick ******************************************/
/********************************************************************************/
p3WikiService::p3WikiService(uint16_t type)
:p3Service(type), mWikiMtx("p3WikiService"), mUpdated(true)
:p3GxsService(type), mWikiMtx("p3WikiService"), mUpdated(true)
{
RsStackMutex stack(mWikiMtx); /********** STACK LOCKED MTX ******/
return;
@ -51,6 +60,8 @@ int p3WikiService::tick()
std::cerr << "p3WikiService::tick()";
std::cerr << std::endl;
fakeprocessrequests();
return 0;
}
@ -66,7 +77,245 @@ bool p3WikiService::updated()
return false;
}
bool p3WikiService::getGroupList(std::list<std::string> &groups)
/***********************************************************************************************/
/* Data Requests */
bool p3WikiService::requestGroupList( uint32_t &token, const RsTokReqOptions &opts)
{
generateToken(token);
std::cerr << "p3WikiService::requestGroupList() gets Token: " << token << std::endl;
std::list<std::string> ids;
storeRequest(token, GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_GROUPS | WIKI_REQUEST_GROUPLIST, ids);
return true;
}
bool p3WikiService::requestMsgList( uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &groupIds)
{
generateToken(token);
std::cerr << "p3WikiService::requestMsgList() gets Token: " << token << std::endl;
storeRequest(token, GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_MSGS | WIKI_REQUEST_ORIGPAGE, groupIds);
return true;
}
bool p3WikiService::requestMsgRelatedList(uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &msgIds)
{
generateToken(token);
std::cerr << "p3WikiService::requestMsgRelatedList() gets Token: " << token << std::endl;
// Look at opts to set the flags.
uint32_t optFlags = 0;
if (opts.mOptions == RS_TOKREQOPT_MSG_VERSIONS)
{
optFlags = WIKI_REQUEST_PAGEVERSIONS;
}
else if (opts.mOptions == RS_TOKREQOPT_MSG_LATEST)
{
optFlags = WIKI_REQUEST_LATESTPAGE;
}
storeRequest(token, GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_MSGS | optFlags, msgIds);
return true;
}
bool p3WikiService::requestGroupData( uint32_t &token, const std::list<std::string> &groupIds)
{
generateToken(token);
std::cerr << "p3WikiService::requestGroupData() gets Token: " << token << std::endl;
storeRequest(token, GXS_REQUEST_TYPE_DATA | GXS_REQUEST_TYPE_GROUPS | WIKI_REQUEST_GROUPS, groupIds);
return true;
}
bool p3WikiService::requestMsgData( uint32_t &token, const std::list<std::string> &msgIds)
{
generateToken(token);
std::cerr << "p3WikiService::requestMsgData() gets Token: " << token << std::endl;
storeRequest(token, GXS_REQUEST_TYPE_DATA | GXS_REQUEST_TYPE_MSGS | WIKI_REQUEST_MSGS, msgIds);
return true;
}
/**************** Return Data *************/
bool p3WikiService::getGroupList(const uint32_t &token, std::list<std::string> &groupIds)
{
uint32_t status;
uint32_t reqtype;
time_t ts;
checkRequestStatus(token, status, reqtype, ts);
if (reqtype != (GXS_REQUEST_TYPE_LIST | GXS_REQUEST_TYPE_GROUPS | WIKI_REQUEST_GROUPLIST))
{
std::cerr << "p3WikiService::getGroupList() ERROR Type Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3WikiService::getGroupList() ERROR Status Incomplete" << std::endl;
return false;
}
bool ans = InternalgetGroupList(groupIds);
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
return ans;
}
bool p3WikiService::getMsgList(const uint32_t &token, std::list<std::string> &msgIds)
{
uint32_t status;
uint32_t reqtype;
time_t ts;
checkRequestStatus(token, status, reqtype, ts);
// MULTIPLY TYPES MATCH HERE....
if (!((reqtype & GXS_REQUEST_TYPE_LIST) && (reqtype & GXS_REQUEST_TYPE_MSGS)))
{
std::cerr << "p3WikiService::getMsgList() ERROR Type Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3WikiService::getMsgList() ERROR Status Incomplete" << std::endl;
return false;
}
std::string id;
bool ans = false;
while (popRequestList(token, id))
{
std::cerr << "p3WikiService::getMsgList() Processing Id: " << id << std::endl;
if (reqtype & WIKI_REQUEST_PAGEVERSIONS)
{
std::cerr << "p3WikiService::getMsgList() get PAGEVERSIONS" << std::endl;
if (InternalgetPageVersions(id, msgIds))
{
ans = true;
}
}
else if (reqtype & WIKI_REQUEST_ORIGPAGE)
{
std::cerr << "p3WikiService::getMsgList() get ORIGPAGE" << std::endl;
if (InternalgetOrigPageList(id, msgIds))
{
ans = true;
}
}
else if (reqtype & WIKI_REQUEST_LATESTPAGE)
{
std::cerr << "p3WikiService::getMsgList() get LATESTPAGE" << std::endl;
std::string latestpage;
if (InternalgetLatestPage(id, latestpage))
{
msgIds.push_back(latestpage);
ans = true;
}
}
else
{
std::cerr << "p3WikiService::getMsgList() ERROR Invalid Request Type" << std::endl;
return false;
}
}
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
return ans;
}
bool p3WikiService::getGroupData(const uint32_t &token, RsWikiGroup &group)
{
uint32_t status;
uint32_t reqtype;
time_t ts;
checkRequestStatus(token, status, reqtype, ts);
if (reqtype != (GXS_REQUEST_TYPE_DATA | GXS_REQUEST_TYPE_GROUPS | WIKI_REQUEST_GROUPS))
{
std::cerr << "p3WikiService::getGroupData() ERROR Type Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3WikiService::getGroupData() ERROR Status Incomplete" << std::endl;
return false;
}
std::string id;
if (!popRequestList(token, id))
{
/* finished */
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
return false;
}
bool ans = InternalgetGroup(id, group);
return ans;
}
bool p3WikiService::getMsgData(const uint32_t &token, RsWikiPage &page)
{
uint32_t status;
uint32_t reqtype;
time_t ts;
checkRequestStatus(token, status, reqtype, ts);
if (reqtype != (GXS_REQUEST_TYPE_DATA | GXS_REQUEST_TYPE_MSGS | WIKI_REQUEST_MSGS))
{
std::cerr << "p3WikiService::getMsgData() ERROR Type Wrong" << std::endl;
return false;
}
if (status != GXS_REQUEST_STATUS_COMPLETE)
{
std::cerr << "p3WikiService::getMsgData() ERROR Status Incomplete" << std::endl;
return false;
}
std::string id;
if (!popRequestList(token, id))
{
/* finished */
updateRequestStatus(token, GXS_REQUEST_STATUS_DONE);
return false;
}
bool ans = InternalgetPage(id, page);
return ans;
}
/* Poll */
uint32_t p3WikiService::requestStatus(const uint32_t token)
{
uint32_t status;
uint32_t reqtype;
time_t ts;
checkRequestStatus(token, status, reqtype, ts);
return status;
}
/****************** INTERNALS ***********************/
bool p3WikiService::InternalgetGroupList(std::list<std::string> &groups)
{
RsStackMutex stack(mWikiMtx); /********** STACK LOCKED MTX ******/
@ -79,7 +328,7 @@ bool p3WikiService::getGroupList(std::list<std::string> &groups)
return false;
}
bool p3WikiService::getGroup(const std::string &groupid, RsWikiGroup &group)
bool p3WikiService::InternalgetGroup(const std::string &groupid, RsWikiGroup &group)
{
RsStackMutex stack(mWikiMtx); /********** STACK LOCKED MTX ******/
@ -96,7 +345,7 @@ bool p3WikiService::getGroup(const std::string &groupid, RsWikiGroup &group)
bool p3WikiService::getPage(const std::string &pageid, RsWikiPage &page)
bool p3WikiService::InternalgetPage(const std::string &pageid, RsWikiPage &page)
{
RsStackMutex stack(mWikiMtx); /********** STACK LOCKED MTX ******/
@ -112,7 +361,7 @@ bool p3WikiService::getPage(const std::string &pageid, RsWikiPage &page)
}
bool p3WikiService::getLatestPage(const std::string &origPageId, std::string &pageId)
bool p3WikiService::InternalgetLatestPage(const std::string &origPageId, std::string &pageId)
{
RsStackMutex stack(mWikiMtx); /********** STACK LOCKED MTX ******/
@ -128,7 +377,7 @@ bool p3WikiService::getLatestPage(const std::string &origPageId, std::string &pa
}
bool p3WikiService::getPageVersions(const std::string &origPageId, std::list<std::string> &pageIds)
bool p3WikiService::InternalgetPageVersions(const std::string &origPageId, std::list<std::string> &pageIds)
{
RsStackMutex stack(mWikiMtx); /********** STACK LOCKED MTX ******/
@ -148,7 +397,7 @@ bool p3WikiService::getPageVersions(const std::string &origPageId, std::list<std
}
bool p3WikiService::getOrigPageList(const std::string &groupid, std::list<std::string> &pageIds)
bool p3WikiService::InternalgetOrigPageList(const std::string &groupid, std::list<std::string> &pageIds)
{
RsStackMutex stack(mWikiMtx); /********** STACK LOCKED MTX ******/

View File

@ -26,7 +26,7 @@
#ifndef P3_WIKI_SERVICE_HEADER
#define P3_WIKI_SERVICE_HEADER
#include "services/p3service.h"
#include "services/p3gxsservice.h"
#include "retroshare/rswiki.h"
@ -48,7 +48,7 @@
*
*/
class p3WikiService: public p3Service, public RsWiki
class p3WikiService: public p3GxsService, public RsWiki
{
public:
@ -58,8 +58,32 @@ virtual int tick();
public:
// NEW INTERFACE.
/************* Extern Interface *******/
virtual bool updated();
/* Data Requests */
virtual bool requestGroupList( uint32_t &token, const RsTokReqOptions &opts);
virtual bool requestMsgList( uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &groupIds);
virtual bool requestMsgRelatedList(uint32_t &token, const RsTokReqOptions &opts, const std::list<std::string> &msgIds);
virtual bool requestGroupData( uint32_t &token, const std::list<std::string> &groupIds);
virtual bool requestMsgData( uint32_t &token, const std::list<std::string> &msgIds);
virtual bool getGroupList(const uint32_t &token, std::list<std::string> &groupIds);
virtual bool getMsgList(const uint32_t &token, std::list<std::string> &msgIds);
virtual bool getGroupData(const uint32_t &token, RsWikiGroup &group);
virtual bool getMsgData(const uint32_t &token, RsWikiPage &page);
/* Poll */
virtual uint32_t requestStatus(const uint32_t token);
virtual bool createGroup(RsWikiGroup &group);
virtual bool createPage(RsWikiPage &page);
/************* Old Extern Interface *******/
#if 0
virtual bool updated();
virtual bool getGroupList(std::list<std::string> &group);
@ -73,8 +97,17 @@ virtual bool getLatestPage(const std::string &origPageId, std::string &page);
virtual bool createGroup(RsWikiGroup &group);
virtual bool createPage(RsWikiPage &page);
#endif
private:
virtual bool InternalgetGroupList(std::list<std::string> &group);
virtual bool InternalgetGroup(const std::string &groupid, RsWikiGroup &group);
virtual bool InternalgetPage(const std::string &pageid, RsWikiPage &page);
virtual bool InternalgetPageVersions(const std::string &origPageId, std::list<std::string> &pages);
virtual bool InternalgetOrigPageList(const std::string &groupid, std::list<std::string> &pageIds);
virtual bool InternalgetLatestPage(const std::string &origPageId, std::string &page);
std::string genRandomId();
RsMutex mWikiMtx;