Commit 34e26e2a authored by Aline Gondim Santos's avatar Aline Gondim Santos Committed by Sébastien Blin

plugin: change preference on-the-fly

Change-Id: I865275b95641aef48a694a375191862ad489ab94
parent b4898421
/*
/**
* 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
......
/*
* 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)) {
......
/*
/**
* Copyright (C) 2020 Savoir-faire Linux Inc.
*
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment