diff --git a/build.xml b/build.xml index 1939bbde9..180462c56 100644 --- a/build.xml +++ b/build.xml @@ -511,7 +511,7 @@ bundle-slick-runner,bundle-sip,bundle-fileaccess, bundle-fileaccess-slick,bundle-media,bundle-media-slick, bundle-protocol,bundle-icq,bundle-icq-slick,bundle-mock,bundle-swing-ui, - meta-contactlist,meta-contactlist-slick"/> + meta-contactlist,meta-contactlist-slick,bundle-plugin-icqaccregwizz"/> @@ -801,5 +801,15 @@ javax.swing.event, javax.swing.border"/> prefix="net/java/sip/communicator/slick/contactlist"/> + + + + + + + + diff --git a/lib/oscar.client.run.properties b/lib/oscar.client.run.properties index 9751fb469..5a64c2935 100644 --- a/lib/oscar.client.run.properties +++ b/lib/oscar.client.run.properties @@ -56,8 +56,11 @@ oscar.auto.start.4= \ file:sc-bundles/msghistory.jar - oscar.auto.start.99= \ + oscar.auto.start.66= \ file:sc-bundles/swing-ui.jar + + oscar.auto.start.67= \ + file:sc-bundles/icqaccregwizz.jar # Uncomment the following lines if you want to run the architect viewer # bundle. diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java new file mode 100644 index 000000000..2ecab098c --- /dev/null +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java @@ -0,0 +1,172 @@ +/* + * 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.icqaccregwizz; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridLayout; + +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JPasswordField; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +import net.java.sip.communicator.service.gui.WizardContainer; +import net.java.sip.communicator.service.gui.WizardPage; + +public class FirstWizardPage extends JPanel + implements WizardPage, DocumentListener { + + public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier"; + + private JPanel uinPassPanel = 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 JLabel uinLabel = new JLabel(Resources.getString("uin")); + + private JLabel passLabel = new JLabel(Resources.getString("password")); + + 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 JPanel mainPanel = new JPanel(); + + private IcqAccountRegistration registration; + + private WizardContainer wizardContainer; + + public FirstWizardPage(IcqAccountRegistration registration, + WizardContainer wizardContainer) { + + super(new BorderLayout()); + + this.wizardContainer = wizardContainer; + + this.registration = registration; + + this.setPreferredSize(new Dimension(300, 150)); + + mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); + + this.init(); + } + + private void init() { + this.uinField.getDocument().addDocumentListener(this); + + labelsPanel.add(uinLabel); + labelsPanel.add(passLabel); + + valuesPanel.add(uinField); + 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); + + this.buttonPanel.add(registerButton); + + 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); + } + + public Object getIdentifier() { + return FIRST_PAGE_IDENTIFIER; + } + + public Object getNextPageIdentifier() { + return WizardPage.SUMMARY_PAGE_IDENTIFIER; + } + + public Object getBackPageIdentifier() { + return WizardPage.DEFAULT_PAGE_IDENTIFIER; + } + + public Object getWizardForm() { + return this; + } + + public void pageHiding() { + } + + public void pageShown() { + } + + public void pageShowing() { + this.setNextButtonAccordingToUIN(); + } + + public void pageNext() { + registration.setUin(uinField.getText()); + registration.setPassword(passField.getPassword().toString()); + registration.setRememberPassword(rememberPassBox.isSelected()); + } + + public void pageBack() { + } + + private void setNextButtonAccordingToUIN() { + if (uinField.getText() == null || uinField.getText().equals("")) { + wizardContainer.setNextFinishButtonEnabled(false); + } + else { + wizardContainer.setNextFinishButtonEnabled(true); + } + } + + public void insertUpdate(DocumentEvent e) { + this.setNextButtonAccordingToUIN(); + } + + public void removeUpdate(DocumentEvent e) { + this.setNextButtonAccordingToUIN(); + } + + public void changedUpdate(DocumentEvent e) { + } +} diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccRegWizzActivator.java new file mode 100644 index 000000000..487e9c0bd --- /dev/null +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccRegWizzActivator.java @@ -0,0 +1,38 @@ +/* + * 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.icqaccregwizz; + +import net.java.sip.communicator.service.gui.AccountRegistrationWizardContainer; +import net.java.sip.communicator.service.gui.UIService; +import net.java.sip.communicator.service.gui.WizardContainer; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + +public class IcqAccRegWizzActivator implements BundleActivator { + + public void start(BundleContext bundleContext) throws Exception { + ServiceReference uiServiceRef = bundleContext + .getServiceReference(UIService.class.getName()); + + UIService uiService + = (UIService) bundleContext.getService(uiServiceRef); + + AccountRegistrationWizardContainer wizardContainer + = uiService.getAccountRegWizardContainer(); + + IcqAccountRegistrationWizard icqWizard + = new IcqAccountRegistrationWizard(wizardContainer); + + wizardContainer.addAccountRegistrationWizard(icqWizard); + } + + public void stop(BundleContext bundleContext) throws Exception { + + } +} diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java new file mode 100644 index 000000000..ff0723f52 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java @@ -0,0 +1,40 @@ +/* + * 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.icqaccregwizz; + +public class IcqAccountRegistration { + + private String uin; + + private String password; + + private boolean rememberPassword; + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public boolean isRememberPassword() { + return rememberPassword; + } + + public void setRememberPassword(boolean rememberPassword) { + this.rememberPassword = rememberPassword; + } + + public String getUin() { + return uin; + } + + public void setUin(String uin) { + this.uin = uin; + } +} diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistrationWizard.java new file mode 100644 index 000000000..1c158beec --- /dev/null +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistrationWizard.java @@ -0,0 +1,61 @@ +/* + * 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.icqaccregwizz; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; + +import net.java.sip.communicator.service.gui.AccountRegistrationWizard; +import net.java.sip.communicator.service.gui.AccountRegistrationWizardContainer; +import net.java.sip.communicator.service.gui.WizardContainer; + +public class IcqAccountRegistrationWizard implements AccountRegistrationWizard { + + private FirstWizardPage firstWizardPage; + + private ArrayList pages = new ArrayList(); + + private IcqAccountRegistration registration + = new IcqAccountRegistration(); + + public IcqAccountRegistrationWizard(WizardContainer wizardContainer) { + firstWizardPage = new FirstWizardPage(registration, wizardContainer); + + pages.add(firstWizardPage); + } + + public byte[] getIcon() { + return Resources.getImage(Resources.ICQ_LOGO); + } + + public String getProtocolName() { + return Resources.getString("protocolName"); + } + + public String getProtocolDescription() { + return Resources.getString("protocolDescription"); + } + + public Iterator getPages() { + return pages.iterator(); + } + + public Iterator getSummary() { + Hashtable summaryTable = new Hashtable(); + + summaryTable.put("UIN", registration.getUin()); + summaryTable.put("Remember password", + new Boolean(registration.isRememberPassword())); + + return summaryTable.entrySet().iterator(); + } + + public void finish() { + System.out.println("FINISH!!!!!!!!!!!!!!!!!!"); + } +} diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java new file mode 100644 index 000000000..fcefa01f0 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java @@ -0,0 +1,86 @@ +/* + * 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.icqaccregwizz; + +import java.awt.image.BufferedImage; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import javax.imageio.ImageIO; + +import net.java.sip.communicator.util.Logger; +/** + * 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.icqaccregwizz.resources"; + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + public static ImageID ICQ_LOGO = new ImageID("protocolIcon"); + + /** + * 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/icqaccregwizz/SecondWizardPage.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/SecondWizardPage.java new file mode 100644 index 000000000..93a5349f8 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/SecondWizardPage.java @@ -0,0 +1,48 @@ +/* + * 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.icqaccregwizz; + +import javax.swing.JPanel; + +import net.java.sip.communicator.service.gui.WizardPage; + +public class SecondWizardPage extends JPanel + implements WizardPage { + + public static final String SECOND_PAGE_IDENTIFIER = "SecondPageIdentifier"; + + public Object getIdentifier() { + return SECOND_PAGE_IDENTIFIER; + } + + public Object getNextPageIdentifier() { + return FINISH_PAGE_IDENTIFIER; + } + + public Object getBackPageIdentifier() { + return FirstWizardPage.FIRST_PAGE_IDENTIFIER; + } + + public Object getWizardForm() { + return this; + } + + public void pageHiding() { + } + + public void pageShown() { + } + + public void pageShowing() { + } + + public void pageNext() { + } + + public void pageBack() { + } +} diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/icqaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/icqaccregwizz/icqaccregwizz.manifest.mf new file mode 100644 index 000000000..3229d68b6 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/icqaccregwizz.manifest.mf @@ -0,0 +1,31 @@ +Bundle-Activator: net.java.sip.communicator.plugin.icqaccregwizz.IcqAccRegWizzActivator +Bundle-Name: ICQ account registration wizard +Bundle-Description: ICQ 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, + 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.event, + javax.swing.border diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/resources.properties b/src/net/java/sip/communicator/plugin/icqaccregwizz/resources.properties new file mode 100644 index 000000000..675a15b32 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/resources.properties @@ -0,0 +1,10 @@ +protocolName=ICQ +protocolDescription=The AOL ICQ service protocol +uin=ICQ UIN: +password=Password: +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. + +protocolIcon=net/java/sip/communicator/plugin/icqaccregwizz/resources/Icq.png \ No newline at end of file diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/resources/Icq.png b/src/net/java/sip/communicator/plugin/icqaccregwizz/resources/Icq.png new file mode 100644 index 000000000..6a3d1549f Binary files /dev/null and b/src/net/java/sip/communicator/plugin/icqaccregwizz/resources/Icq.png differ