From feff0815472c05ad4966ef24253b0717e4059c58 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 9 Dec 2015 10:49:15 +0100 Subject: [PATCH] Add "Roster loading failed" callback --- .../java/org/jivesoftware/smack/roster/Roster.java | 3 +++ .../smack/roster/RosterLoadedListener.java | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java index 2a11e770c..2f6f8248e 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java @@ -404,6 +404,9 @@ public final class Roster extends Manager { logLevel = Level.SEVERE; } LOGGER.log(logLevel, "Exception reloading roster" , exception); + for (RosterLoadedListener listener : rosterLoadedListeners) { + listener.onRosterLoadingFailed(exception); + } } }); } diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterLoadedListener.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterLoadedListener.java index 94f08f094..853cf31f2 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterLoadedListener.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterLoadedListener.java @@ -35,4 +35,17 @@ public interface RosterLoadedListener { */ public void onRosterLoaded(Roster roster); + /** + * Called when roster loading has failed. + *

+ * Note that the reason for the failure could be as trivial as the connection being not + * connected, in which case the exception will be a + * {@link org.jivesoftware.smack.SmackException.NotConnectedException}. + *

+ * + * @param exception the exception which caused the failure. + * @since 4.2 + */ + public void onRosterLoadingFailed(Exception exception); + }