diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-04-15 08:21:39 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-04-15 08:21:39 +0000 |
| commit | fa8d7ed727b892aefb3fc4741c57e0466848b6da (patch) | |
| tree | bd8d58fed06bf96c3000fa4763cd09c7a174f1b0 /source | |
| parent | c0e76a9646b63f8135b6a4c5774c353fc7842c83 (diff) | |
| download | qxmpp-fa8d7ed727b892aefb3fc4741c57e0466848b6da.tar.gz | |
make QXmppRosterIq::Item and QXmppRosterEntry APIs converge
Diffstat (limited to 'source')
| -rw-r--r-- | source/QXmppRoster.cpp | 10 | ||||
| -rw-r--r-- | source/QXmppRoster.h | 1 | ||||
| -rw-r--r-- | source/QXmppRosterIq.cpp | 35 | ||||
| -rw-r--r-- | source/QXmppRosterIq.h | 7 |
4 files changed, 20 insertions, 33 deletions
diff --git a/source/QXmppRoster.cpp b/source/QXmppRoster.cpp index c5fcac77..06f79430 100644 --- a/source/QXmppRoster.cpp +++ b/source/QXmppRoster.cpp @@ -227,16 +227,6 @@ void QXmppRoster::QXmppRosterEntry::setSubscriptionStatus(const QString& status) m_subscriptionStatus = status; } -/// Adds the group entry of the roster entry. -/// -/// \param group name as a QString -/// - -void QXmppRoster::QXmppRosterEntry::addGroupEntry(const QString& group) -{ - m_groups << group; -} - /// Sets the groups of the roster entry. /// /// \param groups list of all the groups as a QSet<QString> diff --git a/source/QXmppRoster.h b/source/QXmppRoster.h index 727eba85..3dccd056 100644 --- a/source/QXmppRoster.h +++ b/source/QXmppRoster.h @@ -91,7 +91,6 @@ public: void setSubscriptionType(QXmppRosterEntry::SubscriptionType); void setSubscriptionStatus(const QString&); void setGroups(const QSet<QString>&); - void addGroupEntry(const QString&); // deprecated accessors, use the form without "get" instead QString Q_DECL_DEPRECATED getBareJid() const; diff --git a/source/QXmppRosterIq.cpp b/source/QXmppRosterIq.cpp index 4ae4fa13..320cb8bb 100644 --- a/source/QXmppRosterIq.cpp +++ b/source/QXmppRosterIq.cpp @@ -54,20 +54,7 @@ void QXmppRosterIq::parse(const QDomElement &element) while(!itemElement.isNull()) { QXmppRosterIq::Item item; - item.setName(itemElement.attribute("name")); - item.setBareJid(itemElement.attribute("jid")); - item.setSubscriptionTypeFromStr( - itemElement.attribute("subscription")); - item.setSubscriptionStatus( - itemElement.attribute("ask")); - - QDomElement groupElement = itemElement.firstChildElement("group"); - while(!groupElement.isNull()) - { - item.addGroup(groupElement.text()); - groupElement = groupElement.nextSiblingElement("group"); - } - + item.parse(itemElement); m_items.append(item); itemElement = itemElement.nextSiblingElement(); } @@ -134,11 +121,6 @@ void QXmppRosterIq::Item::setSubscriptionType(SubscriptionType type) m_type = type; } -void QXmppRosterIq::Item::addGroup(const QString& str) -{ - m_groups << str; -} - QString QXmppRosterIq::Item::getSubscriptionTypeStr() const { switch(m_type) @@ -181,6 +163,21 @@ void QXmppRosterIq::Item::setSubscriptionTypeFromStr(const QString& type) qWarning("QXmppRosterIq::Item::setTypeFromStr(): invalid type"); } +void QXmppRosterIq::Item::parse(const QDomElement &element) +{ + m_name = element.attribute("name"); + m_bareJid = element.attribute("jid"); + setSubscriptionTypeFromStr(element.attribute("subscription")); + setSubscriptionStatus(element.attribute("ask")); + + QDomElement groupElement = element.firstChildElement("group"); + while(!groupElement.isNull()) + { + m_groups << groupElement.text(); + groupElement = groupElement.nextSiblingElement("group"); + } +} + void QXmppRosterIq::Item::toXml(QXmlStreamWriter *writer) const { writer->writeStartElement("item"); diff --git a/source/QXmppRosterIq.h b/source/QXmppRosterIq.h index 9e491623..14624e7c 100644 --- a/source/QXmppRosterIq.h +++ b/source/QXmppRosterIq.h @@ -54,13 +54,11 @@ public: void setBareJid(const QString&); void setGroups(const QSet<QString>&); - void addGroup(const QString&); void setName(const QString&); void setSubscriptionStatus(const QString&); void setSubscriptionType(SubscriptionType); - QString getSubscriptionTypeStr() const; - void setSubscriptionTypeFromStr(const QString&); + void parse(const QDomElement &element); void toXml(QXmlStreamWriter *writer) const; // deprecated accessors, use the form without "get" instead @@ -71,6 +69,9 @@ public: QSet<QString> Q_DECL_DEPRECATED getGroups() const; private: + QString getSubscriptionTypeStr() const; + void setSubscriptionTypeFromStr(const QString&); + QString m_bareJid; SubscriptionType m_type; QString m_name; |
