From 07d3eb886a9fc515c5ebe8d3584193b3f4bb0339 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Tue, 4 Mar 2014 21:27:06 +0200 Subject: [PATCH] Added reading and storing of the XMPP password of the current user. --- .../shared/src/DataServerAccountInfo.cpp | 25 +++++++++++++++---- libraries/shared/src/DataServerAccountInfo.h | 4 +++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/libraries/shared/src/DataServerAccountInfo.cpp b/libraries/shared/src/DataServerAccountInfo.cpp index 7225653998..2bcd2dbcd0 100644 --- a/libraries/shared/src/DataServerAccountInfo.cpp +++ b/libraries/shared/src/DataServerAccountInfo.cpp @@ -12,21 +12,26 @@ DataServerAccountInfo::DataServerAccountInfo() : _accessToken(), - _username() + _username(), + _xmppPassword() { } DataServerAccountInfo::DataServerAccountInfo(const QJsonObject& jsonObject) : _accessToken(jsonObject), - _username() + _username(), + _xmppPassword() { - setUsername(jsonObject["user"].toObject()["username"].toString()); + QJsonObject userJSONObject = jsonObject["user"].toObject(); + setUsername(userJSONObject["username"].toString()); + setXMPPPassword(userJSONObject["xmpp_password"].toString()); } DataServerAccountInfo::DataServerAccountInfo(const DataServerAccountInfo& otherInfo) { _accessToken = otherInfo._accessToken; _username = otherInfo._username; + _xmppPassword = otherInfo._xmppPassword; } DataServerAccountInfo& DataServerAccountInfo::operator=(const DataServerAccountInfo& otherInfo) { @@ -40,6 +45,7 @@ void DataServerAccountInfo::swap(DataServerAccountInfo& otherInfo) { swap(_accessToken, otherInfo._accessToken); swap(_username, otherInfo._username); + swap(_xmppPassword, otherInfo._xmppPassword); } void DataServerAccountInfo::setUsername(const QString& username) { @@ -50,12 +56,21 @@ void DataServerAccountInfo::setUsername(const QString& username) { } } +void DataServerAccountInfo::setXMPPPassword(const QString& xmppPassword) +{ + if (_xmppPassword != xmppPassword) { + _xmppPassword = xmppPassword; + + qDebug() << "XMPP password changed to " << xmppPassword; + } +} + QDataStream& operator<<(QDataStream &out, const DataServerAccountInfo& info) { - out << info._accessToken << info._username; + out << info._accessToken << info._username << info._xmppPassword; return out; } QDataStream& operator>>(QDataStream &in, DataServerAccountInfo& info) { - in >> info._accessToken >> info._username; + in >> info._accessToken >> info._username >> info._xmppPassword; return in; } \ No newline at end of file diff --git a/libraries/shared/src/DataServerAccountInfo.h b/libraries/shared/src/DataServerAccountInfo.h index da7bdbe42e..c840468319 100644 --- a/libraries/shared/src/DataServerAccountInfo.h +++ b/libraries/shared/src/DataServerAccountInfo.h @@ -25,6 +25,9 @@ public: const QString& getUsername() const { return _username; } void setUsername(const QString& username); + + const QString& getXMPPPassword() const { return _xmppPassword; } + void setXMPPPassword(const QString& xmppPassword); friend QDataStream& operator<<(QDataStream &out, const DataServerAccountInfo& info); friend QDataStream& operator>>(QDataStream &in, DataServerAccountInfo& info); @@ -33,6 +36,7 @@ private: OAuthAccessToken _accessToken; QString _username; + QString _xmppPassword; }; #endif /* defined(__hifi__DataServerAccountInfo__) */