QXmpp: QXmppBitsOfBinaryContentId Class Reference

QXmpp Version: 1.14.4

Loading...
Searching...
No Matches
QXmppBitsOfBinaryContentId Class Reference

## Public Member Functions
| QXmppBitsOfBinaryContentId ()
| QXmppBitsOfBinaryContentId (const QXmppBitsOfBinaryContentId &cid)
| Default copy-constructor.
| QXmppBitsOfBinaryContentId (QXmppBitsOfBinaryContentId &&)
| Default move-constructor.
| ~QXmppBitsOfBinaryContentId ()
| Default destructor.
QXmppBitsOfBinaryContentId & | operator= (const QXmppBitsOfBinaryContentId &other)
| Default assignment operator.
QXmppBitsOfBinaryContentId & | operator= (QXmppBitsOfBinaryContentId &&)
| Default move-assignment operator.
QString | toContentId () const
QString | toCidUrl () const
QByteArray | hash () const
void | setHash (const QByteArray &hash)
QCryptographicHash::Algorithm | algorithm () const
void | setAlgorithm (QCryptographicHash::Algorithm algo)
bool | isValid () const
bool | operator== (const QXmppBitsOfBinaryContentId &other) const

## Static Public Member Functions
static QXmppBitsOfBinaryContentId | fromCidUrl (const QString &input)
static QXmppBitsOfBinaryContentId | fromContentId (const QString &input)
static bool | isBitsOfBinaryContentId (const QString &uri, bool checkIsCidUrl=false)

## Detailed Description

QXmppBitsOfBinaryContentId represents a link to or an identifier of XEP-0231: Bits of Binary data.

Currently supported hash algorithms:

- MD4
- MD5
- SHA-1
- SHA-2 (SHA-224, SHA-256, SHA-384, SHA-512)
- SHA-3 (SHA3-224, SHA3-256, SHA3-384, SHA3-512)
- BLAKE2 (BLAKE2b256, BLAKE2b512) (requires Qt 6, since QXmpp 1.5)

Note
  Security notice: When using the content IDs to cache data between multiple entities it is important to avoid hash collisions. SHA-1 cannot fulfill this requirement. You SHOULD use another more secure hash algorithm if you do this.

Since
  QXmpp 1.2

## Constructor & Destructor Documentation

## ◆ QXmppBitsOfBinaryContentId()

QXmppBitsOfBinaryContentId::QXmppBitsOfBinaryContentId | ( |  | ) |

Default contructor

## Member Function Documentation

## ◆ algorithm()

QCryptographicHash::Algorithm QXmppBitsOfBinaryContentId::algorithm | ( |  | ) | const

Returns the hash algorithm used to calculate the `hash` value

The default value is `QCryptographicHash::Sha1`.

## ◆ fromCidUrl()

QXmppBitsOfBinaryContentId QXmppBitsOfBinaryContentId::fromCidUrl | ( | const QString & | input | ) |
| static

Parses a `QXmppBitsOfBinaryContentId` from a XEP-0231: Bits of Binary `cid:` URL

In case parsing failed, the returned `QXmppBitsOfBinaryContentId` is empty.

See also
  QXmppBitsOfBinaryContentId::fromContentId

## ◆ fromContentId()

QXmppBitsOfBinaryContentId QXmppBitsOfBinaryContentId::fromContentId | ( | const QString & | input | ) |
| static

Parses a `QXmppBitsOfBinaryContentId` from a XEP-0231: Bits of Binary content id

In case parsing failed, the returned `QXmppBitsOfBinaryContentId` is empty.

Note
  This does not allow `cid:` URLs to be passed. Use `QXmppBitsOfBinaryContentId::fromCidUrl` for that purpose.

See also
  QXmppBitsOfBinaryContentId::fromCidUrl

## ◆ hash()

QByteArray QXmppBitsOfBinaryContentId::hash | ( |  | ) | const

Returns the hash value in binary form

## ◆ isBitsOfBinaryContentId()

bool QXmppBitsOfBinaryContentId::isBitsOfBinaryContentId | ( | const QString & | input,
|  | bool | checkIsCidUrl = false )
| static

Checks whether `input` is a Bits of Binary content id or `cid:` URL

Parameters

  input | The string to be checked.
  checkIsCidUrl | If true, it only accepts `cid:` URLs.

Returns
  True, if `input` is valid.

## ◆ isValid()

bool QXmppBitsOfBinaryContentId::isValid | ( |  | ) | const

Checks whether the content id is valid and can be serialized into a string.

Also checks the length of the hash.

Returns
  True, if the set hashing algorithm is supported, a hash value is set and its length is correct, false otherwise.

## ◆ operator==()

bool QXmppBitsOfBinaryContentId::operator== | ( | const QXmppBitsOfBinaryContentId & | other | ) | const

Returns true, if two `QXmppBitsOfBinaryContentId` equal

## ◆ setAlgorithm()

void QXmppBitsOfBinaryContentId::setAlgorithm | ( | QCryptographicHash::Algorithm | algo | ) |

Sets the hash algorithm used to calculate the `hash` value

The default value is `QCryptographicHash::Sha1`.

Note
  Only change this, if you know what you do. The XEP allows other hashing algorithms than SHA-1 to be used, but not all clients support this.

## ◆ setHash()

void QXmppBitsOfBinaryContentId::setHash | ( | const QByteArray & | hash | ) |

Sets the hash value in binary form

## ◆ toCidUrl()

QString QXmppBitsOfBinaryContentId::toCidUrl | ( |  | ) | const

Returns a XEP-0231: Bits of Binary `cid:` URL

## ◆ toContentId()

QString QXmppBitsOfBinaryContentId::toContentId | ( |  | ) | const

Returns a XEP-0231: Bits of Binary content id

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

- QXmppBitsOfBinaryContentId.h
- QXmppBitsOfBinary.cpp