QXmpp
Version:0.9.3
|
00001 /* 00002 * Copyright (C) 2008-2014 The QXmpp developers 00003 * 00004 * Authors: 00005 * Manjeet Dahiya 00006 * Jeremy Lainé 00007 * 00008 * Source: 00009 * https://github.com/qxmpp-project/qxmpp 00010 * 00011 * This file is a part of QXmpp library. 00012 * 00013 * This library is free software; you can redistribute it and/or 00014 * modify it under the terms of the GNU Lesser General Public 00015 * License as published by the Free Software Foundation; either 00016 * version 2.1 of the License, or (at your option) any later version. 00017 * 00018 * This library is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 * Lesser General Public License for more details. 00022 * 00023 */ 00024 00025 00026 #ifndef QXMPPUTILS_H 00027 #define QXMPPUTILS_H 00028 00029 // forward declarations of QXmlStream* classes will not work on Mac, we need to 00030 // include the whole header. 00031 // See http://lists.trolltech.com/qt-interest/2008-07/thread00798-0.html 00032 // for an explanation. 00033 #include <QXmlStreamWriter> 00034 00035 #include "QXmppGlobal.h" 00036 00037 class QByteArray; 00038 class QDateTime; 00039 class QDomElement; 00040 class QString; 00041 class QStringList; 00042 00045 class QXMPP_EXPORT QXmppUtils 00046 { 00047 public: 00048 // XEP-0082: XMPP Date and Time Profiles 00049 static QDateTime datetimeFromString(const QString &str); 00050 static QString datetimeToString(const QDateTime &dt); 00051 static int timezoneOffsetFromString(const QString &str); 00052 static QString timezoneOffsetToString(int secs); 00053 00054 static QString jidToDomain(const QString& jid); 00055 static QString jidToResource(const QString& jid); 00056 static QString jidToUser(const QString& jid); 00057 static QString jidToBareJid(const QString& jid); 00058 00059 static quint32 generateCrc32(const QByteArray &input); 00060 static QByteArray generateHmacMd5(const QByteArray &key, const QByteArray &text); 00061 static QByteArray generateHmacSha1(const QByteArray &key, const QByteArray &text); 00062 static int generateRandomInteger(int N); 00063 static QByteArray generateRandomBytes(int length); 00064 static QString generateStanzaHash(int length=32); 00065 }; 00066 00067 void helperToXmlAddAttribute(QXmlStreamWriter* stream, const QString& name, 00068 const QString& value); 00069 void helperToXmlAddTextElement(QXmlStreamWriter* stream, const QString& name, 00070 const QString& value); 00071 00072 #endif // QXMPPUTILS_H