diff --git a/src/client/configurationmanager.cpp b/src/client/configurationmanager.cpp index d2a2179e10bd5c3b635dfcb70a784d2fb54d002d..b98dcbd89123bb83dae8b3a14b6784110edf2004 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 7bb70e52881f2d122988d4ade9b4dd1b0d908cc3..d0e9f3eb9d6ad88de51d3e17708f29490308abf9 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<std::string, std::string> getAccountTemplate(const std::string& accountType); LIBJAMI_PUBLIC std::string addAccount(const std::map<std::string, std::string>& details, const std::string& accountId = {}); diff --git a/src/manager.cpp b/src/manager.cpp index 267f02281b0c9594d1b992fdff8c8b5641fc5758..b4abeceb1ee2e7133a94dc736310088ef594df85 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<JamiAccount>(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 efb6bbbea4b7bc2f1db63f5344c8c20babd5a07e..89c2dbbc8fff33563ac8bb0859b5f157d19b5897 100644 --- a/src/manager.h +++ b/src/manager.h @@ -445,7 +445,9 @@ public: const std::map<std::string, ::std::string>& 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();