From ae6afcdc1baf18ac8f6655d3d99477580ec4d91b Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Fri, 6 Jan 2012 19:01:22 -0500
Subject: [PATCH] * #7264: clear history over dbus

---
 daemon/src/dbus/configurationmanager-introspec.xml |  3 +++
 daemon/src/dbus/configurationmanager.cpp           |  5 +++++
 daemon/src/dbus/configurationmanager.h             |  1 +
 daemon/src/history/history.cpp                     |  5 +++++
 daemon/src/history/history.h                       |  1 +
 daemon/src/managerimpl.cpp                         |  5 +++++
 daemon/src/managerimpl.h                           |  6 +-----
 gnome/src/dbus/configurationmanager-introspec.xml  |  3 +++
 gnome/src/dbus/dbus.c                              | 11 +++++++++++
 gnome/src/dbus/dbus.h                              |  2 ++
 gnome/src/uimanager.c                              |  1 +
 kde/src/dbus/configurationmanager-introspec.xml    |  3 +++
 12 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/daemon/src/dbus/configurationmanager-introspec.xml b/daemon/src/dbus/configurationmanager-introspec.xml
index 1934dc3f72..d86ffc2b6f 100644
--- a/daemon/src/dbus/configurationmanager-introspec.xml
+++ b/daemon/src/dbus/configurationmanager-introspec.xml
@@ -607,6 +607,9 @@
            <arg type="aa{ss}" name="entries" direction="out"/>
 	   </method>
 
+       <method name="clearHistory" tp:name-for-bindings="clearHistory">
+	   </method>
+
 	   <signal name="accountsChanged" tp:name-for-bindings="accountsChanged">
 	   </signal>
 
diff --git a/daemon/src/dbus/configurationmanager.cpp b/daemon/src/dbus/configurationmanager.cpp
index e8a494e1d4..09be098ff3 100644
--- a/daemon/src/dbus/configurationmanager.cpp
+++ b/daemon/src/dbus/configurationmanager.cpp
@@ -336,6 +336,11 @@ int32_t ConfigurationManager::getHistoryLimit()
     return Manager::instance().getHistoryLimit();
 }
 
+void ConfigurationManager::clearHistory()
+{
+    return Manager::instance().clearHistory();
+}
+
 void ConfigurationManager::setHistoryLimit(const int32_t& days)
 {
     Manager::instance().setHistoryLimit(days);
diff --git a/daemon/src/dbus/configurationmanager.h b/daemon/src/dbus/configurationmanager.h
index 2f77eca680..486421d43b 100644
--- a/daemon/src/dbus/configurationmanager.h
+++ b/daemon/src/dbus/configurationmanager.h
@@ -108,6 +108,7 @@ class ConfigurationManager :
 
         void setHistoryLimit(const int32_t& days);
         int32_t getHistoryLimit();
+        void clearHistory();
 
         int32_t getMailNotify();
         void setMailNotify();
diff --git a/daemon/src/history/history.cpp b/daemon/src/history/history.cpp
index 08964fcd95..a84b2128c0 100644
--- a/daemon/src/history/history.cpp
+++ b/daemon/src/history/history.cpp
@@ -146,3 +146,8 @@ void History::addCall(Call *call, int limit)
     HistoryItem item(call->createHistoryEntry());
     addEntry(item, limit);
 }
+
+void History::clear()
+{
+    items_.clear();
+}
diff --git a/daemon/src/history/history.h b/daemon/src/history/history.h
index 99827a849a..c4d9628e4c 100644
--- a/daemon/src/history/history.h
+++ b/daemon/src/history/history.h
@@ -65,6 +65,7 @@ class History {
         std::vector<std::map<std::string, std::string> > getSerialized() const;
 
         void addCall(Call *call, int limit);
+        void clear();
     private:
         void setPath(const std::string &path);
         /* If no path has been set, this will initialize path to a
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index b62560d398..aa6d23e2f4 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -2957,3 +2957,8 @@ void ManagerImpl::saveHistory()
     if (!history_->save())
         ERROR("Manager: could not save history!");
 }
+
+void ManagerImpl::clearHistory()
+{
+    history_->clear();
+}
diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h
index 8d12afe0a0..222c62b36e 100644
--- a/daemon/src/managerimpl.h
+++ b/daemon/src/managerimpl.h
@@ -1142,12 +1142,8 @@ class ManagerImpl {
         bool accountExists(const std::string& accountID);
 
         std::vector<std::map<std::string, std::string> > getHistory() const;
+        void clearHistory();
 
-        /**
-         * Set a list of serialized history entries
-         * @param Vector of history entries
-             */
-        void setHistorySerialized(const std::vector<std::map<std::string, std::string> > &history);
         /**
          * Get an account pointer
          * @param accountID account ID to get
diff --git a/gnome/src/dbus/configurationmanager-introspec.xml b/gnome/src/dbus/configurationmanager-introspec.xml
index 1934dc3f72..d86ffc2b6f 100644
--- a/gnome/src/dbus/configurationmanager-introspec.xml
+++ b/gnome/src/dbus/configurationmanager-introspec.xml
@@ -607,6 +607,9 @@
            <arg type="aa{ss}" name="entries" direction="out"/>
 	   </method>
 
+       <method name="clearHistory" tp:name-for-bindings="clearHistory">
+	   </method>
+
 	   <signal name="accountsChanged" tp:name-for-bindings="accountsChanged">
 	   </signal>
 
diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c
index 9363ea42f7..cbf8537ddf 100644
--- a/gnome/src/dbus/dbus.c
+++ b/gnome/src/dbus/dbus.c
@@ -1716,6 +1716,17 @@ dbus_get_history_limit(void)
     return (guint) days;
 }
 
+void 
+dbus_clear_history(void)
+{
+    GError* error = NULL;
+    org_sflphone_SFLphone_ConfigurationManager_clear_history(
+        configurationManagerProxy, &error);
+
+    if (error)
+        g_error_free(error);
+}
+
 void
 dbus_set_audio_manager(const gchar *api)
 {
diff --git a/gnome/src/dbus/dbus.h b/gnome/src/dbus/dbus.h
index a9b266f9e5..7a2574a120 100644
--- a/gnome/src/dbus/dbus.h
+++ b/gnome/src/dbus/dbus.h
@@ -477,6 +477,8 @@ void dbus_set_accounts_order (const gchar* order);
  */
 GPtrArray *dbus_get_history(void);
 
+void dbus_clear_history(void);
+
 void sflphone_display_transfer_status (const gchar* message);
 
 /**
diff --git a/gnome/src/uimanager.c b/gnome/src/uimanager.c
index 2431e911d7..3145a55ca6 100644
--- a/gnome/src/uimanager.c
+++ b/gnome/src/uimanager.c
@@ -924,6 +924,7 @@ static void
 clear_history(void)
 {
     calllist_clean_history();
+    dbus_clear_history();
 }
 
 /**
diff --git a/kde/src/dbus/configurationmanager-introspec.xml b/kde/src/dbus/configurationmanager-introspec.xml
index 1934dc3f72..d86ffc2b6f 100755
--- a/kde/src/dbus/configurationmanager-introspec.xml
+++ b/kde/src/dbus/configurationmanager-introspec.xml
@@ -607,6 +607,9 @@
            <arg type="aa{ss}" name="entries" direction="out"/>
 	   </method>
 
+       <method name="clearHistory" tp:name-for-bindings="clearHistory">
+	   </method>
+
 	   <signal name="accountsChanged" tp:name-for-bindings="accountsChanged">
 	   </signal>
 
-- 
GitLab