mirror of https://github.com/sipwise/jitsi.git
parent
1c33af095e
commit
d0ae9e93ba
@ -0,0 +1,372 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.jabberaccregwizz;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
|
||||
import javax.imageio.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
import org.jivesoftware.smack.*;
|
||||
|
||||
/**
|
||||
* Dialog for adding a new Jabber account.
|
||||
*
|
||||
* @author Nicolas Grandclaude
|
||||
*/
|
||||
public class JabberNewAccountDialog
|
||||
extends JDialog
|
||||
implements
|
||||
DocumentListener
|
||||
{
|
||||
private static final Logger logger = Logger
|
||||
.getLogger(JabberNewAccountDialog.class);
|
||||
|
||||
private JabberServerChooserDialog jabberServerChooserDialog;
|
||||
|
||||
// Panels
|
||||
private JPanel userIDPassPanel = new JPanel(new BorderLayout(10, 10));
|
||||
|
||||
private JPanel labelsPanel = new JPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
private JPanel valuesPanel = new JPanel(new GridLayout(0, 1, 10, 10));
|
||||
|
||||
private JPanel serverPanel = new JPanel(new BorderLayout(10, 10));
|
||||
|
||||
private JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
|
||||
private Box buttonBox = new Box(BoxLayout.X_AXIS);
|
||||
|
||||
private JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
|
||||
private JPanel westPanel = new JPanel(new BorderLayout(10, 10));
|
||||
|
||||
// Labels
|
||||
private JLabel serverLabel = new JLabel(Resources.getString("cserver"));
|
||||
|
||||
private JLabel userIDLabel = new JLabel(Resources.getString("userID"));
|
||||
|
||||
private JLabel passLabel = new JLabel(Resources.getString("password"));
|
||||
|
||||
private JLabel pass2Label = new JLabel(Resources.getString("password2"));
|
||||
|
||||
private JLabel portLabel = new JLabel(Resources.getString("port"));
|
||||
|
||||
private JLabel westIconLabel = new JLabel();
|
||||
|
||||
// Textfield
|
||||
private JTextField serverField = new JTextField();
|
||||
|
||||
private JTextField userIDField = new JTextField();
|
||||
|
||||
private JPasswordField passField = new JPasswordField();
|
||||
|
||||
private JPasswordField pass2Field = new JPasswordField();
|
||||
|
||||
private JTextField portField = new JTextField("5222");
|
||||
|
||||
// Button
|
||||
private JButton chooseButton = new JButton();
|
||||
|
||||
private JButton okButton = new JButton();
|
||||
|
||||
private JButton cancelButton = new JButton();
|
||||
|
||||
// Smack objects
|
||||
private XMPPConnection xmppConnection = null;
|
||||
|
||||
private AccountManager accountManager = null;
|
||||
|
||||
// Variables for FirstWizardPage
|
||||
public boolean isOK = false;
|
||||
|
||||
public String userID = null;
|
||||
|
||||
public String password = null;
|
||||
|
||||
public String server = null;
|
||||
|
||||
public String port = null;
|
||||
|
||||
private LoadingAccountGlassPane loadingAccountGlassPane
|
||||
= new LoadingAccountGlassPane();
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>JabberNewAccountDialog</tt>.
|
||||
*/
|
||||
public JabberNewAccountDialog()
|
||||
{
|
||||
this.setSize(new Dimension(450, 250));
|
||||
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
this.setTitle(Resources.getString("newAccountTitle"));
|
||||
this.setModal(true);
|
||||
this.setGlassPane(loadingAccountGlassPane);
|
||||
|
||||
// Place the window in the screen center
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
this.setLocation(screenSize.width / 2 - this.getWidth() / 2,
|
||||
screenSize.height / 2 - this.getHeight() / 2);
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the choose server and create a new account with Smack
|
||||
*
|
||||
* @param server the server domain
|
||||
* @param port TCP port to connect
|
||||
* @param username username
|
||||
* @param password password
|
||||
*/
|
||||
private boolean addNewAccount(String server, int port, String username,
|
||||
String password)
|
||||
{
|
||||
try
|
||||
{
|
||||
ConnectionConfiguration config = new ConnectionConfiguration(
|
||||
server, port);
|
||||
|
||||
xmppConnection = new XMPPConnection(config);
|
||||
xmppConnection.connect();
|
||||
|
||||
accountManager = new AccountManager(xmppConnection);
|
||||
accountManager.createAccount(username, password);
|
||||
return true;
|
||||
}
|
||||
catch (XMPPException exc)
|
||||
{
|
||||
if (exc.getXMPPError().getCode() == 409)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, Resources
|
||||
.getString("userExist"), Resources.getString("xmppError"),
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
logger.error(
|
||||
"Error when created a new Jabber account : user already exist");
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, Resources
|
||||
.getString("unknownXmppError"), Resources
|
||||
.getString("xmppError"), JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all panels, buttons, etc.
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
|
||||
labelsPanel.add(serverLabel);
|
||||
labelsPanel.add(userIDLabel);
|
||||
labelsPanel.add(passLabel);
|
||||
labelsPanel.add(pass2Label);
|
||||
labelsPanel.add(portLabel);
|
||||
|
||||
userIDField.setColumns(30);
|
||||
|
||||
serverPanel.add(serverField, BorderLayout.CENTER);
|
||||
serverPanel.add(chooseButton, BorderLayout.EAST);
|
||||
valuesPanel.add(serverPanel);
|
||||
valuesPanel.add(userIDField);
|
||||
valuesPanel.add(passField);
|
||||
valuesPanel.add(pass2Field);
|
||||
valuesPanel.add(portField);
|
||||
|
||||
serverField.getDocument().addDocumentListener(this);
|
||||
userIDField.getDocument().addDocumentListener(this);
|
||||
passField.getDocument().addDocumentListener(this);
|
||||
pass2Field.getDocument().addDocumentListener(this);
|
||||
portField.getDocument().addDocumentListener(this);
|
||||
|
||||
userIDPassPanel.add(labelsPanel, BorderLayout.WEST);
|
||||
userIDPassPanel.add(valuesPanel, BorderLayout.CENTER);
|
||||
|
||||
chooseButton.setText(Resources.getString("chooseLabel"));
|
||||
chooseButton.setMnemonic(Resources.getMnemonic("chooseLabel"));
|
||||
|
||||
westIconLabel.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createEmptyBorder(20, 20, 20, 20), BorderFactory
|
||||
.createTitledBorder("")));
|
||||
try
|
||||
{
|
||||
westIconLabel.setIcon(new ImageIcon(ImageIO
|
||||
.read(new ByteArrayInputStream(Resources
|
||||
.getImage(Resources.PAGE_IMAGE)))));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.error("Could not read image.", e);
|
||||
}
|
||||
|
||||
westPanel.add(westIconLabel, BorderLayout.NORTH);
|
||||
this.mainPanel.add(westPanel, BorderLayout.WEST);
|
||||
|
||||
// Choose button open the JabberServerChooserDialog
|
||||
chooseButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
jabberServerChooserDialog = new JabberServerChooserDialog();
|
||||
if (jabberServerChooserDialog.isOK) // OK pressed in
|
||||
// JabberServerChooserDialog
|
||||
{
|
||||
serverField
|
||||
.setText(jabberServerChooserDialog.serverSelected);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Ok button
|
||||
okButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
if (new String(passField.getPassword()).equals(new String(
|
||||
pass2Field.getPassword())))
|
||||
{ // the two password fields are the same
|
||||
new Thread()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
boolean result = addNewAccount(serverField.getText(),
|
||||
Integer.parseInt(portField.getText()),
|
||||
userIDField.getText(),
|
||||
new String(passField.getPassword()));
|
||||
|
||||
if (result == true)
|
||||
{
|
||||
// Update FirstWizardDialog field
|
||||
isOK = true;
|
||||
userID = new String(userIDField.getText());
|
||||
password = new String(passField.getPassword());
|
||||
server = new String(serverField.getText());
|
||||
port = new String(portField.getText());
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
|
||||
loadingAccountGlassPane.setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, Resources
|
||||
.getString("notSamePassword"), Resources
|
||||
.getString("xmppError"), JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Cancel button
|
||||
cancelButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
okButton.setText(Resources.getString("okLabel"));
|
||||
okButton.setMnemonic(Resources.getMnemonic("okLabel"));
|
||||
okButton.setEnabled(false);
|
||||
|
||||
cancelButton.setText(Resources.getString("cancelLabel"));
|
||||
cancelButton.setMnemonic(Resources.getMnemonic("cancelLabel"));
|
||||
|
||||
buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
|
||||
buttonBox.add(okButton);
|
||||
buttonBox.add(Box.createHorizontalStrut(10));
|
||||
buttonBox.add(cancelButton);
|
||||
|
||||
buttonPanel.add(buttonBox);
|
||||
|
||||
this.mainPanel.add(userIDPassPanel, BorderLayout.CENTER);
|
||||
this.mainPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
this.getContentPane().add(mainPanel, BorderLayout.NORTH);
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the "Ok" button enabled if all fields are filled.
|
||||
*/
|
||||
private void enableOKButton()
|
||||
{
|
||||
okButton.setEnabled(false);
|
||||
try
|
||||
{
|
||||
Integer.parseInt(portField.getText());
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
okButton.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (serverField.getText().equals("")
|
||||
|| userIDField.getText().equals("")
|
||||
|| (new String(passField.getPassword())).equals("")
|
||||
|| (new String(pass2Field.getPassword())).equals(""))
|
||||
{
|
||||
okButton.setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
okButton.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void insertUpdate(DocumentEvent evt)
|
||||
{
|
||||
this.enableOKButton();
|
||||
}
|
||||
|
||||
public void removeUpdate(DocumentEvent evt)
|
||||
{
|
||||
this.enableOKButton();
|
||||
}
|
||||
|
||||
public void changedUpdate(DocumentEvent evt)
|
||||
{
|
||||
}
|
||||
|
||||
public void pageHiding()
|
||||
{
|
||||
}
|
||||
|
||||
public void pageShown()
|
||||
{
|
||||
}
|
||||
|
||||
public void pageBack()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A GlassPane that would change the cursor to a waiting cursor until the
|
||||
* new account is registered.
|
||||
*/
|
||||
private class LoadingAccountGlassPane extends JComponent
|
||||
{
|
||||
public LoadingAccountGlassPane()
|
||||
{
|
||||
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,378 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.plugin.jabberaccregwizz;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.imageio.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.table.*;
|
||||
import javax.xml.parsers.*;
|
||||
|
||||
import net.java.sip.communicator.service.fileaccess.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
import org.osgi.framework.*;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.*;
|
||||
|
||||
/**
|
||||
* A dialog that shows the list of available Jabber servers.
|
||||
*
|
||||
* @author Nicolas Grandclaude
|
||||
*/
|
||||
public class JabberServerChooserDialog
|
||||
extends JDialog
|
||||
implements ListSelectionListener
|
||||
{
|
||||
private static final Logger logger = Logger
|
||||
.getLogger(JabberServerChooserDialog.class);
|
||||
|
||||
private static final String DEFAULT_FILE_NAME = "jabberservers.xml";
|
||||
|
||||
// Servers Table
|
||||
private JTable serversTable;
|
||||
|
||||
private JTextArea chooseArea = new JTextArea(Resources
|
||||
.getString("chooseServerText"));
|
||||
|
||||
// Panel
|
||||
private JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
|
||||
private JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
|
||||
private Box buttonBox = new Box(BoxLayout.X_AXIS);
|
||||
|
||||
private JPanel chooseAreaPanel = new JPanel(new BorderLayout());
|
||||
|
||||
private JPanel westPanel = new JPanel(new BorderLayout(10, 10));
|
||||
|
||||
private JPanel eastPanel = new JPanel(new BorderLayout(10, 10));
|
||||
|
||||
private JLabel westIconLabel = new JLabel();
|
||||
|
||||
private JButton okButton = new JButton(Resources.getString("okLabel"));
|
||||
|
||||
private JButton cancelButton = new JButton(Resources
|
||||
.getString("cancelLabel"));
|
||||
|
||||
private Vector servers = new Vector();
|
||||
|
||||
private FileAccessService faService = null;
|
||||
|
||||
private String[] columnNames =
|
||||
{ Resources.getString("serverColumn"), Resources.getString("commentColumn") };
|
||||
|
||||
public boolean isOK = false;
|
||||
|
||||
public String serverSelected;
|
||||
|
||||
/**
|
||||
* Creates an instance of <tt>JabberServerChooserDialog</tt>.
|
||||
*/
|
||||
public JabberServerChooserDialog()
|
||||
{
|
||||
this.setSize(new Dimension(550, 450));
|
||||
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
this.setTitle(Resources.getString("chooseTitle"));
|
||||
this.setModal(true);
|
||||
|
||||
// Place the window in the center
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
this.setLocation(screenSize.width / 2 - this.getWidth() / 2,
|
||||
screenSize.height / 2 - this.getHeight() / 2);
|
||||
|
||||
this.init();
|
||||
}
|
||||
/**
|
||||
* Initializes all panels, buttons, etc.
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
chooseArea.setEditable(false);
|
||||
chooseArea.setOpaque(false);
|
||||
chooseArea.setLineWrap(true);
|
||||
chooseArea.setWrapStyleWord(true);
|
||||
|
||||
chooseAreaPanel
|
||||
.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 10));
|
||||
|
||||
chooseAreaPanel.add(chooseArea, BorderLayout.NORTH);
|
||||
|
||||
eastPanel.add(chooseAreaPanel, BorderLayout.NORTH);
|
||||
|
||||
// West Jabber icon
|
||||
westIconLabel.setBorder(BorderFactory.createCompoundBorder(
|
||||
BorderFactory.createEmptyBorder(20, 20, 20, 20), BorderFactory
|
||||
.createTitledBorder("")));
|
||||
try
|
||||
{
|
||||
westIconLabel.setIcon(new ImageIcon(ImageIO
|
||||
.read(new ByteArrayInputStream(Resources
|
||||
.getImage(Resources.PAGE_IMAGE)))));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.error("Could not read image.", e);
|
||||
}
|
||||
|
||||
this.westPanel.add(westIconLabel, BorderLayout.NORTH);
|
||||
this.mainPanel.add(westPanel, BorderLayout.WEST);
|
||||
|
||||
// Table with servers and comments
|
||||
serversTable = new JTable(new ServerChooserTableModel());
|
||||
serversTable.setRowHeight(22);
|
||||
serversTable.getSelectionModel().addListSelectionListener(this);
|
||||
serversTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
serversTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
|
||||
|
||||
// Fill the servers array with servers from servers.xml
|
||||
fillTable();
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(serversTable);
|
||||
eastPanel.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
// Ok button
|
||||
okButton.setText(Resources.getString("okLabel"));
|
||||
okButton.setMnemonic(Resources.getMnemonic("okLabel"));
|
||||
okButton.setEnabled(false);
|
||||
|
||||
// Cancel button
|
||||
cancelButton.setText(Resources.getString("cancelLabel"));
|
||||
cancelButton.setMnemonic(Resources.getMnemonic("cancelLabel"));
|
||||
|
||||
// Box with Ok and Cancel
|
||||
buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
|
||||
buttonBox.add(okButton);
|
||||
buttonBox.add(Box.createHorizontalStrut(10));
|
||||
buttonBox.add(cancelButton);
|
||||
buttonPanel.add(buttonBox);
|
||||
|
||||
okButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
isOK = true;
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent evt)
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
this.mainPanel.add(eastPanel, BorderLayout.CENTER);
|
||||
this.mainPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill the servers array variable with data from the remote servers.xml
|
||||
*/
|
||||
public void fillTable()
|
||||
{
|
||||
BundleContext bc = JabberAccRegWizzActivator.bundleContext;
|
||||
|
||||
ServiceReference faServiceReference = bc
|
||||
.getServiceReference(FileAccessService.class.getName());
|
||||
|
||||
faService = (FileAccessService) bc.getService(faServiceReference);
|
||||
|
||||
try
|
||||
{
|
||||
File localServersListFile = faService
|
||||
.getPrivatePersistentFile(DEFAULT_FILE_NAME);
|
||||
|
||||
// Get the file containing the servers list.
|
||||
if (!localServersListFile.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
localServersListFile.createNewFile();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.error("Failed to create file"
|
||||
+ localServersListFile.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
URL file = new URL("http://www.jabber.org/servers.xml");
|
||||
InputStream stream = file.openStream();
|
||||
|
||||
try
|
||||
{
|
||||
// Copy the remote file to the disk
|
||||
byte[] buf = new byte[2048];
|
||||
int len;
|
||||
if (stream.available() > 0)
|
||||
{
|
||||
FileOutputStream fos
|
||||
= new FileOutputStream(localServersListFile);
|
||||
|
||||
while ((len = stream.read(buf)) > 0)
|
||||
{
|
||||
fos.write(buf, 0, len);
|
||||
}
|
||||
fos.close();
|
||||
}
|
||||
} finally
|
||||
{
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.error("");
|
||||
}
|
||||
|
||||
FileInputStream fis = new FileInputStream(localServersListFile);
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory
|
||||
.newInstance();
|
||||
DocumentBuilder constructor = factory.newDocumentBuilder();
|
||||
Document document = constructor.parse(fis);
|
||||
Element root = document.getDocumentElement();
|
||||
|
||||
NodeList list = root.getElementsByTagName("item");
|
||||
|
||||
// Read the xml and fill servers variable for the JTable
|
||||
for (int i = 0; i < list.getLength(); i++)
|
||||
{
|
||||
Element e = (Element) list.item(i);
|
||||
servers.add(new String(e.getAttribute("jid")));
|
||||
}
|
||||
fis.close();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.error(
|
||||
"Failed to get a reference to the Jabber servers list file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When a table row is selected enable the "Ok" button, otherwise disable it.
|
||||
*/
|
||||
public void valueChanged(ListSelectionEvent e)
|
||||
{
|
||||
int row = serversTable.getSelectedRow();
|
||||
if (row != -1)
|
||||
{
|
||||
okButton.setEnabled(true);
|
||||
serverSelected = (String) serversTable.getValueAt(row, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
okButton.setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The table model used for the table containing all servers.
|
||||
*/
|
||||
private class ServerChooserTableModel extends AbstractTableModel
|
||||
{
|
||||
private Document serverComments;
|
||||
|
||||
private NodeList commentsList;
|
||||
|
||||
public ServerChooserTableModel()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create a builder factory
|
||||
DocumentBuilderFactory factory
|
||||
= DocumentBuilderFactory.newInstance();
|
||||
|
||||
// Create the builder and parse the file
|
||||
serverComments = factory.newDocumentBuilder()
|
||||
.parse(new File(Resources.getString("commentsFile")));
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
logger.error("Failed to parse: " + DEFAULT_FILE_NAME, e);
|
||||
}
|
||||
catch (ParserConfigurationException e)
|
||||
{
|
||||
logger.error("Failed to parse: " + DEFAULT_FILE_NAME, e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.error("Failed to parse: " + DEFAULT_FILE_NAME, e);
|
||||
}
|
||||
|
||||
|
||||
Element root = serverComments.getDocumentElement();
|
||||
|
||||
commentsList = root.getElementsByTagName("item");
|
||||
|
||||
}
|
||||
|
||||
public int getColumnCount()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int getRowCount()
|
||||
{
|
||||
return servers.size();
|
||||
}
|
||||
|
||||
public String getColumnName(int col)
|
||||
{
|
||||
return columnNames[col];
|
||||
}
|
||||
|
||||
public Object getValueAt(int row, int col)
|
||||
{
|
||||
String commentString = new String("");
|
||||
if (col == 0) // Column 1 (Server name)
|
||||
{
|
||||
return servers.get(row);
|
||||
}
|
||||
else
|
||||
{ // Column 2 (Comment)
|
||||
|
||||
int i = 0;
|
||||
Element e = (Element) commentsList.item(i);
|
||||
|
||||
while ((i < commentsList.getLength())
|
||||
&& (e.getAttribute("jid").equals(servers.get(row)) == false))
|
||||
{
|
||||
e = (Element) commentsList.item(i);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (e.getAttribute("jid").equals(servers.get(row)))
|
||||
{
|
||||
commentString = e.getAttribute("comment");
|
||||
}
|
||||
|
||||
return commentString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,35 @@
|
||||
protocolName=Jabber
|
||||
protocolDescription=The Jabber protocol
|
||||
userID=Jabber id:
|
||||
password=Password:
|
||||
userID=Jabber id
|
||||
username=Jabber username
|
||||
password=Password
|
||||
password2=Confirm password
|
||||
rememberPassword=Remember password
|
||||
userIDAndPassword=ID and Password
|
||||
advancedOptions=Advanced Options
|
||||
ovverideServerOps=Override server default options
|
||||
cserver=Server
|
||||
server=Connect Server
|
||||
port=Port
|
||||
sendKeepAlive=Send keep alive packets
|
||||
existingAccount=* The account you entered is already installed.
|
||||
newAccountTitle=Jabber new account registration
|
||||
registerNewAccount=Register new account
|
||||
registerNewAccountText=In case you don't have a Jabber account, click on this button to create a new one.
|
||||
chooseTitle=Jabber new account server chooser
|
||||
chooseServerText=Choose the server for your new account in the list below.
|
||||
okLabel=&Ok
|
||||
cancelLabel=C&ancel
|
||||
chooseLabel=&Choose
|
||||
serverColumn=Server
|
||||
commentColumn=Comment
|
||||
|
||||
xmppError=XMPP Error
|
||||
userExist=This user already exist on this server. Choose another user or server.
|
||||
unknownXmppError=Unknown XMPP error. Verify that the server name is correct.
|
||||
notSamePassword=The two entered password aren't the same.
|
||||
|
||||
commentsFile=classes/net/java/sip/communicator/plugin/jabberaccregwizz/resources/servercomments.xml
|
||||
|
||||
protocolIcon=resources/images/jabber/jabber16x16-online.png
|
||||
pageImage=resources/images/jabber/jabber48x48.png
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
<!-- This file lists the open Jabber servers registered with the XMPP Federation. The format of this file is defined by the Service Discovery protocol: http://www.xmpp.org/extensions/xep-0030.html ... To add your server to the list, register at https://www.xmpp.net/ -->
|
||||
|
||||
<query xmlns='http://jabber.org/protocol/disco#items'>
|
||||
<item jid='jabber.org' comment='Jabber Software Foundation Server'/>
|
||||
</query>
|
||||
Loading…
Reference in new issue