diff --git a/src/plugin/callservicesmanager.h b/src/plugin/callservicesmanager.h index dfc328709193e78c5b72f9626e0af86d712150c9..2073e9c7ed3efa672392e9d24d8e3df2a1bf4b6a 100644 --- a/src/plugin/callservicesmanager.h +++ b/src/plugin/callservicesmanager.h @@ -1,4 +1,4 @@ -/* +/** * Copyright (C) 2020 Savoir-faire Linux Inc. * * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> @@ -173,6 +173,15 @@ public: return {{"name", mediaHandlerToggled_.name}, {"state", mediaHandlerToggled_.state}}; } + void setPreference(const std::string& key, const std::string& value, const std::string& scopeStr) + { + for (auto& pair : callMediaHandlers) { + if (pair.second && scopeStr.find(pair.second->getCallMediaHandlerDetails()["name"]) != std::string::npos) { + pair.second->setPreferenceAttribute(key, value); + } + } + } + private: /** * @brief notifyAVSubject diff --git a/src/plugin/jamipluginmanager.cpp b/src/plugin/jamipluginmanager.cpp index bd45e5bfd1a44ca71e9019a351bd0132be09f695..207f102745e8a2660c2c1508aca5aa68b1d1386a 100644 --- a/src/plugin/jamipluginmanager.cpp +++ b/src/plugin/jamipluginmanager.cpp @@ -1,5 +1,7 @@ -/* - * Copyright (C) 2004-2020 Savoir-faire Linux Inc. +/** + * Copyright (C) 2020 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 @@ -450,6 +452,14 @@ JamiPluginManager::setPluginPreference(const std::string& rootPath, auto find = pluginPreferencesMap.find(key); if (find != pluginPreferencesMap.end()) { + std::vector<std::map<std::string, std::string>> preferences = getPluginPreferences(rootPath); + for (auto& preference : preferences) { + if (!preference["key"].compare(key)) { + csm_.setPreference(key, value, preference["scope"]); + break; + } + } + pluginUserPreferencesMap[key] = value; const std::string preferencesValuesFilePath = pluginPreferencesValuesFilePath(rootPath); std::ofstream fs(preferencesValuesFilePath, std::ios::binary); @@ -475,8 +485,8 @@ JamiPluginManager::getPluginPreferencesValuesMap(const std::string& rootPath) std::map<std::string, std::string> rmap; std::vector<std::map<std::string, std::string>> preferences = getPluginPreferences(rootPath); - for (size_t i = 0; i < preferences.size(); i++) { - rmap[preferences[i]["key"]] = preferences[i]["defaultValue"]; + for (auto& preference : preferences) { + rmap[preference["key"]] = preference["defaultValue"]; } for (const auto& pair : getPluginUserPreferencesValuesMap(rootPath)) { diff --git a/src/plugin/jamipluginmanager.h b/src/plugin/jamipluginmanager.h index a7017e4a6277398d3349ada50c8cd005b1b59801..fb37398d38c75e3450c9168ab104088e583834ae 100644 --- a/src/plugin/jamipluginmanager.h +++ b/src/plugin/jamipluginmanager.h @@ -1,4 +1,4 @@ -/* +/** * Copyright (C) 2020 Savoir-faire Linux Inc. * * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> diff --git a/src/plugin/mediahandler.h b/src/plugin/mediahandler.h index c31a9009f68751cba6eb50f64392cf2cfdd9b546..422a7991348f13d31512194dfe49ab427ba85d59 100644 --- a/src/plugin/mediahandler.h +++ b/src/plugin/mediahandler.h @@ -40,19 +40,8 @@ public: * The id is the path of the plugin that created this MediaHandler * @return */ - std::string id() const { return id_; } - virtual void setId(const std::string& id) final { id_ = id; } - /** - * @brief setPreferenceAttribute - * Sets a preference attribute to the new value - * @param key - * @param value - */ - virtual void setPreferenceAttribute(const std::string& key, const std::string& value) - { - (void) key; - (void) value; - } + std::string id() const { return id_;} + virtual void setId(const std::string& id) final {id_ = id;} private: std::string id_; @@ -68,5 +57,7 @@ public: virtual void notifyAVFrameSubject(const StreamData& data, avSubjectPtr subject) = 0; virtual std::map<std::string, std::string> getCallMediaHandlerDetails() = 0; virtual void detach() = 0; + virtual void setPreferenceAttribute(const std::string& key, const std::string& value) = 0; + virtual bool preferenceMapHasKey(const std::string& key) = 0; }; } // namespace jami