mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-11-27 02:56:30 -05:00
changed RsEvents so that it takes event types when registering handlers, which limits the number of handlers called for each event
This commit is contained in:
parent
dc2f2f5eb4
commit
c544b1da7c
19 changed files with 186 additions and 140 deletions
|
|
@ -71,23 +71,32 @@ struct RsBroadcastDiscoveryResult : RsSerializable
|
|||
* @brief Event emitted when a non friend new peer is found in the local network
|
||||
* @see RsEvents
|
||||
*/
|
||||
struct RsBroadcastDiscoveryPeerFoundEvent : RsEvent
|
||||
{
|
||||
RsBroadcastDiscoveryPeerFoundEvent(
|
||||
const RsBroadcastDiscoveryResult& eventData ) :
|
||||
RsEvent(RsEventType::BROADCAST_DISCOVERY_PEER_FOUND), mData(eventData) {}
|
||||
enum class RsBroadcastDiscoveryEventType: uint32_t {
|
||||
UNKNOWN = 0x00,
|
||||
PEER_FOUND = 0x01
|
||||
};
|
||||
|
||||
RsBroadcastDiscoveryResult mData;
|
||||
struct RsBroadcastDiscoveryEvent : RsEvent
|
||||
{
|
||||
RsBroadcastDiscoveryEvent()
|
||||
: RsEvent(RsEventType::BROADCAST_DISCOVERY),
|
||||
mDiscoveryEventType(RsBroadcastDiscoveryEventType::UNKNOWN)
|
||||
{}
|
||||
|
||||
virtual ~RsBroadcastDiscoveryEvent() override = default;
|
||||
|
||||
RsBroadcastDiscoveryEventType mDiscoveryEventType;
|
||||
RsBroadcastDiscoveryResult mData;
|
||||
|
||||
/// @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RsEvent::serial_process(j, ctx);
|
||||
|
||||
RS_SERIAL_PROCESS(mDiscoveryEventType);
|
||||
RS_SERIAL_PROCESS(mData);
|
||||
}
|
||||
|
||||
~RsBroadcastDiscoveryPeerFoundEvent() override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ enum class RsEventType : uint32_t
|
|||
NONE = 0, /// Used to detect uninitialized event
|
||||
|
||||
/// @see RsBroadcastDiscovery
|
||||
BROADCAST_DISCOVERY_PEER_FOUND = 1,
|
||||
BROADCAST_DISCOVERY = 1,
|
||||
|
||||
/// @see RsDiscPendingPgpReceivedEvent
|
||||
GOSSIP_DISCOVERY_INVITE_RECEIVED = 2,
|
||||
GOSSIP_DISCOVERY = 2,
|
||||
|
||||
/// @see AuthSSL
|
||||
AUTHSSL_CONNECTION_AUTENTICATION = 3,
|
||||
|
|
@ -61,14 +61,14 @@ enum class RsEventType : uint32_t
|
|||
/// @see pqissl
|
||||
PEER_CONNECTION = 4,
|
||||
|
||||
/// @see RsGxsChanges // this one should probably be removed because it's not used anywhere
|
||||
/// @see RsGxsChanges // this one is used in RsGxsBroadcast
|
||||
GXS_CHANGES = 5,
|
||||
|
||||
/// Emitted when a peer state changes, @see RsPeers
|
||||
PEER_STATE_CHANGED = 6,
|
||||
|
||||
/// @see RsMailStatusEvent
|
||||
MAIL_STATUS_CHANGE = 7,
|
||||
MAIL_STATUS = 7,
|
||||
|
||||
/// @see RsGxsCircleEvent
|
||||
GXS_CIRCLES = 8,
|
||||
|
|
@ -160,6 +160,7 @@ public:
|
|||
* Every time an event is dispatced the registered events handlers will get
|
||||
* their method handleEvent called with the event passed as paramether.
|
||||
* @jsonapi{development,manualwrapper}
|
||||
* @param eventType Type of event for which the callback is called
|
||||
* @param multiCallback Function that will be called each time an event
|
||||
* is dispatched.
|
||||
* @param[inout] hId Optional storage for handler id, useful to
|
||||
|
|
@ -170,6 +171,7 @@ public:
|
|||
* @return False on error, true otherwise.
|
||||
*/
|
||||
virtual bool registerEventsHandler(
|
||||
RsEventType eventType,
|
||||
std::function<void(std::shared_ptr<const RsEvent>)> multiCallback,
|
||||
RsEventsHandlerId_t& hId = RS_DEFAULT_STORAGE_PARAM(RsEventsHandlerId_t, 0)
|
||||
) = 0;
|
||||
|
|
|
|||
|
|
@ -45,11 +45,18 @@ extern std::shared_ptr<RsGossipDiscovery> rsGossipDiscovery;
|
|||
/**
|
||||
* @brief Emitted when a pending PGP certificate is received
|
||||
*/
|
||||
struct RsGossipDiscoveryFriendInviteReceivedEvent : RsEvent
|
||||
{
|
||||
RsGossipDiscoveryFriendInviteReceivedEvent(
|
||||
const std::string& invite );
|
||||
|
||||
enum class RsGossipDiscoveryEventType: uint32_t {
|
||||
UNKNOWN = 0x00,
|
||||
PEER_INVITE_RECEIVED = 0x01
|
||||
};
|
||||
|
||||
struct RsGossipDiscoveryEvent : RsEvent
|
||||
{
|
||||
RsGossipDiscoveryEvent(): RsEvent(RsEventType::GOSSIP_DISCOVERY) {}
|
||||
virtual ~RsGossipDiscoveryEvent() override {}
|
||||
|
||||
RsGossipDiscoveryEventType mGossipDiscoveryEventType;
|
||||
std::string mInvite;
|
||||
|
||||
/// @see RsSerializable
|
||||
|
|
@ -57,6 +64,7 @@ struct RsGossipDiscoveryFriendInviteReceivedEvent : RsEvent
|
|||
RsGenericSerializer::SerializeContext& ctx )
|
||||
{
|
||||
RsEvent::serial_process(j,ctx);
|
||||
RS_SERIAL_PROCESS(mGossipDiscoveryEventType);
|
||||
RS_SERIAL_PROCESS(mInvite);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -296,19 +296,19 @@ struct MsgTagType : RsSerializable
|
|||
} //namespace Rs
|
||||
} //namespace Msgs
|
||||
|
||||
struct RsMailStatusEvent : RsEvent
|
||||
{
|
||||
RsMailStatusEvent() : RsEvent(RsEventType::MAIL_STATUS_CHANGE) {}
|
||||
|
||||
enum MailStatusEventCode: uint8_t {
|
||||
enum class RsMailStatusEventType: uint8_t {
|
||||
NEW_MESSAGE = 0x00,
|
||||
MESSAGE_REMOVED = 0x01,
|
||||
MESSAGE_SENT = 0x02,
|
||||
MESSAGE_RECEIVED_ACK = 0x03, // means the peer received the message
|
||||
FAILED_SIGNATURE = 0x04, // means the signature of the message cannot be verified
|
||||
};
|
||||
};
|
||||
|
||||
MailStatusEventCode mMailStatusEventCode;
|
||||
struct RsMailStatusEvent : RsEvent
|
||||
{
|
||||
RsMailStatusEvent() : RsEvent(RsEventType::MAIL_STATUS) {}
|
||||
|
||||
RsMailStatusEventType mMailStatusEventCode;
|
||||
std::set<RsMailMessageId> mChangedMsgIds;
|
||||
|
||||
/// @see RsEvent
|
||||
|
|
@ -320,7 +320,7 @@ struct RsMailStatusEvent : RsEvent
|
|||
RS_SERIAL_PROCESS(mMailStatusEventCode);
|
||||
}
|
||||
|
||||
~RsMailStatusEvent() override;
|
||||
~RsMailStatusEvent() override = default;
|
||||
};
|
||||
|
||||
#define RS_CHAT_PUBLIC 0x0001
|
||||
|
|
@ -329,7 +329,7 @@ struct RsMailStatusEvent : RsEvent
|
|||
|
||||
#define RS_DISTANT_CHAT_STATUS_UNKNOWN 0x0000
|
||||
#define RS_DISTANT_CHAT_STATUS_TUNNEL_DN 0x0001
|
||||
#define RS_DISTANT_CHAT_STATUS_CAN_TALK 0x0002
|
||||
#define RS_DISTANT_CHAT_STATUS_CAN_TALK 0x0002
|
||||
#define RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED 0x0003
|
||||
|
||||
#define RS_DISTANT_CHAT_ERROR_NO_ERROR 0x0000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue