diff --git a/src/client/configurationmanager.cpp b/src/client/configurationmanager.cpp index d2a2179e10b..b98dcbd8912 100644 --- a/src/client/configurationmanager.cpp +++ b/src/client/configurationmanager.cpp @@ -243,9 +243,9 @@ setAccountActive(const std::string& accountId, bool enable, bool shutdownConnect } void -loadAccountAndConversation(const std::string& accountID, const std::string& convID) +loadAccountAndConversation(const std::string& accountId, bool loadAll, const std::string& convId) { - jami::Manager::instance().loadAccountAndConversation(accountID, convID); + jami::Manager::instance().loadAccountAndConversation(accountId, loadAll, convId); } void diff --git a/src/jami/configurationmanager_interface.h b/src/jami/configurationmanager_interface.h index 7bb70e52881..d0e9f3eb9d6 100644 --- a/src/jami/configurationmanager_interface.h +++ b/src/jami/configurationmanager_interface.h @@ -61,8 +61,9 @@ LIBJAMI_PUBLIC void setAccountDetails(const std::string& accountId, LIBJAMI_PUBLIC void setAccountActive(const std::string& accountId, bool active, bool shutdownConnections = false); -LIBJAMI_PUBLIC void loadAccountAndConversation(const std::string& accountID, - const std::string& convID); +LIBJAMI_PUBLIC void loadAccountAndConversation(const std::string& accountId, + bool loadAll, + const std::string& convId); LIBJAMI_PUBLIC std::map getAccountTemplate(const std::string& accountType); LIBJAMI_PUBLIC std::string addAccount(const std::map& details, const std::string& accountId = {}); diff --git a/src/manager.cpp b/src/manager.cpp index 267f02281b0..b4abeceb1ee 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -3056,9 +3056,11 @@ Manager::setAccountActive(const std::string& accountID, bool active, bool shutdo } void -Manager::loadAccountAndConversation(const std::string& accountID, const std::string& convID) +Manager::loadAccountAndConversation(const std::string& accountId, + bool loadAll, + const std::string& convId) { - auto account = getAccount(accountID); + auto account = getAccount(accountId); if (!account && !autoLoad) { /* With the LIBJAMI_FLAG_NO_AUTOLOAD flag active, accounts are not @@ -3068,9 +3070,9 @@ Manager::loadAccountAndConversation(const std::string& accountID, const std::str account creation now occurs here in response to a received notification. */ auto accountBaseDir = fileutils::get_data_dir(); - auto configFile = accountBaseDir / accountID / "config.yml"; + auto configFile = accountBaseDir / accountId / "config.yml"; try { - if (account = accountFactory.createAccount(JamiAccount::ACCOUNT_TYPE, accountID)) { + if (account = accountFactory.createAccount(JamiAccount::ACCOUNT_TYPE, accountId)) { account->enableAutoLoadConversations(false); auto configNode = YAML::LoadFile(configFile.string()); auto config = account->buildConfig(); @@ -3082,8 +3084,9 @@ Manager::loadAccountAndConversation(const std::string& accountID, const std::str return; } } + if (!account) { - JAMI_WARN("Could not load account %s", accountID.c_str()); + JAMI_WARN("Could not load account %s", accountId.c_str()); return; } if (auto jamiAcc = std::dynamic_pointer_cast(account)) { @@ -3092,8 +3095,12 @@ Manager::loadAccountAndConversation(const std::string& accountID, const std::str jamiAcc->doRegister(); if (auto convModule = jamiAcc->convModule()) { convModule->reloadRequests(); + if (loadAll) { + convModule->loadConversations(); + } else { + jamiAcc->loadConversation(convId); + } } - jamiAcc->loadConversation(convID); } } diff --git a/src/manager.h b/src/manager.h index efb6bbbea4b..89c2dbbc8ff 100644 --- a/src/manager.h +++ b/src/manager.h @@ -445,7 +445,9 @@ class LIBJAMI_TESTABLE Manager const std::map& details); void setAccountActive(const std::string& accountID, bool active, bool shutdownConnections); - void loadAccountAndConversation(const std::string& accountID, const std::string& convID); + void loadAccountAndConversation(const std::string& accountId, + bool loadAll, + const std::string& convId); std::mt19937_64 getSeededRandomEngine();