Is there currently a way to remove a roster entry from the server? Maybe I''m just not seeing it? If you remove a roster entry from a group, will it also remove it from the roster? Thanks!
Providing the ability to remove a roster entry at the packet level would be great. Currently, I am using Smack only at the packet level because I already have a previous infrastructure that was using a different XMPP library before. Thus, I am using RosterPacket and not the higher-level entities such as Roster and RosterGroup.
Currently I don''t see a way of removing a roster entry just by setting up a RosterPacket and sending it. The necessary XML to remove a roster entry is something like this:
<iq type="set" id="roster_2">
<query xmlns="jabber:iq:roster">
<item
name="Nurse"
jid="nurse@capulet.com"
subscription="remove">
<group>Servants</group>
</item>
</query>
</iq>
Perhaps you could add a method to RosterPacket that allows it to create a packet such as this?
Thanks,
Aman
The only change that need to be made for this is to add:
public static final ItemType REMOVE = new ItemType("remove");
and
else if ("remove".equals(value)) {
return REMOVE;
}
into the RosterPacket.ItemType enumeration class.
Then you could remove an item as such:
RosterEntry entry = getRosterEntryByJID(JID);
RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.SET);
RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), entry.getName());
item.setItemType(RosterPacket.ItemType.REMOVE);
packet.addRosterItem(item);
conn.sendPacket(packet);
Easy temp solution until Matt adds it to Smack.
Take care,
John
Just checked this fix in (added REMOVE constant to RosterPacket class).
Regards,
Matt
I''m trying do delte a RosterEntry like this:
RosterPacket pack = new RosterPacket();
pack.setType(IQ.Type.SET);
RosterPacket.Item item = new RosterPacket.Item(user, nick);
item.setItemType(RosterPacket.ItemType.REMOVE);
pack.addRosterItem(item);
conn1.sendPacket(pack);
While running this code out of Netbeans 3.5 there is no problem.
But if make my project a jar file I get allways this error:
java.lang.NoClassDefFoundError: org/jivesoftware/smack/packet/Packet
Everything works fine with smack until I use that code...
(Class-Path is set to smack in Manifest and org.jivesoftware.smack.packet.* is imported)
Has someone an answer for that problem?