|
After Width: | Height: | Size: 935 B |
|
After Width: | Height: | Size: 913 B |
|
After Width: | Height: | Size: 612 B |
|
After Width: | Height: | Size: 905 B |
|
After Width: | Height: | Size: 956 B |
|
After Width: | Height: | Size: 882 B |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
@ -1,735 +0,0 @@
|
||||
/*
|
||||
* 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.iptelaccregwizz;
|
||||
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* The <tt>FirstWizardPage</tt> is the page, where user could enter the uin
|
||||
* and the password of the account.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class FirstWizardPage
|
||||
extends TransparentPanel
|
||||
implements WizardPage, DocumentListener, ItemListener
|
||||
{
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(FirstWizardPage.class);
|
||||
|
||||
/**
|
||||
* The identifier of this wizard page.
|
||||
*/
|
||||
public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
|
||||
|
||||
/**
|
||||
* The example text that guides the user for the format of the username.
|
||||
*/
|
||||
public static final String USER_NAME_EXAMPLE
|
||||
= "Ex: myusername or myusername@iptel.org";
|
||||
|
||||
private JPanel firstTabPanel = new TransparentPanel(new BorderLayout());
|
||||
|
||||
private JPanel uinPassPanel = new TransparentPanel(new BorderLayout(10, 10));
|
||||
|
||||
private JPanel labelsPanel = new TransparentPanel();
|
||||
|
||||
private JPanel valuesPanel = new TransparentPanel();
|
||||
|
||||
private JLabel uinLabel
|
||||
= new JLabel(Resources.getString("plugin.iptelaccregwizz.USERNAME"));
|
||||
|
||||
private JLabel passLabel
|
||||
= new JLabel(Resources.getString("service.gui.PASSWORD"));
|
||||
|
||||
private JPanel emptyPanel = new TransparentPanel();
|
||||
|
||||
private JLabel uinExampleLabel = 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 JLabel serverLabel
|
||||
= new JLabel(Resources.getString("plugin.sipaccregwizz.REGISTRAR"));
|
||||
|
||||
private JCheckBox enableDefaultEncryption =
|
||||
new SIPCommCheckBox(Resources
|
||||
.getString("plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"), true);
|
||||
|
||||
private JCheckBox enableSipZrtpAttribute =
|
||||
new SIPCommCheckBox(Resources
|
||||
.getString("plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"), true);
|
||||
|
||||
private JLabel proxyLabel
|
||||
= new JLabel(Resources.getString("plugin.sipaccregwizz.PROXY"));
|
||||
|
||||
private JLabel authNameLabel =
|
||||
new JLabel(Resources.getString("plugin.sipaccregwizz.AUTH_NAME"));
|
||||
|
||||
private JLabel serverPortLabel =
|
||||
new JLabel(Resources.getString("plugin.sipaccregwizz.SERVER_PORT"));
|
||||
|
||||
private JLabel proxyPortLabel =
|
||||
new JLabel(Resources.getString("plugin.sipaccregwizz.PROXY_PORT"));
|
||||
|
||||
private JLabel transportLabel =
|
||||
new JLabel(Resources.getString(
|
||||
"plugin.sipaccregwizz.PREFERRED_TRANSPORT"));
|
||||
|
||||
private JTextField serverField = new JTextField();
|
||||
|
||||
private JTextField proxyField = new JTextField();
|
||||
|
||||
private JTextField authNameField = new JTextField();
|
||||
|
||||
private JTextField serverPortField
|
||||
= new JTextField(IptelAccountRegistration.DEFAULT_PORT);
|
||||
|
||||
private JTextField proxyPortField
|
||||
= new JTextField(IptelAccountRegistration.DEFAULT_PORT);
|
||||
|
||||
private JComboBox transportCombo = new JComboBox(new Object[]
|
||||
{ "UDP", "TCP", "TLS" });
|
||||
|
||||
private JPanel presenceOpPanel
|
||||
= new TransparentPanel(new BorderLayout(10, 10));
|
||||
|
||||
private JPanel buttonsPresOpPanel
|
||||
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
private JPanel labelsPresOpPanel
|
||||
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
private JPanel valuesPresOpPanel
|
||||
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
private JCheckBox enablePresOpButton =
|
||||
new SIPCommCheckBox(Resources
|
||||
.getString("plugin.sipaccregwizz.ENABLE_PRESENCE"), true);
|
||||
|
||||
private JCheckBox forceP2PPresOpButton =
|
||||
new SIPCommCheckBox(Resources
|
||||
.getString("plugin.sipaccregwizz.FORCE_P2P_PRESENCE"), false);
|
||||
|
||||
private JLabel pollPeriodLabel = new JLabel(
|
||||
Resources.getString(
|
||||
"plugin.sipaccregwizz.OFFLINE_CONTACT_POLLING_PERIOD"));
|
||||
|
||||
private JLabel subscribeExpiresLabel = new JLabel(
|
||||
Resources.getString("plugin.sipaccregwizz.SUBSCRIPTION_EXPIRATION"));
|
||||
|
||||
private JTextField pollPeriodField
|
||||
= new JTextField(IptelAccountRegistration.DEFAULT_POLL_PERIOD);
|
||||
|
||||
private JTextField subscribeExpiresField =
|
||||
new JTextField(IptelAccountRegistration.DEFAULT_SUBSCRIBE_EXPIRES);
|
||||
|
||||
private JPanel keepAlivePanel
|
||||
= new TransparentPanel(new BorderLayout(10, 10));
|
||||
|
||||
private JPanel keepAliveLabels
|
||||
= new TransparentPanel(new GridLayout(0, 1, 5, 5));
|
||||
|
||||
private JPanel keepAliveValues
|
||||
= new TransparentPanel(new GridLayout(0, 1, 5, 5));
|
||||
|
||||
private JLabel keepAliveMethodLabel = new JLabel(
|
||||
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_METHOD"));
|
||||
|
||||
private JLabel keepAliveIntervalLabel = new JLabel(
|
||||
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_INTERVAL"));
|
||||
|
||||
private JLabel keepAliveIntervalExampleLabel = new JLabel(
|
||||
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_INTERVAL_INFO"));
|
||||
|
||||
private JComboBox keepAliveMethodBox
|
||||
= new JComboBox(new Object []
|
||||
{
|
||||
"REGISTER",
|
||||
"OPTIONS"
|
||||
});
|
||||
|
||||
private JTextField keepAliveIntervalValue = new JTextField();
|
||||
|
||||
private JTabbedPane tabbedPane = new SIPCommTabbedPane(false, false);
|
||||
|
||||
private JPanel advancedPanel = new TransparentPanel();
|
||||
|
||||
private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
|
||||
|
||||
private IptelAccountRegistrationWizard wizard;
|
||||
|
||||
private boolean isCommitted = false;
|
||||
|
||||
private boolean isServerOverridden = false;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>FirstWizardPage</tt>.
|
||||
*
|
||||
* @param wizard the parent wizard
|
||||
*/
|
||||
public FirstWizardPage(IptelAccountRegistrationWizard wizard)
|
||||
{
|
||||
super(new BorderLayout());
|
||||
|
||||
this.wizard = wizard;
|
||||
|
||||
advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS));
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all panels, buttons, etc.
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
this.labelsPanel.setOpaque(false);
|
||||
this.valuesPanel.setOpaque(false);
|
||||
this.uinPassPanel.setOpaque(false);
|
||||
this.emptyPanel.setOpaque(false);
|
||||
|
||||
this.userIDField.getDocument().addDocumentListener(this);
|
||||
this.transportCombo.addItemListener(this);
|
||||
this.rememberPassBox.setSelected(true);
|
||||
|
||||
this.uinExampleLabel.setForeground(Color.GRAY);
|
||||
this.uinExampleLabel.setFont(uinExampleLabel.getFont().deriveFont(8));
|
||||
this.emptyPanel.setMaximumSize(new Dimension(40, 35));
|
||||
this.uinExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8,
|
||||
0));
|
||||
|
||||
labelsPanel.add(uinLabel);
|
||||
labelsPanel.add(emptyPanel);
|
||||
labelsPanel.add(passLabel);
|
||||
|
||||
valuesPanel.add(userIDField);
|
||||
valuesPanel.add(uinExampleLabel);
|
||||
valuesPanel.add(passField);
|
||||
|
||||
uinPassPanel.add(labelsPanel, BorderLayout.WEST);
|
||||
uinPassPanel.add(valuesPanel, BorderLayout.CENTER);
|
||||
|
||||
TransparentPanel southPanel
|
||||
= new TransparentPanel(new GridLayout(1, 2));
|
||||
southPanel.add(rememberPassBox);
|
||||
southPanel.add(createSubscribeLabel());
|
||||
|
||||
uinPassPanel.add(southPanel, BorderLayout.SOUTH);
|
||||
|
||||
uinPassPanel.setBorder(BorderFactory.createTitledBorder(Resources
|
||||
.getString("plugin.sipaccregwizz.USERNAME_AND_PASSWORD")));
|
||||
|
||||
firstTabPanel.add(uinPassPanel, BorderLayout.NORTH);
|
||||
|
||||
tabbedPane.addTab( Resources.getString("service.gui.SUMMARY"),
|
||||
firstTabPanel);
|
||||
|
||||
transportCombo
|
||||
.setSelectedItem(IptelAccountRegistration.DEFAULT_TRANSPORT);
|
||||
|
||||
labelsAdvOpPanel.add(serverLabel);
|
||||
labelsAdvOpPanel.add(authNameLabel);
|
||||
labelsAdvOpPanel.add(serverPortLabel);
|
||||
labelsAdvOpPanel.add(proxyLabel);
|
||||
labelsAdvOpPanel.add(proxyPortLabel);
|
||||
labelsAdvOpPanel.add(transportLabel);
|
||||
|
||||
valuesAdvOpPanel.add(serverField);
|
||||
valuesAdvOpPanel.add(authNameField);
|
||||
valuesAdvOpPanel.add(serverPortField);
|
||||
valuesAdvOpPanel.add(proxyField);
|
||||
valuesAdvOpPanel.add(proxyPortField);
|
||||
valuesAdvOpPanel.add(transportCombo);
|
||||
|
||||
advancedOpPanel.add(labelsAdvOpPanel, BorderLayout.WEST);
|
||||
advancedOpPanel.add(valuesAdvOpPanel, BorderLayout.CENTER);
|
||||
|
||||
JPanel encryptionPanel = new TransparentPanel(new GridLayout(1, 2, 2, 2));
|
||||
encryptionPanel.add(enableDefaultEncryption, BorderLayout.WEST);
|
||||
encryptionPanel.add(enableSipZrtpAttribute, BorderLayout.EAST);
|
||||
|
||||
enableDefaultEncryption.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
// Perform action
|
||||
JCheckBox cb = (JCheckBox) evt.getSource();
|
||||
|
||||
enableSipZrtpAttribute.setEnabled(cb.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
advancedOpPanel.add(encryptionPanel, BorderLayout.SOUTH);
|
||||
|
||||
advancedOpPanel.setBorder(BorderFactory.createTitledBorder(Resources
|
||||
.getString("plugin.aimaccregwizz.ADVANCED_OPTIONS")));
|
||||
|
||||
advancedPanel.add(advancedOpPanel);
|
||||
|
||||
enablePresOpButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
// Perform action
|
||||
JCheckBox cb = (JCheckBox) evt.getSource();
|
||||
|
||||
setPresenceOptionsEnabled(cb.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
labelsPresOpPanel.add(pollPeriodLabel);
|
||||
labelsPresOpPanel.add(subscribeExpiresLabel);
|
||||
|
||||
valuesPresOpPanel.add(pollPeriodField);
|
||||
valuesPresOpPanel.add(subscribeExpiresField);
|
||||
|
||||
buttonsPresOpPanel.add(enablePresOpButton);
|
||||
buttonsPresOpPanel.add(forceP2PPresOpButton);
|
||||
|
||||
presenceOpPanel.add(buttonsPresOpPanel, BorderLayout.NORTH);
|
||||
presenceOpPanel.add(labelsPresOpPanel, BorderLayout.WEST);
|
||||
presenceOpPanel.add(valuesPresOpPanel, BorderLayout.CENTER);
|
||||
|
||||
presenceOpPanel.setBorder(BorderFactory.createTitledBorder(
|
||||
Resources.getString("plugin.sipaccregwizz.PRESENCE_OPTIONS")));
|
||||
|
||||
advancedPanel.add(presenceOpPanel);
|
||||
|
||||
JPanel emptyLabelPanel = new TransparentPanel();
|
||||
emptyLabelPanel.setMaximumSize(new Dimension(40, 35));
|
||||
|
||||
keepAliveLabels.add(keepAliveMethodLabel);
|
||||
keepAliveLabels.add(keepAliveIntervalLabel);
|
||||
keepAliveLabels.add(emptyLabelPanel);
|
||||
|
||||
this.keepAliveIntervalExampleLabel.setForeground(Color.GRAY);
|
||||
this.keepAliveIntervalExampleLabel
|
||||
.setFont(uinExampleLabel.getFont().deriveFont(8));
|
||||
this.keepAliveIntervalExampleLabel
|
||||
.setMaximumSize(new Dimension(40, 35));
|
||||
this.keepAliveIntervalExampleLabel
|
||||
.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
|
||||
|
||||
keepAliveIntervalValue
|
||||
.setText(IptelAccountRegistration.DEFAULT_KEEP_ALIVE_INTERVAL);
|
||||
|
||||
keepAliveMethodBox.setSelectedItem(
|
||||
IptelAccountRegistration.DEFAULT_KEEP_ALIVE_METHOD);
|
||||
|
||||
keepAliveValues.add(keepAliveMethodBox);
|
||||
keepAliveValues.add(keepAliveIntervalValue);
|
||||
keepAliveValues.add(keepAliveIntervalExampleLabel);
|
||||
|
||||
keepAlivePanel.add(keepAliveLabels, BorderLayout.WEST);
|
||||
keepAlivePanel.add(keepAliveValues, BorderLayout.CENTER);
|
||||
|
||||
keepAlivePanel.setBorder(BorderFactory.createTitledBorder(
|
||||
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE")));
|
||||
|
||||
advancedPanel.add(keepAlivePanel);
|
||||
|
||||
tabbedPane.addTab(
|
||||
Resources.getString("service.gui.ADVANCED"),
|
||||
advancedPanel);
|
||||
|
||||
this.add(tabbedPane, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the subscribe label.
|
||||
* @return the newly created subscribe label
|
||||
*/
|
||||
private Component createSubscribeLabel()
|
||||
{
|
||||
JLabel subscribeLabel =
|
||||
new JLabel("<html><a href=''>"
|
||||
+ Resources.getString("plugin.iptelaccregwizz.NEW_ACCOUNT_TITLE")
|
||||
+ "</a></html>",
|
||||
JLabel.RIGHT);
|
||||
|
||||
subscribeLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
subscribeLabel.setToolTipText(
|
||||
Resources.getString("plugin.simpleaccregwizz.SPECIAL_SIGNUP"));
|
||||
subscribeLabel.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
public void mousePressed(MouseEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
wizard.webSignup();
|
||||
}
|
||||
catch (UnsupportedOperationException ex)
|
||||
{
|
||||
// This should not happen, because we check if the
|
||||
// operation is supported, before adding the sign
|
||||
// up.
|
||||
logger.error("The web sign up is not supported.",
|
||||
ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return subscribeLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <code>WizardPage.getIdentifier</code> to return this
|
||||
* page identifier.
|
||||
* @return the identifier of this page
|
||||
*/
|
||||
public Object getIdentifier()
|
||||
{
|
||||
return FIRST_PAGE_IDENTIFIER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <code>WizardPage.getNextPageIdentifier</code> to return
|
||||
* the next page identifier - the summary page.
|
||||
* @return the next page identifier
|
||||
*/
|
||||
public Object getNextPageIdentifier()
|
||||
{
|
||||
return nextPageIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <code>WizardPage.getBackPageIdentifier</code> to return
|
||||
* the back identifier. In this case it's null because this is the first
|
||||
* wizard page.
|
||||
* @return the identifier of the previous wizard page
|
||||
*/
|
||||
public Object getBackPageIdentifier()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <code>WizardPage.getWizardForm</code> to return this
|
||||
* panel.
|
||||
* @return the wizard form
|
||||
*/
|
||||
public Object getWizardForm()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Before this page is displayed enables or disables the "Next" wizard
|
||||
* button according to whether the UIN field is empty.
|
||||
*/
|
||||
public void pageShowing()
|
||||
{
|
||||
this.setNextButtonAccordingToUIN();
|
||||
wizard.getWizardContainer().setBackButtonEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the user input when the "Next" wizard buttons is clicked.
|
||||
*/
|
||||
public void commitPage()
|
||||
{
|
||||
String uin = userIDField.getText();
|
||||
int indexOfSeparator = uin.indexOf('@');
|
||||
if (indexOfSeparator > -1) {
|
||||
uin = uin.substring(0, indexOfSeparator);
|
||||
}
|
||||
|
||||
IptelAccountRegistration registration = wizard.getRegistration();
|
||||
|
||||
String userID = userIDField.getText();
|
||||
|
||||
if(userID == null || userID.trim().length() == 0)
|
||||
throw new IllegalStateException("No user ID provided.");
|
||||
|
||||
registration.setUserID(userID);
|
||||
|
||||
if (passField.getPassword() != null)
|
||||
registration.setPassword(new String(passField.getPassword()));
|
||||
|
||||
registration.setRememberPassword(rememberPassBox.isSelected());
|
||||
|
||||
if (serverField.getText() != null && serverField.getText().length() > 0)
|
||||
registration.setServerAddress(serverField.getText());
|
||||
|
||||
String authName = authNameField.getText();
|
||||
if(authName != null && authName.length() > 0)
|
||||
registration.setAuthorizationName(authName);
|
||||
|
||||
registration.setServerPort(serverPortField.getText());
|
||||
registration.setProxy(proxyField.getText());
|
||||
registration.setProxyPort(proxyPortField.getText());
|
||||
registration.setPreferredTransport(transportCombo.getSelectedItem()
|
||||
.toString());
|
||||
|
||||
registration.setEnablePresence(enablePresOpButton.isSelected());
|
||||
registration.setForceP2PMode(forceP2PPresOpButton.isSelected());
|
||||
registration.setDefaultEncryption(enableDefaultEncryption.isSelected());
|
||||
registration.setSipZrtpAttribute(enableSipZrtpAttribute.isSelected());
|
||||
registration.setPollingPeriod(pollPeriodField.getText());
|
||||
registration.setSubscriptionExpiration(subscribeExpiresField
|
||||
.getText());
|
||||
registration.setKeepAliveMethod(
|
||||
keepAliveMethodBox.getSelectedItem().toString());
|
||||
registration.setKeepAliveInterval(keepAliveIntervalValue.getText());
|
||||
|
||||
wizard.getWizardContainer().setBackButtonEnabled(true);
|
||||
|
||||
nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
|
||||
|
||||
this.isCommitted = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables the "Next" wizard button according to whether the UIN
|
||||
* field is empty.
|
||||
*/
|
||||
private void setNextButtonAccordingToUIN()
|
||||
{
|
||||
if (userIDField.getText() == null || userIDField.getText().equals(""))
|
||||
{
|
||||
wizard.getWizardContainer().setNextFinishButtonEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
wizard.getWizardContainer().setNextFinishButtonEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the <tt>DocumentEvent</tt> triggered when user types in the UIN
|
||||
* field. Enables or disables the "Next" wizard button according to whether
|
||||
* the UIN field is empty.
|
||||
* @param e the <tt>DocumentEvent</tt> that notified us
|
||||
*/
|
||||
public void insertUpdate(DocumentEvent e)
|
||||
{
|
||||
this.setNextButtonAccordingToUIN();
|
||||
this.setServerFieldAccordingToUIN();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
|
||||
* from the UIN field. Enables or disables the "Next" wizard button
|
||||
* according to whether the UIN field is empty.
|
||||
* @param e the <tt>DocumentEvent</tt>
|
||||
*/
|
||||
public void removeUpdate(DocumentEvent e)
|
||||
{
|
||||
this.setNextButtonAccordingToUIN();
|
||||
this.setServerFieldAccordingToUIN();
|
||||
}
|
||||
|
||||
public void changedUpdate(DocumentEvent e) {}
|
||||
|
||||
public void pageHiding() {}
|
||||
|
||||
public void pageShown() {}
|
||||
|
||||
public void pageBack() {}
|
||||
|
||||
/**
|
||||
* Fills the UIN 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.
|
||||
*/
|
||||
public void loadAccount(ProtocolProviderService protocolProvider)
|
||||
{
|
||||
AccountID accountID = protocolProvider.getAccountID();
|
||||
String password = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.PASSWORD);
|
||||
|
||||
String serverAddress = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.SERVER_ADDRESS);
|
||||
|
||||
String authName = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.AUTHORIZATION_NAME);
|
||||
|
||||
String serverPort = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.SERVER_PORT);
|
||||
|
||||
String proxyAddress = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.PROXY_ADDRESS);
|
||||
|
||||
String proxyPort = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.PROXY_PORT);
|
||||
|
||||
String preferredTransport = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.PREFERRED_TRANSPORT);
|
||||
|
||||
boolean enablePresence = accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.IS_PRESENCE_ENABLED, false);
|
||||
|
||||
boolean forceP2P = accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.FORCE_P2P_MODE, false);
|
||||
|
||||
boolean enabledDefaultEncryption = accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.DEFAULT_ENCRYPTION, true);
|
||||
|
||||
boolean enabledSipZrtpAttribute = accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.DEFAULT_SIPZRTP_ATTRIBUTE, true);
|
||||
|
||||
|
||||
String pollingPeriod = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.POLLING_PERIOD);
|
||||
|
||||
String subscriptionPeriod = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.SUBSCRIPTION_EXPIRATION);
|
||||
|
||||
String keepAliveMethod =
|
||||
accountID.getAccountPropertyString("KEEP_ALIVE_METHOD");
|
||||
|
||||
String keepAliveInterval =
|
||||
accountID.getAccountPropertyString("KEEP_ALIVE_INTERVAL");
|
||||
|
||||
this.isServerOverridden = accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.IS_SERVER_OVERRIDDEN, false);
|
||||
|
||||
userIDField.setEnabled(false);
|
||||
this.userIDField.setText((serverAddress == null) ? accountID.getUserID()
|
||||
: (accountID.getUserID() + "@" + serverAddress));
|
||||
|
||||
if (password != null)
|
||||
{
|
||||
this.passField.setText(password);
|
||||
this.rememberPassBox.setSelected(true);
|
||||
}
|
||||
|
||||
serverField.setText(serverAddress);
|
||||
serverField.setEnabled(false);
|
||||
|
||||
if(authName != null && authName.length() > 0)
|
||||
authNameField.setText(authName);
|
||||
|
||||
serverPortField.setText(serverPort);
|
||||
proxyField.setText(proxyAddress);
|
||||
|
||||
// The order of the next two fields is important, as a change listener
|
||||
// of the transportCombo sets the proxyPortField to its default
|
||||
transportCombo.setSelectedItem(preferredTransport);
|
||||
proxyPortField.setText(proxyPort);
|
||||
|
||||
enablePresOpButton.setSelected(enablePresence);
|
||||
forceP2PPresOpButton.setSelected(forceP2P);
|
||||
|
||||
enableDefaultEncryption.setSelected(enabledDefaultEncryption);
|
||||
enableSipZrtpAttribute.setSelected(enabledSipZrtpAttribute);
|
||||
enableSipZrtpAttribute.setEnabled(enabledDefaultEncryption);
|
||||
|
||||
pollPeriodField.setText(pollingPeriod);
|
||||
subscribeExpiresField.setText(subscriptionPeriod);
|
||||
|
||||
if (!enablePresence)
|
||||
{
|
||||
setPresenceOptionsEnabled(enablePresence);
|
||||
}
|
||||
|
||||
keepAliveMethodBox.setSelectedItem(keepAliveMethod);
|
||||
keepAliveIntervalValue.setText(keepAliveInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the server part from the sip id and set it to server as default
|
||||
* value. If Advanced option is enabled Do nothing.
|
||||
*/
|
||||
private void setServerFieldAccordingToUIN()
|
||||
{
|
||||
String serverAddress
|
||||
= wizard.getServerFromUserName(userIDField.getText());
|
||||
|
||||
if (!wizard.isModification() || !isServerOverridden)
|
||||
{
|
||||
serverField.setText(serverAddress);
|
||||
proxyField.setText(serverAddress);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disable all presence related options.
|
||||
*
|
||||
* @param isEnabled <code>true</code> to enable the presence related
|
||||
* options, <code>false</code> - to disable them.
|
||||
*/
|
||||
private void setPresenceOptionsEnabled(boolean isEnabled)
|
||||
{
|
||||
forceP2PPresOpButton.setEnabled(isEnabled);
|
||||
pollPeriodField.setEnabled(isEnabled);
|
||||
subscribeExpiresField.setEnabled(isEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy and server ports depending on the selected transport type.
|
||||
* @param e the <tt>ItemEvent</tt> that notified us
|
||||
*/
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED
|
||||
&& e.getItem().equals("TLS"))
|
||||
{
|
||||
serverPortField.setText(IptelAccountRegistration.DEFAULT_TLS_PORT);
|
||||
proxyPortField.setText(IptelAccountRegistration.DEFAULT_TLS_PORT);
|
||||
}
|
||||
else
|
||||
{
|
||||
serverPortField.setText(IptelAccountRegistration.DEFAULT_PORT);
|
||||
proxyPortField.setText(IptelAccountRegistration.DEFAULT_PORT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the simple form shown by default.
|
||||
* @return the simple form shown by default
|
||||
*/
|
||||
public Object getSimpleForm()
|
||||
{
|
||||
return uinPassPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if the form is committed, <tt>false</tt> -
|
||||
* otherwise.
|
||||
* @return <tt>true</tt> if the form is committed, <tt>false</tt> -
|
||||
* otherwise
|
||||
*/
|
||||
public boolean isCommitted()
|
||||
{
|
||||
return isCommitted;
|
||||
}
|
||||
}
|
||||
@ -1,433 +0,0 @@
|
||||
/*
|
||||
* 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.iptelaccregwizz;
|
||||
|
||||
/**
|
||||
* The <tt>IptelAccountRegistration</tt> is used to store all user input data
|
||||
* through the <tt>IptelAccountRegistrationWizard</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class IptelAccountRegistration
|
||||
{
|
||||
/**
|
||||
* The default port.
|
||||
*/
|
||||
public static String DEFAULT_PORT = "5060";
|
||||
|
||||
/**
|
||||
* The default TLS port.
|
||||
*/
|
||||
public static String DEFAULT_TLS_PORT = "5061";
|
||||
|
||||
/**
|
||||
* The default transport.
|
||||
*/
|
||||
public static String DEFAULT_TRANSPORT = "TCP";
|
||||
|
||||
/**
|
||||
* The default poll period.
|
||||
*/
|
||||
public static String DEFAULT_POLL_PERIOD = "30";
|
||||
|
||||
/**
|
||||
* The default subscribe expiration time in milliseconds.
|
||||
*/
|
||||
public static String DEFAULT_SUBSCRIBE_EXPIRES = "3600";
|
||||
|
||||
/**
|
||||
* The default keep alive method.
|
||||
*/
|
||||
public static String DEFAULT_KEEP_ALIVE_METHOD = "REGISTER";
|
||||
|
||||
/**
|
||||
* The default keep alive interval.
|
||||
*/
|
||||
public static String DEFAULT_KEEP_ALIVE_INTERVAL = "25";
|
||||
|
||||
/**
|
||||
* The iptel.org default server address.
|
||||
*/
|
||||
static final String IPTEL_CONNECT_SRV = "iptel.org";
|
||||
|
||||
private String id;
|
||||
|
||||
private String password;
|
||||
|
||||
private boolean rememberPassword = true;
|
||||
|
||||
private String serverAddress = IPTEL_CONNECT_SRV;
|
||||
|
||||
private String authorizationName;
|
||||
|
||||
private String serverPort = DEFAULT_PORT;
|
||||
|
||||
private String proxyPort = DEFAULT_PORT;
|
||||
|
||||
private String proxy;
|
||||
|
||||
private String preferredTransport = DEFAULT_TRANSPORT;
|
||||
|
||||
private boolean enablePresence = true;
|
||||
|
||||
private boolean forceP2PMode = false;
|
||||
|
||||
private boolean defaultEncryption = false;
|
||||
|
||||
private boolean sipZrtpAttribute = false;
|
||||
|
||||
private String pollingPeriod = DEFAULT_POLL_PERIOD;
|
||||
|
||||
private String subscriptionExpiration = DEFAULT_SUBSCRIBE_EXPIRES;
|
||||
|
||||
private String keepAliveMethod = DEFAULT_KEEP_ALIVE_METHOD;
|
||||
|
||||
private String keepAliveInterval = DEFAULT_KEEP_ALIVE_INTERVAL;
|
||||
|
||||
/**
|
||||
* Returns the preferred transport to use.
|
||||
* @return the preferred transport to use
|
||||
*/
|
||||
public String getPreferredTransport()
|
||||
{
|
||||
return preferredTransport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preferred transport to use.
|
||||
* @param preferredTransport the transport to set
|
||||
*/
|
||||
public void setPreferredTransport(String preferredTransport)
|
||||
{
|
||||
this.preferredTransport = preferredTransport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the proxy.
|
||||
* @return the proxy
|
||||
*/
|
||||
public String getProxy()
|
||||
{
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy
|
||||
* @param proxy the proxy to set
|
||||
*/
|
||||
public void setProxy(String proxy)
|
||||
{
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password of the sip registration account.
|
||||
*
|
||||
* @return the password of the sip registration account.
|
||||
*/
|
||||
public String getPassword()
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password of the sip registration account.
|
||||
*
|
||||
* @param password the password of the sip registration account.
|
||||
*/
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if password has to remembered, FALSE otherwise.
|
||||
*
|
||||
* @return TRUE if password has to remembered, FALSE otherwise
|
||||
*/
|
||||
public boolean isRememberPassword()
|
||||
{
|
||||
return rememberPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rememberPassword value of this sip account registration.
|
||||
*
|
||||
* @param rememberPassword TRUE if password has to remembered, FALSE
|
||||
* otherwise
|
||||
*/
|
||||
public void setRememberPassword(boolean rememberPassword)
|
||||
{
|
||||
this.rememberPassword = rememberPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the UIN of the sip registration account.
|
||||
*
|
||||
* @return the UIN of the sip registration account.
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
String serverAddress = getServerAddress();
|
||||
|
||||
return
|
||||
((id != null)
|
||||
&& (id.indexOf('@') < 0)
|
||||
&& ((serverAddress == null)
|
||||
|| serverAddress.equals(IPTEL_CONNECT_SRV)))
|
||||
? (id + '@' + IPTEL_CONNECT_SRV)
|
||||
: id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The address of the server we will use for this account
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getServerAddress()
|
||||
{
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* The port on the specified server
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public String getServerPort()
|
||||
{
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* The authorization name
|
||||
*
|
||||
* @return String auth name
|
||||
*/
|
||||
public String getAuthorizationName()
|
||||
{
|
||||
return authorizationName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The port on the specified proxy
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public String getProxyPort()
|
||||
{
|
||||
return proxyPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the identifier of the sip registration account.
|
||||
*
|
||||
* @param id the identifier of the sip registration account.
|
||||
*/
|
||||
public void setUserID(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server
|
||||
*
|
||||
* @param serverAddress String
|
||||
*/
|
||||
public void setServerAddress(String serverAddress)
|
||||
{
|
||||
this.serverAddress = serverAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server port.
|
||||
*
|
||||
* @param port int
|
||||
*/
|
||||
public void setServerPort(String port)
|
||||
{
|
||||
this.serverPort = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets authorization name.
|
||||
*
|
||||
* @param authName String
|
||||
*/
|
||||
public void setAuthorizationName(String authName)
|
||||
{
|
||||
this.authorizationName = authName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy port.
|
||||
*
|
||||
* @param port int
|
||||
*/
|
||||
public void setProxyPort(String port)
|
||||
{
|
||||
this.proxyPort = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the presence is enabled
|
||||
*
|
||||
* @return If the presence is enabled
|
||||
*/
|
||||
public boolean isEnablePresence()
|
||||
{
|
||||
return enablePresence;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the p2p mode is forced
|
||||
*
|
||||
* @return If the p2p mode is forced
|
||||
*/
|
||||
public boolean isForceP2PMode()
|
||||
{
|
||||
return forceP2PMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* The offline contact polling period
|
||||
*
|
||||
* @return the polling period
|
||||
*/
|
||||
public String getPollingPeriod()
|
||||
{
|
||||
return pollingPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default expiration of subscriptions
|
||||
*
|
||||
* @return the subscription expiration
|
||||
*/
|
||||
public String getSubscriptionExpiration()
|
||||
{
|
||||
return subscriptionExpiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the presence is enabled
|
||||
*
|
||||
* @param enablePresence if the presence is enabled
|
||||
*/
|
||||
public void setEnablePresence(boolean enablePresence)
|
||||
{
|
||||
this.enablePresence = enablePresence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if we have to force the p2p mode
|
||||
*
|
||||
* @param forceP2PMode if we have to force the p2p mode
|
||||
*/
|
||||
public void setForceP2PMode(boolean forceP2PMode)
|
||||
{
|
||||
this.forceP2PMode = forceP2PMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the offline contacts polling period
|
||||
*
|
||||
* @param pollingPeriod the offline contacts polling period
|
||||
*/
|
||||
public void setPollingPeriod(String pollingPeriod)
|
||||
{
|
||||
this.pollingPeriod = pollingPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subscription expiration value
|
||||
*
|
||||
* @param subscriptionExpiration the subscription expiration value
|
||||
*/
|
||||
public void setSubscriptionExpiration(String subscriptionExpiration)
|
||||
{
|
||||
this.subscriptionExpiration = subscriptionExpiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the keep alive method.
|
||||
*
|
||||
* @return the keep alive method.
|
||||
*/
|
||||
public String getKeepAliveMethod()
|
||||
{
|
||||
return keepAliveMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the keep alive method.
|
||||
*
|
||||
* @param keepAliveMethod the keep alive method to set
|
||||
*/
|
||||
public void setKeepAliveMethod(String keepAliveMethod)
|
||||
{
|
||||
this.keepAliveMethod = keepAliveMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the keep alive interval.
|
||||
*
|
||||
* @return the keep alive interval
|
||||
*/
|
||||
public String getKeepAliveInterval()
|
||||
{
|
||||
return keepAliveInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the keep alive interval.
|
||||
*
|
||||
* @param keepAliveInterval the keep alive interval to set
|
||||
*/
|
||||
public void setKeepAliveInterval(String keepAliveInterval)
|
||||
{
|
||||
this.keepAliveInterval = keepAliveInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* If default call encryption is enabled
|
||||
*
|
||||
* @return If default call encryption is enabled
|
||||
*/
|
||||
public boolean isDefaultEncryption()
|
||||
{
|
||||
return defaultEncryption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default call encryption
|
||||
*
|
||||
* @param defaultEncryption if we want to set call encryption on as default
|
||||
*/
|
||||
public void setDefaultEncryption(boolean defaultEncryption)
|
||||
{
|
||||
this.defaultEncryption = defaultEncryption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets SIP ZRTP attribute support
|
||||
*
|
||||
* @param sipZrtpAttribute include the ZRTP attribute to SIP/SDP
|
||||
*/
|
||||
public void setSipZrtpAttribute(boolean sipZrtpAttribute) {
|
||||
this.sipZrtpAttribute = sipZrtpAttribute;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if to include the ZRTP attribute to SIP/SDP
|
||||
*
|
||||
* @return include the ZRTP attribute to SIP/SDP
|
||||
*/
|
||||
public boolean isSipZrtpAttribute() {
|
||||
return sipZrtpAttribute;
|
||||
}
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* 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.iptelaccregwizz;
|
||||
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
|
||||
/**
|
||||
* The <tt>Resources</tt> class manages the access to the internationalization
|
||||
* properties files and the image resources used in this plugin.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class Resources
|
||||
{
|
||||
private static ResourceManagementService resourcesService;
|
||||
|
||||
/**
|
||||
* A constant pointing to the IP Tel protocol logo image.
|
||||
*/
|
||||
public static final ImageID PROTOCOL_ICON
|
||||
= new ImageID("service.protocol.iptel.IPTEL_16x16");
|
||||
|
||||
/**
|
||||
* A constant pointing to the IP Tel protocol wizard page image.
|
||||
*/
|
||||
public static final ImageID PAGE_IMAGE
|
||||
= new ImageID("service.protocol.iptel.IPTEL_64x64");
|
||||
|
||||
/**
|
||||
* Returns an internationalized string corresponding to the given key.
|
||||
*
|
||||
* @param key The key of the string.
|
||||
* @return An internationalized string corresponding to the given key.
|
||||
*/
|
||||
public static String getString(String key)
|
||||
{
|
||||
return getResources().getI18NString(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an internationalized string corresponding to the given key.
|
||||
*
|
||||
* @param key The key of the string.
|
||||
* @return An internationalized string corresponding to the given key.
|
||||
*/
|
||||
public static char getMnemonic(String key)
|
||||
{
|
||||
return getResources().getI18nMnemonic(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an image from a given image identifier.
|
||||
*
|
||||
* @param imageID The identifier of the image.
|
||||
* @return The image for the given identifier.
|
||||
*/
|
||||
public static byte[] getImage(ImageID imageID)
|
||||
{
|
||||
return getResources().getImageInBytes(imageID.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resource for the given key. This could be any resource stored
|
||||
* in the resources.properties file of this bundle.
|
||||
*
|
||||
* @param key the key of the resource to search for
|
||||
* @return the resource for the given key
|
||||
*/
|
||||
public static String getProperty(String key)
|
||||
{
|
||||
return getResources().getI18NString(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the service giving access to resources.
|
||||
* @return the service giving access to resources
|
||||
*/
|
||||
public static ResourceManagementService getResources()
|
||||
{
|
||||
if (resourcesService == null)
|
||||
resourcesService = ResourceManagementServiceUtils
|
||||
.getService(IptelAccRegWizzActivator.bundleContext);
|
||||
return resourcesService;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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.sip2sipaccregwizz;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.osgi.framework.*;
|
||||
|
||||
import net.java.sip.communicator.service.browserlauncher.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.service.resources.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
/**
|
||||
* Registers the <tt>GoogleTalkAccountRegistrationWizard</tt> in the UI Service.
|
||||
*
|
||||
* @author Lubomir Marinov
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class Sip2SipAccRegWizzActivator
|
||||
implements BundleActivator
|
||||
{
|
||||
public static BundleContext bundleContext;
|
||||
|
||||
private static final Logger logger = Logger.getLogger(
|
||||
Sip2SipAccRegWizzActivator.class.getName());
|
||||
|
||||
private static BrowserLauncherService browserLauncherService;
|
||||
|
||||
private static ResourceManagementService resourcesService;
|
||||
|
||||
private static UIService uiService;
|
||||
|
||||
/**
|
||||
* Starts this bundle.
|
||||
* @param bc BundleContext
|
||||
* @throws Exception
|
||||
*/
|
||||
public void start(BundleContext bc)
|
||||
throws Exception
|
||||
{
|
||||
bundleContext = bc;
|
||||
|
||||
uiService =
|
||||
(UIService) bundleContext.getService(bundleContext
|
||||
.getServiceReference(UIService.class.getName()));
|
||||
|
||||
Sip2SipAccountRegistrationWizard wizard
|
||||
= new Sip2SipAccountRegistrationWizard(uiService
|
||||
.getAccountRegWizardContainer());
|
||||
|
||||
Hashtable<String, String> containerFilter
|
||||
= new Hashtable<String, String>();
|
||||
containerFilter.put(
|
||||
ProtocolProviderFactory.PROTOCOL,
|
||||
Sip2SipAccountRegistrationWizard.PROTOCOL);
|
||||
|
||||
bundleContext.registerService(
|
||||
AccountRegistrationWizard.class.getName(),
|
||||
wizard,
|
||||
containerFilter);
|
||||
}
|
||||
|
||||
public void stop(BundleContext bundleContext) throws Exception {}
|
||||
|
||||
/**
|
||||
* Returns the <tt>ProtocolProviderFactory</tt> for the IP Tel protocol.
|
||||
*
|
||||
* @return the <tt>ProtocolProviderFactory</tt> for the IP Tel protocol
|
||||
*/
|
||||
public static ProtocolProviderFactory getIptelProtocolProviderFactory()
|
||||
{
|
||||
ServiceReference[] serRefs = null;
|
||||
|
||||
String osgiFilter = "("
|
||||
+ ProtocolProviderFactory.PROTOCOL
|
||||
+ "=" + ProtocolNames.SIP + ")";
|
||||
|
||||
try
|
||||
{
|
||||
serRefs = bundleContext.getServiceReferences(
|
||||
ProtocolProviderFactory.class.getName(), osgiFilter);
|
||||
}
|
||||
catch (InvalidSyntaxException ex)
|
||||
{
|
||||
logger.error("IptelAccRegWizzActivator : " + ex);
|
||||
}
|
||||
|
||||
return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>UIService</tt>.
|
||||
*
|
||||
* @return the <tt>UIService</tt>
|
||||
*/
|
||||
public static UIService getUIService()
|
||||
{
|
||||
return uiService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
|
||||
* context.
|
||||
* @return the <tt>BrowserLauncherService</tt> obtained from the bundle
|
||||
* context
|
||||
*/
|
||||
public static BrowserLauncherService getBrowserLauncher()
|
||||
{
|
||||
if (browserLauncherService == null)
|
||||
{
|
||||
browserLauncherService
|
||||
= (BrowserLauncherService) bundleContext.getService(
|
||||
bundleContext.getServiceReference(
|
||||
BrowserLauncherService.class.getName()));
|
||||
}
|
||||
return browserLauncherService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the service giving access to resources.
|
||||
* @return the service giving access to resources
|
||||
*/
|
||||
public static ResourceManagementService getResources()
|
||||
{
|
||||
if (resourcesService == null)
|
||||
resourcesService = ResourceManagementServiceUtils
|
||||
.getService(Sip2SipAccRegWizzActivator.bundleContext);
|
||||
return resourcesService;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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.sip2sipaccregwizz;
|
||||
|
||||
import net.java.sip.communicator.plugin.sipaccregwizz.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
|
||||
/**
|
||||
* The <tt>Sip2SipAccountRegistrationWizard</tt> is an implementation of the
|
||||
* <tt>AccountRegistrationWizard</tt> for the SIP protocol. It should allow
|
||||
* the user to create and configure a new IP Tel SIP account.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class Sip2SipAccountRegistrationWizard
|
||||
extends SIPAccountRegistrationWizard
|
||||
{
|
||||
/**
|
||||
* A constant pointing to the IP Tel protocol logo image.
|
||||
*/
|
||||
private static final String PROTOCOL_ICON
|
||||
= "service.protocol.sip2sip.SIP2SIP_16x16";
|
||||
|
||||
/**
|
||||
* A constant pointing to the IP Tel protocol wizard page image.
|
||||
*/
|
||||
private static final String PAGE_IMAGE
|
||||
= "service.protocol.sip2sip.SIP2SIP_64x64";
|
||||
|
||||
/**
|
||||
* The protocol name.
|
||||
*/
|
||||
public static final String PROTOCOL = "sip2sip.info";
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>IptelAccountRegistrationWizard</tt>.
|
||||
* @param wizardContainer the wizard container
|
||||
*/
|
||||
public Sip2SipAccountRegistrationWizard(WizardContainer wizardContainer)
|
||||
{
|
||||
super(wizardContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <code>AccountRegistrationWizard.getIcon</code> method.
|
||||
* Returns the icon to be used for this wizard.
|
||||
* @return byte[]
|
||||
*/
|
||||
public byte[] getIcon()
|
||||
{
|
||||
return Sip2SipAccRegWizzActivator.getResources()
|
||||
.getImageInBytes(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 Sip2SipAccRegWizzActivator.getResources()
|
||||
.getImageInBytes(PAGE_IMAGE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements the <code>AccountRegistrationWizard.getProtocolName</code>
|
||||
* method. Returns the protocol name for this wizard.
|
||||
* @return String
|
||||
*/
|
||||
public String getProtocolName()
|
||||
{
|
||||
return Resources.getString(
|
||||
"plugin.sip2sipaccregwizz.PROTOCOL_NAME");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the <code>AccountRegistrationWizard.getProtocolDescription
|
||||
* </code> method. Returns the description of the protocol for this wizard.
|
||||
* @return String
|
||||
*/
|
||||
public String getProtocolDescription()
|
||||
{
|
||||
return Resources.getString(
|
||||
"plugin.sip2sipaccregwizz.PROTOCOL_DESCRIPTION");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 String getUserNameExample()
|
||||
{
|
||||
return "Ex: myusername or myusername@sip2sip.info";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol name as listed in "ProtocolNames" or just the name
|
||||
* of the service.
|
||||
* @return the protocol name
|
||||
*/
|
||||
public String getProtocol()
|
||||
{
|
||||
return PROTOCOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the protocol icon path.
|
||||
* @return the protocol icon path
|
||||
*/
|
||||
public String getProtocolIconPath()
|
||||
{
|
||||
return "resources/images/protocol/sip2sip";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the account icon path.
|
||||
* @return the account icon path
|
||||
*/
|
||||
public String getAccountIconPath()
|
||||
{
|
||||
return "resources/images/protocol/sip2sip/sip32x32.png";
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the browser on the page sign up
|
||||
*/
|
||||
public void webSignup()
|
||||
{
|
||||
Sip2SipAccRegWizzActivator.getBrowserLauncher()
|
||||
.openURL("https://secure.dns-hosting.info/register_sip_account.phtml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the web sign up link.
|
||||
* @return the name of the web sign up link
|
||||
*/
|
||||
public String getWebSignupLinkName()
|
||||
{
|
||||
return Resources.getString("plugin.sip2sipaccregwizz.NEW_ACCOUNT_TITLE");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
Bundle-Activator: net.java.sip.communicator.plugin.sip2sipaccregwizz.Sip2SipAccRegWizzActivator
|
||||
Bundle-Name: Sip 2 Sip account registration wizard
|
||||
Bundle-Description: Sip 2 Sip account registration wizard.
|
||||
Bundle-Vendor: sip-communicator.org
|
||||
Bundle-Version: 0.0.1
|
||||
System-Bundle: yes
|
||||
Import-Package: org.osgi.framework,
|
||||
net.java.sip.communicator.service.browserlauncher,
|
||||
net.java.sip.communicator.service.configuration,
|
||||
net.java.sip.communicator.service.configuration.event,
|
||||
net.java.sip.communicator.service.contactlist,
|
||||
net.java.sip.communicator.service.contactlist.event,
|
||||
net.java.sip.communicator.service.fileaccess,
|
||||
net.java.sip.communicator.service.gui,
|
||||
net.java.sip.communicator.service.gui.event,
|
||||
net.java.sip.communicator.service.protocol,
|
||||
net.java.sip.communicator.service.protocol.event,
|
||||
net.java.sip.communicator.service.protocol.icqconstants,
|
||||
net.java.sip.communicator.service.resources,
|
||||
net.java.sip.communicator.util,
|
||||
net.java.sip.communicator.util.swing,
|
||||
net.java.sip.communicator.plugin.sipaccregwizz,
|
||||
javax.naming,
|
||||
javax.naming.directory,
|
||||
javax.xml.parsers,
|
||||
org.w3c.dom,
|
||||
org.xml.sax,
|
||||
javax.swing,
|
||||
javax.swing.event,
|
||||
javax.swing.table,
|
||||
javax.swing.text,
|
||||
javax.swing.text.html,
|
||||
javax.accessibility,
|
||||
javax.swing.plaf,
|
||||
javax.swing.plaf.metal,
|
||||
javax.swing.plaf.basic,
|
||||
javax.imageio,
|
||||
javax.swing.filechooser,
|
||||
javax.swing.tree,
|
||||
javax.swing.undo,
|
||||
javax.swing.border,
|
||||
org.jivesoftware.smack
|
||||
@ -0,0 +1,271 @@
|
||||
/*
|
||||
* 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.sipaccregwizz;
|
||||
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* The panel containing all account related information like user name and
|
||||
* password.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class AccountPanel
|
||||
extends TransparentPanel
|
||||
implements DocumentListener
|
||||
{
|
||||
private final Logger logger = Logger.getLogger(AccountPanel.class);
|
||||
|
||||
private final JPanel labelsPanel
|
||||
= new TransparentPanel(new GridLayout(0, 1));
|
||||
|
||||
private JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1));
|
||||
|
||||
private JPanel emptyPanel = new TransparentPanel();
|
||||
|
||||
private JTextField userIDField = new JTextField();
|
||||
|
||||
private JPasswordField passField = new JPasswordField();
|
||||
|
||||
private final JTextField displayNameField = new JTextField();
|
||||
|
||||
private JCheckBox rememberPassBox
|
||||
= new SIPCommCheckBox(
|
||||
Resources.getString("service.gui.REMEMBER_PASSWORD"));
|
||||
|
||||
private final JLabel displayNameLabel
|
||||
= new JLabel(Resources.getString("plugin.sipaccregwizz.DISPLAY_NAME"));
|
||||
|
||||
private final SIPAccountRegistrationForm regform;
|
||||
|
||||
/**
|
||||
* Creates an instance of the <tt>AccountPanel</tt>.
|
||||
* @param regform the parent registration form
|
||||
*/
|
||||
public AccountPanel(SIPAccountRegistrationForm regform)
|
||||
{
|
||||
super (new BorderLayout());
|
||||
|
||||
this.regform = regform;
|
||||
|
||||
this.userIDField.getDocument().addDocumentListener(this);
|
||||
|
||||
this.rememberPassBox.setSelected(true);
|
||||
|
||||
JLabel uinExampleLabel = new JLabel(regform.getUsernameExample());
|
||||
uinExampleLabel.setForeground(Color.GRAY);
|
||||
uinExampleLabel.setFont(uinExampleLabel.getFont().deriveFont(8));
|
||||
emptyPanel.setMaximumSize(new Dimension(40, 35));
|
||||
uinExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
|
||||
|
||||
JPanel uinPassPanel
|
||||
= new TransparentPanel(new BorderLayout(10, 10));
|
||||
|
||||
JLabel uinLabel
|
||||
= new JLabel(Resources.getString("plugin.sipaccregwizz.USERNAME"));
|
||||
|
||||
JLabel passLabel
|
||||
= new JLabel(Resources.getString("service.gui.PASSWORD"));
|
||||
|
||||
labelsPanel.add(uinLabel);
|
||||
labelsPanel.add(emptyPanel);
|
||||
labelsPanel.add(passLabel);
|
||||
|
||||
valuesPanel.add(userIDField);
|
||||
valuesPanel.add(uinExampleLabel);
|
||||
valuesPanel.add(passField);
|
||||
|
||||
TransparentPanel southPanel
|
||||
= new TransparentPanel(new GridLayout(1, 2));
|
||||
|
||||
uinPassPanel.add(labelsPanel, BorderLayout.WEST);
|
||||
uinPassPanel.add(valuesPanel, BorderLayout.CENTER);
|
||||
uinPassPanel.add(southPanel, BorderLayout.SOUTH);
|
||||
|
||||
southPanel.add(rememberPassBox);
|
||||
|
||||
String webSignup = regform.getWebSignupLinkName();
|
||||
if (webSignup != null)
|
||||
{
|
||||
southPanel.add(createSubscribeLabel(webSignup));
|
||||
}
|
||||
|
||||
uinPassPanel.setBorder(BorderFactory.createTitledBorder(Resources
|
||||
.getString("plugin.sipaccregwizz.USERNAME_AND_PASSWORD")));
|
||||
|
||||
this.add(uinPassPanel, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the advanced account panel.
|
||||
*/
|
||||
void initAdvancedForm()
|
||||
{
|
||||
// If it's not yet added.
|
||||
if (displayNameLabel.getParent() == null)
|
||||
labelsPanel.add(displayNameLabel);
|
||||
|
||||
// If it's not yet added.
|
||||
if (displayNameField.getParent() == null)
|
||||
valuesPanel.add(displayNameField);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the <tt>DocumentEvent</tt> triggered when user types in the UIN
|
||||
* field. Enables or disables the "Next" wizard button according to whether
|
||||
* the UIN field is empty.
|
||||
* @param e the <tt>DocumentEvent</tt> that notified us
|
||||
*/
|
||||
public void insertUpdate(DocumentEvent e)
|
||||
{
|
||||
regform.setNextFinishButtonEnabled(userIDField.getText() == null
|
||||
|| userIDField.getText().equals(""));
|
||||
regform.setServerFieldAccordingToUIN(userIDField.getText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
|
||||
* from the UIN field. Enables or disables the "Next" wizard button
|
||||
* according to whether the UIN field is empty.
|
||||
* @param e the <tt>DocumentEvent</tt> that notified us
|
||||
*/
|
||||
public void removeUpdate(DocumentEvent e)
|
||||
{
|
||||
regform.setNextFinishButtonEnabled(userIDField.getText() == null
|
||||
|| userIDField.getText().equals(""));
|
||||
regform.setServerFieldAccordingToUIN(userIDField.getText());
|
||||
}
|
||||
|
||||
public void changedUpdate(DocumentEvent e) {}
|
||||
|
||||
/**
|
||||
* Returns the user identifier entered by the user.
|
||||
* @return the user identifier
|
||||
*/
|
||||
String getUserID()
|
||||
{
|
||||
return userIDField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password entered by the user.
|
||||
* @return the password
|
||||
*/
|
||||
char[] getPassword()
|
||||
{
|
||||
return passField.getPassword();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the "remember password" check 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name of the account.
|
||||
* @return the display name of the account
|
||||
*/
|
||||
String getDisplayName()
|
||||
{
|
||||
return displayNameField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display name of the account.
|
||||
* @param displayName the display name of the account
|
||||
*/
|
||||
void setDisplayName(String displayName)
|
||||
{
|
||||
displayNameField.setText(displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables the user id text field.
|
||||
* @param isEnabled <tt>true</tt> to enable the user id text field,
|
||||
* <tt>false</tt> - otherwise
|
||||
*/
|
||||
void setUserIDEnabled(boolean isEnabled)
|
||||
{
|
||||
userIDField.setEnabled(isEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user id.
|
||||
* @param userID the user id to set
|
||||
*/
|
||||
void setUserID(String userID)
|
||||
{
|
||||
userIDField.setText(userID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password
|
||||
* @param password the password
|
||||
*/
|
||||
void setPassword(String password)
|
||||
{
|
||||
this.passField.setText(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password remember check box.
|
||||
* @param isRememberPassword <tt>true</tt> to select the remember password
|
||||
* check box, <tt>false</tt> - otherwise
|
||||
*/
|
||||
void setRememberPassword(boolean isRememberPassword)
|
||||
{
|
||||
rememberPassBox.setSelected(isRememberPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the subscribe label.
|
||||
* @param linkName the link name
|
||||
* @return the newly created subscribe label
|
||||
*/
|
||||
private Component createSubscribeLabel(String linkName)
|
||||
{
|
||||
JLabel subscribeLabel =
|
||||
new JLabel("<html><a href=''>"
|
||||
+ linkName
|
||||
+ "</a></html>",
|
||||
JLabel.RIGHT);
|
||||
|
||||
subscribeLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
subscribeLabel.setToolTipText(
|
||||
Resources.getString("plugin.simpleaccregwizz.SPECIAL_SIGNUP"));
|
||||
subscribeLabel.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
public void mousePressed(MouseEvent e)
|
||||
{
|
||||
try
|
||||
{
|
||||
regform.webSignup();
|
||||
}
|
||||
catch (UnsupportedOperationException ex)
|
||||
{
|
||||
// This should not happen, because we check if the
|
||||
// operation is supported, before adding the sign
|
||||
// up.
|
||||
logger.error("The web sign up is not supported.",
|
||||
ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
return subscribeLabel;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,453 @@
|
||||
/*
|
||||
* 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.sipaccregwizz;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.util.swing.*;
|
||||
|
||||
/**
|
||||
* The panel containing information about the connection.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class ConnectionPanel
|
||||
extends TransparentPanel
|
||||
implements ItemListener
|
||||
{
|
||||
private final JCheckBox enableDefaultEncryption =
|
||||
new SIPCommCheckBox(Resources
|
||||
.getString("plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"), true);
|
||||
|
||||
private final JCheckBox enableSipZrtpAttribute =
|
||||
new SIPCommCheckBox(Resources
|
||||
.getString("plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"), true);
|
||||
|
||||
private final JTextField serverField = new JTextField();
|
||||
|
||||
private final JTextField proxyField = new JTextField();
|
||||
|
||||
private final JTextField authNameField = new JTextField();
|
||||
|
||||
private final JTextField serverPortField
|
||||
= new JTextField(SIPAccountRegistration.DEFAULT_PORT);
|
||||
|
||||
private final JTextField proxyPortField
|
||||
= new JTextField(SIPAccountRegistration.DEFAULT_PORT);
|
||||
|
||||
private JComboBox transportCombo = new JComboBox(new Object[]
|
||||
{ "UDP", "TCP", "TLS" });
|
||||
|
||||
private JComboBox keepAliveMethodBox
|
||||
= new JComboBox(new Object []
|
||||
{
|
||||
"REGISTER",
|
||||
"OPTIONS"
|
||||
});
|
||||
|
||||
private JTextField keepAliveIntervalValue = new JTextField();
|
||||
|
||||
private boolean isServerOverridden = false;
|
||||
|
||||
private SIPAccountRegistrationForm regform;
|
||||
|
||||
/**
|
||||
* Creates an instance of the <tt>ConnectionPanel</tt>.
|
||||
* @param regform the parent registration form
|
||||
*/
|
||||
public ConnectionPanel(SIPAccountRegistrationForm regform)
|
||||
{
|
||||
super(new BorderLayout());
|
||||
|
||||
this.regform = regform;
|
||||
|
||||
this.transportCombo.addItemListener(this);
|
||||
|
||||
transportCombo.setSelectedItem(
|
||||
SIPAccountRegistration.DEFAULT_TRANSPORT);
|
||||
|
||||
JPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));
|
||||
|
||||
JPanel labelsPanel
|
||||
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
JPanel valuesPanel
|
||||
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
JLabel serverLabel
|
||||
= new JLabel(Resources.getString("plugin.sipaccregwizz.REGISTRAR"));
|
||||
|
||||
JLabel proxyLabel
|
||||
= new JLabel(Resources.getString("plugin.sipaccregwizz.PROXY"));
|
||||
|
||||
JLabel authNameLabel
|
||||
= new JLabel(Resources.getString(
|
||||
"plugin.sipaccregwizz.AUTH_NAME"));
|
||||
|
||||
JLabel serverPortLabel
|
||||
= new JLabel(Resources.getString(
|
||||
"plugin.sipaccregwizz.SERVER_PORT"));
|
||||
|
||||
JLabel proxyPortLabel
|
||||
= new JLabel(Resources.getString(
|
||||
"plugin.sipaccregwizz.PROXY_PORT"));
|
||||
|
||||
JLabel transportLabel
|
||||
= new JLabel(Resources.getString(
|
||||
"plugin.sipaccregwizz.PREFERRED_TRANSPORT"));
|
||||
|
||||
labelsPanel.add(serverLabel);
|
||||
labelsPanel.add(authNameLabel);
|
||||
labelsPanel.add(serverPortLabel);
|
||||
labelsPanel.add(proxyLabel);
|
||||
labelsPanel.add(proxyPortLabel);
|
||||
labelsPanel.add(transportLabel);
|
||||
|
||||
valuesPanel.add(serverField);
|
||||
valuesPanel.add(authNameField);
|
||||
valuesPanel.add(serverPortField);
|
||||
valuesPanel.add(proxyField);
|
||||
valuesPanel.add(proxyPortField);
|
||||
valuesPanel.add(transportCombo);
|
||||
|
||||
mainPanel.add(labelsPanel, BorderLayout.WEST);
|
||||
mainPanel.add(valuesPanel, BorderLayout.CENTER);
|
||||
|
||||
JPanel encryptionPanel
|
||||
= new TransparentPanel(new GridLayout(1, 2, 2, 2));
|
||||
|
||||
encryptionPanel.add(enableDefaultEncryption, BorderLayout.WEST);
|
||||
encryptionPanel.add(enableSipZrtpAttribute, BorderLayout.EAST);
|
||||
|
||||
enableDefaultEncryption.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
// Perform action
|
||||
JCheckBox cb = (JCheckBox) evt.getSource();
|
||||
|
||||
enableSipZrtpAttribute.setEnabled(cb.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
mainPanel.add(encryptionPanel, BorderLayout.SOUTH);
|
||||
|
||||
mainPanel.setBorder(BorderFactory.createTitledBorder(Resources
|
||||
.getString("plugin.sipaccregwizz.ADVANCED_OPTIONS")));
|
||||
|
||||
this.add(mainPanel, BorderLayout.NORTH);
|
||||
this.add(createKeepAlivePanel(), BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the server part from the sip id and set it to server as default
|
||||
* value. If Advanced option is enabled Do nothing.
|
||||
* @param serverAddress the address of the server
|
||||
*/
|
||||
public void setServerFieldAccordingToUIN(String serverAddress)
|
||||
{
|
||||
if (!regform.isModification() || !isServerOverridden)
|
||||
{
|
||||
serverField.setText(serverAddress);
|
||||
proxyField.setText(serverAddress);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that the state of the item has changed.
|
||||
* @param e the <tt>ItemEvent</tt> that notified us
|
||||
*/
|
||||
public void itemStateChanged(ItemEvent e)
|
||||
{
|
||||
if (e.getStateChange() == ItemEvent.SELECTED
|
||||
&& e.getItem().equals("TLS"))
|
||||
{
|
||||
serverPortField.setText(SIPAccountRegistration.DEFAULT_TLS_PORT);
|
||||
proxyPortField.setText(SIPAccountRegistration.DEFAULT_TLS_PORT);
|
||||
}
|
||||
else
|
||||
{
|
||||
serverPortField.setText(SIPAccountRegistration.DEFAULT_PORT);
|
||||
proxyPortField.setText(SIPAccountRegistration.DEFAULT_PORT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the keep alive panel.
|
||||
* @return the created keep alive panel
|
||||
*/
|
||||
private Component createKeepAlivePanel()
|
||||
{
|
||||
JPanel emptyLabelPanel = new TransparentPanel();
|
||||
emptyLabelPanel.setMaximumSize(new Dimension(40, 35));
|
||||
|
||||
JPanel keepAlivePanel
|
||||
= new TransparentPanel(new BorderLayout(10, 10));
|
||||
|
||||
JPanel keepAliveLabels
|
||||
= new TransparentPanel(new GridLayout(0, 1, 5, 5));
|
||||
|
||||
JPanel keepAliveValues
|
||||
= new TransparentPanel(new GridLayout(0, 1, 5, 5));
|
||||
|
||||
JLabel keepAliveMethodLabel = new JLabel(
|
||||
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_METHOD"));
|
||||
|
||||
JLabel keepAliveIntervalLabel = new JLabel(
|
||||
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_INTERVAL"));
|
||||
|
||||
JLabel keepAliveIntervalExampleLabel = new JLabel(
|
||||
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE_INTERVAL_INFO"));
|
||||
|
||||
keepAliveLabels.add(keepAliveMethodLabel);
|
||||
keepAliveLabels.add(keepAliveIntervalLabel);
|
||||
keepAliveLabels.add(emptyLabelPanel);
|
||||
|
||||
keepAliveIntervalExampleLabel.setForeground(Color.GRAY);
|
||||
keepAliveIntervalExampleLabel
|
||||
.setFont(keepAliveIntervalExampleLabel.getFont().deriveFont(8));
|
||||
keepAliveIntervalExampleLabel
|
||||
.setMaximumSize(new Dimension(40, 35));
|
||||
keepAliveIntervalExampleLabel
|
||||
.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
|
||||
|
||||
keepAliveIntervalValue
|
||||
.setText(SIPAccountRegistration.DEFAULT_KEEP_ALIVE_INTERVAL);
|
||||
|
||||
keepAliveMethodBox.setSelectedItem(
|
||||
SIPAccountRegistration.DEFAULT_KEEP_ALIVE_METHOD);
|
||||
|
||||
keepAliveValues.add(keepAliveMethodBox);
|
||||
keepAliveValues.add(keepAliveIntervalValue);
|
||||
keepAliveValues.add(keepAliveIntervalExampleLabel);
|
||||
|
||||
keepAlivePanel.add(keepAliveLabels, BorderLayout.WEST);
|
||||
keepAlivePanel.add(keepAliveValues, BorderLayout.CENTER);
|
||||
|
||||
keepAlivePanel.setBorder(BorderFactory.createTitledBorder(
|
||||
Resources.getString("plugin.sipaccregwizz.KEEP_ALIVE")));
|
||||
|
||||
return keepAlivePanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables the server text field.
|
||||
* @param isEnabled <tt>true</tt> to enable the server text field,
|
||||
* <tt>false</tt> - otherwise
|
||||
*/
|
||||
void setServerEnabled(boolean isEnabled)
|
||||
{
|
||||
serverField.setEnabled(isEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the authentication name.
|
||||
* @return the authentication name
|
||||
*/
|
||||
String getAuthenticationName()
|
||||
{
|
||||
return authNameField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the authentication name.
|
||||
* @param authName the authentication name
|
||||
*/
|
||||
void setAuthenticationName(String authName)
|
||||
{
|
||||
authNameField.setText(authName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server port.
|
||||
* @return the server port
|
||||
*/
|
||||
String getServerPort()
|
||||
{
|
||||
return serverPortField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server port.
|
||||
* @param serverPort the server port
|
||||
*/
|
||||
void setServerPort(String serverPort)
|
||||
{
|
||||
serverPortField.setText(serverPort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the proxy.
|
||||
* @return the proxy
|
||||
*/
|
||||
String getProxy()
|
||||
{
|
||||
return proxyField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy address.
|
||||
* @param proxyAddress the proxy address
|
||||
*/
|
||||
void setProxy(String proxyAddress)
|
||||
{
|
||||
proxyField.setText(proxyAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the proxy port.
|
||||
* @return the proxy port
|
||||
*/
|
||||
String getProxyPort()
|
||||
{
|
||||
return proxyPortField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy port.
|
||||
* @param proxyPort the proxy port
|
||||
*/
|
||||
void setProxyPort(String proxyPort)
|
||||
{
|
||||
proxyPortField.setText(proxyPort);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected transport.
|
||||
* @return the selected transport
|
||||
*/
|
||||
String getSelectedTransport()
|
||||
{
|
||||
//Emil: it appears that sometimes the selected item may be null even
|
||||
//though the combo box does not allow a null selection.
|
||||
Object selectedItem = transportCombo.getSelectedItem();
|
||||
|
||||
if(selectedItem == null)
|
||||
selectedItem = transportCombo.getItemAt(0);
|
||||
|
||||
return selectedItem.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the selected transport.
|
||||
* @param preferredTransport the transport to select
|
||||
*/
|
||||
void setSelectedTransport(String preferredTransport)
|
||||
{
|
||||
transportCombo.setSelectedItem(preferredTransport);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the default encryption is enabled.
|
||||
* @return <tt>true</tt> if the default encryption is enabled,
|
||||
* <tt>false</tt> - otherwise
|
||||
*/
|
||||
boolean isDefaultEncryptionEnabled()
|
||||
{
|
||||
return enableDefaultEncryption.isSelected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables the default encryption.
|
||||
* @param isEnable <tt>true</tt> to enable the default encryption,
|
||||
* <tt>false</tt> - otherwise
|
||||
*/
|
||||
void enablesDefaultEncryption(boolean isEnable)
|
||||
{
|
||||
enableDefaultEncryption.setSelected(isEnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the ZRTP encryption is enabled.
|
||||
* @return <tt>true</tt> if <tt>ZRTP</tt> is enabled, <tt>false</tt> -
|
||||
* otherwise
|
||||
*/
|
||||
boolean isSipZrtpEnabled()
|
||||
{
|
||||
return enableSipZrtpAttribute.isSelected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables and selects/deselects the sip zrtp checkbox.
|
||||
* @param isSipZrtpEnabled indicates if the sip zrtp is enabled
|
||||
* @param isDefaultEncryptionEnabled indicates if the default encryption is
|
||||
* enabled
|
||||
*/
|
||||
void setSipZrtpEnabled( boolean isSipZrtpEnabled,
|
||||
boolean isDefaultEncryptionEnabled)
|
||||
{
|
||||
enableSipZrtpAttribute.setSelected(isSipZrtpEnabled);
|
||||
enableSipZrtpAttribute.setEnabled(isDefaultEncryptionEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the keep alive method.
|
||||
* @return the keep alive method
|
||||
*/
|
||||
String getKeepAliveMethod()
|
||||
{
|
||||
return keepAliveMethodBox.getSelectedItem().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the keep alive method.
|
||||
* @param keepAliveMethod the keep alive method
|
||||
*/
|
||||
void setKeepAliveMethod(String keepAliveMethod)
|
||||
{
|
||||
keepAliveMethodBox.setSelectedItem(keepAliveMethod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the keep alive interval
|
||||
* @return the keep alive interval
|
||||
*/
|
||||
String getKeepAliveInterval()
|
||||
{
|
||||
return keepAliveIntervalValue.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the keep alive interval
|
||||
* @param keepAliveInterval the keep alive interval
|
||||
*/
|
||||
void setKeepAliveInterval(String keepAliveInterval)
|
||||
{
|
||||
keepAliveIntervalValue.setText(keepAliveInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>serverOverridden</tt> property.
|
||||
* @param isServerOverridden <tt>true</tt> to indicate that the server is
|
||||
* overridden, <tt>false</tt> - otherwise
|
||||
*/
|
||||
void setServerOverridden(boolean isServerOverridden)
|
||||
{
|
||||
this.isServerOverridden = isServerOverridden;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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.sipaccregwizz;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.util.swing.*;
|
||||
|
||||
/**
|
||||
* The <tt>PresencePanel</tt> is the one containing presence information.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class PresencePanel
|
||||
extends TransparentPanel
|
||||
{
|
||||
private JPanel presenceOpPanel
|
||||
= new TransparentPanel(new BorderLayout(10, 10));
|
||||
|
||||
private JPanel buttonsPresOpPanel =
|
||||
new TransparentPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
private JPanel labelsPresOpPanel
|
||||
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
private JPanel valuesPresOpPanel
|
||||
= new TransparentPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
private JCheckBox enablePresOpButton =
|
||||
new SIPCommCheckBox(Resources
|
||||
.getString("plugin.sipaccregwizz.ENABLE_PRESENCE"), true);
|
||||
|
||||
private JCheckBox forceP2PPresOpButton =
|
||||
new SIPCommCheckBox(Resources
|
||||
.getString("plugin.sipaccregwizz.FORCE_P2P_PRESENCE"), false);
|
||||
|
||||
private JLabel pollPeriodLabel = new JLabel(
|
||||
Resources.getString(
|
||||
"plugin.sipaccregwizz.OFFLINE_CONTACT_POLLING_PERIOD"));
|
||||
|
||||
private JLabel subscribeExpiresLabel = new JLabel(
|
||||
Resources.getString("plugin.sipaccregwizz.SUBSCRIPTION_EXPIRATION"));
|
||||
|
||||
private JTextField pollPeriodField
|
||||
= new JTextField(SIPAccountRegistration.DEFAULT_POLL_PERIOD);
|
||||
|
||||
private JTextField subscribeExpiresField =
|
||||
new JTextField(SIPAccountRegistration.DEFAULT_SUBSCRIBE_EXPIRES);
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>PresencePanel</tt>.
|
||||
*/
|
||||
public PresencePanel()
|
||||
{
|
||||
super(new BorderLayout());
|
||||
|
||||
enablePresOpButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
// Perform action
|
||||
JCheckBox cb = (JCheckBox) evt.getSource();
|
||||
|
||||
setPresenceOptionsEnabled(cb.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
labelsPresOpPanel.add(pollPeriodLabel);
|
||||
labelsPresOpPanel.add(subscribeExpiresLabel);
|
||||
|
||||
valuesPresOpPanel.add(pollPeriodField);
|
||||
valuesPresOpPanel.add(subscribeExpiresField);
|
||||
|
||||
buttonsPresOpPanel.add(enablePresOpButton);
|
||||
buttonsPresOpPanel.add(forceP2PPresOpButton);
|
||||
|
||||
presenceOpPanel.add(buttonsPresOpPanel, BorderLayout.NORTH);
|
||||
presenceOpPanel.add(labelsPresOpPanel, BorderLayout.WEST);
|
||||
presenceOpPanel.add(valuesPresOpPanel, BorderLayout.CENTER);
|
||||
|
||||
presenceOpPanel.setBorder(BorderFactory.createTitledBorder(
|
||||
Resources.getString("plugin.sipaccregwizz.PRESENCE_OPTIONS")));
|
||||
|
||||
this.add(presenceOpPanel, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disable all presence related options.
|
||||
*
|
||||
* @param isEnabled <code>true</code> to enable the presence related
|
||||
* options, <code>false</code> - to disable them.
|
||||
*/
|
||||
void setPresenceOptionsEnabled(boolean isEnabled)
|
||||
{
|
||||
forceP2PPresOpButton.setEnabled(isEnabled);
|
||||
pollPeriodField.setEnabled(isEnabled);
|
||||
subscribeExpiresField.setEnabled(isEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the presence is enabled.
|
||||
* @return <tt>true</tt> if the presence is enabled, <tt>false</tt> -
|
||||
* otherwise
|
||||
*/
|
||||
boolean isPresenceEnabled()
|
||||
{
|
||||
return enablePresOpButton.isSelected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables the presence.
|
||||
* @param isPresenceEnabled <tt>true</tt> to enable the presence,
|
||||
* <tt>false</tt> - otherwise
|
||||
*/
|
||||
void setPresenceEnabled(boolean isPresenceEnabled)
|
||||
{
|
||||
enablePresOpButton.setSelected(isPresenceEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the peer-to-peer presence mode is selected.
|
||||
* @return <tt>true</tt> if the peer-to-peer presence mode is selected,
|
||||
* <tt>false</tt> - otherwise.
|
||||
*/
|
||||
boolean isForcePeerToPeerMode()
|
||||
{
|
||||
return forceP2PPresOpButton.isSelected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables the peer-to-peer presence mode.
|
||||
* @param forceP2P <tt>true</tt> to select the peer-to-peer presence mode,
|
||||
* <tt>false</tt> - otherwise.
|
||||
*/
|
||||
void setForcePeerToPeerMode(boolean forceP2P)
|
||||
{
|
||||
forceP2PPresOpButton.setSelected(forceP2P);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the poll period.
|
||||
* @return the poll period
|
||||
*/
|
||||
String getPollPeriod()
|
||||
{
|
||||
return pollPeriodField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the poll period.
|
||||
* @param pollPeriod the poll period
|
||||
*/
|
||||
void setPollPeriod(String pollPeriod)
|
||||
{
|
||||
pollPeriodField.setText(pollPeriod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subscription expiration information.
|
||||
* @return the subscription expiration information
|
||||
*/
|
||||
String getSubscriptionExpiration()
|
||||
{
|
||||
return subscribeExpiresField.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the subscription expiration information.
|
||||
* @param subscExp the subscription expiration information
|
||||
*/
|
||||
void setSubscriptionExpiration(String subscExp)
|
||||
{
|
||||
subscribeExpiresField.setText(subscExp);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,331 @@
|
||||
package net.java.sip.communicator.plugin.sipaccregwizz;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.util.swing.*;
|
||||
|
||||
/**
|
||||
* The <tt>SIPAccountRegistrationForm</tt>.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class SIPAccountRegistrationForm
|
||||
extends TransparentPanel
|
||||
{
|
||||
private final AccountPanel accountPanel;
|
||||
|
||||
private final ConnectionPanel connectionPanel;
|
||||
|
||||
private final PresencePanel presencePanel;
|
||||
|
||||
private boolean isModification;
|
||||
|
||||
private final SIPAccountRegistrationWizard wizard;
|
||||
|
||||
private final JTabbedPane tabbedPane = new SIPCommTabbedPane(false, false);
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>SIPAccountRegistrationForm</tt>.
|
||||
* @param wizard the parent wizard
|
||||
*/
|
||||
public SIPAccountRegistrationForm(SIPAccountRegistrationWizard wizard)
|
||||
{
|
||||
super(new BorderLayout());
|
||||
|
||||
this.wizard = wizard;
|
||||
|
||||
accountPanel = new AccountPanel(this);
|
||||
|
||||
connectionPanel = new ConnectionPanel(this);
|
||||
|
||||
presencePanel = new PresencePanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all panels, buttons, etc.
|
||||
*/
|
||||
void init()
|
||||
{
|
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
accountPanel.initAdvancedForm();
|
||||
|
||||
if (accountPanel.getParent() != tabbedPane)
|
||||
tabbedPane.addTab( Resources.getString("service.gui.ACCOUNT"),
|
||||
accountPanel);
|
||||
|
||||
if (connectionPanel.getParent() != tabbedPane)
|
||||
tabbedPane.addTab(Resources.getString("service.gui.CONNECTION"),
|
||||
connectionPanel);
|
||||
|
||||
if (presencePanel.getParent() != tabbedPane)
|
||||
tabbedPane.addTab(Resources.getString("service.gui.PRESENCE"),
|
||||
presencePanel);
|
||||
|
||||
if (tabbedPane.getParent() != this)
|
||||
this.add(tabbedPane, BorderLayout.NORTH);
|
||||
|
||||
tabbedPane.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the server part from the sip id and set it to server as default
|
||||
* value. If Advanced option is enabled Do nothing.
|
||||
* @param userName the account user name
|
||||
*/
|
||||
void setServerFieldAccordingToUIN(String userName)
|
||||
{
|
||||
String serverAddress = getServerFromUserName(userName);
|
||||
|
||||
connectionPanel.setServerFieldAccordingToUIN(serverAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables the next/finish button of the parent wizard.
|
||||
* @param isEnabled <tt>true</tt> to enable the next button, <tt>false</tt>
|
||||
* otherwise
|
||||
*/
|
||||
void setNextFinishButtonEnabled(boolean isEnabled)
|
||||
{
|
||||
SIPAccRegWizzActivator.getUIService().getAccountRegWizardContainer()
|
||||
.setNextFinishButtonEnabled(isEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the server part of the sip user name.
|
||||
*
|
||||
* @param userName the username.
|
||||
* @return the server part of the sip user name.
|
||||
*/
|
||||
private String getServerFromUserName(String userName)
|
||||
{
|
||||
int delimIndex = userName.indexOf("@");
|
||||
if (delimIndex != -1)
|
||||
{
|
||||
return userName.substring(delimIndex + 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this wizard is modifying an existing account or is creating
|
||||
* a new one.
|
||||
*
|
||||
* @return <code>true</code> to indicate that this wizard is currently in
|
||||
* modification mode, <code>false</code> - otherwise.
|
||||
*/
|
||||
public boolean isModification()
|
||||
{
|
||||
return isModification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the user input when the "Next" wizard buttons is clicked.
|
||||
* @param registration the SIPAccountRegistration
|
||||
*/
|
||||
public void commitPage(SIPAccountRegistration registration)
|
||||
{
|
||||
String userID = accountPanel.getUserID();
|
||||
|
||||
if(userID == null || userID.trim().length() == 0)
|
||||
throw new IllegalStateException("No user ID provided.");
|
||||
|
||||
registration.setUserID(userID);
|
||||
|
||||
char[] password = accountPanel.getPassword();
|
||||
if (password != null)
|
||||
registration.setPassword(new String(password));
|
||||
|
||||
registration.setRememberPassword(accountPanel.isRememberPassword());
|
||||
|
||||
registration.setServerAddress(connectionPanel.getServerAddress());
|
||||
|
||||
String displayName = accountPanel.getDisplayName();
|
||||
registration.setDisplayName(displayName);
|
||||
|
||||
String authName = connectionPanel.getAuthenticationName();
|
||||
if(authName != null && authName.length() > 0)
|
||||
registration.setAuthorizationName(authName);
|
||||
|
||||
registration.setServerPort(connectionPanel.getServerPort());
|
||||
registration.setProxy(connectionPanel.getProxy());
|
||||
registration.setProxyPort(connectionPanel.getProxyPort());
|
||||
|
||||
registration.setPreferredTransport(
|
||||
connectionPanel.getSelectedTransport());
|
||||
|
||||
registration.setEnablePresence(
|
||||
presencePanel.isPresenceEnabled());
|
||||
registration.setForceP2PMode(
|
||||
presencePanel.isForcePeerToPeerMode());
|
||||
registration.setDefaultEncryption(
|
||||
connectionPanel.isDefaultEncryptionEnabled());
|
||||
registration.setSipZrtpAttribute(
|
||||
connectionPanel.isSipZrtpEnabled());
|
||||
registration.setPollingPeriod(
|
||||
presencePanel.getPollPeriod());
|
||||
registration.setSubscriptionExpiration(
|
||||
presencePanel.getSubscriptionExpiration());
|
||||
registration.setKeepAliveMethod(
|
||||
connectionPanel.getKeepAliveMethod());
|
||||
registration.setKeepAliveInterval(
|
||||
connectionPanel.getKeepAliveInterval());
|
||||
|
||||
SIPAccRegWizzActivator.getUIService().getAccountRegWizardContainer()
|
||||
.setBackButtonEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the account with the given identifier.
|
||||
* @param accountID the account identifier
|
||||
*/
|
||||
public void loadAccount(AccountID accountID)
|
||||
{
|
||||
String password = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.PASSWORD);
|
||||
|
||||
String serverAddress = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.SERVER_ADDRESS);
|
||||
|
||||
String displayName = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.DISPLAY_NAME);
|
||||
|
||||
String authName = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.AUTHORIZATION_NAME);
|
||||
|
||||
String serverPort = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.SERVER_PORT);
|
||||
|
||||
String proxyAddress = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.PROXY_ADDRESS);
|
||||
|
||||
String proxyPort = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.PROXY_PORT);
|
||||
|
||||
String preferredTransport = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.PREFERRED_TRANSPORT);
|
||||
|
||||
boolean enablePresence = accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.IS_PRESENCE_ENABLED, false);
|
||||
|
||||
boolean forceP2P = accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.FORCE_P2P_MODE, false);
|
||||
|
||||
boolean enabledDefaultEncryption = accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.DEFAULT_ENCRYPTION, true);
|
||||
|
||||
boolean enabledSipZrtpAttribute = accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.DEFAULT_SIPZRTP_ATTRIBUTE, true);
|
||||
|
||||
String pollingPeriod = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.POLLING_PERIOD);
|
||||
|
||||
String subscriptionPeriod = accountID.getAccountPropertyString(
|
||||
ProtocolProviderFactory.SUBSCRIPTION_EXPIRATION);
|
||||
|
||||
String keepAliveMethod =
|
||||
accountID.getAccountPropertyString("KEEP_ALIVE_METHOD");
|
||||
|
||||
String keepAliveInterval =
|
||||
accountID.getAccountPropertyString("KEEP_ALIVE_INTERVAL");
|
||||
|
||||
connectionPanel.setServerOverridden(
|
||||
accountID.getAccountPropertyBoolean(
|
||||
ProtocolProviderFactory.IS_SERVER_OVERRIDDEN, false));
|
||||
|
||||
accountPanel.setUserIDEnabled(false);
|
||||
accountPanel.setUserID((serverAddress == null) ? accountID.getUserID()
|
||||
: (accountID.getUserID() + "@" + serverAddress));
|
||||
|
||||
setNextFinishButtonEnabled(accountPanel.getUserID() != null);
|
||||
|
||||
if (password != null)
|
||||
{
|
||||
accountPanel.setPassword(password);
|
||||
accountPanel.setRememberPassword(true);
|
||||
}
|
||||
|
||||
connectionPanel.setServerAddress(serverAddress);
|
||||
connectionPanel.setServerEnabled(false);
|
||||
|
||||
if (displayName != null && displayName.length() > 0)
|
||||
accountPanel.setDisplayName(displayName);
|
||||
|
||||
if(authName != null && authName.length() > 0)
|
||||
connectionPanel.setAuthenticationName(authName);
|
||||
|
||||
connectionPanel.setServerPort(serverPort);
|
||||
connectionPanel.setProxy(proxyAddress);
|
||||
|
||||
// The order of the next two fields is important, as a change listener
|
||||
// of the transportCombo sets the proxyPortField to its default
|
||||
connectionPanel.setSelectedTransport(preferredTransport);
|
||||
connectionPanel.setProxyPort(proxyPort);
|
||||
|
||||
presencePanel.setPresenceEnabled(enablePresence);
|
||||
presencePanel.setForcePeerToPeerMode(forceP2P);
|
||||
|
||||
connectionPanel.enablesDefaultEncryption(enabledDefaultEncryption);
|
||||
connectionPanel.setSipZrtpEnabled( enabledSipZrtpAttribute,
|
||||
enabledDefaultEncryption);
|
||||
|
||||
presencePanel.setPollPeriod(pollingPeriod);
|
||||
presencePanel.setSubscriptionExpiration(subscriptionPeriod);
|
||||
|
||||
if (!enablePresence)
|
||||
{
|
||||
presencePanel.setPresenceOptionsEnabled(enablePresence);
|
||||
}
|
||||
|
||||
connectionPanel.setKeepAliveMethod(keepAliveMethod);
|
||||
connectionPanel.setKeepAliveInterval(keepAliveInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a simple version of this registration form.
|
||||
* @return the simple form component
|
||||
*/
|
||||
public Component getSimpleForm()
|
||||
{
|
||||
return accountPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the isModification property.
|
||||
* @param isModification indicates if this form is created for modification
|
||||
*/
|
||||
public void setModification(boolean isModification)
|
||||
{
|
||||
this.isModification = isModification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the username example.
|
||||
* @return the username example string
|
||||
*/
|
||||
public String getUsernameExample()
|
||||
{
|
||||
return wizard.getUserNameExample();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign ups through the web.
|
||||
*/
|
||||
public void webSignup()
|
||||
{
|
||||
wizard.webSignup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sign up link name.
|
||||
* @return the sign up link name
|
||||
*/
|
||||
public String getWebSignupLinkName()
|
||||
{
|
||||
return wizard.getWebSignupLinkName();
|
||||
}
|
||||
}
|
||||