Skip to content
Snippets Groups Projects
Commit 5b1433be authored by Jérémy Quentin's avatar Jérémy Quentin
Browse files

[#1426] Daemon crashes when get alsa plugin

[#1459] The first account is reset when accountsChanged
parent 53f37bc5
No related branches found
Tags
No related merge requests found
......@@ -219,11 +219,12 @@ void Account::setAccountDetail(QString param, QString val)
void Account::setAccountId(QString id)
{
qDebug() << "accountId = " << accountId;
if (! isNew())
{
qDebug() << "Error : setting AccountId of an existing account.";
}
*accountId = id;
accountId = new QString(id);
}
//Operators
......
......@@ -2,11 +2,14 @@
#include "sflphone_const.h"
#include "configurationmanager_interface_singleton.h"
QString AccountList::firstAccount = QString();
//Constructors
AccountList::AccountList(QStringList & _accountIds)
{
firstAccount = NULL;
// firstAccount = QString();
accounts = new QVector<Account *>();
for (int i = 0; i < _accountIds.size(); ++i){
(*accounts) += Account::buildExistingAccountFromId(_accountIds[i]);
......@@ -15,7 +18,7 @@ AccountList::AccountList(QStringList & _accountIds)
AccountList::AccountList()
{
firstAccount = NULL;
// firstAccount = QString();
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
//ask for the list of accounts ids to the configurationManager
QStringList accountIds = configurationManager.getAccountList().value();
......@@ -43,12 +46,14 @@ void AccountList::update()
QVector<Account *> AccountList::registeredAccounts() const
{
qDebug() << "registeredAccounts";
QVector<Account *> registeredAccounts;
Account * current;
for (int i = 0; i < accounts->count(); ++i){
current = (*accounts)[i];
if(current->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED)
{
qDebug() << current->getAlias() << " : " << current;
registeredAccounts.append(current);
}
}
......@@ -57,9 +62,10 @@ QVector<Account *> AccountList::registeredAccounts() const
Account * AccountList::firstRegisteredAccount() const
{
if(firstAccount != NULL)
Account * first = getAccountById(firstAccount);
if(first && (first->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED))
{
return firstAccount;
return first;
}
Account * current;
for (int i = 0; i < accounts->count(); ++i){
......@@ -74,7 +80,7 @@ Account * AccountList::firstRegisteredAccount() const
void AccountList::setAccountFirst(Account * account)
{
firstAccount = account;
firstAccount = account->getAccountId();
}
AccountList::~AccountList()
......@@ -88,7 +94,7 @@ QVector<Account *> & AccountList::getAccounts()
return *accounts;
}
Account * AccountList::getAccountById(QString & id)
Account * AccountList::getAccountById(const QString & id) const
{
for (int i = 0; i < accounts->size(); ++i)
{
......
......@@ -11,7 +11,7 @@ class AccountList{
private:
QVector<Account *> * accounts;
Account * firstAccount;
static QString firstAccount;
public:
......@@ -22,7 +22,7 @@ public:
//Getters
QVector<Account *> & getAccounts();
Account * getAccountById(QString & id);
Account * getAccountById(const QString & id) const;
QVector<Account *> getAccountByState(QString & state);
Account * getAccountByItem(QListWidgetItem * item);
int size();
......
......@@ -43,7 +43,7 @@ ConfigurationDialog::ConfigurationDialog(sflphone_kdeView *parent) : QDialog(par
//TODO ajouter les items de l'interface audio ici avec les constantes
accountsChangedEnableWarning = true;
// accountsChangedEnableWarning = true;
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
connect(&configurationManager, SIGNAL(accountsChanged()),
......@@ -117,8 +117,9 @@ void ConfigurationDialog::loadOptions()
//////////////////////
//Audio Interface settings
comboBox_interface->setCurrentIndex(configurationManager.getAudioManager());
stackedWidget_interfaceSpecificSettings->setCurrentIndex(configurationManager.getAudioManager());
int audioManager = configurationManager.getAudioManager();
comboBox_interface->setCurrentIndex(audioManager);
stackedWidget_interfaceSpecificSettings->setCurrentIndex(audioManager);
//ringtones settings
checkBox_ringtones->setCheckState(configurationManager.isRingtoneEnabled() ? Qt::Checked : Qt::Unchecked);
......@@ -134,19 +135,26 @@ void ConfigurationDialog::loadOptions()
comboBox1_alsaPlugin->addItems(pluginList);
comboBox1_alsaPlugin->setCurrentIndex(comboBox1_alsaPlugin->findText(configurationManager.getCurrentAudioOutputPlugin()));
comboBox2_in->clear();
comboBox3_out->clear();
if(audioManager == ALSA)
{
QStringList devices = configurationManager.getCurrentAudioDevicesIndex();
int inputDevice = devices[1].toInt();
comboBox2_in->clear();
// QStringList inputDeviceList = configurationManager.getAudioInputDeviceList();
// comboBox2_in->addItems(inputDeviceList);
qDebug() << "inputDevice = " << devices[1];
QStringList inputDeviceList = configurationManager.getAudioInputDeviceList();
comboBox2_in->addItems(inputDeviceList);
comboBox2_in->setCurrentIndex(inputDevice);
int outputDevice = devices[0].toInt();
comboBox3_out->clear();
// QStringList outputDeviceList = configurationManager.getAudioOutputDeviceList();
// comboBox3_out->addItems(outputDeviceList);
// comboBox3_out->setCurrentIndex(outputDevice);
qDebug() << "outputDevice = " << devices[0];
QStringList outputDeviceList = configurationManager.getAudioOutputDeviceList();
comboBox3_out->addItems(outputDeviceList);
comboBox3_out->setCurrentIndex(outputDevice);
}
//pulseaudio settings
checkBox_pulseAudioVolumeAlter->setCheckState(configurationManager.getPulseAppVolumeControl() ? Qt::Checked : Qt::Unchecked);
......@@ -192,6 +200,7 @@ void ConfigurationDialog::saveOptions()
{
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
accountsChangedEnableWarning = false;
////////////////////////
////General settings////
////////////////////////
......@@ -256,8 +265,16 @@ void ConfigurationDialog::saveOptions()
{
qDebug() << "setting alsa settings";
configurationManager.setOutputAudioPlugin(comboBox1_alsaPlugin->currentText());
configurationManager.setAudioInputDevice(comboBox2_in->currentIndex());
configurationManager.setAudioOutputDevice(comboBox3_out->currentIndex());
int audioInputDevice = comboBox2_in->currentIndex();
if( audioInputDevice != -1)
{
configurationManager.setAudioInputDevice(audioInputDevice);
}
int audioOutputDevice = comboBox3_out->currentIndex();
if( audioOutputDevice != -1)
{
configurationManager.setAudioOutputDevice(audioOutputDevice);
}
}
//pulseaudio settings
if(manager == PULSEAUDIO)
......@@ -297,6 +314,7 @@ void ConfigurationDialog::saveOptions()
hooksSettings[HOOKS_COMMAND] = lineEdit_command->text();
configurationManager.setHookSettings(hooksSettings);
// accountsChangedEnableWarning = true;
}
......@@ -401,7 +419,7 @@ void ConfigurationDialog::saveAccount(QListWidgetItem * item)
if(! item) { qDebug() << "Attempting to save details of an account from a NULL item"; return; }
Account * account = accountList->getAccountByItem(item);
if(! account) { qDebug() << "Attempting to save details of an unexisting account : " << item->text(); return; }
if(! account) { qDebug() << "Attempting to save details of an unexisting account : " << item->text() << " accounts are "<< accountList; return; }
account->setAccountDetail(ACCOUNT_ALIAS, edit1_alias->text());
QString protocolsTab[] = ACCOUNT_TYPES_TAB;
......@@ -702,6 +720,10 @@ void ConfigurationDialog::on1_accountsChanged()
{
errorWindow->showMessage(tr2i18n("Accounts changed : another client may be changing accounts or an account is unstable. \nIf another client is changing the settings, you may cancel your changes to avoid overwriting one's changes."));
}
if(! isVisible())
{
loadAccountList();
}
}
void ConfigurationDialog::on1_parametersChanged()
......
......@@ -1846,6 +1846,7 @@ ManagerImpl::getCurrentAudioOutputPlugin( void )
alsalayer = dynamic_cast<AlsaLayer *> (getAudioDriver());
if(alsalayer) return alsalayer -> getAudioPlugin ();
else return getConfigString( AUDIO , ALSA_PLUGIN );
}
int ManagerImpl::app_is_running( std::string process )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment