diff --git a/.gitignore b/.gitignore index 08d7b179754ea92b9f3e8ebea457e974a2e21c3d..10b95035be33644752b58a8f6c0513aa865ea681 100644 --- a/.gitignore +++ b/.gitignore @@ -123,7 +123,7 @@ configure jami.pc bin/dbus/*.adaptor.h bin/dbus/cx.ring.Ring.service -bin/jamid +bin/dbus/jamid doltcompile doltlibtool __pycache__ diff --git a/CMakeLists.txt b/CMakeLists.txt index 906b598beae5c56bf62e913f3be8211654fb0f8e..4055c9f90d432efac684980af1c54975352ec79e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -591,8 +591,8 @@ else() endif() if (JAMI_DBUS) - find_program(DBusXml2Cpp dbusxx-xml2cpp REQUIRED) - pkg_search_module (DBusCpp REQUIRED IMPORTED_TARGET dbus-c++-1) + find_program(DBusXml2Cpp sdbus-c++-xml2cpp REQUIRED) + pkg_search_module (DBusCpp REQUIRED IMPORTED_TARGET sdbus-c++) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/bin/dbus/net.jami.daemon.service.in ${CMAKE_CURRENT_SOURCE_DIR}/bin/dbus/cx.ring.Ring.service @@ -614,11 +614,6 @@ else() ${CMAKE_CURRENT_SOURCE_DIR}/bin/dbus/dbuspluginmanagerinterface.adaptor.h ) set(DBUS_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/bin/dbus/dbuscallmanager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/bin/dbus/dbusclient.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/bin/dbus/dbusconfigurationmanager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/bin/dbus/dbusinstance.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/bin/dbus/dbuspresencemanager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/bin/dbus/main.cpp ) diff --git a/Dockerfile b/Dockerfile index d5e99176c88ec5bdccc9944c709e414a4dc29a3c..88a3eabf19fb56ddf0707a307be9b563a22f0ea5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,6 @@ RUN apt-get update && apt-get install -y \ libasio-dev \ libasound2-dev \ libdbus-1-dev \ - libdbus-c++-dev \ libexpat1-dev \ libfmt-dev \ libgmp-dev \ @@ -29,6 +28,8 @@ RUN apt-get update && apt-get install -y \ libspeex-dev \ libspeexdsp-dev \ libssl-dev \ + libsystemd-dev \ + libsdbus-c++-bin \ libtool \ libudev-dev \ libupnp-dev \ diff --git a/README b/README index 7efb9ed02902aff6dfa8cac7bc338a62ad8a4679..aa298bb7c39f674d8ad40bf59885d44a3438a38d 100644 --- a/README +++ b/README @@ -204,17 +204,6 @@ gettext is installed, because symlinks are not created. Run: 'brew link --force gettext' to fix it. -Clang compatibility (developers only) -------------------------------------- - -It is possible to compile jamid with Clang by setting CC and CXX variables -to 'clang' and 'clang++' respectively when calling ./configure. - -Currently it is not possible to use the DBus interface mechanism, and the -interaction between daemon and client will not work; for each platform where -D-Bus is not available the client should implement all the methods in the -*_stub.cpp files. - Contributing to Jami ------------------------ diff --git a/bin/Makefile.am b/bin/Makefile.am index e1917da0cde4894411bd8d34d016981bca9e7102..235b54b88cc38e37758365b023e1bafe944af675 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -22,16 +22,6 @@ SUBDIRS= if RING_DBUS SUBDIRS+=dbus - -libexec_PROGRAMS = jamid - -jamid_SOURCES = main.cpp - -jamid_CXXFLAGS= -I$(top_srcdir)/src ${DBUSCPP_CFLAGS} \ - -I$(top_srcdir)/src/jami \ - -DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\" - -jamid_LDADD = dbus/libclient_dbus.la ${DBUSCPP_LIBS} $(top_builddir)/src/libjami.la -ldl endif if ENABLE_NODEJS diff --git a/bin/dbus/Makefile.am b/bin/dbus/Makefile.am index 5297eb05e4aaf97483840bf477494b130819e44b..c5e98ac65932d0d2ff3fe1a3e4cee7e4276b9518 100644 --- a/bin/dbus/Makefile.am +++ b/bin/dbus/Makefile.am @@ -1,69 +1,62 @@ include $(top_srcdir)/globals.mk -noinst_LTLIBRARIES = libclient_dbus.la +libexec_PROGRAMS= jamid BUILT_SOURCES= \ dbuscallmanager.adaptor.h \ dbusconfigurationmanager.adaptor.h \ - dbusinstance.adaptor.h + dbusinstance.adaptor.h \ + dbuspresencemanager.adaptor.h -BUILT_SOURCES+=dbuspresencemanager.adaptor.h dbuspresencemanager.adaptor.h: cx.ring.Ring.PresenceManager.xml Makefile.am - $(DBUSXX_XML2CPP) $< --adaptor=$@ - -if ENABLE_VIDEO -BUILT_SOURCES+=dbusvideomanager.adaptor.h -dbusvideomanager.adaptor.h: cx.ring.Ring.VideoManager.xml Makefile.am - $(DBUSXX_XML2CPP) $< --adaptor=$@ -endif + $(SDBUSCPP_XML2CPP) $< --adaptor=$@ # Rule to generate the binding headers dbuscallmanager.adaptor.h: cx.ring.Ring.CallManager.xml Makefile.am - $(DBUSXX_XML2CPP) $< --adaptor=$@ + $(SDBUSCPP_XML2CPP) $< --adaptor=$@ # Rule to generate the binding headers dbusconfigurationmanager.adaptor.h: cx.ring.Ring.ConfigurationManager.xml Makefile.am - $(DBUSXX_XML2CPP) $< --adaptor=$@ + $(SDBUSCPP_XML2CPP) $< --adaptor=$@ # Rule to generate the binding headers dbusinstance.adaptor.h: cx.ring.Ring.Instance.xml Makefile.am - $(DBUSXX_XML2CPP) $< --adaptor=$@ + $(SDBUSCPP_XML2CPP) $< --adaptor=$@ + +if ENABLE_VIDEO +dbusvideomanager.adaptor.h: cx.ring.Ring.VideoManager.xml Makefile.am + $(SDBUSCPP_XML2CPP) $< --adaptor=$@ +BUILT_SOURCES+= dbusvideomanager.adaptor.h +endif if ENABLE_PLUGIN -BUILT_SOURCES+=dbuspluginmanagerinterface.adaptor.h -# Rule to generate the binding headers dbuspluginmanagerinterface.adaptor.h: cx.ring.Ring.PluginManagerInterface.xml Makefile.am - $(DBUSXX_XML2CPP) $< --adaptor=$@ + $(SDBUSCPP_XML2CPP) $< --adaptor=$@ +BUILT_SOURCES+= dbuspluginmanagerinterface.adaptor.h endif -libclient_dbus_la_SOURCES = \ - dbuscallmanager.cpp \ - dbuscallmanager.h \ - dbusconfigurationmanager.cpp \ - dbusconfigurationmanager.h \ - dbusinstance.cpp \ - dbusclient.cpp \ - dbusclient.h \ - dbusinstance.h \ - dbus_cpp.h \ - dbuspresencemanager.cpp \ - dbuspresencemanager.h \ +jamid_SOURCES= \ + main.cpp \ + dbuscallmanager.hpp \ + dbusconfigurationmanager.hpp \ + dbusinstance.hpp \ + dbuspresencemanager.hpp \ $(BUILT_SOURCES) -if ENABLE_PLUGIN -libclient_dbus_la_SOURCES += dbuspluginmanagerinterface.cpp dbuspluginmanagerinterface.h -endif - if ENABLE_VIDEO -libclient_dbus_la_SOURCES += dbusvideomanager.cpp dbusvideomanager.h + jamid_SOURCES+= dbusvideomanager.hpp +endif +if ENABLE_PLUGIN + jamid_SOURCES+= dbuspluginmanagerinterface.hpp endif -libclient_dbus_la_CXXFLAGS = $(AM_CXXFLAGS) $(DBUSCPP_CFLAGS) +jamid_CXXFLAGS= ${SDBUSCPP_CFLAGS} -I$(top_srcdir)/src/jami +jamid_LDADD= ${SDBUSCPP_LIBS} $(top_builddir)/src/libjami.la do_subst = $(SED) \ - -e 's,[@]libexecdir[@],$(libexecdir),g' + -e 's,[@]LIBEXECDIR[@],$(libexecdir),g' -cx.ring.Ring.service: cx.ring.Ring.service.in Makefile +cx.ring.Ring.service: net.jami.daemon.service.in Makefile $(do_subst) < $< > $@ # Dbus service file @@ -76,16 +69,13 @@ interfacedir = $(datadir)/dbus-1/interfaces interface_DATA = cx.ring.Ring.CallManager.xml \ cx.ring.Ring.ConfigurationManager.xml \ cx.ring.Ring.Instance.xml \ - cx.ring.Ring.PresenceManager.xml - -if ENABLE_PLUGIN -interface_DATA += cx.ring.Ring.PluginManagerInterface.xml -endif + cx.ring.Ring.PresenceManager.xml if ENABLE_VIDEO interface_DATA += cx.ring.Ring.VideoManager.xml endif +if ENABLE_PLUGIN +interface_DATA += cx.ring.Ring.PluginManagerInterface.xml +endif -CLEANFILES= \ - $(BUILT_SOURCES) \ - cx.ring.Ring.service +CLEANFILES= $(BUILT_SOURCES) cx.ring.Ring.service diff --git a/bin/dbus/cx.ring.Ring.service.in b/bin/dbus/cx.ring.Ring.service.in deleted file mode 100644 index b7b34538c8b6f4cec502994d4e668ec3a87b587a..0000000000000000000000000000000000000000 --- a/bin/dbus/cx.ring.Ring.service.in +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=cx.ring.Ring -Exec=@libexecdir@/jamid diff --git a/bin/dbus/dbus_cpp.h b/bin/dbus/dbus_cpp.h deleted file mode 100644 index 93683b127d84c9d585608fff493e15f6bd6f969d..0000000000000000000000000000000000000000 --- a/bin/dbus/dbus_cpp.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef DBUS_CPP_WRAPPER_H_ -#define DBUS_CPP_WRAPPER_H_ - -#pragma GCC diagnostic ignored "-Wshadow" -#pragma GCC diagnostic ignored "-Wignored-qualifiers" -#pragma GCC diagnostic ignored "-Wunused-parameter" -#include <dbus-c++/dbus.h> -#pragma GCC diagnostic warning "-Wignored-qualifiers" -#pragma GCC diagnostic warning "-Wshadow" -#pragma GCC diagnostic warning "-Wunused-parameter" - -#endif // DBUS_CPP_WRAPPER_H_ diff --git a/bin/dbus/dbuscallmanager.cpp b/bin/dbus/dbuscallmanager.cpp deleted file mode 100644 index 6cb7bfa997c571b9effce65a788c0db4d7f0ad9d..0000000000000000000000000000000000000000 --- a/bin/dbus/dbuscallmanager.cpp +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "dbuscallmanager.h" - -DBusCallManager::DBusCallManager(DBus::Connection& connection) - : DBus::ObjectAdaptor(connection, "/cx/ring/Ring/CallManager") -{} - -auto -DBusCallManager::placeCall(const std::string& accountId, const std::string& to) - -> decltype(libjami::placeCall(accountId, to)) -{ - return libjami::placeCall(accountId, to); -} -auto -DBusCallManager::placeCallWithMedia(const std::string& accountId, - const std::string& to, - const std::vector<std::map<std::string, std::string>>& mediaList) - -> decltype(libjami::placeCallWithMedia(accountId, to, mediaList)) -{ - return libjami::placeCallWithMedia(accountId, to, mediaList); -} - -auto -DBusCallManager::requestMediaChange(const std::string& accountId, - const std::string& callId, - const std::vector<std::map<std::string, std::string>>& mediaList) - -> decltype(libjami::requestMediaChange(accountId, callId, mediaList)) -{ - return libjami::requestMediaChange(accountId, callId, mediaList); -} - -auto -DBusCallManager::refuse(const std::string& accountId, const std::string& callId) - -> decltype(libjami::refuse(accountId, callId)) -{ - return libjami::refuse(accountId, callId); -} - -auto -DBusCallManager::accept(const std::string& accountId, const std::string& callId) - -> decltype(libjami::accept(accountId, callId)) -{ - return libjami::accept(accountId, callId); -} - -auto -DBusCallManager::acceptWithMedia(const std::string& accountId, - const std::string& callId, - const std::vector<std::map<std::string, std::string>>& mediaList) - -> decltype(libjami::acceptWithMedia(accountId, callId, mediaList)) -{ - return libjami::acceptWithMedia(accountId, callId, mediaList); -} - -auto -DBusCallManager::answerMediaChangeRequest( - const std::string& accountId, - const std::string& callId, - const std::vector<std::map<std::string, std::string>>& mediaList) - -> decltype(libjami::answerMediaChangeRequest(accountId, callId, mediaList)) -{ - return libjami::answerMediaChangeRequest(accountId, callId, mediaList); -} - -auto -DBusCallManager::hangUp(const std::string& accountId, const std::string& callId) - -> decltype(libjami::hangUp(accountId, callId)) -{ - return libjami::hangUp(accountId, callId); -} - -auto -DBusCallManager::hold(const std::string& accountId, const std::string& callId) - -> decltype(libjami::hold(accountId, callId)) -{ - return libjami::hold(accountId, callId); -} - -auto -DBusCallManager::unhold(const std::string& accountId, const std::string& callId) - -> decltype(libjami::unhold(accountId, callId)) -{ - return libjami::unhold(accountId, callId); -} - -auto -DBusCallManager::muteLocalMedia(const std::string& accountId, - const std::string& callId, - const std::string& mediaType, - const bool& mute) - -> decltype(libjami::muteLocalMedia(accountId, callId, mediaType, mute)) -{ - return libjami::muteLocalMedia(accountId, callId, mediaType, mute); -} - -auto -DBusCallManager::transfer(const std::string& accountId, - const std::string& callId, - const std::string& to) -> decltype(libjami::transfer(accountId, callId, to)) -{ - return libjami::transfer(accountId, callId, to); -} - -auto -DBusCallManager::attendedTransfer(const std::string& accountId, - const std::string& callId, - const std::string& targetId) - -> decltype(libjami::attendedTransfer(accountId, callId, targetId)) -{ - return libjami::attendedTransfer(accountId, callId, targetId); -} - -auto -DBusCallManager::getCallDetails(const std::string& accountId, const std::string& callId) - -> decltype(libjami::getCallDetails(accountId, callId)) -{ - return libjami::getCallDetails(accountId, callId); -} - -auto -DBusCallManager::getCallList(const std::string& accountId) - -> decltype(libjami::getCallList(accountId)) -{ - return libjami::getCallList(accountId); -} - -std::vector<std::map<std::string, std::string>> -DBusCallManager::getConferenceInfos(const std::string& accountId, const std::string& confId) -{ - return libjami::getConferenceInfos(accountId, confId); -} - -auto -DBusCallManager::joinParticipant(const std::string& accountId, - const std::string& sel_callId, - const std::string& account2Id, - const std::string& drag_callId) - -> decltype(libjami::joinParticipant(accountId, sel_callId, account2Id, drag_callId)) -{ - return libjami::joinParticipant(accountId, sel_callId, account2Id, drag_callId); -} - -void -DBusCallManager::createConfFromParticipantList(const std::string& accountId, - const std::vector<std::string>& participants) -{ - libjami::createConfFromParticipantList(accountId, participants); -} - -void -DBusCallManager::setConferenceLayout(const std::string& accountId, - const std::string& confId, - const uint32_t& layout) -{ - libjami::setConferenceLayout(accountId, confId, layout); -} - -void -DBusCallManager::setActiveParticipant(const std::string& accountId, - const std::string& confId, - const std::string& callId) -{ - libjami::setActiveParticipant(accountId, confId, callId); -} - -void -DBusCallManager::muteStream(const std::string& accountId, - const std::string& confId, - const std::string& accountUri, - const std::string& deviceId, - const std::string& streamId, - const bool& state) -{ - libjami::muteStream(accountId, confId, accountUri, deviceId, streamId, state); -} - -void -DBusCallManager::setActiveStream(const std::string& accountId, - const std::string& confId, - const std::string& accountUri, - const std::string& deviceId, - const std::string& streamId, - const bool& state) -{ - libjami::setActiveStream(accountId, confId, accountUri, deviceId, streamId, state); -} - -void -DBusCallManager::raiseHand(const std::string& accountId, - const std::string& confId, - const std::string& accountUri, - const std::string& deviceId, - const bool& state) -{ - libjami::raiseHand(accountId, confId, accountUri, deviceId, state); -} - -auto -DBusCallManager::isConferenceParticipant(const std::string& accountId, const std::string& call_id) - -> decltype(libjami::isConferenceParticipant(accountId, call_id)) -{ - return libjami::isConferenceParticipant(accountId, call_id); -} - -auto -DBusCallManager::addParticipant(const std::string& accountId, - const std::string& callId, - const std::string& account2Id, - const std::string& confId) - -> decltype(libjami::addParticipant(accountId, callId, account2Id, confId)) -{ - return libjami::addParticipant(accountId, callId, account2Id, confId); -} - -auto -DBusCallManager::addMainParticipant(const std::string& accountId, const std::string& confId) - -> decltype(libjami::addMainParticipant(accountId, confId)) -{ - return libjami::addMainParticipant(accountId, confId); -} - -auto -DBusCallManager::detachLocalParticipant() -> decltype(libjami::detachLocalParticipant()) -{ - return libjami::detachLocalParticipant(); -} - -auto -DBusCallManager::detachParticipant(const std::string& accountId, const std::string& callId) - -> decltype(libjami::detachParticipant(accountId, callId)) -{ - return libjami::detachParticipant(accountId, callId); -} - -auto -DBusCallManager::joinConference(const std::string& accountId, - const std::string& sel_confId, - const std::string& account2Id, - const std::string& drag_confId) - -> decltype(libjami::joinConference(accountId, sel_confId, account2Id, drag_confId)) -{ - return libjami::joinConference(accountId, sel_confId, account2Id, drag_confId); -} - -auto -DBusCallManager::hangUpConference(const std::string& accountId, const std::string& confId) - -> decltype(libjami::hangUpConference(accountId, confId)) -{ - return libjami::hangUpConference(accountId, confId); -} - -auto -DBusCallManager::holdConference(const std::string& accountId, const std::string& confId) - -> decltype(libjami::holdConference(accountId, confId)) -{ - return libjami::holdConference(accountId, confId); -} - -auto -DBusCallManager::unholdConference(const std::string& accountId, const std::string& confId) - -> decltype(libjami::unholdConference(accountId, confId)) -{ - return libjami::unholdConference(accountId, confId); -} - -auto -DBusCallManager::getConferenceList(const std::string& accountId) - -> decltype(libjami::getConferenceList(accountId)) -{ - return libjami::getConferenceList(accountId); -} - -auto -DBusCallManager::getParticipantList(const std::string& accountId, const std::string& confId) - -> decltype(libjami::getParticipantList(accountId, confId)) -{ - return libjami::getParticipantList(accountId, confId); -} - -auto -DBusCallManager::getConferenceId(const std::string& accountId, const std::string& callId) - -> decltype(libjami::getConferenceId(accountId, callId)) -{ - return libjami::getConferenceId(accountId, callId); -} - -auto -DBusCallManager::getConferenceDetails(const std::string& accountId, const std::string& callId) - -> decltype(libjami::getConferenceDetails(accountId, callId)) -{ - return libjami::getConferenceDetails(accountId, callId); -} - -auto -DBusCallManager::currentMediaList(const std::string& accountId, const std::string& callId) - -> decltype(libjami::currentMediaList(accountId, callId)) -{ - return libjami::currentMediaList(accountId, callId); -} - -auto -DBusCallManager::startRecordedFilePlayback(const std::string& filepath) - -> decltype(libjami::startRecordedFilePlayback(filepath)) -{ - return libjami::startRecordedFilePlayback(filepath); -} - -void -DBusCallManager::stopRecordedFilePlayback() -{ - libjami::stopRecordedFilePlayback(); -} - -auto -DBusCallManager::toggleRecording(const std::string& accountId, const std::string& callId) - -> decltype(libjami::toggleRecording(accountId, callId)) -{ - return libjami::toggleRecording(accountId, callId); -} - -void -DBusCallManager::setRecording(const std::string& accountId, const std::string& callId) -{ - libjami::setRecording(accountId, callId); -} - -void -DBusCallManager::recordPlaybackSeek(const double& value) -{ - libjami::recordPlaybackSeek(value); -} - -auto -DBusCallManager::getIsRecording(const std::string& accountId, const std::string& callId) - -> decltype(libjami::getIsRecording(accountId, callId)) -{ - return libjami::getIsRecording(accountId, callId); -} - -bool -DBusCallManager::switchInput(const std::string& accountId, - const std::string& callId, - const std::string& input) -{ - return libjami::switchInput(accountId, callId, input); -} - -bool -DBusCallManager::switchSecondaryInput(const std::string& accountId, - const std::string& conferenceId, - const std::string& input) -{ - return libjami::switchSecondaryInput(accountId, conferenceId, input); -} - -void -DBusCallManager::playDTMF(const std::string& key) -{ - libjami::playDTMF(key); -} - -void -DBusCallManager::startTone(const int32_t& start, const int32_t& type) -{ - libjami::startTone(start, type); -} - -void -DBusCallManager::sendTextMessage(const std::string& accountId, - const std::string& callId, - const std::map<std::string, std::string>& messages, - const bool& isMixed) -{ - libjami::sendTextMessage(accountId, callId, messages, "Me", isMixed); -} - -void -DBusCallManager::startSmartInfo(const uint32_t& refreshTimeMs) -{ - libjami::startSmartInfo(refreshTimeMs); -} - -void -DBusCallManager::stopSmartInfo() -{ - libjami::stopSmartInfo(); -} - -void -DBusCallManager::setModerator(const std::string& accountId, - const std::string& confId, - const std::string& peerId, - const bool& state) -{ - libjami::setModerator(accountId, confId, peerId, state); -} - -void -DBusCallManager::muteParticipant(const std::string& accountId, - const std::string& confId, - const std::string& peerId, - const bool& state) -{ - libjami::muteParticipant(accountId, confId, peerId, state); -} - -void -DBusCallManager::hangupParticipant(const std::string& accountId, - const std::string& confId, - const std::string& peerId, - const std::string& deviceId) -{ - libjami::hangupParticipant(accountId, confId, peerId, deviceId); -} - -void -DBusCallManager::raiseParticipantHand(const std::string& accountId, - const std::string& confId, - const std::string& peerId, - const bool& state) -{ - libjami::raiseParticipantHand(accountId, confId, peerId, state); -} diff --git a/bin/dbus/dbuscallmanager.h b/bin/dbus/dbuscallmanager.h deleted file mode 100644 index 927f818ec28689b953da1a5b2387d373cb3f0a74..0000000000000000000000000000000000000000 --- a/bin/dbus/dbuscallmanager.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __RING_DBUSCALLMANAGER_H__ -#define __RING_DBUSCALLMANAGER_H__ - -#include <vector> -#include <map> -#include <string> - -#include "def.h" -#include "dbus_cpp.h" - -#if __GNUC__ >= 5 || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" -#endif - -#pragma GCC diagnostic ignored "-Wignored-qualifiers" -#pragma GCC diagnostic ignored "-Wunused-parameter" -#include "dbuscallmanager.adaptor.h" -#pragma GCC diagnostic warning "-Wignored-qualifiers" -#pragma GCC diagnostic warning "-Wunused-parameter" - -#if __GNUC__ >= 5 || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic warning "-Wunused-but-set-variable" -#endif - -#include "callmanager_interface.h" -#include <stdexcept> - -class LIBJAMI_PUBLIC DBusCallManager : public cx::ring::Ring::CallManager_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor -{ -public: - DBusCallManager(DBus::Connection& connection); - - // Methods - std::string placeCall(const std::string& accountId, const std::string& to); - std::string placeCallWithMedia(const std::string& accountId, - const std::string& to, - const std::vector<std::map<std::string, std::string>>& mediaList); - - bool requestMediaChange(const std::string& accountId, - const std::string& callId, - const std::vector<std::map<std::string, std::string>>& mediaList); - - bool refuse(const std::string& accountId, const std::string& callId); - bool accept(const std::string& accountId, const std::string& callId); - bool acceptWithMedia(const std::string& accountId, - const std::string& callId, - const std::vector<std::map<std::string, std::string>>& mediaList); - bool answerMediaChangeRequest(const std::string& accountId, - const std::string& callId, - const std::vector<std::map<std::string, std::string>>& mediaList); - bool hangUp(const std::string& accountId, const std::string& callId); - bool hold(const std::string& accountId, const std::string& callId); - bool unhold(const std::string& accountId, const std::string& callId); - bool muteLocalMedia(const std::string& accountId, - const std::string& callid, - const std::string& mediaType, - const bool& mute); - bool transfer(const std::string& accountId, const std::string& callId, const std::string& to); - bool attendedTransfer(const std::string& accountId, - const std::string& transferID, - const std::string& targetID); - std::map<std::string, std::string> getCallDetails(const std::string& accountId, - const std::string& callId); - std::vector<std::string> getCallList(const std::string& accountId); - std::vector<std::map<std::string, std::string>> getConferenceInfos(const std::string& accountId, - const std::string& confId); - bool joinParticipant(const std::string& accountId, - const std::string& sel_callId, - const std::string& account2Id, - const std::string& drag_callId); - void createConfFromParticipantList(const std::string& accountId, - const std::vector<std::string>& participants); - void setConferenceLayout(const std::string& accountId, - const std::string& confId, - const uint32_t& layout); - void setActiveParticipant(const std::string& accountId, - const std::string& confId, - const std::string& callId); - bool isConferenceParticipant(const std::string& accountId, const std::string& call_id); - bool addParticipant(const std::string& accountId, - const std::string& callId, - const std::string& account2Id, - const std::string& confId); - bool addMainParticipant(const std::string& accountId, const std::string& confId); - bool detachLocalParticipant(); - bool detachParticipant(const std::string& accountId, const std::string& callId); - bool joinConference(const std::string& accountId, - const std::string& sel_confId, - const std::string& account2Id, - const std::string& drag_confId); - bool hangUpConference(const std::string& accountId, const std::string& confId); - bool holdConference(const std::string& accountId, const std::string& confId); - bool unholdConference(const std::string& accountId, const std::string& confId); - std::vector<std::string> getConferenceList(const std::string& accountId); - std::vector<std::string> getParticipantList(const std::string& accountId, - const std::string& confId); - std::string getConferenceId(const std::string& accountId, const std::string& callId); - std::map<std::string, std::string> getConferenceDetails(const std::string& accountId, - const std::string& confId); - std::vector<libjami::MediaMap> currentMediaList(const std::string& accountId, - const std::string& callId); - bool startRecordedFilePlayback(const std::string& filepath); - void stopRecordedFilePlayback(); - bool toggleRecording(const std::string& accountId, const std::string& callId); - void setRecording(const std::string& accountId, const std::string& callId); - void recordPlaybackSeek(const double& value); - bool getIsRecording(const std::string& accountId, const std::string& callId); - bool switchInput(const std::string& accountId, - const std::string& callId, - const std::string& input); - bool switchSecondaryInput(const std::string& accountId, - const std::string& conferenceId, - const std::string& input); - void playDTMF(const std::string& key); - void startTone(const int32_t& start, const int32_t& type); - void sendTextMessage(const std::string& accountId, - const std::string& callId, - const std::map<std::string, std::string>& messages, - const bool& isMixed); - void startSmartInfo(const uint32_t& refreshTimeMs); - void stopSmartInfo(); - void setModerator(const std::string& accountId, - const std::string& confId, - const std::string& peerId, - const bool& state); - void muteStream(const std::string& accountId, - const std::string& confId, - const std::string& accountUri, - const std::string& deviceId, - const std::string& streamId, - const bool& state); - void setActiveStream(const std::string& accountId, - const std::string& confId, - const std::string& accountUri, - const std::string& deviceId, - const std::string& streamId, - const bool& state); - void raiseHand(const std::string& accountId, - const std::string& confId, - const std::string& accountUri, - const std::string& deviceId, - const bool& state); - void hangupParticipant(const std::string& accountId, - const std::string& confId, - const std::string& peerId, - const std::string& deviceId); - // DEPRECATED - void muteParticipant(const std::string& accountId, - const std::string& confId, - const std::string& peerId, - const bool& state); - void raiseParticipantHand(const std::string& accountId, - const std::string& confId, - const std::string& peerId, - const bool& state); -}; - -#endif // __RING_CALLMANAGER_H__ diff --git a/bin/dbus/dbuscallmanager.hpp b/bin/dbus/dbuscallmanager.hpp new file mode 100644 index 0000000000000000000000000000000000000000..fcddfb5ee3466bb4164fdca7833e928f56488830 --- /dev/null +++ b/bin/dbus/dbuscallmanager.hpp @@ -0,0 +1,521 @@ +/* + * Copyright (C) 2004-2023 Savoir-faire Linux Inc. + * + * Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com> + * Author: Vladimir Stoiakin <vstoiakin@lavabit.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include "dbuscallmanager.adaptor.h" +#include <callmanager_interface.h> + +class DBusCallManager : public sdbus::AdaptorInterfaces<cx::ring::Ring::CallManager_adaptor> +{ +public: + DBusCallManager(sdbus::IConnection& connection) + : AdaptorInterfaces(connection, "/cx/ring/Ring/CallManager") + { + registerAdaptor(); + registerSignalHandlers(); + } + + ~DBusCallManager() + { + unregisterAdaptor(); + } + + auto + placeCall(const std::string& accountId, const std::string& to) + -> decltype(libjami::placeCall(accountId, to)) + { + return libjami::placeCall(accountId, to); + } + auto + placeCallWithMedia(const std::string& accountId, + const std::string& to, + const std::vector<std::map<std::string, std::string>>& mediaList) + -> decltype(libjami::placeCallWithMedia(accountId, to, mediaList)) + { + return libjami::placeCallWithMedia(accountId, to, mediaList); + } + + auto + requestMediaChange(const std::string& accountId, + const std::string& callId, + const std::vector<std::map<std::string, std::string>>& mediaList) + -> decltype(libjami::requestMediaChange(accountId, callId, mediaList)) + { + return libjami::requestMediaChange(accountId, callId, mediaList); + } + + auto + refuse(const std::string& accountId, const std::string& callId) + -> decltype(libjami::refuse(accountId, callId)) + { + return libjami::refuse(accountId, callId); + } + + auto + accept(const std::string& accountId, const std::string& callId) + -> decltype(libjami::accept(accountId, callId)) + { + return libjami::accept(accountId, callId); + } + + auto + acceptWithMedia(const std::string& accountId, + const std::string& callId, + const std::vector<std::map<std::string, std::string>>& mediaList) + -> decltype(libjami::acceptWithMedia(accountId, callId, mediaList)) + { + return libjami::acceptWithMedia(accountId, callId, mediaList); + } + + auto + answerMediaChangeRequest( + const std::string& accountId, + const std::string& callId, + const std::vector<std::map<std::string, std::string>>& mediaList) + -> decltype(libjami::answerMediaChangeRequest(accountId, callId, mediaList)) + { + return libjami::answerMediaChangeRequest(accountId, callId, mediaList); + } + + auto + hangUp(const std::string& accountId, const std::string& callId) + -> decltype(libjami::hangUp(accountId, callId)) + { + return libjami::hangUp(accountId, callId); + } + + auto + hold(const std::string& accountId, const std::string& callId) + -> decltype(libjami::hold(accountId, callId)) + { + return libjami::hold(accountId, callId); + } + + auto + unhold(const std::string& accountId, const std::string& callId) + -> decltype(libjami::unhold(accountId, callId)) + { + return libjami::unhold(accountId, callId); + } + + auto + muteLocalMedia(const std::string& accountId, + const std::string& callId, + const std::string& mediaType, + const bool& mute) + -> decltype(libjami::muteLocalMedia(accountId, callId, mediaType, mute)) + { + return libjami::muteLocalMedia(accountId, callId, mediaType, mute); + } + + auto + transfer(const std::string& accountId, + const std::string& callId, + const std::string& to) -> decltype(libjami::transfer(accountId, callId, to)) + { + return libjami::transfer(accountId, callId, to); + } + + auto + attendedTransfer(const std::string& accountId, + const std::string& callId, + const std::string& targetId) + -> decltype(libjami::attendedTransfer(accountId, callId, targetId)) + { + return libjami::attendedTransfer(accountId, callId, targetId); + } + + auto + getCallDetails(const std::string& accountId, const std::string& callId) + -> decltype(libjami::getCallDetails(accountId, callId)) + { + return libjami::getCallDetails(accountId, callId); + } + + auto + getCallList(const std::string& accountId) + -> decltype(libjami::getCallList(accountId)) + { + return libjami::getCallList(accountId); + } + + std::vector<std::map<std::string, std::string>> + getConferenceInfos(const std::string& accountId, const std::string& confId) + { + return libjami::getConferenceInfos(accountId, confId); + } + + auto + joinParticipant(const std::string& accountId, + const std::string& sel_callId, + const std::string& account2Id, + const std::string& drag_callId) + -> decltype(libjami::joinParticipant(accountId, sel_callId, account2Id, drag_callId)) + { + return libjami::joinParticipant(accountId, sel_callId, account2Id, drag_callId); + } + + void + createConfFromParticipantList(const std::string& accountId, + const std::vector<std::string>& participants) + { + libjami::createConfFromParticipantList(accountId, participants); + } + + void + setConferenceLayout(const std::string& accountId, + const std::string& confId, + const uint32_t& layout) + { + libjami::setConferenceLayout(accountId, confId, layout); + } + + void + setActiveParticipant(const std::string& accountId, + const std::string& confId, + const std::string& callId) + { + libjami::setActiveParticipant(accountId, confId, callId); + } + + void + muteStream(const std::string& accountId, + const std::string& confId, + const std::string& accountUri, + const std::string& deviceId, + const std::string& streamId, + const bool& state) + { + libjami::muteStream(accountId, confId, accountUri, deviceId, streamId, state); + } + + void + setActiveStream(const std::string& accountId, + const std::string& confId, + const std::string& accountUri, + const std::string& deviceId, + const std::string& streamId, + const bool& state) + { + libjami::setActiveStream(accountId, confId, accountUri, deviceId, streamId, state); + } + + void + raiseHand(const std::string& accountId, + const std::string& confId, + const std::string& accountUri, + const std::string& deviceId, + const bool& state) + { + libjami::raiseHand(accountId, confId, accountUri, deviceId, state); + } + + auto + isConferenceParticipant(const std::string& accountId, const std::string& call_id) + -> decltype(libjami::isConferenceParticipant(accountId, call_id)) + { + return libjami::isConferenceParticipant(accountId, call_id); + } + + auto + addParticipant(const std::string& accountId, + const std::string& callId, + const std::string& account2Id, + const std::string& confId) + -> decltype(libjami::addParticipant(accountId, callId, account2Id, confId)) + { + return libjami::addParticipant(accountId, callId, account2Id, confId); + } + + auto + addMainParticipant(const std::string& accountId, const std::string& confId) + -> decltype(libjami::addMainParticipant(accountId, confId)) + { + return libjami::addMainParticipant(accountId, confId); + } + + auto + detachLocalParticipant() -> decltype(libjami::detachLocalParticipant()) + { + return libjami::detachLocalParticipant(); + } + + auto + detachParticipant(const std::string& accountId, const std::string& callId) + -> decltype(libjami::detachParticipant(accountId, callId)) + { + return libjami::detachParticipant(accountId, callId); + } + + auto + joinConference(const std::string& accountId, + const std::string& sel_confId, + const std::string& account2Id, + const std::string& drag_confId) + -> decltype(libjami::joinConference(accountId, sel_confId, account2Id, drag_confId)) + { + return libjami::joinConference(accountId, sel_confId, account2Id, drag_confId); + } + + auto + hangUpConference(const std::string& accountId, const std::string& confId) + -> decltype(libjami::hangUpConference(accountId, confId)) + { + return libjami::hangUpConference(accountId, confId); + } + + auto + holdConference(const std::string& accountId, const std::string& confId) + -> decltype(libjami::holdConference(accountId, confId)) + { + return libjami::holdConference(accountId, confId); + } + + auto + unholdConference(const std::string& accountId, const std::string& confId) + -> decltype(libjami::unholdConference(accountId, confId)) + { + return libjami::unholdConference(accountId, confId); + } + + auto + getConferenceList(const std::string& accountId) + -> decltype(libjami::getConferenceList(accountId)) + { + return libjami::getConferenceList(accountId); + } + + auto + getParticipantList(const std::string& accountId, const std::string& confId) + -> decltype(libjami::getParticipantList(accountId, confId)) + { + return libjami::getParticipantList(accountId, confId); + } + + auto + getConferenceId(const std::string& accountId, const std::string& callId) + -> decltype(libjami::getConferenceId(accountId, callId)) + { + return libjami::getConferenceId(accountId, callId); + } + + auto + getConferenceDetails(const std::string& accountId, const std::string& callId) + -> decltype(libjami::getConferenceDetails(accountId, callId)) + { + return libjami::getConferenceDetails(accountId, callId); + } + + auto + currentMediaList(const std::string& accountId, const std::string& callId) + -> decltype(libjami::currentMediaList(accountId, callId)) + { + return libjami::currentMediaList(accountId, callId); + } + + auto + startRecordedFilePlayback(const std::string& filepath) + -> decltype(libjami::startRecordedFilePlayback(filepath)) + { + return libjami::startRecordedFilePlayback(filepath); + } + + void + stopRecordedFilePlayback() + { + libjami::stopRecordedFilePlayback(); + } + + auto + toggleRecording(const std::string& accountId, const std::string& callId) + -> decltype(libjami::toggleRecording(accountId, callId)) + { + return libjami::toggleRecording(accountId, callId); + } + + void + setRecording(const std::string& accountId, const std::string& callId) + { + libjami::setRecording(accountId, callId); + } + + void + recordPlaybackSeek(const double& value) + { + libjami::recordPlaybackSeek(value); + } + + auto + getIsRecording(const std::string& accountId, const std::string& callId) + -> decltype(libjami::getIsRecording(accountId, callId)) + { + return libjami::getIsRecording(accountId, callId); + } + + bool + switchInput(const std::string& accountId, + const std::string& callId, + const std::string& input) + { + return libjami::switchInput(accountId, callId, input); + } + + bool + switchSecondaryInput(const std::string& accountId, + const std::string& conferenceId, + const std::string& input) + { + return libjami::switchSecondaryInput(accountId, conferenceId, input); + } + + void + playDTMF(const std::string& key) + { + libjami::playDTMF(key); + } + + void + startTone(const int32_t& start, const int32_t& type) + { + libjami::startTone(start, type); + } + + void + sendTextMessage(const std::string& accountId, + const std::string& callId, + const std::map<std::string, std::string>& messages, + const bool& isMixed) + { + libjami::sendTextMessage(accountId, callId, messages, "Me", isMixed); + } + + void + startSmartInfo(const uint32_t& refreshTimeMs) + { + libjami::startSmartInfo(refreshTimeMs); + } + + void + stopSmartInfo() + { + libjami::stopSmartInfo(); + } + + void + setModerator(const std::string& accountId, + const std::string& confId, + const std::string& peerId, + const bool& state) + { + libjami::setModerator(accountId, confId, peerId, state); + } + + void + muteParticipant(const std::string& accountId, + const std::string& confId, + const std::string& peerId, + const bool& state) + { + libjami::muteParticipant(accountId, confId, peerId, state); + } + + void + hangupParticipant(const std::string& accountId, + const std::string& confId, + const std::string& peerId, + const std::string& deviceId) + { + libjami::hangupParticipant(accountId, confId, peerId, deviceId); + } + + void + raiseParticipantHand(const std::string& accountId, + const std::string& confId, + const std::string& peerId, + const bool& state) + { + libjami::raiseParticipantHand(accountId, confId, peerId, state); + } + +private: + + void + registerSignalHandlers() + { + using namespace std::placeholders; + + using libjami::exportable_callback; + using libjami::CallSignal; + using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>; + + const std::map<std::string, SharedCallback> callEvHandlers + = {exportable_callback<CallSignal::StateChange>( + std::bind(&DBusCallManager::emitCallStateChanged, this, _1, _2, _3, _4)), + exportable_callback<CallSignal::TransferFailed>( + std::bind(&DBusCallManager::emitTransferFailed, this)), + exportable_callback<CallSignal::TransferSucceeded>( + std::bind(&DBusCallManager::emitTransferSucceeded, this)), + exportable_callback<CallSignal::RecordPlaybackStopped>( + std::bind(&DBusCallManager::emitRecordPlaybackStopped, this, _1)), + exportable_callback<CallSignal::VoiceMailNotify>( + std::bind(&DBusCallManager::emitVoiceMailNotify, this, _1, _2, _3, _4)), + exportable_callback<CallSignal::IncomingMessage>( + std::bind(&DBusCallManager::emitIncomingMessage, this, _1, _2, _3, _4)), + exportable_callback<CallSignal::IncomingCall>( + std::bind(&DBusCallManager::emitIncomingCall, this, _1, _2, _3)), + exportable_callback<CallSignal::IncomingCallWithMedia>( + std::bind(&DBusCallManager::emitIncomingCallWithMedia, this, _1, _2, _3, _4)), + exportable_callback<CallSignal::MediaChangeRequested>( + std::bind(&DBusCallManager::emitMediaChangeRequested, this, _1, _2, _3)), + exportable_callback<CallSignal::RecordPlaybackFilepath>( + std::bind(&DBusCallManager::emitRecordPlaybackFilepath, this, _1, _2)), + exportable_callback<CallSignal::ConferenceCreated>( + std::bind(&DBusCallManager::emitConferenceCreated, this, _1, _2)), + exportable_callback<CallSignal::ConferenceChanged>( + std::bind(&DBusCallManager::emitConferenceChanged, this, _1, _2, _3)), + exportable_callback<CallSignal::UpdatePlaybackScale>( + std::bind(&DBusCallManager::emitUpdatePlaybackScale, this, _1, _2, _3)), + exportable_callback<CallSignal::ConferenceRemoved>( + std::bind(&DBusCallManager::emitConferenceRemoved, this, _1, _2)), + exportable_callback<CallSignal::RecordingStateChanged>( + std::bind(&DBusCallManager::emitRecordingStateChanged, this, _1, _2)), + exportable_callback<CallSignal::RtcpReportReceived>( + std::bind(&DBusCallManager::emitOnRtcpReportReceived, this, _1, _2)), + exportable_callback<CallSignal::OnConferenceInfosUpdated>( + std::bind(&DBusCallManager::emitOnConferenceInfosUpdated, this, _1, _2)), + exportable_callback<CallSignal::PeerHold>( + std::bind(&DBusCallManager::emitPeerHold, this, _1, _2)), + exportable_callback<CallSignal::AudioMuted>( + std::bind(&DBusCallManager::emitAudioMuted, this, _1, _2)), + exportable_callback<CallSignal::VideoMuted>( + std::bind(&DBusCallManager::emitVideoMuted, this, _1, _2)), + exportable_callback<CallSignal::SmartInfo>( + std::bind(&DBusCallManager::emitSmartInfo, this, _1)), + exportable_callback<CallSignal::RemoteRecordingChanged>( + std::bind(&DBusCallManager::emitRemoteRecordingChanged, this, _1, _2, _3)), + exportable_callback<CallSignal::MediaNegotiationStatus>( + std::bind(&DBusCallManager::emitMediaNegotiationStatus, this, _1, _2, _3)) + }; + + libjami::registerSignalHandlers(callEvHandlers); + } +}; diff --git a/bin/dbus/dbusclient.cpp b/bin/dbus/dbusclient.cpp deleted file mode 100644 index 2f374ecd4f95c601e70ee72f15f9f8d770555b5e..0000000000000000000000000000000000000000 --- a/bin/dbus/dbusclient.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com> - * Author: Guillaume Roguez <Guillaume.Roguez@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - -#include "dbusclient.h" -#include "dbus_cpp.h" -#include "jami.h" - -#include "dbusinstance.h" - -#include "callmanager_interface.h" -#include "dbuscallmanager.h" - -#include "dbusconfigurationmanager.h" -#include "configurationmanager_interface.h" - -#include "dbuspresencemanager.h" -#include "presencemanager_interface.h" - -#ifdef ENABLE_PLUGIN -#include "dbuspluginmanagerinterface.h" -#include "plugin_manager_interface.h" -#endif // ENABLE_PLUGIN - -#include "datatransfer_interface.h" -#include "conversation_interface.h" - -#ifdef ENABLE_VIDEO -#include "dbusvideomanager.h" -#include "videomanager_interface.h" -#endif - -#include <iostream> -#include <stdexcept> -#include <cstdlib> -#include <cstring> - -static constexpr const char* const JAMI_DBUS_NAME = "cx.ring.Ring"; - -class EventCallback : public DBus::Callback_Base<void, DBus::DefaultTimeout&> -{ -public: - EventCallback(const std::function<void()>&& func) - : callback_ {std::forward<const std::function<void()>>(func)} - {} - - void call(DBus::DefaultTimeout&) const { callback_(); } - -private: - const std::function<void()> callback_; -}; - -DBusClient::DBusClient(int flags, bool persistent) - : dispatcher_(new DBus::BusDispatcher) -{ - try { - DBus::_init_threading(); - DBus::default_dispatcher = dispatcher_.get(); - - DBus::Connection sessionConnection {DBus::Connection::SessionBus()}; - if (sessionConnection.has_name(JAMI_DBUS_NAME)) { - throw std::runtime_error {"Another daemon is detected"}; - } - sessionConnection.request_name(JAMI_DBUS_NAME); - - callManager_.reset(new DBusCallManager {sessionConnection}); - configurationManager_.reset(new DBusConfigurationManager {sessionConnection}); - presenceManager_.reset(new DBusPresenceManager {sessionConnection}); -#ifdef ENABLE_PLUGIN - pluginManagerInterface_.reset(new DBusPluginManagerInterface {sessionConnection}); -#endif - DBusInstance::OnNoMoreClientFunc onNoMoreClientFunc; - if (!persistent) - onNoMoreClientFunc = [this] { - this->exit(); - }; - - instanceManager_.reset(new DBusInstance {sessionConnection, onNoMoreClientFunc}); - -#ifdef ENABLE_VIDEO - videoManager_.reset(new DBusVideoManager {sessionConnection}); -#endif - } catch (const DBus::Error& err) { - throw std::runtime_error {"cannot initialize DBus stuff"}; - } - - if (initLibrary(flags) < 0) - throw std::runtime_error {"cannot initialize libjami"}; - - instanceManager_->started(); -} - -DBusClient::~DBusClient() -{ - // instances destruction order is important - // so we enforce it here - libjami::unregisterSignalHandlers(); -#ifdef ENABLE_VIDEO - videoManager_.reset(); -#endif - instanceManager_.reset(); - presenceManager_.reset(); - configurationManager_.reset(); - callManager_.reset(); -#ifdef ENABLE_PLUGIN - pluginManagerInterface_.reset(); -#endif -} - -int -DBusClient::initLibrary(int flags) -{ - using namespace std::placeholders; - - using std::bind; - using libjami::exportable_callback; - using libjami::CallSignal; - using libjami::ConfigurationSignal; - using libjami::PresenceSignal; - using libjami::AudioSignal; - using libjami::DataTransferSignal; - using libjami::ConversationSignal; - - using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>; - - auto callM = callManager_.get(); - auto confM = configurationManager_.get(); - auto presM = presenceManager_.get(); - -#ifdef ENABLE_VIDEO - using libjami::VideoSignal; - auto videoM = videoManager_.get(); -#endif - -#ifdef ENABLE_PLUGIN - auto pluginM = pluginManagerInterface_.get(); -#endif - - // Call event handlers - const std::map<std::string, SharedCallback> callEvHandlers - = {exportable_callback<CallSignal::StateChange>( - bind(&DBusCallManager::callStateChanged, callM, _1, _2, _3, _4)), - exportable_callback<CallSignal::TransferFailed>( - bind(&DBusCallManager::transferFailed, callM)), - exportable_callback<CallSignal::TransferSucceeded>( - bind(&DBusCallManager::transferSucceeded, callM)), - exportable_callback<CallSignal::RecordPlaybackStopped>( - bind(&DBusCallManager::recordPlaybackStopped, callM, _1)), - exportable_callback<CallSignal::VoiceMailNotify>( - bind(&DBusCallManager::voiceMailNotify, callM, _1, _2, _3, _4)), - exportable_callback<CallSignal::IncomingMessage>( - bind(&DBusCallManager::incomingMessage, callM, _1, _2, _3, _4)), - exportable_callback<CallSignal::IncomingCall>( - bind(&DBusCallManager::incomingCall, callM, _1, _2, _3)), - exportable_callback<CallSignal::IncomingCallWithMedia>( - bind(&DBusCallManager::incomingCallWithMedia, callM, _1, _2, _3, _4)), - exportable_callback<CallSignal::MediaChangeRequested>( - bind(&DBusCallManager::mediaChangeRequested, callM, _1, _2, _3)), - exportable_callback<CallSignal::RecordPlaybackFilepath>( - bind(&DBusCallManager::recordPlaybackFilepath, callM, _1, _2)), - exportable_callback<CallSignal::ConferenceCreated>( - bind(&DBusCallManager::conferenceCreated, callM, _1, _2)), - exportable_callback<CallSignal::ConferenceChanged>( - bind(&DBusCallManager::conferenceChanged, callM, _1, _2, _3)), - exportable_callback<CallSignal::UpdatePlaybackScale>( - bind(&DBusCallManager::updatePlaybackScale, callM, _1, _2, _3)), - exportable_callback<CallSignal::ConferenceRemoved>( - bind(&DBusCallManager::conferenceRemoved, callM, _1, _2)), - exportable_callback<CallSignal::RecordingStateChanged>( - bind(&DBusCallManager::recordingStateChanged, callM, _1, _2)), - exportable_callback<CallSignal::RtcpReportReceived>( - bind(&DBusCallManager::onRtcpReportReceived, callM, _1, _2)), - exportable_callback<CallSignal::OnConferenceInfosUpdated>( - bind(&DBusCallManager::onConferenceInfosUpdated, callM, _1, _2)), - exportable_callback<CallSignal::PeerHold>( - bind(&DBusCallManager::peerHold, callM, _1, _2)), - exportable_callback<CallSignal::AudioMuted>( - bind(&DBusCallManager::audioMuted, callM, _1, _2)), - exportable_callback<CallSignal::VideoMuted>( - bind(&DBusCallManager::videoMuted, callM, _1, _2)), - exportable_callback<CallSignal::SmartInfo>(bind(&DBusCallManager::SmartInfo, callM, _1)), - exportable_callback<CallSignal::RemoteRecordingChanged>( - bind(&DBusCallManager::remoteRecordingChanged, callM, _1, _2, _3)), - exportable_callback<CallSignal::MediaNegotiationStatus>( - bind(&DBusCallManager::mediaNegotiationStatus, callM, _1, _2, _3))}; - - // Configuration event handlers - const std::map<std::string, SharedCallback> configEvHandlers = { - exportable_callback<ConfigurationSignal::VolumeChanged>( - bind(&DBusConfigurationManager::volumeChanged, confM, _1, _2)), - exportable_callback<ConfigurationSignal::AccountsChanged>( - bind(&DBusConfigurationManager::accountsChanged, confM)), - exportable_callback<ConfigurationSignal::AccountDetailsChanged>( - bind(&DBusConfigurationManager::accountDetailsChanged, confM, _1, _2)), - exportable_callback<ConfigurationSignal::StunStatusFailed>( - bind(&DBusConfigurationManager::stunStatusFailure, confM, _1)), - exportable_callback<ConfigurationSignal::RegistrationStateChanged>( - bind(&DBusConfigurationManager::registrationStateChanged, confM, _1, _2, _3, _4)), - exportable_callback<ConfigurationSignal::VolatileDetailsChanged>( - bind(&DBusConfigurationManager::volatileAccountDetailsChanged, confM, _1, _2)), - exportable_callback<ConfigurationSignal::Error>( - bind(&DBusConfigurationManager::errorAlert, confM, _1)), - exportable_callback<ConfigurationSignal::IncomingAccountMessage>( - bind(&DBusConfigurationManager::incomingAccountMessage, confM, _1, _2, _3, _4)), - exportable_callback<ConfigurationSignal::AccountMessageStatusChanged>( - bind(&DBusConfigurationManager::accountMessageStatusChanged, confM, _1, _2, _3, _4, _5)), - exportable_callback<ConfigurationSignal::ProfileReceived>( - bind(&DBusConfigurationManager::profileReceived, confM, _1, _2, _3)), - exportable_callback<ConfigurationSignal::ActiveCallsChanged>( - bind(&DBusConfigurationManager::activeCallsChanged, confM, _1, _2, _3)), - exportable_callback<ConfigurationSignal::ComposingStatusChanged>( - bind(&DBusConfigurationManager::composingStatusChanged, confM, _1, _2, _3, _4)), - exportable_callback<ConfigurationSignal::IncomingTrustRequest>( - bind(&DBusConfigurationManager::incomingTrustRequest, confM, _1, _2, _3, _4, _5)), - exportable_callback<ConfigurationSignal::ContactAdded>( - bind(&DBusConfigurationManager::contactAdded, confM, _1, _2, _3)), - exportable_callback<ConfigurationSignal::ContactRemoved>( - bind(&DBusConfigurationManager::contactRemoved, confM, _1, _2, _3)), - exportable_callback<ConfigurationSignal::ExportOnRingEnded>( - bind(&DBusConfigurationManager::exportOnRingEnded, confM, _1, _2, _3)), - exportable_callback<ConfigurationSignal::KnownDevicesChanged>( - bind(&DBusConfigurationManager::knownDevicesChanged, confM, _1, _2)), - exportable_callback<ConfigurationSignal::NameRegistrationEnded>( - bind(&DBusConfigurationManager::nameRegistrationEnded, confM, _1, _2, _3)), - exportable_callback<ConfigurationSignal::UserSearchEnded>( - bind(&DBusConfigurationManager::userSearchEnded, confM, _1, _2, _3, _4)), - exportable_callback<ConfigurationSignal::RegisteredNameFound>( - bind(&DBusConfigurationManager::registeredNameFound, confM, _1, _2, _3, _4)), - exportable_callback<ConfigurationSignal::DeviceRevocationEnded>( - bind(&DBusConfigurationManager::deviceRevocationEnded, confM, _1, _2, _3)), - exportable_callback<ConfigurationSignal::AccountProfileReceived>( - bind(&DBusConfigurationManager::accountProfileReceived, confM, _1, _2, _3)), - exportable_callback<ConfigurationSignal::CertificatePinned>( - bind(&DBusConfigurationManager::certificatePinned, confM, _1)), - exportable_callback<ConfigurationSignal::CertificatePathPinned>( - bind(&DBusConfigurationManager::certificatePathPinned, confM, _1, _2)), - exportable_callback<ConfigurationSignal::CertificateExpired>( - bind(&DBusConfigurationManager::certificateExpired, confM, _1)), - exportable_callback<ConfigurationSignal::CertificateStateChanged>( - bind(&DBusConfigurationManager::certificateStateChanged, confM, _1, _2, _3)), - exportable_callback<ConfigurationSignal::MediaParametersChanged>( - bind(&DBusConfigurationManager::mediaParametersChanged, confM, _1)), - exportable_callback<ConfigurationSignal::MigrationEnded>( - bind(&DBusConfigurationManager::migrationEnded, confM, _1, _2)), - exportable_callback<ConfigurationSignal::HardwareDecodingChanged>( - bind(&DBusConfigurationManager::hardwareDecodingChanged, confM, _1)), - exportable_callback<ConfigurationSignal::HardwareEncodingChanged>( - bind(&DBusConfigurationManager::hardwareEncodingChanged, confM, _1)), - exportable_callback<ConfigurationSignal::MessageSend>( - bind(&DBusConfigurationManager::messageSend, confM, _1)), - }; - - // Presence event handlers - const std::map<std::string, SharedCallback> presEvHandlers = { - exportable_callback<PresenceSignal::NewServerSubscriptionRequest>( - bind(&DBusPresenceManager::newServerSubscriptionRequest, presM, _1)), - exportable_callback<PresenceSignal::ServerError>( - bind(&DBusPresenceManager::serverError, presM, _1, _2, _3)), - exportable_callback<PresenceSignal::NewBuddyNotification>( - bind(&DBusPresenceManager::newBuddyNotification, presM, _1, _2, _3, _4)), - exportable_callback<PresenceSignal::NearbyPeerNotification>( - bind(&DBusPresenceManager::nearbyPeerNotification, presM, _1, _2, _3, _4)), - exportable_callback<PresenceSignal::SubscriptionStateChanged>( - bind(&DBusPresenceManager::subscriptionStateChanged, presM, _1, _2, _3)), - }; - - // Audio event handlers - const std::map<std::string, SharedCallback> audioEvHandlers = { - exportable_callback<AudioSignal::DeviceEvent>( - bind(&DBusConfigurationManager::audioDeviceEvent, confM)), - exportable_callback<AudioSignal::AudioMeter>( - bind(&DBusConfigurationManager::audioMeter, confM, _1, _2)), - }; - - const std::map<std::string, SharedCallback> dataXferEvHandlers = { - exportable_callback<DataTransferSignal::DataTransferEvent>( - bind(&DBusConfigurationManager::dataTransferEvent, confM, _1, _2, _3, _4, _5)), - }; - - const std::map<std::string, SharedCallback> convEvHandlers = { - exportable_callback<ConversationSignal::ConversationLoaded>( - bind(&DBusConfigurationManager::conversationLoaded, confM, _1, _2, _3, _4)), - exportable_callback<ConversationSignal::MessagesFound>( - bind(&DBusConfigurationManager::messagesFound, confM, _1, _2, _3, _4)), - exportable_callback<ConversationSignal::MessageReceived>( - bind(&DBusConfigurationManager::messageReceived, confM, _1, _2, _3)), - exportable_callback<ConversationSignal::ConversationProfileUpdated>( - bind(&DBusConfigurationManager::conversationProfileUpdated, confM, _1, _2, _3)), - exportable_callback<ConversationSignal::ConversationRequestReceived>( - bind(&DBusConfigurationManager::conversationRequestReceived, confM, _1, _2, _3)), - exportable_callback<ConversationSignal::ConversationRequestDeclined>( - bind(&DBusConfigurationManager::conversationRequestDeclined, confM, _1, _2)), - exportable_callback<ConversationSignal::ConversationReady>( - bind(&DBusConfigurationManager::conversationReady, confM, _1, _2)), - exportable_callback<ConversationSignal::ConversationRemoved>( - bind(&DBusConfigurationManager::conversationRemoved, confM, _1, _2)), - exportable_callback<ConversationSignal::ConversationMemberEvent>( - bind(&DBusConfigurationManager::conversationMemberEvent, confM, _1, _2, _3, _4)), - exportable_callback<ConversationSignal::OnConversationError>( - bind(&DBusConfigurationManager::onConversationError, confM, _1, _2, _3, _4)), - exportable_callback<ConversationSignal::ConversationPreferencesUpdated>( - bind(&DBusConfigurationManager::conversationPreferencesUpdated, confM, _1, _2, _3)), - }; - -#ifdef ENABLE_VIDEO - // Video event handlers - const std::map<std::string, SharedCallback> videoEvHandlers = { - exportable_callback<VideoSignal::DeviceEvent>(bind(&DBusVideoManager::deviceEvent, videoM)), - exportable_callback<VideoSignal::DecodingStarted>( - bind(&DBusVideoManager::decodingStarted, videoM, _1, _2, _3, _4, _5)), - exportable_callback<VideoSignal::DecodingStopped>( - bind(&DBusVideoManager::decodingStopped, videoM, _1, _2, _3)), - }; -#endif - -#ifdef ENABLE_PLUGIN - // Plugin event handlers - const std::map<std::string, SharedCallback> pluginEvHandlers = { - exportable_callback<libjami::PluginSignal::WebViewMessageReceived>( - bind(&DBusPluginManagerInterface::webViewMessageReceived, pluginM, _1, _2, _3, _4)), - }; -#endif - - if (!libjami::init(static_cast<libjami::InitFlag>(flags))) - return -1; - - libjami::registerSignalHandlers(callEvHandlers); - libjami::registerSignalHandlers(configEvHandlers); - libjami::registerSignalHandlers(presEvHandlers); - libjami::registerSignalHandlers(audioEvHandlers); - libjami::registerSignalHandlers(dataXferEvHandlers); - libjami::registerSignalHandlers(convEvHandlers); -#ifdef ENABLE_VIDEO - libjami::registerSignalHandlers(videoEvHandlers); -#endif -#ifdef ENABLE_PLUGIN - libjami::registerSignalHandlers(pluginEvHandlers); -#endif - - if (!libjami::start()) - return -1; - return 0; -} - -void -DBusClient::finiLibrary() noexcept -{ - libjami::fini(); -} - -int -DBusClient::event_loop() noexcept -{ - try { - dispatcher_->enter(); - } catch (const DBus::Error& err) { - std::cerr << "quitting: " << err.name() << ": " << err.what() << std::endl; - return 1; - } catch (const std::exception& err) { - std::cerr << "quitting: " << err.what() << std::endl; - return 1; - } - - return 0; -} - -int -DBusClient::exit() noexcept -{ - try { - dispatcher_->leave(); - finiLibrary(); - } catch (const DBus::Error& err) { - std::cerr << "quitting: " << err.name() << ": " << err.what() << std::endl; - return 1; - } catch (const std::exception& err) { - std::cerr << "quitting: " << err.what() << std::endl; - return 1; - } - - return 0; -} diff --git a/bin/dbus/dbusclient.h b/bin/dbus/dbusclient.h deleted file mode 100644 index 1d8cf6026f4fa677d54113aa0e5018946d577063..0000000000000000000000000000000000000000 --- a/bin/dbus/dbusclient.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - -#include "def.h" -#include <memory> - -class DBusConfigurationManager; -class DBusCallManager; -class DBusNetworkManager; -class DBusInstance; -class DBusPresenceManager; - -#ifdef ENABLE_PLUGIN -class DBusPluginManagerInterface; -#endif - -#ifdef ENABLE_VIDEO -class DBusVideoManager; -#endif - -namespace DBus { - class BusDispatcher; - class DefaultTimeout; -} - -class LIBJAMI_PUBLIC DBusClient { - public: - DBusClient(int flags, bool persistent); - ~DBusClient(); - - int event_loop() noexcept; - int exit() noexcept; - - private: - int initLibrary(int flags); - void finiLibrary() noexcept; - - std::unique_ptr<DBus::BusDispatcher> dispatcher_; - std::unique_ptr<DBus::DefaultTimeout> timeout_; - - std::unique_ptr<DBusCallManager> callManager_; - std::unique_ptr<DBusConfigurationManager> configurationManager_; - std::unique_ptr<DBusPresenceManager> presenceManager_; - std::unique_ptr<DBusInstance> instanceManager_; - -#ifdef ENABLE_PLUGIN - std::unique_ptr<DBusPluginManagerInterface> pluginManagerInterface_; -#endif - -#ifdef ENABLE_VIDEO - std::unique_ptr<DBusVideoManager> videoManager_; -#endif -}; diff --git a/bin/dbus/dbusconfigurationmanager.cpp b/bin/dbus/dbusconfigurationmanager.cpp deleted file mode 100644 index 58dad6752703fdc4bace6180dec64998539a6714..0000000000000000000000000000000000000000 --- a/bin/dbus/dbusconfigurationmanager.cpp +++ /dev/null @@ -1,1001 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "dbusconfigurationmanager.h" -#include "configurationmanager_interface.h" -#include "datatransfer_interface.h" -#include "conversation_interface.h" - -DBusConfigurationManager::DBusConfigurationManager(DBus::Connection& connection) - : DBus::ObjectAdaptor(connection, "/cx/ring/Ring/ConfigurationManager") -{} - -auto -DBusConfigurationManager::getAccountDetails(const std::string& accountID) - -> decltype(libjami::getAccountDetails(accountID)) -{ - return libjami::getAccountDetails(accountID); -} - -auto -DBusConfigurationManager::getVolatileAccountDetails(const std::string& accountID) - -> decltype(libjami::getVolatileAccountDetails(accountID)) -{ - return libjami::getVolatileAccountDetails(accountID); -} - -void -DBusConfigurationManager::setAccountDetails(const std::string& accountID, - const std::map<std::string, std::string>& details) -{ - libjami::setAccountDetails(accountID, details); -} - -void -DBusConfigurationManager::setAccountActive(const std::string& accountID, const bool& active) -{ - libjami::setAccountActive(accountID, active); -} - -auto -DBusConfigurationManager::getAccountTemplate(const std::string& accountType) - -> decltype(libjami::getAccountTemplate(accountType)) -{ - return libjami::getAccountTemplate(accountType); -} - -auto -DBusConfigurationManager::addAccount(const std::map<std::string, std::string>& details) - -> decltype(libjami::addAccount(details)) -{ - return libjami::addAccount(details); -} - -auto -DBusConfigurationManager::monitor(const bool& continuous) -> decltype(libjami::monitor(continuous)) -{ - return libjami::monitor(continuous); -} - -auto -DBusConfigurationManager::exportOnRing(const std::string& accountID, const std::string& password) - -> decltype(libjami::exportOnRing(accountID, password)) -{ - return libjami::exportOnRing(accountID, password); -} - -auto -DBusConfigurationManager::exportToFile(const std::string& accountID, - const std::string& destinationPath, - const std::string& password) - -> decltype(libjami::exportToFile(accountID, destinationPath, password)) -{ - return libjami::exportToFile(accountID, destinationPath, password); -} - -auto -DBusConfigurationManager::revokeDevice(const std::string& accountID, - const std::string& password, - const std::string& device) - -> decltype(libjami::revokeDevice(accountID, password, device)) -{ - return libjami::revokeDevice(accountID, password, device); -} - -auto -DBusConfigurationManager::getKnownRingDevices(const std::string& accountID) - -> decltype(libjami::getKnownRingDevices(accountID)) -{ - return libjami::getKnownRingDevices(accountID); -} - -auto -DBusConfigurationManager::changeAccountPassword(const std::string& accountID, - const std::string& password_old, - const std::string& password_new) - -> decltype(libjami::changeAccountPassword(accountID, password_old, password_new)) -{ - return libjami::changeAccountPassword(accountID, password_old, password_new); -} - -auto -DBusConfigurationManager::lookupName(const std::string& account, - const std::string& nameserver, - const std::string& name) - -> decltype(libjami::lookupName(account, nameserver, name)) -{ - return libjami::lookupName(account, nameserver, name); -} - -auto -DBusConfigurationManager::lookupAddress(const std::string& account, - const std::string& nameserver, - const std::string& address) - -> decltype(libjami::lookupAddress(account, nameserver, address)) -{ - return libjami::lookupAddress(account, nameserver, address); -} - -auto -DBusConfigurationManager::registerName(const std::string& account, - const std::string& password, - const std::string& name) - -> decltype(libjami::registerName(account, password, name)) -{ - return libjami::registerName(account, password, name); -} - -auto -DBusConfigurationManager::searchUser(const std::string& account, const std::string& query) - -> decltype(libjami::searchUser(account, query)) -{ - return libjami::searchUser(account, query); -} - -void -DBusConfigurationManager::removeAccount(const std::string& accountID) -{ - libjami::removeAccount(accountID); -} - -auto -DBusConfigurationManager::getAccountList() -> decltype(libjami::getAccountList()) -{ - return libjami::getAccountList(); -} - -void -DBusConfigurationManager::sendRegister(const std::string& accountID, const bool& enable) -{ - libjami::sendRegister(accountID, enable); -} - -void -DBusConfigurationManager::registerAllAccounts(void) -{ - libjami::registerAllAccounts(); -} - -auto -DBusConfigurationManager::sendTextMessage(const std::string& accountID, - const std::string& to, - const std::map<std::string, std::string>& payloads, - const int32_t& flags) - -> decltype(libjami::sendAccountTextMessage(accountID, to, payloads, flags)) -{ - return libjami::sendAccountTextMessage(accountID, to, payloads, flags); -} - -std::vector<RingDBusMessage> -DBusConfigurationManager::getLastMessages(const std::string& accountID, - const uint64_t& base_timestamp) -{ - auto messages = libjami::getLastMessages(accountID, base_timestamp); - std::vector<RingDBusMessage> result; - for (const auto& message : messages) { - RingDBusMessage m; - m._1 = message.from; - m._2 = message.payloads; - m._3 = message.received; - result.emplace_back(m); - } - return result; -} - -std::map<std::string, std::string> -DBusConfigurationManager::getNearbyPeers(const std::string& accountID) -{ - return libjami::getNearbyPeers(accountID); -} - -auto -DBusConfigurationManager::getMessageStatus(const uint64_t& id) - -> decltype(libjami::getMessageStatus(id)) -{ - return libjami::getMessageStatus(id); -} - -auto -DBusConfigurationManager::getMessageStatus(const std::string& accountID, const uint64_t& id) - -> decltype(libjami::getMessageStatus(accountID, id)) -{ - return libjami::getMessageStatus(accountID, id); -} - -bool -DBusConfigurationManager::cancelMessage(const std::string& accountID, const uint64_t& id) -{ - return libjami::cancelMessage(accountID, id); -} - -void -DBusConfigurationManager::setIsComposing(const std::string& accountID, - const std::string& conversationUri, - const bool& isWriting) -{ - libjami::setIsComposing(accountID, conversationUri, isWriting); -} - -bool -DBusConfigurationManager::setMessageDisplayed(const std::string& accountID, - const std::string& conversationUri, - const std::string& messageId, - const int32_t& status) -{ - return libjami::setMessageDisplayed(accountID, conversationUri, messageId, status); -} - -auto -DBusConfigurationManager::getCodecList() -> decltype(libjami::getCodecList()) -{ - return libjami::getCodecList(); -} - -auto -DBusConfigurationManager::getSupportedTlsMethod() -> decltype(libjami::getSupportedTlsMethod()) -{ - return libjami::getSupportedTlsMethod(); -} - -auto -DBusConfigurationManager::getSupportedCiphers(const std::string& accountID) - -> decltype(libjami::getSupportedCiphers(accountID)) -{ - return libjami::getSupportedCiphers(accountID); -} - -auto -DBusConfigurationManager::getCodecDetails(const std::string& accountID, const unsigned& codecId) - -> decltype(libjami::getCodecDetails(accountID, codecId)) -{ - return libjami::getCodecDetails(accountID, codecId); -} - -auto -DBusConfigurationManager::setCodecDetails(const std::string& accountID, - const unsigned& codecId, - const std::map<std::string, std::string>& details) - -> decltype(libjami::setCodecDetails(accountID, codecId, details)) -{ - return libjami::setCodecDetails(accountID, codecId, details); -} - -auto -DBusConfigurationManager::getActiveCodecList(const std::string& accountID) - -> decltype(libjami::getActiveCodecList(accountID)) -{ - return libjami::getActiveCodecList(accountID); -} - -void -DBusConfigurationManager::setActiveCodecList(const std::string& accountID, - const std::vector<unsigned>& list) -{ - libjami::setActiveCodecList(accountID, list); -} - -auto -DBusConfigurationManager::getAudioPluginList() -> decltype(libjami::getAudioPluginList()) -{ - return libjami::getAudioPluginList(); -} - -void -DBusConfigurationManager::setAudioPlugin(const std::string& audioPlugin) -{ - libjami::setAudioPlugin(audioPlugin); -} - -auto -DBusConfigurationManager::getAudioOutputDeviceList() - -> decltype(libjami::getAudioOutputDeviceList()) -{ - return libjami::getAudioOutputDeviceList(); -} - -void -DBusConfigurationManager::setAudioOutputDevice(const int32_t& index) -{ - libjami::setAudioOutputDevice(index); -} - -void -DBusConfigurationManager::setAudioInputDevice(const int32_t& index) -{ - libjami::setAudioInputDevice(index); -} - -void -DBusConfigurationManager::setAudioRingtoneDevice(const int32_t& index) -{ - libjami::setAudioRingtoneDevice(index); -} - -auto -DBusConfigurationManager::getAudioInputDeviceList() -> decltype(libjami::getAudioInputDeviceList()) -{ - return libjami::getAudioInputDeviceList(); -} - -auto -DBusConfigurationManager::getCurrentAudioDevicesIndex() - -> decltype(libjami::getCurrentAudioDevicesIndex()) -{ - return libjami::getCurrentAudioDevicesIndex(); -} - -auto -DBusConfigurationManager::getAudioInputDeviceIndex(const std::string& name) - -> decltype(libjami::getAudioInputDeviceIndex(name)) -{ - return libjami::getAudioInputDeviceIndex(name); -} - -auto -DBusConfigurationManager::getAudioOutputDeviceIndex(const std::string& name) - -> decltype(libjami::getAudioOutputDeviceIndex(name)) -{ - return libjami::getAudioOutputDeviceIndex(name); -} - -auto -DBusConfigurationManager::getCurrentAudioOutputPlugin() - -> decltype(libjami::getCurrentAudioOutputPlugin()) -{ - return libjami::getCurrentAudioOutputPlugin(); -} - -auto -DBusConfigurationManager::getNoiseSuppressState() -> decltype(libjami::getNoiseSuppressState()) -{ - return libjami::getNoiseSuppressState(); -} - -void -DBusConfigurationManager::setNoiseSuppressState(const std::string& state) -{ - libjami::setNoiseSuppressState(state); -} - -auto -DBusConfigurationManager::isAgcEnabled() -> decltype(libjami::isAgcEnabled()) -{ - return libjami::isAgcEnabled(); -} - -void -DBusConfigurationManager::setAgcState(const bool& enabled) -{ - libjami::setAgcState(enabled); -} - -void -DBusConfigurationManager::muteDtmf(const bool& mute) -{ - libjami::muteDtmf(mute); -} - -auto -DBusConfigurationManager::isDtmfMuted() -> decltype(libjami::isDtmfMuted()) -{ - return libjami::isDtmfMuted(); -} - -auto -DBusConfigurationManager::isCaptureMuted() -> decltype(libjami::isCaptureMuted()) -{ - return libjami::isCaptureMuted(); -} - -void -DBusConfigurationManager::muteCapture(const bool& mute) -{ - libjami::muteCapture(mute); -} - -auto -DBusConfigurationManager::isPlaybackMuted() -> decltype(libjami::isPlaybackMuted()) -{ - return libjami::isPlaybackMuted(); -} - -void -DBusConfigurationManager::mutePlayback(const bool& mute) -{ - libjami::mutePlayback(mute); -} - -auto -DBusConfigurationManager::isRingtoneMuted() -> decltype(libjami::isRingtoneMuted()) -{ - return libjami::isRingtoneMuted(); -} - -void -DBusConfigurationManager::muteRingtone(const bool& mute) -{ - libjami::muteRingtone(mute); -} - -auto -DBusConfigurationManager::getAudioManager() -> decltype(libjami::getAudioManager()) -{ - return libjami::getAudioManager(); -} - -auto -DBusConfigurationManager::setAudioManager(const std::string& api) - -> decltype(libjami::setAudioManager(api)) -{ - return libjami::setAudioManager(api); -} - -auto -DBusConfigurationManager::getSupportedAudioManagers() - -> decltype(libjami::getSupportedAudioManagers()) -{ - return libjami::getSupportedAudioManagers(); -} - -auto -DBusConfigurationManager::getRecordPath() -> decltype(libjami::getRecordPath()) -{ - return libjami::getRecordPath(); -} - -void -DBusConfigurationManager::setRecordPath(const std::string& recPath) -{ - libjami::setRecordPath(recPath); -} - -auto -DBusConfigurationManager::getIsAlwaysRecording() -> decltype(libjami::getIsAlwaysRecording()) -{ - return libjami::getIsAlwaysRecording(); -} - -void -DBusConfigurationManager::setIsAlwaysRecording(const bool& rec) -{ - libjami::setIsAlwaysRecording(rec); -} - -auto -DBusConfigurationManager::getRecordPreview() -> decltype(libjami::getRecordPreview()) -{ - return libjami::getRecordPreview(); -} - -void -DBusConfigurationManager::setRecordPreview(const bool& rec) -{ - libjami::setRecordPreview(rec); -} - -auto -DBusConfigurationManager::getRecordQuality() -> decltype(libjami::getRecordQuality()) -{ - return libjami::getRecordQuality(); -} - -void -DBusConfigurationManager::setRecordQuality(const int32_t& quality) -{ - libjami::setRecordQuality(quality); -} - -void -DBusConfigurationManager::setHistoryLimit(const int32_t& days) -{ - libjami::setHistoryLimit(days); -} - -auto -DBusConfigurationManager::getHistoryLimit() -> decltype(libjami::getHistoryLimit()) -{ - return libjami::getHistoryLimit(); -} - -void -DBusConfigurationManager::setRingingTimeout(const int32_t& timeout) -{ - libjami::setRingingTimeout(timeout); -} - -auto -DBusConfigurationManager::getRingingTimeout() -> decltype(libjami::getRingingTimeout()) -{ - return libjami::getRingingTimeout(); -} - -void -DBusConfigurationManager::setAccountsOrder(const std::string& order) -{ - libjami::setAccountsOrder(order); -} - -auto -DBusConfigurationManager::validateCertificate(const std::string& accountId, - const std::string& certificate) - -> decltype(libjami::validateCertificate(accountId, certificate)) -{ - return libjami::validateCertificate(accountId, certificate); -} - -auto -DBusConfigurationManager::validateCertificatePath(const std::string& accountId, - const std::string& certificate, - const std::string& privateKey, - const std::string& privateKeyPass, - const std::string& caList) - -> decltype(libjami::validateCertificatePath( - accountId, certificate, privateKey, privateKeyPass, caList)) -{ - return libjami::validateCertificatePath(accountId, - certificate, - privateKey, - privateKeyPass, - caList); -} - -auto -DBusConfigurationManager::getCertificateDetails(const std::string& accountId, - const std::string& certificate) - -> decltype(libjami::getCertificateDetails(accountId, certificate)) -{ - return libjami::getCertificateDetails(accountId, certificate); -} - -auto -DBusConfigurationManager::getCertificateDetailsPath(const std::string& accountId, - const std::string& certificate, - const std::string& privateKey, - const std::string& privateKeyPass) - -> decltype(libjami::getCertificateDetailsPath( - accountId, certificate, privateKey, privateKeyPass)) -{ - return libjami::getCertificateDetailsPath(accountId, certificate, privateKey, privateKeyPass); -} - -auto -DBusConfigurationManager::getPinnedCertificates(const std::string& accountId) - -> decltype(libjami::getPinnedCertificates(accountId)) -{ - return libjami::getPinnedCertificates(accountId); -} - -auto -DBusConfigurationManager::pinCertificate(const std::string& accountId, - const std::vector<uint8_t>& certificate, - const bool& local) - -> decltype(libjami::pinCertificate(accountId, certificate, local)) -{ - return libjami::pinCertificate(accountId, certificate, local); -} - -void -DBusConfigurationManager::pinCertificatePath(const std::string& accountId, const std::string& certPath) -{ - libjami::pinCertificatePath(accountId, certPath); -} - -auto -DBusConfigurationManager::unpinCertificate(const std::string& accountId, const std::string& certId) - -> decltype(libjami::unpinCertificate(accountId, certId)) -{ - return libjami::unpinCertificate(accountId, certId); -} - -auto -DBusConfigurationManager::unpinCertificatePath(const std::string& accountId, - const std::string& p) - -> decltype(libjami::unpinCertificatePath(accountId, p)) -{ - return libjami::unpinCertificatePath(accountId, p); -} - -auto -DBusConfigurationManager::pinRemoteCertificate(const std::string& accountId, - const std::string& certId) - -> decltype(libjami::pinRemoteCertificate(accountId, certId)) -{ - return libjami::pinRemoteCertificate(accountId, certId); -} - -auto -DBusConfigurationManager::setCertificateStatus(const std::string& accountId, - const std::string& certId, - const std::string& status) - -> decltype(libjami::setCertificateStatus(accountId, certId, status)) -{ - return libjami::setCertificateStatus(accountId, certId, status); -} - -auto -DBusConfigurationManager::getCertificatesByStatus(const std::string& accountId, - const std::string& status) - -> decltype(libjami::getCertificatesByStatus(accountId, status)) -{ - return libjami::getCertificatesByStatus(accountId, status); -} - -auto -DBusConfigurationManager::getTrustRequests(const std::string& accountId) - -> decltype(libjami::getTrustRequests(accountId)) -{ - return libjami::getTrustRequests(accountId); -} - -auto -DBusConfigurationManager::acceptTrustRequest(const std::string& accountId, const std::string& from) - -> decltype(libjami::acceptTrustRequest(accountId, from)) -{ - return libjami::acceptTrustRequest(accountId, from); -} - -auto -DBusConfigurationManager::discardTrustRequest(const std::string& accountId, const std::string& from) - -> decltype(libjami::discardTrustRequest(accountId, from)) -{ - return libjami::discardTrustRequest(accountId, from); -} - -void -DBusConfigurationManager::sendTrustRequest(const std::string& accountId, - const std::string& to, - const std::vector<uint8_t>& payload) -{ - libjami::sendTrustRequest(accountId, to, payload); -} - -void -DBusConfigurationManager::addContact(const std::string& accountId, const std::string& uri) -{ - libjami::addContact(accountId, uri); -} - -void -DBusConfigurationManager::removeContact(const std::string& accountId, - const std::string& uri, - const bool& ban) -{ - libjami::removeContact(accountId, uri, ban); -} - -auto -DBusConfigurationManager::getContactDetails(const std::string& accountId, const std::string& uri) - -> decltype(libjami::getContactDetails(accountId, uri)) -{ - return libjami::getContactDetails(accountId, uri); -} - -auto -DBusConfigurationManager::getContacts(const std::string& accountId) - -> decltype(libjami::getContacts(accountId)) -{ - return libjami::getContacts(accountId); -} - -auto -DBusConfigurationManager::getCredentials(const std::string& accountID) - -> decltype(libjami::getCredentials(accountID)) -{ - return libjami::getCredentials(accountID); -} - -void -DBusConfigurationManager::setCredentials( - const std::string& accountID, const std::vector<std::map<std::string, std::string>>& details) -{ - libjami::setCredentials(accountID, details); -} - -auto -DBusConfigurationManager::getAddrFromInterfaceName(const std::string& interface) - -> decltype(libjami::getAddrFromInterfaceName(interface)) -{ - return libjami::getAddrFromInterfaceName(interface); -} - -auto -DBusConfigurationManager::getAllIpInterface() -> decltype(libjami::getAllIpInterface()) -{ - return libjami::getAllIpInterface(); -} - -auto -DBusConfigurationManager::getAllIpInterfaceByName() -> decltype(libjami::getAllIpInterfaceByName()) -{ - return libjami::getAllIpInterfaceByName(); -} - -void -DBusConfigurationManager::setVolume(const std::string& device, const double& value) -{ - libjami::setVolume(device, value); -} - -auto -DBusConfigurationManager::getVolume(const std::string& device) - -> decltype(libjami::getVolume(device)) -{ - return libjami::getVolume(device); -} - -void -DBusConfigurationManager::connectivityChanged() -{ - libjami::connectivityChanged(); -} - -void -DBusConfigurationManager::sendFile(const std::string& accountId, - const std::string& conversationId, - const std::string& path, - const std::string& displayName, - const std::string& replyTo) -{ - libjami::sendFile(accountId, conversationId, path, displayName, replyTo); -} - -void -DBusConfigurationManager::fileTransferInfo(const std::string& accountId, - const std::string& conversationId, - const std::string& fileId, - uint32_t& error, - std::string& path, - int64_t& total, - int64_t& progress) -{ - error = uint32_t( - libjami::fileTransferInfo(accountId, conversationId, fileId, path, total, progress)); -} - -bool -DBusConfigurationManager::downloadFile(const std::string& accountId, - const std::string& conversationUri, - const std::string& interactionId, - const std::string& fileId, - const std::string& path) -{ - return libjami::downloadFile(accountId, conversationUri, interactionId, fileId, path); -} - -uint32_t -DBusConfigurationManager::cancelDataTransfer(const std::string& accountId, - const std::string& conversationId, - const std::string& fileId) -{ - return uint32_t(libjami::cancelDataTransfer(accountId, conversationId, fileId)); -} - -std::string -DBusConfigurationManager::startConversation(const std::string& accountId) -{ - return libjami::startConversation(accountId); -} - -void -DBusConfigurationManager::acceptConversationRequest(const std::string& accountId, - const std::string& conversationId) -{ - libjami::acceptConversationRequest(accountId, conversationId); -} - -void -DBusConfigurationManager::declineConversationRequest(const std::string& accountId, - const std::string& conversationId) -{ - libjami::declineConversationRequest(accountId, conversationId); -} - -bool -DBusConfigurationManager::removeConversation(const std::string& accountId, - const std::string& conversationId) -{ - return libjami::removeConversation(accountId, conversationId); -} - -std::vector<std::string> -DBusConfigurationManager::getConversations(const std::string& accountId) -{ - return libjami::getConversations(accountId); -} - -std::vector<std::map<std::string, std::string>> -DBusConfigurationManager::getActiveCalls(const std::string& accountId, - const std::string& conversationId) -{ - return libjami::getActiveCalls(accountId, conversationId); -} - -std::vector<std::map<std::string, std::string>> -DBusConfigurationManager::getConversationRequests(const std::string& accountId) -{ - return libjami::getConversationRequests(accountId); -} - -void -DBusConfigurationManager::updateConversationInfos(const std::string& accountId, - const std::string& conversationId, - const std::map<std::string, std::string>& infos) -{ - libjami::updateConversationInfos(accountId, conversationId, infos); -} - -std::map<std::string, std::string> -DBusConfigurationManager::conversationInfos(const std::string& accountId, - const std::string& conversationId) -{ - return libjami::conversationInfos(accountId, conversationId); -} - -void -DBusConfigurationManager::setConversationPreferences(const std::string& accountId, - const std::string& conversationId, - const std::map<std::string, std::string>& infos) -{ - libjami::setConversationPreferences(accountId, conversationId, infos); -} - -std::map<std::string, std::string> -DBusConfigurationManager::getConversationPreferences(const std::string& accountId, - const std::string& conversationId) -{ - return libjami::getConversationPreferences(accountId, conversationId); -} - -void -DBusConfigurationManager::addConversationMember(const std::string& accountId, - const std::string& conversationId, - const std::string& contactUri) -{ - libjami::addConversationMember(accountId, conversationId, contactUri); -} - -void -DBusConfigurationManager::removeConversationMember(const std::string& accountId, - const std::string& conversationId, - const std::string& contactUri) -{ - libjami::removeConversationMember(accountId, conversationId, contactUri); -} - -std::vector<std::map<std::string, std::string>> -DBusConfigurationManager::getConversationMembers(const std::string& accountId, - const std::string& conversationId) -{ - return libjami::getConversationMembers(accountId, conversationId); -} - -void -DBusConfigurationManager::sendMessage(const std::string& accountId, - const std::string& conversationId, - const std::string& message, - const std::string& replyTo, - const int32_t& flag) -{ - libjami::sendMessage(accountId, conversationId, message, replyTo, flag); -} - -uint32_t -DBusConfigurationManager::loadConversationMessages(const std::string& accountId, - const std::string& conversationId, - const std::string& fromMessage, - const uint32_t& n) -{ - return libjami::loadConversationMessages(accountId, conversationId, fromMessage, n); -} - -uint32_t -DBusConfigurationManager::loadConversationUntil(const std::string& accountId, - const std::string& conversationId, - const std::string& fromMessage, - const std::string& to) -{ - return libjami::loadConversationUntil(accountId, conversationId, fromMessage, to); -} - -uint32_t -DBusConfigurationManager::countInteractions(const std::string& accountId, - const std::string& conversationId, - const std::string& toId, - const std::string& fromId, - const std::string& authorUri) -{ - return libjami::countInteractions(accountId, conversationId, toId, fromId, authorUri); -} - -uint32_t -DBusConfigurationManager::searchConversation(const std::string& accountId, - const std::string& conversationId, - const std::string& author, - const std::string& lastId, - const std::string& regexSearch, - const std::string& type, - const int64_t& after, - const int64_t& before, - const uint32_t& maxResult, - const int32_t& flag) -{ - return libjami::searchConversation(accountId, - conversationId, - author, - lastId, - regexSearch, - type, - after, - before, - maxResult, - flag); -} - -bool -DBusConfigurationManager::isAudioMeterActive(const std::string& id) -{ - return libjami::isAudioMeterActive(id); -} - -void -DBusConfigurationManager::setAudioMeterState(const std::string& id, const bool& state) -{ - return libjami::setAudioMeterState(id, state); -} - -void -DBusConfigurationManager::setDefaultModerator(const std::string& accountID, - const std::string& peerURI, - const bool& state) -{ - libjami::setDefaultModerator(accountID, peerURI, state); -} - -auto -DBusConfigurationManager::getDefaultModerators(const std::string& accountID) - -> decltype(libjami::getDefaultModerators(accountID)) -{ - return libjami::getDefaultModerators(accountID); -} - -void -DBusConfigurationManager::enableLocalModerators(const std::string& accountID, - const bool& isModEnabled) -{ - return libjami::enableLocalModerators(accountID, isModEnabled); -} - -bool -DBusConfigurationManager::isLocalModeratorsEnabled(const std::string& accountID) -{ - return libjami::isLocalModeratorsEnabled(accountID); -} - -void -DBusConfigurationManager::setAllModerators(const std::string& accountID, const bool& allModerators) -{ - return libjami::setAllModerators(accountID, allModerators); -} - -bool -DBusConfigurationManager::isAllModerators(const std::string& accountID) -{ - return libjami::isAllModerators(accountID); -} \ No newline at end of file diff --git a/bin/dbus/dbusconfigurationmanager.h b/bin/dbus/dbusconfigurationmanager.h deleted file mode 100644 index 574aa13c99b68ced3a33eaa7324809eee718fe30..0000000000000000000000000000000000000000 --- a/bin/dbus/dbusconfigurationmanager.h +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com> - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com> - * Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __RING_DBUSCONFIGURATIONMANAGER_H__ -#define __RING_DBUSCONFIGURATIONMANAGER_H__ - -#include <vector> -#include <map> -#include <string> - -#include "def.h" -#include "dbus_cpp.h" - -#include "datatransfer_interface.h" - -#if __GNUC__ >= 5 || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" -#endif - -#pragma GCC diagnostic ignored "-Wignored-qualifiers" -#pragma GCC diagnostic ignored "-Wunused-parameter" -#include "dbusconfigurationmanager.adaptor.h" -#pragma GCC diagnostic warning "-Wignored-qualifiers" -#pragma GCC diagnostic warning "-Wunused-parameter" - -#if __GNUC__ >= 5 || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic warning "-Wunused-but-set-variable" -#endif - -using RingDBusMessage = DBus::Struct<std::string, std::map<std::string, std::string>, uint64_t>; - -class LIBJAMI_PUBLIC DBusConfigurationManager : public cx::ring::Ring::ConfigurationManager_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor -{ -public: - using RingDBusDataTransferInfo = DBus::Struct<std::string, - uint32_t, - uint32_t, - int64_t, - int64_t, - std::string, - std::string, - std::string, - std::string, - std::string, - std::string>; - - DBusConfigurationManager(DBus::Connection& connection); - - // Methods - std::map<std::string, std::string> getAccountDetails(const std::string& accountID); - std::map<std::string, std::string> getVolatileAccountDetails(const std::string& accountID); - void setAccountDetails(const std::string& accountID, - const std::map<std::string, std::string>& details); - void setAccountActive(const std::string& accountID, const bool& active); - std::map<std::string, std::string> getAccountTemplate(const std::string& accountType); - void monitor(const bool& continuous); - std::string addAccount(const std::map<std::string, std::string>& details); - bool exportOnRing(const std::string& accountID, const std::string& password); - bool exportToFile(const std::string& accountID, - const std::string& destinationPath, - const std::string& password = {}); - bool revokeDevice(const std::string& accountID, - const std::string& password, - const std::string& device); - std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID); - bool changeAccountPassword(const std::string& accountID, - const std::string& password_old, - const std::string& password_new); - bool lookupName(const std::string& account, - const std::string& nameserver, - const std::string& name); - bool lookupAddress(const std::string& account, - const std::string& nameserver, - const std::string& address); - bool registerName(const std::string& account, - const std::string& password, - const std::string& name); - bool searchUser(const std::string& account, const std::string& query); - void removeAccount(const std::string& accoundID); - std::vector<std::string> getAccountList(); - void sendRegister(const std::string& accoundID, const bool& enable); - void registerAllAccounts(void); - uint64_t sendTextMessage(const std::string& accoundID, - const std::string& to, - const std::map<std::string, std::string>& payloads, - const int32_t& flags); - std::vector<RingDBusMessage> getLastMessages(const std::string& accountID, - const uint64_t& base_timestamp); - std::map<std::string, std::string> getNearbyPeers(const std::string& accountID); - int getMessageStatus(const uint64_t& id); - int getMessageStatus(const std::string& accountID, const uint64_t& id); - bool cancelMessage(const std::string& accountID, const uint64_t& messageId); - void setIsComposing(const std::string& accountID, - const std::string& conversationUri, - const bool& isWriting); - bool setMessageDisplayed(const std::string& accountID, - const std::string& conversationUri, - const std::string& messageId, - const int32_t& status); - std::vector<std::string> getSupportedCiphers(const std::string& accountID); - std::vector<unsigned> getCodecList(); - std::vector<std::string> getSupportedTlsMethod(); - std::map<std::string, std::string> getCodecDetails(const std::string& accountID, - const unsigned& codecId); - bool setCodecDetails(const std::string& accountID, - const unsigned& codecId, - const std::map<std::string, std::string>& details); - std::vector<unsigned> getActiveCodecList(const std::string& accountID); - void setActiveCodecList(const std::string& accountID, const std::vector<unsigned>& list); - std::vector<std::string> getAudioPluginList(); - void setAudioPlugin(const std::string& audioPlugin); - std::vector<std::string> getAudioOutputDeviceList(); - void setAudioOutputDevice(const int32_t& index); - void setAudioInputDevice(const int32_t& index); - void setAudioRingtoneDevice(const int32_t& index); - std::vector<std::string> getAudioInputDeviceList(); - std::vector<std::string> getCurrentAudioDevicesIndex(); - int32_t getAudioInputDeviceIndex(const std::string& name); - int32_t getAudioOutputDeviceIndex(const std::string& name); - std::string getCurrentAudioOutputPlugin(); - std::string getNoiseSuppressState(); - void setNoiseSuppressState(const std::string& state); - bool isAgcEnabled(); - void setAgcState(const bool& enabled); - void muteDtmf(const bool& mute); - bool isDtmfMuted(); - bool isCaptureMuted(); - void muteCapture(const bool& mute); - bool isPlaybackMuted(); - void mutePlayback(const bool& mute); - bool isRingtoneMuted(); - void muteRingtone(const bool& mute); - std::string getAudioManager(); - bool setAudioManager(const std::string& api); - std::vector<std::string> getSupportedAudioManagers(); - std::string getRecordPath(); - void setRecordPath(const std::string& recPath); - bool getIsAlwaysRecording(); - void setIsAlwaysRecording(const bool& rec); - bool getRecordPreview(); - void setRecordPreview(const bool& rec); - int32_t getRecordQuality(); - void setRecordQuality(const int32_t& quality); - void setHistoryLimit(const int32_t& days); - int32_t getHistoryLimit(); - void setRingingTimeout(const int32_t& timeout); - int32_t getRingingTimeout(); - void setAccountsOrder(const std::string& order); - std::vector<std::map<std::string, std::string>> getCredentials(const std::string& accountID); - void setCredentials(const std::string& accountID, - const std::vector<std::map<std::string, std::string>>& details); - std::string getAddrFromInterfaceName(const std::string& interface); - std::vector<std::string> getAllIpInterface(); - std::vector<std::string> getAllIpInterfaceByName(); - void setVolume(const std::string& device, const double& value); - double getVolume(const std::string& device); - std::map<std::string, std::string> validateCertificate(const std::string& accountId, - const std::string& certificate); - std::map<std::string, std::string> validateCertificatePath(const std::string& accountId, - const std::string& certificatePath, - const std::string& privateKey, - const std::string& privateKeyPass, - const std::string& caList); - std::map<std::string, std::string> getCertificateDetails(const std::string& accountId, - const std::string& certificate); - std::map<std::string, std::string> getCertificateDetailsPath(const std::string& accountId, - const std::string& certificatePath, - const std::string& privateKey, - const std::string& privateKeyPass); - std::vector<std::string> getPinnedCertificates(const std::string& accountId); - std::vector<std::string> pinCertificate(const std::string& accountId, - const std::vector<uint8_t>& certificate, - const bool& local); - bool unpinCertificate(const std::string& accountId, const std::string& certId); - void pinCertificatePath(const std::string& accountId, const std::string& path); - unsigned unpinCertificatePath(const std::string& accountId, const std::string& path); - bool pinRemoteCertificate(const std::string& accountId, const std::string& certId); - bool setCertificateStatus(const std::string& account, - const std::string& certId, - const std::string& status); - std::vector<std::string> getCertificatesByStatus(const std::string& account, - const std::string& status); - std::vector<std::map<std::string, std::string>> getTrustRequests(const std::string& accountId); - bool acceptTrustRequest(const std::string& accountId, const std::string& from); - bool discardTrustRequest(const std::string& accountId, const std::string& from); - void sendTrustRequest(const std::string& accountId, - const std::string& to, - const std::vector<uint8_t>& payload); - void addContact(const std::string& accountId, const std::string& uri); - void removeContact(const std::string& accountId, const std::string& uri, const bool& ban); - std::map<std::string, std::string> getContactDetails(const std::string& accountId, - const std::string& uri); - std::vector<std::map<std::string, std::string>> getContacts(const std::string& accountId); - void connectivityChanged(); - void sendFile(const std::string& accountId, - const std::string& conversationId, - const std::string& path, - const std::string& displayName, - const std::string& replyTo); - void fileTransferInfo(const std::string& accountId, - const std::string& conversationId, - const std::string& fileId, - uint32_t& error, - std::string& path, - int64_t& total, - int64_t& progress); - bool downloadFile(const std::string& accountId, - const std::string& conversationId, - const std::string& interactionId, - const std::string& fileId, - const std::string& path); - uint32_t cancelDataTransfer(const std::string& accountId, - const std::string& conversationId, - const std::string& fileId); - bool isAudioMeterActive(const std::string& id); - void setAudioMeterState(const std::string& id, const bool& state); - void setDefaultModerator(const std::string& accountID, - const std::string& uri, - const bool& state); - std::vector<std::string> getDefaultModerators(const std::string& accountID); - void enableLocalModerators(const std::string& accountID, const bool& isModEnabled); - bool isLocalModeratorsEnabled(const std::string& accountID); - void setAllModerators(const std::string& accountID, const bool& allModerators); - bool isAllModerators(const std::string& accountID); - std::string startConversation(const std::string& accountId); - void acceptConversationRequest(const std::string& accountId, const std::string& conversationId); - void declineConversationRequest(const std::string& accountId, const std::string& conversationId); - bool removeConversation(const std::string& accountId, const std::string& conversationId); - std::vector<std::string> getConversations(const std::string& accountId); - std::vector<std::map<std::string, std::string>> getActiveCalls( - const std::string& accountId, const std::string& conversationId); - std::vector<std::map<std::string, std::string>> getConversationRequests( - const std::string& accountId); - void updateConversationInfos(const std::string& accountId, - const std::string& conversationId, - const std::map<std::string, std::string>& infos); - std::map<std::string, std::string> conversationInfos(const std::string& accountId, - const std::string& conversationId); - void setConversationPreferences(const std::string& accountId, - const std::string& conversationId, - const std::map<std::string, std::string>& prefs); - std::map<std::string, std::string> getConversationPreferences(const std::string& accountId, - const std::string& conversationId); - void addConversationMember(const std::string& accountId, - const std::string& conversationId, - const std::string& contactUri); - void removeConversationMember(const std::string& accountId, - const std::string& conversationId, - const std::string& contactUri); - std::vector<std::map<std::string, std::string>> getConversationMembers( - const std::string& accountId, const std::string& conversationId); - void sendMessage(const std::string& accountId, - const std::string& conversationId, - const std::string& message, - const std::string& replyTo, - const int32_t& flag); - uint32_t loadConversationMessages(const std::string& accountId, - const std::string& conversationId, - const std::string& fromMessage, - const uint32_t& n); - uint32_t loadConversationUntil(const std::string& accountId, - const std::string& conversationId, - const std::string& fromMessage, - const std::string& to); - uint32_t countInteractions(const std::string& accountId, - const std::string& conversationId, - const std::string& toId, - const std::string& fromId, - const std::string& authorUri); - uint32_t searchConversation(const std::string& accountId, - const std::string& conversationId, - const std::string& author, - const std::string& lastId, - const std::string& regexSearch, - const std::string& type, - const int64_t& after, - const int64_t& before, - const uint32_t& maxResult, - const int32_t& flag); -}; - -#endif // __RING_DBUSCONFIGURATIONMANAGER_H__ diff --git a/bin/dbus/dbusconfigurationmanager.hpp b/bin/dbus/dbusconfigurationmanager.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a33e79844027f92913bdeb2835642cad909e109e --- /dev/null +++ b/bin/dbus/dbusconfigurationmanager.hpp @@ -0,0 +1,1138 @@ +/* + * Copyright (C) 2004-2023 Savoir-faire Linux Inc. + * + * Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com> + * Author: Vladimir Stoiakin <vstoiakin@lavabit.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include "dbusconfigurationmanager.adaptor.h" +#include <configurationmanager_interface.h> +#include <datatransfer_interface.h> +#include <conversation_interface.h> + +class DBusConfigurationManager : public sdbus::AdaptorInterfaces<cx::ring::Ring::ConfigurationManager_adaptor> +{ +public: + DBusConfigurationManager(sdbus::IConnection& connection) + : AdaptorInterfaces(connection, "/cx/ring/Ring/ConfigurationManager") + { + registerAdaptor(); + registerSignalHandlers(); + } + + ~DBusConfigurationManager() + { + unregisterAdaptor(); + } + + auto + getAccountDetails(const std::string& accountID) + -> decltype(libjami::getAccountDetails(accountID)) + { + return libjami::getAccountDetails(accountID); + } + + auto + getVolatileAccountDetails(const std::string& accountID) + -> decltype(libjami::getVolatileAccountDetails(accountID)) + { + return libjami::getVolatileAccountDetails(accountID); + } + + void + setAccountDetails(const std::string& accountID, + const std::map<std::string, std::string>& details) + { + libjami::setAccountDetails(accountID, details); + } + + void + setAccountActive(const std::string& accountID, const bool& active) + { + libjami::setAccountActive(accountID, active); + } + + auto + getAccountTemplate(const std::string& accountType) + -> decltype(libjami::getAccountTemplate(accountType)) + { + return libjami::getAccountTemplate(accountType); + } + + auto + addAccount(const std::map<std::string, std::string>& details) + -> decltype(libjami::addAccount(details)) + { + return libjami::addAccount(details); + } + + auto + monitor(const bool& continuous) -> decltype(libjami::monitor(continuous)) + { + return libjami::monitor(continuous); + } + + auto + exportOnRing(const std::string& accountID, const std::string& password) + -> decltype(libjami::exportOnRing(accountID, password)) + { + return libjami::exportOnRing(accountID, password); + } + + auto + exportToFile(const std::string& accountID, + const std::string& destinationPath, + const std::string& password) + -> decltype(libjami::exportToFile(accountID, destinationPath, password)) + { + return libjami::exportToFile(accountID, destinationPath, password); + } + + auto + revokeDevice(const std::string& accountID, + const std::string& password, + const std::string& device) + -> decltype(libjami::revokeDevice(accountID, password, device)) + { + return libjami::revokeDevice(accountID, password, device); + } + + auto + getKnownRingDevices(const std::string& accountID) + -> decltype(libjami::getKnownRingDevices(accountID)) + { + return libjami::getKnownRingDevices(accountID); + } + + auto + changeAccountPassword(const std::string& accountID, + const std::string& password_old, + const std::string& password_new) + -> decltype(libjami::changeAccountPassword(accountID, password_old, password_new)) + { + return libjami::changeAccountPassword(accountID, password_old, password_new); + } + + auto + lookupName(const std::string& account, + const std::string& nameserver, + const std::string& name) + -> decltype(libjami::lookupName(account, nameserver, name)) + { + return libjami::lookupName(account, nameserver, name); + } + + auto + lookupAddress(const std::string& account, + const std::string& nameserver, + const std::string& address) + -> decltype(libjami::lookupAddress(account, nameserver, address)) + { + return libjami::lookupAddress(account, nameserver, address); + } + + auto + registerName(const std::string& account, + const std::string& password, + const std::string& name) + -> decltype(libjami::registerName(account, password, name)) + { + return libjami::registerName(account, password, name); + } + + auto + searchUser(const std::string& account, const std::string& query) + -> decltype(libjami::searchUser(account, query)) + { + return libjami::searchUser(account, query); + } + + void + removeAccount(const std::string& accountID) + { + libjami::removeAccount(accountID); + } + + auto + getAccountList() -> decltype(libjami::getAccountList()) + { + return libjami::getAccountList(); + } + + void + sendRegister(const std::string& accountID, const bool& enable) + { + libjami::sendRegister(accountID, enable); + } + + void + registerAllAccounts(void) + { + libjami::registerAllAccounts(); + } + + auto + sendTextMessage(const std::string& accountID, + const std::string& to, + const std::map<std::string, std::string>& payloads, + const int32_t& flags) + -> decltype(libjami::sendAccountTextMessage(accountID, to, payloads, flags)) + { + return libjami::sendAccountTextMessage(accountID, to, payloads, flags); + } + + std::vector<sdbus::Struct<std::string, std::map<std::string, std::string>, uint64_t>> + getLastMessages(const std::string& accountID, + const uint64_t& base_timestamp) + { + auto messages = libjami::getLastMessages(accountID, base_timestamp); + std::vector<sdbus::Struct<std::string, std::map<std::string, std::string>, uint64_t>> result; + for (const auto& message : messages) { + sdbus::Struct<std::string, std::map<std::string, std::string>, uint64_t> m( + message.from, message.payloads, message.received ); + result.emplace_back(m); + } + return result; + } + + std::map<std::string, std::string> + getNearbyPeers(const std::string& accountID) + { + return libjami::getNearbyPeers(accountID); + } + + auto + getMessageStatus(const uint64_t& id) + -> decltype(libjami::getMessageStatus(id)) + { + return libjami::getMessageStatus(id); + } + + auto + getMessageStatus(const std::string& accountID, const uint64_t& id) + -> decltype(libjami::getMessageStatus(accountID, id)) + { + return libjami::getMessageStatus(accountID, id); + } + + bool + cancelMessage(const std::string& accountID, const uint64_t& id) + { + return libjami::cancelMessage(accountID, id); + } + + void + setIsComposing(const std::string& accountID, + const std::string& conversationUri, + const bool& isWriting) + { + libjami::setIsComposing(accountID, conversationUri, isWriting); + } + + bool + setMessageDisplayed(const std::string& accountID, + const std::string& conversationUri, + const std::string& messageId, + const int32_t& status) + { + return libjami::setMessageDisplayed(accountID, conversationUri, messageId, status); + } + + auto + getCodecList() -> decltype(libjami::getCodecList()) + { + return libjami::getCodecList(); + } + + auto + getSupportedTlsMethod() -> decltype(libjami::getSupportedTlsMethod()) + { + return libjami::getSupportedTlsMethod(); + } + + auto + getSupportedCiphers(const std::string& accountID) + -> decltype(libjami::getSupportedCiphers(accountID)) + { + return libjami::getSupportedCiphers(accountID); + } + + auto + getCodecDetails(const std::string& accountID, const unsigned& codecId) + -> decltype(libjami::getCodecDetails(accountID, codecId)) + { + return libjami::getCodecDetails(accountID, codecId); + } + + auto + setCodecDetails(const std::string& accountID, + const unsigned& codecId, + const std::map<std::string, std::string>& details) + -> decltype(libjami::setCodecDetails(accountID, codecId, details)) + { + return libjami::setCodecDetails(accountID, codecId, details); + } + + auto + getActiveCodecList(const std::string& accountID) + -> decltype(libjami::getActiveCodecList(accountID)) + { + return libjami::getActiveCodecList(accountID); + } + + void + setActiveCodecList(const std::string& accountID, + const std::vector<unsigned>& list) + { + libjami::setActiveCodecList(accountID, list); + } + + auto + getAudioPluginList() -> decltype(libjami::getAudioPluginList()) + { + return libjami::getAudioPluginList(); + } + + void + setAudioPlugin(const std::string& audioPlugin) + { + libjami::setAudioPlugin(audioPlugin); + } + + auto + getAudioOutputDeviceList() + -> decltype(libjami::getAudioOutputDeviceList()) + { + return libjami::getAudioOutputDeviceList(); + } + + void + setAudioOutputDevice(const int32_t& index) + { + libjami::setAudioOutputDevice(index); + } + + void + setAudioInputDevice(const int32_t& index) + { + libjami::setAudioInputDevice(index); + } + + void + setAudioRingtoneDevice(const int32_t& index) + { + libjami::setAudioRingtoneDevice(index); + } + + auto + getAudioInputDeviceList() -> decltype(libjami::getAudioInputDeviceList()) + { + return libjami::getAudioInputDeviceList(); + } + + auto + getCurrentAudioDevicesIndex() + -> decltype(libjami::getCurrentAudioDevicesIndex()) + { + return libjami::getCurrentAudioDevicesIndex(); + } + + auto + getAudioInputDeviceIndex(const std::string& name) + -> decltype(libjami::getAudioInputDeviceIndex(name)) + { + return libjami::getAudioInputDeviceIndex(name); + } + + auto + getAudioOutputDeviceIndex(const std::string& name) + -> decltype(libjami::getAudioOutputDeviceIndex(name)) + { + return libjami::getAudioOutputDeviceIndex(name); + } + + auto + getCurrentAudioOutputPlugin() + -> decltype(libjami::getCurrentAudioOutputPlugin()) + { + return libjami::getCurrentAudioOutputPlugin(); + } + + auto + getNoiseSuppressState() -> decltype(libjami::getNoiseSuppressState()) + { + return libjami::getNoiseSuppressState(); + } + + void + setNoiseSuppressState(const std::string& state) + { + libjami::setNoiseSuppressState(state); + } + + auto + isAgcEnabled() -> decltype(libjami::isAgcEnabled()) + { + return libjami::isAgcEnabled(); + } + + void + setAgcState(const bool& enabled) + { + libjami::setAgcState(enabled); + } + + void + muteDtmf(const bool& mute) + { + libjami::muteDtmf(mute); + } + + auto + isDtmfMuted() -> decltype(libjami::isDtmfMuted()) + { + return libjami::isDtmfMuted(); + } + + auto + isCaptureMuted() -> decltype(libjami::isCaptureMuted()) + { + return libjami::isCaptureMuted(); + } + + void + muteCapture(const bool& mute) + { + libjami::muteCapture(mute); + } + + auto + isPlaybackMuted() -> decltype(libjami::isPlaybackMuted()) + { + return libjami::isPlaybackMuted(); + } + + void + mutePlayback(const bool& mute) + { + libjami::mutePlayback(mute); + } + + auto + isRingtoneMuted() -> decltype(libjami::isRingtoneMuted()) + { + return libjami::isRingtoneMuted(); + } + + void + muteRingtone(const bool& mute) + { + libjami::muteRingtone(mute); + } + + auto + getAudioManager() -> decltype(libjami::getAudioManager()) + { + return libjami::getAudioManager(); + } + + auto + setAudioManager(const std::string& api) + -> decltype(libjami::setAudioManager(api)) + { + return libjami::setAudioManager(api); + } + + auto + getSupportedAudioManagers() + -> decltype(libjami::getSupportedAudioManagers()) + { + return libjami::getSupportedAudioManagers(); + } + + auto + getRecordPath() -> decltype(libjami::getRecordPath()) + { + return libjami::getRecordPath(); + } + + void + setRecordPath(const std::string& recPath) + { + libjami::setRecordPath(recPath); + } + + auto + getIsAlwaysRecording() -> decltype(libjami::getIsAlwaysRecording()) + { + return libjami::getIsAlwaysRecording(); + } + + void + setIsAlwaysRecording(const bool& rec) + { + libjami::setIsAlwaysRecording(rec); + } + + auto + getRecordPreview() -> decltype(libjami::getRecordPreview()) + { + return libjami::getRecordPreview(); + } + + void + setRecordPreview(const bool& rec) + { + libjami::setRecordPreview(rec); + } + + auto + getRecordQuality() -> decltype(libjami::getRecordQuality()) + { + return libjami::getRecordQuality(); + } + + void + setRecordQuality(const int32_t& quality) + { + libjami::setRecordQuality(quality); + } + + void + setHistoryLimit(const int32_t& days) + { + libjami::setHistoryLimit(days); + } + + auto + getHistoryLimit() -> decltype(libjami::getHistoryLimit()) + { + return libjami::getHistoryLimit(); + } + + void + setRingingTimeout(const int32_t& timeout) + { + libjami::setRingingTimeout(timeout); + } + + auto + getRingingTimeout() -> decltype(libjami::getRingingTimeout()) + { + return libjami::getRingingTimeout(); + } + + void + setAccountsOrder(const std::string& order) + { + libjami::setAccountsOrder(order); + } + + auto + validateCertificate(const std::string& accountId, + const std::string& certificate) + -> decltype(libjami::validateCertificate(accountId, certificate)) + { + return libjami::validateCertificate(accountId, certificate); + } + + auto + validateCertificatePath(const std::string& accountId, + const std::string& certificate, + const std::string& privateKey, + const std::string& privateKeyPass, + const std::string& caList) + -> decltype(libjami::validateCertificatePath( + accountId, certificate, privateKey, privateKeyPass, caList)) + { + return libjami::validateCertificatePath(accountId, + certificate, + privateKey, + privateKeyPass, + caList); + } + + auto + getCertificateDetails(const std::string& accountId, + const std::string& certificate) + -> decltype(libjami::getCertificateDetails(accountId, certificate)) + { + return libjami::getCertificateDetails(accountId, certificate); + } + + auto + getCertificateDetailsPath(const std::string& accountId, + const std::string& certificate, + const std::string& privateKey, + const std::string& privateKeyPass) + -> decltype(libjami::getCertificateDetailsPath( + accountId, certificate, privateKey, privateKeyPass)) + { + return libjami::getCertificateDetailsPath(accountId, certificate, privateKey, privateKeyPass); + } + + auto + getPinnedCertificates(const std::string& accountId) + -> decltype(libjami::getPinnedCertificates(accountId)) + { + return libjami::getPinnedCertificates(accountId); + } + + auto + pinCertificate(const std::string& accountId, + const std::vector<uint8_t>& certificate, + const bool& local) + -> decltype(libjami::pinCertificate(accountId, certificate, local)) + { + return libjami::pinCertificate(accountId, certificate, local); + } + + void + pinCertificatePath(const std::string& accountId, const std::string& certPath) + { + libjami::pinCertificatePath(accountId, certPath); + } + + auto + unpinCertificate(const std::string& accountId, const std::string& certId) + -> decltype(libjami::unpinCertificate(accountId, certId)) + { + return libjami::unpinCertificate(accountId, certId); + } + + auto + unpinCertificatePath(const std::string& accountId, + const std::string& p) + -> decltype(libjami::unpinCertificatePath(accountId, p)) + { + return libjami::unpinCertificatePath(accountId, p); + } + + auto + pinRemoteCertificate(const std::string& accountId, + const std::string& certId) + -> decltype(libjami::pinRemoteCertificate(accountId, certId)) + { + return libjami::pinRemoteCertificate(accountId, certId); + } + + auto + setCertificateStatus(const std::string& accountId, + const std::string& certId, + const std::string& status) + -> decltype(libjami::setCertificateStatus(accountId, certId, status)) + { + return libjami::setCertificateStatus(accountId, certId, status); + } + + auto + getCertificatesByStatus(const std::string& accountId, + const std::string& status) + -> decltype(libjami::getCertificatesByStatus(accountId, status)) + { + return libjami::getCertificatesByStatus(accountId, status); + } + + auto + getTrustRequests(const std::string& accountId) + -> decltype(libjami::getTrustRequests(accountId)) + { + return libjami::getTrustRequests(accountId); + } + + auto + acceptTrustRequest(const std::string& accountId, const std::string& from) + -> decltype(libjami::acceptTrustRequest(accountId, from)) + { + return libjami::acceptTrustRequest(accountId, from); + } + + auto + discardTrustRequest(const std::string& accountId, const std::string& from) + -> decltype(libjami::discardTrustRequest(accountId, from)) + { + return libjami::discardTrustRequest(accountId, from); + } + + void + sendTrustRequest(const std::string& accountId, + const std::string& to, + const std::vector<uint8_t>& payload) + { + libjami::sendTrustRequest(accountId, to, payload); + } + + void + addContact(const std::string& accountId, const std::string& uri) + { + libjami::addContact(accountId, uri); + } + + void + removeContact(const std::string& accountId, + const std::string& uri, + const bool& ban) + { + libjami::removeContact(accountId, uri, ban); + } + + auto + getContactDetails(const std::string& accountId, const std::string& uri) + -> decltype(libjami::getContactDetails(accountId, uri)) + { + return libjami::getContactDetails(accountId, uri); + } + + auto + getContacts(const std::string& accountId) + -> decltype(libjami::getContacts(accountId)) + { + return libjami::getContacts(accountId); + } + + auto + getCredentials(const std::string& accountID) + -> decltype(libjami::getCredentials(accountID)) + { + return libjami::getCredentials(accountID); + } + + void + setCredentials( + const std::string& accountID, const std::vector<std::map<std::string, std::string>>& details) + { + libjami::setCredentials(accountID, details); + } + + auto + getAddrFromInterfaceName(const std::string& interface) + -> decltype(libjami::getAddrFromInterfaceName(interface)) + { + return libjami::getAddrFromInterfaceName(interface); + } + + auto + getAllIpInterface() -> decltype(libjami::getAllIpInterface()) + { + return libjami::getAllIpInterface(); + } + + auto + getAllIpInterfaceByName() -> decltype(libjami::getAllIpInterfaceByName()) + { + return libjami::getAllIpInterfaceByName(); + } + + void + setVolume(const std::string& device, const double& value) + { + libjami::setVolume(device, value); + } + + auto + getVolume(const std::string& device) + -> decltype(libjami::getVolume(device)) + { + return libjami::getVolume(device); + } + + void + connectivityChanged() + { + libjami::connectivityChanged(); + } + + void + sendFile(const std::string& accountId, + const std::string& conversationId, + const std::string& path, + const std::string& displayName, + const std::string& replyTo) + { + libjami::sendFile(accountId, conversationId, path, displayName, replyTo); + } + + std::tuple<uint32_t, std::string, int64_t, int64_t> + fileTransferInfo(const std::string& accountId, + const std::string& to, + const std::string& fileId) + { + uint32_t error; + std::string path; + int64_t total; + int64_t progress; + error = (uint32_t) libjami::fileTransferInfo(accountId, to, fileId, path, total, progress); + return {error, path, total, progress}; + } + + bool + downloadFile(const std::string& accountId, + const std::string& conversationUri, + const std::string& interactionId, + const std::string& fileId, + const std::string& path) + { + return libjami::downloadFile(accountId, conversationUri, interactionId, fileId, path); + } + + uint32_t + cancelDataTransfer(const std::string& accountId, + const std::string& conversationId, + const std::string& fileId) + { + return uint32_t(libjami::cancelDataTransfer(accountId, conversationId, fileId)); + } + + std::string + startConversation(const std::string& accountId) + { + return libjami::startConversation(accountId); + } + + void + acceptConversationRequest(const std::string& accountId, + const std::string& conversationId) + { + libjami::acceptConversationRequest(accountId, conversationId); + } + + void + declineConversationRequest(const std::string& accountId, + const std::string& conversationId) + { + libjami::declineConversationRequest(accountId, conversationId); + } + + bool + removeConversation(const std::string& accountId, + const std::string& conversationId) + { + return libjami::removeConversation(accountId, conversationId); + } + + std::vector<std::string> + getConversations(const std::string& accountId) + { + return libjami::getConversations(accountId); + } + + std::vector<std::map<std::string, std::string>> + getActiveCalls(const std::string& accountId, + const std::string& conversationId) + { + return libjami::getActiveCalls(accountId, conversationId); + } + + std::vector<std::map<std::string, std::string>> + getConversationRequests(const std::string& accountId) + { + return libjami::getConversationRequests(accountId); + } + + void + updateConversationInfos(const std::string& accountId, + const std::string& conversationId, + const std::map<std::string, std::string>& infos) + { + libjami::updateConversationInfos(accountId, conversationId, infos); + } + + std::map<std::string, std::string> + conversationInfos(const std::string& accountId, + const std::string& conversationId) + { + return libjami::conversationInfos(accountId, conversationId); + } + + void + setConversationPreferences(const std::string& accountId, + const std::string& conversationId, + const std::map<std::string, std::string>& infos) + { + libjami::setConversationPreferences(accountId, conversationId, infos); + } + + std::map<std::string, std::string> + getConversationPreferences(const std::string& accountId, + const std::string& conversationId) + { + return libjami::getConversationPreferences(accountId, conversationId); + } + + void + addConversationMember(const std::string& accountId, + const std::string& conversationId, + const std::string& contactUri) + { + libjami::addConversationMember(accountId, conversationId, contactUri); + } + + void + removeConversationMember(const std::string& accountId, + const std::string& conversationId, + const std::string& contactUri) + { + libjami::removeConversationMember(accountId, conversationId, contactUri); + } + + std::vector<std::map<std::string, std::string>> + getConversationMembers(const std::string& accountId, + const std::string& conversationId) + { + return libjami::getConversationMembers(accountId, conversationId); + } + + void + sendMessage(const std::string& accountId, + const std::string& conversationId, + const std::string& message, + const std::string& replyTo, + const int32_t& flag) + { + libjami::sendMessage(accountId, conversationId, message, replyTo, flag); + } + + uint32_t + loadConversationMessages(const std::string& accountId, + const std::string& conversationId, + const std::string& fromMessage, + const uint32_t& n) + { + return libjami::loadConversationMessages(accountId, conversationId, fromMessage, n); + } + + uint32_t + loadConversationUntil(const std::string& accountId, + const std::string& conversationId, + const std::string& fromMessage, + const std::string& to) + { + return libjami::loadConversationUntil(accountId, conversationId, fromMessage, to); + } + + uint32_t + countInteractions(const std::string& accountId, + const std::string& conversationId, + const std::string& toId, + const std::string& fromId, + const std::string& authorUri) + { + return libjami::countInteractions(accountId, conversationId, toId, fromId, authorUri); + } + + uint32_t + searchConversation(const std::string& accountId, + const std::string& conversationId, + const std::string& author, + const std::string& lastId, + const std::string& regexSearch, + const std::string& type, + const int64_t& after, + const int64_t& before, + const uint32_t& maxResult, + const int32_t& flag) + { + return libjami::searchConversation(accountId, + conversationId, + author, + lastId, + regexSearch, + type, + after, + before, + maxResult, + flag); + } + + bool + isAudioMeterActive(const std::string& id) + { + return libjami::isAudioMeterActive(id); + } + + void + setAudioMeterState(const std::string& id, const bool& state) + { + return libjami::setAudioMeterState(id, state); + } + + void + setDefaultModerator(const std::string& accountID, + const std::string& peerURI, + const bool& state) + { + libjami::setDefaultModerator(accountID, peerURI, state); + } + + auto + getDefaultModerators(const std::string& accountID) + -> decltype(libjami::getDefaultModerators(accountID)) + { + return libjami::getDefaultModerators(accountID); + } + + void + enableLocalModerators(const std::string& accountID, + const bool& isModEnabled) + { + return libjami::enableLocalModerators(accountID, isModEnabled); + } + + bool + isLocalModeratorsEnabled(const std::string& accountID) + { + return libjami::isLocalModeratorsEnabled(accountID); + } + + void + setAllModerators(const std::string& accountID, const bool& allModerators) + { + return libjami::setAllModerators(accountID, allModerators); + } + + bool + isAllModerators(const std::string& accountID) + { + return libjami::isAllModerators(accountID); + } + +private: + + void + registerSignalHandlers() + { + using namespace std::placeholders; + + using libjami::exportable_callback; + using libjami::ConfigurationSignal; + using libjami::AudioSignal; + using libjami::DataTransferSignal; + using libjami::ConversationSignal; + using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>; + + // Configuration event handlers + const std::map<std::string, SharedCallback> configEvHandlers = { + exportable_callback<ConfigurationSignal::VolumeChanged>( + std::bind(&DBusConfigurationManager::emitVolumeChanged, this, _1, _2)), + exportable_callback<ConfigurationSignal::AccountsChanged>( + std::bind(&DBusConfigurationManager::emitAccountsChanged, this)), + exportable_callback<ConfigurationSignal::AccountDetailsChanged>( + std::bind(&DBusConfigurationManager::emitAccountDetailsChanged, this, _1, _2)), + exportable_callback<ConfigurationSignal::StunStatusFailed>( + std::bind(&DBusConfigurationManager::emitStunStatusFailure, this, _1)), + exportable_callback<ConfigurationSignal::RegistrationStateChanged>( + std::bind(&DBusConfigurationManager::emitRegistrationStateChanged, this, _1, _2, _3, _4)), + exportable_callback<ConfigurationSignal::VolatileDetailsChanged>( + std::bind(&DBusConfigurationManager::emitVolatileAccountDetailsChanged, this, _1, _2)), + exportable_callback<ConfigurationSignal::Error>( + std::bind(&DBusConfigurationManager::emitErrorAlert, this, _1)), + exportable_callback<ConfigurationSignal::IncomingAccountMessage>( + std::bind(&DBusConfigurationManager::emitIncomingAccountMessage, this, _1, _2, _3, _4)), + exportable_callback<ConfigurationSignal::AccountMessageStatusChanged>( + std::bind(&DBusConfigurationManager::emitAccountMessageStatusChanged, this, _1, _2, _3, _4, _5)), + exportable_callback<ConfigurationSignal::ProfileReceived>( + std::bind(&DBusConfigurationManager::emitProfileReceived, this, _1, _2, _3)), + exportable_callback<ConfigurationSignal::ActiveCallsChanged>( + std::bind(&DBusConfigurationManager::emitActiveCallsChanged, this, _1, _2, _3)), + exportable_callback<ConfigurationSignal::ComposingStatusChanged>( + std::bind(&DBusConfigurationManager::emitComposingStatusChanged, this, _1, _2, _3, _4)), + exportable_callback<ConfigurationSignal::IncomingTrustRequest>( + std::bind(&DBusConfigurationManager::emitIncomingTrustRequest, this, _1, _2, _3, _4, _5)), + exportable_callback<ConfigurationSignal::ContactAdded>( + std::bind(&DBusConfigurationManager::emitContactAdded, this, _1, _2, _3)), + exportable_callback<ConfigurationSignal::ContactRemoved>( + std::bind(&DBusConfigurationManager::emitContactRemoved, this, _1, _2, _3)), + exportable_callback<ConfigurationSignal::ExportOnRingEnded>( + std::bind(&DBusConfigurationManager::emitExportOnRingEnded, this, _1, _2, _3)), + exportable_callback<ConfigurationSignal::KnownDevicesChanged>( + std::bind(&DBusConfigurationManager::emitKnownDevicesChanged, this, _1, _2)), + exportable_callback<ConfigurationSignal::NameRegistrationEnded>( + std::bind(&DBusConfigurationManager::emitNameRegistrationEnded, this, _1, _2, _3)), + exportable_callback<ConfigurationSignal::UserSearchEnded>( + std::bind(&DBusConfigurationManager::emitUserSearchEnded, this, _1, _2, _3, _4)), + exportable_callback<ConfigurationSignal::RegisteredNameFound>( + std::bind(&DBusConfigurationManager::emitRegisteredNameFound, this, _1, _2, _3, _4)), + exportable_callback<ConfigurationSignal::DeviceRevocationEnded>( + std::bind(&DBusConfigurationManager::emitDeviceRevocationEnded, this, _1, _2, _3)), + exportable_callback<ConfigurationSignal::AccountProfileReceived>( + std::bind(&DBusConfigurationManager::emitAccountProfileReceived, this, _1, _2, _3)), + exportable_callback<ConfigurationSignal::CertificatePinned>( + std::bind(&DBusConfigurationManager::emitCertificatePinned, this, _1)), + exportable_callback<ConfigurationSignal::CertificatePathPinned>( + std::bind(&DBusConfigurationManager::emitCertificatePathPinned, this, _1, _2)), + exportable_callback<ConfigurationSignal::CertificateExpired>( + std::bind(&DBusConfigurationManager::emitCertificateExpired, this, _1)), + exportable_callback<ConfigurationSignal::CertificateStateChanged>( + std::bind(&DBusConfigurationManager::emitCertificateStateChanged, this, _1, _2, _3)), + exportable_callback<ConfigurationSignal::MediaParametersChanged>( + std::bind(&DBusConfigurationManager::emitMediaParametersChanged, this, _1)), + exportable_callback<ConfigurationSignal::MigrationEnded>( + std::bind(&DBusConfigurationManager::emitMigrationEnded, this, _1, _2)), + exportable_callback<ConfigurationSignal::HardwareDecodingChanged>( + std::bind(&DBusConfigurationManager::emitHardwareDecodingChanged, this, _1)), + exportable_callback<ConfigurationSignal::HardwareEncodingChanged>( + std::bind(&DBusConfigurationManager::emitHardwareEncodingChanged, this, _1)), + exportable_callback<ConfigurationSignal::MessageSend>( + std::bind(&DBusConfigurationManager::emitMessageSend, this, _1)), + }; + + // Audio event handlers + const std::map<std::string, SharedCallback> audioEvHandlers = { + exportable_callback<AudioSignal::DeviceEvent>( + std::bind(&DBusConfigurationManager::emitAudioDeviceEvent, this)), + exportable_callback<AudioSignal::AudioMeter>( + std::bind(&DBusConfigurationManager::emitAudioMeter, this, _1, _2)), + }; + + const std::map<std::string, SharedCallback> dataXferEvHandlers = { + exportable_callback<DataTransferSignal::DataTransferEvent>( + std::bind(&DBusConfigurationManager::emitDataTransferEvent, this, _1, _2, _3, _4, _5)), + }; + + const std::map<std::string, SharedCallback> convEvHandlers = { + exportable_callback<ConversationSignal::ConversationLoaded>( + std::bind(&DBusConfigurationManager::emitConversationLoaded, this, _1, _2, _3, _4)), + exportable_callback<ConversationSignal::MessagesFound>( + std::bind(&DBusConfigurationManager::emitMessagesFound, this, _1, _2, _3, _4)), + exportable_callback<ConversationSignal::MessageReceived>( + std::bind(&DBusConfigurationManager::emitMessageReceived, this, _1, _2, _3)), + exportable_callback<ConversationSignal::ConversationProfileUpdated>( + std::bind(&DBusConfigurationManager::emitConversationProfileUpdated, this, _1, _2, _3)), + exportable_callback<ConversationSignal::ConversationRequestReceived>( + std::bind(&DBusConfigurationManager::emitConversationRequestReceived, this, _1, _2, _3)), + exportable_callback<ConversationSignal::ConversationRequestDeclined>( + std::bind(&DBusConfigurationManager::emitConversationRequestDeclined, this, _1, _2)), + exportable_callback<ConversationSignal::ConversationReady>( + std::bind(&DBusConfigurationManager::emitConversationReady, this, _1, _2)), + exportable_callback<ConversationSignal::ConversationRemoved>( + std::bind(&DBusConfigurationManager::emitConversationRemoved, this, _1, _2)), + exportable_callback<ConversationSignal::ConversationMemberEvent>( + std::bind(&DBusConfigurationManager::emitConversationMemberEvent, this, _1, _2, _3, _4)), + exportable_callback<ConversationSignal::OnConversationError>( + std::bind(&DBusConfigurationManager::emitOnConversationError, this, _1, _2, _3, _4)), + exportable_callback<ConversationSignal::ConversationPreferencesUpdated>( + std::bind(&DBusConfigurationManager::emitConversationPreferencesUpdated, this, _1, _2, _3)), + }; + + libjami::registerSignalHandlers(configEvHandlers); + libjami::registerSignalHandlers(audioEvHandlers); + libjami::registerSignalHandlers(dataXferEvHandlers); + libjami::registerSignalHandlers(convEvHandlers); + } +}; diff --git a/bin/dbus/dbusinstance.h b/bin/dbus/dbusinstance.h deleted file mode 100644 index bf33af7b87f16c0b295e75b641e6636d71c61c76..0000000000000000000000000000000000000000 --- a/bin/dbus/dbusinstance.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __RING_DBUSINSTANCE_H__ -#define __RING_DBUSINSTANCE_H__ - -#include "def.h" - -#include <functional> - -#if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" -#endif -#include "dbus_cpp.h" - -#pragma GCC diagnostic ignored "-Wignored-qualifiers" -#pragma GCC diagnostic ignored "-Wunused-parameter" -#include "dbusinstance.adaptor.h" -#pragma GCC diagnostic warning "-Wignored-qualifiers" -#pragma GCC diagnostic warning "-Wunused-parameter" -#if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) -#pragma GCC diagnostic warning "-Wunused-but-set-variable" -#endif - -class LIBJAMI_PUBLIC DBusInstance : - public cx::ring::Ring::Instance_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor -{ - public: - typedef std::function<void()> OnNoMoreClientFunc; - - DBusInstance(DBus::Connection& connection, - const OnNoMoreClientFunc& onNoMoreClientFunc); - - void Register(const int32_t& pid, const std::string& name); - void Unregister(const int32_t& pid); - - private: - OnNoMoreClientFunc onNoMoreClientFunc_; - int count_; -}; - -#endif // __RING_DBUSINSTANCE_H__ diff --git a/bin/dbus/dbusinstance.cpp b/bin/dbus/dbusinstance.hpp similarity index 50% rename from bin/dbus/dbusinstance.cpp rename to bin/dbus/dbusinstance.hpp index 08da5ccdfb5dc75486bf1efdd42d9eeb8aedb4df..2217fa00974e6070abd254eade9c52df2f9cdd69 100644 --- a/bin/dbus/dbusinstance.cpp +++ b/bin/dbus/dbusinstance.hpp @@ -2,6 +2,7 @@ * Copyright (C) 2004-2023 Savoir-faire Linux Inc. * * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> + * Author: Vladimir Stoiakin <vstoiakin@lavabit.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,29 +19,46 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "dbusinstance.h" +#pragma once -DBusInstance::DBusInstance(DBus::Connection& connection, - const OnNoMoreClientFunc& onNoMoreClientFunc) - : DBus::ObjectAdaptor(connection, "/cx/ring/Ring/Instance") - , onNoMoreClientFunc_(onNoMoreClientFunc) - , count_(0) -{} +#include "dbusinstance.adaptor.h" +#include <sdbus-c++/IConnection.h> +#include <cstdint> +#include <memory> -void -DBusInstance::Register(const int32_t& /*pid*/, - const std::string& /*name*/) +extern bool persistent; +extern std::unique_ptr<sdbus::IConnection> connection; + +class DBusInstance : public sdbus::AdaptorInterfaces<cx::ring::Ring::Instance_adaptor> { - ++count_; -} +public: + DBusInstance(sdbus::IConnection& connection) + : AdaptorInterfaces(connection, "/cx/ring/Ring/Instance") + { + registerAdaptor(); + } + ~DBusInstance() + { + unregisterAdaptor(); + } -void -DBusInstance::Unregister(const int32_t& /*pid*/) -{ - --count_; + void + Register(const int32_t& /*pid*/, const std::string& /*name*/) + { + ++count_; + } + + void + Unregister(const int32_t& /*pid*/) + { + --count_; - if (count_ <= 0 && onNoMoreClientFunc_) { - onNoMoreClientFunc_(); + if (!persistent && count_ <= 0) { + connection->leaveEventLoop(); + } } -} + +private: + int_least16_t count_; +}; diff --git a/bin/dbus/dbuspluginmanagerinterface.cpp b/bin/dbus/dbuspluginmanagerinterface.cpp deleted file mode 100644 index d92a1b0ca9aa491d4d0b0e5b623aa14543dcbc32..0000000000000000000000000000000000000000 --- a/bin/dbus/dbuspluginmanagerinterface.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2020-2023 Savoir-faire Linux Inc. - * - * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "dbuspluginmanagerinterface.h" -#include "plugin_manager_interface.h" - -DBusPluginManagerInterface::DBusPluginManagerInterface(DBus::Connection& connection) - : DBus::ObjectAdaptor(connection, "/cx/ring/Ring/PluginManagerInterface") -{} - -bool -DBusPluginManagerInterface::loadPlugin(const std::string& path) -{ - return libjami::loadPlugin(path); -} - -bool -DBusPluginManagerInterface::unloadPlugin(const std::string& path) -{ - return libjami::unloadPlugin(path); -} - -std::map<std::string, std::string> -DBusPluginManagerInterface::getPluginDetails(const std::string& path) -{ - return libjami::getPluginDetails(path); -} - -std::vector<std::map<std::string, std::string>> -DBusPluginManagerInterface::getPluginPreferences(const std::string& path, - const std::string& accountId) -{ - return libjami::getPluginPreferences(path, accountId); -} - -bool -DBusPluginManagerInterface::setPluginPreference(const std::string& path, - const std::string& accountId, - const std::string& key, - const std::string& value) -{ - return libjami::setPluginPreference(path, accountId, key, value); -} - -std::map<std::string, std::string> -DBusPluginManagerInterface::getPluginPreferencesValues(const std::string& path, - const std::string& accountId) -{ - return libjami::getPluginPreferencesValues(path, accountId); -} - -bool -DBusPluginManagerInterface::resetPluginPreferencesValues(const std::string& path, - const std::string& accountId) -{ - return libjami::resetPluginPreferencesValues(path, accountId); -} - -auto -DBusPluginManagerInterface::getInstalledPlugins() -> decltype(libjami::getInstalledPlugins()) -{ - return libjami::getInstalledPlugins(); -} - -auto -DBusPluginManagerInterface::getLoadedPlugins() -> decltype(libjami::getLoadedPlugins()) -{ - return libjami::getLoadedPlugins(); -} - -int -DBusPluginManagerInterface::installPlugin(const std::string& jplPath, const bool& force) -{ - return libjami::installPlugin(jplPath, force); -} - -int -DBusPluginManagerInterface::uninstallPlugin(const std::string& pluginRootPath) -{ - return libjami::uninstallPlugin(pluginRootPath); -} - -auto -DBusPluginManagerInterface::getCallMediaHandlers() -> decltype(libjami::getCallMediaHandlers()) -{ - return libjami::getCallMediaHandlers(); -} - -auto -DBusPluginManagerInterface::getChatHandlers() -> decltype(libjami::getChatHandlers()) -{ - return libjami::getChatHandlers(); -} -void -DBusPluginManagerInterface::toggleCallMediaHandler(const std::string& mediaHandlerId, - const std::string& callId, - const bool& toggle) -{ - libjami::toggleCallMediaHandler(mediaHandlerId, callId, toggle); -} - -void -DBusPluginManagerInterface::toggleChatHandler(const std::string& chatHandlerId, - const std::string& accountId, - const std::string& peerId, - const bool& toggle) -{ - libjami::toggleChatHandler(chatHandlerId, accountId, peerId, toggle); -} - -std::map<std::string, std::string> -DBusPluginManagerInterface::getCallMediaHandlerDetails(const std::string& mediaHanlderId) -{ - return libjami::getCallMediaHandlerDetails(mediaHanlderId); -} - -std::vector<std::string> -DBusPluginManagerInterface::getCallMediaHandlerStatus(const std::string& callId) -{ - return libjami::getCallMediaHandlerStatus(callId); -} - -std::map<std::string, std::string> -DBusPluginManagerInterface::getChatHandlerDetails(const std::string& chatHanlderId) -{ - return libjami::getChatHandlerDetails(chatHanlderId); -} - -std::vector<std::string> -DBusPluginManagerInterface::getChatHandlerStatus(const std::string& accountId, - const std::string& peerId) -{ - return libjami::getChatHandlerStatus(accountId, peerId); -} - -bool -DBusPluginManagerInterface::getPluginsEnabled() -{ - return libjami::getPluginsEnabled(); -} - -void -DBusPluginManagerInterface::setPluginsEnabled(const bool& state) -{ - libjami::setPluginsEnabled(state); -} - -void -DBusPluginManagerInterface::sendWebViewMessage(const std::string& pluginId, - const std::string& webViewId, - const std::string& messageId, - const std::string& payload) -{ - libjami::sendWebViewAttach(pluginId, webViewId, messageId, payload); -} - -std::string -DBusPluginManagerInterface::sendWebViewAttach(const std::string& pluginId, - const std::string& accountId, - const std::string& webViewId, - const std::string& action) -{ - return libjami::sendWebViewAttach(pluginId, accountId, webViewId, action); -} - -void -DBusPluginManagerInterface::sendWebViewDetach(const std::string& pluginId, - const std::string& webViewId) -{ - libjami::sendWebViewDetach(pluginId, webViewId); -} diff --git a/bin/dbus/dbuspluginmanagerinterface.h b/bin/dbus/dbuspluginmanagerinterface.h deleted file mode 100644 index 89c683a59ee14be7bf5f8d857f98dfe3aa4e3711..0000000000000000000000000000000000000000 --- a/bin/dbus/dbuspluginmanagerinterface.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2020-2023 Savoir-faire Linux Inc. - * - * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include <vector> -#include <map> -#include <string> - -#include "def.h" -#include "dbus_cpp.h" - -#if __GNUC__ >= 5 || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" -#endif - -#pragma GCC diagnostic ignored "-Wignored-qualifiers" -#pragma GCC diagnostic ignored "-Wunused-parameter" -#include "dbuspluginmanagerinterface.adaptor.h" -#pragma GCC diagnostic warning "-Wignored-qualifiers" -#pragma GCC diagnostic warning "-Wunused-parameter" - -#if __GNUC__ >= 5 || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic warning "-Wunused-but-set-variable" -#endif - -class LIBJAMI_PUBLIC DBusPluginManagerInterface - : public cx::ring::Ring::PluginManagerInterface_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor -{ -public: - DBusPluginManagerInterface(DBus::Connection& connection); - - // Methods - bool loadPlugin(const std::string& path); - bool unloadPlugin(const std::string& path); - std::map<std::string, std::string> getPluginDetails(const std::string& path); - std::vector<std::map<std::string, std::string>> getPluginPreferences( - const std::string& path, const std::string& accountId); - bool setPluginPreference(const std::string& path, - const std::string& accountId, - const std::string& key, - const std::string& value); - std::map<std::string, std::string> getPluginPreferencesValues(const std::string& path, - const std::string& accountId); - bool resetPluginPreferencesValues(const std::string& path, const std::string& accountId); - std::vector<std::string> getInstalledPlugins(); - std::vector<std::string> getLoadedPlugins(); - int installPlugin(const std::string& jplPath, const bool& force); - int uninstallPlugin(const std::string& pluginRootPath); - std::vector<std::string> getCallMediaHandlers(); - std::vector<std::string> getChatHandlers(); - void toggleCallMediaHandler(const std::string& mediaHandlerId, - const std::string& callId, - const bool& toggle); - void toggleChatHandler(const std::string& chatHandlerId, - const std::string& accountId, - const std::string& peerId, - const bool& toggle); - std::map<std::string, std::string> getCallMediaHandlerDetails(const std::string& mediaHandlerId); - std::vector<std::string> getCallMediaHandlerStatus(const std::string& callId); - std::map<std::string, std::string> getChatHandlerDetails(const std::string& chatHandlerId); - std::vector<std::string> getChatHandlerStatus(const std::string& accontId, - const std::string& peerId); - - bool getPluginsEnabled(); - void setPluginsEnabled(const bool& state); - - void sendWebViewMessage(const std::string& pluginId, - const std::string& webViewId, - const std::string& messageId, - const std::string& payload); - - std::string sendWebViewAttach(const std::string& pluginId, - const std::string& accountId, - const std::string& webViewId, - const std::string& action); - - void sendWebViewDetach(const std::string& pluginId, const std::string& webViewId); -}; diff --git a/bin/dbus/dbuspluginmanagerinterface.hpp b/bin/dbus/dbuspluginmanagerinterface.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8fed62b1793e517d234009ca4de95f1fc70c7132 --- /dev/null +++ b/bin/dbus/dbuspluginmanagerinterface.hpp @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2020-2023 Savoir-faire Linux Inc. + * + * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> + * Author: Vladimir Stoiakin <vstoiakin@lavabit.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include "dbuspluginmanagerinterface.adaptor.h" +#include <plugin_manager_interface.h> + +class DBusPluginManagerInterface : public sdbus::AdaptorInterfaces<cx::ring::Ring::PluginManagerInterface_adaptor> +{ +public: + DBusPluginManagerInterface(sdbus::IConnection& connection) + : AdaptorInterfaces(connection, "/cx/ring/Ring/PluginManagerInterface") + { + registerAdaptor(); + registerSignalHandlers(); + } + + ~DBusPluginManagerInterface() + { + unregisterAdaptor(); + } + + bool + loadPlugin(const std::string& path) + { + return libjami::loadPlugin(path); + } + + bool + unloadPlugin(const std::string& path) + { + return libjami::unloadPlugin(path); + } + + std::map<std::string, std::string> + getPluginDetails(const std::string& path) + { + return libjami::getPluginDetails(path); + } + + std::vector<std::map<std::string, std::string>> + getPluginPreferences(const std::string& path, + const std::string& accountId) + { + return libjami::getPluginPreferences(path, accountId); + } + + bool + setPluginPreference(const std::string& path, + const std::string& accountId, + const std::string& key, + const std::string& value) + { + return libjami::setPluginPreference(path, accountId, key, value); + } + + std::map<std::string, std::string> + getPluginPreferencesValues(const std::string& path, + const std::string& accountId) + { + return libjami::getPluginPreferencesValues(path, accountId); + } + + bool + resetPluginPreferencesValues(const std::string& path, + const std::string& accountId) + { + return libjami::resetPluginPreferencesValues(path, accountId); + } + + auto + getInstalledPlugins() -> decltype(libjami::getInstalledPlugins()) + { + return libjami::getInstalledPlugins(); + } + + auto + getLoadedPlugins() -> decltype(libjami::getLoadedPlugins()) + { + return libjami::getLoadedPlugins(); + } + + int + installPlugin(const std::string& jplPath, const bool& force) + { + return libjami::installPlugin(jplPath, force); + } + + int + uninstallPlugin(const std::string& pluginRootPath) + { + return libjami::uninstallPlugin(pluginRootPath); + } + + auto + getCallMediaHandlers() -> decltype(libjami::getCallMediaHandlers()) + { + return libjami::getCallMediaHandlers(); + } + + auto + getChatHandlers() -> decltype(libjami::getChatHandlers()) + { + return libjami::getChatHandlers(); + } + void + toggleCallMediaHandler(const std::string& mediaHandlerId, + const std::string& callId, + const bool& toggle) + { + libjami::toggleCallMediaHandler(mediaHandlerId, callId, toggle); + } + + void + toggleChatHandler(const std::string& chatHandlerId, + const std::string& accountId, + const std::string& peerId, + const bool& toggle) + { + libjami::toggleChatHandler(chatHandlerId, accountId, peerId, toggle); + } + + std::map<std::string, std::string> + getCallMediaHandlerDetails(const std::string& mediaHanlderId) + { + return libjami::getCallMediaHandlerDetails(mediaHanlderId); + } + + std::vector<std::string> + getCallMediaHandlerStatus(const std::string& callId) + { + return libjami::getCallMediaHandlerStatus(callId); + } + + std::map<std::string, std::string> + getChatHandlerDetails(const std::string& chatHanlderId) + { + return libjami::getChatHandlerDetails(chatHanlderId); + } + + std::vector<std::string> + getChatHandlerStatus(const std::string& accountId, + const std::string& peerId) + { + return libjami::getChatHandlerStatus(accountId, peerId); + } + + bool + getPluginsEnabled() + { + return libjami::getPluginsEnabled(); + } + + void + setPluginsEnabled(const bool& state) + { + libjami::setPluginsEnabled(state); + } + + void + sendWebViewMessage(const std::string& pluginId, + const std::string& webViewId, + const std::string& messageId, + const std::string& payload) + { + libjami::sendWebViewAttach(pluginId, webViewId, messageId, payload); + } + + std::string + sendWebViewAttach(const std::string& pluginId, + const std::string& accountId, + const std::string& webViewId, + const std::string& action) + { + return libjami::sendWebViewAttach(pluginId, accountId, webViewId, action); + } + + void + sendWebViewDetach(const std::string& pluginId, + const std::string& webViewId) + { + libjami::sendWebViewDetach(pluginId, webViewId); + } + +private: + + void + registerSignalHandlers() + { + using namespace std::placeholders; + + using libjami::exportable_callback; + using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>; + + const std::map<std::string, SharedCallback> pluginEvHandlers = { + exportable_callback<libjami::PluginSignal::WebViewMessageReceived>( + std::bind(&DBusPluginManagerInterface::emitWebViewMessageReceived, this, _1, _2, _3, _4)), + }; + + libjami::registerSignalHandlers(pluginEvHandlers); + } + +}; diff --git a/bin/dbus/dbuspresencemanager.cpp b/bin/dbus/dbuspresencemanager.cpp deleted file mode 100644 index 3354287264ee625969635546e0bc3bb805767b4b..0000000000000000000000000000000000000000 --- a/bin/dbus/dbuspresencemanager.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "dbuspresencemanager.h" -#include "presencemanager_interface.h" - -DBusPresenceManager::DBusPresenceManager(DBus::Connection& connection) - : DBus::ObjectAdaptor(connection, "/cx/ring/Ring/PresenceManager") -{} - -void -DBusPresenceManager::publish(const std::string& accountID, const bool& status, const std::string& note) -{ - libjami::publish(accountID, status, note); -} - -void -DBusPresenceManager::answerServerRequest(const std::string& uri, const bool& flag) -{ - libjami::answerServerRequest(uri, flag); -} - -void -DBusPresenceManager::subscribeBuddy(const std::string& accountID, const std::string& uri, const bool& flag) -{ - libjami::subscribeBuddy(accountID, uri, flag); -} - -auto -DBusPresenceManager::getSubscriptions(const std::string& accountID) -> decltype(libjami::getSubscriptions(accountID)) -{ - return libjami::getSubscriptions(accountID); -} - -void -DBusPresenceManager::setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris) -{ - libjami::setSubscriptions(accountID, uris); -} diff --git a/bin/dbus/dbuspresencemanager.h b/bin/dbus/dbuspresencemanager.h deleted file mode 100644 index 7e13e7e9760923dfe214dad116d60366e5dad319..0000000000000000000000000000000000000000 --- a/bin/dbus/dbuspresencemanager.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Patrick Keroulas <patrick.keroulas@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __RING_DBUSPRESENCEMANAGER_H__ -#define __RING_DBUSPRESENCEMANAGER_H__ - -#include <vector> -#include <map> -#include <string> - -#include "def.h" -#include "dbus_cpp.h" - -#if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" -#endif - -#pragma GCC diagnostic ignored "-Wignored-qualifiers" -#pragma GCC diagnostic ignored "-Wunused-parameter" -#include "dbuspresencemanager.adaptor.h" -#pragma GCC diagnostic warning "-Wignored-qualifiers" -#pragma GCC diagnostic warning "-Wunused-parameter" - -#if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic warning "-Wunused-but-set-variable" -#endif - -class LIBJAMI_PUBLIC DBusPresenceManager : - public cx::ring::Ring::PresenceManager_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor -{ - public: - DBusPresenceManager(DBus::Connection& connection); - - // Methods - void publish(const std::string& accountID, const bool& status, const std::string& note); - void answerServerRequest(const std::string& uri, const bool& flag); - void subscribeBuddy(const std::string& accountID, const std::string& uri, const bool& flag); - std::vector<std::map<std::string, std::string>> getSubscriptions(const std::string& accountID); - void setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris); -}; - -#endif // __RING_DBUSPRESENCEMANAGER_H__ diff --git a/bin/dbus/dbuspresencemanager.hpp b/bin/dbus/dbuspresencemanager.hpp new file mode 100644 index 0000000000000000000000000000000000000000..53427fcf6e3ef3b818249f50e7210a28132e8c0b --- /dev/null +++ b/bin/dbus/dbuspresencemanager.hpp @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2004-2023 Savoir-faire Linux Inc. + * + * Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com> + * Author: Vladimir Stoiakin <vstoiakin@lavabit.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include "dbuspresencemanager.adaptor.h" +#include <presencemanager_interface.h> + +class DBusPresenceManager : public sdbus::AdaptorInterfaces<cx::ring::Ring::PresenceManager_adaptor> +{ +public: + DBusPresenceManager(sdbus::IConnection& connection) + : AdaptorInterfaces(connection, "/cx/ring/Ring/PresenceManager") + { + registerAdaptor(); + registerSignalHandlers(); + } + + ~DBusPresenceManager() + { + unregisterAdaptor(); + } + + void + publish(const std::string& accountID, const bool& status, const std::string& note) + { + libjami::publish(accountID, status, note); + } + + void + answerServerRequest(const std::string& uri, const bool& flag) + { + libjami::answerServerRequest(uri, flag); + } + + void + subscribeBuddy(const std::string& accountID, const std::string& uri, const bool& flag) + { + libjami::subscribeBuddy(accountID, uri, flag); + } + + auto + getSubscriptions(const std::string& accountID) -> decltype(libjami::getSubscriptions(accountID)) + { + return libjami::getSubscriptions(accountID); + } + + void + setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris) + { + libjami::setSubscriptions(accountID, uris); + } + +private: + + void + registerSignalHandlers() + { + using namespace std::placeholders; + + using libjami::exportable_callback; + using libjami::PresenceSignal; + using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>; + + const std::map<std::string, SharedCallback> presEvHandlers = { + exportable_callback<PresenceSignal::NewServerSubscriptionRequest>( + std::bind(&DBusPresenceManager::emitNewServerSubscriptionRequest, this, _1)), + exportable_callback<PresenceSignal::ServerError>( + std::bind(&DBusPresenceManager::emitServerError, this, _1, _2, _3)), + exportable_callback<PresenceSignal::NewBuddyNotification>( + std::bind(&DBusPresenceManager::emitNewBuddyNotification, this, _1, _2, _3, _4)), + exportable_callback<PresenceSignal::NearbyPeerNotification>( + std::bind(&DBusPresenceManager::emitNearbyPeerNotification, this, _1, _2, _3, _4)), + exportable_callback<PresenceSignal::SubscriptionStateChanged>( + std::bind(&DBusPresenceManager::emitSubscriptionStateChanged, this, _1, _2, _3)), + }; + + libjami::registerSignalHandlers(presEvHandlers); + } +}; diff --git a/bin/dbus/dbusvideomanager.cpp b/bin/dbus/dbusvideomanager.cpp deleted file mode 100644 index 60d85bb0cf98ec6ff34a399f0060bd507fc4cb26..0000000000000000000000000000000000000000 --- a/bin/dbus/dbusvideomanager.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "dbusvideomanager.h" -#include "videomanager_interface.h" - -DBusVideoManager::DBusVideoManager(DBus::Connection& connection) - : DBus::ObjectAdaptor(connection, "/cx/ring/Ring/VideoManager") -{} - -auto -DBusVideoManager::getDeviceList() -> decltype(libjami::getDeviceList()) -{ - return libjami::getDeviceList(); -} - -auto -DBusVideoManager::getCapabilities(const std::string& deviceId) -> decltype(libjami::getCapabilities(deviceId)) -{ - return libjami::getCapabilities(deviceId); -} - -auto -DBusVideoManager::getSettings(const std::string& deviceId) -> decltype(libjami::getSettings(deviceId)) -{ - return libjami::getSettings(deviceId); -} - -void -DBusVideoManager::applySettings(const std::string& deviceId, const std::map<std::string, std::string>& settings) -{ - libjami::applySettings(deviceId, settings); -} - -void -DBusVideoManager::setDefaultDevice(const std::string& deviceId) -{ - libjami::setDefaultDevice(deviceId); -} - -auto -DBusVideoManager::getDefaultDevice() -> decltype(libjami::getDefaultDevice()) -{ - return libjami::getDefaultDevice(); -} - -void -DBusVideoManager::startAudioDevice() -{ - libjami::startAudioDevice(); -} - -void -DBusVideoManager::stopAudioDevice() -{ - libjami::stopAudioDevice(); -} - -std::string -DBusVideoManager::openVideoInput(const std::string& inputUri) { - return libjami::openVideoInput(inputUri); -} - -bool -DBusVideoManager::closeVideoInput(const std::string& inputId) { - return libjami::closeVideoInput(inputId); -} - -auto -DBusVideoManager::getDecodingAccelerated() -> decltype(libjami::getDecodingAccelerated()) -{ - return libjami::getDecodingAccelerated(); -} - -void -DBusVideoManager::setDecodingAccelerated(const bool& state) -{ - libjami::setDecodingAccelerated(state); -} - -auto -DBusVideoManager::getEncodingAccelerated() -> decltype(libjami::getEncodingAccelerated()) -{ - return libjami::getEncodingAccelerated(); -} - -void -DBusVideoManager::setEncodingAccelerated(const bool& state) -{ - libjami::setEncodingAccelerated(state); -} - -void -DBusVideoManager::setDeviceOrientation(const std::string& deviceId, const int& angle) -{ - libjami::setDeviceOrientation(deviceId, angle); -} - -void -DBusVideoManager::startShmSink(const std::string& sinkId, const bool& value) -{ - libjami::startShmSink(sinkId, value); -} - -std::map<std::string, std::string> -DBusVideoManager::getRenderer(const std::string& callId) -{ - return libjami::getRenderer(callId); -} - -std::string -DBusVideoManager::startLocalMediaRecorder(const std::string& videoInputId, const std::string& filepath) -{ - return libjami::startLocalMediaRecorder(videoInputId, filepath); -} - -void -DBusVideoManager::stopLocalRecorder(const std::string& filepath) -{ - libjami::stopLocalRecorder(filepath); -} diff --git a/bin/dbus/dbusvideomanager.h b/bin/dbus/dbusvideomanager.h deleted file mode 100644 index 681e2c29a591395c4fe383d3e15f17926ab86799..0000000000000000000000000000000000000000 --- a/bin/dbus/dbusvideomanager.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __RING_DBUSVIDEOMANAGER_H__ -#define __RING_DBUSVIDEOMANAGER_H__ - -#include <vector> -#include <map> -#include <string> - -#include "def.h" -#include "dbus_cpp.h" - -#if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" -#endif - -#pragma GCC diagnostic ignored "-Wignored-qualifiers" -#pragma GCC diagnostic ignored "-Wunused-parameter" -#include "dbusvideomanager.adaptor.h" -#pragma GCC diagnostic warning "-Wignored-qualifiers" -#pragma GCC diagnostic warning "-Wunused-parameter" - -#if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6) -/* This warning option only exists for gcc 4.6.0 and greater. */ -#pragma GCC diagnostic warning "-Wunused-but-set-variable" -#endif - -class LIBJAMI_PUBLIC DBusVideoManager : - public cx::ring::Ring::VideoManager_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::ObjectAdaptor -{ - public: - DBusVideoManager(DBus::Connection& connection); - - // Methods - std::vector<std::string> getDeviceList(); - std::map<std::string, std::map<std::string, std::vector<std::string>>> getCapabilities(const std::string& deviceId); - std::map<std::string, std::string> getSettings(const std::string& deviceId); - void applySettings(const std::string& deviceId, const std::map<std::string, std::string>& settings); - void setDefaultDevice(const std::string& deviceId); - std::string getDefaultDevice(); - void startAudioDevice(); - void stopAudioDevice(); - bool getDecodingAccelerated(); - void setDecodingAccelerated(const bool& state); - bool getEncodingAccelerated(); - void setEncodingAccelerated(const bool& state); - void setDeviceOrientation(const std::string& deviceId, const int& angle); - void startShmSink(const std::string& sinkId, const bool& value); - std::map<std::string, std::string> getRenderer(const std::string& callId); - std::string startLocalMediaRecorder(const std::string& videoInputId, const std::string& filepath); - void stopLocalRecorder(const std::string& filepath); - std::string openVideoInput(const std::string& inputUri); - bool closeVideoInput(const std::string& inputId); -}; - -#endif // __RING_DBUSVIDEOMANAGER_H__ diff --git a/bin/dbus/dbusvideomanager.hpp b/bin/dbus/dbusvideomanager.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f420bfcd6e692a6faec547bd2a71ab7490991107 --- /dev/null +++ b/bin/dbus/dbusvideomanager.hpp @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2004-2023 Savoir-faire Linux Inc. + * + * Author: Philippe Proulx <philippe.proulx@savoirfairelinux.com> + * Author: Vladimir Stoiakin <vstoiakin@lavabit.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include "dbusvideomanager.adaptor.h" +#include <videomanager_interface.h> + +class DBusVideoManager : public sdbus::AdaptorInterfaces<cx::ring::Ring::VideoManager_adaptor> +{ +public: + DBusVideoManager(sdbus::IConnection& connection) + : AdaptorInterfaces(connection, "/cx/ring/Ring/VideoManager") + { + registerAdaptor(); + registerSignalHandlers(); + } + + ~DBusVideoManager() + { + unregisterAdaptor(); + } + + auto + getDeviceList() -> decltype(libjami::getDeviceList()) + { + return libjami::getDeviceList(); + } + + auto + getCapabilities(const std::string& deviceId) -> decltype(libjami::getCapabilities(deviceId)) + { + return libjami::getCapabilities(deviceId); + } + + auto + getSettings(const std::string& deviceId) -> decltype(libjami::getSettings(deviceId)) + { + return libjami::getSettings(deviceId); + } + + void + applySettings(const std::string& deviceId, const std::map<std::string, std::string>& settings) + { + libjami::applySettings(deviceId, settings); + } + + void + setDefaultDevice(const std::string& deviceId) + { + libjami::setDefaultDevice(deviceId); + } + + auto + getDefaultDevice() -> decltype(libjami::getDefaultDevice()) + { + return libjami::getDefaultDevice(); + } + + void + startAudioDevice() + { + libjami::startAudioDevice(); + } + + void + stopAudioDevice() + { + libjami::stopAudioDevice(); + } + + std::string + openVideoInput(const std::string& inputUri) { + return libjami::openVideoInput(inputUri); + } + + bool + closeVideoInput(const std::string& inputId) { + return libjami::closeVideoInput(inputId); + } + + auto + getDecodingAccelerated() -> decltype(libjami::getDecodingAccelerated()) + { + return libjami::getDecodingAccelerated(); + } + + void + setDecodingAccelerated(const bool& state) + { + libjami::setDecodingAccelerated(state); + } + + auto + getEncodingAccelerated() -> decltype(libjami::getEncodingAccelerated()) + { + return libjami::getEncodingAccelerated(); + } + + void + setEncodingAccelerated(const bool& state) + { + libjami::setEncodingAccelerated(state); + } + + void + setDeviceOrientation(const std::string& deviceId, const int& angle) + { + libjami::setDeviceOrientation(deviceId, angle); + } + + void + startShmSink(const std::string& sinkId, const bool& value) + { + libjami::startShmSink(sinkId, value); + } + + std::map<std::string, std::string> + getRenderer(const std::string& callId) + { + return libjami::getRenderer(callId); + } + + std::string + startLocalMediaRecorder(const std::string& videoInputId, const std::string& filepath) + { + return libjami::startLocalMediaRecorder(videoInputId, filepath); + } + + void + stopLocalRecorder(const std::string& filepath) + { + libjami::stopLocalRecorder(filepath); + } + +private: + + void + registerSignalHandlers() + { + using namespace std::placeholders; + + using libjami::exportable_callback; + using libjami::VideoSignal; + using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>; + + const std::map<std::string, SharedCallback> videoEvHandlers = { + exportable_callback<VideoSignal::DeviceEvent>( + std::bind(&DBusVideoManager::emitDeviceEvent, this)), + exportable_callback<VideoSignal::DecodingStarted>( + std::bind(&DBusVideoManager::emitDecodingStarted, this, _1, _2, _3, _4, _5)), + exportable_callback<VideoSignal::DecodingStopped>( + std::bind(&DBusVideoManager::emitDecodingStopped, this, _1, _2, _3)), + }; + + libjami::registerSignalHandlers(videoEvHandlers); + } +}; diff --git a/bin/dbus/main.cpp b/bin/dbus/main.cpp index 398ae9218e20805b1131e0b247097a5bf1ab3dd5..f75f64db42018caa4f9688ff94884dc0fa7b6c8f 100644 --- a/bin/dbus/main.cpp +++ b/bin/dbus/main.cpp @@ -5,6 +5,7 @@ * Author: Yan Morin <yan.morin@savoirfairelinux.com> * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> * Author: Simon Zeni <simon.zeni@savoirfairelinux.com> + * Author: Vladimir Stoiakin <vstoiakin@lavabit.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,20 +22,34 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "dbusclient.h" -#include "jami.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#include <signal.h> -#include <getopt.h> +#include "dbuscallmanager.hpp" +#include "dbusconfigurationmanager.hpp" +#include "dbusinstance.hpp" +#include "dbuspresencemanager.hpp" +#ifdef ENABLE_VIDEO +#include "dbusvideomanager.hpp" +#endif +#ifdef ENABLE_PLUGIN +#include "dbuspluginmanagerinterface.hpp" +#endif + +#include <sdbus-c++/sdbus-c++.h> +#include <jami.h> +#include <string.h> +#include <csignal> +#include <getopt.h> #include <iostream> -#include <thread> #include <memory> -#include <cstring> -#include <cstdlib> + +bool persistent = false; +std::unique_ptr<sdbus::IConnection> connection; static int ringFlags = 0; -static std::weak_ptr<DBusClient> weakClient; static void print_title() @@ -67,7 +82,7 @@ print_usage() // message accordingly. // returns true if we should quit (i.e. help was printed), false otherwise static bool -parse_args(int argc, char *argv[], bool& persistent) +parse_args(int argc, char *argv[]) { int consoleFlag = false; int debugFlag = false; @@ -148,17 +163,15 @@ parse_args(int argc, char *argv[], bool& persistent) static void signal_handler(int code) { - std::cerr << "Caught signal " << strsignal(code) - << ", terminating..." << std::endl; - // Unset signal handlers - signal(SIGHUP, SIG_DFL); signal(SIGINT, SIG_DFL); + signal(SIGHUP, SIG_DFL); signal(SIGTERM, SIG_DFL); - // Interrupt the process - if (auto client = weakClient.lock()) - client->exit(); + std::cerr << "Caught signal " << strsignal(code) + << ", terminating..." << std::endl; + + connection->leaveEventLoop(); } int @@ -166,25 +179,49 @@ main(int argc, char *argv []) { print_title(); - bool persistent = false; - if (parse_args(argc, argv, persistent)) + if (parse_args(argc, argv)) return 0; - // TODO: Block signals for all threads but the main thread, decide how/if we should - // handle other signals - signal(SIGINT, signal_handler); - signal(SIGHUP, signal_handler); - signal(SIGTERM, signal_handler); - signal(SIGPIPE, SIG_IGN); + if (!libjami::init(static_cast<libjami::InitFlag>(ringFlags))) { + std::cerr << "libjami::init() failed" << std::endl; + return 1; + } try { - if (auto client = std::make_shared<DBusClient>(ringFlags, persistent)) - { - weakClient = client; - return client->event_loop(); + connection = sdbus::createSessionBusConnection("cx.ring.Ring"); + DBusCallManager callManager(*connection); + DBusConfigurationManager configurationManager(*connection); + DBusInstance instanceManager(*connection); + DBusPresenceManager presenceManager(*connection); +#ifdef ENABLE_VIDEO + DBusVideoManager videoManager(*connection); +#endif +#ifdef ENABLE_PLUGIN + DBusPluginManagerInterface pluginManager(*connection); +#endif + + if (!libjami::start()) { + std::cerr << "libjami::start() failed" << std::endl; + libjami::unregisterSignalHandlers(); + libjami::fini(); + return 2; } - } catch (const std::exception& ex) { - std::cerr << "Exception in the DBusClient: " << ex.what() << std::endl; + + // TODO: Block signals for all threads but the main thread, decide how/if we should + // handle other signals + std::signal(SIGINT, signal_handler); + std::signal(SIGHUP, signal_handler); + std::signal(SIGTERM, signal_handler); + std::signal(SIGPIPE, SIG_IGN); + + connection->enterEventLoop(); + + libjami::unregisterSignalHandlers(); + + } catch (const sdbus::Error& ex) { + std::cerr << "sdbus exception: " << ex.what() << std::endl; } - return 1; + + libjami::fini(); + return 0; } diff --git a/bin/dbus/meson.build b/bin/dbus/meson.build index bb3120fef7f01fe1e327859863b3f88a2e8bc1d0..7d17d6f1ddd814eb53f373118a6af73e89f0b981 100644 --- a/bin/dbus/meson.build +++ b/bin/dbus/meson.build @@ -3,55 +3,48 @@ jamid_includedirs = include_directories( ) jamid_sources = files( - 'dbuscallmanager.cpp', - 'dbusclient.cpp', - 'dbusconfigurationmanager.cpp', - 'dbusinstance.cpp', - 'dbuspresencemanager.cpp', 'main.cpp' ) jamid_targets = [] jamid_targets += custom_target('callmanager.adaptor', - command: [progdbusxxxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], + command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], input: 'cx.ring.Ring.CallManager.xml', output: 'dbuscallmanager.adaptor.h' ) jamid_targets += custom_target('configurationmanager.adaptor', - command: [progdbusxxxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], + command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], input: 'cx.ring.Ring.ConfigurationManager.xml', output: 'dbusconfigurationmanager.adaptor.h' ) jamid_targets += custom_target('instance.adaptor', - command: [progdbusxxxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], + command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], input: 'cx.ring.Ring.Instance.xml', output: 'dbusinstance.adaptor.h' ) jamid_targets += custom_target('presencemanager.adaptor', - command: [progdbusxxxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], + command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], input: 'cx.ring.Ring.PresenceManager.xml', output: 'dbuspresencemanager.adaptor.h' ) if conf.get('ENABLE_VIDEO') jamid_targets += custom_target('videomanager.adaptor', - command: [progdbusxxxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], + command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], input: 'cx.ring.Ring.VideoManager.xml', output: 'dbusvideomanager.adaptor.h' ) - jamid_sources += files('dbusvideomanager.cpp') endif if conf.get('ENABLE_PLUGIN') jamid_targets += custom_target('pluginmanagerinterface.adaptor', - command: [progdbusxxxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], + command: [progsdbuscppxml2cpp, '@INPUT@', '--adaptor=@OUTPUT@'], input: 'cx.ring.Ring.PluginManagerInterface.xml', output: 'dbuspluginmanagerinterface.adaptor.h' ) - jamid_sources += files('dbuspluginmanagerinterface.cpp') endif if progpod2man.found() @@ -68,13 +61,13 @@ jamid = executable('jamid', jamid_targets, include_directories: jamid_includedirs, sources: jamid_sources, - dependencies: [depdbuscpp, depjami], + dependencies: [depsdbuscpp, depjami], install: true, - install_dir: get_option('libdir') + install_dir: get_option('libexecdir') ) configure_file( - configuration: {'LIBDIR': get_option('prefix') / get_option('libdir')}, + configuration: {'LIBEXECDIR': get_option('prefix') / get_option('libexecdir')}, input: 'net.jami.daemon.service.in', output: 'cx.ring.Ring.service', install: true, diff --git a/bin/dbus/net.jami.daemon.service.in b/bin/dbus/net.jami.daemon.service.in index 8e79e23e920d618f04b7eab6d5d832123109ad3d..7fe9ceacb4a0ac4b3abd08af6304033b396b8521 100644 --- a/bin/dbus/net.jami.daemon.service.in +++ b/bin/dbus/net.jami.daemon.service.in @@ -1,3 +1,3 @@ [D-BUS Service] Name=cx.ring.Ring -Exec=@LIBDIR@/jamid +Exec=@LIBEXECDIR@/jamid diff --git a/bin/main.cpp b/bin/main.cpp deleted file mode 100644 index b29f0e8b95d86c603b6ce5912081e5434b78b63f..0000000000000000000000000000000000000000 --- a/bin/main.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (C) 2004-2023 Savoir-faire Linux Inc. - * - * Author: Alexandre Bourget <alexandre.bourget@savoirfairelinux.com> - * Author: Yan Morin <yan.morin@savoirfairelinux.com> - * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> - * Author: Simon Zeni <simon.zeni@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "jami.h" - -#if REST_API -#include "restcpp/restclient.h" -#else -#include "dbus/dbusclient.h" -#endif - -#include "fileutils.h" - -#include <signal.h> -#include <getopt.h> - -#include <iostream> -#include <thread> -#include <memory> -#include <cstring> -#include <cstdlib> - -static int ringFlags = 0; -static int port = 8080; - -#if REST_API -static std::weak_ptr<RestClient> weakClient; -#else -static std::weak_ptr<DBusClient> weakClient; -#endif - -static void -print_title() -{ - std::cout - << "Jami Daemon " << libjami::version() - << ", by Savoir-faire Linux Inc. 2004-2023" << std::endl - << "https://jami.net/" << std::endl -#ifdef ENABLE_VIDEO - << "[Video support enabled]" << std::endl -#endif -#ifdef ENABLE_PLUGIN - << "[Plugins support enabled]" << std::endl -#endif - << std::endl; -} - -static void -print_usage() -{ - std::cout << std::endl << - "-c, --console \t- Log in console (instead of syslog)" << std::endl << - "-d, --debug \t- Debug mode (more verbose)" << std::endl << - "-p, --persistent \t- Stay alive after client quits" << std::endl << - "--port \t- Port to use for the rest API. Default is 8080" << std::endl << - "--auto-answer \t- Force automatic answer to incoming calls" << std::endl << - "-h, --help \t- Print help" << std::endl; -} - -// Parse command line arguments, setting debug options or printing a help -// message accordingly. -// returns true if we should quit (i.e. help was printed), false otherwise -static bool -parse_args(int argc, char *argv[], bool& persistent) -{ - int consoleFlag = false; - int debugFlag = false; - int helpFlag = false; - int versionFlag = false; - int autoAnswer = false; - - const struct option long_options[] = { - /* These options set a flag. */ - {"debug", no_argument, nullptr, 'd'}, - {"console", no_argument, nullptr, 'c'}, - {"persistent", no_argument, nullptr, 'p'}, - {"help", no_argument, nullptr, 'h'}, - {"version", no_argument, nullptr, 'v'}, - {"auto-answer", no_argument, &autoAnswer, true}, - {"port", optional_argument, nullptr, 'x'}, - {nullptr, 0, nullptr, 0} /* Sentinel */ - }; - - while (true) { - /* getopt_long stores the option index here. */ - int option_index = 0; - - auto c = getopt_long(argc, argv, "dcphvx:", long_options, &option_index); - - // end of the options - if (c == -1) - break; - - switch (c) { - case 'd': - debugFlag = true; - break; - - case 'c': - consoleFlag = true; - break; - - case 'p': - persistent = true; - break; - - case 'h': - case '?': - helpFlag = true; - break; - - case 'v': - versionFlag = true; - break; - - case 'x': - port = std::atoi(optarg); - break; - - default: - break; - } - } - - if (helpFlag) { - print_usage(); - return true; - } - - if (versionFlag) { - // We've always print the title/version, so we can just exit - return true; - } - - if (consoleFlag) - ringFlags |= libjami::LIBJAMI_FLAG_CONSOLE_LOG; - - if (debugFlag) - ringFlags |= libjami::LIBJAMI_FLAG_DEBUG; - - if (autoAnswer) - ringFlags |= libjami::LIBJAMI_FLAG_AUTOANSWER; - - return false; -} - -static void -signal_handler(int code) -{ - std::cerr << "Caught signal " << strsignal(code) - << ", terminating..." << std::endl; - - // Unset signal handlers - signal(SIGHUP, SIG_DFL); - signal(SIGINT, SIG_DFL); - signal(SIGTERM, SIG_DFL); - - // Interrupt the process - if (auto client = weakClient.lock()) - client->exit(); -} - -int -main(int argc, char *argv []) -{ - // make a copy as we don't want to modify argv[0], copy it to a vector to - // guarantee that memory is correctly managed/exception safe - std::string programName {argv[0]}; - std::vector<char> writable(programName.size() + 1); - std::copy(programName.begin(), programName.end(), writable.begin()); - - jami::fileutils::set_program_dir(writable.data()); - -#ifdef TOP_BUILDDIR - if (!getenv("CODECS_PATH")) - setenv("CODECS_PATH", TOP_BUILDDIR "/src/media/audio/codecs", 1); -#endif - - print_title(); - - bool persistent = false; - if (parse_args(argc, argv, persistent)) - return 0; - - // TODO: Block signals for all threads but the main thread, decide how/if we should - // handle other signals - signal(SIGINT, signal_handler); - signal(SIGHUP, signal_handler); - signal(SIGTERM, signal_handler); - signal(SIGPIPE, SIG_IGN); - - try { -#if REST_API - if (auto client = std::make_shared<RestClient>(port, ringFlags, persistent)) -#else - if (auto client = std::make_shared<DBusClient>(ringFlags, persistent)) -#endif - { - weakClient = client; - return client->event_loop(); - } - } catch (const std::exception& ex) { - std::cerr << "One does not simply initialize the client: " << ex.what() << std::endl; - } - return 1; -} diff --git a/configure.ac b/configure.ac index 05d8542def749c0823b0a6d050096faf2602dc66..3b2de6ac0256574624e66f07b5f3794e2efd8408 100644 --- a/configure.ac +++ b/configure.ac @@ -406,24 +406,21 @@ AS_IF([test "x$enable_coverage" = "xyes"], [DAEMONCXXFLAGS+=" --coverage" DAEMONLDFLAGS+=" --coverage"]) -# DBUSCPP -dnl Check for dbuscpp, the C++ bindings for D-Bus +# SDBUSCPP +dnl Check for sdbus-c++, the C++ bindings for D-Bus AC_ARG_WITH([dbus], [AS_HELP_STRING([--without-dbus], [disable support for dbus])], [], [with_dbus=yes]) AS_IF([test "x$with_dbus" = "xyes"], - [PKG_CHECK_MODULES(DBUSCPP, dbus-c++-1,, + [PKG_CHECK_MODULES(SDBUSCPP, sdbus-c++,, AC_MSG_WARN([Missing dbus development files])) AC_CONFIG_FILES([bin/dbus/Makefile]) - AC_PATH_PROG([DBUSXX_XML2CPP], dbusxx-xml2cpp, + AC_PATH_PROG([SDBUSCPP_XML2CPP], sdbus-c++-xml2cpp, [AC_MSG_ERROR([dbusxx-xml2cpp not found])]) - AS_IF([test "x$CLANG" = "xyes"], - [AC_MSG_ERROR([dbus does not compile when clang is used, - rerun with --without-dbus])]); AM_CONDITIONAL(RING_DBUS, true)], [TESTS= $(check_PROGRAMS) AM_CONDITIONAL(RING_DBUS, false)]); diff --git a/contrib/src/dbus-cpp/0001-dbus-c++-gcc4.7.patch b/contrib/src/dbus-cpp/0001-dbus-c++-gcc4.7.patch deleted file mode 100644 index 5cb8096b9a0f625b772c4defca3b44b503e9e53f..0000000000000000000000000000000000000000 --- a/contrib/src/dbus-cpp/0001-dbus-c++-gcc4.7.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/include/dbus-c++/eventloop-integration.h b/include/dbus-c++/eventloop-integration.h -index 1b0302e..3e44304 100644 ---- a/include/dbus-c++/eventloop-integration.h -+++ b/include/dbus-c++/eventloop-integration.h -@@ -26,6 +26,7 @@ - #define __DBUSXX_EVENTLOOP_INTEGRATION_H - - #include <errno.h> -+#include <unistd.h> - #include "api.h" - #include "dispatcher.h" - #include "util.h" diff --git a/contrib/src/dbus-cpp/0002-dbus-c++-threading.patch b/contrib/src/dbus-cpp/0002-dbus-c++-threading.patch deleted file mode 100644 index c4fafef6270ae902c8499968c9002385238c1bc5..0000000000000000000000000000000000000000 --- a/contrib/src/dbus-cpp/0002-dbus-c++-threading.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- libdbus-c++-0.9.0/include/dbus-c++/dispatcher.h.threading 2017-02-15 13:40:53.796004263 +0000 -+++ libdbus-c++-0.9.0/include/dbus-c++/dispatcher.h 2017-02-15 13:40:46.907000493 +0000 -@@ -188,6 +188,7 @@ - /* classes for multithreading support - */ - -+#if 0 - class DXXAPI Mutex - { - public: -@@ -243,9 +244,11 @@ - typedef bool (*CondVarWaitTimeoutFn)(CondVar *cv, Mutex *mx, int timeout); - typedef void (*CondVarWakeOneFn)(CondVar *cv); - typedef void (*CondVarWakeAllFn)(CondVar *cv); -+#endif - - void DXXAPI _init_threading(); - -+#if 0 - void DXXAPI _init_threading( - MutexNewFn, MutexFreeFn, MutexLockFn, MutexUnlockFn, - CondVarNewFn, CondVarFreeFn, CondVarWaitFn, CondVarWaitTimeoutFn, CondVarWakeOneFn, CondVarWakeAllFn -@@ -312,6 +315,7 @@ - cv->wake_all(); - } - }; -+#endif - - } /* namespace DBus */ - ---- libdbus-c++-0.9.0/src/dispatcher.cpp.threading 2017-02-15 13:48:22.627249868 +0000 -+++ libdbus-c++-0.9.0/src/dispatcher.cpp 2017-02-15 13:48:29.164253445 +0000 -@@ -253,6 +253,7 @@ - #endif//DBUS_HAS_THREADS_INIT_DEFAULT - } - -+#if 0 - void DBus::_init_threading( - MutexNewFn m1, - MutexFreeFn m2, -@@ -318,3 +319,4 @@ - #endif//DBUS_HAS_RECURSIVE_MUTEX - dbus_threads_init(&functions); - } -+#endif diff --git a/contrib/src/dbus-cpp/0003-dbus-c++-writechar.patch b/contrib/src/dbus-cpp/0003-dbus-c++-writechar.patch deleted file mode 100644 index d936b7fc172d6866cea53f2923425a571f78d0a2..0000000000000000000000000000000000000000 --- a/contrib/src/dbus-cpp/0003-dbus-c++-writechar.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- libdbus-c++-0.9.0/src/pipe.cpp.writechar 2017-02-16 11:07:13.591950169 +0000 -+++ libdbus-c++-0.9.0/src/pipe.cpp 2017-02-16 11:04:17.158796092 +0000 -@@ -83,5 +83,5 @@ - void Pipe::signal() - { - // TODO: ignoring return of read/write generates warning; maybe relevant for eventloop work... -- ::write(_fd_write, '\0', 1); -+ ::write(_fd_write, "", 1); - } diff --git a/contrib/src/dbus-cpp/0004-g++12.patch b/contrib/src/dbus-cpp/0004-g++12.patch deleted file mode 100644 index 306a576cf52a34da4d923cf8614ebcfd969a6112..0000000000000000000000000000000000000000 --- a/contrib/src/dbus-cpp/0004-g++12.patch +++ /dev/null @@ -1,71 +0,0 @@ -[dbus-c++] rearrange some deckchairs in types.h - -clang requires that when you invoke an operator with type-based dispatch, the -variant for the type you are invoking it on has already been pre-declared; this -bites us in the Variant T() operator, which relies on the overloaded '>>' -operator for MessageIter; we invoke >> on some type T, but >> for T is declared -later in the file. - -To hack around this, switch over to just forward-declaring the existence of the -T() operator, and put the body of the T() operator after all the -declarations/definitions of MessageIter >> operators. Also, shuffle the Variant -MessageIter >> operator to be above the map >> operator, since if someone tries -to invoke >> on a map of variants, they'll have the same problem. - -There will probably be other, similar problems requiring more rearrangements in -future. - -BUG=chromium-os:37776 -TEST=trybot - -Change-Id: I024ec58d427d960372d92ecaa48f711b4569778f -Signed-off-by: Elly Fong-Jones <ellyjones@chromium.org> -Reviewed-on: https://gerrit.chromium.org/gerrit/41576 -Reviewed-by: Guozhi Wei <carrot@google.com> -Reviewed-by: Ryan Sleevi <rsleevi@chromium.org> - -diff --git a/include/dbus-c++/types.h b/include/dbus-c++/types.h -index a11149a..72606f6 100644 ---- a/include/dbus-c++/types.h -+++ b/include/dbus-c++/types.h - -@@ -103,13 +103,7 @@ - } - - template <typename T> -- operator T() const -- { -- T cast; -- MessageIter ri = _msg.reader(); -- ri >> cast; -- return cast; -- } -+ operator T() const; - - private: - -@@ -440,6 +434,8 @@ - return ++iter; - } - -+extern DXXAPI DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Variant &val); -+ - template<typename E> - inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector<E>& val) - { -@@ -521,6 +517,14 @@ - return ++iter; - } - --extern DXXAPI DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Variant &val); -+template <typename T> -+inline DBus::Variant::operator T() const -+{ -+ T cast; -+ DBus::MessageIter ri = _msg.reader(); -+ ri >> cast; -+ return cast; -+} -+ - - #endif//__DBUSXX_TYPES_H diff --git a/contrib/src/dbus-cpp/0005-g++12-part2.patch b/contrib/src/dbus-cpp/0005-g++12-part2.patch deleted file mode 100644 index 92a4dea0a859525fbd7e9966bcaad6739ce6eb63..0000000000000000000000000000000000000000 --- a/contrib/src/dbus-cpp/0005-g++12-part2.patch +++ /dev/null @@ -1,109 +0,0 @@ -[dbus-c++] DBus-C++ operator overloading should rely on ADL - -DBus-C++ operator overloading (operator >>/<<) should rely on -argument-dependent lookup, rather than on sticking the overloads in the -global namespace, so that they can always be found correctly when used in -templates. - -See http://clang.llvm.org/compatibility.html#dep_lookup to understand why the -existing behaviour was incorrect - -BUG=none -TEST=Compile against types.h with Clang - -Change-Id: I9239e960f6872f0f312561050d1bbd4cc9b87458 -Reviewed-on: https://gerrit.chromium.org/gerrit/42027 -Tested-by: Liam McLoughlin <lmcloughlin@chromium.org> -Commit-Queue: Ryan Sleevi <rsleevi@chromium.org> -Reviewed-by: Ryan Sleevi <rsleevi@chromium.org> - -diff --git a/include/dbus-c++/types.h b/include/dbus-c++/types.h -index 9acb0a3..6652cd4 100644 ---- a/include/dbus-c++/types.h -+++ b/include/dbus-c++/types.h -@@ -310,7 +310,7 @@ struct type< Struct<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, - } - }; - --} /* namespace DBus */ -+extern DXXAPI DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Variant &val); - - inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Invalid &) - { -@@ -649,6 +649,7 @@ inline DBus::Variant::operator T() const - return cast; - } - -+} /* namespace DBus */ - - #endif//__DBUSXX_TYPES_H - -diff --git a/src/types.cpp b/src/types.cpp -index d414a3e..70f9ac0 100644 ---- a/src/types.cpp -+++ b/src/types.cpp -@@ -34,7 +34,7 @@ - #include "message_p.h" - #include "internalerror.h" - --using namespace DBus; -+namespace DBus { - - Variant::Variant() - : _msg(CallMessage()) // dummy message used as temporary storage for variant data -@@ -104,3 +104,4 @@ MessageIter &operator >> (MessageIter &iter, Variant &val) - return ++iter; - } - -+} /* namespace DBus */ -diff --git a/tools/xml.cpp b/tools/xml.cpp -index d3cc3ab..e21f7f5 100644 ---- a/tools/xml.cpp -+++ b/tools/xml.cpp -@@ -26,6 +26,10 @@ - - #include <expat.h> - -+namespace DBus { -+ -+namespace Xml { -+ - std::istream &operator >> (std::istream &in, DBus::Xml::Document &doc) - { - std::stringbuf xmlbuf; -@@ -40,9 +44,6 @@ std::ostream &operator << (std::ostream &out, const DBus::Xml::Document &doc) - return out << doc.to_xml(); - } - --using namespace DBus; --using namespace DBus::Xml; -- - Error::Error(const char *error, int line, int column) - { - std::ostringstream estream; -@@ -311,3 +312,6 @@ void Document::Expat::end_element_handler(void *data, const XML_Char *name) - doc->_depth--; - } - -+} /* namespace Xml */ -+ -+} /* namespace DBus */ -diff --git a/tools/xml.h b/tools/xml.h -index 736a0dd..7edb65c 100644 ---- a/tools/xml.h -+++ b/tools/xml.h -@@ -134,11 +134,11 @@ private: - int _depth; - }; - -+std::istream &operator >> (std::istream &, DBus::Xml::Document &); -+std::ostream &operator << (std::ostream &, DBus::Xml::Document &); -+ - } /* namespace Xml */ - - } /* namespace DBus */ - --std::istream &operator >> (std::istream &, DBus::Xml::Document &); --std::ostream &operator << (std::ostream &, DBus::Xml::Document &); -- - #endif//__DBUSXX_XML_H diff --git a/contrib/src/dbus-cpp/SHA512SUMS b/contrib/src/dbus-cpp/SHA512SUMS deleted file mode 100644 index 71776c48cc5e7c365334823860b83f91705a17ab..0000000000000000000000000000000000000000 --- a/contrib/src/dbus-cpp/SHA512SUMS +++ /dev/null @@ -1 +0,0 @@ -7acebbb4254b2886cc0f05c5ddeeeac0b5863c5552d32249463b89380b0b95b8225c80bd98b8c7fcaada42ab770b5eff41b15390cd0d78bf1ee322ac6c2de319 libdbus-c++-0.9.0.tar.gz diff --git a/contrib/src/dbus-cpp/rules.mak b/contrib/src/dbus-cpp/rules.mak deleted file mode 100644 index 28c9c37afaee7b04ba41b0bb0bb424e922f0f806..0000000000000000000000000000000000000000 --- a/contrib/src/dbus-cpp/rules.mak +++ /dev/null @@ -1,34 +0,0 @@ -# DBus-C++ - -DBUS_CPP_VERSION := 0.9.0 -DBUS_CPP_URL := ${SF}/dbus-cplusplus/files/dbus-c%2B%2B/${DBUS_CPP_VERSION}/libdbus-c%2B%2B-${DBUS_CPP_VERSION}.tar.gz/download - -ifdef HAVE_LINUX -ifndef HAVE_ANDROID -PKGS += dbus-cpp -endif -endif - -ifeq ($(call need_pkg,"dbus-c++-1 >= 0.9.0"),) -PKGS_FOUND += dbus-cpp -endif - -$(TARBALLS)/libdbus-c++-${DBUS_CPP_VERSION}.tar.gz: - $(call download,$(DBUS_CPP_URL)) - -.sum-dbus-cpp: $(TARBALLS)/libdbus-c++-${DBUS_CPP_VERSION}.tar.gz - -dbus-cpp: $(TARBALLS)/libdbus-c++-${DBUS_CPP_VERSION}.tar.gz .sum-dbus-cpp - $(UNPACK) - $(APPLY) $(SRC)/dbus-cpp/0001-dbus-c++-gcc4.7.patch - $(APPLY) $(SRC)/dbus-cpp/0002-dbus-c++-threading.patch - $(APPLY) $(SRC)/dbus-cpp/0003-dbus-c++-writechar.patch - $(APPLY) $(SRC)/dbus-cpp/0004-g++12.patch - $(APPLY) $(SRC)/dbus-cpp/0005-g++12-part2.patch - $(UPDATE_AUTOCONFIG) - $(MOVE) - -.dbus-cpp: dbus-cpp - cd $< && $(HOSTVARS) ./configure $(HOSTCONF) --disable-ecore --disable-glib --disable-tests --disable-examples - cd $< && $(MAKE) install - touch $@ diff --git a/contrib/src/sdbus-cpp/SHA512SUMS b/contrib/src/sdbus-cpp/SHA512SUMS new file mode 100644 index 0000000000000000000000000000000000000000..a48ebec1cff1d5a69b7a8d8e482f70d829825982 --- /dev/null +++ b/contrib/src/sdbus-cpp/SHA512SUMS @@ -0,0 +1 @@ +dab2c4d9a5ea6d626672a5a6ee6f3490c60c6fdd160769801a4d6b4cf3df4983fad57ff0230132a5d637ec78a55993200ce217fa89461016e101865cc2777d7d sdbus-cpp-1.2.0.tar.gz diff --git a/contrib/src/sdbus-cpp/rules.mak b/contrib/src/sdbus-cpp/rules.mak new file mode 100644 index 0000000000000000000000000000000000000000..397d18d3b934374224465165d353c52855a9cc4b --- /dev/null +++ b/contrib/src/sdbus-cpp/rules.mak @@ -0,0 +1,35 @@ +SDBUS_CPP_VERSION := 1.2.0 +SDBUS_CPP_URL := https://github.com/Kistler-Group/sdbus-cpp/archive/refs/tags/v$(SDBUS_CPP_VERSION).tar.gz + +ifdef HAVE_LINUX +ifndef HAVE_ANDROID +PKGS += sdbus-cpp +endif +endif + +ifeq ($(call need_pkg,"sdbus-c++ >= 1.2.0"),) +PKGS_FOUND += sdbus-cpp +endif + +SDBUS_CPP_CMAKECONF := -D CMAKE_BUILD_TYPE=Release \ + -D BUILD_SHARED_LIBS=OFF \ + -D BUILD_CODE_GEN=ON \ + -D BUILD_LIBSYSTEMD=OFF \ + -D BUILD_TESTS=OFF \ + -D BUILD_EXAMPLES=OFF \ + -D BUILD_DOC=OFF + +$(TARBALLS)/sdbus-cpp-$(SDBUS_CPP_VERSION).tar.gz: + $(call download,$(SDBUS_CPP_URL)) + +.sum-sdbus-cpp: sdbus-cpp-$(SDBUS_CPP_VERSION).tar.gz + +sdbus-cpp: sdbus-cpp-$(SDBUS_CPP_VERSION).tar.gz .sum-sdbus-cpp + $(UNPACK) + $(MOVE) + +.sdbus-cpp: sdbus-cpp + cd $< && $(HOSTVARS) $(CMAKE) $(SDBUS_CPP_CMAKECONF) . + cd $< && $(MAKE) + cd $< && $(MAKE) install + touch $@ diff --git a/doc/trace/tracepoint-analysis.rst b/doc/trace/tracepoint-analysis.rst index 431becf3047491e90df6664809191c8b1a1564b8..bd2f7ed23514cd2c1f67d694d2031a29c1fe06e2 100644 --- a/doc/trace/tracepoint-analysis.rst +++ b/doc/trace/tracepoint-analysis.rst @@ -127,7 +127,7 @@ You can now start the session with ``lttng start``:: Tracing started for session jami -and run Jami ``./bin/jamid``. +and run Jami ``./bin/dbus/jamid``. Let it run a few seconds and stop the Jami's daemon. Then you can run ``lttng destroy`` (or ``lttng stop`` if you do not want to destroy) to stop and destroy diff --git a/docker/Dockerfile_ubuntu_18.04 b/docker/Dockerfile_ubuntu_18.04 index 805d9493f59e4fc979576d2ced76025869f35c0d..aa960060eb38d0d8f8b6a86713f6b312b8346524 100644 --- a/docker/Dockerfile_ubuntu_18.04 +++ b/docker/Dockerfile_ubuntu_18.04 @@ -19,7 +19,6 @@ RUN add-apt-repository universe && \ autopoint \ cmake \ libdbus-1-dev \ - libdbus-c++-dev \ libupnp-dev \ libgnutls28-dev \ libargon2-0-dev \ @@ -36,6 +35,8 @@ RUN add-apt-repository universe && \ nasm \ autotools-dev \ gettext \ + libsystemd-dev \ + libsdbus-c++-bin \ libpulse-dev \ libasound2-dev \ libpcre3-dev \ diff --git a/docker/Dockerfile_ubuntu_20.04 b/docker/Dockerfile_ubuntu_20.04 index 18d1822c0045f073eb65e7c4040a6dab95a055f3..3dd90032f5e68cf845ad2677653065fb8818bd9b 100644 --- a/docker/Dockerfile_ubuntu_20.04 +++ b/docker/Dockerfile_ubuntu_20.04 @@ -22,7 +22,6 @@ RUN add-apt-repository universe && \ cmake \ dpkg-dev \ libdbus-1-dev \ - libdbus-c++-dev \ libupnp-dev \ libgnutls28-dev \ libargon2-dev \ @@ -40,6 +39,8 @@ RUN add-apt-repository universe && \ autotools-dev \ libtool \ gettext \ + libsystemd-dev \ + libsdbus-c++-bin \ libpulse-dev \ libasound2-dev \ libpcre3-dev \ diff --git a/meson.build b/meson.build index 6e32690d462f49d67e2b8dcec1d59e387ad83c6a..50e9f3f41cdf917181a53ba77ddfb20cef826670 100644 --- a/meson.build +++ b/meson.build @@ -34,8 +34,8 @@ depjsoncpp = dependency('jsoncpp', version: '>= 1.6.5') depzlib = dependency('zlib') if get_option('interfaces').contains('dbus') - depdbuscpp = dependency('dbus-c++-1') - progdbusxxxml2cpp = find_program('dbusxx-xml2cpp', native: true) + depsdbuscpp = dependency('sdbus-c++', version: '>= 1.2.0') + progsdbuscppxml2cpp = find_program('sdbus-c++-xml2cpp', native: true) endif if get_option('interfaces').contains('nodejs')