Commit ffc6d6d1 authored by Andreas Traczyk's avatar Andreas Traczyk

dring: unify register signal handlers functions

- provides registerSignalHandlers to replace registerCallHandlers,
  registerConfHandlers, registerDataXferHandlers,
  registerPresHandlers, and registerVideoHandlers which are now
  deprecated and forward to registerSignalHandlers

- this patch bumps the daemon API to 5.2.0 and is backwards
  compatible

Change-Id: Ie9479610114a474b4748614988c3ea0156dce6a9
Reviewed-by: Sébastien Blin's avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent 993766a9
......@@ -223,13 +223,13 @@ DBusClient::initLibrary(int flags)
if (!DRing::init(static_cast<DRing::InitFlag>(flags)))
return -1;
registerCallHandlers(callEvHandlers);
registerConfHandlers(configEvHandlers);
registerPresHandlers(presEvHandlers);
registerPresHandlers(audioEvHandlers);
registerDataXferHandlers(dataXferEvHandlers);
registerSignalHandlers(callEvHandlers);
registerSignalHandlers(configEvHandlers);
registerSignalHandlers(presEvHandlers);
registerSignalHandlers(audioEvHandlers);
registerSignalHandlers(dataXferEvHandlers);
#ifdef RING_VIDEO
registerVideoHandlers(videoEvHandlers);
registerSignalHandlers(videoEvHandlers);
#endif
if (!DRing::start())
......
......@@ -293,11 +293,11 @@ void init(ConfigurationCallback* confM, Callback* callM, PresenceCallback* presM
if (!DRing::init(static_cast<DRing::InitFlag>(DRing::DRING_FLAG_DEBUG)))
return;
registerCallHandlers(callEvHandlers);
registerConfHandlers(configEvHandlers);
registerPresHandlers(presenceEvHandlers);
registerDataXferHandlers(dataTransferEvHandlers);
registerVideoHandlers(videoEvHandlers);
registerSignalHandlers(callEvHandlers);
registerSignalHandlers(configEvHandlers);
registerSignalHandlers(presenceEvHandlers);
registerSignalHandlers(dataTransferEvHandlers);
registerSignalHandlers(videoEvHandlers);
DRing::start();
}
......
......@@ -156,8 +156,8 @@ void init(const v8::Handle<v8::Value> &funcMap){
if (!DRing::init(static_cast<DRing::InitFlag>(DRing::DRING_FLAG_DEBUG)))
return;
registerConfHandlers(configEvHandlers);
registerCallHandlers(callEvHandlers);
registerSignalHandlers(configEvHandlers);
registerSignalHandlers(callEvHandlers);
DRing::start();
}
......
......@@ -151,12 +151,8 @@ osxTests()
DRing::init(static_cast<DRing::InitFlag>(ringFlags));
registerCallHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
registerConfHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
registerPresHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
#ifdef RING_VIDEO
registerVideoHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
#endif
registerSignalHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
if (!DRing::start())
return -1;
......
......@@ -119,13 +119,13 @@ RestClient::initLib(int flags)
if (!DRing::init(static_cast<DRing::InitFlag>(flags)))
return -1;
registerConfHandlers(configEvHandlers);
registerSignalHandlers(configEvHandlers);
// Dummy callbacks are registered for the other managers
registerCallHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
registerPresHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
registerSignalHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
registerSignalHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
#ifdef RING_VIDEO
registerVideoHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
registerSignalHandlers(std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>>());
#endif
if (!DRing::start())
......
......@@ -172,7 +172,7 @@ run()
callHandlers.insert(DRing::exportable_callback<DRing::CallSignal::IncomingCall>
(std::bind(&IncomingCall, _1, _2, _3)));
registerCallHandlers(callHandlers);
registerSignalHandlers(callHandlers);
if (!DRing::start())
return -1;
......
......@@ -2,7 +2,7 @@ dnl Ring - configure.ac for automake 1.9 and autoconf 2.59
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65])
AC_INIT([Ring Daemon],[5.1.0],[ring@gnu.org],[ring])
AC_INIT([Ring Daemon],[5.2.0],[ring@gnu.org],[ring])
AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2018]])
AC_REVISION([$Revision$])
......
......@@ -31,7 +31,7 @@ PROJECT_NAME = "Ring Daemon"
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 5.1.0
PROJECT_NUMBER = 5.2.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer
......
......@@ -39,18 +39,9 @@ namespace DRing {
void
registerCallHandlers(const std::map<std::string,
std::shared_ptr<CallbackWrapperBase>>& handlers)
std::shared_ptr<CallbackWrapperBase>>&handlers)
{
auto& handlers_ = ring::getSignalHandlers();
for (auto& item : handlers) {
auto iter = handlers_.find(item.first);
if (iter == handlers_.end()) {
RING_ERR("Signal %s not supported", item.first.c_str());
continue;
}
iter->second = std::move(item.second);
}
registerSignalHandlers(handlers);
}
std::string
......
......@@ -73,18 +73,9 @@ using ring::HookPreference;
void
registerConfHandlers(const std::map<std::string,
std::shared_ptr<CallbackWrapperBase>>& handlers)
{
auto& handlers_ = ring::getSignalHandlers();
for (auto& item : handlers) {
auto iter = handlers_.find(item.first);
if (iter == handlers_.end()) {
RING_ERR("Signal %s not supported", item.first.c_str());
continue;
}
iter->second = std::move(item.second);
}
std::shared_ptr<CallbackWrapperBase>>&handlers)
{
registerSignalHandlers(handlers);
}
std::map<std::string, std::string>
......
......@@ -27,18 +27,10 @@
namespace DRing {
void
registerDataXferHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>& handlers)
registerDataXferHandlers(const std::map<std::string,
std::shared_ptr<CallbackWrapperBase>>& handlers)
{
auto& handlers_ = ring::getSignalHandlers();
for (const auto& item : handlers) {
auto iter = handlers_.find(item.first);
if (iter == handlers_.end()) {
RING_ERR("Signal %s not supported", item.first.c_str());
continue;
}
iter->second = std::move(item.second);
}
registerSignalHandlers(handlers);
}
std::vector<DataTransferId>
......
......@@ -46,18 +46,9 @@ using ring::SIPAccount;
void
registerPresHandlers(const std::map<std::string,
std::shared_ptr<CallbackWrapperBase>>& handlers)
std::shared_ptr<CallbackWrapperBase>>&handlers)
{
auto& handlers_ = ring::getSignalHandlers();
for (auto& item : handlers) {
auto iter = handlers_.find(item.first);
if (iter == handlers_.end()) {
RING_ERR("Signal %s not supported", item.first.c_str());
continue;
}
iter->second = std::move(item.second);
}
registerSignalHandlers(handlers);
}
/**
......
......@@ -117,3 +117,22 @@ getSignalHandlers()
}
}; // namespace ring
namespace DRing {
void
registerSignalHandlers(const std::map<std::string,
std::shared_ptr<CallbackWrapperBase>>&handlers)
{
auto& handlers_ = ring::getSignalHandlers();
for (auto& item : handlers) {
auto iter = handlers_.find(item.first);
if (iter == handlers_.end()) {
RING_ERR("Signal %s not supported", item.first.c_str());
continue;
}
iter->second = std::move(item.second);
}
}
}
\ No newline at end of file
......@@ -41,21 +41,11 @@ namespace DRing {
void
registerVideoHandlers(const std::map<std::string,
std::shared_ptr<CallbackWrapperBase>>& handlers)
std::shared_ptr<CallbackWrapperBase>>&handlers)
{
auto& handlers_ = ring::getSignalHandlers();
for (auto& item : handlers) {
auto iter = handlers_.find(item.first);
if (iter == handlers_.end()) {
RING_ERR("Signal %s not supported", item.first.c_str());
continue;
}
iter->second = std::move(item.second);
}
registerSignalHandlers(handlers);
}
std::vector<std::string>
getDeviceList()
{
......
......@@ -33,6 +33,7 @@
namespace DRing {
[[deprecated("Replaced by registerSignalHandlers")]]
void registerCallHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
/* Call related methods */
......
......@@ -40,6 +40,9 @@
namespace DRing {
[[deprecated("Replaced by registerSignalHandlers")]]
void registerConfHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
struct Message
{
std::string from;
......@@ -47,8 +50,6 @@ struct Message
uint64_t received;
};
void registerConfHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
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);
......
......@@ -31,6 +31,9 @@
namespace DRing {
[[deprecated("Replaced by registerSignalHandlers")]]
void registerDataXferHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
using DataTransferId = uint64_t;
enum class DataTransferEventCode : uint32_t
......@@ -158,9 +161,6 @@ DataTransferError dataTransferInfo(const DataTransferId& id, DataTransferInfo& i
DataTransferError dataTransferBytesProgress(const DataTransferId& id, int64_t& total,
int64_t& progress) noexcept;
// Signal handlers registration
void registerDataXferHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
// Signals
struct DataTransferSignal
{
......
......@@ -150,6 +150,8 @@ exportable_callback(std::function<typename Ts::cb_type>&& func) {
(std::forward<std::function<typename Ts::cb_type>>(func)));
}
void registerSignalHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
} // namespace DRing
#endif /* DRING_H */
......@@ -31,6 +31,7 @@
namespace DRing {
[[deprecated("Replaced by registerSignalHandlers")]]
void registerPresHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
/* Presence subscription/Notification. */
......
......@@ -37,6 +37,9 @@
namespace DRing {
[[deprecated("Replaced by registerSignalHandlers")]]
void registerVideoHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
/* FrameBuffer is a generic video frame container */
struct FrameBuffer {
uint8_t* ptr {nullptr}; // data as a plain raw pointer
......@@ -55,8 +58,6 @@ struct SinkTarget {
using VideoCapabilities = std::map<std::string, std::map<std::string, std::vector<std::string>>>;
void registerVideoHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>&);
std::vector<std::string> getDeviceList();
VideoCapabilities getCapabilities(const std::string& name);
std::map<std::string, std::string> getSettings(const std::string& name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment