Hide all accounts if "hidden" in their custom parameters.

This commit is contained in:
Julien Wadel 2022-07-12 17:48:54 +02:00
parent a51086c06a
commit 5ceda97c00
8 changed files with 20 additions and 11 deletions

View file

@ -990,7 +990,7 @@ void App::openAppAfterInit (bool mustBeIconified) {
#endif // ifndef __APPLE__
// Display Assistant if it does not exist proxy config.
if (coreManager->getCore()->getAccountList().empty())
if (coreManager->getAccountList().empty())
QMetaObject::invokeMethod(mainWindow, "setView", Q_ARG(QVariant, Constants::AssistantViewName), Q_ARG(QVariant, QString("")), Q_ARG(QVariant, QString("")));
#ifdef ENABLE_UPDATE_CHECK

View file

@ -531,7 +531,7 @@ void CallModel::accept (bool withVideo) {
params->enableVideo(withVideo);
setRecordFile(params);
auto localAddress = mCall->getCallLog()->getLocalAddress();
for(auto account : core->getAccountList()){
for(auto account : coreManager->getAccountList()){
if( account->getParams()->getIdentityAddress()->weakEqual(localAddress)){
params->setAccount(account);
break;

View file

@ -65,7 +65,7 @@ void CoreHandlers::onAuthenticationRequested (
) {
Q_UNUSED(method)
if( authInfo ) {
auto accounts = core->getAccountList();
auto accounts = CoreManager::getInstance()->getAccountList();
auto itAccount = accounts.begin() ;
std::string username = authInfo->getUsername();
std::string domain = authInfo->getDomain();

View file

@ -307,7 +307,7 @@ void CoreManager::migrate () {
.arg(rcVersion).arg(Constants::RcVersionCurrent);
bool setlimeServerUrl = false;
for(const auto &account : mCore->getAccountList()){
for(const auto &account : getAccountList()){
auto params = account->getParams();
if( params->getDomain() == Constants::LinphoneDomain) {
auto newParams = params->clone();
@ -362,6 +362,13 @@ int CoreManager::getMissedCallCountFromLocal( const QString &localAddress)const{
return mEventCountNotifier ? mEventCountNotifier->getMissedCallCountFromLocal(localAddress) : 0;
}
std::list<std::shared_ptr<linphone::Account>> CoreManager::getAccountList()const{
std::list<std::shared_ptr<linphone::Account>> accounts;
for(auto account : mCore->getAccountList())
if( account->getCustomParam("hidden") != "1")
accounts.push_back(account);
return accounts;
}
// -----------------------------------------------------------------------------
void CoreManager::startIterate(){

View file

@ -159,6 +159,8 @@ public:
int getMissedCallCount(const QString &peerAddress, const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
int getMissedCallCountFromLocal(const QString &localAddress) const;// Get missed call count from a chat (useful for showing bubbles on Timelines)
std::list<std::shared_ptr<linphone::Account>> getAccountList()const;
static bool isInstanciated(){return mInstance!=nullptr;}
Q_INVOKABLE bool isLastRemoteProvisioningGood();

View file

@ -112,7 +112,7 @@ bool AccountSettingsModel::addOrUpdateAccount (std::shared_ptr<linphone::Account
CoreManager *coreManager = CoreManager::getInstance();
shared_ptr<linphone::Core> core = coreManager->getCore();
list<shared_ptr<linphone::Account>> accounts = core->getAccountList();
list<shared_ptr<linphone::Account>> accounts = coreManager->getAccountList();
if(!account)
account = core->createAccount(accountParams);
if (account->setParams(accountParams) == -1) {
@ -229,7 +229,7 @@ void AccountSettingsModel::setDefaultAccountFromSipAddress (const QString &sipAd
return;
}
for (const auto &account : core->getAccountList())
for (const auto &account : CoreManager::getInstance()->getAccountList())
if (account->getParams()->getIdentityAddress()->weakEqual(address)) {
setDefaultAccount(account);
return;
@ -241,7 +241,7 @@ void AccountSettingsModel::removeAccount (const shared_ptr<linphone::Account> &a
CoreManager *coreManager = CoreManager::getInstance();
std::shared_ptr<linphone::Account> newAccount = nullptr;
std::list<std::shared_ptr<linphone::Account>> allAccounts = coreManager->getCore()->getAccountList();
std::list<std::shared_ptr<linphone::Account>> allAccounts = coreManager->getAccountList();
if( account == coreManager->getCore()->getDefaultAccount()){
for(auto nextAccount : allAccounts){
if( nextAccount != account){
@ -391,7 +391,7 @@ bool AccountSettingsModel::addOrUpdateAccount (
QString sipAddress = data["sipAddress"].toString();
shared_ptr<linphone::Address> address = CoreManager::getInstance()->getCore()->interpretUrl(sipAddress.toStdString());
for (const auto &databaseAccount : CoreManager::getInstance()->getCore()->getAccountList())
for (const auto &databaseAccount : CoreManager::getInstance()->getAccountList())
if (databaseAccount->getParams()->getIdentityAddress()->weakEqual(address)) {
account = databaseAccount;
}
@ -513,7 +513,7 @@ QVariantList AccountSettingsModel::getAccounts () const {
accounts << account;
}
for (const auto &account : core->getAccountList()) {
for (const auto &account : CoreManager::getInstance()->getAccountList()) {
QVariantMap accountMap;
accountMap["sipAddress"] = Utils::coreStringToAppString(account->getParams()->getIdentityAddress()->asStringUriOnly());
accountMap["fullSipAddress"] = Utils::coreStringToAppString(account->getParams()->getIdentityAddress()->asString());

View file

@ -1331,7 +1331,7 @@ void SettingsModel::configureRlsUri () {
// Set rls uri if necessary.
const string domain = getRlsUriDomain();
for (const auto &account : CoreManager::getInstance()->getCore()->getAccountList())
for (const auto &account : CoreManager::getInstance()->getAccountList())
if (account->getParams()->getDomain() == domain) {
mConfig->setString("sip", "rls_uri", Constants::DefaultRlsUri);
return;

View file

@ -147,7 +147,7 @@ std::shared_ptr<linphone::Address> Utils::getMatchingLocalAddress(std::shared_pt
QVector<std::shared_ptr<linphone::Address> > addresses;
// Get default account
addresses.push_back(CoreManager::getInstance()->getCore()->createPrimaryContactParsed());
auto accounts = CoreManager::getInstance()->getCore()->getAccountList();
auto accounts = CoreManager::getInstance()->getAccountList();
foreach(auto account, accounts)
addresses.push_back(account->getParams()->getIdentityAddress()->clone());
foreach(auto address, addresses){