From 2b2b251d5cfd324df9ec3bfdc110568a43f03140 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Wed, 18 Jul 2012 16:33:00 +0200 Subject: restore support for obsolete "invisible" presence (fixes issue #111) --- src/base/QXmppPresence.cpp | 4 ++++ src/base/QXmppPresence.h | 1 + tests/presence.cpp | 12 ++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/base/QXmppPresence.cpp b/src/base/QXmppPresence.cpp index 42143b10..e5821068 100644 --- a/src/base/QXmppPresence.cpp +++ b/src/base/QXmppPresence.cpp @@ -318,6 +318,8 @@ void QXmppPresence::Status::setTypeFromStr(const QString& str) m_type = QXmppPresence::Status::DND; else if(str == "xa") m_type = QXmppPresence::Status::XA; + else if(str == "invisible") + m_type = QXmppPresence::Status::Invisible; else { qWarning("QXmppPresence::Status::setTypeFromStr() invalid input string type %s", qPrintable(str)); @@ -341,6 +343,8 @@ QString QXmppPresence::Status::getTypeStr() const return "dnd"; case QXmppPresence::Status::Chat: return "chat"; + case QXmppPresence::Status::Invisible: + return "invisible"; default: qWarning("QXmppPresence::Status::getTypeStr() invalid type %d", (int)m_type); diff --git a/src/base/QXmppPresence.h b/src/base/QXmppPresence.h index b4a12be9..a34526c4 100644 --- a/src/base/QXmppPresence.h +++ b/src/base/QXmppPresence.h @@ -77,6 +77,7 @@ public: XA, ///< The entity or resource is away for an extended period. DND, ///< The entity or resource is busy ("Do Not Disturb"). Chat, ///< The entity or resource is actively interested in chatting. + Invisible ///< obsolete XEP-0018: Invisible Presence }; Status(QXmppPresence::Status::Type type = QXmppPresence::Status::Online, diff --git a/tests/presence.cpp b/tests/presence.cpp index 9c65566b..e134b30b 100644 --- a/tests/presence.cpp +++ b/tests/presence.cpp @@ -41,10 +41,14 @@ void tst_QXmppPresence::testPresence_data() QTest::newRow("unavailable") << QByteArray("") << int(QXmppPresence::Unavailable) << 0 << int(QXmppPresence::Status::Online) << "" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); QTest::newRow("error") << QByteArray("") << int(QXmppPresence::Error) << 0 << int(QXmppPresence::Status::Online) << "" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); - QTest::newRow("away") << QByteArray("awayIn a meeting5") << int(QXmppPresence::Available) << 5 << int(QXmppPresence::Status::Away) << "In a meeting" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); - QTest::newRow("dnd") << QByteArray("dndIn a meeting5") << int(QXmppPresence::Available) << 5 << int(QXmppPresence::Status::DND) << "In a meeting" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); - QTest::newRow("chat") << QByteArray("chatIn a meeting5") << int(QXmppPresence::Available) << 5 << int(QXmppPresence::Status::Chat) << "In a meeting" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); - QTest::newRow("xa") << QByteArray("xaIn a meeting5") << int(QXmppPresence::Available) << 5 << int(QXmppPresence::Status::XA) << "In a meeting" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); + QTest::newRow("full") << QByteArray("awayIn a meeting5") << int(QXmppPresence::Available) << 5 << int(QXmppPresence::Status::Away) << "In a meeting" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); + + // status type + QTest::newRow("away") << QByteArray("away") << int(QXmppPresence::Available) << 0 << int(QXmppPresence::Status::Away) << "" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); + QTest::newRow("dnd") << QByteArray("dnd") << int(QXmppPresence::Available) << 0 << int(QXmppPresence::Status::DND) << "" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); + QTest::newRow("chat") << QByteArray("chat") << int(QXmppPresence::Available) << 0 << int(QXmppPresence::Status::Chat) << "" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); + QTest::newRow("xa") << QByteArray("xa") << int(QXmppPresence::Available) << 0 << int(QXmppPresence::Status::XA) << "" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); + QTest::newRow("invisible") << QByteArray("invisible") << int(QXmppPresence::Available) << 0 << int(QXmppPresence::Status::Invisible) << "" << int(QXmppPresence::VCardUpdateNone) << QByteArray(); QTest::newRow("vcard-photo") << QByteArray( "" -- cgit v1.2.3