diff options
author | Rohit Sutradhar <rohitsutradhar311@gmail.com> | 2022-10-14 19:19:05 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-14 13:49:05 +0000 |
commit | ac48c332867e773e0e0eb9ad0139b7b625e26851 (patch) | |
tree | 9f4799c650889bb770f72e127441426c9ae42a07 /src/timeline/TimelineModel.cpp | |
parent | Add toggle to disable decrypting notifications (diff) | |
download | nheko-ac48c332867e773e0e0eb9ad0139b7b625e26851.tar.xz |
VoIP v1 implementation (#1161)
* Initial commit for VoIP v1 implementation * Added draft of event handlers for voip methods * Added event handlers for VoIP events, added rejectCall, added version tracking for call version for V0 and V1 compatibility * Added call events to the general message pipeline. Modified Call Reject mechanism * Added message delegates for new events. Modified hidden events. Updated handle events. * Updated implementation to keep track of calls on other devices * Fixed linting * Fixed code warnings * Fixed minor bugs * fixed ci * Added acceptNegotiation method definition when missing gstreamer * Fixed warnings * Fixed linting
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r-- | src/timeline/TimelineModel.cpp | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 0e726bde..6aa81d8b 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -138,6 +138,20 @@ struct RoomEventType { return qml_mtx_events::EventType::CallCandidates; } + qml_mtx_events::EventType + operator()(const mtx::events::Event<mtx::events::voip::CallSelectAnswer> &) + { + return qml_mtx_events::EventType::CallSelectAnswer; + } + qml_mtx_events::EventType operator()(const mtx::events::Event<mtx::events::voip::CallReject> &) + { + return qml_mtx_events::EventType::CallReject; + } + qml_mtx_events::EventType + operator()(const mtx::events::Event<mtx::events::voip::CallNegotiate> &) + { + return qml_mtx_events::EventType::CallNegotiate; + } // ::EventType::Type operator()(const Event<mtx::events::msg::Location> &e) { return // ::EventType::LocationMessage; } }; @@ -258,6 +272,15 @@ qml_mtx_events::fromRoomEventType(qml_mtx_events::EventType t) /// m.call.candidates case qml_mtx_events::CallCandidates: return mtx::events::EventType::CallCandidates; + /// m.call.select_answer + case qml_mtx_events::CallSelectAnswer: + return mtx::events::EventType::CallSelectAnswer; + /// m.call.reject + case qml_mtx_events::CallReject: + return mtx::events::EventType::CallReject; + /// m.call.negotiate + case qml_mtx_events::CallNegotiate: + return mtx::events::EventType::CallNegotiate; /// m.room.canonical_alias case qml_mtx_events::CanonicalAlias: return mtx::events::EventType::RoomCanonicalAlias; @@ -922,16 +945,22 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline) } if (std::holds_alternative<RoomEvent<voip::CallCandidates>>(e) || + std::holds_alternative<RoomEvent<voip::CallNegotiate>>(e) || std::holds_alternative<RoomEvent<voip::CallInvite>>(e) || std::holds_alternative<RoomEvent<voip::CallAnswer>>(e) || + std::holds_alternative<RoomEvent<voip::CallSelectAnswer>>(e) || + std::holds_alternative<RoomEvent<voip::CallReject>>(e) || std::holds_alternative<RoomEvent<voip::CallHangUp>>(e)) std::visit( [this](auto &event) { event.room_id = room_id_.toStdString(); - if constexpr (std::is_same_v<std::decay_t<decltype(event)>, - RoomEvent<voip::CallAnswer>> || - std::is_same_v<std::decay_t<decltype(event)>, - RoomEvent<voip::CallHangUp>>) + if constexpr ( + std::is_same_v<std::decay_t<decltype(event)>, RoomEvent<voip::CallAnswer>> || + std::is_same_v<std::decay_t<decltype(event)>, RoomEvent<voip::CallInvite>> || + std::is_same_v<std::decay_t<decltype(event)>, + RoomEvent<voip::CallSelectAnswer>> || + std::is_same_v<std::decay_t<decltype(event)>, RoomEvent<voip::CallReject>> || + std::is_same_v<std::decay_t<decltype(event)>, RoomEvent<voip::CallHangUp>>) emit newCallEvent(event); else { if (event.sender != http::client()->user_id().to_string()) @@ -1007,6 +1036,17 @@ isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallHangUp> &) return true; } +auto +isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallReject> &) +{ + return true; +} +auto +isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallSelectAnswer> &) +{ + return true; +} + // Workaround. We also want to see a room at the top, if we just joined it auto isYourJoin(const mtx::events::StateEvent<mtx::events::state::Member> &e) @@ -1503,6 +1543,23 @@ struct SendMessageVisitor sendRoomEvent<mtx::events::voip::CallHangUp, mtx::events::EventType::CallHangUp>(event); } + void operator()(const mtx::events::RoomEvent<mtx::events::voip::CallSelectAnswer> &event) + { + sendRoomEvent<mtx::events::voip::CallSelectAnswer, + mtx::events::EventType::CallSelectAnswer>(event); + } + + void operator()(const mtx::events::RoomEvent<mtx::events::voip::CallReject> &event) + { + sendRoomEvent<mtx::events::voip::CallReject, mtx::events::EventType::CallReject>(event); + } + + void operator()(const mtx::events::RoomEvent<mtx::events::voip::CallNegotiate> &event) + { + sendRoomEvent<mtx::events::voip::CallNegotiate, mtx::events::EventType::CallNegotiate>( + event); + } + void operator()(const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &msg) { sendRoomEvent<mtx::events::msg::KeyVerificationRequest, |