powered by Jive Software

How to change subscription mode and status

Hi all,

I’m developing a web application that interacts with Openfire using smack API.

I was not able to find how to change subscription mode and status of a roster entry.

I add the new entry with:

Roster roster = connection.getRoster();
roster.createEntry(emailAddress, screenName, new String[0]);
RosterGroup someGroup = roster.createGroup("friend");
RosterEntry entry = roster.getEntry(emailAddress);
someGroup.addEntry(entry);

The new entry has subscription mode “none”. How can I change it?

Thanks,

Marco

I think I found the solution.

I’m sending two different packet:

Presence presence = new Presence(Presence.Type.SUBSCRIBE);
        presence.setTo(to);
        presence.setFrom(from);
        conn.sendPacket(presence);         presence = new Presence(Presence.Type.SUBSCRIBED);
        presence.setTo(to); // e' giusto che il setTo sia con from!!
        presence.setFrom(from);
        conn.sendPacket(presence);

It seems to be working

Is it ok?