aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppBitsOfBinaryContentId.h
blob: 79e8a625d76da99499be033a51408aaefd58ac5c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#ifndef QXMPPBITSOFBINARYCONTENTID_H
#define QXMPPBITSOFBINARYCONTENTID_H

#include "QXmppGlobal.h"

#include <QCryptographicHash>
#include <QSharedDataPointer>

class QXmppBitsOfBinaryContentIdPrivate;

class QXMPP_EXPORT QXmppBitsOfBinaryContentId
{
public:
    static QXmppBitsOfBinaryContentId fromCidUrl(const QString &input);
    static QXmppBitsOfBinaryContentId fromContentId(const QString &input);

    QXmppBitsOfBinaryContentId();
    QXmppBitsOfBinaryContentId(const QXmppBitsOfBinaryContentId &cid);
    QXmppBitsOfBinaryContentId(QXmppBitsOfBinaryContentId &&);
    ~QXmppBitsOfBinaryContentId();

    QXmppBitsOfBinaryContentId &operator=(const QXmppBitsOfBinaryContentId &other);
    QXmppBitsOfBinaryContentId &operator=(QXmppBitsOfBinaryContentId &&);

    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