the new account is installed

cusax-fix
Yana Stamcheva 20 years ago
parent b781cce2c3
commit fffb8dc80e

@ -26,6 +26,12 @@
import net.java.sip.communicator.service.gui.WizardContainer;
import net.java.sip.communicator.service.gui.WizardPage;
/**
* 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 {
@ -65,6 +71,13 @@ public class FirstWizardPage extends JPanel
private WizardContainer wizardContainer;
/**
* Creates an instance of <tt>FirstWizardPage</tt>.
* @param registration the <tt>IcqAccountRegistration</tt>, 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 <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 WizardPage.SUMMARY_PAGE_IDENTIFIER;
}
/**
* 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;
}
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 <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() {
}
}

@ -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 <tt>IcqAccountRegistrationWizard</tt> 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]);
}
}

@ -6,6 +6,12 @@
*/
package net.java.sip.communicator.plugin.icqaccregwizz;
/**
* The <tt>IcqAccountRegistration</tt> is used to store all user input data
* through the <tt>IcqAccountRegistrationWizard</tt>.
*
* @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;
}

@ -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 <tt>IcqAccountRegistrationWizard</tt> is an implementation of the
* <tt>AccountRegistrationWizard</tt> 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 <tt>IcqAccountRegistrationWizard</tt>.
* @param wizardContainer the wizard container, where this wizard
* is added
*/
public IcqAccountRegistrationWizard(WizardContainer wizardContainer) {
firstWizardPage = new FirstWizardPage(registration, wizardContainer);
pages.add(firstWizardPage);
}
/**
* Implements the <code>AccountRegistrationWizard.getIcon</code> method.
* Returns the icon to be used for this wizard.
*/
public byte[] getIcon() {
return Resources.getImage(Resources.ICQ_LOGO);
}
/**
* 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() {
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);
}
}

@ -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

Loading…
Cancel
Save