aboutsummaryrefslogtreecommitdiff
path: root/src/QXmppRosterManager.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-02-07 10:01:21 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2012-02-07 10:01:21 +0000
commit8ba49d951bc9b3de467cc2766f9130441099748c (patch)
treef4ff79cd28966ba36ec1fdf00d376ecaf62479d5 /src/QXmppRosterManager.cpp
parentd11e0741bd431c46984a661dd76d487e7d7c59be (diff)
downloadqxmpp-8ba49d951bc9b3de467cc2766f9130441099748c.tar.gz
add QXmppRosterManager::addItem (fixes issue 95)
Diffstat (limited to 'src/QXmppRosterManager.cpp')
-rw-r--r--src/QXmppRosterManager.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/QXmppRosterManager.cpp b/src/QXmppRosterManager.cpp
index b89bdc0a..7c2f56ed 100644
--- a/src/QXmppRosterManager.cpp
+++ b/src/QXmppRosterManager.cpp
@@ -235,7 +235,30 @@ bool QXmppRosterManager::refuseSubscription(const QString &bareJid)
return client()->sendPacket(presence);
}
-/// Removes a roster entry and cancels subscriptions to and from the contact.
+/// Adds a new item to the roster without sending any subscription requests.
+///
+/// As a result, the server will initiate a roster push, causing the
+/// itemAdded() or itemChanged() signal to be emitted.
+///
+/// \param bareJid
+/// \param name Optional name for the item.
+/// \param groups Optional groups for the item.
+
+bool QXmppRosterManager::addItem(const QString &bareJid, const QString &name, const QSet<QString> &groups)
+{
+ QXmppRosterIq::Item item;
+ item.setBareJid(bareJid);
+ item.setName(name);
+ item.setGroups(groups);
+ item.setSubscriptionType(QXmppRosterIq::Item::NotSet);
+
+ QXmppRosterIq iq;
+ iq.setType(QXmppIq::Set);
+ iq.addItem(item);
+ return client()->sendPacket(iq);
+}
+
+/// Removes a roster item and cancels subscriptions to and from the contact.
///
/// As a result, the server will initiate a roster push, causing the
/// itemRemoved() signal to be emitted.