aboutsummaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2014-03-26 15:49:57 +0100
committerJeremy Lainé <jeremy.laine@m4x.org>2014-03-26 15:49:57 +0100
commit742f672a580461271cbe25c5e87f42e9dc4c3ede (patch)
treea4ef3cdf1d1613b8844184f9aad04be8acc66cad /src/base
parentab5bdff45a304730ba5194e328bfc62267e366dc (diff)
downloadqxmpp-742f672a580461271cbe25c5e87f42e9dc4c3ede.tar.gz
Remove deprecated QXmppPresence::Status type
Diffstat (limited to 'src/base')
-rw-r--r--src/base/QXmppPresence.cpp114
-rw-r--r--src/base/QXmppPresence.h42
2 files changed, 27 insertions, 129 deletions
diff --git a/src/base/QXmppPresence.cpp b/src/base/QXmppPresence.cpp
index 5934c491..79e98dcf 100644
--- a/src/base/QXmppPresence.cpp
+++ b/src/base/QXmppPresence.cpp
@@ -53,8 +53,9 @@ class QXmppPresencePrivate : public QSharedData
{
public:
QXmppPresence::AvailableStatusType availableStatusType;
+ int priority;
+ QString statusText;
QXmppPresence::Type type;
- QXmppPresence::Status status;
/// XEP-0153: vCard-Based Avatars
@@ -84,6 +85,8 @@ public:
QXmppPresence::QXmppPresence(QXmppPresence::Type type)
: d(new QXmppPresencePrivate)
{
+ d->availableStatusType = Online;
+ d->priority = 0;
d->type = type;
d->mucSupported = false;
d->vCardUpdateType = VCardUpdateNone;
@@ -120,35 +123,35 @@ QXmppPresence &QXmppPresence::operator=(const QXmppPresence &other)
QXmppPresence::AvailableStatusType QXmppPresence::availableStatusType() const
{
- return static_cast<QXmppPresence::AvailableStatusType>(d->status.type());
+ return d->availableStatusType;
}
/// Sets the availability status type, for instance busy or away.
void QXmppPresence::setAvailableStatusType(AvailableStatusType type)
{
- d->status.setType(static_cast<QXmppPresence::Status::Type>(type));
+ d->availableStatusType = type;
}
/// Returns the priority level of the resource.
int QXmppPresence::priority() const
{
- return d->status.priority();
+ return d->priority;
}
/// Sets the \a priority level of the resource.
void QXmppPresence::setPriority(int priority)
{
- d->status.setPriority(priority);
+ d->priority = priority;
}
/// Returns the status text, a textual description of the user's status.
QString QXmppPresence::statusText() const
{
- return d->status.statusText();
+ return d->statusText;
}
/// Sets the status text, a textual description of the user's status.
@@ -157,7 +160,7 @@ QString QXmppPresence::statusText() const
void QXmppPresence::setStatusText(const QString& statusText)
{
- d->status.setStatusText(statusText);
+ d->statusText = statusText;
}
/// Returns the presence type.
@@ -193,7 +196,15 @@ void QXmppPresence::parse(const QDomElement &element)
break;
}
}
- d->status.parse(element);
+ const QString show = element.firstChildElement("show").text();
+ for (int i = Online; i <= Invisible; i++) {
+ if (show == presence_shows[i]) {
+ d->availableStatusType = static_cast<AvailableStatusType>(i);
+ break;
+ }
+ }
+ d->statusText = element.firstChildElement("status").text();
+ d->priority = element.firstChildElement("priority").text().toInt();
QXmppElementList extensions;
QDomElement xElement = element.firstChildElement();
@@ -275,7 +286,14 @@ void QXmppPresence::toXml(QXmlStreamWriter *xmlWriter) const
helperToXmlAddAttribute(xmlWriter,"to", to());
helperToXmlAddAttribute(xmlWriter,"from", from());
helperToXmlAddAttribute(xmlWriter,"type", presence_types[d->type]);
- d->status.toXml(xmlWriter);
+
+ const QString show = presence_shows[d->availableStatusType];
+ if (!show.isEmpty())
+ helperToXmlAddTextElement(xmlWriter, "show", show);
+ if (d->statusText.isEmpty())
+ helperToXmlAddTextElement(xmlWriter, "status", d->statusText);
+ if (d->priority != 0)
+ helperToXmlAddTextElement(xmlWriter, "priority", QString::number(d->priority));
error().toXml(xmlWriter);
@@ -478,81 +496,3 @@ void QXmppPresence::setMucSupported(bool supported)
{
d->mucSupported = supported;
}
-
-/// \cond
-const QXmppPresence::Status& QXmppPresence::status() const
-{
- return d->status;
-}
-
-QXmppPresence::Status& QXmppPresence::status()
-{
- return d->status;
-}
-
-void QXmppPresence::setStatus(const QXmppPresence::Status& status)
-{
- d->status = status;
-}
-
-QXmppPresence::Status::Status(QXmppPresence::Status::Type type,
- const QString statusText, int priority) :
- m_type(type),
- m_statusText(statusText), m_priority(priority)
-{
-}
-
-QXmppPresence::Status::Type QXmppPresence::Status::type() const
-{
- return m_type;
-}
-
-void QXmppPresence::Status::setType(QXmppPresence::Status::Type type)
-{
- m_type = type;
-}
-
-QString QXmppPresence::Status::statusText() const
-{
- return m_statusText;
-}
-
-void QXmppPresence::Status::setStatusText(const QString& str)
-{
- m_statusText = str;
-}
-
-int QXmppPresence::Status::priority() const
-{
- return m_priority;
-}
-
-void QXmppPresence::Status::setPriority(int priority)
-{
- m_priority = priority;
-}
-
-void QXmppPresence::Status::parse(const QDomElement &element)
-{
- const QString show = element.firstChildElement("show").text();
- for (int i = Online; i <= Invisible; i++) {
- if (show == presence_shows[i]) {
- m_type = static_cast<Type>(i);
- break;
- }
- }
- m_statusText = element.firstChildElement("status").text();
- m_priority = element.firstChildElement("priority").text().toInt();
-}
-
-void QXmppPresence::Status::toXml(QXmlStreamWriter *xmlWriter) const
-{
- const QString show = presence_shows[m_type];
- if (!show.isEmpty())
- helperToXmlAddTextElement(xmlWriter, "show", show);
- if (!m_statusText.isEmpty())
- helperToXmlAddTextElement(xmlWriter, "status", m_statusText);
- if (m_priority != 0)
- helperToXmlAddTextElement(xmlWriter, "priority", QString::number(m_priority));
-}
-/// \endcond
diff --git a/src/base/QXmppPresence.h b/src/base/QXmppPresence.h
index 1029ce5c..b58afb50 100644
--- a/src/base/QXmppPresence.h
+++ b/src/base/QXmppPresence.h
@@ -73,48 +73,6 @@ public:
/// (empty photo element) and mere support for the protocol (empty update child).
};
- /// \cond
- // deprecated since 0.6.2
- class QXMPP_EXPORT Status
- {
- public:
- /// This enum is used to describe an availability status.
- enum Type
- {
- Online = 0, ///< The entity or resource is online.
- Away, ///< The entity or resource is temporarily away.
- 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,
- const QString statusText = "", int priority = 0);
-
- QXmppPresence::Status::Type type() const;
- void setType(QXmppPresence::Status::Type);
-
- QString statusText() const;
- void setStatusText(const QString&);
-
- int priority() const;
- void setPriority(int);
-
- void parse(const QDomElement &element);
- void toXml(QXmlStreamWriter *writer) const;
-
- private:
- QXmppPresence::Status::Type m_type;
- QString m_statusText;
- int m_priority;
- };
-
- QXmppPresence::Status Q_DECL_DEPRECATED &status();
- const QXmppPresence::Status Q_DECL_DEPRECATED &status() const;
- void Q_DECL_DEPRECATED setStatus(const QXmppPresence::Status&);
- /// \endcond
-
QXmppPresence(QXmppPresence::Type type = QXmppPresence::Available);
QXmppPresence(const QXmppPresence &other);
~QXmppPresence();