aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2011-03-18 16:53:40 +0000
committerYana Stamcheva <yana@jitsi.org>2011-03-18 16:53:40 +0000
commit5f275613b49a0190e34e89f9338a5614eb267bf6 (patch)
treeb9ae8b019df43ca61d0477630443397f853efc75 /src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java
parent67fd578d02d8bcec92334cf23732ddc2f7b24e6a (diff)
downloadjitsi-5f275613b49a0190e34e89f9338a5614eb267bf6.zip
jitsi-5f275613b49a0190e34e89f9338a5614eb267bf6.tar.gz
jitsi-5f275613b49a0190e34e89f9338a5614eb267bf6.tar.bz2
Fixes an issue in the sip2sip and iptel.org account forms.
Makes the jabber account form extendable, so that in the google talk account form we have all the options we find in the jabber form.
Diffstat (limited to 'src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java')
-rw-r--r--src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java411
1 files changed, 93 insertions, 318 deletions
diff --git a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java
index ce8ba2a..75cd722 100644
--- a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java
@@ -6,14 +6,10 @@
*/
package net.java.sip.communicator.plugin.googletalkaccregwizz;
-import java.awt.*;
import java.util.*;
+import net.java.sip.communicator.plugin.jabberaccregwizz.*;
import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
/**
* The <tt>GoogleTalkAccountRegistrationWizard</tt> is an implementation of the
@@ -21,84 +17,36 @@ import org.osgi.framework.*;
* allow the user to create and configure a new Google Talk account.
*
* @author Lubomir Marinov
+ * @author Yana Stamcheva
*/
public class GoogleTalkAccountRegistrationWizard
- implements AccountRegistrationWizard
+ extends JabberAccountRegistrationWizard
{
/**
- * The <tt>Logger</tt> used by this
- * <tt>GoogleTalkAccountRegistrationWizard</tt> for logging output.
+ * The Google Talk protocol name.
*/
- private final Logger logger
- = Logger.getLogger(GoogleTalkAccountRegistrationWizard.class);
-
public static final String PROTOCOL = "Google Talk";
- private FirstWizardPage firstWizardPage;
-
- private GoogleTalkAccountRegistration registration
- = new GoogleTalkAccountRegistration();
-
- private WizardContainer wizardContainer;
-
- private ProtocolProviderService protocolProvider;
-
- private boolean isModification;
-
/**
- * Creates an instance of <tt>GoogleTalkAccountRegistrationWizard</tt>.
- * @param wizardContainer the wizard container, where this wizard
- * is added
+ * A constant pointing to the Google Talk protocol logo image.
*/
- public GoogleTalkAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- this.wizardContainer = wizardContainer;
-
- this.wizardContainer
- .setFinishButtonText(Resources.getString("service.gui.SIGN_IN"));
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * Returns the icon to be used for this wizard.
- * @return byte[]
- */
- public byte[] getIcon()
- {
- return Resources.getImage(Resources.PROTOCOL_ICON);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
- * Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- public byte[] getPageImage()
- {
- return Resources.getImage(Resources.PAGE_IMAGE);
- }
+ public static final String PROTOCOL_ICON
+ = "service.protocol.googletalk.GTALK_16x16";
/**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method. Returns the protocol name for this wizard.
- * @return String
+ * A constant pointing to the Aim protocol wizard page image.
*/
- public String getProtocolName()
- {
- return Resources
- .getString("plugin.googletalkaccregwizz.PROTOCOL_NAME");
- }
+ public static final String PAGE_IMAGE
+ = "service.protocol.googletalk.GTALK_64x64";
/**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code> method. Returns the description of the protocol for this wizard.
- * @return String
+ * Creates an instance of <tt>GoogleTalkAccountRegistrationWizard</tt>.
+ * @param wizardContainer the wizard container, where this wizard
+ * is added
*/
- public String getProtocolDescription()
+ public GoogleTalkAccountRegistrationWizard(WizardContainer wizardContainer)
{
- return Resources
- .getString("plugin.googletalkaccregwizz.PROTOCOL_DESCRIPTION");
+ super(wizardContainer);
}
/**
@@ -107,318 +55,156 @@ public class GoogleTalkAccountRegistrationWizard
*/
public Iterator<WizardPage> getPages()
{
- java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
-
- // create new registration, our container needs the pages
- // this means this is a new wizard and we must reset all data
- // it will be invoked and when the wizard cleans and unregister
- // our pages, but this fix don't hurt in this situation.
- this.registration = new GoogleTalkAccountRegistration();
+ JabberAccountRegistration reg = new JabberAccountRegistration();
- firstWizardPage = new FirstWizardPage(this);
+ setPredefinedProperties(reg);
- pages.add(firstWizardPage);
-
- return pages.iterator();
+ return getPages(reg);
}
/**
- * Returns the set of data that user has entered through this wizard.
- * @return Iterator
+ * Returns the first wizard page.
+ *
+ * @return the first wizard page.
*/
- public Iterator<Map.Entry<String, String>> getSummary()
+ public Object getSimpleForm()
{
- Hashtable<String, String> summaryTable
- = new Hashtable<String, String>();
-
- summaryTable.put(
- Resources.getString("plugin.googletalkaccregwizz.USERNAME"),
- registration.getUserID());
-
- summaryTable.put(
- Resources.getString("service.gui.REMEMBER_PASSWORD"),
- Boolean.toString(registration.isRememberPassword()));
-
- summaryTable.put(
- Resources.getString("plugin.jabberaccregwizz.SERVER"),
- registration.getServerAddress());
+ JabberAccountRegistration reg = new JabberAccountRegistration();
- summaryTable.put(
- Resources.getString("service.gui.PORT"),
- String.valueOf(registration.getPort()));
+ setPredefinedProperties(reg);
- summaryTable.put(
- Resources.getString("plugin.jabberaccregwizz.ENABLE_KEEP_ALIVE"),
- String.valueOf(registration.isSendKeepAlive()));
-
- summaryTable.put(
- Resources.getString("plugin.jabberaccregwizz.RESOURCE"),
- registration.getResource());
-
- summaryTable.put(
- Resources.getString("plugin.jabberaccregwizz.PRIORITY"),
- String.valueOf(registration.getPriority()));
-
- return summaryTable.entrySet().iterator();
+ return getSimpleForm(reg);
}
/**
- * Installs the account created through this wizard.
- *
- * @return ProtocolProviderService
+ * Sets all google talk specific properties.
+ *
+ * @param reg the registration object
*/
- public ProtocolProviderService signin()
- throws OperationFailedException
+ private void setPredefinedProperties(JabberAccountRegistration reg)
{
- firstWizardPage.commitPage();
+ reg.setServerAddress("talk.google.com");
- return signin( registration.getUserID(),
- registration.getPassword());
- }
-
- public ProtocolProviderService signin(String userName, String password)
- throws OperationFailedException
- {
- ProtocolProviderFactory factory
- = GoogleTalkAccRegWizzActivator
- .getGoogleTalkProtocolProviderFactory();
-
- return this.installAccount(factory,
- userName,
- password);
+ reg.setServerOverridden(true);
}
/**
- * Creates an account for the given user and password.
- *
- * @param providerFactory the ProtocolProviderFactory which will create
- * the account
- * @param userName the user identifier
- * @param passwd the password
- * @return the <tt>ProtocolProviderService</tt> for the new account.
+ * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
+ * Returns the icon to be used for this wizard.
+ * @return byte[]
*/
- public ProtocolProviderService installAccount(
- ProtocolProviderFactory providerFactory,
- String userName,
- String passwd)
- throws OperationFailedException
+ public byte[] getIcon()
{
- Hashtable<String, String> accountProperties
- = new Hashtable<String, String>();
-
- /* Make the account use the resources specific to Google Talk. */
- accountProperties.put(ProtocolProviderFactory.PROTOCOL, PROTOCOL);
- accountProperties
- .put(ProtocolProviderFactory.PROTOCOL_ICON_PATH,
- "resources/images/protocol/googletalk");
-
- accountProperties.put(ProtocolProviderFactory.ACCOUNT_ICON_PATH,
- "resources/images/protocol/googletalk/logo32x32.png");
-
- if (registration.isRememberPassword())
- {
- accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
- }
-
- accountProperties.put("SEND_KEEP_ALIVE",
- String.valueOf(registration.isSendKeepAlive()));
-
- String serverName = registration.getServerAddress();
- if (serverName != null)
- {
- if (userName.indexOf(serverName) < 0)
- accountProperties.put(
- ProtocolProviderFactory.IS_SERVER_OVERRIDDEN,
- Boolean.toString(true));
- }
- else
- {
- serverName = getServerFromUserName(userName);
- }
-
- accountProperties.put(ProtocolProviderFactory.SERVER_ADDRESS,
- serverName);
-
- accountProperties.put(ProtocolProviderFactory.SERVER_PORT,
- String.valueOf(registration.getPort()));
-
- accountProperties.put(ProtocolProviderFactory.RESOURCE,
- registration.getResource());
-
- accountProperties.put(ProtocolProviderFactory.RESOURCE_PRIORITY,
- String.valueOf(registration.getPriority()));
-
- if (isModification)
- {
- providerFactory.modifyAccount( protocolProvider,
- accountProperties);
-
- this.isModification = false;
-
- return protocolProvider;
- }
-
- try
- {
- AccountID accountID = providerFactory.installAccount(
- userName, accountProperties);
-
- ServiceReference serRef = providerFactory
- .getProviderForAccount(accountID);
-
- protocolProvider = (ProtocolProviderService)
- GoogleTalkAccRegWizzActivator.bundleContext
- .getService(serRef);
- }
- catch (IllegalStateException exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Account already exists.",
- OperationFailedException.IDENTIFICATION_CONFLICT);
- }
- catch (Exception exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Failed to add account",
- OperationFailedException.GENERAL_ERROR);
- }
-
- return protocolProvider;
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getImageInBytes(PROTOCOL_ICON);
}
-
+
/**
- * Fills the User ID and Password fields in this panel with the data coming
- * from the given protocolProvider.
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load the
- * data from.
+ * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
+ * Returns the image used to decorate the wizard page
+ *
+ * @return byte[] the image used to decorate the wizard page
*/
- public void loadAccount(ProtocolProviderService protocolProvider)
+ public byte[] getPageImage()
{
- this.isModification = true;
-
- this.protocolProvider = protocolProvider;
-
- this.registration = new GoogleTalkAccountRegistration();
-
- this.firstWizardPage.loadAccount(protocolProvider);
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getImageInBytes(PAGE_IMAGE);
}
/**
- * Indicates if this wizard is opened for modification or for creating a
- * new account.
- *
- * @return <code>true</code> if this wizard is opened for modification and
- * <code>false</code> otherwise.
+ * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
+ * method. Returns the protocol name for this wizard.
+ * @return String
*/
- public boolean isModification()
+ public String getProtocolName()
{
- return isModification;
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getI18NString("plugin.googletalkaccregwizz.PROTOCOL_NAME");
}
/**
- * Returns the wizard container, where all pages are added.
- *
- * @return the wizard container, where all pages are added
+ * Implements the <code>AccountRegistrationWizard.getProtocolDescription
+ * </code> method. Returns the description of the protocol for this wizard.
+ * @return String
*/
- public WizardContainer getWizardContainer()
+ public String getProtocolDescription()
{
- return wizardContainer;
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getI18NString("plugin.googletalkaccregwizz.PROTOCOL_DESCRIPTION");
}
/**
- * Returns the registration object, which will store all the data through
- * the wizard.
- *
- * @return the registration object, which will store all the data through
- * the wizard
+ * Returns an example string, which should indicate to the user how the
+ * user name should look like.
+ * @return an example string, which should indicate to the user how the
+ * user name should look like.
*/
- public GoogleTalkAccountRegistration getRegistration()
+ public String getUserNameExample()
{
- return registration;
+ return "Ex: johnsmith@gmail.com";
}
/**
- * Returns the size of this wizard.
- * @return the size of this wizard
+ * Returns the display label used for the sip id field.
+ * @return the sip id display label string.
*/
- public Dimension getSize()
+ protected String getUsernameLabel()
{
- return new Dimension(300, 480);
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getI18NString("plugin.googletalkaccregwizz.USERNAME");
}
-
+
/**
- * Returns the identifier of the page to show first in the wizard.
- * @return the identifier of the page to show first in the wizard.
+ * Return the string for add existing account button.
+ * @return the string for add existing account button.
*/
- public Object getFirstPageIdentifier()
+ protected String getCreateAccountButtonLabel()
{
- return firstWizardPage.getIdentifier();
+ return GoogleTalkAccRegWizzActivator.getResources().getI18NString(
+ "plugin.googletalkaccregwizz.NEW_ACCOUNT_TITLE");
}
/**
- * Returns the identifier of the page to show last in the wizard.
- * @return the identifier of the page to show last in the wizard.
+ * Return the string for create new account button.
+ * @return the string for create new account button.
*/
- public Object getLastPageIdentifier()
+ protected String getCreateAccountLabel()
{
- return firstWizardPage.getIdentifier();
+ return GoogleTalkAccRegWizzActivator.getResources().getI18NString(
+ "plugin.googletalkaccregwizz.REGISTER_NEW_ACCOUNT_TEXT");
}
/**
- * 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.
+ * Returns the protocol name as listed in "ProtocolNames" or just the name
+ * of the service.
+ * @return the protocol name
*/
- public void setModification(boolean isModification)
+ public String getProtocol()
{
- this.isModification = isModification;
+ return PROTOCOL;
}
/**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
+ * Returns the protocol icon path.
+ * @return the protocol icon path
*/
- public String getUserNameExample()
+ public String getProtocolIconPath()
{
- return FirstWizardPage.USER_NAME_EXAMPLE;
+ return "resources/images/protocol/googletalk";
}
/**
- * Enables the simple "Sign in" form.
+ * Returns the account icon path.
+ * @return the account icon path
*/
- public boolean isSimpleFormEnabled()
+ public String getAccountIconPath()
{
- return true;
+ return "resources/images/protocol/googletalk/logo32x32.png";
}
/**
- * Parse the server part from the Google Talk id and set it to server as
- * default value. If Advanced option is enabled Do nothing.
+ * Opens a browser on the sign up page.
*/
- protected String getServerFromUserName(String userName)
- {
- int delimIndex = userName.indexOf("@");
-
- if (delimIndex != -1)
- {
- String newServerAddr = userName.substring(delimIndex + 1);
-
- if (!newServerAddr
- .equals(GoogleTalkAccountRegistration.GOOGLE_USER_SUFFIX))
- return newServerAddr;
- }
-
- return GoogleTalkAccountRegistration.GOOGLE_CONNECT_SRV;
- }
-
public void webSignup()
{
GoogleTalkAccRegWizzActivator.getBrowserLauncher()
@@ -435,15 +221,4 @@ public class GoogleTalkAccountRegistrationWizard
{
return true;
}
-
- public Object getSimpleForm()
- {
- // when creating first wizard page, create and new
- // AccountRegistration to avoid reusing old instances and
- // data left from old registrations
- registration = new GoogleTalkAccountRegistration();
-
- firstWizardPage = new FirstWizardPage(this);
- return firstWizardPage.getSimpleForm();
- }
}