diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-09-01 08:29:31 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-09-01 08:29:31 +0000 |
| commit | b110d11d15d2e67b3cb00ea1d84a08c60d375c3d (patch) | |
| tree | b5a6d50c3e7fa324e4bfb8a4692295195d9e32e2 /src | |
| parent | bdb959c784e4f3a5be7424f7ff70d08821d1e164 (diff) | |
| download | qxmpp-b110d11d15d2e67b3cb00ea1d84a08c60d375c3d.tar.gz | |
add code for using getImageType without QtGui
Diffstat (limited to 'src')
| -rw-r--r-- | src/QXmppVCard.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/QXmppVCard.cpp b/src/QXmppVCard.cpp index 9b4b93b2..ee336805 100644 --- a/src/QXmppVCard.cpp +++ b/src/QXmppVCard.cpp @@ -34,32 +34,22 @@ #include "QXmppUtils.h" #include "QXmppConstants.h" -static QString getImageType(const QByteArray& image) +QString getImageType(const QByteArray &contents) { -#ifndef QXMPP_NO_GUI - QBuffer buffer; - buffer.setData(image); - buffer.open(QIODevice::ReadOnly); - QString format = QImageReader::imageFormat(&buffer); - - if(format.toUpper() == "PNG") + if (contents.startsWith("\x89PNG\x0d\x0a\x1a\x0a")) return "image/png"; - else if(format.toUpper() == "MNG") + else if (contents.startsWith("\x8aMNG")) return "video/x-mng"; - else if(format.toUpper() == "GIF") + else if (contents.startsWith("GIF8")) return "image/gif"; - else if(format.toUpper() == "BMP") + else if (contents.startsWith("BM")) return "image/bmp"; - else if(format.toUpper() == "XPM") + else if (contents.contains("/* XPM */")) return "image/x-xpm"; - else if(format.toUpper() == "SVG") - return "image/svg+xml"; - else if(format.toUpper() == "JPEG") + else if (contents.contains("<?xml") && contents.contains("<svg")) + return "image/svg+xml"; + else if (contents.startsWith("\xFF\xD8\xFF\xE0")) return "image/jpeg"; -#else - Q_UNUSED(image); -#endif - return "image/unknown"; } @@ -201,7 +191,7 @@ QString QXmppVCard::url() const /// homepage or a location at which you can find real-time information about /// the vCard. /// -/// \param vCard +/// \param url void QXmppVCard::setUrl(const QString& url) { |
