* Cleaned up lots of old VEG services.

- left the code for p3gxsserviceVEG and p3postedVEG, until p3posted is finished.
 * Converted p3wireVEG => p3wire
 * cleaned up rsinit.cc and libretroshare.pro



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5901 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-11-26 22:53:44 +00:00
parent 6a063ff32d
commit 78bc0a4567
22 changed files with 859 additions and 5315 deletions

View file

@ -198,7 +198,7 @@ bool RsGxsWikiSerialiser::serialiseGxsWikiCollectionItem(RsGxsWikiCollectionItem
#ifdef GXSID_DEBUG
if (!ok)
{
std::cerr << "RsGxsWikiSerialiser::serialiseGxsIdcollectionItem() NOK" << std::endl;
std::cerr << "RsGxsWikiSerialiser::serialiseGxsWikiCollectionItem() NOK" << std::endl;
}
#endif
@ -354,7 +354,7 @@ bool RsGxsWikiSerialiser::serialiseGxsWikiSnapshotItem(RsGxsWikiSnapshotItem *it
#ifdef GXSID_DEBUG
if (!ok)
{
std::cerr << "RsGxsWikiSerialiser::serialiseGxsIdgroupItem() NOK" << std::endl;
std::cerr << "RsGxsWikiSerialiser::serialiseGxsWikiSnapshotItem() NOK" << std::endl;
}
#endif
@ -502,7 +502,7 @@ bool RsGxsWikiSerialiser::serialiseGxsWikiCommentItem(RsGxsWikiCommentItem *item
#ifdef GXSID_DEBUG
if (!ok)
{
std::cerr << "RsGxsWikiSerialiser::serialiseGxsIdgroupItem() NOK" << std::endl;
std::cerr << "RsGxsWikiSerialiser::serialiseGxsWikiCommentItem() NOK" << std::endl;
}
#endif

View file

@ -7,7 +7,7 @@
*
* 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.
* License Version 2.1 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

View file

@ -0,0 +1,408 @@
/*
* libretroshare/src/serialiser: rswikiitems.cc
*
* RetroShare C++ Interface.
*
* 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.1 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 <iostream>
#include "rswireitems.h"
#include "serialiser/rstlvbase.h"
#include "serialiser/rsbaseserial.h"
#define WIRE_DEBUG 1
uint32_t RsGxsWireSerialiser::size(RsItem *item)
{
RsGxsWireGroupItem* grp_item = NULL;
RsGxsWirePulseItem* snap_item = NULL;
if((grp_item = dynamic_cast<RsGxsWireGroupItem*>(item)) != NULL)
{
return sizeGxsWireGroupItem(grp_item);
}
else if((snap_item = dynamic_cast<RsGxsWirePulseItem*>(item)) != NULL)
{
return sizeGxsWirePulseItem(snap_item);
}
return NULL;
}
bool RsGxsWireSerialiser::serialise(RsItem *item, void *data, uint32_t *size)
{
RsGxsWireGroupItem* grp_item = NULL;
RsGxsWirePulseItem* snap_item = NULL;
if((grp_item = dynamic_cast<RsGxsWireGroupItem*>(item)) != NULL)
{
return serialiseGxsWireGroupItem(grp_item, data, size);
}
else if((snap_item = dynamic_cast<RsGxsWirePulseItem*>(item)) != NULL)
{
return serialiseGxsWirePulseItem(snap_item, data, size);
}
return false;
}
RsItem* RsGxsWireSerialiser::deserialise(void* data, uint32_t* size)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialise()" << std::endl;
#endif
/* get the type and size */
uint32_t rstype = getRsItemId(data);
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(RS_SERVICE_GXSV1_TYPE_WIRE != getRsItemService(rstype)))
{
return NULL; /* wrong type */
}
switch(getRsItemSubType(rstype))
{
case RS_PKT_SUBTYPE_WIRE_GROUP_ITEM:
return deserialiseGxsWireGroupItem(data, size);
break;
case RS_PKT_SUBTYPE_WIRE_PULSE_ITEM:
return deserialiseGxsWirePulseItem(data, size);
break;
default:
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialise(): unknown subtype";
std::cerr << std::endl;
#endif
break;
}
return NULL;
}
/*****************************************************************************************/
/*****************************************************************************************/
/*****************************************************************************************/
void RsGxsWireGroupItem::clear()
{
group.mDescription.clear();
}
std::ostream& RsGxsWireGroupItem::print(std::ostream& out, uint16_t indent)
{
printRsItemBase(out, "RsGxsWireGroupItem", indent);
uint16_t int_Indent = indent + 2;
printIndent(out, int_Indent);
out << "Description: " << group.mDescription << std::endl;
printRsItemEnd(out ,"RsGxsWireGroupItem", indent);
return out;
}
uint32_t RsGxsWireSerialiser::sizeGxsWireGroupItem(RsGxsWireGroupItem *item)
{
const RsWireGroup& group = item->group;
uint32_t s = 8; // header
s += GetTlvStringSize(group.mDescription);
return s;
}
bool RsGxsWireSerialiser::serialiseGxsWireGroupItem(RsGxsWireGroupItem *item, void *data, uint32_t *size)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::serialiseGxsWireGroupItem()" << std::endl;
#endif
uint32_t tlvsize = sizeGxsWireGroupItem(item);
uint32_t offset = 0;
if(*size < tlvsize)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::serialiseGxsWireGroupItem()" << std::endl;
#endif
return false;
}
*size = tlvsize;
bool ok = true;
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
/* skip the header */
offset += 8;
/* GxsWireGroupItem */
ok &= SetTlvString(data, tlvsize, &offset, 1, item->group.mDescription);
if(offset != tlvsize)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::serialiseGxsWireGroupItem() FAIL Size Error! " << std::endl;
#endif
ok = false;
}
#ifdef WIRE_DEBUG
if (!ok)
{
std::cerr << "RsGxsWireSerialiser::serialiseGxsWireGroupItem() NOK" << std::endl;
}
#endif
return ok;
}
RsGxsWireGroupItem* RsGxsWireSerialiser::deserialiseGxsWireGroupItem(void *data, uint32_t *size)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWireGroupItem()" << std::endl;
#endif
/* get the type and size */
uint32_t rstype = getRsItemId(data);
uint32_t rssize = getRsItemSize(data);
uint32_t offset = 0;
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(RS_SERVICE_GXSV1_TYPE_WIRE != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_WIRE_GROUP_ITEM != getRsItemSubType(rstype)))
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWireGroupItem() FAIL wrong type" << std::endl;
#endif
return NULL; /* wrong type */
}
if (*size < rssize) /* check size */
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWireGroupItem() FAIL wrong size" << std::endl;
#endif
return NULL; /* not enough data */
}
/* set the packet length */
*size = rssize;
bool ok = true;
RsGxsWireGroupItem* item = new RsGxsWireGroupItem();
/* skip the header */
offset += 8;
ok &= GetTlvString(data, rssize, &offset, 1, item->group.mDescription);
if (offset != rssize)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWireGroupItem() FAIL size mismatch" << std::endl;
#endif
/* error */
delete item;
return NULL;
}
if (!ok)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWireGroupItem() NOK" << std::endl;
#endif
delete item;
return NULL;
}
return item;
}
/*****************************************************************************************/
/*****************************************************************************************/
/*****************************************************************************************/
void RsGxsWirePulseItem::clear()
{
pulse.mPulseText.clear();
pulse.mHashTags.clear();
}
std::ostream& RsGxsWirePulseItem::print(std::ostream& out, uint16_t indent)
{
printRsItemBase(out, "RsGxsWirePulseItem", indent);
uint16_t int_Indent = indent + 2;
printIndent(out, int_Indent);
out << "Page: " << pulse.mPulseText << std::endl;
printIndent(out, int_Indent);
out << "HashTags: " << pulse.mHashTags << std::endl;
printRsItemEnd(out ,"RsGxsWirePulseItem", indent);
return out;
}
uint32_t RsGxsWireSerialiser::sizeGxsWirePulseItem(RsGxsWirePulseItem *item)
{
const RsWirePulse& pulse = item->pulse;
uint32_t s = 8; // header
s += GetTlvStringSize(pulse.mPulseText);
s += GetTlvStringSize(pulse.mHashTags);
return s;
}
bool RsGxsWireSerialiser::serialiseGxsWirePulseItem(RsGxsWirePulseItem *item, void *data, uint32_t *size)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::serialiseGxsWirePulseItem()" << std::endl;
#endif
uint32_t tlvsize = sizeGxsWirePulseItem(item);
uint32_t offset = 0;
if(*size < tlvsize)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::serialiseGxsWirePulseItem()" << std::endl;
#endif
return false;
}
*size = tlvsize;
bool ok = true;
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
/* skip the header */
offset += 8;
/* GxsWirePulseItem */
ok &= SetTlvString(data, tlvsize, &offset, 1, item->pulse.mPulseText);
ok &= SetTlvString(data, tlvsize, &offset, 1, item->pulse.mHashTags);
if(offset != tlvsize)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::serialiseGxsWirePulseItem() FAIL Size Error! " << std::endl;
#endif
ok = false;
}
#ifdef WIRE_DEBUG
if (!ok)
{
std::cerr << "RsGxsWireSerialiser::serialiseGxsWirePulseItem() NOK" << std::endl;
}
#endif
return ok;
}
RsGxsWirePulseItem* RsGxsWireSerialiser::deserialiseGxsWirePulseItem(void *data, uint32_t *size)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWirePulseItem()" << std::endl;
#endif
/* get the type and size */
uint32_t rstype = getRsItemId(data);
uint32_t rssize = getRsItemSize(data);
uint32_t offset = 0;
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(RS_SERVICE_GXSV1_TYPE_WIRE != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_WIRE_PULSE_ITEM != getRsItemSubType(rstype)))
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWirePulseItem() FAIL wrong type" << std::endl;
#endif
return NULL; /* wrong type */
}
if (*size < rssize) /* check size */
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWirePulseItem() FAIL wrong size" << std::endl;
#endif
return NULL; /* not enough data */
}
/* set the packet length */
*size = rssize;
bool ok = true;
RsGxsWirePulseItem* item = new RsGxsWirePulseItem();
/* skip the header */
offset += 8;
ok &= GetTlvString(data, rssize, &offset, 1, item->pulse.mPulseText);
ok &= GetTlvString(data, rssize, &offset, 1, item->pulse.mHashTags);
if (offset != rssize)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWirePulseItem() FAIL size mismatch" << std::endl;
#endif
/* error */
delete item;
return NULL;
}
if (!ok)
{
#ifdef WIRE_DEBUG
std::cerr << "RsGxsWireSerialiser::deserialiseGxsWirePulseItem() NOK" << std::endl;
#endif
delete item;
return NULL;
}
return item;
}
/*****************************************************************************************/
/*****************************************************************************************/
/*****************************************************************************************/

