Skip to content
Snippets Groups Projects
Commit 34e26e2a authored by Aline Gondim Santos's avatar Aline Gondim Santos Committed by Sébastien Blin
Browse files

plugin: change preference on-the-fly

Change-Id: I865275b95641aef48a694a375191862ad489ab94
parent b4898421
No related branches found
No related tags found
No related merge requests found
/* /**
* Copyright (C) 2020 Savoir-faire Linux Inc. * Copyright (C) 2020 Savoir-faire Linux Inc.
* *
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
...@@ -173,6 +173,15 @@ public: ...@@ -173,6 +173,15 @@ public:
return {{"name", mediaHandlerToggled_.name}, {"state", mediaHandlerToggled_.state}}; 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: private:
/** /**
* @brief notifyAVSubject * @brief notifyAVSubject
......
/* /**
* 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -450,6 +452,14 @@ JamiPluginManager::setPluginPreference(const std::string& rootPath, ...@@ -450,6 +452,14 @@ JamiPluginManager::setPluginPreference(const std::string& rootPath,
auto find = pluginPreferencesMap.find(key); auto find = pluginPreferencesMap.find(key);
if (find != pluginPreferencesMap.end()) { 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; pluginUserPreferencesMap[key] = value;
const std::string preferencesValuesFilePath = pluginPreferencesValuesFilePath(rootPath); const std::string preferencesValuesFilePath = pluginPreferencesValuesFilePath(rootPath);
std::ofstream fs(preferencesValuesFilePath, std::ios::binary); std::ofstream fs(preferencesValuesFilePath, std::ios::binary);
...@@ -475,8 +485,8 @@ JamiPluginManager::getPluginPreferencesValuesMap(const std::string& rootPath) ...@@ -475,8 +485,8 @@ JamiPluginManager::getPluginPreferencesValuesMap(const std::string& rootPath)
std::map<std::string, std::string> rmap; std::map<std::string, std::string> rmap;
std::vector<std::map<std::string, std::string>> preferences = getPluginPreferences(rootPath); std::vector<std::map<std::string, std::string>> preferences = getPluginPreferences(rootPath);
for (size_t i = 0; i < preferences.size(); i++) { for (auto& preference : preferences) {
rmap[preferences[i]["key"]] = preferences[i]["defaultValue"]; rmap[preference["key"]] = preference["defaultValue"];
} }
for (const auto& pair : getPluginUserPreferencesValuesMap(rootPath)) { for (const auto& pair : getPluginUserPreferencesValuesMap(rootPath)) {
......
/* /**
* Copyright (C) 2020 Savoir-faire Linux Inc. * Copyright (C) 2020 Savoir-faire Linux Inc.
* *
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
......
...@@ -42,17 +42,6 @@ public: ...@@ -42,17 +42,6 @@ public:
*/ */
std::string id() const { return id_;} std::string id() const { return id_;}
virtual void setId(const std::string& id) final {id_ = 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;
}
private: private:
std::string id_; std::string id_;
...@@ -68,5 +57,7 @@ public: ...@@ -68,5 +57,7 @@ public:
virtual void notifyAVFrameSubject(const StreamData& data, avSubjectPtr subject) = 0; virtual void notifyAVFrameSubject(const StreamData& data, avSubjectPtr subject) = 0;
virtual std::map<std::string, std::string> getCallMediaHandlerDetails() = 0; virtual std::map<std::string, std::string> getCallMediaHandlerDetails() = 0;
virtual void detach() = 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 } // namespace jami
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment