qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
ToxId Class Reference

This class represents a Tox ID. More...

#include <toxid.h>

Collaboration diagram for ToxId:
Collaboration graph

Public Member Functions

 ToxId ()
 The default constructor. Creates an empty Tox ID. More...
 
 ToxId (const ToxId &other)
 The copy constructor. More...
 
 ToxId (const QString &id)
 Create a Tox ID from a QString. More...
 
 ToxId (const QByteArray &rawId)
 Create a Tox ID from a QByteArray. More...
 
 ToxId (const uint8_t *rawId, int len)
 Create a Tox ID from uint8_t bytes and lenght, convenience function for toxcore interface. More...
 
ToxIdoperator= (const ToxId &other)=default
 
ToxIdoperator= (ToxId &&other)=default
 
bool operator== (const ToxId &other) const
 Compares the equality of the Public Key. More...
 
bool operator!= (const ToxId &other) const
 Compares the inequality of the Public Key. More...
 
QString toString () const
 Returns the Tox ID converted to QString. Is equal to getPublicKey() if the Tox ID was constructed from only a Public Key. More...
 
void clear ()
 Clears all elements of the Tox ID. More...
 
bool isValid () const
 Check it it's a valid Tox ID by verifying the checksum. More...
 
const uint8_t * getBytes () const
 Gets the ToxID as bytes, convenience function for toxcore interface. More...
 
QByteArray getToxId () const
 
ToxPk getPublicKey () const
 Gets the Public Key part of the ToxID. More...
 
QString getNoSpamString () const
 Returns the NoSpam value converted to QString. More...
 

Static Public Member Functions

static bool isValidToxId (const QString &id)
 Check, that id is a valid Tox ID. More...
 
static bool isToxId (const QString &id)
 Check, that id is probably a valid Tox ID. More...
 

Static Public Attributes

static const QRegularExpression ToxIdRegEx
 

Private Member Functions

void constructToxId (const QByteArray &rawId)
 

Private Attributes

QByteArray toxId
 

Detailed Description

This class represents a Tox ID.

An ID is composed of 32 bytes long public key, 4 bytes long NoSpam and 2 bytes long checksum.

e.g.

| C7719C6808C14B77348004956D1D98046CE09A34370E7608150EAD74C3815D30 | C8BA3AB9 | BEB9
| / |
| / NoSpam | Checksum
| Public Key (PK), 32 bytes, 64 characters / 4 bytes | 2 bytes
| | 8 characters| 4 characters

Definition at line 29 of file toxid.h.

Constructor & Destructor Documentation

◆ ToxId() [1/5]

ToxId::ToxId ( )

The default constructor. Creates an empty Tox ID.

Definition at line 62 of file toxid.cpp.

Here is the caller graph for this function:

◆ ToxId() [2/5]

ToxId::ToxId ( const ToxId other)

The copy constructor.

Parameters
otherToxId to copy

Definition at line 70 of file toxid.cpp.

◆ ToxId() [3/5]

ToxId::ToxId ( const QString &  id)
explicit

Create a Tox ID from a QString.

If the given rawId is not a valid Tox ID, but can be a Public Key then: publicKey == rawId and noSpam == 0 == checkSum. If the given rawId isn't a valid Public Key or Tox ID a ToxId with all zero bytes is created.

Parameters
idTox ID string to convert to ToxId object

Definition at line 83 of file toxid.cpp.

Here is the call graph for this function:

◆ ToxId() [4/5]

ToxId::ToxId ( const QByteArray &  rawId)
explicit

Create a Tox ID from a QByteArray.

If the given rawId is not a valid Tox ID, but can be a Public Key then: publicKey == rawId and noSpam == 0 == checkSum. If the given rawId isn't a valid Public Key or Tox ID a ToxId with all zero bytes is created.

Parameters
rawIdTox ID bytes to convert to ToxId object

Definition at line 102 of file toxid.cpp.

Here is the call graph for this function:

◆ ToxId() [5/5]

ToxId::ToxId ( const uint8_t *  rawId,
int  len 
)
explicit

Create a Tox ID from uint8_t bytes and lenght, convenience function for toxcore interface.

If the given rawId is not a valid Tox ID, but can be a Public Key then: publicKey == rawId and noSpam == 0 == checkSum. If the given rawId isn't a valid Public Key or Tox ID a ToxId with all zero bytes is created.

Parameters
rawIdPointer to bytes to convert to ToxId object
lenNumber of bytes to read. Must be TOX_PUBLIC_KEY_SIZE for a Public Key or TOX_ADDRESS_SIZE for a Tox ID.

Definition at line 118 of file toxid.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ clear()

void ToxId::clear ( )

Clears all elements of the Tox ID.

Definition at line 168 of file toxid.cpp.

◆ constructToxId()

void ToxId::constructToxId ( const QByteArray &  rawId)
private

Definition at line 125 of file toxid.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBytes()

const uint8_t * ToxId::getBytes ( ) const

Gets the ToxID as bytes, convenience function for toxcore interface.

Returns
The ToxID as uint8_t* if isValid() is true, else a nullptr.

Definition at line 177 of file toxid.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNoSpamString()

QString ToxId::getNoSpamString ( ) const

Returns the NoSpam value converted to QString.

Returns
The NoSpam value as QString or "" if the ToxId was constructed from a Public Key.

Definition at line 204 of file toxid.cpp.

Here is the caller graph for this function:

◆ getPublicKey()

ToxPk ToxId::getPublicKey ( ) const

Gets the Public Key part of the ToxID.

Returns
Public Key of the ToxID

Definition at line 190 of file toxid.cpp.

Here is the caller graph for this function:

◆ getToxId()

QByteArray ToxId::getToxId ( ) const

◆ isToxId()

bool ToxId::isToxId ( const QString &  id)
static

Check, that id is probably a valid Tox ID.

Parameters
idTox ID to check.
Returns
True if the string can be a ToxID, false otherwise.
Note
Doesn't validate checksum.

Definition at line 230 of file toxid.cpp.

Here is the caller graph for this function:

◆ isValid()

bool ToxId::isValid ( ) const

Check it it's a valid Tox ID by verifying the checksum.

Returns
True if it is a valid Tox ID, false otherwise.

Definition at line 239 of file toxid.cpp.

Here is the caller graph for this function:

◆ isValidToxId()

bool ToxId::isValidToxId ( const QString &  id)
static

Check, that id is a valid Tox ID.

Parameters
idTox ID to check.
Returns
True if id is a valid Tox ID, false otherwise.
Note
Validates the checksum.

Definition at line 219 of file toxid.cpp.

Here is the call graph for this function:

◆ operator!=()

bool ToxId::operator!= ( const ToxId other) const

Compares the inequality of the Public Key.

Parameters
otherTox ID to compare.
Returns
True if both Tox IDs have different public keys, false otherwise.

Definition at line 150 of file toxid.cpp.

Here is the call graph for this function:

◆ operator=() [1/2]

ToxId& ToxId::operator= ( const ToxId other)
default

◆ operator=() [2/2]

ToxId& ToxId::operator= ( ToxId &&  other)
default

◆ operator==()

bool ToxId::operator== ( const ToxId other) const

Compares the equality of the Public Key.

Parameters
otherTox ID to compare.
Returns
True if both Tox IDs have the same public keys, false otherwise.

Definition at line 140 of file toxid.cpp.

Here is the call graph for this function:

◆ toString()

QString ToxId::toString ( ) const

Returns the Tox ID converted to QString. Is equal to getPublicKey() if the Tox ID was constructed from only a Public Key.

Returns
The Tox ID as QString.

Definition at line 160 of file toxid.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ toxId

QByteArray ToxId::toxId
private

Definition at line 60 of file toxid.h.

◆ ToxIdRegEx

const QRegularExpression ToxId::ToxIdRegEx
static

Definition at line 57 of file toxid.h.


The documentation for this class was generated from the following files: