From a374f1dc6bc5a60407460f4d621a75c3c9f0340d Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sat, 13 Mar 2021 21:11:18 +0100 Subject: [PATCH] Implement RsNxsSerialiser::create_item for RsNxsPullRequestItem --- libretroshare/src/rsitems/rsnxsitems.cc | 6 ++++++ libretroshare/src/rsitems/rsnxsitems.h | 15 ++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libretroshare/src/rsitems/rsnxsitems.cc b/libretroshare/src/rsitems/rsnxsitems.cc index e8178e045..94409bc19 100644 --- a/libretroshare/src/rsitems/rsnxsitems.cc +++ b/libretroshare/src/rsitems/rsnxsitems.cc @@ -64,6 +64,12 @@ RsItem *RsNxsSerialiser::create_item(uint16_t service_id,uint8_t item_subtype) c if(service_id != SERVICE_TYPE) return NULL ; + switch(static_cast(item_subtype)) + { + case RsNxsSubtype::PULL_REQUEST: + return new RsNxsPullRequestItem(static_cast(service_id)); + } + switch(item_subtype) { case RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM: return new RsNxsSyncGrpReqItem(SERVICE_TYPE) ; diff --git a/libretroshare/src/rsitems/rsnxsitems.h b/libretroshare/src/rsitems/rsnxsitems.h index 8be63f74c..c7b6c58e3 100644 --- a/libretroshare/src/rsitems/rsnxsitems.h +++ b/libretroshare/src/rsitems/rsnxsitems.h @@ -35,8 +35,12 @@ #include "serialiser/rstlvkeys.h" #include "gxs/rsgxsdata.h" -// These items have "flag type" numbers, but this is not used. +enum class RsNxsSubtype : uint8_t +{ + PULL_REQUEST = 0x90 /// @see RsNxsPullRequestItem +}; +// These items have "flag type" numbers, but this is not used. // TODO: refactor as C++11 enum class const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP_REQ_ITEM = 0x01; const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM = 0x02; @@ -50,10 +54,6 @@ const uint8_t RS_PKT_SUBTYPE_NXS_MSG_ITEM = 0x20; const uint8_t RS_PKT_SUBTYPE_NXS_TRANSAC_ITEM = 0x40; const uint8_t RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY_ITEM = 0x80; -enum class RsNxsSubtype : uint8_t -{ - PULL_REQUEST = 0x90 /// @see RsNxsPullRequestItem -}; #ifdef RS_DEAD_CODE // possibility create second service to deal with this functionality @@ -525,8 +525,9 @@ class RsNxsSerialiser : public RsServiceSerializer { public: - explicit RsNxsSerialiser(uint16_t servtype) : RsServiceSerializer(servtype), SERVICE_TYPE(servtype) {} - virtual ~RsNxsSerialiser() {} + explicit RsNxsSerialiser(uint16_t servtype): + RsServiceSerializer(servtype), SERVICE_TYPE(servtype) {} + virtual ~RsNxsSerialiser() = default; virtual RsItem *create_item(uint16_t service_id,uint8_t item_subtype) const ;