Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.protocol
Class AccountManager

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AccountManager

public class AccountManager
extends Object

Represents an implementation of AccountManager which loads the accounts in a separate thread.

Author:
Lubomir Marinov, Yana Stamcheva

Constructor Summary
AccountManager(org.osgi.framework.BundleContext bundleContext)
          Initializes a new AccountManagerImpl instance loaded in a specific BundleContext (in which the caller will usually later register it).
 
Method Summary
 void addListener(AccountManagerListener listener)
          Implements AccountManager#addListener(AccountManagerListener).
 Collection<AccountID> getStoredAccounts()
          Returns an Iterator over a list of all stored AccountIDs.
 boolean hasStoredAccounts(String protocolName, boolean includeHidden)
           
 boolean isAccountLoaded(AccountID accountID)
          Checks if the account corresponding to the given accountID is loaded.
 void loadAccount(AccountID accountID)
          Loads the account corresponding to the given AccountID.
 void removeListener(AccountManagerListener listener)
          Implements AccountManager#removeListener(AccountManagerListener).
 boolean removeStoredAccount(ProtocolProviderFactory factory, AccountID accountID)
          Removes the account with accountID from the set of accounts that are persistently stored inside the configuration service.
 void removeStoredAccounts()
          Removes all accounts which have been persistently stored.
 void storeAccount(ProtocolProviderFactory factory, AccountID accountID)
          Stores an account represented in the form of an AccountID created by a specific ProtocolProviderFactory.
 void unloadAccount(AccountID accountID)
          Unloads the account corresponding to the given AccountID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccountManager

public AccountManager(org.osgi.framework.BundleContext bundleContext)
Initializes a new AccountManagerImpl instance loaded in a specific BundleContext (in which the caller will usually later register it).

Parameters:
bundleContext - the BundleContext in which the new instance is loaded (and in which the caller will usually later register it as a service)
Method Detail

addListener

public void addListener(AccountManagerListener listener)
Implements AccountManager#addListener(AccountManagerListener).

Parameters:
listener - the AccountManagerListener to add

hasStoredAccounts

public boolean hasStoredAccounts(String protocolName,
                                 boolean includeHidden)

removeListener

public void removeListener(AccountManagerListener listener)
Implements AccountManager#removeListener(AccountManagerListener).

Parameters:
listener - the AccountManagerListener to remove

storeAccount

public void storeAccount(ProtocolProviderFactory factory,
                         AccountID accountID)
                  throws OperationFailedException
Stores an account represented in the form of an AccountID created by a specific ProtocolProviderFactory.

Parameters:
factory - the ProtocolProviderFactory which created the account to be stored
accountID - the account in the form of AccountID to be stored
Throws:
OperationFailedException - if anything goes wrong while storing the account

removeStoredAccount

public boolean removeStoredAccount(ProtocolProviderFactory factory,
                                   AccountID accountID)
Removes the account with accountID from the set of accounts that are persistently stored inside the configuration service.

Parameters:
factory - the ProtocolProviderFactory which created the account to be stored
accountID - the AccountID of the account to remove.
Returns:
true if an account has been removed and false otherwise.

removeStoredAccounts

public void removeStoredAccounts()
Removes all accounts which have been persistently stored.

See Also:
removeStoredAccount(ProtocolProviderFactory, AccountID)

getStoredAccounts

public Collection<AccountID> getStoredAccounts()
Returns an Iterator over a list of all stored AccountIDs. The list of stored accounts include all registered accounts and all disabled accounts. In other words in this list we could find accounts that aren't loaded.

In order to check if an account is already loaded please use the #isAccountLoaded(AccountID accountID) method. To load an account use the #loadAccount(AccountID accountID) method.

Returns:
an Iterator over a list of all stored AccountIDs

loadAccount

public void loadAccount(AccountID accountID)
                 throws OperationFailedException
Loads the account corresponding to the given AccountID. An account is loaded when its ProtocolProviderService is registered in the bundle context. This method is meant to load the account through the corresponding ProtocolProviderFactory.

Parameters:
accountID - the identifier of the account to load
Throws:
OperationFailedException - if anything goes wrong while loading the account corresponding to the specified accountID

unloadAccount

public void unloadAccount(AccountID accountID)
                   throws OperationFailedException
Unloads the account corresponding to the given AccountID. An account is unloaded when its ProtocolProviderService is unregistered in the bundle context. This method is meant to unload the account through the corresponding ProtocolProviderFactory.

Parameters:
accountID - the identifier of the account to load
Throws:
OperationFailedException - if anything goes wrong while unloading the account corresponding to the specified accountID

isAccountLoaded

public boolean isAccountLoaded(AccountID accountID)
Checks if the account corresponding to the given accountID is loaded. An account is loaded if its ProtocolProviderService is registered in the bundle context. By default all accounts are loaded. However the user could manually unload an account, which would be unregistered from the bundle context, but would remain in the configuration file.

Parameters:
accountID - the identifier of the account to load
Returns:
true to indicate that the account with the given accountID is loaded, false - otherwise

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.