1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00

clientmessage: Refactor token to web_address

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
Ralf Ramsauer 2016-07-17 22:44:02 +02:00
parent 5355749c6b
commit 474d941918
4 changed files with 13 additions and 13 deletions

View File

@ -44,7 +44,7 @@ static void onDoorlockUpdate(const Clientmessage &msg)
{ {
const auto& doormessage = msg.doormessage(); const auto& doormessage = msg.doormessage();
l("Received message", LogLevel::info); l("Received message", LogLevel::info);
l((std::string)" token: " + msg.token(), l((std::string)" token: " + msg.web_address(),
LogLevel::info); LogLevel::info);
l((std::string)" open: " + std::to_string(msg.isOpen()), l((std::string)" open: " + std::to_string(msg.isOpen()),
LogLevel::info); LogLevel::info);

View File

@ -24,8 +24,8 @@ MainWindow::~MainWindow()
void MainWindow::setClientmessage(const Clientmessage &msg) void MainWindow::setClientmessage(const Clientmessage &msg)
{ {
ui->qrwidget->setQRData(msg.token()); ui->qrwidget->setQRData(msg.web_address());
ui->address->setText(QString::fromStdString(msg.token())); ui->address->setText(QString::fromStdString(msg.web_address()));
QString statusMessage(""); QString statusMessage("");
const auto &doormsg = msg.doormessage(); const auto &doormsg = msg.doormessage();

View File

@ -8,17 +8,17 @@ const std::string Clientmessage::_lockButtonKey = "lockButton";
const std::string Clientmessage::_emergencyUnlockKey = "emergencyUnlock"; const std::string Clientmessage::_emergencyUnlockKey = "emergencyUnlock";
const std::string Clientmessage::_isOpenKey = "isOpen"; const std::string Clientmessage::_isOpenKey = "isOpen";
Clientmessage::Clientmessage(std::string token, Clientmessage::Clientmessage(std::string web_address,
bool isOpen, bool isOpen,
Doormessage doormessage) : Doormessage doormessage) :
_token(token), _web_address(web_address),
_isOpen(isOpen), _isOpen(isOpen),
_doormessage(doormessage) _doormessage(doormessage)
{ {
} }
Clientmessage::Clientmessage() : Clientmessage::Clientmessage() :
_token(), _web_address(),
_isOpen(false), _isOpen(false),
_doormessage() _doormessage()
{ {
@ -31,7 +31,7 @@ Clientmessage &Clientmessage::operator=(const Clientmessage &rhs)
return *this; return *this;
} }
this->_token = rhs._token; this->_web_address = rhs._web_address;
this->_isOpen = rhs._isOpen; this->_isOpen = rhs._isOpen;
this->_doormessage = rhs._doormessage; this->_doormessage = rhs._doormessage;
@ -43,7 +43,7 @@ std::string Clientmessage::toJson() const
Json::StyledWriter writer; Json::StyledWriter writer;
Json::Value message; Json::Value message;
message[_tokenKey] = _token; message[_tokenKey] = _web_address;
message[_unlockButtonKey] = _doormessage.isUnlockButton; message[_unlockButtonKey] = _doormessage.isUnlockButton;
message[_lockButtonKey] = _doormessage.isLockButton; message[_lockButtonKey] = _doormessage.isLockButton;
message[_emergencyUnlockKey] = _doormessage.isEmergencyUnlock; message[_emergencyUnlockKey] = _doormessage.isEmergencyUnlock;
@ -52,9 +52,9 @@ std::string Clientmessage::toJson() const
return writer.write(message); return writer.write(message);
} }
const std::string& Clientmessage::token() const const std::string& Clientmessage::web_address() const
{ {
return _token; return _web_address;
} }
const Doormessage& Clientmessage::doormessage() const const Doormessage& Clientmessage::doormessage() const

View File

@ -10,7 +10,7 @@ class Clientmessage
{ {
public: public:
Clientmessage(std::string token, Clientmessage(std::string web_address,
bool isOpen, bool isOpen,
Doormessage doormessage); Doormessage doormessage);
Clientmessage(); Clientmessage();
@ -21,13 +21,13 @@ public:
static Clientmessage fromString(const std::string &json); static Clientmessage fromString(const std::string &json);
std::string toJson() const; std::string toJson() const;
const std::string& token() const; const std::string& web_address() const;
bool isOpen() const; bool isOpen() const;
const Doormessage& doormessage() const; const Doormessage& doormessage() const;
private: private:
std::string _token; std::string _web_address;
bool _isOpen; bool _isOpen;
Doormessage _doormessage; Doormessage _doormessage;