diff --git a/src/api/account.h b/src/api/account.h index a32297020163dee68b9267bf2a9eaf2c6540f765..d2c08b0ec218b8bcc9687d3d1dda56b00082daea 100644 --- a/src/api/account.h +++ b/src/api/account.h @@ -78,6 +78,18 @@ to_status(const std::string& type) #pragma pop_macro("REGISTERED") +enum class KeyExchangeProtocol { + NONE, + SDES +}; + +enum class TlsMethod { + DEFAULT, + TLSv1, + TLSv1_1, + TLSv1_2 +}; + struct ConfProperties_t { std::string displayName; std::string mailbox; @@ -104,11 +116,10 @@ struct ConfProperties_t { bool archiveHasPassword; std::string archivePath; std::string archivePin; - // in NewDeviceModel: deviceID; - // in NewDeviceModel: deviceName; bool proxyEnabled; std::string proxyServer; std::string proxyPushToken; + int registrationExpire; struct Audio_t { int audioPortMax; int audioPortMin; @@ -139,7 +150,7 @@ struct ConfProperties_t { bool ringtoneEnabled; } Ringtone; struct SRTP_t { - std::string keyExchange; + KeyExchangeProtocol keyExchange; bool enable; bool rtpFallback; } SRTP; @@ -151,7 +162,7 @@ struct ConfProperties_t { std::string certificateFile; std::string privateKeyFile; std::string password; - std::string method; + TlsMethod method; std::string ciphers; std::string serverName; bool verifyServer; @@ -168,6 +179,9 @@ struct ConfProperties_t { std::string uri; std::string account; } RingNS; + struct Registration_t { + int expire; + } Registration; MapStringString toDetails() const; }; diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index deabcaeddf5ea246b52899409ab8584a3daaf8f1..e1d42d96aed3cde4fecded7f0595563c5475dfca 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -533,7 +533,7 @@ account::Info::fromDetails(const MapStringString& details) confProperties.Ringtone.ringtonePath = toStdString(details[ConfProperties::Ringtone::PATH]); confProperties.Ringtone.ringtoneEnabled = toBool(details[ConfProperties::Ringtone::ENABLED]); // SRTP - confProperties.SRTP.keyExchange = toStdString(details[ConfProperties::SRTP::KEY_EXCHANGE]); + confProperties.SRTP.keyExchange = toStdString(details[ConfProperties::SRTP::KEY_EXCHANGE]).empty()? account::KeyExchangeProtocol::NONE : account::KeyExchangeProtocol::SDES; confProperties.SRTP.enable = toBool(details[ConfProperties::SRTP::ENABLED]); confProperties.SRTP.rtpFallback = toBool(details[ConfProperties::SRTP::RTP_FALLBACK]); // TLS @@ -544,7 +544,16 @@ account::Info::fromDetails(const MapStringString& details) confProperties.TLS.certificateFile = toStdString(details[ConfProperties::TLS::CERTIFICATE_FILE]); confProperties.TLS.privateKeyFile = toStdString(details[ConfProperties::TLS::PRIVATE_KEY_FILE]); confProperties.TLS.password = toStdString(details[ConfProperties::TLS::PASSWORD]); - confProperties.TLS.method = toStdString(details[ConfProperties::TLS::METHOD]); + auto method = toStdString(details[ConfProperties::TLS::METHOD]); + if (method == "TLSv1") { + confProperties.TLS.method = account::TlsMethod::TLSv1; + } else if (method == "TLSv1.1") { + confProperties.TLS.method = account::TlsMethod::TLSv1_1; + } else if (method == "TLSv1.2") { + confProperties.TLS.method = account::TlsMethod::TLSv1_2; + } else { + confProperties.TLS.method = account::TlsMethod::DEFAULT; + } confProperties.TLS.ciphers = toStdString(details[ConfProperties::TLS::CIPHERS]); confProperties.TLS.serverName = toStdString(details[ConfProperties::TLS::SERVER_NAME]); confProperties.TLS.verifyServer = toBool(details[ConfProperties::TLS::VERIFY_SERVER]); @@ -558,6 +567,8 @@ account::Info::fromDetails(const MapStringString& details) // RingNS confProperties.RingNS.uri = toStdString(details[ConfProperties::RingNS::URI]); confProperties.RingNS.account = toStdString(details[ConfProperties::RingNS::ACCOUNT]); + // Registration + confProperties.Registration.expire = toInt(details[ConfProperties::Registration::EXPIRE]); } MapStringString @@ -618,7 +629,7 @@ account::ConfProperties_t::toDetails() const details[ConfProperties::Ringtone::PATH] = toQString(this->Ringtone.ringtonePath); details[ConfProperties::Ringtone::ENABLED] = toQString(this->Ringtone.ringtoneEnabled); // SRTP - details[ConfProperties::SRTP::KEY_EXCHANGE] = toQString(this->SRTP.keyExchange); + details[ConfProperties::SRTP::KEY_EXCHANGE] = this->SRTP.keyExchange == account::KeyExchangeProtocol::NONE? "" : "sdes"; details[ConfProperties::SRTP::ENABLED] = toQString(this->SRTP.enable); details[ConfProperties::SRTP::RTP_FALLBACK] = toQString(this->SRTP.rtpFallback); // TLS @@ -629,7 +640,21 @@ account::ConfProperties_t::toDetails() const details[ConfProperties::TLS::CERTIFICATE_FILE] = toQString(this->TLS.certificateFile); details[ConfProperties::TLS::PRIVATE_KEY_FILE] = toQString(this->TLS.privateKeyFile); details[ConfProperties::TLS::PASSWORD] = toQString(this->TLS.password); - details[ConfProperties::TLS::METHOD] = toQString(this->TLS.method); + switch (this->TLS.method) { + case account::TlsMethod::TLSv1: + details[ConfProperties::TLS::METHOD] = "TLSv1"; + break; + case account::TlsMethod::TLSv1_1: + details[ConfProperties::TLS::METHOD] = "TLSv1.1"; + break; + case account::TlsMethod::TLSv1_2: + details[ConfProperties::TLS::METHOD] = "TLSv1.2"; + break; + case account::TlsMethod::DEFAULT: + default: + details[ConfProperties::TLS::METHOD] = "Default"; + break; + } details[ConfProperties::TLS::CIPHERS] = toQString(this->TLS.ciphers); details[ConfProperties::TLS::SERVER_NAME] = toQString(this->TLS.serverName); details[ConfProperties::TLS::VERIFY_SERVER] = toQString(this->TLS.verifyServer); @@ -643,6 +668,8 @@ account::ConfProperties_t::toDetails() const // RingNS details[ConfProperties::RingNS::URI] = toQString(this->RingNS.uri); details[ConfProperties::RingNS::ACCOUNT] = toQString(this->RingNS.account); + // Registration + details[ConfProperties::Registration::EXPIRE] = toQString(this->Registration.expire); return details; }