1 /*
2     Copyright © 2015-2019 by The qTox Project Contributors
3 
4     This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6     qTox is libre software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     qTox is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with qTox.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #ifndef TOXID_H
22 #define TOXID_H
23 
24 #include "toxpk.h"
25 
26 #include <QByteArray>
27 #include <QString>
28 #include <cstdint>
29 
30 class ToxId
31 {
32 public:
33     ToxId();
34     ToxId(const ToxId& other);
35     explicit ToxId(const QString& id);
36     explicit ToxId(const QByteArray& rawId);
37     explicit ToxId(const uint8_t* rawId, int len);
38     ToxId& operator=(const ToxId& other) = default;
39     ToxId& operator=(ToxId&& other) = default;
40 
41     bool operator==(const ToxId& other) const;
42     bool operator!=(const ToxId& other) const;
43     QString toString() const;
44     void clear();
45     bool isValid() const;
46 
47     static bool isValidToxId(const QString& id);
48     static bool isToxId(const QString& id);
49     const uint8_t* getBytes() const;
50     QByteArray getToxId() const;
51     ToxPk getPublicKey() const;
52     QString getNoSpamString() const;
53 
54 private:
55     void constructToxId(const QByteArray& rawId);
56 
57 public:
58     static const QRegularExpression ToxIdRegEx;
59 
60 private:
61     QByteArray toxId;
62 };
63 
64 #endif // TOXID_H
65