From 9316bacac19802147406616c00d54b98be808cf3 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> Date: Thu, 23 Apr 2015 16:00:10 -0400 Subject: [PATCH] account: Add TURN settings Refs #71564 --- src/account.cpp | 26 +++++++++++++++++++++++++- src/account.h | 6 ++++++ src/accountmodel.cpp | 2 ++ src/keyexchangemodel.cpp | 2 +- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/account.cpp b/src/account.cpp index 839930f2..d29cebd2 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -858,6 +858,16 @@ bool Account::useDefaultPort() const return d_ptr->m_UseDefaultPort; } +bool Account::isTurnEnabled() const +{ + return d_ptr->accountDetail(DRing::Account::ConfProperties::TURN::ENABLED) IS_TRUE; +} + +QString Account::turnServer() const +{ + return d_ptr->accountDetail(DRing::Account::ConfProperties::TURN::SERVER); +} + #define CAST(item) static_cast<int>(item) QVariant Account::roleData(int role) const { @@ -971,6 +981,10 @@ QVariant Account::roleData(int role) const return trimesterCallCount(); case CAST(Account::Role::LastUsed): return (int)lastUsed(); + case CAST(Account::Role::SipTurnServer): + return turnServer(); + case CAST(Account::Role::SipTurnEnabled): + return isTurnEnabled(); default: return QVariant(); } @@ -1467,7 +1481,7 @@ void Account::setUseDefaultPort(bool value) switch (protocol()) { case Account::Protocol::SIP: case Account::Protocol::IAX: - setLocalPort(5060); + setLocalPort(5060); //FIXME check is TLS is used break; case Account::Protocol::RING: setLocalPort(5061); @@ -1479,6 +1493,16 @@ void Account::setUseDefaultPort(bool value) d_ptr->m_UseDefaultPort = value; } +void Account::setTurnEnabled(bool value) +{ + d_ptr->setAccountProperty(DRing::Account::ConfProperties::TURN::ENABLED, (value)TO_BOOL); +} + +void Account::setTurnServer(const QString& value) +{ + d_ptr->setAccountProperty(DRing::Account::ConfProperties::TURN::SERVER, value); +} + ///Set the DTMF type void Account::setDTMFType(DtmfType type) { diff --git a/src/account.h b/src/account.h index 3476be4a..e84af502 100644 --- a/src/account.h +++ b/src/account.h @@ -230,6 +230,8 @@ class LIB_EXPORT Account : public QObject { WeekCallCount = 148, TrimesterCallCount = 149, LastUsed = 150, + SipTurnServer = 151, + SipTurnEnabled = 152, }; enum class Protocol { @@ -323,6 +325,8 @@ class LIB_EXPORT Account : public QObject { QString lastTransportErrorMessage () const; QString userAgent () const; bool useDefaultPort () const; + bool isTurnEnabled () const; + QString turnServer () const; RegistrationState registrationState () const; Protocol protocol () const; KeyExchangeModel::Type keyExchange () const; @@ -358,6 +362,7 @@ class LIB_EXPORT Account : public QObject { void setLocalInterface (const QString& detail ); void setRingtonePath (const QString& detail ); void setLastErrorMessage (const QString& message ); + void setTurnServer (const QString& value ); void setKeyExchange (KeyExchangeModel::Type detail); void setLastErrorCode (int code ); void setVoiceMailCount (int count ); @@ -391,6 +396,7 @@ class LIB_EXPORT Account : public QObject { void setUpnpEnabled (bool enable); void setHasCustomUserAgent (bool enable); void setUseDefaultPort (bool value ); + void setTurnEnabled (bool value ); void setRoleData(int role, const QVariant& value); diff --git a/src/accountmodel.cpp b/src/accountmodel.cpp index 87200504..ac01f1da 100644 --- a/src/accountmodel.cpp +++ b/src/accountmodel.cpp @@ -147,6 +147,8 @@ QHash<int,QByteArray> AccountModel::roleNames() const roles.insert(CAST(Account::Role::WeekCallCount ) ,QByteArray("weekCallCount" )); roles.insert(CAST(Account::Role::TrimesterCallCount ) ,QByteArray("trimesterCallCount" )); roles.insert(CAST(Account::Role::LastUsed ) ,QByteArray("lastUsed" )); + roles.insert(CAST(Account::Role::SipTurnServer ) ,QByteArray("sipTurnServer" )); + roles.insert(CAST(Account::Role::SipTurnEnabled ) ,QByteArray("sipTurnEnabled" )); } return roles; } diff --git a/src/keyexchangemodel.cpp b/src/keyexchangemodel.cpp index 270eb277..39b09f1d 100644 --- a/src/keyexchangemodel.cpp +++ b/src/keyexchangemodel.cpp @@ -96,7 +96,7 @@ int KeyExchangeModel::rowCount( const QModelIndex& parent ) const Qt::ItemFlags KeyExchangeModel::flags( const QModelIndex& index ) const { if (!index.isValid()) return Qt::NoItemFlags; - return Qt::ItemIsEnabled|Qt::ItemIsSelectable; + return index.row()!=(int)KeyExchangeModel::Type::ZRTP?(Qt::ItemIsEnabled|Qt::ItemIsSelectable):Qt::NoItemFlags; } bool KeyExchangeModel::setData( const QModelIndex& index, const QVariant &value, int role) -- GitLab