diff options
author | Damian Minkov <damencho@jitsi.org> | 2007-04-10 15:29:01 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2007-04-10 15:29:01 +0000 |
commit | 214e73f5094eea707603331ce3919968091c2423 (patch) | |
tree | f4f6520c9a95af240c39684520116463ec677f05 /src/net/java/sip/communicator/plugin | |
parent | 75b88bb5a6b6ea924903fc1092f33caa21bd3ca7 (diff) | |
download | jitsi-214e73f5094eea707603331ce3919968091c2423.zip jitsi-214e73f5094eea707603331ce3919968091c2423.tar.gz jitsi-214e73f5094eea707603331ce3919968091c2423.tar.bz2 |
Aim wizard and some improvments on the loading of accounts for the aim/icq protocol.
Diffstat (limited to 'src/net/java/sip/communicator/plugin')
7 files changed, 1010 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/AimAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/aimaccregwizz/AimAccRegWizzActivator.java new file mode 100644 index 0000000..85786f0 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/AimAccRegWizzActivator.java @@ -0,0 +1,95 @@ +/* + * 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.aimaccregwizz; + +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.util.*; + +import org.osgi.framework.*; + +/** + * Registers the <tt>AimAccountRegistrationWizard</tt> in the UI Service. + * + * @author Yana Stamcheva + */ +public class AimAccRegWizzActivator implements BundleActivator { + + public static BundleContext bundleContext; + + private static Logger logger = Logger.getLogger( + AimAccRegWizzActivator.class); + + private static BrowserLauncherService browserLauncherService; + + /** + * Starts this bundle. + */ + public void start(BundleContext bc) throws Exception { + + bundleContext = bc; + + ServiceReference uiServiceRef = bundleContext + .getServiceReference(UIService.class.getName()); + + UIService uiService + = (UIService) bundleContext.getService(uiServiceRef); + + AccountRegistrationWizardContainer wizardContainer + = uiService.getAccountRegWizardContainer(); + + AimAccountRegistrationWizard aimWizard + = new AimAccountRegistrationWizard(wizardContainer); + + wizardContainer.addAccountRegistrationWizard(aimWizard); + } + + public void stop(BundleContext bundleContext) throws Exception { + } + + /** + * Returns the <tt>ProtocolProviderFactory</tt> for the AIM protocol. + * @return the <tt>ProtocolProviderFactory</tt> for the AIM protocol + */ + public static ProtocolProviderFactory getAimProtocolProviderFactory() { + + ServiceReference[] serRefs = null; + + String osgiFilter = "(" + + ProtocolProviderFactory.PROTOCOL + + "="+ProtocolNames.AIM+")"; + + try { + serRefs = bundleContext.getServiceReferences( + ProtocolProviderFactory.class.getName(), osgiFilter); + } + catch (InvalidSyntaxException ex){ + logger.error("AimAccRegWizzActivator : " + ex); + } + + return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]); + } + + /** + * 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) { + ServiceReference serviceReference = bundleContext + .getServiceReference(BrowserLauncherService.class.getName()); + + browserLauncherService = (BrowserLauncherService) bundleContext + .getService(serviceReference); + } + + return browserLauncherService; + } +} diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/AimAccountRegistration.java b/src/net/java/sip/communicator/plugin/aimaccregwizz/AimAccountRegistration.java new file mode 100644 index 0000000..54d14f3 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/AimAccountRegistration.java @@ -0,0 +1,161 @@ +/* + * 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.aimaccregwizz; + +/** + * The <tt>AimAccountRegistration</tt> is used to store all user input data + * through the <tt>AimAccountRegistrationWizard</tt>. + * + * @author Yana Stamcheva + */ +public class AimAccountRegistration { + + private String uin; + + private String password; + + private boolean rememberPassword; + + private String proxyPort; + + private String proxy; + + private String proxyType; + + private String proxyUsername; + + private String proxyPassword; + + /** + * Returns the password of the aim registration account. + * @return the password of the aim registration account. + */ + public String getPassword() { + return password; + } + + /** + * Sets the password of the aim registration account. + * @param password the password of the aim 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 aim 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 aim registration account. + * @return the UIN of the aim registration account. + */ + public String getUin() { + return uin; + } + + /** + * Sets the UIN of the aim registration account. + * @param uin the UIN of the aim registration account. + */ + public void setUin(String uin) { + this.uin = uin; + } + + /** + * Returns the proxy that will be used for this aim account. + * @return the proxy that will be used for this aim account. + */ + public String getProxy() { + return proxy; + } + + /** + * Sets the proxy for this aim account. + * @param proxy the proxy for this aim account. + */ + public void setProxy(String proxy) { + this.proxy = proxy; + } + + /** + * Returns the proxy port that will be used for this aim account. + * @return the proxy port that will be used for this aim account. + */ + public String getProxyPort() { + return proxyPort; + } + + /** + * Sets the proxy port for this aim account. + * @param proxyPort the proxy port for this aim account. + */ + public void setProxyPort(String proxyPort) { + this.proxyPort = proxyPort; + } + + /** + * Returns the proxy type that will be used for this aim account. + * @return the proxy type that will be used for this aim account. + */ + public String getProxyType() { + return proxyType; + } + + /** + * Sets the proxy type for this aim account. + * @param proxyType the proxy type for this aim account + */ + public void setProxyType(String proxyType) { + this.proxyType = proxyType; + } + + /** + * Returns the proxy password of the aim registration account. + * @return the proxy password of the aim registration account. + */ + public String getProxyPassword() { + return proxyPassword; + } + + /** + * Sets the proxy password of the aim registration account. + * @param password the proxy password of the aim registration account. + */ + public void setProxyPassword(String password) { + this.proxyPassword = password; + } + + /** + * Returns the proxy username of the aim registration account. + * @return the proxy username of the aim registration account. + */ + public String getProxyUsername() { + return proxyUsername; + } + + /** + * Sets the proxy username of the aim registration account. + * @param username the proxy username of the aim registration account + */ + public void setProxyUsername(String username) { + this.proxyUsername = username; + } +} diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/AimAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/aimaccregwizz/AimAccountRegistrationWizard.java new file mode 100644 index 0000000..70d74b1 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/AimAccountRegistrationWizard.java @@ -0,0 +1,216 @@ +/* + * 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.aimaccregwizz; + +import java.util.*; + +import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.plugin.gibberishaccregwizz.*; +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.protocol.*; + +import org.osgi.framework.*; + +/** + * The <tt>AimAccountRegistrationWizard</tt> is an implementation of the + * <tt>AccountRegistrationWizard</tt> for the AIM protocol. It should allow + * the user to create and configure a new AIM account. + * + * @author Yana Stamcheva + */ +public class AimAccountRegistrationWizard implements AccountRegistrationWizard +{ + private FirstWizardPage firstWizardPage; + + private AimAccountRegistration registration + = new AimAccountRegistration(); + + private WizardContainer wizardContainer; + + private ProtocolProviderService protocolProvider; + + private boolean isModification; + + /** + * Creates an instance of <tt>AimAccountRegistrationWizard</tt>. + * @param wizardContainer the wizard container, where this wizard + * is added + */ + public AimAccountRegistrationWizard(WizardContainer wizardContainer) { + this.wizardContainer = wizardContainer; + } + + /** + * Implements the <code>AccountRegistrationWizard.getIcon</code> method. + * Returns the icon to be used for this wizard. + */ + public byte[] getIcon() { + return Resources.getImage(Resources.AIM_LOGO); + } + + /** + * 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 Resources.getImage(Resources.PAGE_IMAGE); + } + + /** + * Implements the <code>AccountRegistrationWizard.getProtocolName</code> + * method. Returns the protocol name for this wizard. + */ + public String getProtocolName() { + return Resources.getString("protocolName"); + } + + /** + * Implements the <code>AccountRegistrationWizard.getProtocolDescription + * </code> method. Returns the description of the protocol for this wizard. + */ + public String getProtocolDescription() { + return Resources.getString("protocolDescription"); + } + + /** + * Returns the set of pages contained in this wizard. + */ + public Iterator getPages() { + ArrayList pages = new ArrayList(); + firstWizardPage = new FirstWizardPage(registration, wizardContainer); + + pages.add(firstWizardPage); + + return pages.iterator(); + } + + /** + * Returns the set of data that user has entered through this wizard. + */ + public Iterator getSummary() { + Hashtable summaryTable = new Hashtable(); + + summaryTable.put("UIN", registration.getUin()); + summaryTable.put("Remember password", + new Boolean(registration.isRememberPassword())); + + if(registration.getProxy() != null) + summaryTable.put(Resources.getString("proxy"), + registration.getProxy()); + + if(registration.getProxyPort() != null) + summaryTable.put(Resources.getString("proxyPort"), + registration.getProxyPort()); + + if(registration.getProxyType() != null) + summaryTable.put(Resources.getString("proxyType"), + registration.getProxyType()); + + if(registration.getProxyPort() != null) + summaryTable.put(Resources.getString("proxyUsername"), + registration.getProxyPort()); + + if(registration.getProxyType() != null) + summaryTable.put(Resources.getString("proxyPassword"), + registration.getProxyType()); + + return summaryTable.entrySet().iterator(); + } + + /** + * Installs the account created through this wizard. + */ + public ProtocolProviderService finish() { + firstWizardPage = null; + ProtocolProviderFactory factory + = AimAccRegWizzActivator.getAimProtocolProviderFactory(); + + return this.installAccount(factory, + registration.getUin(), registration.getPassword()); + } + + /** + * Creates an account for the given user and password. + * @param providerFactory the ProtocolProviderFactory which will create + * the account + * @param user the user identifier + * @param passwd the password + * @return the <tt>ProtocolProviderService</tt> for the new account. + */ + public ProtocolProviderService installAccount( + ProtocolProviderFactory providerFactory, + String user, + String passwd) { + + Hashtable accountProperties = new Hashtable(); + + if(registration.isRememberPassword()) { + accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd); + } + + if(registration.getProxyType() != null) + { + accountProperties.put(ProtocolProviderFactory.PROXY_ADDRESS, + registration.getProxy()); + + accountProperties.put(ProtocolProviderFactory.PROXY_PORT, + registration.getProxyPort()); + + accountProperties.put(ProtocolProviderFactory.PROXY_TYPE, + registration.getProxyType()); + + accountProperties.put(ProtocolProviderFactory.PROXY_USERNAME, + registration.getProxyUsername()); + + accountProperties.put(ProtocolProviderFactory.PROXY_PASSWORD, + registration.getProxyPassword()); + } + + if(isModification) { + providerFactory.uninstallAccount(protocolProvider.getAccountID()); + this.protocolProvider = null; + } + + try { + AccountID accountID = providerFactory.installAccount( + user, accountProperties); + + ServiceReference serRef = providerFactory + .getProviderForAccount(accountID); + + protocolProvider + = (ProtocolProviderService) AimAccRegWizzActivator.bundleContext + .getService(serRef); + } + catch (IllegalArgumentException e) { + new ErrorDialog(null, e.getMessage(), e).showDialog(); + } + catch (IllegalStateException e) { + new ErrorDialog(null, e.getMessage(), e).showDialog(); + } + + return protocolProvider; + } + + /** + * Fills the UIN and Password fields in this panel with the data comming + * from the given protocolProvider. + * @param protocolProvider The <tt>ProtocolProviderService</tt> to load the + * data from. + */ + public void loadAccount(ProtocolProviderService protocolProvider) { + + this.protocolProvider = protocolProvider; + + this.firstWizardPage.loadAccount(protocolProvider); + + this.isModification = true; + } +} diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/aimaccregwizz/FirstWizardPage.java new file mode 100644 index 0000000..3533308 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/FirstWizardPage.java @@ -0,0 +1,405 @@ +/* + * 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.aimaccregwizz; + +import java.awt.*; +import java.awt.event.*; +import java.util.*; + +import javax.swing.*; +import javax.swing.event.*; + +import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.protocol.*; + +/** + * The <tt>FirstWizardPage</tt> is the page, where user could enter the uin + * and the password of the account. + * + * @author Yana Stamcheva + */ +public class FirstWizardPage extends JPanel + implements WizardPage, + DocumentListener, + ActionListener { + + public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier"; + + private JPanel uinPassPanel = new JPanel(new BorderLayout(10, 10)); + + private JPanel labelsPanel = new JPanel(); + + private JPanel valuesPanel = new JPanel(); + + private JPanel advancedOpPanel = new JPanel(new BorderLayout(10, 10)); + + private JPanel labelsAdvOpPanel = new JPanel(new GridLayout(0, 1, 10, 10)); + + private JPanel valuesAdvOpPanel = new JPanel(new GridLayout(0, 1, 10, 10)); + + private JCheckBox enableAdvOpButton = new JCheckBox( + Resources.getString("ovverideServerOps"), false); + + private JLabel uinLabel = new JLabel(Resources.getString("uin")); + + private JPanel emptyPanel = new JPanel(); + + private JLabel uinExampleLabel = new JLabel("Ex: 83378997"); + + 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(); + + private JCheckBox rememberPassBox = new JCheckBox( + Resources.getString("rememberPassword")); + + private JPanel registerPanel = new JPanel(new GridLayout(0, 1)); + + private JPanel buttonPanel = new JPanel( + new FlowLayout(FlowLayout.CENTER)); + + private JTextArea registerArea = new JTextArea( + Resources.getString("registerNewAccountText")); + + private JButton registerButton = new JButton( + Resources.getString("registerNewAccount")); + + private JLabel proxyLabel = new JLabel(Resources.getString("proxy")); + + private JLabel proxyPortLabel = new JLabel(Resources.getString("proxyPort")); + + private JLabel proxyUsernameLabel = new JLabel(Resources.getString("proxyUsername")); + + private JLabel proxyPasswordLabel = new JLabel(Resources.getString("proxyPassword")); + + private JLabel proxyTypeLabel = new JLabel(Resources.getString("proxyType")); + + private JTextField proxyField = new JTextField(); + + private JTextField proxyPortField = new JTextField(); + + private JTextField proxyUsernameField = new JTextField(); + + private JPasswordField proxyPassField = new JPasswordField(); + + private JComboBox proxyTypeCombo = new JComboBox( + new Object[]{"http", "socks5", "socks4"}); + + private JPanel mainPanel = new JPanel(); + + private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER; + + private AimAccountRegistration registration; + + private WizardContainer wizardContainer; + + /** + * Creates an instance of <tt>FirstWizardPage</tt>. + * @param registration the <tt>AimAccountRegistration</tt>, where + * all data through the wizard are stored + * @param wizardContainer the wizardContainer, where this page will + * be added + */ + public FirstWizardPage(AimAccountRegistration registration, + WizardContainer wizardContainer) { + + super(new BorderLayout()); + + this.wizardContainer = wizardContainer; + + this.registration = registration; + + this.setPreferredSize(new Dimension(600, 500)); + + mainPanel.setLayout(new BoxLayout(mainPanel, 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.registerButton.addActionListener(this); + this.uinField.getDocument().addDocumentListener(this); + this.rememberPassBox.setSelected(true); + + this.existingAccountLabel.setForeground(Color.RED); + + this.uinExampleLabel.setForeground(Color.GRAY); + this.uinExampleLabel.setFont(uinExampleLabel.getFont().deriveFont(8)); + this.emptyPanel.setMaximumSize(new Dimension(40, 35)); + this.uinExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); + + labelsPanel.add(uinLabel); + labelsPanel.add(emptyPanel); + labelsPanel.add(passLabel); + + valuesPanel.add(uinField); + valuesPanel.add(uinExampleLabel); + valuesPanel.add(passField); + + uinPassPanel.add(labelsPanel, BorderLayout.WEST); + uinPassPanel.add(valuesPanel, BorderLayout.CENTER); + uinPassPanel.add(rememberPassBox, BorderLayout.SOUTH); + + uinPassPanel.setBorder(BorderFactory + .createTitledBorder(Resources.getString("uinAndPassword"))); + + mainPanel.add(uinPassPanel); + + proxyField.setEditable(false); + proxyPortField.setEditable(false); + proxyTypeCombo.setEnabled(false); + + enableAdvOpButton.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent evt) { + // Perform action + JCheckBox cb = (JCheckBox)evt.getSource(); + + proxyField.setEditable(cb.isSelected()); + proxyPortField.setEditable(cb.isSelected()); + proxyTypeCombo.setEnabled(cb.isSelected()); + }}); + + proxyTypeCombo.setSelectedItem("http"); + + labelsAdvOpPanel.add(proxyLabel); + labelsAdvOpPanel.add(proxyPortLabel); + labelsAdvOpPanel.add(proxyTypeLabel); + labelsAdvOpPanel.add(proxyUsernameLabel); + labelsAdvOpPanel.add(proxyPasswordLabel); + + valuesAdvOpPanel.add(proxyField); + valuesAdvOpPanel.add(proxyPortField); + valuesAdvOpPanel.add(proxyTypeCombo); + valuesAdvOpPanel.add(proxyUsernameField); + valuesAdvOpPanel.add(proxyPassField); + + advancedOpPanel.add(enableAdvOpButton, BorderLayout.NORTH); + advancedOpPanel.add(labelsAdvOpPanel, BorderLayout.WEST); + advancedOpPanel.add(valuesAdvOpPanel, BorderLayout.CENTER); + + advancedOpPanel.setBorder(BorderFactory + .createTitledBorder(Resources.getString( + "advancedOptions"))); + + mainPanel.add(advancedOpPanel); + + + this.buttonPanel.add(registerButton); + + this.registerArea.setEditable(false); + this.registerArea.setLineWrap(true); + this.registerArea.setWrapStyleWord(true); + + this.registerPanel.add(registerArea); + this.registerPanel.add(buttonPanel); + + this.registerPanel.setBorder(BorderFactory + .createTitledBorder(Resources.getString("registerNewAccount"))); + + mainPanel.add(registerPanel); + + this.add(mainPanel, BorderLayout.NORTH); + } + + /** + * Implements the <code>WizardPage.getIdentifier</code> to return + * this page identifier. + */ + public Object getIdentifier() { + return FIRST_PAGE_IDENTIFIER; + } + + /** + * Implements the <code>WizardPage.getNextPageIdentifier</code> to return + * the next page identifier - the summary page. + */ + public Object getNextPageIdentifier() { + return nextPageIdentifier; + } + + /** + * Implements the <code>WizardPage.getBackPageIdentifier</code> to return + * the next back identifier - the default page. + */ + public Object getBackPageIdentifier() { + return WizardPage.DEFAULT_PAGE_IDENTIFIER; + } + + /** + * Implements the <code>WizardPage.getWizardForm</code> to return + * this panel. + */ + 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(); + } + + /** + * Saves the user input when the "Next" wizard buttons is clicked. + */ + public void pageNext() { + 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()); + + if(enableAdvOpButton.isSelected()) + { + registration.setProxy(proxyField.getText()); + registration.setProxyPort(proxyPortField.getText()); + registration.setProxyType( + proxyTypeCombo.getSelectedItem().toString()); + registration.setProxyUsername(proxyUsernameField.getText()); + registration.setProxyPassword(new String(proxyPassField.getPassword())); + } + } + } + + /** + * Enables or disables the "Next" wizard button according to whether the + * UIN field is empty. + */ + private void setNextButtonAccordingToUIN() { + if (uinField.getText() == null || uinField.getText().equals("")) { + wizardContainer.setNextFinishButtonEnabled(false); + } + else { + wizardContainer.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. + */ + public void insertUpdate(DocumentEvent e) { + this.setNextButtonAccordingToUIN(); + } + + /** + * 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. + */ + public void removeUpdate(DocumentEvent e) { + this.setNextButtonAccordingToUIN(); + } + + 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 comming + * 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 = (String)accountID.getAccountProperties() + .get(ProtocolProviderFactory.PASSWORD); + + this.uinField.setText(accountID.getUserID()); + + if(password != null) { + this.passField.setText(password); + + this.rememberPassBox.setSelected(true); + } + + String proxyAddress = (String)accountID.getAccountProperties() + .get(ProtocolProviderFactory.PROXY_ADDRESS); + + String proxyPort = (String)accountID.getAccountProperties() + .get(ProtocolProviderFactory.PROXY_PORT); + + String proxyType = (String)accountID.getAccountProperties() + .get(ProtocolProviderFactory.PROXY_TYPE); + + String proxyUsername = (String)accountID.getAccountProperties() + .get(ProtocolProviderFactory.PROXY_USERNAME); + + String proxyPassword = (String)accountID.getAccountProperties() + .get(ProtocolProviderFactory.PROXY_PASSWORD); + + proxyField.setText(proxyAddress); + proxyPortField.setText(proxyPort); + proxyTypeCombo.setSelectedItem(proxyType); + proxyUsernameField.setText(proxyUsername); + proxyPassField.setText(proxyPassword); + } + + public void actionPerformed(ActionEvent e) + { + AimAccRegWizzActivator.getBrowserLauncher() + .openURL("http://my.screenname.aol.com/_cqr/login/login.psp?seamless=n&createSn=1"); + } + + /** + * Checks if an acount with the given account already exists. + * + * @param accountName the name of the account to check + * @return TRUE, if an account with the given name already exists, FALSE - + * otherwise + */ + private boolean isExistingAccount(String accountName) + { + ProtocolProviderFactory factory + = AimAccRegWizzActivator.getAimProtocolProviderFactory(); + + 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; + } +} diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java new file mode 100644 index 0000000..9f74eed --- /dev/null +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/Resources.java @@ -0,0 +1,83 @@ +/* + * 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.aimaccregwizz; + +import java.io.*; +import java.util.*; + +import net.java.sip.communicator.util.*; +/** + * The Messages class manages the access to the internationalization + * properties files. + * @author Yana Stamcheva + */ +public class Resources { + + private static Logger log = Logger.getLogger(Resources.class); + + private static final String BUNDLE_NAME + = "net.java.sip.communicator.plugin.aimaccregwizz.resources"; + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + public static ImageID AIM_LOGO = new ImageID("protocolIcon"); + + public static ImageID PAGE_IMAGE = new ImageID("pageImage"); + + /** + * 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) { + try { + return RESOURCE_BUNDLE.getString(key); + + } catch (MissingResourceException e) { + + return '!' + 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) { + byte[] image = new byte[100000]; + + String path = Resources.getString(imageID.getId()); + try { + Resources.class.getClassLoader() + .getResourceAsStream(path).read(image); + + } catch (IOException e) { + log.error("Failed to load image:" + path, e); + } + + return image; + } + + /** + * Represents the Image Identifier. + */ + public static class ImageID { + private String id; + + private ImageID(String id) { + this.id = id; + } + + public String getId() { + return id; + } + } + +} diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf new file mode 100644 index 0000000..dd0809f --- /dev/null +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf @@ -0,0 +1,31 @@ +Bundle-Activator: net.java.sip.communicator.plugin.aimaccregwizz.AimAccRegWizzActivator +Bundle-Name: AIM account registration wizard +Bundle-Description: AIM account registration wizard. +Bundle-Vendor: sip-communicator.org +Bundle-Version: 0.0.1 +Import-Package: org.osgi.framework, + net.java.sip.communicator.util, + net.java.sip.communicator.service.configuration, + net.java.sip.communicator.service.configuration.event, + net.java.sip.communicator.service.protocol, + net.java.sip.communicator.service.protocol.icqconstants, + net.java.sip.communicator.service.protocol.event, + net.java.sip.communicator.service.contactlist, + net.java.sip.communicator.service.contactlist.event, + net.java.sip.communicator.service.gui, + net.java.sip.communicator.service.gui.event, + net.java.sip.communicator.service.browserlauncher, + 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
\ No newline at end of file diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/resources.properties b/src/net/java/sip/communicator/plugin/aimaccregwizz/resources.properties new file mode 100644 index 0000000..f749fa2 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/resources.properties @@ -0,0 +1,19 @@ +protocolName=AIM +protocolDescription=The AIM service protocol +uin=AIM Screenname: +password=Password: +rememberPassword=Remember password +uinAndPassword=UIN and Password +registerNewAccount=Register new account +registerNewAccountText=In case you don't have an AIM account, click on this button to create a new one. +existingAccount=* The account you entered is already installed. +ovverideServerOps=Override server default options +advancedOptions=Advanced Options +proxy=Proxy +proxyPort=Proxy port +proxyType=Proxy type +proxyUsername=Proxy username +proxyPassword=Proxy password + +protocolIcon=resources/images/aim/aim16x16-online.png +pageImage=resources/images/aim/aim64x64.png |