QXmpp Version: 1.5.6
Loading...
Searching...
No Matches
QXmppUtils.h
1// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <manjeetdahiya@gmail.com>
2// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
3//
4// SPDX-License-Identifier: LGPL-2.1-or-later
5
6#ifndef QXMPPUTILS_H
7#define QXMPPUTILS_H
8
9// forward declarations of QXmlStream* classes will not work on Mac, we need to
10// include the whole header.
11// See http://lists.trolltech.com/qt-interest/2008-07/thread00798-0.html
12// for an explanation.
13#include "QXmppGlobal.h"
14
15#include <QXmlStreamWriter>
16
17class QByteArray;
18class QDateTime;
19class QDomElement;
20class QString;
21
24class QXMPP_EXPORT QXmppUtils
25{
26public:
27 // XEP-0082: XMPP Date and Time Profiles
28 static QDateTime datetimeFromString(const QString &str);
29 static QString datetimeToString(const QDateTime &dt);
30 static int timezoneOffsetFromString(const QString &str);
31 static QString timezoneOffsetToString(int secs);
32
33 static QString jidToDomain(const QString &jid);
34 static QString jidToResource(const QString &jid);
35 static QString jidToUser(const QString &jid);
36 static QString jidToBareJid(const QString &jid);
37
38 static quint32 generateCrc32(const QByteArray &input);
39 static QByteArray generateHmacMd5(const QByteArray &key, const QByteArray &text);
40 static QByteArray generateHmacSha1(const QByteArray &key, const QByteArray &text);
41 static int generateRandomInteger(int N);
42 static QByteArray generateRandomBytes(int length);
43 static QString generateStanzaUuid();
44 static QString generateStanzaHash(int length = 36);
45};
46
47void helperToXmlAddAttribute(QXmlStreamWriter *stream, const QString &name,
48 const QString &value);
49void helperToXmlAddTextElement(QXmlStreamWriter *stream, const QString &name,
50 const QString &value);
51
52#endif // QXMPPUTILS_H
The QXmppUtils class contains static utility functions.
Definition QXmppUtils.h:25