summary refs log tree commit diff
path: root/src/EventAccessors.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/EventAccessors.cpp')
-rw-r--r--src/EventAccessors.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/EventAccessors.cpp b/src/EventAccessors.cpp

index 7071819b..043e24a2 100644 --- a/src/EventAccessors.cpp +++ b/src/EventAccessors.cpp
@@ -1,5 +1,7 @@ #include "EventAccessors.h" +#include <algorithm> +#include <cctype> #include <type_traits> namespace { @@ -65,6 +67,22 @@ struct EventRoomTopic } }; +struct CallType +{ + template<class T> + std::string operator()(const T &e) + { + if constexpr (std::is_same_v<mtx::events::RoomEvent<mtx::events::msg::CallInvite>, T>) { + const char video[] = "m=video"; + const std::string &sdp = e.content.sdp; + return std::search(sdp.cbegin(), sdp.cend(), std::cbegin(video), std::cend(video) - 1, + [](unsigned char c1, unsigned char c2) {return std::tolower(c1) == std::tolower(c2);}) + != sdp.cend() ? "video" : "voice"; + } + return std::string(); + } +}; + struct EventBody { template<class C> @@ -326,6 +344,12 @@ mtx::accessors::room_topic(const mtx::events::collections::TimelineEvents &event } std::string +mtx::accessors::call_type(const mtx::events::collections::TimelineEvents &event) +{ + return std::visit(CallType{}, event); +} + +std::string mtx::accessors::body(const mtx::events::collections::TimelineEvents &event) { return std::visit(EventBody{}, event);