diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java
index 2ecab098c..f190d0ca9 100644
--- a/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java
+++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java
@@ -26,6 +26,12 @@
import net.java.sip.communicator.service.gui.WizardContainer;
import net.java.sip.communicator.service.gui.WizardPage;
+/**
+ * The FirstWizardPage 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 {
@@ -65,6 +71,13 @@ public class FirstWizardPage extends JPanel
private WizardContainer wizardContainer;
+ /**
+ * Creates an instance of FirstWizardPage.
+ * @param registration the IcqAccountRegistration, where
+ * all data through the wizard are stored
+ * @param wizardContainer the wizardContainer, where this page will
+ * be added
+ */
public FirstWizardPage(IcqAccountRegistration registration,
WizardContainer wizardContainer) {
@@ -81,8 +94,12 @@ public FirstWizardPage(IcqAccountRegistration registration,
this.init();
}
+ /**
+ * Initializes all panels, buttons, etc.
+ */
private void init() {
this.uinField.getDocument().addDocumentListener(this);
+ this.rememberPassBox.setSelected(true);
labelsPanel.add(uinLabel);
labelsPanel.add(passLabel);
@@ -115,41 +132,59 @@ private void init() {
this.add(mainPanel, BorderLayout.NORTH);
}
+ /**
+ * Implements the WizardPage.getIdentifier to return
+ * this page identifier.
+ */
public Object getIdentifier() {
return FIRST_PAGE_IDENTIFIER;
}
+ /**
+ * Implements the WizardPage.getNextPageIdentifier to return
+ * the next page identifier - the summary page.
+ */
public Object getNextPageIdentifier() {
return WizardPage.SUMMARY_PAGE_IDENTIFIER;
}
+ /**
+ * Implements the WizardPage.getBackPageIdentifier to return
+ * the next back identifier - the default page.
+ */
public Object getBackPageIdentifier() {
return WizardPage.DEFAULT_PAGE_IDENTIFIER;
}
+ /**
+ * Implements the WizardPage.getWizardForm to return
+ * this panel.
+ */
public Object getWizardForm() {
return this;
}
- public void pageHiding() {
- }
-
- public void pageShown() {
- }
-
+ /**
+ * 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() {
registration.setUin(uinField.getText());
- registration.setPassword(passField.getPassword().toString());
+ registration.setPassword(new String(passField.getPassword()));
registration.setRememberPassword(rememberPassBox.isSelected());
}
-
- public void pageBack() {
- }
-
+
+ /**
+ * 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);
@@ -159,14 +194,33 @@ private void setNextButtonAccordingToUIN() {
}
}
+ /**
+ * Handles the DocumentEvent 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 DocumentEvent 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() {
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccRegWizzActivator.java
index 487e9c0bd..ff2746a4a 100644
--- a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccRegWizzActivator.java
+++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccRegWizzActivator.java
@@ -8,15 +8,35 @@
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 net.java.sip.communicator.service.protocol.ProtocolNames;
+import net.java.sip.communicator.service.protocol.ProtocolProviderFactory;
+import net.java.sip.communicator.slick.protocol.icq.IcqSlickFixture;
+import net.java.sip.communicator.util.Logger;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
+/**
+ * Registers the IcqAccountRegistrationWizard in the UI Service.
+ *
+ * @author Yana Stamcheva
+ */
public class IcqAccRegWizzActivator implements BundleActivator {
- public void start(BundleContext bundleContext) throws Exception {
+ public static BundleContext bundleContext;
+
+ private static Logger logger = Logger.getLogger(
+ IcqAccRegWizzActivator.class.getName());
+
+ /**
+ * Starts this bundle.
+ */
+ public void start(BundleContext bc) throws Exception {
+
+ bundleContext = bc;
+
ServiceReference uiServiceRef = bundleContext
.getServiceReference(UIService.class.getName());
@@ -33,6 +53,24 @@ public void start(BundleContext bundleContext) throws Exception {
}
public void stop(BundleContext bundleContext) throws Exception {
+ }
+
+ public static ProtocolProviderFactory getIcqProtocolProviderFactory() {
+
+ ServiceReference[] serRefs = null;
+ String osgiFilter = "("
+ + ProtocolProviderFactory.PROTOCOL_PROPERTY_NAME
+ + "="+ProtocolNames.ICQ+")";
+
+ try {
+ serRefs = bundleContext.getServiceReferences(
+ ProtocolProviderFactory.class.getName(), osgiFilter);
+ }
+ catch (InvalidSyntaxException ex){
+ logger.error("IcqAccRegWizzActivator : " + ex);
+ }
+
+ return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
}
}
diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java
index ff0723f52..e8a53056e 100644
--- a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java
+++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistration.java
@@ -6,6 +6,12 @@
*/
package net.java.sip.communicator.plugin.icqaccregwizz;
+/**
+ * The IcqAccountRegistration is used to store all user input data
+ * through the IcqAccountRegistrationWizard.
+ *
+ * @author Yana Stamcheva
+ */
public class IcqAccountRegistration {
private String uin;
@@ -14,26 +20,51 @@ public class IcqAccountRegistration {
private boolean rememberPassword;
+ /**
+ * Returns the password of the icq registration account.
+ * @return the password of the icq registration account.
+ */
public String getPassword() {
return password;
}
+ /**
+ * Sets the password of the icq registration account.
+ * @param password the password of the icq 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 icq 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 icq registration account.
+ * @return the UIN of the icq registration account.
+ */
public String getUin() {
return uin;
}
+ /**
+ * Sets the UIN of the icq registration account.
+ * @param uin the UIN of the icq registration account.
+ */
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
index 1c158beec..e2c63c546 100644
--- a/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/IcqAccountRegistrationWizard.java
@@ -11,9 +11,17 @@
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;
+import net.java.sip.communicator.service.protocol.AccountProperties;
+import net.java.sip.communicator.service.protocol.ProtocolProviderFactory;
+/**
+ * The IcqAccountRegistrationWizard is an implementation of the
+ * AccountRegistrationWizard for the ICQ protocol. It should allow
+ * the user to create and configure a new ICQ account.
+ *
+ * @author Yana Stamcheva
+ */
public class IcqAccountRegistrationWizard implements AccountRegistrationWizard {
private FirstWizardPage firstWizardPage;
@@ -23,28 +31,51 @@ public class IcqAccountRegistrationWizard implements AccountRegistrationWizard {
private IcqAccountRegistration registration
= new IcqAccountRegistration();
+ /**
+ * Creates an instance of IcqAccountRegistrationWizard.
+ * @param wizardContainer the wizard container, where this wizard
+ * is added
+ */
public IcqAccountRegistrationWizard(WizardContainer wizardContainer) {
firstWizardPage = new FirstWizardPage(registration, wizardContainer);
pages.add(firstWizardPage);
}
+ /**
+ * Implements the AccountRegistrationWizard.getIcon method.
+ * Returns the icon to be used for this wizard.
+ */
public byte[] getIcon() {
return Resources.getImage(Resources.ICQ_LOGO);
}
+ /**
+ * Implements the AccountRegistrationWizard.getProtocolName
+ * method. Returns the protocol name for this wizard.
+ */
public String getProtocolName() {
return Resources.getString("protocolName");
}
+ /**
+ * Implements the AccountRegistrationWizard.getProtocolDescription
+ * 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() {
return pages.iterator();
}
+ /**
+ * Returns the set of data that user has entered through this wizard.
+ */
public Iterator getSummary() {
Hashtable summaryTable = new Hashtable();
@@ -55,7 +86,36 @@ public Iterator getSummary() {
return summaryTable.entrySet().iterator();
}
+ /**
+ * Installs the account created through this wizard.
+ */
public void finish() {
- System.out.println("FINISH!!!!!!!!!!!!!!!!!!");
+ ProtocolProviderFactory factory
+ = IcqAccRegWizzActivator.getIcqProtocolProviderFactory();
+
+ 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
+ */
+ public void installAccount( ProtocolProviderFactory providerFactory,
+ String user,
+ String passwd) {
+
+ Hashtable accountProperties = new Hashtable();
+
+ if(registration.isRememberPassword()) {
+ accountProperties.put(AccountProperties.PASSWORD, passwd);
+ }
+
+ providerFactory.installAccount(
+ IcqAccRegWizzActivator.bundleContext, user,
+ accountProperties);
}
}
diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java
index fcefa01f0..42c88e564 100644
--- a/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java
+++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/Resources.java
@@ -7,14 +7,10 @@
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