From f93f2f8e6dc049f780e414bc0a7429f75825821e Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Fri, 1 Dec 2006 10:56:54 +0000 Subject: [PATCH] More precise error codes and events. Added unregister to clean up connection. --- .../msn/ProtocolProviderServiceMsnImpl.java | 52 +++++++++++++++++-- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java index 9893f90b4..d6432afee 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java @@ -438,11 +438,11 @@ public void logout(MsnMessenger msnMessenger) { logger.trace("logout"); - if(isRegistered()) - fireRegistrationStateChanged( - getRegistrationState(), - RegistrationState.UNREGISTERED, - RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null); +// if(isRegistered()) +// fireRegistrationStateChanged( +// getRegistrationState(), +// RegistrationState.UNREGISTERED, +// RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null); } @@ -456,13 +456,55 @@ public void exceptionCaught(MsnMessenger msnMessenger, Throwable throwable) "Incorrect Password"); else { + if(throwable instanceof MsnProtocolException) + { + MsnProtocolException exception = + (MsnProtocolException)throwable; + + + logger.error("Error in Msn lib ", exception); + + switch(exception.getErrorCode()) + { + case 500: + case 540: + case 601: + if(isRegistered()) + { + unregister(false); + fireRegistrationStateChanged( + getRegistrationState(), + RegistrationState.UNREGISTERED, + RegistrationStateChangeEvent. + REASON_INTERNAL_ERROR, null); + } + break; + case 911: + if(isRegistered()) + { + unregister(false); + fireRegistrationStateChanged( + getRegistrationState(), + RegistrationState.UNREGISTERED, + RegistrationStateChangeEvent. + REASON_AUTHENTICATION_FAILED, null); + } + break; + } + + return; + } + logger.error("Error in Msn lib ", throwable); if(isRegistered()) + { + unregister(false); fireRegistrationStateChanged( getRegistrationState(), RegistrationState.UNREGISTERED, RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null); + } } } }