diff --git a/src/api/account.h b/src/api/account.h index d2c08b0ec218b8bcc9687d3d1dda56b00082daea..d9170888cb3e5fecfd9431339a5655e206375950 100644 --- a/src/api/account.h +++ b/src/api/account.h @@ -102,6 +102,8 @@ struct ConfProperties_t { std::string password; std::string realm; std::string localInterface; + std::string deviceId; + std::string deviceName; bool publishedSameAsLocal; int localPort; int publishedPort; diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index e1d42d96aed3cde4fecded7f0595563c5475dfca..78b9c9fb57da50cc2c162aeb35638065667d01f7 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -492,6 +492,8 @@ account::Info::fromDetails(const MapStringString& details) confProperties.password = toStdString(details[ConfProperties::PASSWORD]); confProperties.realm = toStdString(details[ConfProperties::REALM]); confProperties.localInterface = toStdString(details[ConfProperties::LOCAL_INTERFACE]); + confProperties.deviceId = toStdString(details[ConfProperties::RING_DEVICE_ID]); + confProperties.deviceName = toStdString(details[ConfProperties::RING_DEVICE_NAME]); confProperties.publishedSameAsLocal = toBool(details[ConfProperties::PUBLISHED_SAMEAS_LOCAL]); confProperties.localPort = toInt(details[ConfProperties::LOCAL_PORT]); confProperties.publishedPort = toInt(details[ConfProperties::PUBLISHED_PORT]); @@ -586,6 +588,8 @@ account::ConfProperties_t::toDetails() const details[ConfProperties::ROUTE] = toQString(this->routeset); details[ConfProperties::PASSWORD] = toQString(this->password); details[ConfProperties::REALM] = toQString(this->realm); + details[ConfProperties::RING_DEVICE_ID] = toQString(this->deviceId); + details[ConfProperties::RING_DEVICE_NAME] = toQString(this->deviceName); details[ConfProperties::LOCAL_INTERFACE] = toQString(this->localInterface); details[ConfProperties::PUBLISHED_SAMEAS_LOCAL] = toQString(this->publishedSameAsLocal); details[ConfProperties::LOCAL_PORT] = toQString(this->localPort); diff --git a/src/newdevicemodel.cpp b/src/newdevicemodel.cpp index dc916a716a43b3c167a6b74f2e6c7ec6b1dfe08d..47c7a5f298fa102f6e00c09f0c7ab2c349652d65 100644 --- a/src/newdevicemodel.cpp +++ b/src/newdevicemodel.cpp @@ -22,6 +22,7 @@ #include <mutex> // LRC +#include "api/newaccountmodel.h" #include "callbackshandler.h" #include "dbus/configurationmanager.h" @@ -107,9 +108,17 @@ NewDeviceModel::revokeDevice(const std::string& id, const std::string& password) void NewDeviceModel::setCurrentDeviceName(const std::string& newName) { - MapStringString details = {}; - details[DRing::Account::ConfProperties::RING_DEVICE_NAME] = newName.c_str(); - ConfigurationManager::instance().setAccountDetails(owner.id.c_str(), details); + // Update deamon config + auto config = owner.accountModel->getAccountConfig(owner.id); + config.deviceName = newName; + owner.accountModel->setAccountConfig(owner.id, config); + // Update model + std::lock_guard<std::mutex> lock(pimpl_->devicesMtx_); + for (auto& device : pimpl_->devices_) { + if (device.id == config.deviceId) { + device.name = newName; + } + } } NewDeviceModelPimpl::NewDeviceModelPimpl(const NewDeviceModel& linked, const CallbacksHandler& callbacksHandler)