diff --git a/daemon/bin/dbus/configurationmanager-introspec.xml b/daemon/bin/dbus/configurationmanager-introspec.xml index 72091673fcf76103f20981c39f39723e4e6ecdaf..3c219b4809747d6db78122aadce6a29fddadd29e 100644 --- a/daemon/bin/dbus/configurationmanager-introspec.xml +++ b/daemon/bin/dbus/configurationmanager-introspec.xml @@ -516,21 +516,9 @@ </arg> </method> - <method name="getHistory" tp:name-for-bindings="getHistory"> - <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="VectorMapStringString"/> - <!-- Return a List of type Dict<string, string> >...a List of Dicts --> - <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> - <signal name="historyChanged" tp:name-for-bindings="historyChanged"> - </signal> - <!-- FIXME: we should rethink these two signals --> <!-- Used by IAX and SIP accounts --> <signal name="registrationStateChanged" tp:name-for-bindings="registrationStateChanged"> diff --git a/daemon/bin/dbus/dbusclient.cpp b/daemon/bin/dbus/dbusclient.cpp index 7b809186e50aeb28d5fb8315f095e0f520fdb7a2..6cc83ddc35baa0bbe2b8a994ee7b22caa80deaa3 100644 --- a/daemon/bin/dbus/dbusclient.cpp +++ b/daemon/bin/dbus/dbusclient.cpp @@ -175,7 +175,6 @@ int DBusClient::initLibrary(int sflphFlags) DRing::EventHandlerKey::CONFIG, { exportable_callback<ConfigurationSignal::VolumeChanged>(bind(&DBusConfigurationManager::volumeChanged, confM, _1, _2)), exportable_callback<ConfigurationSignal::AccountsChanged>(bind(&DBusConfigurationManager::accountsChanged, confM)), - exportable_callback<ConfigurationSignal::HistoryChanged>(bind(&DBusConfigurationManager::historyChanged, confM)), exportable_callback<ConfigurationSignal::StunStatusFailed>(bind(&DBusConfigurationManager::stunStatusFailure, confM, _1)), exportable_callback<ConfigurationSignal::RegistrationStateChanged>(bind(&DBusConfigurationManager::registrationStateChanged, confM, _1, _2)), exportable_callback<ConfigurationSignal::SipRegistrationStateChanged>(bind(&DBusConfigurationManager::sipRegistrationStateChanged, confM, _1, _2, _3)), diff --git a/daemon/bin/dbus/dbusconfigurationmanager.cpp b/daemon/bin/dbus/dbusconfigurationmanager.cpp index 219510344ebe529b05b0cdfdcc88eabcc65ed7ba..856a0be490c8edd92d51ff9a2940c0588132484a 100644 --- a/daemon/bin/dbus/dbusconfigurationmanager.cpp +++ b/daemon/bin/dbus/dbusconfigurationmanager.cpp @@ -330,12 +330,6 @@ DBusConfigurationManager::getHistoryLimit() -> decltype(DRing::getHistoryLimit() return DRing::getHistoryLimit(); } -void -DBusConfigurationManager::clearHistory() -{ - DRing::clearHistory(); -} - void DBusConfigurationManager::setAccountsOrder(const std::string& order) { @@ -354,12 +348,6 @@ DBusConfigurationManager::setHookSettings(const std::map<std::string, std::strin DRing::setHookSettings(settings); } -auto -DBusConfigurationManager::getHistory() -> decltype(DRing::getHistory()) -{ - return DRing::getHistory(); -} - auto DBusConfigurationManager::getTlsSettings() -> decltype(DRing::getTlsSettings()) { diff --git a/daemon/bin/dbus/dbusconfigurationmanager.h b/daemon/bin/dbus/dbusconfigurationmanager.h index 0dad0d1d9461ec90f8e80eb75c1eb39ac7ce9ba2..18447aa96c15c21899501316bf064408488a8989 100644 --- a/daemon/bin/dbus/dbusconfigurationmanager.h +++ b/daemon/bin/dbus/dbusconfigurationmanager.h @@ -112,11 +112,9 @@ class DBusConfigurationManager : void setIsAlwaysRecording(const bool& rec); void setHistoryLimit(const int32_t& days); int32_t getHistoryLimit(); - void clearHistory(); void setAccountsOrder(const std::string& order); std::map<std::string, std::string> getHookSettings(); void setHookSettings(const std::map<std::string, std::string>& settings); - std::vector<std::map<std::string, std::string>> getHistory(); std::map<std::string, std::string> getTlsSettings(); void setTlsSettings(const std::map<std::string, std::string>& details); std::map<std::string, std::string> getIp2IpDetails(); diff --git a/daemon/configure.ac b/daemon/configure.ac index 349c19d0032c6cc845384d6183eb60c04288424c..6d2c7b970ab2ddb5a3cd3e42a6e45acf6cc43159 100644 --- a/daemon/configure.ac +++ b/daemon/configure.ac @@ -591,7 +591,6 @@ AC_CONFIG_FILES([Makefile \ src/config/Makefile \ src/client/Makefile \ src/hooks/Makefile \ - src/history/Makefile \ src/media/video/Makefile \ src/media/video/v4l2/Makefile \ src/media/video/test/Makefile \ diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am index d0b6c9ff7f1f8c0f9537fca3d2292fb8fe572a56..7f1bd34a6a37baf0e9e565310ae99e78ede21ed0 100644 --- a/daemon/src/Makefile.am +++ b/daemon/src/Makefile.am @@ -35,7 +35,7 @@ TLS_LIB = @GNUTLS_LIBS@ TLS_CFLAGS = @GNUTLS_CFLAGS@ endif -SUBDIRS = client media config hooks history sip upnp $(IAX_SUBDIR) $(RINGACC_SUBDIR) $(INSTANT_MESSAGING_SUBDIR) $(RING_VIDEO_SUBDIR) +SUBDIRS = client media config hooks sip upnp $(IAX_SUBDIR) $(RINGACC_SUBDIR) $(INSTANT_MESSAGING_SUBDIR) $(RING_VIDEO_SUBDIR) # libring @@ -47,7 +47,6 @@ libring_la_LIBADD = \ ./client/libclient.la \ ./config/libconfig.la \ ./hooks/libhooks.la \ - ./history/libhistory.la \ ./upnp/libupnpcontrol.la \ $(RINGACC_LIBA) \ $(IAX_LIBA) \ diff --git a/daemon/src/call.cpp b/daemon/src/call.cpp index 8180628a393ded9414bca9a5db956bdbba861023..2cb97602d59d870fb40c267b06d0534e3420787e 100644 --- a/daemon/src/call.cpp +++ b/daemon/src/call.cpp @@ -34,7 +34,6 @@ #include "account.h" #include "manager.h" #include "audio/ringbufferpool.h" -#include "history/historyitem.h" #include "sip/sip_utils.h" #include "ip_utils.h" @@ -244,35 +243,6 @@ timestamp_to_string(const time_t ×tamp) return time_str.str(); } -std::map<std::string, std::string> Call::createHistoryEntry() const -{ - std::map<std::string, std::string> result; - - result[HistoryItem::ACCOUNT_ID_KEY] = getAccountId(); - result[HistoryItem::CONFID_KEY] = confID_; - result[HistoryItem::CALLID_KEY] = id_; - result[HistoryItem::DISPLAY_NAME_KEY] = displayName_; - result[HistoryItem::PEER_NUMBER_KEY] = peerNumber_; - result[HistoryItem::RECORDING_PATH_KEY] = recAudio_.fileExists() ? getFilename() : ""; - result[HistoryItem::TIMESTAMP_START_KEY] = timestamp_to_string(timestamp_start_); - result[HistoryItem::TIMESTAMP_STOP_KEY] = timestamp_to_string(timestamp_stop_); - - // FIXME: state will no longer exist, it will be split into - // a boolean field called "missed" and a direction field "incoming" or "outgoing" - if (connectionState_ == RINGING) { - result[HistoryItem::STATE_KEY] = HistoryItem::MISSED_STRING; - result[HistoryItem::MISSED_KEY] = "true"; - } else { - result[HistoryItem::STATE_KEY] = getTypeStr(); - result[HistoryItem::MISSED_KEY] = "false"; - } - - // now "missed" and direction are independent - result[HistoryItem::DIRECTION_KEY] = getTypeStr(); - - return result; -} - std::map<std::string, std::string> Call::getDetails() { diff --git a/daemon/src/call.h b/daemon/src/call.h index d1bd08e1b9e43a8f1291eeeef89e2ede7a5c8dac..aeacc08183c333472357a869ce356a9d29b7c5cc 100644 --- a/daemon/src/call.h +++ b/daemon/src/call.h @@ -234,9 +234,6 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> { virtual std::map<std::string, std::string> getDetails(); static std::map<std::string, std::string> getNullDetails(); - virtual std::map<std::string, std::string> - createHistoryEntry() const; - virtual bool toggleRecording(); /** diff --git a/daemon/src/client/configurationmanager.cpp b/daemon/src/client/configurationmanager.cpp index e3c2d7cd550ebe0a461afb8258f968c988b44d9c..4f73face4411ffc190d6fd9204e2ecf01c3d0597 100644 --- a/daemon/src/client/configurationmanager.cpp +++ b/daemon/src/client/configurationmanager.cpp @@ -435,12 +435,6 @@ getHistoryLimit() return ring::Manager::instance().getHistoryLimit(); } -void -clearHistory() -{ - return ring::Manager::instance().clearHistory(); -} - void setHistoryLimit(int32_t days) { @@ -562,12 +556,6 @@ void setAccountsOrder(const std::string& order) ring::Manager::instance().setAccountsOrder(order); } -std::vector<std::map<std::string, std::string>> -getHistory() -{ - return ring::Manager::instance().getHistory(); -} - std::string getAddrFromInterfaceName(const std::string& interface) { diff --git a/daemon/src/client/signal.cpp b/daemon/src/client/signal.cpp index 5248838688151bf24161da8d84679b75fa0607e7..a023554c23c2ad21af8dabafece3c6421cc03c9b 100644 --- a/daemon/src/client/signal.cpp +++ b/daemon/src/client/signal.cpp @@ -64,7 +64,6 @@ getSignalHandlers() /* Configuration */ exported_callback<DRing::ConfigurationSignal::VolumeChanged>(), exported_callback<DRing::ConfigurationSignal::AccountsChanged>(), - exported_callback<DRing::ConfigurationSignal::HistoryChanged>(), exported_callback<DRing::ConfigurationSignal::StunStatusFailed>(), exported_callback<DRing::ConfigurationSignal::RegistrationStateChanged>(), exported_callback<DRing::ConfigurationSignal::SipRegistrationStateChanged>(), diff --git a/daemon/src/dring/configurationmanager_interface.h b/daemon/src/dring/configurationmanager_interface.h index 7b729104fecff94e3cad49453279de35010ef844..9ef4a026257ee9b89076ddce60b6103b4f746532 100644 --- a/daemon/src/dring/configurationmanager_interface.h +++ b/daemon/src/dring/configurationmanager_interface.h @@ -59,10 +59,6 @@ struct ConfigurationSignal { constexpr static const char* name = "AccountsChanged"; using cb_type = void(void); }; - struct HistoryChanged { - constexpr static const char* name = "HistoryChanged"; - using cb_type = void(void); - }; struct StunStatusFailed { constexpr static const char* name = "StunStatusFailed"; using cb_type = void(const std::string& /*account_id*/); @@ -144,15 +140,12 @@ void setIsAlwaysRecording(bool rec); void setHistoryLimit(int32_t days); int32_t getHistoryLimit(); -void clearHistory(); void setAccountsOrder(const std::string& order); std::map<std::string, std::string> getHookSettings(); void setHookSettings(const std::map<std::string, std::string>& settings); -std::vector<std::map<std::string, std::string>> getHistory(); - std::map<std::string, std::string> getTlsSettings(); void setTlsSettings(const std::map<std::string, std::string>& details); std::map<std::string, std::string> getIp2IpDetails(); diff --git a/daemon/src/history/Makefile.am b/daemon/src/history/Makefile.am deleted file mode 100644 index 4a405ae6307527070fa1dc1ee29aefacf605b7c8..0000000000000000000000000000000000000000 --- a/daemon/src/history/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -include ../../globals.mak - -noinst_LTLIBRARIES = libhistory.la - -libhistory_la_SOURCES = \ - historyitem.h \ - historyitem.cpp \ - history.h \ - history.cpp diff --git a/daemon/src/history/history.cpp b/daemon/src/history/history.cpp deleted file mode 100644 index 48a6ce25e8db9dd62e3333ef9e0f8450cde77d17..0000000000000000000000000000000000000000 --- a/daemon/src/history/history.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2004-2015 Savoir-Faire Linux Inc. - * - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * Author: Alexandre Savard <alexandre.savard@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. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#include "history.h" -#include <cerrno> -#include <algorithm> -#include <fstream> -#include <sys/stat.h> // for mkdir -#include <ctime> -#include <cstring> -#include "fileutils.h" -#include "logger.h" -#include "call.h" - -namespace ring { - -History::History() : historyItemsMutex_(), items_(), path_() {} - - -using std::map; -using std::string; -using std::vector; - -bool History::load(int limit) -{ - // load only once - if (!items_.empty()) - return true; - - ensurePath(); - std::ifstream infile(path_.c_str()); - if (!infile) { - RING_DBG("No history file to load"); - return false; - } - - while (!infile.eof()) { - HistoryItem item(infile); - addEntry(item, limit); - } - - return true; -} - -bool History::save() -{ - std::lock_guard<std::mutex> lock(historyItemsMutex_); - RING_DBG("Saving history in XDG directory: %s", path_.c_str()); - ensurePath(); - std::sort(items_.begin(), items_.end()); - std::ofstream outfile(path_.c_str()); - if (outfile.fail()) - return false; - for (const auto &item : items_) - outfile << item << std::endl; - return true; -} - -void History::addEntry(const HistoryItem &item, int oldest) -{ - std::lock_guard<std::mutex> lock(historyItemsMutex_); - if (item.hasPeerNumber() and item.youngerThan(oldest)) { - items_.push_back(item); - auto im = item.toMap(); - string name(im["display_name"]); - string account(im["accountid"]); - string number(im["peer_number"]); - if (nameCache_[account][number].empty() and not name.empty() and not number.empty()) - nameCache_[account][number] = name; - } -} - -void History::ensurePath() -{ - if (path_.empty()) { - const string userdata = fileutils::get_data_dir(); - if (!fileutils::check_dir(userdata.c_str())) { - RING_DBG("Cannot create directory: %s", userdata.c_str()); - return; - } - path_ = userdata + DIR_SEPARATOR_STR + "history"; - } -} - -vector<map<string, string> > History::getSerialized() -{ - std::lock_guard<std::mutex> lock(historyItemsMutex_); - vector<map<string, string> > result; - for (const auto &item : items_) - result.push_back(item.toMap()); - - return result; -} - -void History::setPath(const std::string &path) -{ - path_ = path; -} - -void History::addCall(Call *call, int limit) -{ - if (!call) { - RING_ERR("Call is NULL, ignoring"); - return; - } - call->time_stop(); - HistoryItem item(call->createHistoryEntry()); - addEntry(item, limit); -} - -void History::clear() -{ - std::lock_guard<std::mutex> lock(historyItemsMutex_); - items_.clear(); -} - -bool History::empty() -{ - std::lock_guard<std::mutex> lock(historyItemsMutex_); - return items_.empty(); -} - - -size_t History::numberOfItems() -{ - std::lock_guard<std::mutex> lock(historyItemsMutex_); - return items_.size(); -} - -std::string -History::getNameFromHistory(const std::string &number, - const std::string &accountid) const { - const auto& it1 = nameCache_.find(accountid); - if (it1 == nameCache_.cend()) - return ""; - const auto& map = it1->second; - const auto& it2 = map.find(number); - if (it2 == map.cend()) - return ""; - return it2->second; -} - -} // namespace ring diff --git a/daemon/src/history/history.h b/daemon/src/history/history.h deleted file mode 100644 index 6e4c2acab70fc5e54f0209576776e1bd55d05cce..0000000000000000000000000000000000000000 --- a/daemon/src/history/history.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2004-2015 Savoir-Faire Linux Inc. - * - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * Author: Alexandre Savard <alexandre.savard@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. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#ifndef HISTORY_ -#define HISTORY_ - -#include "historyitem.h" -#include <mutex> -#include <vector> - -namespace ring { - -namespace test { -class HistoryTest; -} - -class Call; - -class History { - - public: - History(); - /** Load history from file */ - bool load(int limit); - - /** - *@return True if the history has been successfully saved in the file - */ - bool save(); - - /* - *@return The number of items found in the history file - */ - size_t numberOfItems(); - - bool empty(); - - std::vector<std::map<std::string, std::string> > getSerialized(); - - void addCall(Call *call, int limit); - void clear(); - void setPath(const std::string &path); - - std::string getNameFromHistory(const std::string &number, - const std::string &accountid) const; - - private: - /* Mutex to protect the history items */ - std::mutex historyItemsMutex_; - - /* If no path has been set, this will initialize path to a - * system-dependent location */ - void ensurePath(); - /* - * Add a new history item in the data structure - */ - void addEntry(const HistoryItem &new_item, int limit); - - /* - * Vector containing the history items - */ - std::vector<HistoryItem> items_; - - /* - * Reverse mapping of display name for given account id and peer number. - */ - std::map<std::string, std::map<std::string, std::string>> nameCache_ {}; - - /* The path to the history file */ - std::string path_; - - friend class test::HistoryTest; -}; - -} - -#endif // HISTORY_ diff --git a/daemon/src/history/historyitem.cpp b/daemon/src/history/historyitem.cpp deleted file mode 100644 index 2bbc702df5fa8cf543de04badb22f3a689d1a9d7..0000000000000000000000000000000000000000 --- a/daemon/src/history/historyitem.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2004-2015 Savoir-Faire Linux Inc. - * - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * Author: Alexandre Savard <alexandre.savard@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. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#include "historyitem.h" -#include <unistd.h> -#include <cstdlib> -#include <istream> - -namespace ring { - -const char * const HistoryItem::ACCOUNT_ID_KEY = "accountid"; -const char * const HistoryItem::CALLID_KEY = "callid"; -const char * const HistoryItem::CONFID_KEY = "confid"; -const char * const HistoryItem::DISPLAY_NAME_KEY = "display_name"; -const char * const HistoryItem::PEER_NUMBER_KEY = "peer_number"; -const char * const HistoryItem::RECORDING_PATH_KEY = "recordfile"; -// FIXME: Deprecated -const char * const HistoryItem::STATE_KEY = "state"; -// New version: -const char * const HistoryItem::MISSED_KEY = "missed"; -const char * const HistoryItem::DIRECTION_KEY = "direction"; -const char * const HistoryItem::TIMESTAMP_START_KEY = "timestamp_start"; -const char * const HistoryItem::TIMESTAMP_STOP_KEY = "timestamp_stop"; -const char * const HistoryItem::AUDIO_CODEC_KEY = "audio_codec"; -const char * const HistoryItem::VIDEO_CODEC_KEY = "video_codec"; - -const char * const HistoryItem::MISSED_STRING = "missed"; -const char * const HistoryItem::INCOMING_STRING = "incoming"; -const char * const HistoryItem::OUTGOING_STRING = "outgoing"; - -using std::map; -using std::string; - -static bool -file_exists(const std::string &str) -{ - return access(str.c_str(), F_OK) != -1; -} - -HistoryItem::HistoryItem(const map<string, string> &args) : entryMap_(args), - timestampStart_(std::atol(entryMap_[TIMESTAMP_START_KEY].c_str())) -{} - -HistoryItem::HistoryItem(std::istream &entry) : entryMap_(), timestampStart_(0) -{ - string tmp; - while (std::getline(entry, tmp, '\n')) { - size_t pos = tmp.find('='); - if (pos == string::npos) - break; - else if (pos < tmp.length() - 1) { - string key(tmp.substr(0, pos)); - string val(tmp.substr(pos + 1, tmp.length() - pos - 1)); - if (key == RECORDING_PATH_KEY and not file_exists(val)) - val = ""; - entryMap_[key] = val; - } - } - timestampStart_ = std::atol(entryMap_[TIMESTAMP_START_KEY].c_str()); -} - -map<string, string> HistoryItem::toMap() const -{ - return entryMap_; -} - -bool HistoryItem::youngerThan(unsigned long otherTime) const -{ - return timestampStart_ > otherTime; -} - -bool HistoryItem::hasPeerNumber() const -{ - return entryMap_.find(PEER_NUMBER_KEY) != entryMap_.end(); -} - -void HistoryItem::print(std::ostream &o) const -{ - // every entry starts with "[" + random integer = "]" - for (const auto &item : entryMap_) { - // if the file does not exist anymore, we do not save it - if (item.first == RECORDING_PATH_KEY and not file_exists(item.second)) - o << item.first << "=" << "" << std::endl; - else - o << item.first << "=" << item.second << std::endl; - } -} - -std::ostream& operator << (std::ostream& o, const HistoryItem& item) -{ - item.print(o); - return o; -} - -} // namespace ring diff --git a/daemon/src/history/historyitem.h b/daemon/src/history/historyitem.h deleted file mode 100644 index a5cc81c4c1a06e627e331dfdfaac952f7f993697..0000000000000000000000000000000000000000 --- a/daemon/src/history/historyitem.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2004-2015 Savoir-Faire Linux Inc. - * - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * Author: Alexamdre Savard <alexandre.savard@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. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ - -#ifndef HISTORY_ITEM_H_ -#define HISTORY_ITEM_H_ - -#include <string> -#include <map> - -namespace ring { - -class HistoryItem { - public: - static const char * const ACCOUNT_ID_KEY; - static const char * const CONFID_KEY; - static const char * const CALLID_KEY; - static const char * const DISPLAY_NAME_KEY; - static const char * const PEER_NUMBER_KEY; - static const char * const RECORDING_PATH_KEY; - static const char * const TIMESTAMP_START_KEY; - static const char * const TIMESTAMP_STOP_KEY; - static const char * const AUDIO_CODEC_KEY; - static const char * const VIDEO_CODEC_KEY; - static const char * const STATE_KEY; - static const char * const MISSED_KEY; - static const char * const DIRECTION_KEY; - - static const char * const MISSED_STRING; - static const char * const INCOMING_STRING; - static const char * const OUTGOING_STRING; - HistoryItem(const std::map<std::string, std::string> &args); - HistoryItem(std::istream &stream); - - bool hasPeerNumber() const; - - bool youngerThan(unsigned long otherTime) const; - - std::map<std::string, std::string> toMap() const; - void print(std::ostream &o) const; - bool operator< (const HistoryItem &other) const { - return timestampStart_ > other.timestampStart_; - } - - bool operator> (const HistoryItem &other) const { - return not (*this < other); - } - - private: - std::map<std::string, std::string> entryMap_; - unsigned long timestampStart_; // cached as we use this a lot, avoids string ops -}; - -std::ostream& operator << (std::ostream& o, const HistoryItem& item); - -} // namespace ring - -#endif // HISTORY_ITEM diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 790718c3ecf8061da2b55258ade850cc5d7c5900..aa5763af3094e321f95241b2888ddaa680a42a84 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -68,7 +68,6 @@ #include "audio/sound/audiofile.h" #include "audio/sound/dtmf.h" #include "audio/ringbufferpool.h" -#include "history/history.h" #include "manager.h" #ifdef RING_VIDEO @@ -162,7 +161,7 @@ ManagerImpl::ManagerImpl() : toneMutex_(), telephoneTone_(), audiofile_(), audioLayerMutex_(), waitingCalls_(), waitingCallsMutex_(), path_() , ringbufferpool_(new RingBufferPool) - , callFactory(), conferenceMap_(), history_() + , callFactory(), conferenceMap_() , accountFactory_(), ice_tf_() { // initialize random generator @@ -269,15 +268,13 @@ ManagerImpl::init(const std::string &config_file) } } - history_.load(preferences.getHistoryLimit()); - registerAccounts(); } void -ManagerImpl::setPath(const std::string &path) +ManagerImpl::setPath(const std::string&) { - history_.setPath(path); + // FIME: needed? } void @@ -297,9 +294,7 @@ ManagerImpl::finish() noexcept hangupCall(call->getCallId()); callFactory.clear(); - // Save accounts config and call's history saveConfig(); - saveHistory(); // Disconnect accounts, close link stacks and free allocated ressources unregisterAccounts(); @@ -408,14 +403,6 @@ ManagerImpl::outgoingCall(const std::string& preferred_account_id, detachParticipant(RingBufferPool::DEFAULT_ID); } - // try to reverse match the peer name using the cache - if (call->getDisplayName().empty()) { - const auto& name = history_.getNameFromHistory(call->getPeerNumber(), - call->getAccountId()); - const std::string pseudo_contact_name(name); - if (not pseudo_contact_name.empty()) - call->setDisplayName(pseudo_contact_name); - } switchCall(call); call->setConfId(conf_id); @@ -526,10 +513,8 @@ ManagerImpl::hangupCall(const std::string& callId) } try { - history_.addCall(call.get(), preferences.getHistoryLimit()); call->hangup(0); checkAudio(); - saveHistory(); } catch (const VoipLinkException &e) { RING_ERR("%s", e.what()); return false; @@ -1674,9 +1659,7 @@ ManagerImpl::peerHungupCall(Call& call) unsetCurrentCall(); } - history_.addCall(&call, preferences.getHistoryLimit()); call.peerHungup(); - saveHistory(); emitSignal<DRing::CallSignal::StateChange>(call_id, "HUNGUP"); @@ -2612,12 +2595,6 @@ ManagerImpl::getCallDetails(const std::string &callID) } } -std::vector<std::map<std::string, std::string> > -ManagerImpl::getHistory() -{ - return history_.getSerialized(); -} - std::vector<std::string> ManagerImpl::getCallList() const { @@ -2687,21 +2664,6 @@ ManagerImpl::getConferenceId(const std::string& callID) return ""; } -void -ManagerImpl::saveHistory() -{ - if (!history_.save()) - RING_ERR("Could not save history!"); - else - emitSignal<DRing::ConfigurationSignal::AccountsChanged>(); -} - -void -ManagerImpl::clearHistory() -{ - history_.clear(); -} - void ManagerImpl::startAudioDriverStream() { diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index 6ca8eb607f7cbd2127e33fb875402bd7cab6fa24..572af9ebca812799824e3b0ddc25859b39f6a48d 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -58,7 +58,6 @@ #include "audio/sound/tone.h" // for Tone::TONEID declaration #include "preferences.h" -#include "history/history.h" #include "noncopyable.h" namespace ring { @@ -865,9 +864,6 @@ class ManagerImpl { */ bool hasCurrentCall() const; - std::vector<std::map<std::string, std::string> > getHistory(); - void clearHistory(); - /** * Get an account pointer, looks for both SIP and IAX * @param accountID account ID to get @@ -902,8 +898,6 @@ class ManagerImpl { */ void registerAccounts(); - void saveHistory(); - /** * Suspends Ring's audio processing if no calls remain, allowing * other applications to resume audio. @@ -970,11 +964,6 @@ class ManagerImpl { // Map containing conference pointers ConferenceMap conferenceMap_; - /** - * To handle the persistent history - * TODO: move this to ConfigurationManager - */ - History history_; std::atomic_bool finished_ {false}; AccountFactory accountFactory_; diff --git a/daemon/src/sip/sipcall.cpp b/daemon/src/sip/sipcall.cpp index 2e06135ccc580772239cdd005682bdd1162a167a..1de9ce876cfc921ad80a86c2f85a1309ec111619 100644 --- a/daemon/src/sip/sipcall.cpp +++ b/daemon/src/sip/sipcall.cpp @@ -183,13 +183,6 @@ void SIPCall::setContactHeader(pj_str_t *contact) pj_strcpy(&contactHeader_, contact); } -std::map<std::string, std::string> -SIPCall::createHistoryEntry() const -{ - std::map<std::string, std::string> entry(Call::createHistoryEntry()); - return entry; -} - /** * Send a reINVITE inside an active dialog to modify its state * Local SDP session should be modified before calling this method diff --git a/daemon/src/sip/sipcall.h b/daemon/src/sip/sipcall.h index c9278e6135c2a8a95cb5ad5c6fe9b0db3a155ff1..a3499dd243ec06e12bc194b8801631e5d00425d3 100644 --- a/daemon/src/sip/sipcall.h +++ b/daemon/src/sip/sipcall.h @@ -196,10 +196,6 @@ class SIPCall : public Call private: NON_COPYABLE(SIPCall); - // override of Call::createHistoryEntry - std::map<std::string, std::string> - createHistoryEntry() const; - void stopAllMedia(); /**