diff options
author | Yana Stamcheva <yana@jitsi.org> | 2013-01-29 14:14:48 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2013-01-29 14:14:48 +0000 |
commit | 07a34a3f1382f817c6ab328963ce9b8c699afd30 (patch) | |
tree | 617f211b82681851653ef58e17e83641595a7c71 /src/net/java/sip/communicator/util | |
parent | 0052044d0509495615e72d8ac054c4ea0d1d1d36 (diff) | |
download | jitsi-07a34a3f1382f817c6ab328963ce9b8c699afd30.zip jitsi-07a34a3f1382f817c6ab328963ce9b8c699afd30.tar.gz jitsi-07a34a3f1382f817c6ab328963ce9b8c699afd30.tar.bz2 |
Separates account status related methods to AccountStatusUtils class in the util package. Moves LoginManager to util package and creates a LoginRenderer interface that allows to provide a different UI implementation for login related operations.
Diffstat (limited to 'src/net/java/sip/communicator/util')
6 files changed, 835 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/util/UtilActivator.java b/src/net/java/sip/communicator/util/UtilActivator.java index ab9678f..0bafaca 100644 --- a/src/net/java/sip/communicator/util/UtilActivator.java +++ b/src/net/java/sip/communicator/util/UtilActivator.java @@ -54,6 +54,10 @@ public class UtilActivator public static BundleContext bundleContext; + private static AccountManager accountManager; + + private static AlertUIService alertUIService; + /** * Network address manager service will inform us for changes in * network configuration. @@ -280,4 +284,37 @@ public class UtilActivator } return parallelResolver; } + + /** + * Returns the <tt>AccountManager</tt> obtained from the bundle context. + * @return the <tt>AccountManager</tt> obtained from the bundle context + */ + public static AccountManager getAccountManager() + { + if(accountManager == null) + { + accountManager + = ServiceUtils.getService(bundleContext, AccountManager.class); + } + return accountManager; + } + + + /** + * Returns the <tt>MetaContactListService</tt> obtained from the bundle + * context. + * @return the <tt>MetaContactListService</tt> obtained from the bundle + * context + */ + public static AlertUIService getAlertUIService() + { + if (alertUIService == null) + { + alertUIService + = ServiceUtils.getService( + bundleContext, + AlertUIService.class); + } + return alertUIService; + } } diff --git a/src/net/java/sip/communicator/util/account/AccountStatusUtils.java b/src/net/java/sip/communicator/util/account/AccountStatusUtils.java new file mode 100644 index 0000000..ee42942 --- /dev/null +++ b/src/net/java/sip/communicator/util/account/AccountStatusUtils.java @@ -0,0 +1,108 @@ +/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.util.account;
+
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.globalstatus.*;
+import net.java.sip.communicator.util.*;
+
+/**
+ * The <tt>AccountStatusUtils</tt> provides utility methods for account status
+ * management.
+ *
+ * @author Yana Stamcheva
+ */
+public class AccountStatusUtils
+{
+ private static GlobalStatusService globalStatusService;
+
+ /**
+ * If the protocol provider supports presence operation set searches the
+ * last status which was selected, otherwise returns null.
+ *
+ * @param protocolProvider the protocol provider we're interested in.
+ * @return the last protocol provider presence status, or null if this
+ * provider doesn't support presence operation set
+ */
+ public static Object getProtocolProviderLastStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ if(getProtocolPresenceOpSet(protocolProvider) != null)
+ return getLastPresenceStatus(protocolProvider);
+ else
+ return getGlobalStatusService()
+ .getLastStatusString(protocolProvider);
+ }
+
+ /**
+ * Returns the presence operation set for the given protocol provider.
+ *
+ * @param protocolProvider The protocol provider for which the
+ * presence operation set is searched.
+ * @return the presence operation set for the given protocol provider.
+ */
+ public static OperationSetPresence getProtocolPresenceOpSet(
+ ProtocolProviderService protocolProvider)
+ {
+ OperationSet opSet
+ = protocolProvider.getOperationSet(OperationSetPresence.class);
+
+ return
+ (opSet instanceof OperationSetPresence)
+ ? (OperationSetPresence) opSet
+ : null;
+ }
+
+ /**
+ * Returns the last status that was stored in the configuration xml for the
+ * given protocol provider.
+ *
+ * @param protocolProvider the protocol provider
+ * @return the last status that was stored in the configuration xml for the
+ * given protocol provider
+ */
+ public static PresenceStatus getLastPresenceStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ if (getGlobalStatusService() != null)
+ return getGlobalStatusService().getLastPresenceStatus(
+ protocolProvider);
+
+ return null;
+ }
+
+ /**
+ * Returns the last contact status saved in the configuration.
+ *
+ * @param protocolProvider the protocol provider to which the status
+ * corresponds
+ * @return the last contact status saved in the configuration.
+ */
+ public String getLastStatusString(ProtocolProviderService protocolProvider)
+ {
+ return getGlobalStatusService().getLastStatusString(protocolProvider);
+ }
+
+ /**
+ * Returns the <tt>GlobalStatusService</tt> obtained from the bundle
+ * context.
+ * @return the <tt>GlobalStatusService</tt> obtained from the bundle
+ * context
+ */
+ public static GlobalStatusService getGlobalStatusService()
+ {
+ if (globalStatusService == null)
+ {
+ globalStatusService
+ = ServiceUtils.getService(
+ UtilActivator.bundleContext,
+ GlobalStatusService.class);
+ }
+
+ return globalStatusService;
+ }
+}
\ No newline at end of file diff --git a/src/net/java/sip/communicator/util/account/AccountUtils.java b/src/net/java/sip/communicator/util/account/AccountUtils.java index 5134362..4dfe918 100644 --- a/src/net/java/sip/communicator/util/account/AccountUtils.java +++ b/src/net/java/sip/communicator/util/account/AccountUtils.java @@ -14,6 +14,9 @@ import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*;
/**
+ * The <tt>AccountUtils</tt> provides utility methods helping us to easily
+ * obtain an account or a groups of accounts or protocol providers by some
+ * specific criteria.
*
* @author Yana Stamcheva
*/
diff --git a/src/net/java/sip/communicator/util/account/LoginManager.java b/src/net/java/sip/communicator/util/account/LoginManager.java new file mode 100644 index 0000000..ab0d7fe --- /dev/null +++ b/src/net/java/sip/communicator/util/account/LoginManager.java @@ -0,0 +1,588 @@ +/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.util.account;
+
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.event.*;
+import net.java.sip.communicator.service.protocol.globalstatus.*;
+import net.java.sip.communicator.util.*;
+
+import org.osgi.framework.*;
+
+/**
+ * The <tt>LoginManager</tt> manages the login operation. Here we obtain the
+ * <tt>ProtocolProviderFactory</tt>, we make the account installation and we
+ * handle all events related to the registration state.
+ * <p>
+ * The <tt>LoginManager</tt> is the one that opens one or more
+ * <tt>LoginWindow</tt>s for each <tt>ProtocolProviderFactory</tt>. The
+ * <tt>LoginWindow</tt> is where user could enter an identifier and password.
+ * <p>
+ * Note that the behavior of this class will be changed when the Configuration
+ * Service is ready.
+ *
+ * @author Yana Stamcheva
+ */
+public class LoginManager
+ implements ServiceListener,
+ RegistrationStateChangeListener,
+ AccountManagerListener
+{
+ private static final Logger logger = Logger.getLogger(LoginManager.class);
+
+ private boolean manuallyDisconnected = false;
+
+ private final LoginRenderer loginRenderer;
+
+ /**
+ * Creates an instance of the <tt>LoginManager</tt>, by specifying the main
+ * application window.
+ *
+ * @param loginRenderer the main application window
+ */
+ public LoginManager(LoginRenderer loginRenderer)
+ {
+ this.loginRenderer = loginRenderer;
+
+ UtilActivator.bundleContext.addServiceListener(this);
+ }
+
+ /**
+ * Registers the given protocol provider.
+ *
+ * @param protocolProvider the ProtocolProviderService to register.
+ */
+ public void login(ProtocolProviderService protocolProvider)
+ {
+ loginRenderer.startConnectingUI(protocolProvider);
+
+ new RegisterProvider(protocolProvider,
+ loginRenderer.getSecurityAuthorityImpl(protocolProvider)).start();
+ }
+
+ /**
+ * Unregisters the given protocol provider.
+ *
+ * @param protocolProvider the ProtocolProviderService to unregister
+ */
+ public static void logoff(ProtocolProviderService protocolProvider)
+ {
+ new UnregisterProvider(protocolProvider).start();
+ }
+
+ /**
+ * Shows login window for each registered account.
+ */
+ public void runLogin()
+ {
+ // if someone is late registering catch it
+ UtilActivator.getAccountManager().addListener(this);
+
+ for (ProtocolProviderFactory providerFactory : UtilActivator
+ .getProtocolProviderFactories().values())
+ {
+ addAccountsForProtocolProviderFactory(providerFactory);
+ }
+ }
+
+ /**
+ * Notifies that the loading of the stored accounts of a
+ * specific <code>ProtocolProviderFactory</code> has finished.
+ *
+ * @param event the <code>AccountManagerEvent</code> describing the
+ * <code>AccountManager</code> firing the notification and the
+ * other details of the specific notification.
+ */
+ public void handleAccountManagerEvent(AccountManagerEvent event)
+ {
+ if(event.getType()
+ == AccountManagerEvent.STORED_ACCOUNTS_LOADED)
+ {
+ addAccountsForProtocolProviderFactory(event.getFactory());
+ }
+ }
+
+ /**
+ * Handles stored accounts for a protocol provider factory and add them
+ * to the UI and register them if needed.
+ * @param providerFactory the factory to handle.
+ */
+ private void addAccountsForProtocolProviderFactory(
+ ProtocolProviderFactory providerFactory)
+ {
+ ServiceReference serRef;
+ ProtocolProviderService protocolProvider;
+
+ for (AccountID accountID : providerFactory.getRegisteredAccounts())
+ {
+ serRef = providerFactory.getProviderForAccount(accountID);
+
+ protocolProvider =
+ (ProtocolProviderService) UtilActivator.bundleContext
+ .getService(serRef);
+
+ // check whether we have already loaded this provider
+ if(loginRenderer.containsProtocolProviderUI(protocolProvider))
+ continue;
+
+ protocolProvider.addRegistrationStateChangeListener(this);
+
+ loginRenderer.addProtocolProviderUI(protocolProvider);
+
+ Object status =
+ AccountStatusUtils
+ .getProtocolProviderLastStatus(protocolProvider);
+
+ if (status == null
+ || status.equals(GlobalStatusEnum.ONLINE_STATUS)
+ || ((status instanceof PresenceStatus)
+ && (((PresenceStatus) status)
+ .getStatus() >= PresenceStatus.ONLINE_THRESHOLD)))
+ {
+ login(protocolProvider);
+ }
+ }
+ }
+
+ /**
+ * The method is called by a ProtocolProvider implementation whenever a
+ * change in the registration state of the corresponding provider had
+ * occurred.
+ *
+ * @param evt ProviderStatusChangeEvent the event describing the status
+ * change.
+ */
+ public void registrationStateChanged(RegistrationStateChangeEvent evt)
+ {
+ RegistrationState newState = evt.getNewState();
+ ProtocolProviderService protocolProvider = evt.getProvider();
+ AccountID accountID = protocolProvider.getAccountID();
+
+ if (logger.isTraceEnabled())
+ logger.trace("Protocol provider: " + protocolProvider
+ + " changed its state to: " + evt.getNewState().getStateName());
+
+ if (newState.equals(RegistrationState.REGISTERED)
+ || newState.equals(RegistrationState.UNREGISTERED)
+ || newState.equals(RegistrationState.EXPIRED)
+ || newState.equals(RegistrationState.AUTHENTICATION_FAILED)
+ || newState.equals(RegistrationState.CONNECTION_FAILED)
+ || newState.equals(RegistrationState.CHALLENGED_FOR_AUTHENTICATION)
+ || newState.equals(RegistrationState.REGISTERED))
+ {
+ loginRenderer.stopConnectingUI(protocolProvider);
+ }
+
+ if (newState.equals(RegistrationState.REGISTERED))
+ {
+ loginRenderer.protocolProviderConnected(protocolProvider,
+ System.currentTimeMillis());
+ }
+ else
+ {
+ String msgText;
+ if (newState.equals(RegistrationState.AUTHENTICATION_FAILED))
+ {
+ switch (evt.getReasonCode())
+ {
+ case RegistrationStateChangeEvent
+ .REASON_RECONNECTION_RATE_LIMIT_EXCEEDED:
+
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.RECONNECTION_LIMIT_EXCEEDED", new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ break;
+
+ case RegistrationStateChangeEvent.REASON_NON_EXISTING_USER_ID:
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.NON_EXISTING_USER_ID",
+ new String[]
+ { protocolProvider.getProtocolDisplayName() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ break;
+ case RegistrationStateChangeEvent.REASON_TLS_REQUIRED:
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.NON_SECURE_CONNECTION",
+ new String[]
+ { accountID.getAccountAddress() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ break;
+ default:
+ break;
+ }
+
+ if (logger.isTraceEnabled())
+ logger.trace(evt.getReason());
+ }
+// CONNECTION_FAILED events are now dispatched in reconnect plugin
+// else if (newState.equals(RegistrationState.CONNECTION_FAILED))
+// {
+// loginRenderer.protocolProviderConnectionFailed(
+// protocolProvider,
+// this);
+//
+// logger.trace(evt.getReason());
+// }
+ else if (newState.equals(RegistrationState.EXPIRED))
+ {
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.CONNECTION_EXPIRED_MSG",
+ new String[]
+ { protocolProvider.getProtocolDisplayName() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+
+ logger.error(evt.getReason());
+ }
+ else if (newState.equals(RegistrationState.UNREGISTERED))
+ {
+ if (!manuallyDisconnected)
+ {
+ if (evt.getReasonCode() == RegistrationStateChangeEvent
+ .REASON_MULTIPLE_LOGINS)
+ {
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.MULTIPLE_LOGINS",
+ new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ }
+ else if (evt.getReasonCode() == RegistrationStateChangeEvent
+ .REASON_CLIENT_LIMIT_REACHED_FOR_IP)
+ {
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.LIMIT_REACHED_FOR_IP", new String[]
+ { protocolProvider.getProtocolDisplayName() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ }
+ else if (evt.getReasonCode() == RegistrationStateChangeEvent
+ .REASON_USER_REQUEST)
+ {
+ // do nothing
+ }
+ else
+ {
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.UNREGISTERED_MESSAGE", new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ }
+ if (logger.isTraceEnabled())
+ logger.trace(evt.getReason());
+ }
+ }
+ }
+ }
+
+ /**
+ * Implements the <tt>ServiceListener</tt> method. Verifies whether the
+ * passed event concerns a <tt>ProtocolProviderService</tt> and adds the
+ * corresponding UI controls.
+ *
+ * @param event The <tt>ServiceEvent</tt> object.
+ */
+ public void serviceChanged(ServiceEvent event)
+ {
+ ServiceReference serviceRef = event.getServiceReference();
+
+ // if the event is caused by a bundle being stopped, we don't want to
+ // know
+ if (serviceRef.getBundle().getState() == Bundle.STOPPING)
+ {
+ return;
+ }
+
+ Object service
+ = UtilActivator.bundleContext.getService(serviceRef);
+
+ // we don't care if the source service is not a protocol provider
+ if (!(service instanceof ProtocolProviderService))
+ {
+ return;
+ }
+
+ switch (event.getType())
+ {
+ case ServiceEvent.REGISTERED:
+ this.handleProviderAdded((ProtocolProviderService) service);
+ break;
+ case ServiceEvent.UNREGISTERING:
+ this.handleProviderRemoved((ProtocolProviderService) service);
+ break;
+ }
+ }
+
+ /**
+ * Adds all UI components (status selector box, etc) related to the given
+ * protocol provider.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt>
+ */
+ private void handleProviderAdded(ProtocolProviderService protocolProvider)
+ {
+ if (logger.isTraceEnabled())
+ logger.trace("The following protocol provider was just added: "
+ + protocolProvider.getAccountID().getAccountAddress());
+
+ protocolProvider.addRegistrationStateChangeListener(this);
+ loginRenderer.addProtocolProviderUI(protocolProvider);
+
+ Object status = AccountStatusUtils
+ .getProtocolProviderLastStatus(protocolProvider);
+
+ if (status == null
+ || status.equals(GlobalStatusEnum.ONLINE_STATUS)
+ || ((status instanceof PresenceStatus) && (((PresenceStatus) status)
+ .getStatus() >= PresenceStatus.ONLINE_THRESHOLD)))
+ {
+ login(protocolProvider);
+ }
+ }
+
+ /**
+ * Removes all UI components related to the given protocol provider.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt>
+ */
+ private void handleProviderRemoved(ProtocolProviderService protocolProvider)
+ {
+ loginRenderer.removeProtocolProviderUI(protocolProvider);
+ }
+
+ /**
+ * Returns <tt>true</tt> to indicate the jitsi has been manually
+ * disconnected, <tt>false</tt> - otherwise.
+ *
+ * @return <tt>true</tt> to indicate the jitsi has been manually
+ * disconnected, <tt>false</tt> - otherwise
+ */
+ public boolean isManuallyDisconnected()
+ {
+ return manuallyDisconnected;
+ }
+
+ /**
+ * Sets the manually disconnected property.
+ *
+ * @param manuallyDisconnected <tt>true</tt> to indicate the jitsi has been
+ * manually disconnected, <tt>false</tt> - otherwise
+ */
+ public void setManuallyDisconnected(boolean manuallyDisconnected)
+ {
+ this.manuallyDisconnected = manuallyDisconnected;
+ }
+
+ /**
+ * Registers a protocol provider in a separate thread.
+ */
+ private class RegisterProvider
+ extends Thread
+ {
+ private final ProtocolProviderService protocolProvider;
+
+ private final SecurityAuthority secAuth;
+
+ RegisterProvider( ProtocolProviderService protocolProvider,
+ SecurityAuthority secAuth)
+ {
+ this.protocolProvider = protocolProvider;
+ this.secAuth = secAuth;
+ }
+
+ /**
+ * Registers the contained protocol provider and process all possible
+ * errors that may occur during the registration process.
+ */
+ public void run()
+ {
+ try
+ {
+ protocolProvider.register(secAuth);
+ }
+ catch (OperationFailedException ex)
+ {
+ handleOperationFailedException(ex);
+ }
+ catch (Throwable ex)
+ {
+ logger.error("Failed to register protocol provider. ", ex);
+
+ AccountID accountID = protocolProvider.getAccountID();
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ UtilActivator.getResources()
+ .getI18NString("service.gui.LOGIN_GENERAL_ERROR",
+ new String[]
+ { accountID.getUserID(),
+ accountID.getProtocolName(),
+ accountID.getService() }));
+ }
+ }
+
+ private void handleOperationFailedException(OperationFailedException ex)
+ {
+ String errorMessage = "";
+
+ switch (ex.getErrorCode())
+ {
+ case OperationFailedException.GENERAL_ERROR:
+ {
+ logger.error("Provider could not be registered"
+ + " due to the following general error: ", ex);
+
+ AccountID accountID = protocolProvider.getAccountID();
+ errorMessage =
+ UtilActivator.getResources().getI18NString(
+ "service.gui.LOGIN_GENERAL_ERROR",
+ new String[]
+ { accountID.getUserID(),
+ accountID.getProtocolName(),
+ accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"), errorMessage, ex);
+ }
+ break;
+ case OperationFailedException.INTERNAL_ERROR:
+ {
+ logger.error("Provider could not be registered"
+ + " due to the following internal error: ", ex);
+
+ AccountID accountID = protocolProvider.getAccountID();
+ errorMessage =
+ UtilActivator.getResources().getI18NString(
+ "service.gui.LOGIN_INTERNAL_ERROR",
+ new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources().getI18NString(
+ "service.gui.ERROR"), errorMessage, ex);
+ }
+ break;
+ case OperationFailedException.NETWORK_FAILURE:
+ {
+ if (logger.isInfoEnabled())
+ {
+ logger.info("Provider could not be registered"
+ + " due to a network failure: " + ex);
+ }
+
+ loginRenderer.protocolProviderConnectionFailed(
+ protocolProvider,
+ LoginManager.this);
+ }
+ break;
+ case OperationFailedException.INVALID_ACCOUNT_PROPERTIES:
+ {
+ logger.error("Provider could not be registered"
+ + " due to an invalid account property: ", ex);
+
+ AccountID accountID = protocolProvider.getAccountID();
+ errorMessage =
+ UtilActivator.getResources().getI18NString(
+ "service.gui.LOGIN_INVALID_PROPERTIES_ERROR",
+ new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ errorMessage, ex);
+ }
+ break;
+ default:
+ logger.error("Provider could not be registered.", ex);
+ }
+ }
+ }
+
+ /**
+ * Unregisters a protocol provider in a separate thread.
+ */
+ private static class UnregisterProvider
+ extends Thread
+ {
+ ProtocolProviderService protocolProvider;
+
+ UnregisterProvider(ProtocolProviderService protocolProvider)
+ {
+ this.protocolProvider = protocolProvider;
+ }
+
+ /**
+ * Unregisters the contained protocol provider and process all possible
+ * errors that may occur during the un-registration process.
+ */
+ public void run()
+ {
+ try
+ {
+ protocolProvider.unregister();
+ }
+ catch (OperationFailedException ex)
+ {
+ int errorCode = ex.getErrorCode();
+
+ if (errorCode == OperationFailedException.GENERAL_ERROR)
+ {
+ logger.error("Provider could not be unregistered"
+ + " due to the following general error: " + ex);
+ }
+ else if (errorCode == OperationFailedException.INTERNAL_ERROR)
+ {
+ logger.error("Provider could not be unregistered"
+ + " due to the following internal error: " + ex);
+ }
+ else if (errorCode == OperationFailedException.NETWORK_FAILURE)
+ {
+ logger.error("Provider could not be unregistered"
+ + " due to a network failure: " + ex);
+ }
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ UtilActivator.getResources()
+ .getI18NString("service.gui.LOGOFF_NOT_SUCCEEDED",
+ new String[]
+ { protocolProvider.getAccountID().getUserID(),
+ protocolProvider.getAccountID().getService() }));
+ }
+ }
+ }
+}
\ No newline at end of file diff --git a/src/net/java/sip/communicator/util/account/LoginRenderer.java b/src/net/java/sip/communicator/util/account/LoginRenderer.java new file mode 100644 index 0000000..9806ff1 --- /dev/null +++ b/src/net/java/sip/communicator/util/account/LoginRenderer.java @@ -0,0 +1,97 @@ +/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.util.account;
+
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ * The <tt>LoginRenderer</tt> is the renderer of all login related operations.
+ *
+ * @author Yana Stamcheva
+ */
+public interface LoginRenderer
+{
+ /**
+ * Adds the user interface related to the given protocol provider.
+ *
+ * @param protocolProvider the protocol provider for which we add the user
+ * interface
+ */
+ public void addProtocolProviderUI(
+ ProtocolProviderService protocolProvider);
+
+ /**
+ * Removes the user interface related to the given protocol provider.
+ *
+ * @param protocolProvider the protocol provider to remove
+ */
+ public void removeProtocolProviderUI(
+ ProtocolProviderService protocolProvider);
+
+ /**
+ * Starts the connecting user interface for the given protocol provider.
+ *
+ * @param protocolProvider the protocol provider for which we add the
+ * connecting user interface
+ */
+ public void startConnectingUI(ProtocolProviderService protocolProvider);
+
+ /**
+ * Stops the connecting user interface for the given protocol provider.
+ *
+ * @param protocolProvider the protocol provider for which we remove the
+ * connecting user interface
+ */
+ public void stopConnectingUI(ProtocolProviderService protocolProvider);
+
+ /**
+ * Indicates that the given protocol provider is now connected.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt> that is
+ * connected
+ * @param date the date on which the event occured
+ */
+ public void protocolProviderConnected(
+ ProtocolProviderService protocolProvider,
+ long date);
+
+ /**
+ * Indicates that a protocol provider connection has failed.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt>, which
+ * connection failed
+ * @param loginManagerCallback the <tt>LoginManager</tt> implementation,
+ * which is managing the process
+ */
+ public void protocolProviderConnectionFailed(
+ ProtocolProviderService protocolProvider,
+ LoginManager loginManagerCallback);
+
+ /**
+ * Returns the <tt>SecurityAuthority</tt> implementation related to this
+ * login renderer.
+ *
+ * @param protocolProvider the specific <tt>ProtocolProviderService</tt>,
+ * for which we're obtaining a security authority
+ * @return the <tt>SecurityAuthority</tt> implementation related to this
+ * login renderer
+ */
+ public SecurityAuthority getSecurityAuthorityImpl(
+ ProtocolProviderService protocolProvider);
+
+ /**
+ * Indicates if the given <tt>protocolProvider</tt> related user interface
+ * is already rendered.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt>, which
+ * related user interface we're looking for
+ * @return <tt>true</tt> if the given <tt>protocolProvider</tt> related user
+ * interface is already rendered
+ */
+ public boolean containsProtocolProviderUI(
+ ProtocolProviderService protocolProvider);
+}
\ No newline at end of file diff --git a/src/net/java/sip/communicator/util/util.manifest.mf b/src/net/java/sip/communicator/util/util.manifest.mf index 0d7de8f..54512ed 100644 --- a/src/net/java/sip/communicator/util/util.manifest.mf +++ b/src/net/java/sip/communicator/util/util.manifest.mf @@ -38,6 +38,8 @@ Import-Package: com.sun.awt, net.java.sip.communicator.service.contactlist, net.java.sip.communicator.service.browserlauncher, net.java.sip.communicator.service.protocol, + net.java.sip.communicator.service.protocol.event, + net.java.sip.communicator.service.protocol.globalstatus, net.java.sip.communicator.service.dns, org.apache.xml.serialize, org.jitsi.service.configuration, |