aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/service
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2010-07-05 15:47:13 +0000
committerYana Stamcheva <yana@jitsi.org>2010-07-05 15:47:13 +0000
commit68337df58b03cb701971fc9e784dc54bea34d6a3 (patch)
tree84557fe73cb18c10a462a3754c01527f38d9a63d /src/net/java/sip/communicator/service
parentb44c93dccb9fe2aa578240a0fd59335c51dd4de6 (diff)
downloadjitsi-68337df58b03cb701971fc9e784dc54bea34d6a3.zip
jitsi-68337df58b03cb701971fc9e784dc54bea34d6a3.tar.gz
jitsi-68337df58b03cb701971fc9e784dc54bea34d6a3.tar.bz2
Configuration window improvements including reorganizing sections, user interface modifications, account loading/unloading functionality and more.
Diffstat (limited to 'src/net/java/sip/communicator/service')
-rw-r--r--src/net/java/sip/communicator/service/gui/AccountRegistrationForm.java148
-rw-r--r--src/net/java/sip/communicator/service/gui/ConfigurationForm.java11
-rw-r--r--src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java108
-rw-r--r--src/net/java/sip/communicator/service/keybindings/KeybindingSet.java2
-rw-r--r--src/net/java/sip/communicator/service/protocol/AccountID.java11
-rw-r--r--src/net/java/sip/communicator/service/protocol/AccountManager.java66
-rw-r--r--src/net/java/sip/communicator/service/protocol/ProtocolIcon.java21
-rw-r--r--src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java195
-rw-r--r--src/net/java/sip/communicator/service/protocol/ProtocolProviderService.java2
9 files changed, 480 insertions, 84 deletions
diff --git a/src/net/java/sip/communicator/service/gui/AccountRegistrationForm.java b/src/net/java/sip/communicator/service/gui/AccountRegistrationForm.java
new file mode 100644
index 0000000..6be0b40
--- /dev/null
+++ b/src/net/java/sip/communicator/service/gui/AccountRegistrationForm.java
@@ -0,0 +1,148 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.gui;
+
+import java.awt.*;
+
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ *
+ * @author Yana Stamcheva
+ */
+public interface AccountRegistrationForm
+{
+ /**
+ * Returns the protocol icon that will be shown on the left of the protocol
+ * name in the list, where user will choose the protocol to register to.
+ *
+ * @return a short description of the protocol.
+ */
+ public byte[] getListIcon();
+
+ /**
+ * Returns the icon that will be shown on the left of the registration form.
+ * @return the icon that will be shown on the left of the registration form
+ */
+ public byte[] getIcon();
+
+ /**
+ * Returns the protocol name that will be shown in the list, where user
+ * will choose the protocol to register to.
+ *
+ * @return the protocol name.
+ */
+ public String getProtocolName();
+
+ /**
+ * Returns a short description of the protocol that will be shown on the
+ * right of the protocol name in the list, where user will choose the
+ * protocol to register to.
+ *
+ * @return a short description of the protocol.
+ */
+ public String getProtocolDescription();
+
+ /**
+ * Returns an example string, which should indicate to the user how the
+ * user name should look like. For example: john@jabber.org.
+ * @return an example string, which should indicate to the user how the
+ * user name should look like.
+ */
+ public String getUserNameExample();
+
+ /**
+ * Loads all data concerning the given <tt>ProtocolProviderService</tt>.
+ * This method is meant to be used when a modification in an already
+ * created account is needed.
+ *
+ * @param protocolProvider The <tt>ProtocolProviderService</tt> to
+ * load data from.
+ */
+ public void loadAccount(ProtocolProviderService protocolProvider);
+
+ /**
+ * Returns the advanced registration form.
+ *
+ * @return the advanced registration form
+ */
+ public Component getAdvancedForm();
+
+ /**
+ * Defines the operations that will be executed when the user clicks on
+ * the wizard "Signin" button.
+ * @return the <tt>ProtocolProviderService</tt> that signed in
+ * @throws OperationFailedException
+ */
+ public ProtocolProviderService signin()
+ throws OperationFailedException;
+
+ /**
+ * Defines the operations that will be executed when the user clicks on
+ * the wizard "Signin" button.
+ *
+ * @param userName the user name to sign in with
+ * @param password the password to sign in with
+ */
+ public ProtocolProviderService signin( String userName,
+ String password)
+ throws OperationFailedException;
+
+ /**
+ * Returns <code>true</code> if the web sign up is supported by the current
+ * implementation, <code>false</code> - otherwise.
+ * @return <code>true</code> if the web sign up is supported by the current
+ * implementation, <code>false</code> - otherwise
+ */
+ public boolean isWebSignupSupported();
+
+ /**
+ * Defines the operation that will be executed when user clicks on the
+ * "Sign up" link.
+ * @throws UnsupportedOperationException if the web sign up operation is
+ * not supported by the current implementation.
+ */
+ public void webSignup() throws UnsupportedOperationException;
+
+ /**
+ * Sets the modification property to indicate if this wizard is opened for
+ * a modification.
+ *
+ * @param isModification indicates if this wizard is opened for modification
+ * or for creating a new account.
+ */
+ public void setModification(boolean isModification);
+
+ /**
+ * Indicates if this wizard is modifying an existing account or is creating
+ * a new one.
+ *
+ * @return <code>true</code> to indicate that this wizard is currently in
+ * modification mode, <code>false</code> - otherwise.
+ */
+ public boolean isModification();
+
+ /**
+ * Indicates whether this wizard enables the simple "sign in" form shown
+ * when the user opens the application for the first time. The simple
+ * "sign in" form allows user to configure her account in one click, just
+ * specifying her username and password and leaving any other configuration
+ * as by default.
+ * @return <code>true</code> if the simple "Sign in" form is enabled or
+ * <code>false</code> otherwise.
+ */
+ public boolean isSimpleFormEnabled();
+
+ /**
+ * Returns a simple account registration form that would be the first form
+ * shown to the user. Only if the user needs more settings she'll choose
+ * to open the advanced wizard, consisted by all pages.
+ *
+ * @return a simple account registration form
+ */
+ public Component getSimpleForm();
+}
diff --git a/src/net/java/sip/communicator/service/gui/ConfigurationForm.java b/src/net/java/sip/communicator/service/gui/ConfigurationForm.java
index 0b6fb05..85f70c8 100644
--- a/src/net/java/sip/communicator/service/gui/ConfigurationForm.java
+++ b/src/net/java/sip/communicator/service/gui/ConfigurationForm.java
@@ -17,8 +17,8 @@ package net.java.sip.communicator.service.gui;
*
* @author Yana Stamcheva
*/
-public interface ConfigurationForm {
-
+public interface ConfigurationForm
+{
/**
* Returns the title of this configuration form.
* @return the title of this configuration form
@@ -54,4 +54,11 @@ public interface ConfigurationForm {
* @return the index of this configuration form in the configuration window.
*/
public int getIndex();
+
+ /**
+ * Indicates if this is an advanced configuration form.
+ * @return <tt>true</tt> if this is an advanced configuration form,
+ * otherwise it returns <tt>false</tt>
+ */
+ public boolean isAdvanced();
}
diff --git a/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java b/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java
index 86ba615..9208450 100644
--- a/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java
+++ b/src/net/java/sip/communicator/service/gui/LazyConfigurationForm.java
@@ -12,12 +12,21 @@ import net.java.sip.communicator.service.resources.*;
/**
* @author Lubomir Marinov
+ * @author Yana Stamcheva
*/
public class LazyConfigurationForm
implements ConfigurationForm
{
+ /**
+ * The <tt>ResourceManagementService</tt> used to obtain any resources.
+ */
private static ResourceManagementService resources;
+ /**
+ * Returns an instance of the <tt>ResourceManagementService</tt>, which
+ * could be used to obtain any resources.
+ * @return an instance of the <tt>ResourceManagementService</tt>
+ */
private static ResourceManagementService getResources()
{
if (resources == null)
@@ -27,32 +36,91 @@ public class LazyConfigurationForm
return resources;
}
+ /**
+ * The form class loader.
+ */
private final ClassLoader formClassLoader;
+ /**
+ * The class name of the form.
+ */
private final String formClassName;
+ /**
+ * The identifier of the icon.
+ */
private final String iconID;
+ /**
+ * The index of the form in the parent container.
+ */
private final int index;
+ /**
+ * The title identifier.
+ */
private final String titleID;
+ /**
+ * Indicates if this form is advanced.
+ */
+ private final boolean isAdvanced;
+
+ /**
+ * Creates an instance of <tt>LazyConfigurationForm</tt>.
+ * @param formClassName the class name of the configuration form
+ * @param formClassLoader the class loader
+ * @param iconID the identifier of the form icon
+ * @param titleID the identifier of the form title
+ */
public LazyConfigurationForm(String formClassName,
ClassLoader formClassLoader, String iconID, String titleID)
{
- this(formClassName, formClassLoader, iconID, titleID, -1);
+ this(formClassName, formClassLoader, iconID, titleID, -1, false);
}
+ /**
+ * Creates an instance of <tt>LazyConfigurationForm</tt>.
+ * @param formClassName the class name of the configuration form
+ * @param formClassLoader the class loader
+ * @param iconID the identifier of the form icon
+ * @param titleID the identifier of the form title
+ * @param index the index of the form in the parent container
+ */
public LazyConfigurationForm(String formClassName,
ClassLoader formClassLoader, String iconID, String titleID, int index)
{
+ this(formClassName, formClassLoader, iconID, titleID, index, false);
+ }
+
+ /**
+ * Creates an instance of <tt>LazyConfigurationForm</tt>.
+ * @param formClassName the class name of the configuration form
+ * @param formClassLoader the class loader
+ * @param iconID the identifier of the form icon
+ * @param titleID the identifier of the form title
+ * @param index the index of the form in the parent container
+ * @param isAdvanced indicates if the form is advanced configuration form
+ */
+ public LazyConfigurationForm(String formClassName,
+ ClassLoader formClassLoader,
+ String iconID,
+ String titleID,
+ int index,
+ boolean isAdvanced)
+ {
this.formClassName = formClassName;
this.formClassLoader = formClassLoader;
this.iconID = iconID;
this.titleID = titleID;
this.index = index;
+ this.isAdvanced = isAdvanced;
}
+ /**
+ * Returns the form component.
+ * @return the form component
+ */
public Object getForm()
{
Exception exception;
@@ -77,38 +145,76 @@ public class LazyConfigurationForm
throw new UndeclaredThrowableException(exception);
}
+ /**
+ * Returns the form class loader.
+ * @return the form class loader
+ */
protected ClassLoader getFormClassLoader()
{
return formClassLoader;
}
+ /**
+ * Returns the form class name.
+ * @return the form class name
+ */
protected String getFormClassName()
{
return formClassName;
}
+ /**
+ * Returns the icon of the form.
+ * @return a byte array containing the icon of the form
+ */
public byte[] getIcon()
{
return getResources().getImageInBytes(getIconID());
}
+ /**
+ * Returns the identifier of the icon.
+ * @return the identifier of the icon
+ */
protected String getIconID()
{
return iconID;
}
+ /**
+ * Returns the index of the form in its parent container.
+ * @return the index of the form in its parent container
+ */
public int getIndex()
{
return index;
}
+ /**
+ * Returns the title of the form.
+ * @return the title of the form
+ */
public String getTitle()
{
return getResources().getI18NString(getTitleID());
}
+ /**
+ * Returns the identifier of the title of the form.
+ * @return the identifier of the title of the form
+ */
protected String getTitleID()
{
return titleID;
}
+
+ /**
+ * Indicates if the form is an advanced form.
+ * @return <tt>true</tt> to indicate that this is an advanced form,
+ * otherwise returns <tt>false</tt>
+ */
+ public boolean isAdvanced()
+ {
+ return isAdvanced;
+ }
}
diff --git a/src/net/java/sip/communicator/service/keybindings/KeybindingSet.java b/src/net/java/sip/communicator/service/keybindings/KeybindingSet.java
index 9174f9f..42c5a9f 100644
--- a/src/net/java/sip/communicator/service/keybindings/KeybindingSet.java
+++ b/src/net/java/sip/communicator/service/keybindings/KeybindingSet.java
@@ -10,8 +10,6 @@ import java.util.*;
import javax.swing.*;
-import chooser.*;
-
/**
* Wrapper for keybinding sets. Observers are notified when there's a change.
* @author Damian Johnson
diff --git a/src/net/java/sip/communicator/service/protocol/AccountID.java b/src/net/java/sip/communicator/service/protocol/AccountID.java
index 25ea6ff..71035dc 100644
--- a/src/net/java/sip/communicator/service/protocol/AccountID.java
+++ b/src/net/java/sip/communicator/service/protocol/AccountID.java
@@ -339,6 +339,17 @@ public abstract class AccountID
}
/**
+ * Indicates if this account is currently enabled.
+ * @return <tt>true</tt> if this account is enabled, <tt>false</tt> -
+ * otherwise.
+ */
+ public boolean isEnabled()
+ {
+ return !getAccountPropertyBoolean(
+ ProtocolProviderFactory.IS_ACCOUNT_DISABLED, false);
+ }
+
+ /**
* Set the account properties.
*
* @param accountProperties the properties of the account
diff --git a/src/net/java/sip/communicator/service/protocol/AccountManager.java b/src/net/java/sip/communicator/service/protocol/AccountManager.java
index c692e1a..d6853a8 100644
--- a/src/net/java/sip/communicator/service/protocol/AccountManager.java
+++ b/src/net/java/sip/communicator/service/protocol/AccountManager.java
@@ -6,6 +6,10 @@
*/
package net.java.sip.communicator.service.protocol;
+import java.util.*;
+
+import org.osgi.framework.*;
+
import net.java.sip.communicator.service.protocol.event.*;
/**
@@ -17,7 +21,6 @@ import net.java.sip.communicator.service.protocol.event.*;
*/
public interface AccountManager
{
-
/**
* Registers a specific listener to be notified about events fired by this
* <code>AccountManager</code>. If the <code>listener</code> is already
@@ -67,4 +70,65 @@ public interface AccountManager
* the account in the form of <code>AccountID</code> to be stored
*/
void storeAccount(ProtocolProviderFactory factory, AccountID accountID);
+
+ /**
+ * Removes the account with <tt>accountID</tt> from the set of accounts
+ * that are persistently stored inside the configuration service.
+ * <p>
+ * @param factory the <code>ProtocolProviderFactory</code> which created the
+ * account to be stored
+ * @param accountID the AccountID of the account to remove.
+ * <p>
+ * @return true if an account has been removed and false otherwise.
+ */
+ boolean removeStoredAccount(ProtocolProviderFactory factory,
+ AccountID accountID);
+
+ /**
+ * Returns an <tt>Iterator</tt> over a list of all stored
+ * <tt>AccountID</tt>s. 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.
+ * <p>
+ * 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.
+ *
+ * @return a <tt>Collection</tt> of all stored <tt>AccountID</tt>s
+ */
+ public Collection<AccountID> getStoredAccounts();
+
+ /**
+ * Loads the account corresponding to the given <tt>AccountID</tt>. An
+ * account is loaded when its <tt>ProtocolProviderService</tt> is registered
+ * in the bundle context. This method is meant to load the account through
+ * the corresponding <tt>ProtocolProviderFactory</tt>.
+ *
+ * @param accountID the identifier of the account to load
+ */
+ public void loadAccount(AccountID accountID);
+
+ /**
+ * Unloads the account corresponding to the given <tt>AccountID</tt>. An
+ * account is unloaded when its <tt>ProtocolProviderService</tt> is
+ * unregistered in the bundle context. This method is meant to unload the
+ * account through the corresponding <tt>ProtocolProviderFactory</tt>.
+ *
+ * @param accountID the identifier of the account to load
+ */
+ public void unloadAccount(AccountID accountID);
+
+ /**
+ * Checks if the account corresponding to the given <tt>accountID</tt> is
+ * loaded. An account is loaded if its <tt>ProtocolProviderService</tt> 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.
+ *
+ * @param accountID the identifier of the account to load
+ * @return <tt>true</tt> to indicate that the account with the given
+ * <tt>accountID</tt> is loaded, <tt>false</tt> - otherwise
+ */
+ public boolean isAccountLoaded(AccountID accountID);
}
diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolIcon.java b/src/net/java/sip/communicator/service/protocol/ProtocolIcon.java
index 82e5a25..de0ab4e 100644
--- a/src/net/java/sip/communicator/service/protocol/ProtocolIcon.java
+++ b/src/net/java/sip/communicator/service/protocol/ProtocolIcon.java
@@ -23,22 +23,22 @@ public interface ProtocolIcon
* Defines a 16x16 icon size.
*/
public static final String ICON_SIZE_16x16 = "IconSize16x16";
-
+
/**
* Defines a 32x32 icon size.
*/
public static final String ICON_SIZE_32x32 = "IconSize32x32";
-
+
/**
* Defines a 48x48 icon size.
*/
public static final String ICON_SIZE_48x48 = "IconSize48x48";
-
+
/**logo
* Defines a 64x64 icon size.
*/
public static final String ICON_SIZE_64x64 = "IconSize64x64";
-
+
/**
* Returns an iterator over a set, containing different predefined icon sizes.
* Each icon size in the set is one of the ICON_SIZE_XXX constants. The
@@ -51,7 +51,7 @@ public interface ProtocolIcon
* constants.
*/
public Iterator<String> getSupportedSizes();
-
+
/**
* Checks if the given icon size is supported by the current protocol
* implementation. If the given <tt>iconSize</tt> is contained in the list of
@@ -63,7 +63,7 @@ public interface ProtocolIcon
* implementation, FALSE - otherwise.
*/
public boolean isSizeSupported(String iconSize);
-
+
/**
* Returns the protocol icon image in the desired size.
* @param iconSize the size of the protocol icon; one of the ICON_SIZE_XXX
@@ -71,7 +71,14 @@ public interface ProtocolIcon
* @return the protocol icon image in the desired size
*/
public byte[] getIcon(String iconSize);
-
+
+ /**
+ * Returns a path to the icon with the given size.
+ * @param iconSize the size of the icon we're looking for
+ * @return the path to the icon with the given size
+ */
+ public String getIconPath(String iconSize);
+
/**
* Returns the icon that should be used when the protocol provider is in
* a connecting state.
diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
index a665c09..e2091fb 100644
--- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
+++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
@@ -46,6 +46,13 @@ public abstract class ProtocolProviderFactory
public static final String PROTOCOL_ICON_PATH = "PROTOCOL_ICON_PATH";
/**
+ * The name of a property representing the path to the account icon to
+ * be used in the user interface, when the protocol provider service is not
+ * available.
+ */
+ public static final String ACCOUNT_ICON_PATH = "ACCOUNT_ICON_PATH";
+
+ /**
* The name of a property which represents the AccountID of a
* ProtocolProvider and that, together with a password is used to login
* on the protocol network..
@@ -236,6 +243,12 @@ public abstract class ProtocolProviderFactory
public static final String IS_PROTOCOL_HIDDEN = "IS_PROTOCOL_HIDDEN";
/**
+ * The name of the property that would indicate if a given account is
+ * currently enabled or disabled.
+ */
+ public static final String IS_ACCOUNT_DISABLED = "IS_ACCOUNT_DISABLED";
+
+ /**
* The <code>BundleContext</code> containing (or to contain) the service
* registration of this factory.
*/
@@ -255,8 +268,8 @@ public abstract class ProtocolProviderFactory
* achieved by also hiding it from protected into private access.
* </p>
*/
- protected final Hashtable<AccountID, ServiceRegistration> registeredAccounts =
- new Hashtable<AccountID, ServiceRegistration>();
+ protected final Hashtable<AccountID, ServiceRegistration> registeredAccounts
+ = new Hashtable<AccountID, ServiceRegistration>();
protected ProtocolProviderFactory(BundleContext bundleContext,
String protocolName)
@@ -409,7 +422,7 @@ public abstract class ProtocolProviderFactory
// Kill the service.
registration.unregister();
- return removeStoredAccount(bundleContext, accountID);
+ return removeStoredAccount(accountID);
}
/**
@@ -569,25 +582,26 @@ public abstract class ProtocolProviderFactory
*/
public AccountID loadAccount(Map<String, String> accountProperties)
{
- BundleContext bundleContext = getBundleContext();
- if (bundleContext == null)
- throw new NullPointerException(
- "The specified BundleContext was null");
-
- if (accountProperties == null)
- throw new NullPointerException(
- "The specified property map was null");
+ AccountID accountID = createAccount(accountProperties);
- String userID = accountProperties.get(USER_ID);
- if (userID == null)
- throw new NullPointerException(
- "The account properties contained no user id.");
+ loadAccount(accountID);
- String protocolName = getProtocolName();
- if (!accountProperties.containsKey(PROTOCOL))
- accountProperties.put(PROTOCOL, protocolName);
+ return accountID;
+ }
- AccountID accountID = createAccountID(userID, accountProperties);
+ /**
+ * Creates a protocol provider for the given <tt>accountID</tt> and
+ * registers it in the bundle context. This method has a persistent
+ * effect. Once created the resulting account will remain installed until
+ * removed through the uninstallAccount method.
+ *
+ * @param accountID the account identifier
+ * @return <tt>true</tt> if the account with the given <tt>accountID</tt> is
+ * successfully loaded, otherwise returns <tt>false</tt>
+ */
+ public boolean loadAccount(AccountID accountID)
+ {
+ String userID = accountID.getUserID();
ProtocolProviderService service = createService(userID, accountID);
@@ -599,12 +613,99 @@ public abstract class ProtocolProviderFactory
bundleContext.registerService(ProtocolProviderService.class
.getName(), service, properties);
+ if (serviceRegistration == null)
+ {
+ return false;
+ }
+
synchronized (registeredAccounts)
{
registeredAccounts.put(accountID, serviceRegistration);
}
- return accountID;
+ return true;
+ }
+
+ /**
+ * Unloads the account corresponding to the given <tt>accountID</tt>.
+ * Unregisters the corresponding protocol provider, but keeps the account in
+ * contrast to the uninstallAccount method.
+ *
+ * @param accountID the account identifier
+ * @return true if an account with the specified ID existed and was unloaded
+ * and false otherwise.
+ */
+ public boolean unloadAccount(AccountID accountID)
+ {
+ // Unregister the protocol provider.
+ ServiceReference serRef = getProviderForAccount(accountID);
+
+ if (serRef == null)
+ {
+ return false;
+ }
+
+ BundleContext bundleContext = getBundleContext();
+ ProtocolProviderService protocolProvider =
+ (ProtocolProviderService) bundleContext.getService(serRef);
+
+ try
+ {
+ protocolProvider.unregister();
+ }
+ catch (OperationFailedException ex)
+ {
+ logger
+ .error("Failed to unregister protocol provider for account : "
+ + accountID + " caused by: " + ex);
+ }
+
+ ServiceRegistration registration;
+
+ synchronized (registeredAccounts)
+ {
+ registration = registeredAccounts.remove(accountID);
+ }
+ if (registration == null)
+ {
+ return false;
+ }
+
+ // Kill the service.
+ registration.unregister();
+
+ return true;
+ }
+
+ /**
+ * Initializes and creates an account corresponding to the specified
+ * accountProperties.
+ *
+ * @param accountProperties a set of protocol (or implementation) specific
+ * properties defining the new account.
+ * @return the AccountID of the newly created account
+ */
+ public AccountID createAccount(Map<String, String> accountProperties)
+ {
+ BundleContext bundleContext = getBundleContext();
+ if (bundleContext == null)
+ throw new NullPointerException(
+ "The specified BundleContext was null");
+
+ if (accountProperties == null)
+ throw new NullPointerException(
+ "The specified property map was null");
+
+ String userID = accountProperties.get(USER_ID);
+ if (userID == null)
+ throw new NullPointerException(
+ "The account properties contained no user id.");
+
+ String protocolName = getProtocolName();
+ if (!accountProperties.containsKey(PROTOCOL))
+ accountProperties.put(PROTOCOL, protocolName);
+
+ return createAccountID(userID, accountProperties);
}
/**
@@ -664,60 +765,14 @@ public abstract class ProtocolProviderFactory
/**
* Removes the account with <tt>accountID</tt> from the set of accounts
* that are persistently stored inside the configuration service.
- * <p>
- * @param bundleContext a currently valid bundle context.
+ *
* @param accountID the AccountID of the account to remove.
- * <p>
+ *
* @return true if an account has been removed and false otherwise.
*/
- protected boolean removeStoredAccount(BundleContext bundleContext,
- AccountID accountID)
+ protected boolean removeStoredAccount(AccountID accountID)
{
- String sourcePackageName = getFactoryImplPackageName();
-
- ServiceReference confReference
- = bundleContext.getServiceReference(
- ConfigurationService.class.getName());
- ConfigurationService configurationService
- = (ConfigurationService) bundleContext.getService(confReference);
-
- //first retrieve all accounts that we've registered
- List<String> storedAccounts = configurationService.getPropertyNamesByPrefix(
- sourcePackageName, true);
-
- //find an account with the corresponding id.
- for (String accountRootPropertyName : storedAccounts)
- {
- //unregister the account in the configuration service.
- //all the properties must have been registered in the following
- //hierarchy:
- //net.java.sip.communicator.impl.protocol.PROTO_NAME.ACC_ID.PROP_NAME
- String accountUID = configurationService.getString(
- accountRootPropertyName //node id
- + "." + ACCOUNT_UID); // propname
-
- if (accountUID.equals(accountID.getAccountUniqueID()))
- {
- //retrieve the names of all properties registered for the
- //current account.
- List<String> accountPropertyNames
- = configurationService.getPropertyNamesByPrefix(
- accountRootPropertyName, false);
-
- //set all account properties to null in order to remove them.
- for (String propName : accountPropertyNames)
- {
- configurationService.setProperty(propName, null);
- }
-
- //and now remove the parent too.
- configurationService.setProperty(
- accountRootPropertyName, null);
-
- return true;
- }
- }
- return false;
+ return getAccountManager().removeStoredAccount(this, accountID);
}
/**
diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderService.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderService.java
index 896948e..a170d0c 100644
--- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderService.java
+++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderService.java
@@ -151,7 +151,7 @@ public interface ProtocolProviderService
* @param opsetClass the <tt>Class</tt> of the operation set that we're
* looking for.
* @return returns an OperationSet of the specified <tt>Class</tt> if the
- * undelying implementation supports it or null otherwise.
+ * underlying implementation supports it or null otherwise.
*/
public <T extends OperationSet> T getOperationSet(Class<T> opsetClass);