diff --git a/bin/dbus/cx.ring.Ring.CallManager.xml b/bin/dbus/cx.ring.Ring.CallManager.xml index 4c9acb4ddae1f01c3dac32c84488910c8615d729..b6cd4d539effbde0b9ce2951f4edf5eb91598622 100644 --- a/bin/dbus/cx.ring.Ring.CallManager.xml +++ b/bin/dbus/cx.ring.Ring.CallManager.xml @@ -270,6 +270,12 @@ <arg type="b" name="isParticipant" direction="out"/> </method> + <method name="hangupParticipant" tp:name-for-bindings="hangupParticipant"> + <tp:added version="9.8.0"/> + <arg type="s" name="confId" direction="in"/> + <arg type="s" name="peerId" direction="in"/> + </method> + <method name="addParticipant" tp:name-for-bindings="addParticipant"> <tp:added version="0.9.7"/> <tp:docstring> diff --git a/bin/dbus/dbuscallmanager.cpp b/bin/dbus/dbuscallmanager.cpp index 2fbe410b7d124f998a00df462158068beaf0b5fa..4b74d76b59737416121fdf70bae5e6e9a30cec6f 100644 --- a/bin/dbus/dbuscallmanager.cpp +++ b/bin/dbus/dbuscallmanager.cpp @@ -310,3 +310,8 @@ DBusCallManager::muteParticipant(const std::string& confId, const std::string& p DRing::muteParticipant(confId, peerId, state); } +void +DBusCallManager::hangupParticipant(const std::string& confId, const std::string& peerId) +{ + DRing::hangupParticipant(confId, peerId); +} \ No newline at end of file diff --git a/bin/dbus/dbuscallmanager.h b/bin/dbus/dbuscallmanager.h index 5d27a1a294d806afdb6801162f76c074457e9253..7df54d4fb05db24e709d2697672e4a50f930a811 100644 --- a/bin/dbus/dbuscallmanager.h +++ b/bin/dbus/dbuscallmanager.h @@ -103,6 +103,7 @@ class DRING_PUBLIC DBusCallManager : void stopSmartInfo(); void setModerator(const std::string& confId, const std::string& peerId, const bool& state); void muteParticipant(const std::string& confId, const std::string& peerId, const bool& state); + void hangupParticipant(const std::string& confId, const std::string& peerId); }; #endif // __RING_CALLMANAGER_H__ diff --git a/bin/nodejs/callmanager.i b/bin/nodejs/callmanager.i index 12f10cad92c2ef908fb8853b7f64ab3553079c7f..cd74578acfcbefffc138c1c4ba259ebf0df00e75 100644 --- a/bin/nodejs/callmanager.i +++ b/bin/nodejs/callmanager.i @@ -92,6 +92,7 @@ std::map<std::string, std::string> getConferenceDetails(const std::string& callI std::vector<std::map<std::string, std::string>> getConferenceInfos(const std::string& confId); void setModerator(const std::string& confId, const std::string& peerId, const bool& state); void muteParticipant(const std::string& confId, const std::string& peerId, const bool& state); +void hangupParticipant(const std::string& confId, const std::string& peerId); /* File Playback methods */ bool startRecordedFilePlayback(const std::string& filepath); diff --git a/configure.ac b/configure.ac index a1b6815223c345e72041d8e5a7710d76e033f48c..a7ddebe3dc0c02d9bc9a07f19b4bf370eefdcc1f 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Jami - configure.ac for automake 1.9 and autoconf 2.59 dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([Jami Daemon],[9.7.0],[ring@gnu.org],[jami]) +AC_INIT([Jami Daemon],[9.8.0],[ring@gnu.org],[jami]) AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2020]]) AC_REVISION([$Revision$]) diff --git a/src/client/callmanager.cpp b/src/client/callmanager.cpp index 77d0f6bfe4f646f9cba6a327f6d41573be056fd1..7979a0e6588baf49458b8430065ea127b92ee5c9 100644 --- a/src/client/callmanager.cpp +++ b/src/client/callmanager.cpp @@ -358,4 +358,11 @@ muteParticipant(const std::string& confId, { jami::Manager::instance().muteParticipant(confId, peerId, state); } + +void +hangupParticipant(const std::string& confId, + const std::string& participant) +{ + jami::Manager::instance().hangupParticipant(confId, participant); +} } // namespace DRing diff --git a/src/conference.cpp b/src/conference.cpp index 8d3fb3e3a25b7e0d03f8b7eff33c6f0d69a2585d..e860e519b9dcbec3e94db8aa5299269cddeb9f9b 100644 --- a/src/conference.cpp +++ b/src/conference.cpp @@ -571,6 +571,9 @@ Conference::onConfOrder(const std::string& callId, const std::string& confOrder) if (root.isMember("muteParticipant") and root.isMember("muteState")) { muteParticipant(root["muteParticipant"].asString(), root["muteState"].asString() == "true"); } + if (root.isMember("hangupParticipant")) { + hangupParticipant(root["hangupParticipant"].asString()); + } } } @@ -751,4 +754,24 @@ Conference::updateConferenceInfo(ConfInfo confInfo) sendConferenceInfos(); } +void +Conference::hangupParticipant(const std::string& participant_id) +{ + if (isHost(participant_id)) { + Manager::instance().detachLocalParticipant(id_); + return; + } + + for (const auto& p : participants_) { + if (auto call = Manager::instance().callFactory.getCall<SIPCall>(p)) { + std::string_view partURI = call->getPeerNumber(); + partURI = string_remove_suffix(partURI, '@'); + if (partURI == participant_id) { + Manager::instance().hangupCall(call->getCallId()); + return; + } + } + } +} + } // namespace jami diff --git a/src/conference.h b/src/conference.h index 0f7cb02b513bffbc392958e17a8a9b33918d6795..cb7801a726e8225089f2d9b7d21799524f0926ab 100644 --- a/src/conference.h +++ b/src/conference.h @@ -238,6 +238,7 @@ public: void setModerator(const std::string& uri, const bool& state); void muteParticipant(const std::string& uri, const bool& state, const std::string& mediaType = "MEDIA_TYPE_AUDIO"); + void hangupParticipant(const std::string& participant_id); private: std::weak_ptr<Conference> weak() diff --git a/src/dring/callmanager_interface.h b/src/dring/callmanager_interface.h index c52d49e9b7153bdb3d6289ec20688363ad18221d..5ce6fb5dd6037a34a0d65b4f4d95df412e10875d 100644 --- a/src/dring/callmanager_interface.h +++ b/src/dring/callmanager_interface.h @@ -79,6 +79,7 @@ DRING_PUBLIC std::vector<std::map<std::string, std::string>> getConferenceInfos( const std::string& confId); DRING_PUBLIC void setModerator(const std::string& confId, const std::string& peerId, const bool& state); DRING_PUBLIC void muteParticipant(const std::string& confId, const std::string& peerId, const bool& state); +DRING_PUBLIC void hangupParticipant(const std::string& confId, const std::string& participant); /* Statistic related methods */ DRING_PUBLIC void startSmartInfo(uint32_t refreshTimeMs); diff --git a/src/manager.cpp b/src/manager.cpp index 2d5989952aac635f3dada2a446a64c0a058c09b5..b0f58a6706534f1c2c1b2795a86f64433dac97f3 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1509,6 +1509,24 @@ Manager::setActiveParticipant(const std::string& confId, const std::string& part } } +void +Manager::hangupParticipant(const std::string& confId, const std::string& participant) +{ + if (auto conf = getConferenceFromID(confId)) { + conf->hangupParticipant(participant); + } else if (auto call = getCallFromCallID(confId)) { + std::map<std::string, std::string> messages; + Json::Value root; + root["hangupParticipant"] = participant; + Json::StreamWriterBuilder wbuilder; + wbuilder["commentStyle"] = "None"; + wbuilder["indentation"] = ""; + auto output = Json::writeString(wbuilder, root); + messages["application/confOrder+json"] = output; + call->sendTextMessage(messages, call->getPeerDisplayName()); + } +} + bool Manager::detachLocalParticipant(const std::string& conf_id) { diff --git a/src/manager.h b/src/manager.h index 7e83fd81977f6992a8b4057c247a46d6c36fcf2a..ae33a0fb2a0bbdc61e942b304172f97be67823b5 100644 --- a/src/manager.h +++ b/src/manager.h @@ -936,6 +936,7 @@ public: void setModerator(const std::string& confId, const std::string& peerId, const bool& state); void muteParticipant(const std::string& confId, const std::string& peerId, const bool& state); + void hangupParticipant(const std::string& confId, const std::string& participant); private: Manager();