View file

@ -0,0 +1,93 @@
/*
* libretroshare/src/serialiser: rswireitems.h
*
* RetroShare C++ Interface.
*
* 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.1 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 RS_WIRE_ITEMS_H
#define RS_WIRE_ITEMS_H
#include <map>
#include "serialiser/rsserviceids.h"
#include "serialiser/rsserial.h"
#include "serialiser/rstlvtypes.h"
#include "rsgxsitems.h"
#include "retroshare/rswire.h"
const uint8_t RS_PKT_SUBTYPE_WIRE_GROUP_ITEM = 0x02;
const uint8_t RS_PKT_SUBTYPE_WIRE_PULSE_ITEM = 0x03;
class RsGxsWireGroupItem : public RsGxsGrpItem
{
public:
RsGxsWireGroupItem(): RsGxsGrpItem(RS_SERVICE_GXSV1_TYPE_WIRE,
RS_PKT_SUBTYPE_WIRE_GROUP_ITEM) { return;}
virtual ~RsGxsWireGroupItem() { return;}
void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
RsWireGroup group;
};
class RsGxsWirePulseItem : public RsGxsMsgItem
{
public:
RsGxsWirePulseItem(): RsGxsMsgItem(RS_SERVICE_GXSV1_TYPE_WIRE,
RS_PKT_SUBTYPE_WIRE_PULSE_ITEM) {return; }
virtual ~RsGxsWirePulseItem() { return;}
void clear();
std::ostream &print(std::ostream &out, uint16_t indent = 0);
RsWirePulse pulse;
};
class RsGxsWireSerialiser : public RsSerialType
{
public:
RsGxsWireSerialiser()
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_GXSV1_TYPE_WIRE)
{ return; }
virtual ~RsGxsWireSerialiser() { return; }
uint32_t size(RsItem *item);
bool serialise (RsItem *item, void *data, uint32_t *size);
RsItem * deserialise(void *data, uint32_t *size);
private:
uint32_t sizeGxsWireGroupItem(RsGxsWireGroupItem *item);
bool serialiseGxsWireGroupItem (RsGxsWireGroupItem *item, void *data, uint32_t *size);
RsGxsWireGroupItem * deserialiseGxsWireGroupItem(void *data, uint32_t *size);
uint32_t sizeGxsWirePulseItem(RsGxsWirePulseItem *item);
bool serialiseGxsWirePulseItem (RsGxsWirePulseItem *item, void *data, uint32_t *size);
RsGxsWirePulseItem * deserialiseGxsWirePulseItem(void *data, uint32_t *size);
};
#endif /* RS_WIKI_ITEMS_H */