}
else if (strcmp(event->subclass_name, "sofia::gateway_del") == 0)
{
+ qDebug() << "We are deleted...";
QSharedPointer<Account> acc = _accounts.take(switch_event_get_header_nil(event, "Gateway"));
if (!acc.isNull())
emit delAccount(acc);
}
}
+void FSHost::accountReloadCmd(QSharedPointer<Account> acc)
+{
+ QString res;
+ QString arg = QString("profile softphone killgw %1").arg(acc.data()->getName());
+
+ connect(this, SIGNAL(delAccount(QSharedPointer<Account>)), this, SLOT(accountReloadSlot(QSharedPointer<Account>)));
+
+ if (g_FSHost.sendCmd("sofia", arg.toAscii().data() , &res) != SWITCH_STATUS_SUCCESS)
+ {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not killgw %s from profile softphone.\n",
+ acc.data()->getName().toAscii().data());
+ }
+ _reloading_Accounts.append(acc.data()->getName());
+
+ qDebug() << "We are reloading...";
+}
+
+void FSHost::accountReloadSlot(QSharedPointer<Account> acc)
+{
+ if (_reloading_Accounts.contains(acc.data()->getName()))
+ {
+ _reloading_Accounts.takeAt(_reloading_Accounts.indexOf(acc.data()->getName(), 0));
+ QString res;
+ if (g_FSHost.sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
+ {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not rescan the softphone profile.\n");
+ return;
+ }
+ if (_reloading_Accounts.isEmpty())
+ disconnect(this, SLOT(accountReloadSlot(QSharedPointer<Account>)));
+ qDebug() << "We are rescanning...";
+ }
+}
+
switch_status_t FSHost::sendCmd(const char *cmd, const char *args, QString *res)
{
switch_status_t status = SWITCH_STATUS_FALSE;
QSharedPointer<Call> getCurrentActiveCall();
QList<QSharedPointer<Account> > getAccounts() { return _accounts.values(); }
QSharedPointer<Account> getAccountByUUID(QString uuid);
+ void accountReloadCmd(QSharedPointer<Account> acc);
protected:
void run(void);
void newAccount(QSharedPointer<Account>);
void delAccount(QSharedPointer<Account>);
+private slots:
+ void accountReloadSlot(QSharedPointer<Account>);
+
private:
switch_status_t processBlegEvent(switch_event_t *, QString);
switch_status_t processAlegEvent(switch_event_t *, QString);
QHash<QString, QSharedPointer<Call> > _active_calls;
QHash<QString, QSharedPointer<Account> > _accounts;
QHash<QString, QString> _bleg_uuids;
+ QList<QString> _reloading_Accounts;
};
extern FSHost g_FSHost;
void AccountDialog::writeConfig()
{
+ QSharedPointer<Account> acc = g_FSHost.getAccountByUUID(_accId);
+ if (!acc.isNull())
+ {
+ g_FSHost.accountReloadCmd(acc);
+ }
+
_settings->beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways");
_settings->beginGroup(_accId);
-
- if (!g_FSHost.getAccountByUUID(_accId).isNull())
- {
- QString res;
- QString arg = QString("profile softphone killgw %1").arg(g_FSHost.getAccountByUUID(_accId).data()->getName());
-
- if (g_FSHost.sendCmd("sofia", arg.toAscii().data() , &res) != SWITCH_STATUS_SUCCESS)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not killgw %s from profile softphone.\n",
- g_FSHost.getAccountByUUID(_accId).data()->getName().toAscii().data());
- }
- }
_settings->beginGroup("gateway/attrs");
_settings->setValue("name", ui->sofiaGwNameEdit->text());
if (reload)
{
QString res;
- _settings->sync();
if (g_FSHost.sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not rescan the softphone profile.\n");