powered by Jive Software

Remove roster entry

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!

Yep, removing a roster item from a group is the way to go. I suppose a method needs to be added to remove unfiled roster entries though. Maybe I should add a method to delete an entry entirely from your roster at once as well?

Regards,

Matt

Having a method to remove a roster entry based on JID would be great for completeness. Certainly not a priority, since the functionality is essentially there in the removal-from-group method. Maybe I was the only one slightly confused by that =). I was testing using only unfiled entries.

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:

<item

name=“Nurse”

    jid="nurse@capulet.com"

subscription=“remove”>

Servants

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

Sounds like a good suggestion. I’'ll file a feature request for it.

-iain

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?

Are you compiling the Smack source code as part of your project? If so, you might want to just include the Smack JAR file as part of your classpath instead. That should likely work a lot better.

Regards,

Matt

THX! Found my problem! There was an error in my Manifest. I don’'t know why it work without that code…