1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Smack 4.1.1

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQF8BAABCgBmBQJVTgmuXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
 ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxMzU3QjAxODY1QjI1MDNDMTg0NTNEMjA4
 Q0FDMkE5Njc4NTQ4RTM1AAoJEIysKpZ4VI41MXUH/3A5Jc6rzALhnXMT4yj+jXow
 rLLX5/ypOvkAXEMRlTf9xd2apz4hT8dMsBcL3JvZscuVmkw0/woh9eV/PFSDoc7t
 HA7bMZRqWqUuVOezFD0ggHsJ7zfpcIuxsgoNARQlCRMPHzCLzKhMNctz5UApAdfy
 +wPpTMpc3K5SM1bNlM60qp+dbPCqQcLwYP02KrOQASgenVDm6iKFpzx0ieVpPY1M
 hOBMyaZg3n2j+267gpqBG6c7PVmEq3deAlB6BOBAsL/Bp1w5B5Smq959LWJLstrU
 /LeYJFi1TeIASiFy1vZyTV0Tw+Pe++3gB6ppLqkQhfWV8vXzm0coCXx29qWxAzM=
 =pGJt
 -----END PGP SIGNATURE-----

Merge tag '4.1.1'

Smack 4.1.1

Conflicts:
	smack-extensions/src/main/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProvider.java
	smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java
	smack-java7/src/main/java/org/jivesoftware/smack/java7/Java7SmackInitializer.java
	version.gradle
This commit is contained in:
Florian Schmaus 2015-05-09 15:31:47 +02:00
commit bbc7aaae77
9 changed files with 112 additions and 15 deletions

View file

@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.SmackException.NotConnectedException;
@ -37,7 +38,7 @@ import org.jxmpp.jid.Jid;
*
* @author Matt Tucker
*/
public class RosterEntry {
public final class RosterEntry extends Manager {
/**
* The JID of the entity/user.
@ -49,7 +50,6 @@ public class RosterEntry {
private RosterPacket.ItemStatus status;
private final boolean approved;
final private Roster roster;
final private XMPPConnection connection;
/**
* Creates a new roster entry.
@ -63,13 +63,13 @@ public class RosterEntry {
*/
RosterEntry(Jid user, String name, RosterPacket.ItemType type,
RosterPacket.ItemStatus status, boolean approved, Roster roster, XMPPConnection connection) {
super(connection);
this.user = user;
this.name = name;
this.type = type;
this.status = status;
this.approved = approved;
this.roster = roster;
this.connection = connection;
}
/**
@ -99,7 +99,7 @@ public class RosterEntry {
* @throws NoResponseException
* @throws InterruptedException
*/
public void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException {
public synchronized void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException {
// Do nothing if the name hasn't changed.
if (name != null && name.equals(this.name)) {
return;
@ -107,8 +107,11 @@ public class RosterEntry {
RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.set);
packet.addRosterItem(toRosterItem(this));
connection.createPacketCollectorAndSend(packet).nextResultOrThrow();
// Create a new roster item with the current RosterEntry and the *new* name. Note that we can't set the name of
// RosterEntry right away, as otherwise the updated event wont get fired, because equalsDeep would return true.
packet.addRosterItem(toRosterItem(this, name));
connection().createPacketCollectorAndSend(packet).nextResultOrThrow();
// We have received a result response to the IQ set, the name was successfully changed
this.name = name;
@ -262,7 +265,11 @@ public class RosterEntry {
}
static RosterPacket.Item toRosterItem(RosterEntry entry) {
RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), entry.getName());
return toRosterItem(entry, entry.getName());
}
private static RosterPacket.Item toRosterItem(RosterEntry entry, String name) {
RosterPacket.Item item = new RosterPacket.Item(entry.getUser(), name);
item.setItemType(entry.getType());
item.setItemStatus(entry.getStatus());
item.setApproved(entry.isApproved());