Skip to content
Snippets Groups Projects
Commit 3448725d authored by Pierre Lespagnol's avatar Pierre Lespagnol
Browse files

conference: add account preference to set local moderators

Change-Id: Ia5ba79e370642738df593493a6d1da52a9b1d9b8
parent 67d85f86
No related branches found
No related tags found
No related merge requests found
......@@ -1774,5 +1774,16 @@
<arg type="as" name="list" direction="out">
</arg>
</method>
<method name="enableLocalModerators" tp:name-for-bindings="enableLocalModerators">
<tp:added version="9.9.0"/>
<arg type="s" name="accountID" direction="in"/>
<arg type="b" name="isModEnabled" direction="in"/>
</method>
<method name="isLocalModeratorsEnabled" tp:name-for-bindings="isLocalModeratorsEnabled">
<tp:added version="9.9.0"/>
<arg type="s" name="accountID" direction="in"/>
<arg type="b" name="isModEnabled" direction="out"/>
</method>
</interface>
</node>
......@@ -764,3 +764,16 @@ DBusConfigurationManager::getDefaultModerators(const std::string& accountID) ->
return DRing::getDefaultModerators(accountID);
}
void
DBusConfigurationManager::enableLocalModerators(const std::string& accountID,
const bool& isModEnabled)
{
return DRing::enableLocalModerators(accountID, isModEnabled);
}
bool
DBusConfigurationManager::isLocalModeratorsEnabled(const std::string& accountID)
{
return DRing::isLocalModeratorsEnabled(accountID);
}
......@@ -179,6 +179,8 @@ class DRING_PUBLIC DBusConfigurationManager :
void setAudioMeterState(const std::string& id, const bool& state);
void setDefaultModerator(const std::string& accountID, const std::string& uri, const bool& state);
std::vector<std::string> getDefaultModerators(const std::string& accountID);
void enableLocalModerators(const std::string& accountID, const bool& isModEnabled);
bool isLocalModeratorsEnabled(const std::string& accountID);
};
#endif // __RING_DBUSCONFIGURATIONMANAGER_H__
......@@ -232,6 +232,8 @@ void setAudioMeterState(const std::string& id, bool state);
void setDefaultModerator(const std::string& accountID, const std::string& peerURI, bool state);
std::vector<std::string> getDefaultModerators(const std::string& accountID);
void enableLocalModerators(const std::string& accountID, bool isModEnabled);
bool isLocalModeratorsEnabled(const std::string& accountID);
}
......
......@@ -219,6 +219,8 @@ void setAudioMeterState(const std::string& id, bool state);
void setDefaultModerator(const std::string& accountID, const std::string& peerURI, bool state);
std::vector<std::string> getDefaultModerators(const std::string& accountID);
void enableLocalModerators(const std::string& accountID, bool isModEnabled);
bool isLocalModeratorsEnabled(const std::string& accountID);
}
class ConfigurationCallback {
......
......@@ -88,6 +88,7 @@ const char* const Account::UPNP_ENABLED_KEY = "upnpEnabled";
const char* const Account::ACTIVE_CODEC_KEY = "activeCodecs";
const std::string Account::DEFAULT_USER_AGENT = Account::setDefaultUserAgent();
const char* const Account::DEFAULT_MODERATORS_KEY = "defaultModerators";
const char* const Account::LOCAL_MODERATORS_ENABLED_KEY = "localModeratorsEnabled";
#ifdef __ANDROID__
constexpr const char* const DEFAULT_RINGTONE_PATH
......@@ -115,6 +116,7 @@ Account::Account(const std::string& accountID)
, customUserAgent_("")
, hasCustomUserAgent_(false)
, mailBox_()
, localModeratorsEnabled_(true)
{
// Initialize the codec order, used when creating a new account
loadDefaultCodecs();
......@@ -239,6 +241,7 @@ Account::serialize(YAML::Emitter& out) const
out << YAML::Key << HOSTNAME_KEY << YAML::Value << hostname_;
out << YAML::Key << UPNP_ENABLED_KEY << YAML::Value << upnpEnabled_;
out << YAML::Key << DEFAULT_MODERATORS_KEY << YAML::Value << string_join(defaultModerators_);
out << YAML::Key << LOCAL_MODERATORS_ENABLED_KEY << YAML::Value << localModeratorsEnabled_;
}
void
......@@ -293,6 +296,7 @@ Account::unserialize(const YAML::Node& node)
std::string defMod;
parseValueOptional(node, DEFAULT_MODERATORS_KEY, defMod);
defaultModerators_ = string_split_set(defMod);
parseValueOptional(node, LOCAL_MODERATORS_ENABLED_KEY, localModeratorsEnabled_);
}
void
......@@ -320,6 +324,7 @@ Account::setAccountDetails(const std::map<std::string, std::string>& details)
enableUpnp(upnpEnabled_ && isEnabled());
auto defMod = string_join(defaultModerators_);
parseString(details, Conf::CONFIG_DEFAULT_MODERATORS, defMod);
parseBool(details, Conf::CONFIG_LOCAL_MODERATORS_ENABLED, localModeratorsEnabled_);
}
std::map<std::string, std::string>
......@@ -340,7 +345,8 @@ Account::getAccountDetails() const
{Conf::CONFIG_RINGTONE_ENABLED, ringtoneEnabled_ ? TRUE_STR : FALSE_STR},
{Conf::CONFIG_RINGTONE_PATH, ringtonePath_},
{Conf::CONFIG_UPNP_ENABLED, upnpEnabled_ ? TRUE_STR : FALSE_STR},
{Conf::CONFIG_DEFAULT_MODERATORS, string_join(defaultModerators_)}};
{Conf::CONFIG_DEFAULT_MODERATORS, string_join(defaultModerators_)},
{Conf::CONFIG_LOCAL_MODERATORS_ENABLED, localModeratorsEnabled_ ? TRUE_STR : FALSE_STR}};
}
std::map<std::string, std::string>
......
......@@ -319,6 +319,9 @@ public:
void addDefaultModerator(const std::string& peerURI);
void removeDefaultModerator(const std::string& peerURI);
bool isLocalModeratorsEnabled() const { return localModeratorsEnabled_; }
void enableLocalModerators(bool isModEnabled) { localModeratorsEnabled_ = isModEnabled; }
public: // virtual methods that has to be implemented by concrete classes
/**
* This method is called to request removal of possible account traces on the system,
......@@ -391,6 +394,7 @@ protected:
static const char* const PROXY_PUSH_TOKEN_KEY;
static const char* const ACTIVE_CODEC_KEY;
static const char* const DEFAULT_MODERATORS_KEY;
static const char* const LOCAL_MODERATORS_ENABLED_KEY;
static const std::string DEFAULT_USER_AGENT;
......@@ -509,6 +513,7 @@ protected:
std::unique_ptr<jami::upnp::Controller> upnp_;
std::set<std::string> defaultModerators_ {};
bool localModeratorsEnabled_;
/**
* private account codec searching functions
......
......@@ -70,6 +70,7 @@ static const char* const CONFIG_PUBLISHED_PORT = "Account.publishedPort";
static const char* const CONFIG_PUBLISHED_ADDRESS = "Account.publishedAddress";
static const char* const CONFIG_UPNP_ENABLED = "Account.upnpEnabled";
static const char* const CONFIG_DEFAULT_MODERATORS = "Account.defaultModerator";
static const char* const CONFIG_LOCAL_MODERATORS_ENABLED = "Account.localModeratorEnabled";
// SIP specific parameters
static const char* const CONFIG_STUN_SERVER = "STUN.server";
......
......@@ -1092,4 +1092,16 @@ getDefaultModerators(const std::string& accountID)
return jami::Manager::instance().getDefaultModerators(accountID);
}
void
enableLocalModerators(const std::string& accountID, bool isModEnabled)
{
jami::Manager::instance().enableLocalModerators(accountID, isModEnabled);
}
bool
isLocalModeratorsEnabled(const std::string& accountID)
{
return jami::Manager::instance().isLocalModeratorsEnabled(accountID);
}
} // namespace DRing
......@@ -53,16 +53,6 @@ Conference::Conference()
{
JAMI_INFO("Create new conference %s", id_.c_str());
// TODO: For now, add all accounts on the same device as
// conference master. In the future, this should be
// retrieven with another way
auto accounts = jami::Manager::instance().getAllAccounts<JamiAccount>();
for (const auto& account : accounts) {
if (!account)
continue;
moderators_.emplace(account->getUsername());
}
#ifdef ENABLE_VIDEO
getVideoMixer()->setOnSourcesUpdated([this](std::vector<video::SourceInfo>&& infos) {
runOnMainThread([w = weak(), infos = std::move(infos)] {
......@@ -185,14 +175,23 @@ Conference::add(const std::string& participant_id)
participantsMuted_.emplace(string_remove_suffix(call->getPeerNumber(), '@'));
}
}
// Add defined moderators for the account link to the call
if (auto call = Manager::instance().callFactory.getCall<SIPCall>(participant_id)) {
auto w = call->getAccount();
auto account = w.lock();
if (account) {
// Add defined moderators for the account link to the call
for (const auto& mod : account->getDefaultModerators()) {
moderators_.emplace(mod);
}
// Check for localModeratorEnabled preference
if (account->isLocalModeratorsEnabled() && not localModAdded_) {
auto accounts = jami::Manager::instance().getAllAccounts<JamiAccount>();
for (const auto& account : accounts) {
moderators_.emplace(account->getUsername());
}
localModAdded_ = true;
}
}
}
#ifdef ENABLE_VIDEO
......
......@@ -288,6 +288,8 @@ private:
bool isHost(std::string_view uri) const;
bool audioMuted_ {false};
bool videoMuted_ {false};
bool localModAdded_ {false};
};
} // namespace jami
......@@ -152,6 +152,7 @@ constexpr static const char MANAGER_USERNAME[] = "Account.managerUsername";
constexpr static const char BOOTSTRAP_LIST_URL[] = "Account.bootstrapListUrl";
constexpr static const char DHT_PROXY_LIST_URL[] = "Account.dhtProxyListUrl";
constexpr static const char DEFAULT_MODERATORS[] = "Account.defaultModerators";
constexpr static const char LOCAL_MODERATORS_ENABLED[] = "Account.localModeratorsEnabled";
namespace Audio {
......
......@@ -298,6 +298,17 @@ DRING_PUBLIC void setDefaultModerator(const std::string& accountID,
*/
DRING_PUBLIC std::vector<std::string> getDefaultModerators(const std::string& accountID);
/**
* Enable/disable local moderators for conferences
*/
DRING_PUBLIC void enableLocalModerators(const std::string& accountID,
bool isModEnabled);
/**
* Get local moderators state
*/
DRING_PUBLIC bool isLocalModeratorsEnabled(const std::string& accountID);
struct DRING_PUBLIC AudioSignal
{
struct DRING_PUBLIC DeviceEvent
......
......@@ -3301,4 +3301,27 @@ Manager::getDefaultModerators(const std::string& accountID)
return std::vector<std::string>(set.begin(), set.end());
}
void
Manager::enableLocalModerators(const std::string& accountID, bool isModEnabled)
{
auto acc = getAccount(accountID);
if(!acc) {
JAMI_ERR("Fail to set local moderators, account %s not found", accountID.c_str());
return;
}
acc->enableLocalModerators(isModEnabled);
saveConfig(acc);
}
bool
Manager::isLocalModeratorsEnabled(const std::string& accountID)
{
auto acc = getAccount(accountID);
if(!acc) {
JAMI_ERR("Fail to get local moderators, account %s not found", accountID.c_str());
return true; // Default value
}
return acc->isLocalModeratorsEnabled();
}
} // namespace jami
......@@ -942,6 +942,9 @@ public:
const std::string& peerURI,
bool state);
std::vector<std::string> getDefaultModerators(const std::string& accountID);
void enableLocalModerators(const std::string& accountID, bool state);
bool isLocalModeratorsEnabled(const std::string& accountID);
private:
Manager();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment