diff --git a/libretroshare/src/gxs/rsgxsifaceimpl.cc b/libretroshare/src/gxs/rsgxsifaceimpl.cc index bfae83f85..3a488cbef 100644 --- a/libretroshare/src/gxs/rsgxsifaceimpl.cc +++ b/libretroshare/src/gxs/rsgxsifaceimpl.cc @@ -1,3 +1,29 @@ + +/* + * libretroshare/src/gxs/rsgxsifaceimpl.cc: rsgxsifaceimpl.cc + * + * RetroShare GXS. + * + * Copyright 2012 by Christopher Evi-Parker + * + * 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 "rsgxsifaceimpl.h" #include "gxs/rsgxs.h" #include "gxs/rsgxsflags.h" diff --git a/libretroshare/src/gxs/rsgxsifaceimpl.h b/libretroshare/src/gxs/rsgxsifaceimpl.h index a1236421b..df105cd91 100644 --- a/libretroshare/src/gxs/rsgxsifaceimpl.h +++ b/libretroshare/src/gxs/rsgxsifaceimpl.h @@ -1,6 +1,31 @@ #ifndef RSGXSIFACEIMPL_H #define RSGXSIFACEIMPL_H +/* + * libretroshare/src/gxs/: rsgxsifaceimpl.h + * + * RetroShare GXS. Convenience interface implementation + * + * Copyright 2012 by Christopher Evi-Parker + * + * 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 "gxs/rsgenexchange.h" /*! diff --git a/libretroshare/src/serialiser/rsphotov2items.h b/libretroshare/src/serialiser/rsphotov2items.h index c636ab5bc..54cb76a07 100644 --- a/libretroshare/src/serialiser/rsphotov2items.h +++ b/libretroshare/src/serialiser/rsphotov2items.h @@ -33,7 +33,6 @@ #include "serialiser/rstlvtypes.h" #include "rsgxsitems.h" -//#include "rsphotoitems.h" #include "retroshare/rsphotoV2.h" const uint8_t RS_PKT_SUBTYPE_PHOTO_ITEM = 0x02; diff --git a/libretroshare/src/serialiser/rsposteditems.cc b/libretroshare/src/serialiser/rsposteditems.cc new file mode 100644 index 000000000..ce0f71bab --- /dev/null +++ b/libretroshare/src/serialiser/rsposteditems.cc @@ -0,0 +1,653 @@ + +/* + * libretroshare/src/gxs: rsopsteditems.cc + * + * RetroShare Serialiser. + * + * Copyright 2012 by Christopher Evi-Parker + * + * 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 "serialiser/rsposteditems.h" + + +uint32_t RsGxsPostedSerialiser::size(RsItem *item) +{ + RsGxsPostedPostItem* ppItem = NULL; + RsGxsPostedCommentItem* pcItem = NULL; + RsGxsPostedVoteItem* pvItem = NULL; + RsGxsPostedGroupItem* pgItem = NULL; + + if((ppItem = dynamic_cast(item)) != NULL) + { + return sizeGxsPostedPostItem(ppItem); + } + else if((pcItem = dynamic_cast(item)) != NULL) + { + return sizeGxsPostedCommentItem(pcItem); + }else if((pvItem = dynamic_cast(item)) != NULL) + { + return sizeGxsPostedVoteItem(pvItem); + }else if((pgItem = dynamic_cast(item)) != NULL) + { + return sizeGxsPostedGroupItem(pgItem); + } + else + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::size() Failed" << std::endl; +#endif + return NULL; + } +} + +bool RsGxsPostedSerialiser::serialise(RsItem *item, void *data, uint32_t *size) +{ + + RsGxsPostedPostItem* ppItem = NULL; + RsGxsPostedCommentItem* pcItem = NULL; + RsGxsPostedVoteItem* pvItem = NULL; + RsGxsPostedGroupItem* pgItem = NULL; + + if((ppItem = dynamic_cast(item)) != NULL) + { + return serialiseGxsPostedPostItem(ppItem, data, size); + } + else if((pcItem = dynamic_cast(item)) != NULL) + { + return serialiseGxsPostedCommentItem(pcItem, data, size); + }else if((pvItem = dynamic_cast(item)) != NULL) + { + return serialiseGxsPostedVoteItem(pvItem, data, size); + }else if((pgItem = dynamic_cast(item)) != NULL) + { + return serialiseGxsPostedGroupItem(pgItem, data, size); + } + else + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialise() FAILED" << std::endl; +#endif + return false; + } +} + +RsItem* RsGxsPostedSerialiser::deserialise(void *data, uint32_t *size) +{ +#ifdef RSSERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::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_POSTED != getRsItemService(rstype))) + { + return NULL; /* wrong type */ + } + + switch(getRsItemSubType(rstype)) + { + + case RS_PKT_SUBTYPE_POSTED_COMMENT_ITEM: + return deserialiseGxsPostedCommentItem(data, size); + case RS_PKT_SUBTYPE_POSTED_GRP_ITEM: + return deserialiseGxsPostedGroupItem(data, size); + case RS_PKT_SUBTYPE_POSTED_POST_ITEM: + return deserialiseGxsPostedPostItem(data, size); + case RS_PKT_SUBTYPE_POSTED_VOTE_ITEM: + return deserialiseGxsPostedVoteItem(data, size); + default: + { +#ifdef RS_SSERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialise(): subtype could not be dealt with" + << std::endl; +#endif + break; + } + } + return NULL; +} + + +uint32_t RsGxsPostedSerialiser::sizeGxsPostedPostItem(RsGxsPostedPostItem* item) +{ + RsPostedPost& p = item->mPost; + + uint32_t s = 8; + + s += GetTlvStringSize(p.mLink); + s += GetTlvStringSize(p.mNotes); + + return s; +} + +uint32_t RsGxsPostedSerialiser::sizeGxsPostedCommentItem(RsGxsPostedCommentItem* item) +{ + RsPostedComment& c = item->mComment; + + uint32_t s = 8; + + s += GetTlvStringSize(c.mComment); + + return s; +} + +uint32_t RsGxsPostedSerialiser::sizeGxsPostedVoteItem(RsGxsPostedVoteItem* item) +{ + RsPostedVote& v = item->mVote; + + uint32_t s = 8; + + return s; +} + +uint32_t RsGxsPostedSerialiser::sizeGxsPostedGroupItem(RsGxsPostedGroupItem* item) +{ + RsPostedGroup& g = item->mGroup; + + uint32_t s = 8; + return s; +} + +bool RsGxsPostedSerialiser::serialiseGxsPostedPostItem(RsGxsPostedPostItem* item, void* data, uint32_t *size) +{ + +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedPostItem()" << std::endl; +#endif + + uint32_t tlvsize = sizeGxsPostedPostItem(item); + uint32_t offset = 0; + + if(*size < tlvsize){ +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedPostItem()()" << std::endl; +#endif + return false; + } + + *size = tlvsize; + + bool ok = true; + + ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize); + + /* skip the header */ + offset += 8; + + /* GxsPhotoAlbumItem */ + + ok &= SetTlvString(data, tlvsize, &offset, 1, item->mPost.mNotes); + ok &= SetTlvString(data, tlvsize, &offset, 1, item->mPost.mLink); + + + if(offset != tlvsize) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedPostItem() FAIL Size Error! " << std::endl; +#endif + ok = false; + } + +#ifdef GXS_POSTED_SERIAL_DEBUG + if (!ok) + { + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedPostItem() NOK" << std::endl; + } +#endif + + return ok; +} + +bool RsGxsPostedSerialiser::serialiseGxsPostedCommentItem(RsGxsPostedCommentItem* item, void* data, uint32_t *size) +{ +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedCommentItem()" << std::endl; +#endif + + uint32_t tlvsize = sizeGxsPostedCommentItem(item); + uint32_t offset = 0; + + if(*size < tlvsize){ +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedCommentItem()" << std::endl; +#endif + return false; + } + + *size = tlvsize; + + bool ok = true; + + ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize); + + /* skip the header */ + offset += 8; + + /* GxsPhotoAlbumItem */ + + ok &= SetTlvString(data, tlvsize, &offset, 1, item->mComment.mComment); + + + if(offset != tlvsize) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedCommentItem()() FAIL Size Error! " << std::endl; +#endif + ok = false; + } + +#ifdef GXS_POSTED_SERIAL_DEBUG + if (!ok) + { + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedCommentItem()() NOK" << std::endl; + } +#endif + + return ok; +} + +bool RsGxsPostedSerialiser::serialiseGxsPostedVoteItem(RsGxsPostedVoteItem* item, void* data, uint32_t *size) +{ + +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedVoteItem()" << std::endl; +#endif + + uint32_t tlvsize = sizeGxsPostedVoteItem(item); + uint32_t offset = 0; + + if(*size < tlvsize){ +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedVoteItem()" << std::endl; +#endif + return false; + } + + *size = tlvsize; + + bool ok = true; + + ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize); + + /* skip the header */ + offset += 8; + + /* GxsPhotoAlbumItem */ + + if(offset != tlvsize) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedVoteItem() FAIL Size Error! " << std::endl; +#endif + ok = false; + } + +#ifdef GXS_POSTED_SERIAL_DEBUG + if (!ok) + { + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedVoteItem() NOK" << std::endl; + } +#endif + + return ok; +} + +bool RsGxsPostedSerialiser::serialiseGxsPostedGroupItem(RsGxsPostedGroupItem* item, void* data, uint32_t *size) +{ + +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedGroupItem()" << std::endl; +#endif + + uint32_t tlvsize = sizeGxsPostedGroupItem(item); + uint32_t offset = 0; + + if(*size < tlvsize){ +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedGroupItem()" << std::endl; +#endif + return false; + } + + *size = tlvsize; + + bool ok = true; + + ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize); + + /* skip the header */ + offset += 8; + + /* GxsPhotoAlbumItem */ + + if(offset != tlvsize) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedGroupItem() FAIL Size Error! " << std::endl; +#endif + ok = false; + } + +#ifdef GXS_POSTED_SERIAL_DEBUG + if (!ok) + { + std::cerr << "RsGxsPostedSerialiser::serialiseGxsPostedGroupItem() NOK" << std::endl; + } +#endif + + return ok; +} + +RsGxsPostedPostItem* RsGxsPostedSerialiser::deserialiseGxsPostedPostItem(void *data, uint32_t *size) +{ + +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedPostItem()" << 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_POSTED != getRsItemService(rstype)) || + (RS_PKT_SUBTYPE_POSTED_POST_ITEM != getRsItemSubType(rstype))) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedPostItem() FAIL wrong type" << std::endl; +#endif + return NULL; /* wrong type */ + } + + if (*size < rssize) /* check size */ + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedPostItem() FAIL wrong size" << std::endl; +#endif + return NULL; /* not enough data */ + } + + /* set the packet length */ + *size = rssize; + + bool ok = true; + + RsGxsPostedPostItem* item = new RsGxsPostedPostItem(); + /* skip the header */ + offset += 8; + + + ok &= GetTlvString(data, rssize, &offset, 1, item->mPost.mLink); + ok &= GetTlvString(data, rssize, &offset, 1, item->mPost.mNotes); + + if (offset != rssize) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedPostItem() FAIL size mismatch" << std::endl; +#endif + /* error */ + delete item; + return NULL; + } + + if (!ok) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedPostItem() NOK" << std::endl; +#endif + delete item; + return NULL; + } + + return item; +} + +RsGxsPostedCommentItem* RsGxsPostedSerialiser::deserialiseGxsPostedCommentItem(void *data, uint32_t *size) +{ +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedCommentItem()" << 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_POSTED != getRsItemService(rstype)) || + (RS_PKT_SUBTYPE_POSTED_POST_ITEM != getRsItemSubType(rstype))) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedCommentItem() FAIL wrong type" << std::endl; +#endif + return NULL; /* wrong type */ + } + + if (*size < rssize) /* check size */ + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedCommentItem() FAIL wrong size" << std::endl; +#endif + return NULL; /* not enough data */ + } + + /* set the packet length */ + *size = rssize; + + bool ok = true; + + RsGxsPostedCommentItem* item = new RsGxsPostedCommentItem(); + /* skip the header */ + offset += 8; + + + ok &= GetTlvString(data, rssize, &offset, 1, item->mComment.mComment); + + if (offset != rssize) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedCommentItem() FAIL size mismatch" << std::endl; +#endif + /* error */ + delete item; + return NULL; + } + + if (!ok) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedCommentItem() NOK" << std::endl; +#endif + delete item; + return NULL; + } + + return item; +} + +RsGxsPostedVoteItem* RsGxsPostedSerialiser::deserialiseGxsPostedVoteItem(void *data, uint32_t *size) +{ + +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedVoteItem()" << 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_POSTED != getRsItemService(rstype)) || + (RS_PKT_SUBTYPE_POSTED_VOTE_ITEM != getRsItemSubType(rstype))) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedVoteItem() FAIL wrong type" << std::endl; +#endif + return NULL; /* wrong type */ + } + + if (*size < rssize) /* check size */ + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedVoteItem() FAIL wrong size" << std::endl; +#endif + return NULL; /* not enough data */ + } + + /* set the packet length */ + *size = rssize; + + bool ok = true; + + RsGxsPostedVoteItem* item = new RsGxsPostedVoteItem(); + /* skip the header */ + offset += 8; + + if (offset != rssize) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedVoteItem() FAIL size mismatch" << std::endl; +#endif + /* error */ + delete item; + return NULL; + } + + if (!ok) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedVoteItem() NOK" << std::endl; +#endif + delete item; + return NULL; + } + + return item; +} + +RsGxsPostedGroupItem* RsGxsPostedSerialiser::deserialiseGxsPostedGroupItem(void *data, uint32_t *size) +{ + +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedGroupItem()" << 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_POSTED != getRsItemService(rstype)) || + (RS_PKT_SUBTYPE_POSTED_VOTE_ITEM != getRsItemSubType(rstype))) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedGroupItem() FAIL wrong type" << std::endl; +#endif + return NULL; /* wrong type */ + } + + if (*size < rssize) /* check size */ + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedGroupItem() FAIL wrong size" << std::endl; +#endif + return NULL; /* not enough data */ + } + + /* set the packet length */ + *size = rssize; + + bool ok = true; + + RsGxsPostedGroupItem* item = new RsGxsPostedGroupItem(); + /* skip the header */ + offset += 8; + + if (offset != rssize) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedGroupItem() FAIL size mismatch" << std::endl; +#endif + /* error */ + delete item; + return NULL; + } + + if (!ok) + { +#ifdef GXS_POSTED_SERIAL_DEBUG + std::cerr << "RsGxsPostedSerialiser::deserialiseGxsPostedGroupItem() NOK" << std::endl; +#endif + delete item; + return NULL; + } + + return item; +} + + +void RsGxsPostedPostItem::clear() +{ + +} + +std::ostream & RsGxsPostedPostItem::print(std::ostream &out, uint16_t indent) +{ + return out; +} + +void RsGxsPostedVoteItem::clear() +{ + return; +} + +std::ostream & RsGxsPostedVoteItem::print(std::ostream &out, uint16_t indent) +{ + return out; +} + +void RsGxsPostedCommentItem::clear() +{ + return; +} + +std::ostream & RsGxsPostedCommentItem::print(std::ostream &out, uint16_t indent) +{ + return out; +} + +void RsGxsPostedGroupItem::clear() +{ + return; +} + +std::ostream & RsGxsPostedGroupItem::print(std::ostream &out, uint16_t indent) +{ + return out; + +} diff --git a/libretroshare/src/serialiser/rsposteditems.h b/libretroshare/src/serialiser/rsposteditems.h new file mode 100644 index 000000000..7ff748c44 --- /dev/null +++ b/libretroshare/src/serialiser/rsposteditems.h @@ -0,0 +1,101 @@ +#ifndef RSPOSTEDITEMS_H +#define RSPOSTEDITEMS_H + +#include "serialiser/rsserviceids.h" +#include "serialiser/rsserial.h" +#include "serialiser/rstlvtypes.h" + +#include "rsgxsitems.h" +#include "retroshare/rsposted.h" + +const uint8_t RS_PKT_SUBTYPE_POSTED_GRP_ITEM = 0x02; +const uint8_t RS_PKT_SUBTYPE_POSTED_POST_ITEM = 0x03; +const uint8_t RS_PKT_SUBTYPE_POSTED_VOTE_ITEM = 0x04; +const uint8_t RS_PKT_SUBTYPE_POSTED_COMMENT_ITEM = 0x05; + +class RsGxsPostedPostItem : public RsGxsMsgItem +{ +public: + RsGxsPostedPostItem() : RsGxsMsgItem(RS_SERVICE_GXSV1_TYPE_POSTED, + RS_PKT_SUBTYPE_POSTED_POST_ITEM) + {return ; } + + void clear(); + std::ostream &print(std::ostream &out, uint16_t indent = 0); + + RsPostedPost mPost; +}; + +class RsGxsPostedVoteItem : public RsGxsMsgItem +{ +public: + RsGxsPostedVoteItem() : RsGxsMsgItem(RS_SERVICE_GXSV1_TYPE_POSTED, + RS_PKT_SUBTYPE_POSTED_VOTE_ITEM) + {return ;} + + void clear(); + std::ostream &print(std::ostream &out, uint16_t indent = 0); + + RsPostedVote mVote; +}; + +class RsGxsPostedCommentItem : public RsGxsMsgItem +{ +public: + RsGxsPostedCommentItem() : RsGxsMsgItem(RS_SERVICE_GXSV1_TYPE_POSTED, + RS_PKT_SUBTYPE_POSTED_COMMENT_ITEM) + { return; } + + void clear(); + std::ostream &print(std::ostream &out, uint16_t indent = 0); + + RsPostedComment mComment; +}; + +class RsGxsPostedGroupItem : public RsGxsGrpItem +{ +public: + RsGxsPostedGroupItem() : RsGxsGrpItem(RS_SERVICE_GXSV1_TYPE_POSTED, + RS_PKT_SUBTYPE_POSTED_GRP_ITEM) + { return; } + + void clear(); + std::ostream &print(std::ostream &out, uint16_t indent = 0); + + RsPostedGroup mGroup; +}; + +class RsGxsPostedSerialiser : public RsSerialType +{ + + RsGxsPostedSerialiser() + : RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_GXSV1_TYPE_PHOTO) + { return; } + + virtual ~RsGxsPostedSerialiser() { 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 sizeGxsPostedPostItem(RsGxsPostedPostItem* item); + bool serialiseGxsPostedPostItem(RsGxsPostedPostItem* item, void* data, uint32_t *size); + RsGxsPostedPostItem* deserialiseGxsPostedPostItem(void *data, uint32_t *size); + + uint32_t sizeGxsPostedCommentItem(RsGxsPostedCommentItem* item); + bool serialiseGxsPostedCommentItem(RsGxsPostedCommentItem* item, void* data, uint32_t *size); + RsGxsPostedCommentItem* deserialiseGxsPostedCommentItem(void *data, uint32_t *size); + + uint32_t sizeGxsPostedVoteItem(RsGxsPostedVoteItem* item); + bool serialiseGxsPostedVoteItem(RsGxsPostedVoteItem* item, void* data, uint32_t *size); + RsGxsPostedVoteItem* deserialiseGxsPostedVoteItem(void *data, uint32_t *size); + + uint32_t sizeGxsPostedGroupItem(RsGxsPostedGroupItem* item); + bool serialiseGxsPostedGroupItem(RsGxsPostedGroupItem* item, void* data, uint32_t *size); + RsGxsPostedGroupItem* deserialiseGxsPostedGroupItem(void *data, uint32_t *size); +}; + + +#endif // RSPOSTEDITEMS_H diff --git a/libretroshare/src/services/p3posted.cc b/libretroshare/src/services/p3posted.cc index 45e13f5fc..a0fc2e91f 100644 --- a/libretroshare/src/services/p3posted.cc +++ b/libretroshare/src/services/p3posted.cc @@ -7,8 +7,7 @@ p3Posted::p3Posted(RsGeneralDataService *gds, RsNetworkExchangeService *nes) void p3Posted::notifyChanges(std::vector &changes) { - - + receiveChanges(changes); } bool p3Posted::getGroup(const uint32_t &token, RsPostedGroup &group)