moved GxsNotify classes to rsgxsnotify.h internal to gxs (not visible in API) since it is unused in GUI. Added event item in forum to handle moderator list changes

This commit is contained in:
csoler 2020-04-26 23:35:37 +02:00
parent ae54e53bc1
commit f7199f1f1c
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
9 changed files with 69 additions and 89 deletions

View file

@ -112,6 +112,7 @@ enum class RsForumEventCode: uint8_t
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed
MODERATOR_LIST_CHANGED = 0x08, /// forum moderation list has changed.
};
struct RsGxsForumEvent: RsEvent
@ -123,6 +124,8 @@ struct RsGxsForumEvent: RsEvent
RsForumEventCode mForumEventCode;
RsGxsGroupId mForumGroupId;
RsGxsMessageId mForumMsgId;
std::list<RsGxsId> mModeratorsAdded;
std::list<RsGxsId> mModeratorsRemoved;
///* @see RsEvent @see RsSerializable
void serial_process(
@ -133,6 +136,9 @@ struct RsGxsForumEvent: RsEvent
RS_SERIAL_PROCESS(mForumEventCode);
RS_SERIAL_PROCESS(mForumGroupId);
RS_SERIAL_PROCESS(mForumMsgId);
RS_SERIAL_PROCESS(mForumMsgId);
RS_SERIAL_PROCESS(mModeratorsAdded);
RS_SERIAL_PROCESS(mModeratorsRemoved);
}
~RsGxsForumEvent() override;

View file

@ -116,12 +116,14 @@ struct RsGxsIface
*/
virtual uint16_t serviceType() const =0;
#ifdef TO_REMOVE
/*!
* Gxs services should call this for automatic handling of
* changes, send
* @param changes
*/
virtual void receiveChanges(std::vector<RsGxsNotify*>& changes) = 0;
#endif
/*!
* @return handle to token service for this GXS service

View file

@ -72,6 +72,7 @@ public:
~RsGxsIfaceHelper() = default;
#ifdef TO_REMOVE
/*!
* Gxs services should call this for automatic handling of
* changes, send
@ -81,6 +82,7 @@ public:
{
mGxs.receiveChanges(changes);
}
#endif
/* Generic Lists */

View file

@ -32,86 +32,6 @@ typedef uint32_t TurtleRequestId;
typedef std::map<RsGxsGroupId, std::vector<RsMsgMetaData> > GxsMsgMetaMap;
typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsMsgMetaData> > GxsMsgRelatedMetaMap;
class RsNxsGrp;
/*!
* The aim of this class is to abstract how changes are represented so they can
* be determined outside the client API without explcitly enumerating all
* possible changes at the interface
*/
struct RsGxsNotify
{
enum NotifyType
{
TYPE_UNKNOWN = 0x00,
TYPE_PUBLISHED = 0x01,
TYPE_RECEIVED_NEW = 0x02,
TYPE_PROCESSED = 0x03,
TYPE_RECEIVED_PUBLISHKEY = 0x04,
TYPE_RECEIVED_DISTANT_SEARCH_RESULTS = 0x05,
TYPE_STATISTICS_CHANGED = 0x06,
TYPE_UPDATED = 0x07,
};
virtual ~RsGxsNotify() {}
virtual NotifyType getType() = 0;
};
/*!
* Relevant to group changes
*/
class RsGxsGroupChange : public RsGxsNotify
{
public:
RsGxsGroupChange(NotifyType type, bool metaChange) : mNotifyType(type), mMetaChange(metaChange) {}
std::list<RsGxsGroupId> mGrpIdList;
NotifyType getType() override { return mNotifyType;}
bool metaChange() { return mMetaChange; }
protected:
NotifyType mNotifyType;
bool mMetaChange;
};
class RsGxsGroupUpdate : public RsGxsNotify
{
public:
RsGxsGroupUpdate() : mOldGroup(nullptr),mNewGroup(nullptr) {}
RsGxsGroupId mGroupId;
RsNxsGrp *mOldGroup;
RsNxsGrp *mNewGroup;
NotifyType getType() override { return RsGxsNotify::TYPE_UPDATED;}
};
class RsGxsDistantSearchResultChange: public RsGxsNotify
{
public:
RsGxsDistantSearchResultChange(TurtleRequestId id,const RsGxsGroupId& group_id) : mRequestId(id),mGroupId(group_id){}
NotifyType getType() { return TYPE_RECEIVED_DISTANT_SEARCH_RESULTS ; }
TurtleRequestId mRequestId ;
RsGxsGroupId mGroupId;
};
/*!
* Relevant to message changes
*/
class RsGxsMsgChange : public RsGxsNotify
{
public:
RsGxsMsgChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {}
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgChangeMap;
NotifyType getType(){ return NOTIFY_TYPE;}
bool metaChange() { return mMetaChange; }
private:
const NotifyType NOTIFY_TYPE;
bool mMetaChange;
};
#endif // RSGXSSERVICE_H