diff options
| author | Linus Jahn <lnj@kaidan.im> | 2019-11-16 22:39:26 +0100 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2019-12-06 22:26:12 +0100 |
| commit | c470dbdfe053ef0e8d7e196982013f1edf2aaff5 (patch) | |
| tree | 863217f93b2071caab71b343c12bc59af875d33d /src/base/QXmppBitsOfBinaryContentId.h | |
| parent | eb3e44bbe886315de76c89555403c95cd28e182f (diff) | |
| download | qxmpp-c470dbdfe053ef0e8d7e196982013f1edf2aaff5.tar.gz | |
Implement XEP-0231: Bits of Binary: content identifiers
This implements parsing and serialization of content identifiers from
XEP-0231: Bits of Binary in version 1.0.
Diffstat (limited to 'src/base/QXmppBitsOfBinaryContentId.h')
| -rw-r--r-- | src/base/QXmppBitsOfBinaryContentId.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/base/QXmppBitsOfBinaryContentId.h b/src/base/QXmppBitsOfBinaryContentId.h new file mode 100644 index 00000000..7bf93685 --- /dev/null +++ b/src/base/QXmppBitsOfBinaryContentId.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2008-2019 The QXmpp developers + * + * Author: + * Linus Jahn + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef QXMPPBITSOFBINARYCONTENTID_H +#define QXMPPBITSOFBINARYCONTENTID_H + +#include <QSharedDataPointer> +#include <QCryptographicHash> + +#include "QXmppGlobal.h" + +class QXmppBitsOfBinaryContentIdPrivate; + +/// \class QXmppBitsOfBinaryContentId represents a link to or an identifier of +/// XEP-0231: Bits of Binary data. +/// +/// \since QXmpp 1.2 + +class QXMPP_EXPORT QXmppBitsOfBinaryContentId +{ +public: + static QXmppBitsOfBinaryContentId fromCidUrl(const QString &input); + static QXmppBitsOfBinaryContentId fromContentId(const QString &input); + + QXmppBitsOfBinaryContentId(); + QXmppBitsOfBinaryContentId(const QXmppBitsOfBinaryContentId &cid); + ~QXmppBitsOfBinaryContentId(); + + QXmppBitsOfBinaryContentId &operator=(const QXmppBitsOfBinaryContentId &other); + + 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; + + static bool isBitsOfBinaryContentId(const QString &uri, bool checkIsCidUrl = false); + + bool operator==(const QXmppBitsOfBinaryContentId &other) const; + +private: + QSharedDataPointer<QXmppBitsOfBinaryContentIdPrivate> d; +}; + +#endif // QXMPPBITSOFBINARYCONTENTID_H |
