QXmpp Version: 0.9.3
QXmppUtils.h
1/*
2 * Copyright (C) 2008-2014 The QXmpp developers
3 *
4 * Authors:
5 * Manjeet Dahiya
6 * Jeremy Lainé
7 *
8 * Source:
9 * https://github.com/qxmpp-project/qxmpp
10 *
11 * This file is a part of QXmpp library.
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 */
24
25
26#ifndef QXMPPUTILS_H
27#define QXMPPUTILS_H
28
29// forward declarations of QXmlStream* classes will not work on Mac, we need to
30// include the whole header.
31// See http://lists.trolltech.com/qt-interest/2008-07/thread00798-0.html
32// for an explanation.
33#include <QXmlStreamWriter>
34
35#include "QXmppGlobal.h"
36
37class QByteArray;
38class QDateTime;
39class QDomElement;
40class QString;
41class QStringList;
42
45class QXMPP_EXPORT QXmppUtils
46{
47public:
48 // XEP-0082: XMPP Date and Time Profiles
49 static QDateTime datetimeFromString(const QString &str);
50 static QString datetimeToString(const QDateTime &dt);
51 static int timezoneOffsetFromString(const QString &str);
52 static QString timezoneOffsetToString(int secs);
53
54 static QString jidToDomain(const QString& jid);
55 static QString jidToResource(const QString& jid);
56 static QString jidToUser(const QString& jid);
57 static QString jidToBareJid(const QString& jid);
58
59 static quint32 generateCrc32(const QByteArray &input);
60 static QByteArray generateHmacMd5(const QByteArray &key, const QByteArray &text);
61 static QByteArray generateHmacSha1(const QByteArray &key, const QByteArray &text);
62 static int generateRandomInteger(int N);
63 static QByteArray generateRandomBytes(int length);
64 static QString generateStanzaHash(int length=32);
65};
66
67void helperToXmlAddAttribute(QXmlStreamWriter* stream, const QString& name,
68 const QString& value);
69void helperToXmlAddTextElement(QXmlStreamWriter* stream, const QString& name,
70 const QString& value);
71
72#endif // QXMPPUTILS_H
The QXmppUtils class contains static utility functions.
Definition: QXmppUtils.h:46