summary refs log tree commit diff
path: root/src/EventAccessors.cpp
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2020-08-14 07:59:39 +0000
committerGitHub <noreply@github.com>2020-08-14 07:59:39 +0000
commit3fece53eb7bc38a338ac85faa58638c251d3cda7 (patch)
tree4e8c69ff9cccf376185f3a430ef1b07c06c288f4 /src/EventAccessors.cpp
parentAdded translation using Weblate (Sinhala) (diff)
parentAppease the linter (diff)
downloadnheko-3fece53eb7bc38a338ac85faa58638c251d3cda7.tar.xz
Merge pull request #237 from trilene/voip
Support voice calls
Diffstat (limited to 'src/EventAccessors.cpp')
-rw-r--r--src/EventAccessors.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/EventAccessors.cpp b/src/EventAccessors.cpp

index 7071819b..7846737b 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,29 @@ 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 +351,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);