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