diff options
author | Yana Stamcheva <yana@jitsi.org> | 2009-01-21 12:51:15 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2009-01-21 12:51:15 +0000 |
commit | 333a823b1417bfe834e7090a19d95a510b1b51e0 (patch) | |
tree | 26a56dbd25ba307a037a589a34e910449fe91fd6 /src/net/java/sip/communicator/plugin/icqaccregwizz | |
parent | a832239300e3479bffad2a955b00bb555e55c44a (diff) | |
download | jitsi-333a823b1417bfe834e7090a19d95a510b1b51e0.zip jitsi-333a823b1417bfe834e7090a19d95a510b1b51e0.tar.gz jitsi-333a823b1417bfe834e7090a19d95a510b1b51e0.tar.bz2 |
- Fixes Issue #: 434 Wrong ID when try to install an already installed account.
- Removes the "Override server" option from account wizards.
- Adds a property to the ProtocolProviderFactory which indicates if the server has been modified
Diffstat (limited to 'src/net/java/sip/communicator/plugin/icqaccregwizz')
3 files changed, 86 insertions, 173 deletions
diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java index 8492540..d3571eb 100644 --- a/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java @@ -7,7 +7,6 @@ package net.java.sip.communicator.plugin.icqaccregwizz; import java.awt.*; import java.awt.event.*; -import java.util.*; import javax.swing.*; import javax.swing.event.*; @@ -37,16 +36,14 @@ public class FirstWizardPage private JPanel valuesPanel = new TransparentPanel(); - private JPanel advancedOpPanel = new TransparentPanel(new BorderLayout(10, 10)); + private JPanel advancedOpPanel + = new TransparentPanel(new BorderLayout(10, 10)); - private JPanel labelsAdvOpPanel = new TransparentPanel(new GridLayout(0, 1, 10, 10)); + private JPanel labelsAdvOpPanel + = new TransparentPanel(new GridLayout(0, 1, 10, 10)); - private JPanel valuesAdvOpPanel = new TransparentPanel(new GridLayout(0, 1, 10, 10)); - - private JCheckBox enableAdvOpButton = - new SIPCommCheckBox(Resources.getString( - "plugin.aimaccregwizz.OVERRIDE_SERVER_DEFAULT_OPTIONS"), - false); + private JPanel valuesAdvOpPanel + = new TransparentPanel(new GridLayout(0, 1, 10, 10)); private JLabel uinLabel = new JLabel(Resources.getString("plugin.icqaccregwizz.USERNAME")); @@ -58,10 +55,6 @@ public class FirstWizardPage private JLabel passLabel = new JLabel(Resources.getString("service.gui.PASSWORD")); - private JLabel existingAccountLabel = - new JLabel(Resources.getString( - "service.gui.EXISTING_ACCOUNT_ERROR")); - private JTextField uinField = new JTextField(); private JPasswordField passField = new JPasswordField(); @@ -71,7 +64,8 @@ public class FirstWizardPage private JPanel registerPanel = new TransparentPanel(new GridLayout(0, 1)); - private JPanel buttonPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); + private JPanel buttonPanel + = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); private JTextArea registerArea = new JTextArea( Resources.getString("plugin.icqaccregwizz.REGISTER_NEW_ACCOUNT_TEXT")); @@ -154,8 +148,6 @@ public class FirstWizardPage this.uinField.getDocument().addDocumentListener(this); this.rememberPassBox.setSelected(true); - this.existingAccountLabel.setForeground(Color.RED); - this.uinExampleLabel.setForeground(Color.GRAY); this.uinExampleLabel.setFont(uinExampleLabel.getFont().deriveFont(8)); this.emptyPanel.setMaximumSize(new Dimension(40, 35)); @@ -179,27 +171,6 @@ public class FirstWizardPage mainPanel.add(uinPassPanel); - proxyField.setEditable(false); - proxyPortField.setEditable(false); - proxyTypeCombo.setEnabled(false); - proxyUsernameField.setEditable(false); - proxyPassField.setEditable(false); - - enableAdvOpButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - // Perform action - JCheckBox cb = (JCheckBox) evt.getSource(); - - proxyField.setEditable(cb.isSelected()); - proxyPortField.setEditable(cb.isSelected()); - proxyTypeCombo.setEnabled(cb.isSelected()); - proxyUsernameField.setEditable(cb.isSelected()); - proxyPassField.setEditable(cb.isSelected()); - } - }); - proxyTypeCombo.setSelectedItem(wizard.getRegistration().getProxyType()); labelsAdvOpPanel.add(proxyLabel); @@ -214,7 +185,6 @@ public class FirstWizardPage valuesAdvOpPanel.add(proxyUsernameField); valuesAdvOpPanel.add(proxyPassField); - advancedOpPanel.add(enableAdvOpButton, BorderLayout.NORTH); advancedOpPanel.add(labelsAdvOpPanel, BorderLayout.WEST); advancedOpPanel.add(valuesAdvOpPanel, BorderLayout.CENTER); @@ -292,41 +262,27 @@ public class FirstWizardPage { String uin = uinField.getText(); - if (!wizard.isModification() && isExistingAccount(uin)) - { - nextPageIdentifier = FIRST_PAGE_IDENTIFIER; - uinPassPanel.add(existingAccountLabel, BorderLayout.NORTH); - this.revalidate(); - } - else - { - nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER; - uinPassPanel.remove(existingAccountLabel); + IcqAccountRegistration registration = wizard.getRegistration(); - IcqAccountRegistration registration = wizard.getRegistration(); + registration.setUin(uin); + registration.setPassword(new String(passField.getPassword())); + registration.setRememberPassword(rememberPassBox.isSelected()); - registration.setUin(uin); - registration.setPassword(new String(passField.getPassword())); - registration.setRememberPassword(rememberPassBox.isSelected()); + registration.setProxy(proxyField.getText()); + registration.setProxyPort(proxyPortField.getText()); - if (enableAdvOpButton.isSelected()) - { - registration.setAdvancedSettingsEnabled(true); - registration.setProxy(proxyField.getText()); - registration.setProxyPort(proxyPortField.getText()); + if (proxyTypeCombo.getSelectedItem() != null) + registration.setProxyType( + proxyTypeCombo.getSelectedItem().toString()); - if (proxyTypeCombo.getSelectedItem() != null) - registration.setProxyType( - proxyTypeCombo.getSelectedItem().toString()); + registration.setProxyUsername(proxyUsernameField.getText()); - registration.setProxyUsername(proxyUsernameField.getText()); + if (proxyPassField.getPassword() != null) + registration.setProxyPassword( + new String(proxyPassField.getPassword())); + + nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER; - if (proxyPassField.getPassword() != null) - registration.setProxyPassword( - new String(proxyPassField.getPassword())); - } - } - isCommitted = true; } @@ -427,13 +383,6 @@ public class FirstWizardPage accountID .getAccountPropertyString(ProtocolProviderFactory.PROXY_PASSWORD); - if (proxyAddress != null || proxyPort != null - || proxyType != null || proxyUsername != null - || proxyPassword != null) - { - enableAdvOpButton.setSelected(true); - } - proxyField.setText(proxyAddress); proxyPortField.setText(proxyPort); proxyTypeCombo.setSelectedItem(proxyType); @@ -449,30 +398,6 @@ public class FirstWizardPage wizard.webSignup(); } - /** - * Checks if an acount with the given account already exists. - * - * @param accountName the name of the account to check - * @return TRUE, if an account with the given name already exists, FALSE - - * otherwise - */ - private boolean isExistingAccount(String accountName) - { - ProtocolProviderFactory factory = - IcqAccRegWizzActivator.getIcqProtocolProviderFactory(); - - ArrayList registeredAccounts = factory.getRegisteredAccounts(); - - for (int i = 0; i < registeredAccounts.size(); i++) - { - AccountID accountID = (AccountID) registeredAccounts.get(i); - - if (accountName.equalsIgnoreCase(accountID.getUserID())) - return true; - } - return false; - } - public Object getSimpleForm() { return uinPassPanel; diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java index d1a43ca..0540a1a 100644 --- a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java @@ -160,26 +160,4 @@ public class IcqAccountRegistration public void setProxyUsername(String username) { this.proxyUsername = username; } - - /** - * Indicates if the advanced server settings are enabled. - * - * @return <code>true</code> to indicate that the advanced server settings - * are enabled, <code>false</code> - otherwise. - */ - public boolean isAdvancedSettingsEnabled() - { - return isAdvancedSettingsEnabled; - } - - /** - * Enables or disables the advanced server settings. - * - * @param isAdvancedSettingsEnabled <code>true</code> to indicate that the - * advanced server settings are enabled, <code>false</code> - otherwise - */ - public void setAdvancedSettingsEnabled(boolean isAdvancedSettingsEnabled) - { - this.isAdvancedSettingsEnabled = isAdvancedSettingsEnabled; - } } diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistrationWizard.java index 134aed0..44bd0bb 100644 --- a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistrationWizard.java @@ -10,6 +10,7 @@ import java.util.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; import org.osgi.framework.*; @@ -23,6 +24,9 @@ import org.osgi.framework.*; public class IcqAccountRegistrationWizard implements AccountRegistrationWizard { + private final Logger logger + = Logger.getLogger(IcqAccountRegistrationWizard.class); + private FirstWizardPage firstWizardPage; private IcqAccountRegistration registration = new IcqAccountRegistration(); @@ -42,7 +46,8 @@ public class IcqAccountRegistrationWizard { this.wizardContainer = wizardContainer; - this.wizardContainer.setFinishButtonText(Resources.getString("service.gui.SIGN_IN")); + this.wizardContainer + .setFinishButtonText(Resources.getString("service.gui.SIGN_IN")); } /** @@ -102,34 +107,33 @@ public class IcqAccountRegistrationWizard */ public Iterator getSummary() { - LinkedHashMap summaryTable = new LinkedHashMap(); + LinkedHashMap<String, Object> summaryTable + = new LinkedHashMap<String, Object>(); - summaryTable.put(Resources.getString("service.gui.USER_IDENTIFIER"), registration.getUin()); + summaryTable.put(Resources.getString("service.gui.USER_IDENTIFIER"), + registration.getUin()); summaryTable.put(Resources.getString("service.gui.REMEMBER_PASSWORD"), new Boolean(registration.isRememberPassword())); - if(registration.isAdvancedSettingsEnabled()) - { - if (registration.getProxy() != null) - summaryTable.put(Resources.getString("plugin.icqaccregwizz.PROXY"), - registration.getProxy()); + if (registration.getProxy() != null) + summaryTable.put(Resources.getString("plugin.icqaccregwizz.PROXY"), + registration.getProxy()); - if (registration.getProxyPort() != null) - summaryTable.put(Resources.getString("proxyPort"), - registration.getProxyPort()); + if (registration.getProxyPort() != null) + summaryTable.put(Resources.getString("proxyPort"), + registration.getProxyPort()); - if (registration.getProxyType() != null) - summaryTable.put(Resources.getString("proxyType"), - registration.getProxyType()); + if (registration.getProxyType() != null) + summaryTable.put(Resources.getString("proxyType"), + registration.getProxyType()); - if (registration.getProxyPort() != null) - summaryTable.put(Resources.getString("proxyUsername"), - registration.getProxyUsername()); + if (registration.getProxyPort() != null) + summaryTable.put(Resources.getString("proxyUsername"), + registration.getProxyUsername()); - if (registration.getProxyType() != null) - summaryTable.put(Resources.getString("proxyPassword"), - registration.getProxyPassword()); - } + if (registration.getProxyType() != null) + summaryTable.put(Resources.getString("proxyPassword"), + registration.getProxyPassword()); return summaryTable.entrySet().iterator(); } @@ -141,17 +145,17 @@ public class IcqAccountRegistrationWizard * account. */ public ProtocolProviderService signin() + throws OperationFailedException { - if (!firstWizardPage.isCommitted()) - firstWizardPage.commitPage(); + firstWizardPage.commitPage(); return this.signin(registration.getUin(), registration .getPassword()); } public ProtocolProviderService signin(String userName, String password) + throws OperationFailedException { - firstWizardPage = null; ProtocolProviderFactory factory = IcqAccRegWizzActivator.getIcqProtocolProviderFactory(); @@ -171,36 +175,40 @@ public class IcqAccountRegistrationWizard ProtocolProviderFactory providerFactory, String user, String passwd) + throws OperationFailedException { - Hashtable accountProperties = new Hashtable(); + Hashtable<String, String> accountProperties + = new Hashtable<String, String>(); if (registration.isRememberPassword()) { accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd); } - if (registration.isAdvancedSettingsEnabled()) - { - if (registration.getProxy() != null) - accountProperties.put(ProtocolProviderFactory.PROXY_ADDRESS, - registration.getProxy()); + if (registration.getProxy() != null + && registration.getProxy() != "") + accountProperties.put(ProtocolProviderFactory.PROXY_ADDRESS, + registration.getProxy()); - if (registration.getProxyPort() != null) - accountProperties.put(ProtocolProviderFactory.PROXY_PORT, - registration.getProxyPort()); + if (registration.getProxyPort() != null + && registration.getProxyPort() != "") + accountProperties.put(ProtocolProviderFactory.PROXY_PORT, + registration.getProxyPort()); - if (registration.getProxyType() != null) - accountProperties.put(ProtocolProviderFactory.PROXY_TYPE, - registration.getProxyType()); + if (registration.getProxyType() != null + && registration.getProxyType() != "") + accountProperties.put(ProtocolProviderFactory.PROXY_TYPE, + registration.getProxyType()); - if (registration.getProxyUsername() != null) - accountProperties.put(ProtocolProviderFactory.PROXY_USERNAME, - registration.getProxyUsername()); + if (registration.getProxyUsername() != null + && registration.getProxyUsername() != "") + accountProperties.put(ProtocolProviderFactory.PROXY_USERNAME, + registration.getProxyUsername()); - if (registration.getProxyPassword() != null) - accountProperties.put(ProtocolProviderFactory.PROXY_PASSWORD, - registration.getProxyPassword()); - } + if (registration.getProxyPassword() != null + && registration.getProxyPassword() != "") + accountProperties.put(ProtocolProviderFactory.PROXY_PASSWORD, + registration.getProxyPassword()); if (isModification) { @@ -224,19 +232,21 @@ public class IcqAccountRegistrationWizard (ProtocolProviderService) IcqAccRegWizzActivator.bundleContext .getService(serRef); } - catch (IllegalArgumentException e) + catch (IllegalStateException exc) { - IcqAccRegWizzActivator.getUIService().getPopupDialog() - .showMessagePopupDialog(e.getMessage(), - Resources.getString("service.gui.ERROR"), - PopupDialog.ERROR_MESSAGE); + logger.warn(exc.getMessage()); + + throw new OperationFailedException( + "Account already exists.", + OperationFailedException.IDENTIFICATION_CONFLICT); } - catch (IllegalStateException e) + catch (Exception exc) { - IcqAccRegWizzActivator.getUIService().getPopupDialog() - .showMessagePopupDialog(e.getMessage(), - Resources.getString("service.gui.ERROR"), - PopupDialog.ERROR_MESSAGE); + logger.warn(exc.getMessage()); + + throw new OperationFailedException( + "Failed to add account", + OperationFailedException.GENERAL_ERROR); } return protocolProvider; |