diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-04-15 12:22:19 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-04-15 12:22:19 +0000 |
| commit | fd84a9f73dd5fffebdf122a0ecd154281b701d52 (patch) | |
| tree | 17c373e5a1eb82da3fae0827c1c6915e2e704cd7 /source/QXmppUtils.cpp | |
| parent | ca824b7fe4b209f41072ac41ef263cd5c39da38b (diff) | |
| download | qxmpp-fd84a9f73dd5fffebdf122a0ecd154281b701d52.tar.gz | |
* move QImage-related code out of QXmppUtils
* make it possible to disable QtGui-dependent code
Diffstat (limited to 'source/QXmppUtils.cpp')
| -rw-r--r-- | source/QXmppUtils.cpp | 56 |
1 files changed, 7 insertions, 49 deletions
diff --git a/source/QXmppUtils.cpp b/source/QXmppUtils.cpp index f59462a1..bf58706b 100644 --- a/source/QXmppUtils.cpp +++ b/source/QXmppUtils.cpp @@ -22,17 +22,16 @@ */ -#include "QXmppUtils.h" -#include "QXmppLogger.h" +#include <QBuffer> +#include <QByteArray> +#include <QDateTime> #include <QDebug> +#include <QRegExp> #include <QString> #include <QXmlStreamWriter> -#include <QByteArray> -#include <QBuffer> -#include <QImage> -#include <QImageReader> -#include <QCryptographicHash> -#include <QDateTime> + +#include "QXmppUtils.h" +#include "QXmppLogger.h" QDateTime datetimeFromString(const QString &str) { @@ -137,45 +136,4 @@ QString unescapeString(const QString& str) return strOut; } -QString getImageType(const QByteArray& image) -{ - QBuffer buffer; - buffer.setData(image); - buffer.open(QIODevice::ReadOnly); - QString format = QImageReader::imageFormat(&buffer); - - if(format.toUpper() == "PNG") - return "image/png"; - else if(format.toUpper() == "MNG") - return "video/x-mng"; - else if(format.toUpper() == "GIF") - return "image/gif"; - else if(format.toUpper() == "BMP") - return "image/bmp"; - else if(format.toUpper() == "XPM") - return "image/x-xpm"; - else if(format.toUpper() == "SVG") - return "image/svg+xml"; - else if(format.toUpper() == "JPEG") - return "image/jpeg"; - - return "image/unknown"; -} -QString getImageHash(const QByteArray& image) -{ - if(image.isEmpty()) - return ""; - else - return QString(QCryptographicHash::hash(image, - QCryptographicHash::Sha1).toHex()); -} - -QImage getImageFromByteArray(const QByteArray& image) -{ - QBuffer buffer; - buffer.setData(image); - buffer.open(QIODevice::ReadOnly); - QImageReader imageReader(&buffer); - return imageReader.read(); -} |
