Fixed changing state from offline to online. Removed field for keeping current reg state

cusax-fix
Damian Minkov 20 years ago
parent 86b527cee7
commit cd2096624b

@ -411,16 +411,17 @@ public void publishPresenceStatus(PresenceStatus status,
if(((JabberStatusEnum)status).equals(JabberStatusEnum.OFFLINE))
{
presence = new Presence(Presence.Type.UNAVAILABLE);
jabberProvider.unregister();
}
else
{
presence = new Presence(Presence.Type.AVAILABLE);
presence.setMode(presenceStatusToJabberMode((JabberStatusEnum)status));
}
presence.setStatus(statusMessage);
presence.setStatus(statusMessage);
jabberProvider.getConnection().sendPacket(presence);
jabberProvider.getConnection().sendPacket(presence);
}
fireProviderPresenceStatusChangeEvent(currentStatus, status);

@ -34,9 +34,6 @@ public class ProtocolProviderServiceJabberImpl
private XMPPConnection connection = null;
private RegistrationState currentConnectionState =
RegistrationState.UNREGISTERED;
/**
* indicates whether or not the provider is initialized and ready for use.
*/
@ -70,7 +67,12 @@ public class ProtocolProviderServiceJabberImpl
*/
public RegistrationState getRegistrationState()
{
return currentConnectionState;
if(connection == null)
return RegistrationState.UNREGISTERED;
else if(connection.isConnected() && connection.isAuthenticated())
return RegistrationState.REGISTERED;
else
return RegistrationState.UNREGISTERED;
}
/**
@ -124,8 +126,7 @@ void reregister()
// sets this if any is tring to use us through registration
// to know we are not registered
this.currentConnectionState = RegistrationState.UNREGISTERED;
this.connection.close();
this.unregister();
connectAndLogin(authority);
}
@ -254,7 +255,14 @@ private void connectAndLogin(SecurityAuthority authority)
*/
public void unregister()
{
RegistrationState currRegState = getRegistrationState();
connection.close();
fireRegistrationStateChanged(
currRegState,
RegistrationState.UNREGISTERED,
RegistrationStateChangeEvent.REASON_USER_REQUEST, null);
}
/**
@ -457,9 +465,6 @@ void fireRegistrationStateChanged( RegistrationState oldState,
int reasonCode,
String reason)
{
// sets the new state
currentConnectionState = newState;
RegistrationStateChangeEvent event =
new RegistrationStateChangeEvent(
this, oldState, newState, reasonCode, reason);
@ -489,13 +494,6 @@ private class JabberConnectionListener
{
public void connectionClosed()
{
RegistrationState oldConnectionState = currentConnectionState;
// fireRegistrationStateChanged(
// oldConnectionState,
// RegistrationState.UNREGISTERED,
// RegistrationStateChangeEvent.REASON_USER_REQUEST, null);
OperationSetPersistentPresenceJabberImpl opSetPersPresence =
(OperationSetPersistentPresenceJabberImpl)
getSupportedOperationSets()
@ -508,7 +506,7 @@ public void connectionClosed()
public void connectionClosedOnError(Exception exception)
{
RegistrationState oldConnectionState = currentConnectionState;
RegistrationState oldConnectionState = getRegistrationState();
fireRegistrationStateChanged(
oldConnectionState,

Loading…
Cancel
Save