Commit 3c8c4bd1 authored by yanmorin's avatar yanmorin
Browse files

Partial multi-SIP account implementation

- (core) use only the first enable account
- (qt) unable to send new call on SIP1, SIP2, SIP3
parent 38815300
......@@ -143,6 +143,10 @@
<property name="margin">
<number>0</number>
</property>
<widget class="QComboBox">
<property name="name"><cstring>cboSIPAccount</cstring></property>
<property name="currentItem"><number>0</number></property>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox1</cstring>
......@@ -282,7 +286,7 @@
</property>
<widget class="QCheckBox">
<property name="name">
<cstring>autoregister</cstring>
<cstring>chkAutoregister</cstring>
</property>
<property name="text">
<string>Auto-register</string>
......@@ -291,6 +295,17 @@
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>chkEnable</cstring>
</property>
<property name="text">
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer7</cstring>
......@@ -1420,6 +1435,12 @@ Montreal, Quebec H2T 1S6, Canada&lt;/p&gt;</string>
</image>
</images>
<connections>
<connection>
<sender>cboSIPAccount</sender>
<signal>activated(int)</signal>
<receiver>ConfigurationPanel</receiver>
<slot>slotSIPAccountChange(int)</slot>
</connection>
<connection>
<sender>buttonOk</sender>
<signal>clicked()</signal>
......@@ -1482,13 +1503,15 @@ Montreal, Quebec H2T 1S6, Canada&lt;/p&gt;</string>
</connection>
</connections>
<tabstops>
<tabstop>cboSIPAccount</tabstop>
<tabstop>fullName</tabstop>
<tabstop>userPart</tabstop>
<tabstop>hostPart</tabstop>
<tabstop>username</tabstop>
<tabstop>password</tabstop>
<tabstop>sipproxy</tabstop>
<tabstop>autoregister</tabstop>
<tabstop>chkAutoregister</tabstop>
<tabstop>chkEnable</tabstop>
<tabstop>buttonRegister</tabstop>
<tabstop>buttonOk</tabstop>
<tabstop>buttonCancel</tabstop>
......@@ -1516,11 +1539,12 @@ Montreal, Quebec H2T 1S6, Canada&lt;/p&gt;</string>
<include location="local" impldecl="in implementation">ConfigurationPanel.ui.h</include>
</includes>
<signals>
<signal>needRegister()</signal>
<signal>needRegister(const QString&amp;)</signal>
<signal>soundDriverChanged()</signal>
</signals>
<slots>
<slot>generate()</slot>
<slot>slotSIPAccountChange(int)</slot>
<slot>slotRegister()</slot>
<slot>slotRegisterReturn( bool, QString )</slot>
<slot>slotTestSoundDriver()</slot>
......@@ -1540,6 +1564,13 @@ Montreal, Quebec H2T 1S6, Canada&lt;/p&gt;</string>
</slots>
<functions>
<function access="private" specifier="non virtual">init()</function>
<function access="private" specifier="non virtual">loadSIPAccount(int number)</function>
<function access="private" specifier="non virtual">saveSIPAccount(int number)</function>
</functions>
<variables>
<variable access="private">int lastSIPAccount;</variable>
</variables>
<layoutdefaults spacing="6" margin="11"/>
</UI>
......@@ -127,30 +127,19 @@ ConfigurationPanel::generate()
ringsChoice->setCurrentText(ConfigurationManager::instance().get(AUDIO_SECTION,
AUDIO_RINGTONE));
QString account = ACCOUNT_DEFAULT_NAME;
QString type = ConfigurationManager::instance().get(account, ACCOUNT_TYPE);
QString active = ConfigurationManager::instance().get(account, ACCOUNT_ENABLE);
// For signalisations tab
autoregister->setChecked(ConfigurationManager::instance()
.get(account,ACCOUNT_AUTO_REGISTER).toUInt());
fullName->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_FULL_NAME));
userPart->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_USER_PART));
username->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_AUTH_USER_NAME));
password->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_PASSWORD));
hostPart->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_HOST_PART));
sipproxy->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_PROXY));
STUNserver->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_STUN_SERVER));
((QRadioButton*)stunButtonGroup->find(ConfigurationManager::instance()
.get(account,SIGNALISATION_USE_STUN).toUInt()))->setChecked(true);
// Load account
QComboBox* cbo = cboSIPAccount;
cbo->clear();
int nbItem = 4;
QString accountName;
for (int iItem = 0; iItem < nbItem; iItem++) {
accountName = "SIP" + QString::number(iItem);
cbo->insertItem(accountName,iItem);
}
loadSIPAccount(0);
sendDTMFas->setCurrentItem(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
......@@ -172,31 +161,7 @@ ConfigurationPanel::generate()
// For saving settings at application 'save'
void ConfigurationPanel::saveSlot()
{
QString account = ACCOUNT_DEFAULT_NAME;
ConfigurationManager::instance().set(account,
SIGNALISATION_FULL_NAME,
fullName->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_USER_PART,
userPart->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_AUTH_USER_NAME,
username->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_PASSWORD,
password->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_HOST_PART,
hostPart->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_PROXY,
sipproxy->text());
ConfigurationManager::instance().set(account,
ACCOUNT_AUTO_REGISTER,
QString::number(autoregister->isChecked()));
ConfigurationManager::instance().set(account,
SIGNALISATION_STUN_SERVER,
STUNserver->text());
saveSIPAccount(cboSIPAccount->currentItem());
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_PULSE_LENGTH,
......@@ -379,8 +344,8 @@ ConfigurationPanel::SkinChoice_selected( const QString & )
void
ConfigurationPanel::slotRegister()
{
saveSlot();
emit needRegister();
saveSIPAccount(cboSIPAccount->currentItem());
emit needRegister("SIP" + QString::number(cboSIPAccount->currentItem()));
}
void
......@@ -435,3 +400,79 @@ ConfigurationPanel::slotSoundDriverReturn( bool hasError, QString message )
lblSoundDriver->show();
}
void
ConfigurationPanel::slotSIPAccountChange(int index)
{
if (lastSIPAccount!=index) {
QString account = "SIP" + QString::number(index);
DebugOutput::instance() << "Selecting SIP account " << account << "\n";
saveSIPAccount(lastSIPAccount);
loadSIPAccount(index);
lblError->setText("");
}
}
void
ConfigurationPanel::loadSIPAccount(int number)
{
QString account = "SIP" + QString::number(number);
QString type = ConfigurationManager::instance().get(account, ACCOUNT_TYPE);
chkAutoregister->setChecked(ConfigurationManager::instance()
.get(account,ACCOUNT_AUTO_REGISTER).toUInt());
chkEnable->setChecked(ConfigurationManager::instance()
.get(account,ACCOUNT_ENABLE).toUInt());
fullName->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_FULL_NAME));
userPart->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_USER_PART));
username->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_AUTH_USER_NAME));
password->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_PASSWORD));
hostPart->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_HOST_PART));
sipproxy->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_PROXY));
STUNserver->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_STUN_SERVER));
((QRadioButton*)stunButtonGroup->find(ConfigurationManager::instance()
.get(account,SIGNALISATION_USE_STUN).toUInt()))->setChecked(true);
lastSIPAccount = number;
}
void
ConfigurationPanel::saveSIPAccount(int number)
{
QString account = "SIP" + QString::number(number);
ConfigurationManager::instance().set(account,
SIGNALISATION_FULL_NAME,
fullName->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_USER_PART,
userPart->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_AUTH_USER_NAME,
username->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_PASSWORD,
password->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_HOST_PART,
hostPart->text());
ConfigurationManager::instance().set(account,
SIGNALISATION_PROXY,
sipproxy->text());
ConfigurationManager::instance().set(account,
ACCOUNT_AUTO_REGISTER,
QString::number(chkAutoregister->isChecked()));
ConfigurationManager::instance().set(account,
ACCOUNT_ENABLE,
QString::number(chkEnable->isChecked()));
ConfigurationManager::instance().set(account,
SIGNALISATION_STUN_SERVER,
STUNserver->text());
}
......@@ -125,11 +125,11 @@ PhoneLineManagerImpl::connect()
}
void
PhoneLineManagerImpl::slotRegisterToServer()
PhoneLineManagerImpl::slotRegisterToServer(const QString& account)
{
isInitialized();
Request *r = mSession->registerToServer();
Request *r = mSession->registerToServer(account);
QObject::connect(r, SIGNAL(success(QString, QString)),
this, SLOT(slotRegisterSucceed(QString, QString)));
QObject::connect(r, SIGNAL(error(QString, QString)),
......
......@@ -96,7 +96,7 @@ public slots:
void hasDisconnected();
void slotRegisterToServer();
void slotRegisterToServer(const QString&);
void slotRegisterFailed(QString, QString);
void slotRegisterSucceed(QString, QString);
void slotReloadSoundDriver();
......
......@@ -128,8 +128,8 @@ SFLPhoneApp::initConnections(SFLPhoneWindow *w)
}
QObject::connect(w, SIGNAL(needRegister()),
&PhoneLineManager::instance(), SLOT(slotRegisterToServer()));
QObject::connect(w, SIGNAL(needRegister(const QString&)),
&PhoneLineManager::instance(), SLOT(slotRegisterToServer(const QString&)));
QObject::connect(&PhoneLineManager::instance(), SIGNAL(registerReturn(bool, QString)),
w, SIGNAL(registerReturn(bool, QString)));
......
......@@ -64,7 +64,7 @@ SFLPhoneWindow::SFLPhoneWindow()
connect(this, SIGNAL(audioDevicesOutUpdated()),mSetupPanel, SLOT(updateAudioDevicesOut()));
connect(this, SIGNAL(codecsUpdated()), mSetupPanel, SLOT(updateCodecs()));
connect(mSetupPanel, SIGNAL(needRegister()), this, SIGNAL(needRegister()));
connect(mSetupPanel, SIGNAL(needRegister(const QString&)), this, SIGNAL(needRegister(const QString&)));
connect(this, SIGNAL(registerReturn(bool, QString)), mSetupPanel, SLOT(slotRegisterReturn(bool, QString)));
// when we receive a signal from mSetupPanel, we should resend one to...
......
......@@ -66,7 +66,7 @@ signals:
void audioDevicesOutUpdated();
void codecsUpdated();
void needRegister();
void needRegister(const QString&);
void registerReturn(bool, QString);
void soundDriverChanged();
......
......@@ -160,10 +160,10 @@ Session::list(const QString &category) const
}
Request *
Session::registerToServer() const
Session::registerToServer(const QString& account) const
{
std::list< QString > args;
args.push_back(getDefaultAccount().id());
args.push_back(account);
return Requester::instance().send(mId, "register", args);
}
......
......@@ -76,7 +76,7 @@ class Session
/**
* This function will register with the default account.
*/
Request *registerToServer() const;
Request *registerToServer(const QString&) const;
/**
* This function try to switch audio (sound) driver
......
......@@ -425,6 +425,8 @@ ManagerImpl::initRegisterVoIPLink()
if (iter->second->shouldRegisterOnStart()) {
iter->second->registerAccount();
}
// init only the first account
break;
}
}
iter++;
......@@ -1588,6 +1590,7 @@ ManagerImpl::getNewCallID()
random_id << (unsigned)rand();
// when it's not found, it return ""
// generate, something like s10000s20000s4394040
while (getAccountFromCall(random_id.str()) != AccountNULL) {
random_id.clear();
random_id << "s";
......@@ -1601,8 +1604,15 @@ ManagerImpl::loadAccountMap()
{
short nbAccount = 0;
_accountMap[ACCOUNT_SIP0] = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, ACCOUNT_SIP0);
nbAccount++;
// SIP Loading 4 account...
short nbAccountSIP = 4;
for (short iAccountSIP = 0; iAccountSIP<nbAccountSIP; iAccountSIP++) {
std::ostringstream accountName;
accountName << "SIP" << iAccountSIP;
_accountMap[accountName.str()] = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, accountName.str());
nbAccount++;
}
Account* account = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, ACCOUNT_IAX0);
if (account != 0) {
......
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