aboutsummaryrefslogtreecommitdiff
path: root/examples/GuiClient/utils.cpp
diff options
context:
space:
mode:
authorManjeet Dahiya <manjeetdahiya@gmail.com>2010-09-12 08:54:47 +0000
committerManjeet Dahiya <manjeetdahiya@gmail.com>2010-09-12 08:54:47 +0000
commite321944e15211065b802a8dde6038d63bd4988fa (patch)
tree13522ead2b60e77aabff62fd3f1fd3c9253604b9 /examples/GuiClient/utils.cpp
parent651181fa5a0d4c32986221a8a50ff9614a7e3be0 (diff)
downloadqxmpp-e321944e15211065b802a8dde6038d63bd4988fa.tar.gz
eol fix
Diffstat (limited to 'examples/GuiClient/utils.cpp')
-rw-r--r--examples/GuiClient/utils.cpp302
1 files changed, 151 insertions, 151 deletions
diff --git a/examples/GuiClient/utils.cpp b/examples/GuiClient/utils.cpp
index 251a7366..cea1c48a 100644
--- a/examples/GuiClient/utils.cpp
+++ b/examples/GuiClient/utils.cpp
@@ -1,151 +1,151 @@
-/*
- * Copyright (C) 2008-2010 The QXmpp developers
- *
- * Author:
- * Manjeet Dahiya
- *
- * Source:
- * http://code.google.com/p/qxmpp
- *
- * This file is a part of QXmpp library.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- */
-
-
-#include "utils.h"
-#include <QDir>
-#include <QDesktopServices>
-
-int comparisonWeightsPresenceStatusType(QXmppPresence::Status::Type statusType)
-{
- switch(statusType)
- {
- case QXmppPresence::Status::Online:
- case QXmppPresence::Status::Chat:
- return 0;
- case QXmppPresence::Status::DND:
- return 1;
- case QXmppPresence::Status::Away:
- case QXmppPresence::Status::XA:
- return 2;
- case QXmppPresence::Status::Offline:
- case QXmppPresence::Status::Invisible:
- return 3;
- default:
- return 5;
- }
-}
-
-int comparisonWeightsPresenceType(QXmppPresence::Type type)
-{
- switch(type)
- {
- case QXmppPresence::Available:
- return 0;
- case QXmppPresence::Unavailable:
- return 1;
- case QXmppPresence::Error:
- case QXmppPresence::Subscribe:
- case QXmppPresence::Subscribed:
- case QXmppPresence::Unsubscribe:
- case QXmppPresence::Unsubscribed:
- case QXmppPresence::Probe:
- return 3;
- default:
- return 5;
- }
-}
-
-QString presenceToStatusText(const QXmppPresence& presence)
-{
- QString statusText = presence.status().statusText();
- if(statusText.isEmpty())
- {
- if(presence.type() == QXmppPresence::Available)
- {
- switch(presence.status().type())
- {
- case QXmppPresence::Status::Invisible:
- case QXmppPresence::Status::Offline:
- statusText = "Offline";
- break;
- case QXmppPresence::Status::Online:
- case QXmppPresence::Status::Chat:
- statusText = "Available";
- break;
- case QXmppPresence::Status::Away:
- case QXmppPresence::Status::XA:
- statusText = "Idle";
- break;
- case QXmppPresence::Status::DND:
- statusText = "Busy";
- break;
- }
- }
- else
- statusText = "Offline";
- }
-
- return statusText;
-}
-
-QString getSettingsDir(const QString& bareJid)
-{
- if(bareJid.isEmpty())
- return "appCache/";
- else
- return QString("appCache/%1/").arg(bareJid);
-}
-
-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();
-}
-
-QString getImageType1(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";
-}
+/*
+ * Copyright (C) 2008-2010 The QXmpp developers
+ *
+ * Author:
+ * Manjeet Dahiya
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+
+#include "utils.h"
+#include <QDir>
+#include <QDesktopServices>
+
+int comparisonWeightsPresenceStatusType(QXmppPresence::Status::Type statusType)
+{
+ switch(statusType)
+ {
+ case QXmppPresence::Status::Online:
+ case QXmppPresence::Status::Chat:
+ return 0;
+ case QXmppPresence::Status::DND:
+ return 1;
+ case QXmppPresence::Status::Away:
+ case QXmppPresence::Status::XA:
+ return 2;
+ case QXmppPresence::Status::Offline:
+ case QXmppPresence::Status::Invisible:
+ return 3;
+ default:
+ return 5;
+ }
+}
+
+int comparisonWeightsPresenceType(QXmppPresence::Type type)
+{
+ switch(type)
+ {
+ case QXmppPresence::Available:
+ return 0;
+ case QXmppPresence::Unavailable:
+ return 1;
+ case QXmppPresence::Error:
+ case QXmppPresence::Subscribe:
+ case QXmppPresence::Subscribed:
+ case QXmppPresence::Unsubscribe:
+ case QXmppPresence::Unsubscribed:
+ case QXmppPresence::Probe:
+ return 3;
+ default:
+ return 5;
+ }
+}
+
+QString presenceToStatusText(const QXmppPresence& presence)
+{
+ QString statusText = presence.status().statusText();
+ if(statusText.isEmpty())
+ {
+ if(presence.type() == QXmppPresence::Available)
+ {
+ switch(presence.status().type())
+ {
+ case QXmppPresence::Status::Invisible:
+ case QXmppPresence::Status::Offline:
+ statusText = "Offline";
+ break;
+ case QXmppPresence::Status::Online:
+ case QXmppPresence::Status::Chat:
+ statusText = "Available";
+ break;
+ case QXmppPresence::Status::Away:
+ case QXmppPresence::Status::XA:
+ statusText = "Idle";
+ break;
+ case QXmppPresence::Status::DND:
+ statusText = "Busy";
+ break;
+ }
+ }
+ else
+ statusText = "Offline";
+ }
+
+ return statusText;
+}
+
+QString getSettingsDir(const QString& bareJid)
+{
+ if(bareJid.isEmpty())
+ return "appCache/";
+ else
+ return QString("appCache/%1/").arg(bareJid);
+}
+
+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();
+}
+
+QString getImageType1(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";
+}