aboutsummaryrefslogtreecommitdiff
path: root/lib/user.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-07-01 16:26:56 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-07-01 16:26:56 +0900
commit00ff511ab11fae58eb9dc43879f2483a9f303263 (patch)
tree804a23d1aa6ad6dd0669882c3107a5ed0edad7b3 /lib/user.cpp
parent12478cf7330727083103d22f76de92c4aa476f5b (diff)
parentd3ddd394e855cfe217bf0f0d368822c9b99316bb (diff)
downloadlibquotient-00ff511ab11fae58eb9dc43879f2483a9f303263.tar.gz
libquotient-00ff511ab11fae58eb9dc43879f2483a9f303263.zip
Merge branch 'master' into forget-rooms-really
Diffstat (limited to 'lib/user.cpp')
-rw-r--r--lib/user.cpp20
1 files changed, 1 insertions, 19 deletions
diff --git a/lib/user.cpp b/lib/user.cpp
index 7f3f11f6..7b695618 100644
--- a/lib/user.cpp
+++ b/lib/user.cpp
@@ -33,9 +33,6 @@
#include <QtCore/QStringBuilder>
#include <QtCore/QElapsedTimer>
-#include <QtCore/QCryptographicHash>
-#include <QtCore/QtEndian>
-
#include <functional>
using namespace QMatrixClient;
@@ -50,23 +47,8 @@ class User::Private
return Avatar(move(url));
}
- qreal makeHueF()
- {
- Q_ASSERT(!userId.isEmpty());
- QByteArray hash = QCryptographicHash::hash(userId.toUtf8(),
- QCryptographicHash::Sha1);
- QDataStream dataStream(qToLittleEndian(hash).left(2));
- dataStream.setByteOrder(QDataStream::LittleEndian);
- quint16 hashValue;
- dataStream >> hashValue;
- const auto hueF =
- qreal(hashValue)/std::numeric_limits<quint16>::max();
- Q_ASSERT((0 <= hueF) && (hueF <= 1));
- return hueF;
- }
-
Private(QString userId, Connection* connection)
- : userId(move(userId)), connection(connection), hueF(makeHueF())
+ : userId(move(userId)), connection(connection), hueF(stringToHueF(this->userId))
{ }
QString userId;