mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-10 23:52:51 -04:00
Added basic GXS Wiki Service.
* Filled in p3wiki and rswiki * tweaked VEG files to prevent clashes. * added serialiser header. Still to do: * complete design of Wiki Links, and the like. * Finish serialiser git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5692 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c5d750c0ea
commit
d4bf742268
7 changed files with 521 additions and 6 deletions
184
libretroshare/src/services/p3wiki.cc
Normal file
184
libretroshare/src/services/p3wiki.cc
Normal file
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
* libretroshare/src/services p3wiki.cc
|
||||
*
|
||||
* Wiki interface for RetroShare.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include "services/p3wiki.h"
|
||||
#include "serialiser/rswikiitems.h"
|
||||
|
||||
/****
|
||||
* #define WIKI_DEBUG 1
|
||||
****/
|
||||
|
||||
RsWiki *rsWiki = NULL;
|
||||
|
||||
|
||||
p3Wiki::p3Wiki(RsGeneralDataService* gds, RsNetworkExchangeService* nes)
|
||||
:RsGenExchange(gds, nes, NULL, RS_SERVICE_GXSV1_TYPE_WIKI), RsWiki(this)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void p3Wiki::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
||||
{
|
||||
receiveChanges(changes);
|
||||
}
|
||||
|
||||
/* Specific Service Data */
|
||||
bool p3Wiki::getCollections(const uint32_t &token, std::vector<RsWikiCollection> &collections)
|
||||
{
|
||||
std::vector<RsGxsGrpItem*> grpData;
|
||||
bool ok = RsGenExchange::getGroupData(token, grpData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin();
|
||||
|
||||
for(; vit != grpData.end(); vit++)
|
||||
{
|
||||
RsGxsWikiCollectionItem* item = dynamic_cast<RsGxsWikiCollectionItem*>(*vit);
|
||||
RsWikiCollection collection = item->collection;
|
||||
collection.mMeta = item->collection.mMeta;
|
||||
delete item;
|
||||
collections.push_back(collection);
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool p3Wiki::getSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots)
|
||||
{
|
||||
GxsMsgDataMap msgData;
|
||||
bool ok = RsGenExchange::getMsgData(token, msgData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
GxsMsgDataMap::iterator mit = msgData.begin();
|
||||
|
||||
for(; mit != msgData.end(); mit++)
|
||||
{
|
||||
RsGxsGroupId grpId = mit->first;
|
||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||
|
||||
for(; vit != msgItems.end(); vit++)
|
||||
{
|
||||
RsGxsWikiSnapshotItem* item = dynamic_cast<RsGxsWikiSnapshotItem*>(*vit);
|
||||
|
||||
if(item)
|
||||
{
|
||||
RsWikiSnapshot snapshot = item->snapshot;
|
||||
snapshot.mMeta = item->meta;
|
||||
snapshots.push_back(snapshot);
|
||||
delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Not a WikiSnapshot Item, deleting!" << std::endl;
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool p3Wiki::getComments(const uint32_t &token, std::vector<RsWikiComment> &comments)
|
||||
{
|
||||
GxsMsgDataMap msgData;
|
||||
bool ok = RsGenExchange::getMsgData(token, msgData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
GxsMsgDataMap::iterator mit = msgData.begin();
|
||||
|
||||
for(; mit != msgData.end(); mit++)
|
||||
{
|
||||
RsGxsGroupId grpId = mit->first;
|
||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||
|
||||
for(; vit != msgItems.end(); vit++)
|
||||
{
|
||||
RsGxsWikiCommentItem* item = dynamic_cast<RsGxsWikiCommentItem*>(*vit);
|
||||
|
||||
if(item)
|
||||
{
|
||||
RsWikiComment comment = item->comment;
|
||||
comment.mMeta = item->meta;
|
||||
comments.push_back(comment);
|
||||
delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Not a WikiComment Item, deleting!" << std::endl;
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool p3Wiki::submitCollection(uint32_t &token, RsWikiCollection &collection)
|
||||
{
|
||||
RsGxsWikiCollectionItem* collectionItem = new RsGxsWikiCollectionItem();
|
||||
collectionItem->collection = collection;
|
||||
collectionItem->meta = collection.mMeta;
|
||||
RsGenExchange::publishGroup(token, collectionItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool p3Wiki::submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot)
|
||||
{
|
||||
RsGxsWikiSnapshotItem* snapshotItem = new RsGxsWikiSnapshotItem();
|
||||
snapshotItem->snapshot = snapshot;
|
||||
snapshotItem->meta = snapshot.mMeta;
|
||||
snapshotItem->meta.mMsgFlags = FLAG_MSG_TYPE_WIKI_SNAPSHOT;
|
||||
|
||||
RsGenExchange::publishMsg(token, snapshotItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool p3Wiki::submitComment(uint32_t &token, RsWikiComment &comment)
|
||||
{
|
||||
RsGxsWikiCommentItem* commentItem = new RsGxsWikiCommentItem();
|
||||
commentItem->comment = comment;
|
||||
commentItem->meta = comment.mMeta;
|
||||
commentItem->meta.mMsgFlags = FLAG_MSG_TYPE_WIKI_COMMENT;
|
||||
|
||||
RsGenExchange::publishMsg(token, commentItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
69
libretroshare/src/services/p3wiki.h
Normal file
69
libretroshare/src/services/p3wiki.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* libretroshare/src/services: p3wikiservice.h
|
||||
*
|
||||
* Wiki interface for RetroShare.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef P3_WIKI_SERVICE_HEADER
|
||||
#define P3_WIKI_SERVICE_HEADER
|
||||
|
||||
#include "retroshare/rswiki.h"
|
||||
#include "gxs/rsgenexchange.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
* Wiki Service
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class p3Wiki: public RsGenExchange, public RsWiki
|
||||
{
|
||||
public:
|
||||
p3Wiki(RsGeneralDataService* gds, RsNetworkExchangeService* nes);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) ;
|
||||
|
||||
public:
|
||||
|
||||
/* Specific Service Data */
|
||||
virtual bool getCollections(const uint32_t &token, std::vector<RsWikiCollection> &collections);
|
||||
virtual bool getSnapshots(const uint32_t &token, std::vector<RsWikiSnapshot> &snapshots);
|
||||
virtual bool getComments(const uint32_t &token, std::vector<RsWikiComment> &comments);
|
||||
|
||||
virtual bool submitCollection(uint32_t &token, RsWikiCollection &collection);
|
||||
virtual bool submitSnapshot(uint32_t &token, RsWikiSnapshot &snapshot);
|
||||
virtual bool submitComment(uint32_t &token, RsWikiComment &comment);
|
||||
|
||||
private:
|
||||
|
||||
//std::string genRandomId();
|
||||
// RsMutex mWikiMtx;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -23,8 +23,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef P3_WIKI_SERVICE_HEADER
|
||||
#define P3_WIKI_SERVICE_HEADER
|
||||
#ifndef P3_WIKI_SERVICE_VEG_HEADER
|
||||
#define P3_WIKI_SERVICE_VEG_HEADER
|
||||
|
||||
#include "services/p3gxsserviceVEG.h"
|
||||
#include "retroshare/rswikiVEG.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue