aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2010-08-27 14:32:54 +0000
committerYana Stamcheva <yana@jitsi.org>2010-08-27 14:32:54 +0000
commit1ccc8a5f2875f1e49d7d7d3945f11b92cffe8df6 (patch)
tree27f0d45cb5df2f09c990d9f01c5f3d98d682395d /src/net/java/sip/communicator
parentb741c059fbf244619d229e068f91d4c2e4ef691f (diff)
downloadjitsi-1ccc8a5f2875f1e49d7d7d3945f11b92cffe8df6.zip
jitsi-1ccc8a5f2875f1e49d7d7d3945f11b92cffe8df6.tar.gz
jitsi-1ccc8a5f2875f1e49d7d7d3945f11b92cffe8df6.tar.bz2
New configurations prepared for the arrive of ice and stun support.
Diffstat (limited to 'src/net/java/sip/communicator')
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java242
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/ConnectionPanel.java269
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/FirstWizardPage.java445
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/IceConfigPanel.java526
-rwxr-xr-xsrc/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java138
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java70
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/StunServer.java173
-rw-r--r--src/net/java/sip/communicator/service/gui/AccountRegistrationWizard.java8
-rw-r--r--src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java36
-rw-r--r--src/net/java/sip/communicator/util/swing/SIPCommDialog.java1
10 files changed, 1584 insertions, 324 deletions
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java
new file mode 100644
index 0000000..f62e2d1
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java
@@ -0,0 +1,242 @@
+package net.java.sip.communicator.plugin.jabberaccregwizz;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import javax.swing.event.*;
+
+import net.java.sip.communicator.util.*;
+import net.java.sip.communicator.util.swing.*;
+
+/**
+ *
+ * @author Yana Stamcheva
+ */
+public class AccountPanel
+ extends TransparentPanel
+ implements DocumentListener
+{
+ private static final Logger logger = Logger.getLogger(AccountPanel.class);
+
+ public static final String USER_NAME_EXAMPLE = "Ex: johnsmith@jabber.org";
+
+ private final JPanel userIDPassPanel
+ = new TransparentPanel(new BorderLayout(10, 10));
+
+ private final JPanel labelsPanel = new TransparentPanel();
+
+ private final JPanel valuesPanel = new TransparentPanel();
+
+ private final JLabel userIDLabel
+ = new JLabel(Resources.getString("plugin.jabberaccregwizz.USERNAME"));
+
+ private final JLabel passLabel
+ = new JLabel(Resources.getString("service.gui.PASSWORD"));
+
+ private final JPanel emptyPanel = new TransparentPanel();
+
+ private final JLabel userIDExampleLabel = new JLabel(USER_NAME_EXAMPLE);
+
+ private final JTextField userIDField = new JTextField();
+
+ private final JPasswordField passField = new JPasswordField();
+
+ private final JCheckBox rememberPassBox = new SIPCommCheckBox(Resources
+ .getString("service.gui.REMEMBER_PASSWORD"));
+
+ private final JPanel registerPanel
+ = new TransparentPanel(new GridLayout(0, 1));
+
+ private final JPanel buttonPanel
+ = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
+
+ private final JTextArea registerArea = new JTextArea(Resources
+ .getString("plugin.jabberaccregwizz.REGISTER_NEW_ACCOUNT_TEXT"));
+
+ private final JButton registerButton = new JButton(Resources
+ .getString("plugin.jabberaccregwizz.NEW_ACCOUNT_TITLE"));
+
+ private JabberNewAccountDialog jabberNewAccountDialog;
+
+ private final FirstWizardPage parentPage;
+
+ /**
+ * Creates an instance of <tt>AccountPanel</tt> by specifying the parent
+ * wizard page, where it's contained.
+ * @param parentPage the parent page where this panel is contained
+ */
+ public AccountPanel(final FirstWizardPage parentPage)
+ {
+ super(new BorderLayout());
+
+ this.parentPage = parentPage;
+
+ labelsPanel.setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
+
+ valuesPanel.setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
+
+ userIDField.getDocument().addDocumentListener(this);
+ rememberPassBox.setSelected(true);
+
+ userIDExampleLabel.setForeground(Color.GRAY);
+ userIDExampleLabel.setFont(userIDExampleLabel.getFont().deriveFont(8));
+ emptyPanel.setMaximumSize(new Dimension(40, 35));
+ userIDExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
+
+ labelsPanel.add(userIDLabel);
+ labelsPanel.add(emptyPanel);
+ labelsPanel.add(passLabel);
+
+ valuesPanel.add(userIDField);
+ valuesPanel.add(userIDExampleLabel);
+ valuesPanel.add(passField);
+
+ userIDPassPanel.add(labelsPanel, BorderLayout.WEST);
+ userIDPassPanel.add(valuesPanel, BorderLayout.CENTER);
+ userIDPassPanel.add(rememberPassBox, BorderLayout.SOUTH);
+
+ registerButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent evt)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Reg OK");
+
+ // Open the new account dialog.
+ jabberNewAccountDialog = new JabberNewAccountDialog();
+
+ if (jabberNewAccountDialog.isOK == true)
+ {
+ ConnectionPanel connectionPanel
+ = parentPage.getConnectionPanel();
+
+ if (connectionPanel != null)
+ {
+ connectionPanel
+ .setServerAddress(jabberNewAccountDialog.server);
+ connectionPanel
+ .setServerPort(jabberNewAccountDialog.port);
+ }
+
+ // This userIDField contains the username "@" the server.
+ userIDField.setText(jabberNewAccountDialog.userID + "@"
+ + jabberNewAccountDialog.server);
+
+ passField.setText(jabberNewAccountDialog.password);
+ }
+ if (logger.isDebugEnabled())
+ logger.debug("Reg End");
+ }
+ });
+
+ buttonPanel.add(registerButton);
+
+ registerArea.setEditable(false);
+ registerArea.setOpaque(false);
+ registerArea.setLineWrap(true);
+ registerArea.setWrapStyleWord(true);
+
+ registerPanel.add(registerArea);
+ registerPanel.add(buttonPanel);
+
+ registerPanel.setBorder(BorderFactory.createTitledBorder(Resources
+ .getString("plugin.jabberaccregwizz.NEW_ACCOUNT_TITLE")));
+
+ JPanel mainPanel = new TransparentPanel();
+ mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
+ mainPanel.add(userIDPassPanel);
+ mainPanel.add(Box.createVerticalStrut(10));
+ mainPanel.add(registerPanel);
+
+ add(mainPanel, BorderLayout.NORTH);
+ }
+
+
+ /**
+ * Handles the <tt>DocumentEvent</tt> triggered when user types in the
+ * UserID field. Enables or disables the "Next" wizard button according to
+ * whether the UserID field is empty.
+ *
+ * @param evt the document event that has triggered this method call.
+ */
+ public void insertUpdate(DocumentEvent evt)
+ {
+ parentPage.setNextButtonAccordingToUserIDAndResource();
+
+ parentPage.setServerFieldAccordingToUsername(userIDField.getText());
+ }
+
+ /**
+ * Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
+ * from the User ID field. Enables or disables the "Next" wizard button
+ * according to whether the User ID field is empty.
+ *
+ * @param evt the document event that has triggered this method call.
+ */
+ public void removeUpdate(DocumentEvent evt)
+ {
+ parentPage.setNextButtonAccordingToUserIDAndResource();
+
+ parentPage.setServerFieldAccordingToUsername(userIDField.getText());
+ }
+
+ public void changedUpdate(DocumentEvent evt) {}
+
+ /**
+ * Returns the username entered in this panel.
+ * @return the username entered in this panel
+ */
+ String getUsername()
+ {
+ return userIDField.getText();
+ }
+
+ /**
+ * Sets the username to display in the username field.
+ * @param username the username to set
+ */
+ void setUsername(String username)
+ {
+ userIDField.setText(username);
+ }
+
+ /**
+ * Returns the password entered in this panel.
+ * @return the password entered in this panel
+ */
+ char[] getPassword()
+ {
+ return passField.getPassword();
+ }
+
+ /**
+ * Sets the password to display in the password field of this panel.
+ * @param password the password to set
+ */
+ void setPassword(String password)
+ {
+ passField.setText(password);
+ }
+
+ /**
+ * Indicates if the remember password box is selected.
+ * @return <tt>true</tt> if the remember password check box is selected,
+ * otherwise returns <tt>false</tt>
+ */
+ boolean isRememberPassword()
+ {
+ return rememberPassBox.isSelected();
+ }
+
+ /**
+ * Selects/deselects the remember password check box depending on the given
+ * <tt>isRemember</tt> parameter.
+ * @param isRemember indicates if the remember password checkbox should be
+ * selected or not
+ */
+ void setRememberPassword(boolean isRemember)
+ {
+ rememberPassBox.setSelected(isRemember);
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/ConnectionPanel.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/ConnectionPanel.java
new file mode 100644
index 0000000..08de91e
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/ConnectionPanel.java
@@ -0,0 +1,269 @@
+/*
+ * 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.plugin.jabberaccregwizz;
+
+import java.awt.*;
+
+import javax.swing.*;
+import javax.swing.event.*;
+
+import net.java.sip.communicator.util.swing.*;
+
+/**
+ *
+ * @author Yana Stamcheva
+ */
+public class ConnectionPanel
+ extends TransparentPanel
+{
+ private final TransparentPanel mainPanel = new TransparentPanel();
+
+ private final JPanel advancedOpPanel
+ = new TransparentPanel(new BorderLayout(10, 10));
+
+ private final JPanel labelsAdvOpPanel
+ = new TransparentPanel(new GridLayout(0, 1, 10, 10));
+
+ private final JPanel valuesAdvOpPanel
+ = new TransparentPanel(new GridLayout(0, 1, 10, 10));
+
+ private final JCheckBox sendKeepAliveBox = new SIPCommCheckBox(
+ Resources.getString("plugin.jabberaccregwizz.ENABLE_KEEP_ALIVE"));
+
+ private final JCheckBox gmailNotificationsBox = new SIPCommCheckBox(
+ Resources.getString(
+ "plugin.jabberaccregwizz.ENABLE_GMAIL_NOTIFICATIONS"));
+
+ private final JLabel resourceLabel
+ = new JLabel(Resources.getString("plugin.jabberaccregwizz.RESOURCE"));
+
+ private final JTextField resourceField
+ = new JTextField(JabberAccountRegistration.DEFAULT_RESOURCE);
+
+ private final JLabel priorityLabel = new JLabel(
+ Resources.getString("plugin.jabberaccregwizz.PRIORITY"));
+
+ private final JTextField priorityField
+ = new JTextField(JabberAccountRegistration.DEFAULT_PRIORITY);
+
+ private final JLabel serverLabel
+ = new JLabel(Resources.getString("plugin.jabberaccregwizz.SERVER"));
+
+ private final JTextField serverField = new JTextField();
+
+ private final JLabel portLabel
+ = new JLabel(Resources.getString("plugin.jabberaccregwizz.PORT"));
+
+ private final JTextField portField
+ = new JTextField(JabberAccountRegistration.DEFAULT_PORT);
+
+ private final JabberAccountRegistrationWizard wizard;
+
+ /**
+ * Creates an instance of <tt>ConnectionPanel</tt> by specifying the parent
+ * wizard, where it's contained.
+ * @param wizard the parent wizard
+ */
+ public ConnectionPanel(JabberAccountRegistrationWizard wizard)
+ {
+ super(new BorderLayout());
+
+ this.wizard = wizard;
+
+ mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
+
+ portField.getDocument().addDocumentListener(new DocumentListener()
+ {
+ public void changedUpdate(DocumentEvent evt)
+ {
+ }
+
+ public void insertUpdate(DocumentEvent evt)
+ {
+ setNextButtonAccordingToPortAndPriority();
+ }
+
+ public void removeUpdate(DocumentEvent evt)
+ {
+ setNextButtonAccordingToPortAndPriority();
+ }
+ });
+
+ priorityField.getDocument().addDocumentListener(new DocumentListener()
+ {
+ public void changedUpdate(DocumentEvent evt)
+ {
+ }
+
+ public void insertUpdate(DocumentEvent evt)
+ {
+ setNextButtonAccordingToPortAndPriority();
+ }
+
+ public void removeUpdate(DocumentEvent evt)
+ {
+ setNextButtonAccordingToPortAndPriority();
+ }
+ });
+
+ labelsAdvOpPanel.add(serverLabel);
+ labelsAdvOpPanel.add(portLabel);
+ labelsAdvOpPanel.add(resourceLabel);
+ labelsAdvOpPanel.add(priorityLabel);
+
+ valuesAdvOpPanel.add(serverField);
+ valuesAdvOpPanel.add(portField);
+ valuesAdvOpPanel.add(resourceField);
+ valuesAdvOpPanel.add(priorityField);
+
+ JPanel checkBoxesPanel
+ = new TransparentPanel(new GridLayout(0, 1, 10, 10));
+ checkBoxesPanel.add(sendKeepAliveBox);
+ checkBoxesPanel.add(gmailNotificationsBox);
+
+ advancedOpPanel.add(checkBoxesPanel, BorderLayout.NORTH);
+ advancedOpPanel.add(labelsAdvOpPanel, BorderLayout.WEST);
+ advancedOpPanel.add(valuesAdvOpPanel, BorderLayout.CENTER);
+
+ mainPanel.add(advancedOpPanel);
+
+ add(mainPanel, BorderLayout.NORTH);
+ }
+
+ /**
+ * Returns the server address.
+ * @return the server address
+ */
+ String getServerAddress()
+ {
+ return serverField.getText();
+ }
+
+ /**
+ * Sets the server address.
+ * @param serverAddress the server address
+ */
+ void setServerAddress(String serverAddress)
+ {
+ serverField.setText(serverAddress);
+ }
+
+ /**
+ * Returns the server port.
+ * @return the server port
+ */
+ String getServerPort()
+ {
+ return portField.getText();
+ }
+
+ /**
+ * Sets the server port.
+ * @param serverPort the server port
+ */
+ void setServerPort(String serverPort)
+ {
+ portField.setText(serverPort);
+ }
+
+ /**
+ * Returns the resource.
+ * @return the resource
+ */
+ String getResource()
+ {
+ return resourceField.getText();
+ }
+
+ /**
+ * Sets the resource field value.
+ * @param resource the resource to set
+ */
+ void setResource(String resource)
+ {
+ resourceField.setText(resource);
+ }
+
+ /**
+ * Returns the priority field value.
+ * @return the priority field value
+ */
+ String getPriority()
+ {
+ return priorityField.getText();
+ }
+
+ /**
+ * Sets the priority field value.
+ * @param priority the priority field value
+ */
+ void setPriority(String priority)
+ {
+ priorityField.setText(priority);
+ }
+
+ /**
+ * Returns <tt>true</tt> if the "send keep alive" check box is selected,
+ * otherwise returns <tt>false</tt>.
+ * @return <tt>true</tt> if the "send keep alive" check box is selected,
+ * otherwise returns <tt>false</tt>
+ */
+ boolean isSendKeepAlive()
+ {
+ return sendKeepAliveBox.isSelected();
+ }
+
+ /**
+ * Selects/unselects the "send keep alive" check box according to the given
+ * <tt>isSendKeepAlive</tt> property.
+ * @param isSendKeepAlive indicates if the "send keep alive" check box
+ * should be selected or not
+ */
+ void setSendKeepAlive(boolean isSendKeepAlive)
+ {
+ sendKeepAliveBox.setSelected(isSendKeepAlive);
+ }
+
+ /**
+ * Returns <tt>true</tt> if the "gmail notifications" check box is selected,
+ * otherwise returns <tt>false</tt>.
+ * @return <tt>true</tt> if the "gmail notifications" check box is selected,
+ * otherwise returns <tt>false</tt>
+ */
+ boolean isGmailNotificationsEnabled()
+ {
+ return gmailNotificationsBox.isSelected();
+ }
+
+ /**
+ * Selects/unselects the "gmail notifications" check box according to the
+ * given <tt>isEnabled</tt> property.
+ * @param isEnabled indicates if the "gmail notifications"
+ * check box should be selected or not
+ */
+ void setGmailNotificationsEnabled(boolean isEnabled)
+ {
+ gmailNotificationsBox.setSelected(isEnabled);
+ }
+
+ /**
+ * Disables Next Button if Port field value is incorrect
+ */
+ private void setNextButtonAccordingToPortAndPriority()
+ {
+ try
+ {
+ Integer.parseInt(getServerPort());
+ Integer.parseInt(getPriority());
+ wizard.getWizardContainer().setNextFinishButtonEnabled(true);
+ }
+ catch (NumberFormatException ex)
+ {
+ wizard.getWizardContainer().setNextFinishButtonEnabled(false);
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/FirstWizardPage.java
index 57d9a84..4096005 100644
--- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/FirstWizardPage.java
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/FirstWizardPage.java
@@ -6,16 +6,13 @@
*/
package net.java.sip.communicator.plugin.jabberaccregwizz;
+import java.awt.*;
import java.util.*;
-import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.event.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
/**
@@ -27,92 +24,15 @@ import net.java.sip.communicator.util.swing.*;
*/
public class FirstWizardPage
extends TransparentPanel
- implements WizardPage,
- DocumentListener
+ implements WizardPage
{
- private static final Logger logger = Logger
- .getLogger(FirstWizardPage.class);
-
public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
- public static final String USER_NAME_EXAMPLE = "Ex: johnsmith@jabber.org";
-
- private JabberNewAccountDialog jabberNewAccountDialog;
-
- private JPanel userIDPassPanel
- = new TransparentPanel(new BorderLayout(10, 10));
-
- private JPanel labelsPanel = new TransparentPanel();
-
- private JPanel valuesPanel = new TransparentPanel();
-
- private JLabel userIDLabel
- = new JLabel(Resources.getString("plugin.jabberaccregwizz.USERNAME"));
-
- private JLabel passLabel
- = new JLabel(Resources.getString("service.gui.PASSWORD"));
-
- private JPanel emptyPanel = new TransparentPanel();
-
- private JLabel userIDExampleLabel = new JLabel(USER_NAME_EXAMPLE);
-
- private JTextField userIDField = new JTextField();
-
- private JPasswordField passField = new JPasswordField();
-
- private JCheckBox rememberPassBox = new SIPCommCheckBox(Resources
- .getString("service.gui.REMEMBER_PASSWORD"));
-
- private JPanel advancedOpPanel
- = new TransparentPanel(new BorderLayout(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 final AccountPanel accountPanel;
- private JCheckBox sendKeepAliveBox = new SIPCommCheckBox(Resources
- .getString("plugin.jabberaccregwizz.ENABLE_KEEP_ALIVE"));
+ private final ConnectionPanel connectionPanel;
- private JCheckBox gmailNotificationsBox = new SIPCommCheckBox(Resources
- .getString("plugin.jabberaccregwizz.ENABLE_GMAIL_NOTIFICATIONS"));
-
- private JLabel resourceLabel
- = new JLabel(Resources.getString("plugin.jabberaccregwizz.RESOURCE"));
-
- private JTextField resourceField
- = new JTextField(JabberAccountRegistration.DEFAULT_RESOURCE);
-
- private JLabel priorityLabel = new JLabel(
- Resources.getString("plugin.jabberaccregwizz.PRIORITY"));
-
- private JTextField priorityField
- = new JTextField(JabberAccountRegistration.DEFAULT_PRIORITY);
-
- private JLabel serverLabel
- = new JLabel(Resources.getString("plugin.jabberaccregwizz.SERVER"));
-
- private JTextField serverField = new JTextField();
-
- private JLabel portLabel
- = new JLabel(Resources.getString("plugin.jabberaccregwizz.PORT"));
-
- private JTextField portField
- = new JTextField(JabberAccountRegistration.DEFAULT_PORT);
-
- private JPanel registerPanel = new TransparentPanel(new GridLayout(0, 1));
-
- private JPanel buttonPanel
- = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
-
- private JTextArea registerArea = new JTextArea(Resources
- .getString("plugin.jabberaccregwizz.REGISTER_NEW_ACCOUNT_TEXT"));
-
- private JButton registerButton = new JButton(Resources
- .getString("plugin.jabberaccregwizz.NEW_ACCOUNT_TITLE"));
-
- private JPanel mainPanel = new TransparentPanel();
+ private final IceConfigPanel iceConfigPanel;
private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
@@ -133,17 +53,11 @@ public class FirstWizardPage
this.wizard = wizard;
- mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
+ accountPanel = new AccountPanel(this);
+ connectionPanel = new ConnectionPanel(wizard);
+ iceConfigPanel = new IceConfigPanel();
this.init();
-
- this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- this.labelsPanel
- .setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
-
- this.valuesPanel
- .setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
}
/**
@@ -151,139 +65,19 @@ public class FirstWizardPage
*/
private void init()
{
- this.mainPanel.setOpaque(false);
- this.labelsPanel.setOpaque(false);
- this.valuesPanel.setOpaque(false);
- this.emptyPanel.setOpaque(false);
+ JTabbedPane tabbedPane = new JTabbedPane();
- this.userIDField.getDocument().addDocumentListener(this);
- this.rememberPassBox.setSelected(true);
-
- this.userIDExampleLabel.setForeground(Color.GRAY);
- this.userIDExampleLabel.setFont(userIDExampleLabel.getFont()
- .deriveFont(8));
- this.emptyPanel.setMaximumSize(new Dimension(40, 35));
- this.userIDExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0,
- 8, 0));
-
- labelsPanel.add(userIDLabel);
- labelsPanel.add(emptyPanel);
- labelsPanel.add(passLabel);
-
- valuesPanel.add(userIDField);
- valuesPanel.add(userIDExampleLabel);
- valuesPanel.add(passField);
-
- userIDPassPanel.add(labelsPanel, BorderLayout.WEST);
- userIDPassPanel.add(valuesPanel, BorderLayout.CENTER);
- userIDPassPanel.add(rememberPassBox, BorderLayout.SOUTH);
-
- userIDPassPanel.setBorder(BorderFactory.createTitledBorder(Resources
- .getString("plugin.jabberaccregwizz.USERNAME_AND_PASSWORD")));
-
- mainPanel.add(userIDPassPanel);
-
- portField.getDocument().addDocumentListener(new DocumentListener()
- {
- public void changedUpdate(DocumentEvent evt)
- {
- }
-
- public void insertUpdate(DocumentEvent evt)
- {
- setNextButtonAccordingToPortAndPriority();
- }
-
- public void removeUpdate(DocumentEvent evt)
- {
- setNextButtonAccordingToPortAndPriority();
- }
- });
-
- priorityField.getDocument().addDocumentListener(new DocumentListener()
- {
- public void changedUpdate(DocumentEvent evt)
- {
- }
-
- public void insertUpdate(DocumentEvent evt)
- {
- setNextButtonAccordingToPortAndPriority();
- }
-
- public void removeUpdate(DocumentEvent evt)
- {
- setNextButtonAccordingToPortAndPriority();
- }
- });
-
- labelsAdvOpPanel.add(serverLabel);
- labelsAdvOpPanel.add(portLabel);
- labelsAdvOpPanel.add(resourceLabel);
- labelsAdvOpPanel.add(priorityLabel);
-
- valuesAdvOpPanel.add(serverField);
- valuesAdvOpPanel.add(portField);
- valuesAdvOpPanel.add(resourceField);
- valuesAdvOpPanel.add(priorityField);
-
- JPanel checkBoxesPanel
- = new TransparentPanel(new GridLayout(0, 1, 10, 10));
- checkBoxesPanel.add(sendKeepAliveBox);
- checkBoxesPanel.add(gmailNotificationsBox);
-
- advancedOpPanel.add(checkBoxesPanel, BorderLayout.NORTH);
- advancedOpPanel.add(labelsAdvOpPanel, BorderLayout.WEST);
- advancedOpPanel.add(valuesAdvOpPanel, BorderLayout.CENTER);
-
- advancedOpPanel.setBorder(BorderFactory.createTitledBorder(Resources
- .getString("plugin.jabberaccregwizz.ADVANCED_OPTIONS")));
-
- mainPanel.add(advancedOpPanel);
-
- registerButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("Reg OK");
-
- // Open the new account dialog.
-
- jabberNewAccountDialog = new JabberNewAccountDialog();
-
- if (jabberNewAccountDialog.isOK == true)
- {
- serverField.setText(jabberNewAccountDialog.server);
- portField.setText(jabberNewAccountDialog.port);
-
- // This userIDField contains the username "@" the server.
- userIDField.setText(jabberNewAccountDialog.userID + "@"
- + jabberNewAccountDialog.server);
-
- passField.setText(jabberNewAccountDialog.password);
- }
- if (logger.isDebugEnabled())
- logger.debug("Reg End");
- }
- });
-
- buttonPanel.add(registerButton);
-
- registerArea.setEditable(false);
- registerArea.setOpaque(false);
- registerArea.setLineWrap(true);
- registerArea.setWrapStyleWord(true);
-
- registerPanel.add(registerArea);
- registerPanel.add(buttonPanel);
-
- registerPanel.setBorder(BorderFactory.createTitledBorder(Resources
- .getString("plugin.jabberaccregwizz.NEW_ACCOUNT_TITLE")));
+ this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- mainPanel.add(registerPanel);
+ tabbedPane.addTab( Resources.getString("service.gui.ACCOUNT"),
+ accountPanel);
+ tabbedPane.addTab( Resources.getString("service.gui.CONNECTION"),
+ connectionPanel);
+// tabbedPane.addTab( Resources.getString("service.gui.ADVANCED"),
+// iceConfigPanel);
- this.add(mainPanel, BorderLayout.NORTH);
+ add(tabbedPane, BorderLayout.NORTH);
+ tabbedPane.setSelectedIndex(0);
}
/**
@@ -347,27 +141,39 @@ public class FirstWizardPage
{
JabberAccountRegistration registration = wizard.getRegistration();
- String userID = userIDField.getText();
+ String userID = accountPanel.getUsername();
if(userID == null || userID.trim().length() == 0)
throw new IllegalStateException("No user ID provided.");
registration.setUserID(userID);
- registration.setPassword(new String(passField.getPassword()));
- registration.setRememberPassword(rememberPassBox.isSelected());
+ registration.setPassword(new String(accountPanel.getPassword()));
+ registration.setRememberPassword(accountPanel.isRememberPassword());
- registration.setServerAddress(serverField.getText());
- registration.setSendKeepAlive(sendKeepAliveBox.isSelected());
+ registration.setServerAddress(connectionPanel.getServerAddress());
+ registration.setSendKeepAlive(connectionPanel.isSendKeepAlive());
registration.setGmailNotificationEnabled(
- this.gmailNotificationsBox.isSelected());
- registration.setResource(resourceField.getText());
+ connectionPanel.isGmailNotificationsEnabled());
+ registration.setResource(connectionPanel.getResource());
+
+ String serverPort = connectionPanel.getServerPort();
+ if (serverPort != null)
+ registration.setPort(Integer.parseInt(serverPort));
- if (portField.getText() != null)
- registration.setPort(Integer.parseInt(portField.getText()));
+ String priority = connectionPanel.getPriority();
+ if (priority != null)
+ registration.setPriority(Integer.parseInt(priority));
- if (priorityField.getText() != null)
- registration.setPriority(
- Integer.parseInt(priorityField.getText()));
+ registration.setUseIce(iceConfigPanel.isUseIce());
+ registration.setAutoDiscoverStun(iceConfigPanel.isAutoDiscoverStun());
+
+ Iterator<StunServer> stunServers
+ = iceConfigPanel.getAdditionalStunServers().iterator();
+
+ while (stunServers.hasNext())
+ {
+ registration.addStunServer(stunServers.next());
+ }
nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
@@ -378,14 +184,14 @@ public class FirstWizardPage
* Enables or disables the "Next" wizard button according to whether the
* UserID field is empty.
*/
- private void setNextButtonAccordingToUserIDAndResource()
+ void setNextButtonAccordingToUserIDAndResource()
{
boolean nextFinishButtonEnabled = false;
- String userID = userIDField.getText();
+ String userID = accountPanel.getUsername();
if ((userID != null) && !userID.equals(""))
{
- String resource = resourceField.getText();
+ String resource = connectionPanel.getResource();
if ((resource != null) && !resource.equals(""))
{
nextFinishButtonEnabled = true;
@@ -397,49 +203,11 @@ public class FirstWizardPage
.setNextFinishButtonEnabled(nextFinishButtonEnabled);
}
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user types in the
- * UserID field. Enables or disables the "Next" wizard button according to
- * whether the UserID field is empty.
- *
- * @param evt the document event that has triggered this method call.
- */
- public void insertUpdate(DocumentEvent evt)
- {
- this.setNextButtonAccordingToUserIDAndResource();
+ public void pageHiding() {}
- this.setServerFieldAccordingToUserID();
- }
+ public void pageShown() {}
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
- * from the User ID field. Enables or disables the "Next" wizard button
- * according to whether the User ID field is empty.
- *
- * @param evt the document event that has triggered this method call.
- */
- public void removeUpdate(DocumentEvent evt)
- {
- this.setNextButtonAccordingToUserIDAndResource();
-
- this.setServerFieldAccordingToUserID();
- }
-
- public void changedUpdate(DocumentEvent evt)
- {
- }
-
- public void pageHiding()
- {
- }
-
- public void pageShown()
- {
- }
-
- public void pageBack()
- {
- }
+ public void pageBack() {}
/**
* Fills the User ID and Password fields in this panel with the data coming
@@ -457,45 +225,91 @@ public class FirstWizardPage
String password
= accountProperties.get(ProtocolProviderFactory.PASSWORD);
- this.userIDField.setEnabled(false);
- this.userIDField.setText(accountID.getUserID());
+ accountPanel.setRememberPassword(false);
+ accountPanel.setUsername(accountID.getUserID());
if (password != null)
{
- this.passField.setText(password);
- this.rememberPassBox.setSelected(true);
+ accountPanel.setPassword(password);
+ accountPanel.setRememberPassword(true);
}
String serverAddress
= accountProperties.get(ProtocolProviderFactory.SERVER_ADDRESS);
- serverField.setText(serverAddress);
+ connectionPanel.setServerAddress(serverAddress);
String serverPort
= accountProperties.get(ProtocolProviderFactory.SERVER_PORT);
- portField.setText(serverPort);
+ connectionPanel.setServerPort(serverPort);
boolean keepAlive
= Boolean.parseBoolean(accountProperties.get("SEND_KEEP_ALIVE"));
- sendKeepAliveBox.setSelected(keepAlive);
+ connectionPanel.setSendKeepAlive(keepAlive);
boolean gmailNotificationEnabled
= Boolean.parseBoolean(
accountProperties.get("GMAIL_NOTIFICATIONS_ENABLED"));
- gmailNotificationsBox.setSelected(gmailNotificationEnabled);
+ connectionPanel.setGmailNotificationsEnabled(gmailNotificationEnabled);
String resource
= accountProperties.get(ProtocolProviderFactory.RESOURCE);
- resourceField.setText(resource);
+ connectionPanel.setResource(resource);
String priority
= accountProperties.get(ProtocolProviderFactory.RESOURCE_PRIORITY);
- priorityField.setText(priority);
+ connectionPanel.setPriority(priority);
+
+// Disable STUN and ICE configs until it's implemented.
+//
+// boolean isUseIce
+// = Boolean.parseBoolean(
+// accountProperties.get(ProtocolProviderFactory.IS_USE_ICE));
+//
+// iceConfigPanel.setUseIce(isUseIce);
+//
+// boolean isAutoDiscoverStun
+// = Boolean.parseBoolean(
+// accountProperties.get(
+// ProtocolProviderFactory.AUTO_DISCOVER_STUN));
+//
+// iceConfigPanel.setAutoDiscoverStun(isAutoDiscoverStun);
+
+ for (int i = 0; i < 100; i ++)
+ {
+ String stunAddress = accountProperties
+ .get(ProtocolProviderFactory.STUN_ADDRESS + i);
+
+ // If we don't find a stun address with the given index, it means
+ // that there're no more in the properties table, so we're nothing
+ // more to do here.
+ if (stunAddress == null)
+ break;
+
+ String stunPort = accountProperties
+ .get(ProtocolProviderFactory.STUN_PORT + i);
+ String stunUsername = accountProperties
+ .get(ProtocolProviderFactory.STUN_USERNAME + i);
+ String stunPassword = accountProperties
+ .get(ProtocolProviderFactory.STUN_PASSWORD + i);
+ boolean stunIsTurnSupported
+ = Boolean.parseBoolean(accountProperties
+ .get(ProtocolProviderFactory.STUN_IS_TURN_SUPPORTED + i));
+
+ StunServer stunServer = new StunServer( stunAddress,
+ stunPort,
+ stunIsTurnSupported,
+ stunUsername,
+ stunPassword.toCharArray(),
+ i);
+
+ iceConfigPanel.addStunServer(stunServer);
+ }
this.isServerOverridden
= accountID.getAccountPropertyBoolean(
@@ -504,43 +318,44 @@ public class FirstWizardPage
}
/**
- * Parse the server part from the jabber id and set it to server as default
- * value. If Advanced option is enabled Do nothing.
+ * Returns the simple form.
+ * @return the simple form
*/
- private void setServerFieldAccordingToUserID()
+ public Object getSimpleForm()
{
- if (!wizard.isModification() || !isServerOverridden)
- {
- String userId = userIDField.getText();
-
- serverField.setText(wizard.getServerFromUserName(userId));
- }
+ return accountPanel;
}
/**
- * Disables Next Button if Port field value is incorrect
+ * Indicates if this page has been already committed.
+ * @return <tt>true</tt> if this page has been already committed,
+ * <tt>false</tt> - otherwise
*/
- private void setNextButtonAccordingToPortAndPriority()
+ public boolean isCommitted()
{
- try
- {
- Integer.parseInt(portField.getText());
- Integer.parseInt(priorityField.getText());
- wizard.getWizardContainer().setNextFinishButtonEnabled(true);
- }
- catch (NumberFormatException ex)
- {
- wizard.getWizardContainer().setNextFinishButtonEnabled(false);
- }
+ return isCommitted;
}
- public Object getSimpleForm()
+ /**
+ * Parse the server part from the jabber id and set it to server as default
+ * value. If the server was overriden do nothing.
+ * @param username the username from which to extract the server address
+ */
+ void setServerFieldAccordingToUsername(String username)
{
- return userIDPassPanel;
+ if (!wizard.isModification() || !isServerOverridden)
+ {
+ connectionPanel.setServerAddress(
+ wizard.getServerFromUserName(username));
+ }
}
- public boolean isCommitted()
+ /**
+ * Returns the contained connection panel.
+ * @return the contained connection panel
+ */
+ ConnectionPanel getConnectionPanel()
{
- return isCommitted;
+ return connectionPanel;
}
}
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/IceConfigPanel.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/IceConfigPanel.java
new file mode 100644
index 0000000..b845be5
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/IceConfigPanel.java
@@ -0,0 +1,526 @@
+/*
+ * 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.plugin.jabberaccregwizz;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.util.List;
+
+import javax.swing.*;
+import javax.swing.table.*;
+
+import net.java.sip.communicator.util.swing.*;
+
+/**
+ *
+ * @author Yana Stamcheva
+ */
+public class IceConfigPanel
+ extends TransparentPanel
+{
+ /**
+ * The check box allowing the user to choose to use ICE.
+ */
+ private final JCheckBox iceBox = new SIPCommCheckBox(
+ Resources.getString("plugin.jabberaccregwizz.USE_ICE"));
+
+ /**
+ * The check box allowing the user to choose to automatically discover
+ * STUN servers.
+ */
+ private final JCheckBox autoDiscoverBox = new SIPCommCheckBox(
+ Resources.getString("plugin.jabberaccregwizz.AUTO_DISCOVER_STUN"));
+
+ /**
+ * The table model for our additional stun servers table.
+ */
+ private final DefaultTableModel tableModel = new StunServerTableModel();
+
+ /**
+ * The stun server table.
+ */
+ private final JTable table = new JTable(tableModel);
+
+ /**
+ * Creates an instance of <tt>IceConfigPanel</tt>.
+ */
+ public IceConfigPanel()
+ {
+ this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+
+ iceBox.setAlignmentX(Component.LEFT_ALIGNMENT);
+ autoDiscoverBox.setAlignmentX(Component.LEFT_ALIGNMENT);
+
+ JPanel checkBoxPanel = new TransparentPanel(new GridLayout(0, 1));
+ checkBoxPanel.add(iceBox);
+ checkBoxPanel.add(autoDiscoverBox);
+
+ add(checkBoxPanel);
+ add(Box.createVerticalStrut(10));
+ add(createAdditionalServersComponent());
+ }
+
+ /**
+ * Creates the list of additional STUN/TURN servers that are added by the
+ * user.
+ * @return the created component
+ */
+ private Component createAdditionalServersComponent()
+ {
+ table.setPreferredScrollableViewportSize(new Dimension(450, 60));
+
+ tableModel.addColumn(
+ Resources.getString("plugin.jabberaccregwizz.IP_ADDRESS")
+ + "/" + Resources.getString("plugin.jabberaccregwizz.PORT"));
+ tableModel.addColumn(
+ Resources.getString("plugin.jabberaccregwizz.SUPPORT_TURN"));
+
+ table.setDefaultRenderer( StunServer.class,
+ new StunServerCellRenderer());
+
+ //Create the scroll pane and add the table to it.
+ JScrollPane scrollPane = new JScrollPane(table);
+
+ JButton addButton
+ = new JButton(Resources.getString("service.gui.ADD"));
+ addButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ StunConfigDialog stunDialog = new StunConfigDialog();
+
+ stunDialog.setVisible(true);
+ }
+ });
+
+ JButton editButton
+ = new JButton(Resources.getString("service.gui.EDIT"));
+ editButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ StunServer stunServer
+ = (StunServer) tableModel.getValueAt(
+ table.getSelectedRow(), 0);
+
+ if (stunServer != null)
+ {
+ StunConfigDialog dialog
+ = new StunConfigDialog( stunServer.getIpAddress(),
+ stunServer.getPort(),
+ stunServer.isSupportTurn(),
+ stunServer.getUsername(),
+ stunServer.getPassword());
+
+ dialog.setVisible(true);
+ }
+ }
+ });
+
+ JButton deleteButton
+ = new JButton(Resources.getString("service.gui.DELETE"));
+ deleteButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ tableModel.removeRow(table.getSelectedRow());
+ }
+ });
+
+ TransparentPanel buttonsPanel
+ = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
+
+ buttonsPanel.add(addButton);
+ buttonsPanel.add(editButton);
+ buttonsPanel.add(deleteButton);
+
+ TransparentPanel mainPanel = new TransparentPanel(new BorderLayout());
+ mainPanel.setBorder(BorderFactory.createTitledBorder(
+ Resources.getString(
+ "plugin.jabberaccregwizz.ADDITIONAL_STUN_SERVERS")));
+ mainPanel.add(scrollPane);
+ mainPanel.add(buttonsPanel, BorderLayout.SOUTH);
+
+ return mainPanel;
+ }
+
+ /**
+ * The STUN configuration window.
+ */
+ private class StunConfigDialog extends SIPCommDialog
+ {
+ private final JPanel mainPanel = new TransparentPanel(new BorderLayout());
+ private final JTextField addressField = new JTextField();
+ private final JTextField portField = new JTextField();
+ private final JCheckBox supportTurnCheckBox = new JCheckBox(
+ Resources.getString("plugin.jabberaccregwizz.SUPPORT_TURN"));
+ private final JTextField usernameField = new JTextField();
+ private final JPasswordField passwordField = new JPasswordField();
+ private JEditorPane errorMessagePane;
+
+ public StunConfigDialog(String address,
+ String port,
+ boolean isSupportTurn,
+ String username,
+ char[] password)
+ {
+ this();
+
+ addressField.setText(address);
+ portField.setText(port);
+ supportTurnCheckBox.setSelected(isSupportTurn);
+ usernameField.setText(username);
+ passwordField.setText(password.toString());
+ }
+
+ public StunConfigDialog()
+ {
+ super(false);
+
+ setTitle(Resources.getString(
+ "plugin.jabberaccregwizz.ADD_STUN_SERVER"));
+
+ JLabel addressLabel = new JLabel(
+ Resources.getString("plugin.jabberaccregwizz.IP_ADDRESS"));
+ JLabel portLabel = new JLabel(
+ Resources.getString("plugin.jabberaccregwizz.PORT"));
+ JLabel usernameLabel = new JLabel(
+ Resources.getString("plugin.jabberaccregwizz.USERNAME"));
+ JLabel passwordLabel = new JLabel(
+ Resources.getString("service.gui.PASSWORD"));
+
+ TransparentPanel labelsPanel
+ = new TransparentPanel(new GridLayout(0, 1));
+
+ labelsPanel.add(new JLabel());
+ labelsPanel.add(addressLabel);
+ labelsPanel.add(portLabel);
+ labelsPanel.add(usernameLabel);
+ labelsPanel.add(passwordLabel);
+
+ TransparentPanel valuesPanel
+ = new TransparentPanel(new GridLayout(0, 1));
+
+ valuesPanel.add(supportTurnCheckBox);
+ valuesPanel.add(addressField);
+ valuesPanel.add(portField);
+ valuesPanel.add(usernameField);
+ valuesPanel.add(passwordField);
+
+ JButton addButton
+ = new JButton(Resources.getString("service.gui.ADD"));
+ JButton cancelButton
+ = new JButton(Resources.getString("service.gui.CANCEL"));
+
+ addButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ String address = addressField.getText();
+ String port = portField.getText();
+ String username = usernameField.getText();
+ char[] password = passwordField.getPassword();
+
+ String errorMessage = null;
+ if (address == null || address.length() <= 0)
+ errorMessage = Resources.getString(
+ "plugin.jabberaccregwizz.NO_STUN_ADDRESS");
+
+ if (username == null || username.length() <= 0)
+ errorMessage = Resources.getString(
+ "plugin.jabberaccregwizz.NO_STUN_USERNAME");
+
+ if (port == null || port.length() <= 0)
+ port = JabberAccountRegistration.DEFAULT_STUN_PORT;
+
+ if (containsStunServer(address, port))
+ errorMessage = Resources.getString(
+ "plugin.jabberaccregwizz.STUN_ALREADY_EXIST");
+
+ if (errorMessage != null)
+ {
+ loadErrorMessage(errorMessage);
+ return;
+ }
+
+ StunServer stunServer = new StunServer(
+ address,
+ port,
+ supportTurnCheckBox.isSelected(),
+ username,
+ password,
+ table.getRowCount());
+
+ addStunServer(stunServer);
+
+ dispose();
+ }
+ });
+
+ cancelButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ dispose();
+ }
+ });
+
+ TransparentPanel buttonsPanel
+ = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
+ buttonsPanel.add(addButton);
+ buttonsPanel.add(cancelButton);
+
+ mainPanel.add(labelsPanel, BorderLayout.WEST);
+ mainPanel.add(valuesPanel, BorderLayout.CENTER);
+ mainPanel.add(buttonsPanel, BorderLayout.SOUTH);
+
+ mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
+ getContentPane().add(mainPanel, BorderLayout.NORTH);
+ pack();
+ }
+
+ /**
+ * Loads the given error message in the current dialog, by re-validating
+ * the content.
+ *
+ * @param errorMessage The error message to load.
+ */
+ private void loadErrorMessage(String errorMessage)
+ {
+ if (errorMessagePane == null)
+ {
+ errorMessagePane = new JEditorPane();
+
+ errorMessagePane.setOpaque(false);
+ errorMessagePane.setForeground(Color.RED);
+
+ mainPanel.add(errorMessagePane, BorderLayout.NORTH);
+ }
+
+ errorMessagePane.setText(errorMessage);
+ mainPanel.revalidate();
+ mainPanel.repaint();
+
+ this.pack();
+
+ //WORKAROUND: there's something wrong happening in this pack and
+ //components get cluttered, partially hiding the password text field.
+ //I am under the impression that this has something to do with the
+ //message pane preferred size being ignored (or being 0) which is why
+ //I am adding it's height to the dialog. It's quite ugly so please fix
+ //if you have something better in mind.
+ this.setSize(getWidth(), getHeight()+errorMessagePane.getHeight());
+ }
+ @Override
+ protected void close(boolean escaped) {}
+ }
+
+ /**
+ * A custom cell renderer used in the cell containing the
+ * <tt>StunServer</tt> instance.
+ */
+ private static class StunServerCellRenderer
+ extends DefaultTableCellRenderer
+ {
+ // We need a place to store the color the JLabel should be returned
+ // to after its foreground and background colors have been set
+ // to the selection background color.
+ // These ivars will be made protected when their names are finalized.
+ private Color unselectedForeground;
+ private Color unselectedBackground;
+
+ /**
+ * Overrides <code>JComponent.setForeground</code> to assign
+ * the unselected-foreground color to the specified color.
+ *
+ * @param c set the foreground color to this value
+ */
+ public void setForeground(Color c)
+ {
+ super.setForeground(c);
+ unselectedForeground = c;
+ }
+
+ /**
+ * Overrides <code>JComponent.setBackground</code> to assign
+ * the unselected-background color to the specified color.
+ *
+ * @param c set the background color to this value
+ */
+ public void setBackground(Color c)
+ {
+ super.setBackground(c);
+ unselectedBackground = c;
+ }
+
+ public Component getTableCellRendererComponent( JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column)
+ {
+
+ if (value instanceof StunServer)
+ {
+ StunServer stunServer = (StunServer) value;
+
+ this.setText( stunServer.getIpAddress()
+ + "/" + stunServer.getPort());
+
+ if (isSelected)
+ {
+ super.setForeground(table.getSelectionForeground());
+ super.setBackground(table.getSelectionBackground());
+ }
+ else
+ {
+ super.setForeground((unselectedForeground != null)
+ ? unselectedForeground
+ : table.getForeground());
+ super.setBackground((unselectedBackground != null)
+ ? unselectedBackground
+ : table.getBackground());
+ }
+ }
+ else
+ return super.getTableCellRendererComponent(table, value,
+ isSelected, hasFocus, row, column);
+
+ return this;
+ }
+ }
+
+ /**
+ * A custom table model, with a non editable cells and a custom class column
+ * objects.
+ *
+ */
+ private class StunServerTableModel
+ extends DefaultTableModel
+ {
+ /**
+ * Returns the class of the objects contained in the column given by
+ * the index. The class is used to distinguish which renderer should be
+ * used.
+ *
+ * @param columnIndex the column being queried
+ * @return the class of objects contained in the column
+ */
+ public Class getColumnClass(int columnIndex)
+ {
+ return getValueAt(0, columnIndex).getClass();
+ }
+
+ /**
+ * Returns <tt>false</tt> to indicate that none of the columns is
+ * editable.
+ *
+ * @param row the row whose value is to be queried
+ * @param column the column whose value is to be queried
+ * @return false
+ */
+ public boolean isCellEditable(int row, int column)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Indicates if ice should be used for this account.
+ * @return <tt>true</tt> if ICE should be used for this account, otherwise
+ * returns <tt>false</tt>
+ */
+ boolean isUseIce()
+ {
+ return iceBox.isSelected();
+ }
+
+ /**
+ * Sets the <tt>useIce</tt> property.
+ * @param isUseIce <tt>true</tt> to indicate that ICE should be used for
+ * this account, <tt>false</tt> - otherwise.
+ */
+ void setUseIce(boolean isUseIce)
+ {
+ iceBox.setSelected(isUseIce);
+ }
+
+ /**
+ * Indicates if the stun server should be automatically discovered.
+ * @return <tt>true</tt> if the stun server should be automatically
+ * discovered, otherwise returns <tt>false</tt>.
+ */
+ boolean isAutoDiscoverStun()
+ {
+ return autoDiscoverBox.isSelected();
+ }
+
+ /**
+ * Sets the <tt>autoDiscoverStun</tt> property.
+ * @param isAutoDiscover <tt>true</tt> to indicate that stun server should
+ * be auto-discovered, <tt>false</tt> - otherwise.
+ */
+ void setAutoDiscoverStun(boolean isAutoDiscover)
+ {
+ autoDiscoverBox.setSelected(isAutoDiscover);
+ }
+
+ /**
+ * Returns the list of additional stun servers entered by the user.
+ * @return the list of additional stun servers entered by the user
+ */
+ @SuppressWarnings("unchecked")
+ List<StunServer> getAdditionalStunServers()
+ {
+ LinkedList<StunServer> serversList = new LinkedList<StunServer>();
+ Iterator i = tableModel.getDataVector().iterator();
+
+ while(i.hasNext())
+ {
+ Vector row = (Vector) i.next();
+
+ serversList.add((StunServer) row.elementAt(0));
+ }
+
+ return serversList;
+ }
+
+ /**
+ * Adds the given <tt>stunServer</tt> to the list of additional stun
+ * servers.
+ * @param stunServer the stun server to add
+ */
+ void addStunServer(StunServer stunServer)
+ {
+ tableModel.addRow(new Object[]{stunServer,
+ stunServer.isSupportTurn()});
+ }
+
+ /**
+ * Indicates if a stun server with the given <tt>address</tt> and
+ * <tt>port</tt> already exists in the additional stun servers table.
+ * @param address the STUN server address to check
+ * @param port the STUN server port to check
+ * @return <tt>true</tt> if a STUN server with the given <tt>address</tt>
+ * and <tt>port</tt> already exists in the table, otherwise returns
+ * <tt>false</tt>
+ */
+ boolean containsStunServer(String address, String port)
+ {
+ for (int i = 0; i < tableModel.getRowCount(); i++)
+ {
+ StunServer stunServer = (StunServer) tableModel.getValueAt(i, 0);
+
+ if (stunServer.getIpAddress().equalsIgnoreCase(address)
+ && stunServer.getPort().equalsIgnoreCase(port))
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java
index 0357053..d2ee639 100755
--- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistration.java
@@ -6,6 +6,8 @@
*/
package net.java.sip.communicator.plugin.jabberaccregwizz;
+import java.util.*;
+
/**
* The <tt>JabberAccountRegistration</tt> is used to store all user input data
* through the <tt>JabberAccountRegistrationWizard</tt>.
@@ -14,31 +16,87 @@ package net.java.sip.communicator.plugin.jabberaccregwizz;
*/
public class JabberAccountRegistration
{
+ /**
+ * The default value of server port for jabber accounts.
+ */
public static final String DEFAULT_PORT = "5222";
+ /**
+ * The default value of the priority property.
+ */
public static final String DEFAULT_PRIORITY = "10";
+ /**
+ * The default value of the resource property.
+ */
public static final String DEFAULT_RESOURCE = "sip-comm";
+ /**
+ * The default value of stun server port for jabber accounts.
+ */
+ public static final String DEFAULT_STUN_PORT = "3478";
+
+ /**
+ * The user identifier.
+ */
private String userID;
+ /**
+ * The password.
+ */
private String password;
+ /**
+ * Indicates if the password should be remembered.
+ */
private boolean rememberPassword = true;
+ /**
+ * The server address.
+ */
private String serverAddress;
+ /**
+ * The port.
+ */
private int port = new Integer(DEFAULT_PORT).intValue();
+ /**
+ * The resource property, initialized to the default resource.
+ */
private String resource = DEFAULT_RESOURCE;
+ /**
+ * The priority property.
+ */
private int priority = new Integer(DEFAULT_PRIORITY).intValue();
+ /**
+ * Indicates if keep alive packets should be send.
+ */
private boolean sendKeepAlive = true;
+ /**
+ * Indicates if gmail notifications should be enabled.
+ */
private boolean enableGmailNotification = false;
/**
+ * Indicates if ICE should be used.
+ */
+ private boolean isUseIce = false;
+
+ /**
+ * Indicates if STUN server should be automatically discovered.
+ */
+ private boolean isAutoDiscoverStun = false;
+
+ /**
+ * The list of additional STUN servers entered by user.
+ */
+ private LinkedList<StunServer> additionalStunServers;
+
+ /**
* Returns the password of the jabber registration account.
* @return the password of the jabber registration account.
*/
@@ -179,23 +237,103 @@ public class JabberAccountRegistration
this.enableGmailNotification = enabled;
}
+ /**
+ * Returns the resource.
+ * @return the resource
+ */
public String getResource()
{
return resource;
}
+ /**
+ * Sets the resource.
+ * @param resource the resource for the jabber account
+ */
public void setResource(String resource)
{
this.resource = resource;
}
+ /**
+ * Returns the priority property.
+ * @return priority
+ */
public int getPriority()
{
return priority;
}
+ /**
+ * Sets the priority property.
+ * @param priority the priority to set
+ */
public void setPriority(int priority)
{
this.priority = priority;
}
+
+ /**
+ * Indicates if ice should be used for this account.
+ * @return <tt>true</tt> if ICE should be used for this account, otherwise
+ * returns <tt>false</tt>
+ */
+ public boolean isUseIce()
+ {
+ return isUseIce;
+ }
+
+ /**
+ * Sets the <tt>useIce</tt> property.
+ * @param isUseIce <tt>true</tt> to indicate that ICE should be used for
+ * this account, <tt>false</tt> - otherwise.
+ */
+ public void setUseIce(boolean isUseIce)
+ {
+ this.isUseIce = isUseIce;
+ }
+
+ /**
+ * Indicates if the stun server should be automatically discovered.
+ * @return <tt>true</tt> if the stun server should be automatically
+ * discovered, otherwise returns <tt>false</tt>.
+ */
+ public boolean isAutoDiscoverStun()
+ {
+ return isAutoDiscoverStun;
+ }
+
+ /**
+ * Sets the <tt>autoDiscoverStun</tt> property.
+ * @param isAutoDiscover <tt>true</tt> to indicate that stun server should
+ * be auto-discovered, <tt>false</tt> - otherwise.
+ */
+ public void setAutoDiscoverStun(boolean isAutoDiscover)
+ {
+ this.isAutoDiscoverStun = isAutoDiscover;
+ }
+
+ /**
+ * Adds the given <tt>stunServer</tt> to the list of additional stun servers.
+ * @param stunServer the <tt>StunServer</tt> to add
+ */
+ public void addStunServer(StunServer stunServer)
+ {
+ if (additionalStunServers == null)
+ additionalStunServers = new LinkedList<StunServer>();
+
+ additionalStunServers.add(stunServer);
+ }
+
+ /**
+ * Returns an <tt>Iterator</tt> over a list of all additional stun servers
+ * entered by the user.
+ * @return an <tt>Iterator</tt> over a list of all additional stun servers
+ */
+ public Iterator<StunServer> getAdditionalStunServers()
+ {
+ if (additionalStunServers != null)
+ return additionalStunServers.iterator();
+ return null;
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java
index 2445bf3..a0d8dde 100644
--- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java
@@ -157,9 +157,10 @@ public class JabberAccountRegistrationWizard
}
/**
- * Installs the account created through this wizard.
- *
- * @return ProtocolProviderService
+ * Installs the account defined in this wizard.
+ * @return the created <tt>ProtocolProviderService</tt> corresponding to the
+ * new account
+ * @throws OperationFailedException if the operation didn't succeed
*/
public ProtocolProviderService signin()
throws OperationFailedException
@@ -170,6 +171,15 @@ public class JabberAccountRegistrationWizard
registration.getPassword());
}
+ /**
+ * Installs the account defined in this wizard.
+ *
+ * @param userName the user name to sign in with
+ * @param password the password to sign in with
+ * @return the created <tt>ProtocolProviderService</tt> corresponding to the
+ * new account
+ * @throws OperationFailedException if the operation didn't succeed
+ */
public ProtocolProviderService signin(String userName, String password)
throws OperationFailedException
{
@@ -189,6 +199,7 @@ public class JabberAccountRegistrationWizard
* @param userName the user identifier
* @param passwd the password
* @return the <tt>ProtocolProviderService</tt> for the new account.
+ * @throws OperationFailedException if the operation didn't succeed
*/
public ProtocolProviderService installAccount(
ProtocolProviderFactory providerFactory,
@@ -235,13 +246,58 @@ public class JabberAccountRegistrationWizard
serverName);
accountProperties.put(ProtocolProviderFactory.SERVER_PORT,
- String.valueOf(registration.getPort()));
+ String.valueOf(registration.getPort()));
accountProperties.put(ProtocolProviderFactory.RESOURCE,
- registration.getResource());
+ registration.getResource());
accountProperties.put(ProtocolProviderFactory.RESOURCE_PRIORITY,
- String.valueOf(registration.getPriority()));
+ String.valueOf(registration.getPriority()));
+
+// Disable STUN and ICE configs until it's implemented.
+//
+// accountProperties.put(ProtocolProviderFactory.IS_USE_ICE,
+// String.valueOf(registration.isUseIce()));
+//
+// accountProperties.put(ProtocolProviderFactory.AUTO_DISCOVER_STUN,
+// String.valueOf(registration.isAutoDiscoverStun()));
+
+ Iterator<StunServer> stunServers
+ = registration.getAdditionalStunServers();
+
+ while(stunServers != null && stunServers.hasNext())
+ {
+ StunServer stunServer = stunServers.next();
+
+ int stunIndex = stunServer.getIndex();
+ String stunPort = stunServer.getPort();
+ String stunUsername = stunServer.getUsername();
+ String stunPassword = stunServer.getPassword().toString();
+ boolean isSupportTurn = stunServer.isSupportTurn();
+
+ accountProperties.put(
+ ProtocolProviderFactory.STUN_ADDRESS + stunIndex,
+ stunServer.getIpAddress());
+
+ if (stunPort != null && stunPort.length() > 0)
+ accountProperties.put(
+ ProtocolProviderFactory.STUN_PORT + stunIndex,
+ stunPort);
+
+ if (stunUsername != null && stunUsername.length() > 0)
+ accountProperties.put(
+ ProtocolProviderFactory.STUN_USERNAME + stunIndex,
+ stunUsername);
+
+ if (stunPassword != null && stunPassword.length() > 0)
+ accountProperties.put(
+ ProtocolProviderFactory.STUN_PASSWORD + stunIndex,
+ stunPassword);
+
+ accountProperties.put(
+ ProtocolProviderFactory.STUN_IS_TURN_SUPPORTED + stunIndex,
+ new Boolean(isSupportTurn).toString());
+ }
if (isModification)
{
@@ -399,7 +455,7 @@ public class JabberAccountRegistrationWizard
*/
public String getUserNameExample()
{
- return FirstWizardPage.USER_NAME_EXAMPLE;
+ return AccountPanel.USER_NAME_EXAMPLE;
}
/**
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/StunServer.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/StunServer.java
new file mode 100644
index 0000000..b431999
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/StunServer.java
@@ -0,0 +1,173 @@
+package net.java.sip.communicator.plugin.jabberaccregwizz;
+
+/**
+ * The <tt>StunServer</tt> keeps all information related to the stun server.
+ *
+ * @author Yana Stamcheva
+ */
+public class StunServer
+{
+ /**
+ * The IP address of the server.
+ */
+ private String ipAddress;
+
+ /**
+ * The port of the server.
+ */
+ private String port;
+
+ /**
+ * Indicates if Turn is supported by this server.
+ */
+ private boolean supportTurn;
+
+ /**
+ * The username.
+ */
+ private String username;
+
+ /**
+ * The password.
+ */
+ private char[] password;
+
+ /**
+ * The index of this server in the additional servers table.
+ */
+ private int index;
+
+ /**
+ * Creates an instance of <tt>StunServer</tt> by specifying all parameters.
+ * @param ipAddress the IP address of the STUN server
+ * @param port the port of the server
+ * @param supportTurn indicates if this STUN server supports TURN
+ * @param username the user name for authenticating
+ * @param password the password
+ * @param index the index of this server in the additional servers table
+ */
+ public StunServer( String ipAddress,
+ String port,
+ boolean supportTurn,
+ String username,
+ char[] password,
+ int index)
+ {
+ this.ipAddress = ipAddress;
+ this.port = port;
+ this.supportTurn = supportTurn;
+ this.username = username;
+ this.password = password;
+ this.index = index;
+ }
+
+ /**
+ * Returns the IP address of this server.
+ * @return the IP address of this server
+ */
+ String getIpAddress()
+ {
+ return ipAddress;
+ }
+
+ /**
+ * Sets the IP address of this server.
+ * @param ipAddress the IP address to set
+ */
+ void setIpAddress(String ipAddress)
+ {
+ this.ipAddress = ipAddress;
+ }
+
+ /**
+ * Returns the port of this server.
+ * @return the port of this server
+ */
+ String getPort()
+ {
+ return port;
+ }
+
+ /**
+ * Sets the port corresponding to this server.
+ * @param port the port to set
+ */
+ void setPort(String port)
+ {
+ this.port = port;
+ }
+
+ /**
+ * Indicates if Turn is supported by this server.
+ * @return <tt>true</tt> if Turn is supported by this server, otherwise -
+ * returns <tt>false</tt>
+ */
+ boolean isSupportTurn()
+ {
+ return supportTurn;
+ }
+
+ /**
+ * Sets the support turn property to indicate if this server supports Turn.
+ * @param supportTurn <tt>true</tt> to indicate that Turn is supported,
+ * <tt>false</tt> - otherwise
+ */
+ void setSupportTurn(boolean supportTurn)
+ {
+ this.supportTurn = supportTurn;
+ }
+
+ /**
+ * Returns the username associated to this server.
+ * @return the username associated to this server
+ */
+ String getUsername()
+ {
+ return username;
+ }
+
+ /**
+ * Sets the username associated to this server.
+ * @param username the username to set
+ */
+ void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ /**
+ * Returns the password associated to this server username.
+ * @return the password associated to this server username
+ */
+ char[] getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Sets the password associated to this server username.
+ * @param password the password to set
+ */
+ void setPassword(char[] password)
+ {
+ this.password = password;
+ }
+
+ /**
+ * The index of this server int the additional stun servers table.
+ * @return the index of this server int the additional stun servers table
+ */
+ int getIndex()
+ {
+ return index;
+ }
+
+ /**
+ * Sets the index of this server int the additional stun servers table.
+ * @param index the index to set
+ */
+ void setIndex(int index)
+ {
+ this.index = index;
+ }
+} \ No newline at end of file
diff --git a/src/net/java/sip/communicator/service/gui/AccountRegistrationWizard.java b/src/net/java/sip/communicator/service/gui/AccountRegistrationWizard.java
index 3be72fb..98d73d5 100644
--- a/src/net/java/sip/communicator/service/gui/AccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/service/gui/AccountRegistrationWizard.java
@@ -118,6 +118,9 @@ public interface AccountRegistrationWizard
/**
* Defines the operations that will be executed when the user clicks on
* the wizard "Signin" button.
+ * @return the created <tt>ProtocolProviderService</tt> corresponding to the
+ * new account
+ * @throws OperationFailedException if the operation didn't succeed
*/
public ProtocolProviderService signin()
throws OperationFailedException;
@@ -125,9 +128,12 @@ public interface AccountRegistrationWizard
/**
* 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
+ * @return the created <tt>ProtocolProviderService</tt> corresponding to the
+ * new account
+ * @throws OperationFailedException if the operation didn't succeed
*/
public ProtocolProviderService signin( String userName,
String password)
diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
index add6ebe..f866a7a 100644
--- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
+++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
@@ -256,6 +256,42 @@ public abstract class ProtocolProviderFactory
public static final String IS_ACCOUNT_DISABLED = "IS_ACCOUNT_DISABLED";
/**
+ * Indicates if ICE should be used.
+ */
+ public static final String IS_USE_ICE = "IS_USE_ICE";
+
+ /**
+ * Indicates if STUN server should be automatically discovered.
+ */
+ public static final String AUTO_DISCOVER_STUN = "AUTO_DISCOVER_STUN";
+
+ /**
+ * The base property name for address of additional STUN servers specified.
+ */
+ public static final String STUN_ADDRESS = "STUN_ADDRESS";
+
+ /**
+ * The base property name for port of additional STUN servers specified.
+ */
+ public static final String STUN_PORT = "STUN_PORT";
+
+ /**
+ * The base property name for username of additional STUN servers specified.
+ */
+ public static final String STUN_USERNAME = "STUN_USERNAME";
+
+ /**
+ * The base property name for password of additional STUN servers specified.
+ */
+ public static final String STUN_PASSWORD = "STUN_PASSWORD";
+
+ /**
+ * The base property name for the turn supported property of additional
+ * STUN servers specified.
+ */
+ public static final String STUN_IS_TURN_SUPPORTED = "STUN_IS_TURN_SUPPORTED";
+
+ /**
* The <code>BundleContext</code> containing (or to contain) the service
* registration of this factory.
*/
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommDialog.java b/src/net/java/sip/communicator/util/swing/SIPCommDialog.java
index 0eb584c..0ecf3f5 100644
--- a/src/net/java/sip/communicator/util/swing/SIPCommDialog.java
+++ b/src/net/java/sip/communicator/util/swing/SIPCommDialog.java
@@ -21,7 +21,6 @@ import net.java.sip.communicator.util.*;
public abstract class SIPCommDialog
extends JDialog
{
-
/**
* The <tt>Logger</tt> used by the <tt>SIPCommDialog</tt> class and its
* instances for logging output.