2014-02-19 06:08:37 -05:00
|
|
|
#ifndef RS_GXSREPUTATION_ITEMS_H
|
|
|
|
#define RS_GXSREPUTATION_ITEMS_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/serialiser: rsgxsreputationitems.h
|
|
|
|
*
|
|
|
|
* RetroShare Serialiser.
|
|
|
|
*
|
|
|
|
* Copyright 2014 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 <map>
|
|
|
|
|
2017-04-18 15:11:37 -04:00
|
|
|
#include "rsitems/rsserviceids.h"
|
2014-02-19 06:08:37 -05:00
|
|
|
#include "serialiser/rsserial.h"
|
2016-08-04 05:43:35 -04:00
|
|
|
#include "serialiser/rstlvidset.h"
|
2014-03-20 07:26:53 -04:00
|
|
|
#include "retroshare/rsgxsifacetypes.h"
|
2017-01-08 05:10:33 -05:00
|
|
|
#include "retroshare/rsreputations.h"
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
#include "serialization/rsserializer.h"
|
|
|
|
|
2016-08-02 17:57:11 -04:00
|
|
|
#define RS_PKT_SUBTYPE_GXS_REPUTATION_CONFIG_ITEM 0x01
|
|
|
|
#define RS_PKT_SUBTYPE_GXS_REPUTATION_SET_ITEM_deprecated2 0x02
|
|
|
|
#define RS_PKT_SUBTYPE_GXS_REPUTATION_UPDATE_ITEM 0x03
|
|
|
|
#define RS_PKT_SUBTYPE_GXS_REPUTATION_REQUEST_ITEM 0x04
|
2017-01-08 05:10:33 -05:00
|
|
|
#define RS_PKT_SUBTYPE_GXS_REPUTATION_SET_ITEM_deprecated1 0x05
|
|
|
|
#define RS_PKT_SUBTYPE_GXS_REPUTATION_SET_ITEM_deprecated3 0x06
|
2016-08-04 05:43:35 -04:00
|
|
|
#define RS_PKT_SUBTYPE_GXS_REPUTATION_BANNED_NODE_SET_ITEM 0x07
|
2017-01-08 05:10:33 -05:00
|
|
|
#define RS_PKT_SUBTYPE_GXS_REPUTATION_SET_ITEM 0x08
|
2014-02-19 06:08:37 -05:00
|
|
|
|
|
|
|
/**************************************************************************/
|
2015-10-06 00:11:18 -04:00
|
|
|
class RsReputationItem: public RsItem
|
2014-02-19 06:08:37 -05:00
|
|
|
{
|
|
|
|
public:
|
2015-10-06 00:11:18 -04:00
|
|
|
RsReputationItem(uint8_t reputation_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_GXS_TYPE_REPUTATION,reputation_subtype)
|
|
|
|
{
|
|
|
|
setPriorityLevel(QOS_PRIORITY_RS_GXSREPUTATION_ITEM);
|
|
|
|
}
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2015-10-06 00:11:18 -04:00
|
|
|
virtual ~RsReputationItem() {}
|
|
|
|
virtual void clear() = 0 ;
|
2014-02-19 06:08:37 -05:00
|
|
|
};
|
|
|
|
|
2015-10-06 00:11:18 -04:00
|
|
|
class RsGxsReputationConfigItem: public RsReputationItem
|
2014-02-19 06:08:37 -05:00
|
|
|
{
|
2015-10-06 00:11:18 -04:00
|
|
|
public:
|
|
|
|
RsGxsReputationConfigItem() :RsReputationItem(RS_PKT_SUBTYPE_GXS_REPUTATION_CONFIG_ITEM) {}
|
|
|
|
|
|
|
|
virtual ~RsGxsReputationConfigItem() {}
|
|
|
|
virtual void clear() {}
|
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
virtual void serial_process(SerializeJob /* j */,SerializeContext& /* ctx */) ;
|
|
|
|
|
2015-10-06 00:11:18 -04:00
|
|
|
RsPeerId mPeerId;
|
|
|
|
uint32_t mLatestUpdate; // timestamp they returned.
|
2016-08-02 17:57:11 -04:00
|
|
|
uint32_t mLastQuery; // when we sent out.
|
2014-02-19 06:08:37 -05:00
|
|
|
};
|
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
#ifdef TO_REMOVE
|
2017-01-08 05:10:33 -05:00
|
|
|
// This class should disappear. Deprecated since Jan 7, 2017. The class definition is actually not needed,
|
2016-08-02 17:57:11 -04:00
|
|
|
// that is why it's commented out. Kept here in order to explains how the deserialisation works.
|
|
|
|
//
|
2017-01-08 05:10:33 -05:00
|
|
|
class RsGxsReputationSetItem_deprecated3: public RsReputationItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsGxsReputationSetItem_deprecated3() :RsReputationItem(RS_PKT_SUBTYPE_GXS_REPUTATION_SET_ITEM_deprecated3) {}
|
2016-08-02 17:57:11 -04:00
|
|
|
|
2017-01-08 05:10:33 -05:00
|
|
|
virtual ~RsGxsReputationSetItem_deprecated3() {}
|
|
|
|
virtual void clear() {}
|
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
virtual void serial_process(SerializeJob /* j */,SerializeContext& /* ctx */) ;
|
2017-01-08 05:10:33 -05:00
|
|
|
|
|
|
|
RsGxsId mGxsId;
|
|
|
|
uint32_t mOwnOpinion;
|
|
|
|
uint32_t mOwnOpinionTS;
|
|
|
|
uint32_t mIdentityFlags ;
|
|
|
|
RsPgpId mOwnerNodeId;
|
|
|
|
std::map<RsPeerId, uint32_t> mOpinions; // RsPeerId -> Opinion.
|
|
|
|
};
|
2017-04-22 15:10:55 -04:00
|
|
|
#endif
|
|
|
|
|
2015-10-06 00:11:18 -04:00
|
|
|
class RsGxsReputationSetItem: public RsReputationItem
|
2014-02-19 06:08:37 -05:00
|
|
|
{
|
2015-10-06 00:11:18 -04:00
|
|
|
public:
|
2017-01-08 05:10:33 -05:00
|
|
|
RsGxsReputationSetItem() :RsReputationItem(RS_PKT_SUBTYPE_GXS_REPUTATION_SET_ITEM)
|
|
|
|
{
|
|
|
|
mOwnOpinion = RsReputations::OPINION_NEUTRAL ;
|
|
|
|
mOwnOpinionTS = 0;
|
|
|
|
mIdentityFlags = 0;
|
|
|
|
mLastUsedTS = 0;
|
|
|
|
}
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2015-10-06 22:39:14 -04:00
|
|
|
virtual ~RsGxsReputationSetItem() {}
|
2016-08-02 17:57:11 -04:00
|
|
|
virtual void clear();
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
virtual void serial_process(SerializeJob /* j */,SerializeContext& /* ctx */) ;
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2016-08-02 17:57:11 -04:00
|
|
|
RsGxsId mGxsId;
|
|
|
|
uint32_t mOwnOpinion;
|
|
|
|
uint32_t mOwnOpinionTS;
|
2017-01-08 05:10:33 -05:00
|
|
|
uint32_t mIdentityFlags;
|
|
|
|
uint32_t mLastUsedTS;
|
2016-08-02 17:57:11 -04:00
|
|
|
RsPgpId mOwnerNodeId;
|
|
|
|
std::map<RsPeerId, uint32_t> mOpinions; // RsPeerId -> Opinion.
|
|
|
|
};
|
2016-08-04 05:43:35 -04:00
|
|
|
class RsGxsReputationBannedNodeSetItem: public RsReputationItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsGxsReputationBannedNodeSetItem() :RsReputationItem(RS_PKT_SUBTYPE_GXS_REPUTATION_BANNED_NODE_SET_ITEM) {}
|
|
|
|
|
|
|
|
virtual ~RsGxsReputationBannedNodeSetItem() {}
|
|
|
|
virtual void clear();
|
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
virtual void serial_process(SerializeJob /* j */,SerializeContext& /* ctx */) ;
|
2016-08-04 05:43:35 -04:00
|
|
|
|
|
|
|
RsPgpId mPgpId ;
|
|
|
|
uint32_t mLastActivityTS ;
|
|
|
|
RsTlvGxsIdSet mKnownIdentities ;
|
|
|
|
};
|
|
|
|
|
2015-10-06 00:11:18 -04:00
|
|
|
class RsGxsReputationUpdateItem: public RsReputationItem
|
2014-02-19 06:08:37 -05:00
|
|
|
{
|
2015-10-06 00:11:18 -04:00
|
|
|
public:
|
|
|
|
RsGxsReputationUpdateItem() :RsReputationItem(RS_PKT_SUBTYPE_GXS_REPUTATION_UPDATE_ITEM) {}
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2015-10-06 22:39:14 -04:00
|
|
|
virtual ~RsGxsReputationUpdateItem() {}
|
2015-10-06 00:11:18 -04:00
|
|
|
virtual void clear();
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
virtual void serial_process(SerializeJob /* j */,SerializeContext& /* ctx */) ;
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
uint32_t mLatestUpdate;
|
2015-10-06 00:11:18 -04:00
|
|
|
std::map<RsGxsId, uint32_t> mOpinions; // GxsId -> Opinion.
|
|
|
|
};
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2015-10-06 00:11:18 -04:00
|
|
|
class RsGxsReputationRequestItem: public RsReputationItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RsGxsReputationRequestItem() :RsReputationItem(RS_PKT_SUBTYPE_GXS_REPUTATION_REQUEST_ITEM) {}
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2015-10-06 22:39:14 -04:00
|
|
|
virtual ~RsGxsReputationRequestItem() {}
|
2015-10-06 00:11:18 -04:00
|
|
|
virtual void clear() {}
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
virtual void serial_process(SerializeJob /* j */,SerializeContext& /* ctx */) ;
|
2014-02-19 06:08:37 -05:00
|
|
|
|
2015-10-06 00:11:18 -04:00
|
|
|
uint32_t mLastUpdate;
|
|
|
|
};
|
2014-02-19 06:08:37 -05:00
|
|
|
|
|
|
|
|
2017-04-24 08:14:34 -04:00
|
|
|
class RsGxsReputationSerialiser: public RsServiceSerializer
|
2015-10-06 00:11:18 -04:00
|
|
|
{
|
|
|
|
public:
|
2017-04-24 08:14:34 -04:00
|
|
|
RsGxsReputationSerialiser() :RsServiceSerializer(RS_SERVICE_GXS_TYPE_REPUTATION){}
|
2015-10-06 00:11:18 -04:00
|
|
|
virtual ~RsGxsReputationSerialiser(){}
|
|
|
|
|
2017-04-22 15:10:55 -04:00
|
|
|
virtual RsItem *create_item(uint16_t service,uint8_t item_type) const;
|
2014-02-19 06:08:37 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
#endif /* RS_GXSREPUTATION_ITEMS_H */
|
|
|
|
|
|
|
|
|