1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 17:52:06 +01:00

Roster: merge the two registered ConnectionListeners

This commit is contained in:
Georg Lukas 2014-07-18 14:38:48 +02:00 committed by Florian Schmaus
parent d35fd16a21
commit 2a05c3b707

View file

@ -131,6 +131,23 @@ public class Roster {
// Listen for connection events // Listen for connection events
connection.addConnectionListener(new AbstractConnectionListener() { connection.addConnectionListener(new AbstractConnectionListener() {
public void authenticated(XMPPConnection connection) {
// Anonymous users can't have a roster, but it is possible that a Roster instance is
// retrieved if getRoster() is called *before* connect(). So we have to check here
// again if it's an anonymous connection.
if (connection.isAnonymous())
return;
if (!connection.isRosterLoadedAtLogin())
return;
try {
Roster.this.reload();
}
catch (SmackException e) {
LOGGER.log(Level.SEVERE, "Could not reload Roster", e);
return;
}
}
public void connectionClosed() { public void connectionClosed() {
// Changes the presence available contacts to unavailable // Changes the presence available contacts to unavailable
try { try {
@ -161,24 +178,6 @@ public class Roster {
LOGGER.log(Level.SEVERE, "Could not reload Roster", e); LOGGER.log(Level.SEVERE, "Could not reload Roster", e);
} }
} }
connection.addConnectionListener(new AbstractConnectionListener() {
public void authenticated(XMPPConnection connection) {
// Anonymous users can't have a roster, but it is possible that a Roster instance is
// retrieved if getRoster() is called *before* connect(). So we have to check here
// again if it's an anonymous connection.
if (connection.isAnonymous())
return;
if (!connection.isRosterLoadedAtLogin())
return;
try {
Roster.this.reload();
}
catch (SmackException e) {
LOGGER.log(Level.SEVERE, "Could not reload Roster", e);
return;
}
}
});
} }
/** /**