From 8ba49d951bc9b3de467cc2766f9130441099748c Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Tue, 7 Feb 2012 10:01:21 +0000 Subject: add QXmppRosterManager::addItem (fixes issue 95) --- src/QXmppRosterManager.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/QXmppRosterManager.cpp') 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 &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. -- cgit v1.2.3