modify account

cusax-fix
Yana Stamcheva 20 years ago
parent 5701da3bf4
commit 4bae517366

@ -141,10 +141,16 @@ public void pageNext() {
this.wizardContainer.addAccountWizard(protocolProvider, wizard);
this.wizardContainer.unregisterWizardPage(
WizardPage.DEFAULT_PAGE_IDENTIFIER);
this.wizardContainer.unregisterWizardPage(
WizardPage.SUMMARY_PAGE_IDENTIFIER);
if(wizardContainer.containsPage(WizardPage.DEFAULT_PAGE_IDENTIFIER)) {
this.wizardContainer.unregisterWizardPage(
WizardPage.DEFAULT_PAGE_IDENTIFIER);
}
if(wizardContainer.containsPage(WizardPage.SUMMARY_PAGE_IDENTIFIER)) {
this.wizardContainer.unregisterWizardPage(
WizardPage.SUMMARY_PAGE_IDENTIFIER);
}
this.wizardContainer.unregisterAll();
this.wizardContainer.removeWizzardIcon();
}

@ -8,14 +8,16 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.imageio.ImageIO;
import net.java.sip.communicator.impl.gui.GuiActivator;
import net.java.sip.communicator.impl.gui.customcontrols.wizard.Wizard;
import net.java.sip.communicator.impl.gui.i18n.Messages;
import net.java.sip.communicator.service.configuration.ConfigurationService;
import net.java.sip.communicator.service.gui.AccountRegistrationWizard;
import net.java.sip.communicator.service.gui.AccountRegistrationWizardContainer;
import net.java.sip.communicator.service.gui.WizardPage;
@ -38,11 +40,11 @@ public class AccountRegWizardContainerImpl extends Wizard
private AccountRegFirstPage firstPage;
private AccountRegSummaryPage summaryPage;
private Hashtable accountWizards = new Hashtable();
private AccountRegistrationWizard currentWizard;
ConfigurationService configService
= GuiActivator.getConfigurationService();
/**
* Listeners interested in events dispatched upon modifications
* in the account registrations list.
@ -171,6 +173,9 @@ public AccountRegSummaryPage getSummaryPage() {
return summaryPage;
}
/**
* Opens a wizard for creating a new account.
*/
public void newAccount() {
this.registerWizardPage(firstPage.getIdentifier(), firstPage);
@ -180,18 +185,41 @@ public void newAccount() {
}
/**
* Opens the corresponding wizard to modify an existing account given by
* the <tt>protocolProvider</tt> parameter.
*
* @param protocolProvider
* @param protocolProvider The <tt>ProtocolProviderService</tt> for the
* account to modify.
*/
public void modifyAccount(ProtocolProviderService protocolProvider) {
this.registerWizardPage(summaryPage.getIdentifier(), summaryPage);
AccountRegistrationWizard wizard = (AccountRegistrationWizard)
this.accountWizards.get(protocolProvider);
String wizardClassName = null;
this.setCurrentWizard(wizard);
String prefix = "net.java.sip.communicator.impl.ui";
wizard.loadAccount(protocolProvider);
List accounts = this.configService
.getPropertyNamesByPrefix(prefix, true);
Iterator accountsIter = accounts.iterator();
while(accountsIter.hasNext()) {
String accountRootPropName = (String) accountsIter.next();
String accountUID = configService.getString(accountRootPropName);
if(accountUID.equals(protocolProvider
.getAccountID().getAccountUniqueID())) {
wizardClassName = configService.getString(
accountRootPropName + ".WIZARD");
}
}
AccountRegistrationWizard wizard
= getWizardFromClassName(wizardClassName);
this.registerWizardPage(summaryPage.getIdentifier(), summaryPage);
this.setCurrentWizard(wizard);
Iterator i = wizard.getPages();
@ -211,6 +239,8 @@ public void modifyAccount(ProtocolProviderService protocolProvider) {
}
}
wizard.loadAccount(protocolProvider);
this.getSummaryPage()
.setPreviousPageIdentifier(identifier);
@ -224,22 +254,72 @@ public void modifyAccount(ProtocolProviderService protocolProvider) {
}
/**
* Adds the (protocol provider, wizard) pair.
* Saves the (protocol provider, wizard) pair in through the
* <tt>ConfigurationService</tt>.
*
* @param protocolProvider
* @param wizard
* @param protocolProvider the protocol provider to save
* @param wizard the wizard to save
*/
public void addAccountWizard(
ProtocolProviderService protocolProvider,
AccountRegistrationWizard wizard) {
this.accountWizards.put(protocolProvider, wizard);
String accNodeName
= "acc" + Long.toString(System.currentTimeMillis());
String wizardClassName = wizard.getClass()
.getName().replace('.', '_');
String accountPackage = "net.java.sip.communicator.impl.ui."
+ accNodeName;
configService.setProperty(accountPackage,
protocolProvider.getAccountID().getAccountUniqueID());
configService.setProperty(accountPackage+".WIZARD",
wizardClassName);
}
/**
* Returns the currently used <tt>AccountRegistrationWizard</tt>.
* @return the currently used <tt>AccountRegistrationWizard</tt>
*/
public AccountRegistrationWizard getCurrentWizard() {
return currentWizard;
}
/**
* Sets the currently used <tt>AccountRegistrationWizard</tt>.
* @param currentWizard the <tt>AccountRegistrationWizard</tt> to set
* as current one
*/
public void setCurrentWizard(AccountRegistrationWizard currentWizard) {
this.currentWizard = currentWizard;
}
/**
* Returns the <tt>AccountRegistrationWizard</tt> corresponding to the
* given class name.
* @param wizardClassName the class name of the searched wizard
* @return the <tt>AccountRegistrationWizard</tt> corresponding to the
* given class name
*/
private AccountRegistrationWizard getWizardFromClassName(
String wizardClassName) {
Iterator i = this.firstPage.getWizardsList();
while(i.hasNext()) {
AccountRegistrationWizard wizard
= (AccountRegistrationWizard)i.next();
String wizardClassName1 = wizard.getClass()
.getName().replace('.', '_');
if(wizardClassName1.equals(wizardClassName)) {
return wizard;
}
}
return null;
}
}

