update to new ngc_events

This commit is contained in:
Green Sky 2023-12-26 20:42:20 +01:00
parent d05875f489
commit 54084b5a53
No known key found for this signature in database
3 changed files with 9 additions and 59 deletions

View File

@ -64,11 +64,11 @@ struct ToxEventI {
struct ToxEventProviderI {
virtual ~ToxEventProviderI(void) {}
// TODO: unsub
virtual void subscribe(ToxEventI* object, const Tox_Event event_type) = 0;
virtual void subscribe(ToxEventI* object, const Tox_Event_Type event_type) = 0;
};
constexpr Tox_Event tox_event_from_string(const std::string_view str) {
#define CASE_E_TYPE(x) if (str == #x) return Tox_Event::x;
constexpr Tox_Event_Type tox_event_from_string(const std::string_view str) {
#define CASE_E_TYPE(x) if (str == #x) return Tox_Event_Type::x;
CASE_E_TYPE(TOX_EVENT_SELF_CONNECTION_STATUS)
@ -117,63 +117,13 @@ constexpr Tox_Event tox_event_from_string(const std::string_view str) {
CASE_E_TYPE(TOX_EVENT_GROUP_JOIN_FAIL)
CASE_E_TYPE(TOX_EVENT_GROUP_MODERATION)
return (Tox_Event)-1; // TODO: add invalid event enum?
return Tox_Event_Type::TOX_EVENT_INVALID;
#undef CASE_E_TYPE
}
constexpr std::string_view tox_event_to_string(const Tox_Event e) {
#define CASE_E_TYPE(x) if (e == x) return #x;
CASE_E_TYPE(TOX_EVENT_SELF_CONNECTION_STATUS)
CASE_E_TYPE(TOX_EVENT_FRIEND_REQUEST)
CASE_E_TYPE(TOX_EVENT_FRIEND_CONNECTION_STATUS)
CASE_E_TYPE(TOX_EVENT_FRIEND_LOSSY_PACKET)
CASE_E_TYPE(TOX_EVENT_FRIEND_LOSSLESS_PACKET)
CASE_E_TYPE(TOX_EVENT_FRIEND_NAME)
CASE_E_TYPE(TOX_EVENT_FRIEND_STATUS)
CASE_E_TYPE(TOX_EVENT_FRIEND_STATUS_MESSAGE)
CASE_E_TYPE(TOX_EVENT_FRIEND_MESSAGE)
CASE_E_TYPE(TOX_EVENT_FRIEND_READ_RECEIPT)
CASE_E_TYPE(TOX_EVENT_FRIEND_TYPING)
CASE_E_TYPE(TOX_EVENT_FILE_CHUNK_REQUEST)
CASE_E_TYPE(TOX_EVENT_FILE_RECV)
CASE_E_TYPE(TOX_EVENT_FILE_RECV_CHUNK)
CASE_E_TYPE(TOX_EVENT_FILE_RECV_CONTROL)
CASE_E_TYPE(TOX_EVENT_CONFERENCE_INVITE)
CASE_E_TYPE(TOX_EVENT_CONFERENCE_CONNECTED)
CASE_E_TYPE(TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED)
CASE_E_TYPE(TOX_EVENT_CONFERENCE_PEER_NAME)
CASE_E_TYPE(TOX_EVENT_CONFERENCE_TITLE)
CASE_E_TYPE(TOX_EVENT_CONFERENCE_MESSAGE)
CASE_E_TYPE(TOX_EVENT_GROUP_PEER_NAME)
CASE_E_TYPE(TOX_EVENT_GROUP_PEER_STATUS)
CASE_E_TYPE(TOX_EVENT_GROUP_TOPIC)
CASE_E_TYPE(TOX_EVENT_GROUP_PRIVACY_STATE)
CASE_E_TYPE(TOX_EVENT_GROUP_VOICE_STATE)
CASE_E_TYPE(TOX_EVENT_GROUP_TOPIC_LOCK)
CASE_E_TYPE(TOX_EVENT_GROUP_PEER_LIMIT)
CASE_E_TYPE(TOX_EVENT_GROUP_PASSWORD)
CASE_E_TYPE(TOX_EVENT_GROUP_MESSAGE)
CASE_E_TYPE(TOX_EVENT_GROUP_PRIVATE_MESSAGE)
CASE_E_TYPE(TOX_EVENT_GROUP_CUSTOM_PACKET)
CASE_E_TYPE(TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET)
CASE_E_TYPE(TOX_EVENT_GROUP_INVITE)
CASE_E_TYPE(TOX_EVENT_GROUP_PEER_JOIN)
CASE_E_TYPE(TOX_EVENT_GROUP_PEER_EXIT)
CASE_E_TYPE(TOX_EVENT_GROUP_SELF_JOIN)
CASE_E_TYPE(TOX_EVENT_GROUP_JOIN_FAIL)
CASE_E_TYPE(TOX_EVENT_GROUP_MODERATION)
return "<unk>"; // TODO: add invalid event enum?
#undef CASE_E_TYPE
// why do you exists?
static inline std::string_view tox_event_to_string(const Tox_Event_Type e) {
return tox_event_type_to_string(e);
}

View File

@ -70,7 +70,7 @@ void ToxEventProviderBase::dispatchEvents(const Tox_Events* events) {
#undef HANDLE_EVENT
}
void ToxEventProviderBase::subscribe(ToxEventI* object, const Tox_Event event_type) {
void ToxEventProviderBase::subscribe(ToxEventI* object, const Tox_Event_Type event_type) {
_subscribers.at(event_type).push_back(object);
}

View File

@ -11,7 +11,7 @@ struct ToxEventProviderBase : public ToxEventProviderI {
void dispatchEvents(const Tox_Events* events);
public: // event provider
virtual void subscribe(ToxEventI* object, const Tox_Event event_type) override;
virtual void subscribe(ToxEventI* object, const Tox_Event_Type event_type) override;
protected:
std::array<std::vector<ToxEventI*>, 39> _subscribers; // rn 39 event types