Commit 55387924 authored by Alexandre Bourget's avatar Alexandre Bourget

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
......@@ -429,11 +429,7 @@ ManagerImpl::initRegisterAccounts()
if ( iter->second) {
iter->second->loadConfig();
if ( iter->second->isEnabled() ) {
if ( iter->second->init() ) {
iter->second->registerVoIPLink();
}
// init only the first account -- naahh..
//break;
iter->second->registerVoIPLink();
}
}
iter++;
......@@ -1713,6 +1709,26 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
}
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 */
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
}
......@@ -1729,10 +1745,6 @@ ManagerImpl::addAccount(const std::map< ::DBus::String, ::DBus::String >& detail
AccountID newAccountID = accountID.str();
/** @todo Verify the uniqueness, in case a program adds accounts, two in a row. */
setAccountDetails(accountID.str(), details);
saveConfig();
if (accountType == "SIP") {
newAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, newAccountID);
}
......@@ -1745,13 +1757,7 @@ ManagerImpl::addAccount(const std::map< ::DBus::String, ::DBus::String >& detail
}
_accountMap[newAccountID] = newAccount;
// Get it up and running...
newAccount->loadConfig();
if (newAccount->isEnabled()) {
if (newAccount->init()) {
newAccount->registerVoIPLink();
}
}
setAccountDetails(accountID.str(), details);
}
void
......
......@@ -236,6 +236,9 @@ public:
/**
* 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,
const std::map< ::DBus::String, ::DBus::String >& details );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment