Search in sources :

Example 21 with RosterPacket

use of org.jivesoftware.smack.roster.packet.RosterPacket in project xabber-android by redsolution.

the class RosterManager method setGroups.

public void setGroups(String account, String bareAddress, Collection<String> groups) throws NetworkException {
    final Roster roster = getRoster(account);
    if (roster == null) {
        return;
    }
    final RosterEntry entry = roster.getEntry(bareAddress);
    if (entry == null) {
        return;
    }
    RosterPacket packet = new RosterPacket();
    packet.setType(IQ.Type.set);
    RosterPacket.Item item = new RosterPacket.Item(bareAddress, entry.getName());
    for (String group : groups) {
        item.addGroupName(group);
    }
    packet.addRosterItem(item);
    ConnectionManager.getInstance().sendStanza(account, packet);
}
Also used : AccountItem(com.xabber.android.data.account.AccountItem) ConnectionItem(com.xabber.android.data.connection.ConnectionItem) Roster(org.jivesoftware.smack.roster.Roster) RosterPacket(org.jivesoftware.smack.roster.packet.RosterPacket) RosterEntry(org.jivesoftware.smack.roster.RosterEntry)

Aggregations

RosterPacket (org.jivesoftware.smack.roster.packet.RosterPacket)21 Item (org.jivesoftware.smack.roster.packet.RosterPacket.Item)12 Test (org.junit.Test)8 BareJid (org.jxmpp.jid.BareJid)6 XMPPConnection (org.jivesoftware.smack.XMPPConnection)3 Stanza (org.jivesoftware.smack.packet.Stanza)3 AccountItem (com.xabber.android.data.account.AccountItem)2 ConnectionItem (com.xabber.android.data.connection.ConnectionItem)2 ErrorIQ (org.jivesoftware.smack.packet.ErrorIQ)2 IQ (org.jivesoftware.smack.packet.IQ)2 Roster (org.jivesoftware.smack.roster.Roster)2 RosterEntry (org.jivesoftware.smack.roster.RosterEntry)2 DirectoryRosterStore (org.jivesoftware.smack.roster.rosterstore.DirectoryRosterStore)2 RosterStore (org.jivesoftware.smack.roster.rosterstore.RosterStore)2 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Level (java.util.logging.Level)1 ExceptionCallback (org.jivesoftware.smack.ExceptionCallback)1 SmackException (org.jivesoftware.smack.SmackException)1 FeatureNotSupportedException (org.jivesoftware.smack.SmackException.FeatureNotSupportedException)1