Skip to content
Snippets Groups Projects
Commit 55387924 authored by Alexandre Bourget's avatar Alexandre Bourget
Browse files

Automatic update of registration when receiving new ACCOUNT DETAILS.

It will register if it wasn't, and was now set to 'Enabled',

It will unregister if it was already registered, and we switched to 'Disabled'
parent dd407a6b
No related branches found
No related tags found
No related merge requests found
...@@ -429,12 +429,8 @@ ManagerImpl::initRegisterAccounts() ...@@ -429,12 +429,8 @@ ManagerImpl::initRegisterAccounts()
if ( iter->second) { if ( iter->second) {
iter->second->loadConfig(); iter->second->loadConfig();
if ( iter->second->isEnabled() ) { if ( iter->second->isEnabled() ) {
if ( iter->second->init() ) {
iter->second->registerVoIPLink(); iter->second->registerVoIPLink();
} }
// init only the first account -- naahh..
//break;
}
} }
iter++; iter++;
} }
...@@ -1713,6 +1709,26 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID, ...@@ -1713,6 +1709,26 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
} }
saveConfig(); saveConfig();
/*
* register if it was just enabled, and we hadn't registered
* unregister if it was enabled/registered, and we want it closed
*/
Account* acc = getAccount(accountID);
acc->loadConfig();
if (acc->isEnabled()) {
// Verify we aren't already registered, then register
if (acc->getRegistrationState() == VoIPLink::Unregistered) {
acc->registerVoIPLink();
}
} else {
// Verify we are already registered, then unregister
if (acc->getRegistrationState() == VoIPLink::Registered) {
acc->unregisterVoIPLink();
}
}
/** @todo Make the daemon use the new settings */ /** @todo Make the daemon use the new settings */
if (_dbus) _dbus->getConfigurationManager()->accountsChanged(); if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
} }
...@@ -1729,10 +1745,6 @@ ManagerImpl::addAccount(const std::map< ::DBus::String, ::DBus::String >& detail ...@@ -1729,10 +1745,6 @@ ManagerImpl::addAccount(const std::map< ::DBus::String, ::DBus::String >& detail
AccountID newAccountID = accountID.str(); AccountID newAccountID = accountID.str();
/** @todo Verify the uniqueness, in case a program adds accounts, two in a row. */ /** @todo Verify the uniqueness, in case a program adds accounts, two in a row. */
setAccountDetails(accountID.str(), details);
saveConfig();
if (accountType == "SIP") { if (accountType == "SIP") {
newAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, newAccountID); newAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, newAccountID);
} }
...@@ -1745,13 +1757,7 @@ ManagerImpl::addAccount(const std::map< ::DBus::String, ::DBus::String >& detail ...@@ -1745,13 +1757,7 @@ ManagerImpl::addAccount(const std::map< ::DBus::String, ::DBus::String >& detail
} }
_accountMap[newAccountID] = newAccount; _accountMap[newAccountID] = newAccount;
// Get it up and running... setAccountDetails(accountID.str(), details);
newAccount->loadConfig();
if (newAccount->isEnabled()) {
if (newAccount->init()) {
newAccount->registerVoIPLink();
}
}
} }
void void
......
...@@ -236,6 +236,9 @@ public: ...@@ -236,6 +236,9 @@ public:
/** /**
* Save the details of an existing account, given the account ID * Save the details of an existing account, given the account ID
*
* This will load the configuration map with the given data.
* It will also register/unregister links where the 'Enabled' switched.
*/ */
void setAccountDetails( const ::DBus::String& accountID, void setAccountDetails( const ::DBus::String& accountID,
const std::map< ::DBus::String, ::DBus::String >& details ); const std::map< ::DBus::String, ::DBus::String >& details );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment