Overte C++ Documentation
DataServerAccountInfo.h
1 //
2 // DataServerAccountInfo.h
3 // libraries/networking/src
4 //
5 // Created by Stephen Birarda on 2/21/2014.
6 // Copyright 2014 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_DataServerAccountInfo_h
13 #define hifi_DataServerAccountInfo_h
14 
15 #include <QtCore/QObject>
16 #include <QtCore/QUuid>
17 #include <QtNetwork/qnetworkreply.h>
18 
19 #include "OAuthAccessToken.h"
20 
21 const float SATOSHIS_PER_CREDIT = 100000000.0f;
22 
23 class DataServerAccountInfo : public QObject {
24  Q_OBJECT
25  const static QString EMPTY_KEY;
26 public:
27  DataServerAccountInfo() {};
28  DataServerAccountInfo(const DataServerAccountInfo& otherInfo);
29  DataServerAccountInfo& operator=(const DataServerAccountInfo& otherInfo);
30 
31  const OAuthAccessToken& getAccessToken() const { return _accessToken; }
32  void setAccessToken(const OAuthAccessToken& accessToken) { _accessToken = accessToken; }
33  void setAccessTokenFromJSON(const QJsonObject& jsonObject);
34 
35  const QString& getUsername() const { return _username; }
36  void setUsername(const QString& username);
37 
38  const QString& getXMPPPassword() const { return _xmppPassword; }
39  void setXMPPPassword(const QString& xmppPassword);
40 
41  const QString& getDiscourseApiKey() const { return _discourseApiKey; }
42  void setDiscourseApiKey(const QString& discourseApiKey);
43 
44  QByteArray getUsernameSignature(const QUuid& connectionToken);
45  bool hasPrivateKey() const { return !_privateKey.isEmpty(); }
46  void setPrivateKey(const QByteArray& privateKey) { _privateKey = privateKey; }
47 
48  QByteArray signPlaintext(const QByteArray& plaintext);
49 
50  void setDomainID(const QUuid& domainID) { _domainID = domainID; }
51  const QUuid& getDomainID() const { return _domainID; }
52 
53  void setTemporaryDomain(const QUuid& domainID, const QString& key) { _temporaryDomainID = domainID; _temporaryDomainApiKey = key; }
54  const QString& getTemporaryDomainKey(const QUuid& domainID) { return domainID == _temporaryDomainID ? _temporaryDomainApiKey : EMPTY_KEY; }
55 
56  bool hasProfile() const;
57 
58  void setProfileInfoFromJSON(const QJsonObject& jsonObject);
59 
60  friend QDataStream& operator<<(QDataStream &out, const DataServerAccountInfo& info);
61  friend QDataStream& operator>>(QDataStream &in, DataServerAccountInfo& info);
62 
63 private:
64  void swap(DataServerAccountInfo& otherInfo);
65 
66  OAuthAccessToken _accessToken;
67  QString _username;
68  QString _xmppPassword;
69  QString _discourseApiKey;
70  QUuid _domainID;
71  QUuid _temporaryDomainID;
72  QString _temporaryDomainApiKey;
73  QByteArray _privateKey;
74 
75 };
76 
77 #endif // hifi_DataServerAccountInfo_h