From 6261e2db0670bcc7e8a8cf005aa63dd12d29a344 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Tue, 23 Jan 2018 01:35:20 -0500
Subject: [PATCH] dring: add AccountDetailsChanged signal

Change-Id: I538d3a777380d8c8c55c0999705a957a522a4a86
Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
---
 bin/dbus/cx.ring.Ring.ConfigurationManager.xml | 14 ++++++++++++++
 bin/dbus/dbusclient.cpp                        |  1 +
 configure.ac                                   |  2 +-
 doc/doxygen/core-doc.cfg.in                    |  2 +-
 src/client/ring_signal.cpp                     |  1 +
 src/dring/configurationmanager_interface.h     |  4 ++++
 src/manager.cpp                                |  3 +++
 7 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/bin/dbus/cx.ring.Ring.ConfigurationManager.xml b/bin/dbus/cx.ring.Ring.ConfigurationManager.xml
index d7122b934f..6f693e193d 100644
--- a/bin/dbus/cx.ring.Ring.ConfigurationManager.xml
+++ b/bin/dbus/cx.ring.Ring.ConfigurationManager.xml
@@ -874,6 +874,20 @@
        <signal name="accountsChanged" tp:name-for-bindings="accountsChanged">
        </signal>
 
+       <signal name="accountDetailsChanged" tp:name-for-bindings="accountDetailsChanged">
+           <arg type="s" name="accountID">
+               <tp:docstring>
+                   The account ID
+               </tp:docstring>
+           </arg>
+           <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="MapStringString"/>
+           <arg type="a{ss}" name="details" tp:type="String_String_Map">
+               <tp:docstring>
+                   New persistent account details
+               </tp:docstring>
+           </arg>
+       </signal>
+
        <signal name="registrationStateChanged" tp:name-for-bindings="registrationStateChanged">
            <arg type="s" name="accountID"/>
            <arg type="s" name="registrationState"/>
diff --git a/bin/dbus/dbusclient.cpp b/bin/dbus/dbusclient.cpp
index 152a69a2fc..e13b4c681d 100644
--- a/bin/dbus/dbusclient.cpp
+++ b/bin/dbus/dbusclient.cpp
@@ -172,6 +172,7 @@ DBusClient::initLibrary(int flags)
     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)),
diff --git a/configure.ac b/configure.ac
index 8d244e24b8..4365a1a6b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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],[4.2.0],[ring@gnu.org],[ring])
+AC_INIT([Ring Daemon],[4.3.0],[ring@gnu.org],[ring])
 
 AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2018]])
 AC_REVISION([$Revision$])
diff --git a/doc/doxygen/core-doc.cfg.in b/doc/doxygen/core-doc.cfg.in
index 50a752648f..2e72e59662 100644
--- a/doc/doxygen/core-doc.cfg.in
+++ b/doc/doxygen/core-doc.cfg.in
@@ -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         = 4.2.0
+PROJECT_NUMBER         = 4.3.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
diff --git a/src/client/ring_signal.cpp b/src/client/ring_signal.cpp
index 65175ed034..b9343f58b3 100644
--- a/src/client/ring_signal.cpp
+++ b/src/client/ring_signal.cpp
@@ -53,6 +53,7 @@ getSignalHandlers()
         /* Configuration */
         exported_callback<DRing::ConfigurationSignal::VolumeChanged>(),
         exported_callback<DRing::ConfigurationSignal::AccountsChanged>(),
+        exported_callback<DRing::ConfigurationSignal::AccountDetailsChanged>(),
         exported_callback<DRing::ConfigurationSignal::StunStatusFailed>(),
         exported_callback<DRing::ConfigurationSignal::RegistrationStateChanged>(),
         exported_callback<DRing::ConfigurationSignal::VolatileDetailsChanged>(),
diff --git a/src/dring/configurationmanager_interface.h b/src/dring/configurationmanager_interface.h
index 3021b74e39..3e78409a4a 100644
--- a/src/dring/configurationmanager_interface.h
+++ b/src/dring/configurationmanager_interface.h
@@ -223,6 +223,10 @@ struct ConfigurationSignal {
         };
 
         // TODO: move those to AccountSignal in next API breakage
+        struct AccountDetailsChanged {
+                constexpr static const char* name = "AccountDetailsChanged";
+                using cb_type = void(const std::string& /*account_id*/, const std::map<std::string, std::string>& /* details */);
+        };
         struct StunStatusFailed {
                 constexpr static const char* name = "StunStatusFailed";
                 using cb_type = void(const std::string& /*account_id*/);
diff --git a/src/manager.cpp b/src/manager.cpp
index a8a1eb4567..d2adddece0 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -2653,6 +2653,9 @@ Manager::setAccountDetails(const std::string& accountID,
             account->doRegister();
         else
             account->doUnregister();
+
+        // Update account details to the client side
+        emitSignal<DRing::ConfigurationSignal::AccountDetailsChanged>(accountID, details);
     });
 }
 
-- 
GitLab