@ -25,6 +25,9 @@
import net.java.sip.communicator.service.gui.WizardContainer;
import net.java.sip.communicator.service.gui.WizardPage;
import net.java.sip.communicator.service.protocol.AccountID;
import net.java.sip.communicator.service.protocol.ProtocolProviderFactory;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
/**
* The <tt>FirstWizardPage</tt> is the page, where user could enter the uin
@ -223,4 +226,22 @@ 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,
boolean rememberPassword) {
AccountID accountID = protocolProvider.getAccountID();
String password = (String)accountID.getAccountProperties()
.get(ProtocolProviderFactory.PASSWORD);
this.uinField.setText(accountID.getUserID());
this.passField.setText(password);
this.rememberPassBox.setSelected(rememberPassword);
}
}

@ -6,11 +6,11 @@
*/
package net.java.sip.communicator.plugin.icqaccregwizz;
import net.java.sip.communicator.service.configuration.ConfigurationService;
import net.java.sip.communicator.service.gui.AccountRegistrationWizardContainer;
import net.java.sip.communicator.service.gui.UIService;
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;
@ -30,6 +30,8 @@ public class IcqAccRegWizzActivator implements BundleActivator {
private static Logger logger = Logger.getLogger(
IcqAccRegWizzActivator.class.getName());
private static ConfigurationService configService;
/**
* Starts this bundle.
*/
@ -55,6 +57,10 @@ public void start(BundleContext bc) throws Exception {
public void stop(BundleContext bundleContext) throws Exception {
}
/**
* Returns the <tt>ProtocolProviderFactory</tt> for the ICQ protocol.
* @return the <tt>ProtocolProviderFactory</tt> for the ICQ protocol
*/
public static ProtocolProviderFactory getIcqProtocolProviderFactory() {
ServiceReference[] serRefs = null;
@ -73,4 +79,20 @@ public static ProtocolProviderFactory getIcqProtocolProviderFactory() {
return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
}
/**
* Returns the <tt>ConfigurationService</tt>.
* @return the <tt>ConfigurationService</tt>
*/
public static ConfigurationService getConfigurationService() {
if(configService == null) {
ServiceReference configReference = bundleContext
.getServiceReference(ConfigurationService.class.getName());
configService = (ConfigurationService) bundleContext
.getService(configReference);
}
return configService;
}
}

@ -10,15 +10,15 @@
import java.util.Hashtable;
import java.util.Iterator;
import org.osgi.framework.ServiceReference;
import net.java.sip.communicator.service.configuration.ConfigurationService;
import net.java.sip.communicator.service.gui.AccountRegistrationWizard;
import net.java.sip.communicator.service.gui.WizardContainer;
import net.java.sip.communicator.service.protocol.AccountID;
import net.java.sip.communicator.service.protocol.AccountProperties;
import net.java.sip.communicator.service.protocol.ProtocolProviderFactory;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
import org.osgi.framework.ServiceReference;
/**
* The <tt>IcqAccountRegistrationWizard</tt> is an implementation of the
* <tt>AccountRegistrationWizard</tt> for the ICQ protocol. It should allow
@ -35,6 +35,13 @@ public class IcqAccountRegistrationWizard implements AccountRegistrationWizard {
private WizardContainer wizardContainer;
ConfigurationService configService
= IcqAccRegWizzActivator.getConfigurationService();
private ProtocolProviderService protocolProvider;
private String propertiesPackage = "net.java.sip.communicator.plugin.icqaccregwizz";
/**
* Creates an instance of <tt>IcqAccountRegistrationWizard</tt>.
* @param wizardContainer the wizard container, where this wizard
@ -124,22 +131,46 @@ public ProtocolProviderService installAccount(
if(registration.isRememberPassword()) {
accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
}
if(protocolProvider != null) {
providerFactory.uninstallAccount(protocolProvider.getAccountID());
this.protocolProvider = null;
}
AccountID accountID = providerFactory.installAccount(
user, accountProperties);
configService.setProperty(
propertiesPackage + ".REMEMBER_PASSWORD",
new Boolean(registration.isRememberPassword())
);
ServiceReference serRef = providerFactory
.getProviderForAccount(accountID);
ProtocolProviderService protocolProvider
= (ProtocolProviderService) IcqAccRegWizzActivator.bundleContext
.getService(serRef);
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) {
System.out.println("LOAD ACCOUNT!!!!!!!!!!!!!!!!!!");
this.protocolProvider = protocolProvider;
boolean rememberPassword
= new Boolean(configService
.getString(propertiesPackage + ".REMEMBER_PASSWORD"))
.booleanValue();
this.firstWizardPage.loadAccount(
protocolProvider, rememberPassword);
}
}

Loading…
Cancel
Save