Search in sources :

Example 1 with ExceptionCallback

use of org.jivesoftware.smack.ExceptionCallback in project Smack by igniterealtime.

the class Roster method reload.

/**
     * Reloads the entire roster from the server. This is an asynchronous operation,
     * which means the method will return immediately, and the roster will be
     * reloaded at a later point when the server responds to the reload request.
     * @throws NotLoggedInException If not logged in.
     * @throws NotConnectedException 
     * @throws InterruptedException 
     */
public void reload() throws NotLoggedInException, NotConnectedException, InterruptedException {
    final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
    RosterPacket packet = new RosterPacket();
    if (rosterStore != null && isRosterVersioningSupported()) {
        packet.setVersion(rosterStore.getRosterVersion());
    }
    rosterState = RosterState.loading;
    connection.sendIqWithResponseCallback(packet, new RosterResultListener(), new ExceptionCallback() {

        @Override
        public void processException(Exception exception) {
            rosterState = RosterState.uninitialized;
            Level logLevel;
            if (exception instanceof NotConnectedException) {
                logLevel = Level.FINE;
            } else {
                logLevel = Level.SEVERE;
            }
            LOGGER.log(logLevel, "Exception reloading roster", exception);
            for (RosterLoadedListener listener : rosterLoadedListeners) {
                listener.onRosterLoadingFailed(exception);
            }
        }
    });
}
Also used : NotConnectedException(org.jivesoftware.smack.SmackException.NotConnectedException) RosterPacket(org.jivesoftware.smack.roster.packet.RosterPacket) Level(java.util.logging.Level) XMPPConnection(org.jivesoftware.smack.XMPPConnection) ExceptionCallback(org.jivesoftware.smack.ExceptionCallback) SmackException(org.jivesoftware.smack.SmackException) FeatureNotSupportedException(org.jivesoftware.smack.SmackException.FeatureNotSupportedException) NotLoggedInException(org.jivesoftware.smack.SmackException.NotLoggedInException) XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) NotConnectedException(org.jivesoftware.smack.SmackException.NotConnectedException) NoResponseException(org.jivesoftware.smack.SmackException.NoResponseException)

Aggregations

Level (java.util.logging.Level)1 ExceptionCallback (org.jivesoftware.smack.ExceptionCallback)1 SmackException (org.jivesoftware.smack.SmackException)1 FeatureNotSupportedException (org.jivesoftware.smack.SmackException.FeatureNotSupportedException)1 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)1 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)1 NotLoggedInException (org.jivesoftware.smack.SmackException.NotLoggedInException)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)1 RosterPacket (org.jivesoftware.smack.roster.packet.RosterPacket)1