in all account registration wizards, check if the account entered by user is not already installed and if so, show a message to the user.

cusax-fix
Yana Stamcheva 20 years ago
parent fe8562ed49
commit 2fa5a83fdd

@ -8,11 +8,11 @@
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
@ -39,6 +39,9 @@ public class FirstWizardPage extends JPanel
private JLabel passLabel = new JLabel(Resources.getString("password"));
private JLabel existingAccountLabel
= new JLabel(Resources.getString("existingAccount"));
private JTextField uinField = new JTextField();
private JPasswordField passField = new JPasswordField();
@ -59,6 +62,8 @@ public class FirstWizardPage extends JPanel
private JPanel mainPanel = new JPanel();
private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
private IcqAccountRegistration registration;
private WizardContainer wizardContainer;
@ -95,6 +100,8 @@ private void init() {
this.registerButton.addActionListener(this);
this.uinField.getDocument().addDocumentListener(this);
this.rememberPassBox.setSelected(true);
this.existingAccountLabel.setForeground(Color.RED);
labelsPanel.add(uinLabel);
labelsPanel.add(passLabel);
@ -140,8 +147,8 @@ public Object getIdentifier() {
* Implements the <code>WizardPage.getNextPageIdentifier</code> to return
* the next page identifier - the summary page.
*/
public Object getNextPageIdentifier() {
return WizardPage.SUMMARY_PAGE_IDENTIFIER;
public Object getNextPageIdentifier() {
return nextPageIdentifier;
}
/**
@ -172,9 +179,21 @@ public void pageShowing() {
* Saves the user input when the "Next" wizard buttons is clicked.
*/
public void pageNext() {
registration.setUin(uinField.getText());
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
String uin = uinField.getText();
if(isExistingAccount(uin)) {
nextPageIdentifier = FIRST_PAGE_IDENTIFIER;
uinPassPanel.add(existingAccountLabel, BorderLayout.NORTH);
this.revalidate();
}
else {
nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
uinPassPanel.remove(existingAccountLabel);
registration.setUin(uin);
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
}
}
/**
@ -242,6 +261,22 @@ public void loadAccount(ProtocolProviderService protocolProvider) {
public void actionPerformed(ActionEvent e)
{
CrossPlatformBrowserLauncher.openURL("https://www.icq.com/register/");
CrossPlatformBrowserLauncher.openURL("https://www.icq.com/register/");
}
private boolean isExistingAccount(String accountName)
{
ProtocolProviderFactory factory
= IcqAccRegWizzActivator.getIcqProtocolProviderFactory();
ArrayList registeredAccounts = factory.getRegisteredAccounts();
for(int i = 0; i < registeredAccounts.size(); i ++) {
AccountID accountID = (AccountID) registeredAccounts.get(i);
if(accountName.equalsIgnoreCase(accountID.getUserID()))
return true;
}
return false;
}
}

@ -6,5 +6,6 @@ rememberPassword=Remember password
uinAndPassword=UIN and Password
registerNewAccount=Register new account
registerNewAccountText=In case you don't have an ICQ account, click on this button to create a new one.
existingAccount=* The account you entered is already installed.
protocolIcon=net/java/sip/communicator/plugin/icqaccregwizz/resources/Icq.png

@ -8,6 +8,8 @@
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
@ -36,9 +38,12 @@ public class FirstWizardPage extends JPanel
private JPanel valuesPanel = new JPanel(new GridLayout(0, 1, 10, 10));
private JLabel uinLabel = new JLabel(Resources.getString("uin"));
private JLabel passLabel = new JLabel(Resources.getString("password"));
private JLabel existingAccountLabel
= new JLabel(Resources.getString("existingAccount"));
private JTextField uinField = new JTextField();
private JPasswordField passField = new JPasswordField();
@ -66,6 +71,8 @@ public class FirstWizardPage extends JPanel
private JPanel mainPanel = new JPanel();
private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
private JabberAccountRegistration registration;
private WizardContainer wizardContainer;
@ -102,6 +109,8 @@ private void init() {
this.uinField.getDocument().addDocumentListener(this);
this.rememberPassBox.setSelected(true);
this.existingAccountLabel.setForeground(Color.RED);
labelsPanel.add(uinLabel);
labelsPanel.add(passLabel);
@ -177,7 +186,7 @@ public Object getIdentifier() {
* the next page identifier - the summary page.
*/
public Object getNextPageIdentifier() {
return WizardPage.SUMMARY_PAGE_IDENTIFIER;
return nextPageIdentifier;
}
/**
@ -208,18 +217,30 @@ public void pageShowing() {
* Saves the user input when the "Next" wizard buttons is clicked.
*/
public void pageNext() {
registration.setUin(uinField.getText());
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
registration.setServerAddress(serverField.getText());
registration.setSendKeepAlive(sendKeepAliveBox.isSelected());
try
{
registration.setPort(Integer.parseInt(portField.getText()));
String uin = uinField.getText();
if(isExistingAccount(uin)) {
nextPageIdentifier = FIRST_PAGE_IDENTIFIER;
uinPassPanel.add(existingAccountLabel, BorderLayout.NORTH);
this.revalidate();
}
else {
nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
uinPassPanel.remove(existingAccountLabel);
registration.setUin(uinField.getText());
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
registration.setServerAddress(serverField.getText());
registration.setSendKeepAlive(sendKeepAliveBox.isSelected());
try
{
registration.setPort(Integer.parseInt(portField.getText()));
}
catch (NumberFormatException ex)
{}
}
catch (NumberFormatException ex)
{}
}
/**
@ -323,4 +344,20 @@ private void setNextButtonAccordingToPort()
wizardContainer.setNextFinishButtonEnabled(false);
}
}
private boolean isExistingAccount(String accountName)
{
ProtocolProviderFactory factory
= JabberAccRegWizzActivator.getJabberProtocolProviderFactory();
ArrayList registeredAccounts = factory.getRegisteredAccounts();
for(int i = 0; i < registeredAccounts.size(); i ++) {
AccountID accountID = (AccountID) registeredAccounts.get(i);
if(accountName.equalsIgnoreCase(accountID.getUserID()))
return true;
}
return false;
}
}

@ -9,5 +9,6 @@ ovverideServerOps=Override server default options
server=Connect Server
port=Port
sendKeepAlive=Send keep alive packets
existingAccount=* The account you entered is already installed.
protocolIcon=net/java/sip/communicator/plugin/jabberaccregwizz/resources/jabber.gif

@ -7,7 +7,8 @@
package net.java.sip.communicator.plugin.msnaccregwizz;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
@ -36,6 +37,9 @@ public class FirstWizardPage extends JPanel
private JLabel passLabel = new JLabel(Resources.getString("password"));
private JLabel existingAccountLabel
= new JLabel(Resources.getString("existingAccount"));
private JTextField uinField = new JTextField();
private JPasswordField passField = new JPasswordField();
@ -44,6 +48,8 @@ public class FirstWizardPage extends JPanel
Resources.getString("rememberPassword"));
private JPanel mainPanel = new JPanel();
private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
private MsnAccountRegistration registration;
@ -81,6 +87,8 @@ private void init() {
this.uinField.getDocument().addDocumentListener(this);
this.rememberPassBox.setSelected(true);
this.existingAccountLabel.setForeground(Color.RED);
labelsPanel.add(uinLabel);
labelsPanel.add(passLabel);
@ -111,7 +119,7 @@ public Object getIdentifier() {
* the next page identifier - the summary page.
*/
public Object getNextPageIdentifier() {
return WizardPage.SUMMARY_PAGE_IDENTIFIER;
return nextPageIdentifier;
}
/**
@ -142,9 +150,21 @@ public void pageShowing() {
* Saves the user input when the "Next" wizard buttons is clicked.
*/
public void pageNext() {
registration.setUin(uinField.getText());
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
String uin = uinField.getText();
if(isExistingAccount(uin)) {
nextPageIdentifier = FIRST_PAGE_IDENTIFIER;
uinPassPanel.add(existingAccountLabel, BorderLayout.NORTH);
this.revalidate();
}
else {
nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
uinPassPanel.remove(existingAccountLabel);
registration.setUin(uinField.getText());
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
}
}
/**
@ -208,4 +228,20 @@ public void loadAccount(ProtocolProviderService protocolProvider) {
this.rememberPassBox.setSelected(true);
}
}
private boolean isExistingAccount(String accountName)
{
ProtocolProviderFactory factory
= MsnAccRegWizzActivator.getMsnProtocolProviderFactory();
ArrayList registeredAccounts = factory.getRegisteredAccounts();
for(int i = 0; i < registeredAccounts.size(); i ++) {
AccountID accountID = (AccountID) registeredAccounts.get(i);
if(accountName.equalsIgnoreCase(accountID.getUserID()))
return true;
}
return false;
}
}

@ -4,5 +4,6 @@ uin=Email:
password=Password:
rememberPassword=Remember password
uinAndPassword=ID and Password
existingAccount=* The account you entered is already installed.
protocolIcon=net/java/sip/communicator/plugin/msnaccregwizz/resources/msn.gif

@ -8,6 +8,7 @@
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
@ -42,6 +43,9 @@ public class FirstWizardPage extends JPanel
private JLabel passLabel = new JLabel(Resources.getString("password"));
private JLabel existingAccountLabel
= new JLabel(Resources.getString("existingAccount"));
private JTextField uinField = new JTextField();
private JPasswordField passField = new JPasswordField();
@ -81,6 +85,8 @@ public class FirstWizardPage extends JPanel
new Object[]{"UDP", "TLS", "TCP"});
private JPanel mainPanel = new JPanel();
private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
private SIPAccountRegistration registration;
@ -118,6 +124,8 @@ private void init() {
this.uinField.getDocument().addDocumentListener(this);
this.transportCombo.addItemListener(this);
this.rememberPassBox.setSelected(true);
existingAccountLabel.setForeground(Color.RED);
labelsPanel.add(uinLabel);
labelsPanel.add(passLabel);
@ -191,7 +199,7 @@ public Object getIdentifier() {
* the next page identifier - the summary page.
*/
public Object getNextPageIdentifier() {
return WizardPage.SUMMARY_PAGE_IDENTIFIER;
return nextPageIdentifier;
}
/**
@ -222,16 +230,28 @@ public void pageShowing() {
* Saves the user input when the "Next" wizard buttons is clicked.
*/
public void pageNext() {
registration.setUin(uinField.getText());
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
registration.setServerAddress(serverField.getText());
registration.setServerPort(serverPortField.getText());
registration.setProxy(proxyField.getText());
registration.setProxyPort(proxyPortField.getText());
registration.setPreferredTransport(
transportCombo.getSelectedItem().toString());
String uin = uinField.getText();
if(isExistingAccount(uin)) {
nextPageIdentifier = FIRST_PAGE_IDENTIFIER;
uinPassPanel.add(existingAccountLabel, BorderLayout.NORTH);
this.revalidate();
}
else {
nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
uinPassPanel.remove(existingAccountLabel);
registration.setUin(uinField.getText());
registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
registration.setServerAddress(serverField.getText());
registration.setServerPort(serverPortField.getText());
registration.setProxy(proxyField.getText());
registration.setProxyPort(proxyPortField.getText());
registration.setPreferredTransport(
transportCombo.getSelectedItem().toString());
}
}
/**
@ -367,4 +387,20 @@ public void itemStateChanged(ItemEvent e)
proxyPortField.setText("5060");
}
}
private boolean isExistingAccount(String accountName)
{
ProtocolProviderFactory factory
= SIPAccRegWizzActivator.getSIPProtocolProviderFactory();
ArrayList registeredAccounts = factory.getRegisteredAccounts();
for(int i = 0; i < registeredAccounts.size(); i ++) {
AccountID accountID = (AccountID) registeredAccounts.get(i);
if(accountName.equalsIgnoreCase(accountID.getUserID()))
return true;
}
return false;
}
}

@ -13,5 +13,6 @@ proxyPort=Proxy port
preferredTransport=Preferred transport
yes=Yes
no=No
existingAccount=* The account you entered is already installed.
protocolIcon=net/java/sip/communicator/plugin/sipaccregwizz/resources/sip.png

Loading…
Cancel
Save