aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/msnaccregwizz
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/sip/communicator/plugin/msnaccregwizz')
-rw-r--r--src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java193
-rw-r--r--src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java18
-rw-r--r--src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java195
-rwxr-xr-xsrc/net/java/sip/communicator/plugin/msnaccregwizz/resources.properties1
4 files changed, 257 insertions, 150 deletions
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java
index 92e5afa..1373b8c 100644
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java
+++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java
@@ -1,8 +1,7 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.msnaccregwizz;
@@ -18,12 +17,14 @@ 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
* @author Damian Minkov
*/
-public class FirstWizardPage extends JPanel
- implements WizardPage, DocumentListener {
+public class FirstWizardPage
+ extends JPanel
+ implements WizardPage, DocumentListener
+{
public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
@@ -37,71 +38,67 @@ public class FirstWizardPage extends JPanel
private JLabel passLabel = new JLabel(Resources.getString("password"));
- private JLabel existingAccountLabel
- = new JLabel(Resources.getString("existingAccount"));
-
+ private JLabel existingAccountLabel =
+ new JLabel(Resources.getString("existingAccount"));
+
private JPanel emptyPanel = new JPanel();
-
+
private JLabel uinExampleLabel = new JLabel("Ex: johnsmith@hotmail.com");
-
+
private JTextField uinField = new JTextField();
private JPasswordField passField = new JPasswordField();
- private JCheckBox rememberPassBox = new JCheckBox(
- Resources.getString("rememberPassword"));
+ private JCheckBox rememberPassBox =
+ new JCheckBox(Resources.getString("rememberPassword"));
private JPanel mainPanel = new JPanel();
-
- private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
- private MsnAccountRegistration registration;
+ private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
- private WizardContainer wizardContainer;
+ private MsnAccountRegistrationWizard wizard;
/**
* Creates an instance of <tt>FirstWizardPage</tt>.
- * @param registration the <tt>MsnAccountRegistration</tt>, where
- * all data through the wizard are stored
- * @param wizardContainer the wizardContainer, where this page will
- * be added
+ *
+ * @param wizard the parent wizard
*/
- public FirstWizardPage(MsnAccountRegistration registration,
- WizardContainer wizardContainer) {
+ public FirstWizardPage( MsnAccountRegistrationWizard wizard)
+ {
super(new BorderLayout());
- this.wizardContainer = wizardContainer;
-
- this.registration = registration;
-
- this.setPreferredSize(new Dimension(300, 150));
+ this.wizard = wizard;
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));
+
+ 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() {
+ private void init()
+ {
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));
-
+ this.uinExampleLabel.setBorder(
+ BorderFactory.createEmptyBorder(0, 0, 8, 0));
+
labelsPanel.add(uinLabel);
labelsPanel.add(emptyPanel);
labelsPanel.add(passLabel);
@@ -114,18 +111,19 @@ public class FirstWizardPage extends JPanel
uinPassPanel.add(valuesPanel, BorderLayout.CENTER);
uinPassPanel.add(rememberPassBox, BorderLayout.SOUTH);
- uinPassPanel.setBorder(BorderFactory
- .createTitledBorder(Resources.getString("uinAndPassword")));
+ uinPassPanel.setBorder(BorderFactory.createTitledBorder(Resources
+ .getString("uinAndPassword")));
mainPanel.add(uinPassPanel);
this.add(mainPanel, BorderLayout.NORTH);
}
/**
- * Implements the <code>WizardPage.getIdentifier</code> to return
- * this page identifier.
+ * Implements the <code>WizardPage.getIdentifier</code> to return this
+ * page identifier.
*/
- public Object getIdentifier() {
+ public Object getIdentifier()
+ {
return FIRST_PAGE_IDENTIFIER;
}
@@ -133,7 +131,8 @@ public class FirstWizardPage extends JPanel
* Implements the <code>WizardPage.getNextPageIdentifier</code> to return
* the next page identifier - the summary page.
*/
- public Object getNextPageIdentifier() {
+ public Object getNextPageIdentifier()
+ {
return nextPageIdentifier;
}
@@ -141,15 +140,17 @@ public class FirstWizardPage extends JPanel
* Implements the <code>WizardPage.getBackPageIdentifier</code> to return
* the next back identifier - the default page.
*/
- public Object getBackPageIdentifier() {
+ public Object getBackPageIdentifier()
+ {
return WizardPage.DEFAULT_PAGE_IDENTIFIER;
}
/**
- * Implements the <code>WizardPage.getWizardForm</code> to return
- * this panel.
+ * Implements the <code>WizardPage.getWizardForm</code> to return this
+ * panel.
*/
- public Object getWizardForm() {
+ public Object getWizardForm()
+ {
return this;
}
@@ -157,50 +158,64 @@ public class FirstWizardPage extends JPanel
* Before this page is displayed enables or disables the "Next" wizard
* button according to whether the UIN field is empty.
*/
- public void pageShowing() {
+ public void pageShowing()
+ {
this.setNextButtonAccordingToUIN();
}
/**
* Saves the user input when the "Next" wizard buttons is clicked.
*/
- public void pageNext() {
+ public void pageNext()
+ {
String uin = uinField.getText();
-
- if(isExistingAccount(uin)) {
+
+ if (!wizard.isModification() && isExistingAccount(uin))
+ {
nextPageIdentifier = FIRST_PAGE_IDENTIFIER;
uinPassPanel.add(existingAccountLabel, BorderLayout.NORTH);
this.revalidate();
}
- else {
+ else
+ {
nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
uinPassPanel.remove(existingAccountLabel);
-
+
+ MsnAccountRegistration registration
+ = wizard.getRegistration();
+
registration.setUin(uinField.getText());
- registration.setPassword(new String(passField.getPassword()));
+
+ if (passField.getPassword() != null)
+ registration.setPassword(new String(passField.getPassword()));
+
registration.setRememberPassword(rememberPassBox.isSelected());
}
}
/**
- * Enables or disables the "Next" wizard button according to whether the
- * UIN field is empty.
+ * 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);
+ private void setNextButtonAccordingToUIN()
+ {
+ if (uinField.getText() == null || uinField.getText().equals(""))
+ {
+ wizard.getWizardContainer().setNextFinishButtonEnabled(false);
}
- else {
- wizardContainer.setNextFinishButtonEnabled(true);
+ else
+ {
+ wizard.getWizardContainer().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.
+ * 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) {
+ public void insertUpdate(DocumentEvent e)
+ {
this.setNextButtonAccordingToUIN();
}
@@ -209,52 +224,62 @@ public class FirstWizardPage extends JPanel
* from the UIN field. Enables or disables the "Next" wizard button
* according to whether the UIN field is empty.
*/
- public void removeUpdate(DocumentEvent e) {
+ public void removeUpdate(DocumentEvent e)
+ {
this.setNextButtonAccordingToUIN();
}
- public void changedUpdate(DocumentEvent e) {
+ public void changedUpdate(DocumentEvent e)
+ {
}
- public void pageHiding() {
+ public void pageHiding()
+ {
}
- public void pageShown() {
+ public void pageShown()
+ {
}
- public void pageBack() {
+ 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.
+ *
+ * @param protocolProvider The <tt>ProtocolProviderService</tt> to load
+ * the data from.
*/
- public void loadAccount(ProtocolProviderService protocolProvider) {
+ public void loadAccount(ProtocolProviderService protocolProvider)
+ {
AccountID accountID = protocolProvider.getAccountID();
- String password = (String)accountID.getAccountProperties()
- .get(ProtocolProviderFactory.PASSWORD);
+ String password =
+ (String) accountID.getAccountProperties().get(
+ ProtocolProviderFactory.PASSWORD);
this.uinField.setText(accountID.getUserID());
- if(password != null) {
+ if (password != null)
+ {
this.passField.setText(password);
this.rememberPassBox.setSelected(true);
}
}
-
+
private boolean isExistingAccount(String accountName)
- {
- ProtocolProviderFactory factory
- = MsnAccRegWizzActivator.getMsnProtocolProviderFactory();
-
+ {
+ ProtocolProviderFactory factory =
+ MsnAccRegWizzActivator.getMsnProtocolProviderFactory();
+
ArrayList registeredAccounts = factory.getRegisteredAccounts();
-
- for(int i = 0; i < registeredAccounts.size(); i ++) {
+
+ for (int i = 0; i < registeredAccounts.size(); i++)
+ {
AccountID accountID = (AccountID) registeredAccounts.get(i);
-
- if(accountName.equalsIgnoreCase(accountID.getUserID()))
+
+ if (accountName.equalsIgnoreCase(accountID.getUserID()))
return true;
}
return false;
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java
index 6d3e36a..0e0f953 100644
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java
+++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java
@@ -27,9 +27,11 @@ public class MsnAccRegWizzActivator implements BundleActivator {
private static ConfigurationService configService;
private static AccountRegistrationWizardContainer wizardContainer;
-
+
private static MsnAccountRegistrationWizard msnWizard;
-
+
+ private static UIService uiService;
+
/**
* Starts this bundle.
* @param bc BundleContext
@@ -42,7 +44,7 @@ public class MsnAccRegWizzActivator implements BundleActivator {
ServiceReference uiServiceRef = bundleContext
.getServiceReference(UIService.class.getName());
- UIService uiService
+ uiService
= (UIService) bundleContext.getService(uiServiceRef);
wizardContainer = uiService.getAccountRegWizardContainer();
@@ -79,4 +81,14 @@ public class MsnAccRegWizzActivator implements BundleActivator {
return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
}
+
+ /**
+ * Returns the <tt>UIService</tt>.
+ *
+ * @return the <tt>UIService</tt>
+ */
+ public static UIService getUIService()
+ {
+ return uiService;
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java
index 9acb0a4..81a8026 100644
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java
@@ -1,66 +1,66 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.msnaccregwizz;
+import java.awt.*;
import java.util.*;
-import javax.swing.*;
-
-import org.osgi.framework.*;
-
-import net.java.sip.communicator.impl.gui.customcontrols.*;
-import net.java.sip.communicator.plugin.jabberaccregwizz.*;
-import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
+import org.osgi.framework.*;
+
/**
* The <tt>MsnAccountRegistrationWizard</tt> is an implementation of the
* <tt>AccountRegistrationWizard</tt> for the Msn protocol. It should allow
* the user to create and configure a new Msn account.
- *
+ *
* @author Yana Stamcheva
*/
-public class MsnAccountRegistrationWizard implements AccountRegistrationWizard {
+public class MsnAccountRegistrationWizard
+ implements AccountRegistrationWizard
+{
private FirstWizardPage firstWizardPage;
- private MsnAccountRegistration registration
- = new MsnAccountRegistration();
+ private MsnAccountRegistration registration = new MsnAccountRegistration();
private WizardContainer wizardContainer;
private ProtocolProviderService protocolProvider;
- private String propertiesPackage = "net.java.sip.communicator.plugin.msnaccregwizz";
-
+ private String propertiesPackage =
+ "net.java.sip.communicator.plugin.msnaccregwizz";
+
private boolean isModification;
/**
* Creates an instance of <tt>MsnAccountRegistrationWizard</tt>.
- * @param wizardContainer the wizard container, where this wizard
- * is added
+ *
+ * @param wizardContainer the wizard container, where this wizard is added
*/
- public MsnAccountRegistrationWizard(WizardContainer wizardContainer) {
+ public MsnAccountRegistrationWizard(WizardContainer wizardContainer)
+ {
this.wizardContainer = wizardContainer;
}
/**
* Implements the <code>AccountRegistrationWizard.getIcon</code> method.
* Returns the icon to be used for this wizard.
+ *
* @return byte[]
*/
- public byte[] getIcon() {
+ public byte[] getIcon()
+ {
return Resources.getImage(Resources.MSN_LOGO);
}
-
+
/**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
- * Returns the image used to decorate the wizard page
+ * 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
*/
@@ -69,32 +69,38 @@ public class MsnAccountRegistrationWizard implements AccountRegistrationWizard {
return Resources.getImage(Resources.PAGE_IMAGE);
}
-
/**
* Implements the <code>AccountRegistrationWizard.getProtocolName</code>
* method. Returns the protocol name for this wizard.
+ *
* @return String
*/
- public String getProtocolName() {
+ public String getProtocolName()
+ {
return Resources.getString("protocolName");
}
/**
* Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code> method. Returns the description of the protocol for this wizard.
+ * </code>
+ * method. Returns the description of the protocol for this wizard.
+ *
* @return String
*/
- public String getProtocolDescription() {
+ public String getProtocolDescription()
+ {
return Resources.getString("protocolDescription");
}
/**
* Returns the set of pages contained in this wizard.
+ *
* @return Iterator
*/
- public Iterator getPages() {
+ public Iterator getPages()
+ {
ArrayList pages = new ArrayList();
- firstWizardPage = new FirstWizardPage(registration, wizardContainer);
+ firstWizardPage = new FirstWizardPage(this);
pages.add(firstWizardPage);
@@ -103,88 +109,151 @@ public class MsnAccountRegistrationWizard implements AccountRegistrationWizard {
/**
* Returns the set of data that user has entered through this wizard.
+ *
* @return Iterator
*/
- public Iterator getSummary() {
+ public Iterator getSummary()
+ {
Hashtable summaryTable = new Hashtable();
summaryTable.put("UIN", registration.getUin());
- summaryTable.put("Remember password",
- new Boolean(registration.isRememberPassword()));
+ summaryTable.put("Remember password", new Boolean(registration
+ .isRememberPassword()));
return summaryTable.entrySet().iterator();
}
/**
* Installs the account created through this wizard.
+ *
* @return ProtocolProviderService
*/
- public ProtocolProviderService finish() {
+ public ProtocolProviderService finish()
+ {
firstWizardPage = null;
- ProtocolProviderFactory factory
- = MsnAccRegWizzActivator.getMsnProtocolProviderFactory();
+ ProtocolProviderFactory factory =
+ MsnAccRegWizzActivator.getMsnProtocolProviderFactory();
- return this.installAccount(factory,
- registration.getUin(), registration.getPassword());
+ 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 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) {
+ ProtocolProviderFactory providerFactory, String user, String passwd)
+ {
Hashtable accountProperties = new Hashtable();
- if(registration.isRememberPassword()) {
+ if (registration.isRememberPassword())
+ {
accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
}
- if(isModification) {
+ if (isModification)
+ {
providerFactory.uninstallAccount(protocolProvider.getAccountID());
this.protocolProvider = null;
+ this.isModification = false;
}
- try {
- AccountID accountID = providerFactory.installAccount(
- user, accountProperties);
+ try
+ {
+ AccountID accountID =
+ providerFactory.installAccount(user, accountProperties);
- ServiceReference serRef = providerFactory
- .getProviderForAccount(accountID);
-
- protocolProvider
- = (ProtocolProviderService) MsnAccRegWizzActivator.bundleContext
+ ServiceReference serRef =
+ providerFactory.getProviderForAccount(accountID);
+
+ protocolProvider =
+ (ProtocolProviderService) MsnAccRegWizzActivator.bundleContext
.getService(serRef);
}
- catch (IllegalArgumentException e) {
- new ErrorDialog(null, e.getMessage(), e).showDialog();
+ catch (IllegalArgumentException e)
+ {
+ MsnAccRegWizzActivator.getUIService().getPopupDialog()
+ .showMessagePopupDialog(e.getMessage(),
+ Resources.getString("error"),
+ PopupDialog.ERROR_MESSAGE);
+ }
+ catch (IllegalStateException e)
+ {
+ MsnAccRegWizzActivator.getUIService().getPopupDialog()
+ .showMessagePopupDialog(e.getMessage(),
+ Resources.getString("error"),
+ PopupDialog.ERROR_MESSAGE);
}
- 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
+ * Fills the UIN and Password fields in this panel with the data coming
* from the given protocolProvider.
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load the
- * data from.
+ *
+ * @param protocolProvider The <tt>ProtocolProviderService</tt> to load
+ * the data from.
*/
- public void loadAccount(ProtocolProviderService protocolProvider) {
+ public void loadAccount(ProtocolProviderService protocolProvider)
+ {
+ this.isModification = true;
this.protocolProvider = protocolProvider;
+ this.registration = new MsnAccountRegistration();
+
this.firstWizardPage.loadAccount(protocolProvider);
-
- this.isModification = true;
+ }
+
+ /**
+ * Indicates if this wizard is opened for modification or for creating a
+ * new account.
+ *
+ * @return <code>true</code> if this wizard is opened for modification and
+ * <code>false</code> otherwise.
+ */
+ public boolean isModification()
+ {
+ return isModification;
+ }
+
+ /**
+ * Returns the wizard container, where all pages are added.
+ *
+ * @return the wizard container, where all pages are added
+ */
+ public WizardContainer getWizardContainer()
+ {
+ return wizardContainer;
+ }
+
+ /**
+ * Returns the registration object, which will store all the data through
+ * the wizard.
+ *
+ * @return the registration object, which will store all the data through
+ * the wizard
+ */
+ public MsnAccountRegistration getRegistration()
+ {
+ return registration;
+ }
+
+ /**
+ * Returns the size of this wizard.
+ * @return the size of this wizard
+ */
+ public Dimension getSize()
+ {
+ return new Dimension(600, 500);
}
}
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/resources.properties b/src/net/java/sip/communicator/plugin/msnaccregwizz/resources.properties
index 612b680..1cbb040 100755
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/resources.properties
+++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/resources.properties
@@ -5,6 +5,7 @@ password=Password:
rememberPassword=Remember password
uinAndPassword=ID and Password
existingAccount=* The account you entered is already installed.
+error=Error
protocolIcon=resources/images/msn/msn16x16.png
pageImage=resources/images/msn/msn64x64.png