diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 4ca594b6669462ec2bbdcbcbb18248856714c1d1..8169663785ac5897a818b07c599ce79d9d5cc460 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -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 diff --git a/src/managerimpl.h b/src/managerimpl.h index 0e45e2c21b7ade5e7cc612864a0365ceb8eacd82..bb7e0ba3656acb5dca31a56aaf5e0fb4ea16ddfe 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -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 );