diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderFactoryJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderFactoryJabberImpl.java index a4c448178..025b7ae3a 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderFactoryJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderFactoryJabberImpl.java @@ -305,7 +305,79 @@ public void modifyAccount( ProtocolProviderService protocolProvider, Map accountProperties) throws NullPointerException { - // TODO Auto-generated method stub - + BundleContext context + = JabberActivator.getBundleContext(); + + if (context == null) + throw new NullPointerException( + "The specified BundleContext was null"); + + if (protocolProvider == null) + throw new NullPointerException( + "The specified Protocol Provider was null"); + + JabberAccountID accountID + = (JabberAccountID) protocolProvider.getAccountID(); + + // If the given accountID doesn't correspond to an existing account + // we return. + if(!registeredAccounts.containsKey(accountID)) + return; + + ServiceRegistration registration + = (ServiceRegistration) registeredAccounts.get(accountID); + + // kill the service + if (registration != null) + registration.unregister(); + + if (accountProperties == null) + throw new NullPointerException( + "The specified property map was null"); + + accountProperties.put(USER_ID, accountID.getUserID()); + + String serverAddress = (String) accountProperties.get(SERVER_ADDRESS); + + if(serverAddress == null) + throw new NullPointerException("null is not a valid ServerAddress"); + + // if server port is null, we will set default value + if(accountProperties.get(SERVER_PORT) == null) + { + accountProperties.put(SERVER_PORT, + "5222"); + } + + if (!accountProperties.containsKey(PROTOCOL)) + accountProperties.put(PROTOCOL, ProtocolNames.JABBER); + + accountID.setAccountProperties(accountProperties); + + // First store the account and only then load it as the load generates + // an osgi event, the osgi event triggers (trhgough the UI) a call to + // the register() method and it needs to acces the configuration service + // and check for a password. + this.storeAccount(JabberActivator.getBundleContext(), accountID); + + Hashtable properties = new Hashtable(); + properties.put(PROTOCOL, ProtocolNames.JABBER); + properties.put(USER_ID, accountID.getUserID()); + + ((ProtocolProviderServiceJabberImpl) protocolProvider) + .initialize(accountID.getUserID(), accountID); + + // We store again the account in order to store all properties added + // during the protocol provider initialization. + this.storeAccount( + JabberActivator.getBundleContext(), accountID); + + registration + = context.registerService( + ProtocolProviderService.class.getName(), + protocolProvider, + properties); + + registeredAccounts.put(accountID, registration); } } diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java index 9d4d83e74..9d9c7b925 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java @@ -9,6 +9,7 @@ import java.util.*; import org.osgi.framework.*; + import net.java.sip.communicator.service.protocol.*; /** @@ -267,7 +268,66 @@ public void modifyAccount( ProtocolProviderService protocolProvider, Map accountProperties) throws NullPointerException { - // TODO Auto-generated method stub - + BundleContext context + = MsnActivator.getBundleContext(); + + if (context == null) + throw new NullPointerException( + "The specified BundleContext was null"); + + if (protocolProvider == null) + throw new NullPointerException( + "The specified Protocol Provider was null"); + + MsnAccountID accountID = (MsnAccountID) protocolProvider.getAccountID(); + + // If the given accountID doesn't correspond to an existing account + // we return. + if(!registeredAccounts.containsKey(accountID)) + return; + + ServiceRegistration registration + = (ServiceRegistration) registeredAccounts.get(accountID); + + // kill the service + if (registration != null) + registration.unregister(); + + if (accountProperties == null) + throw new NullPointerException( + "The specified property map was null"); + + accountProperties.put(USER_ID, accountID.getUserID()); + + if (!accountProperties.containsKey(PROTOCOL)) + accountProperties.put(PROTOCOL, ProtocolNames.MSN); + + accountID.setAccountProperties(accountProperties); + + // First store the account and only then load it as the load generates + // an osgi event, the osgi event triggers (trhgough the UI) a call to + // the register() method and it needs to acces the configuration service + // and check for a password. + this.storeAccount(MsnActivator.getBundleContext(), accountID); + + Hashtable properties = new Hashtable(); + properties.put(PROTOCOL, ProtocolNames.MSN); + properties.put(USER_ID, accountID.getUserID()); + + ((ProtocolProviderServiceMsnImpl)protocolProvider) + .initialize(accountID.getUserID(), accountID); + + // We store again the account in order to store all properties added + // during the protocol provider initialization. + this.storeAccount( + MsnActivator.getBundleContext(), accountID); + + registration + = context.registerService( + ProtocolProviderService.class.getName(), + protocolProvider, + properties); + + registeredAccounts.put(accountID, registration); } } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java index 1c3a4be32..f158c2a49 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java @@ -184,12 +184,12 @@ public void modifyAccount( ProtocolProviderService protocolProvider, if (registration != null) registration.unregister(); - accountProperties.put(USER_ID, accountID.getUserID()); - if (accountProperties == null) throw new NullPointerException( "The specified property map was null"); + accountProperties.put(USER_ID, accountID.getUserID()); + String serverAddress = (String) accountProperties.get(SERVER_ADDRESS); if(serverAddress == null) diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java index 4c6ae4c91..409143520 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java @@ -9,6 +9,7 @@ import java.util.*; import org.osgi.framework.*; + import net.java.sip.communicator.service.protocol.*; /** @@ -267,7 +268,67 @@ public void modifyAccount( ProtocolProviderService protocolProvider, Map accountProperties) throws NullPointerException { - // TODO Auto-generated method stub - + BundleContext context + = YahooActivator.getBundleContext(); + + if (context == null) + throw new NullPointerException( + "The specified BundleContext was null"); + + if (protocolProvider == null) + throw new NullPointerException( + "The specified Protocol Provider was null"); + + YahooAccountID accountID + = (YahooAccountID) protocolProvider.getAccountID(); + + // If the given accountID doesn't correspond to an existing account + // we return. + if(!registeredAccounts.containsKey(accountID)) + return; + + ServiceRegistration registration + = (ServiceRegistration) registeredAccounts.get(accountID); + + // kill the service + if (registration != null) + registration.unregister(); + + if (accountProperties == null) + throw new NullPointerException( + "The specified property map was null"); + + accountProperties.put(USER_ID, accountID.getUserID()); + + if (!accountProperties.containsKey(PROTOCOL)) + accountProperties.put(PROTOCOL, ProtocolNames.YAHOO); + + accountID.setAccountProperties(accountProperties); + + // First store the account and only then load it as the load generates + // an osgi event, the osgi event triggers (trhgough the UI) a call to + // the register() method and it needs to acces the configuration service + // and check for a password. + this.storeAccount(YahooActivator.getBundleContext(), accountID); + + Hashtable properties = new Hashtable(); + properties.put(PROTOCOL, ProtocolNames.YAHOO); + properties.put(USER_ID, accountID.getUserID()); + + ((ProtocolProviderServiceYahooImpl)protocolProvider) + .initialize(accountID.getUserID(), accountID); + + // We store again the account in order to store all properties added + // during the protocol provider initialization. + this.storeAccount( + YahooActivator.getBundleContext(), accountID); + + registration + = context.registerService( + ProtocolProviderService.class.getName(), + protocolProvider, + properties); + + registeredAccounts.put(accountID, registration); } } diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java index b3da6df28..3aa347d4a 100644 --- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountRegistrationWizard.java @@ -210,9 +210,12 @@ public ProtocolProviderService installAccount( if (isModification) { - providerFactory.uninstallAccount(protocolProvider.getAccountID()); - this.protocolProvider = null; + providerFactory.modifyAccount( protocolProvider, + accountProperties); + this.isModification = false; + + return protocolProvider; } try diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java index 5141301c4..394c5c747 100644 --- a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java @@ -176,9 +176,12 @@ public ProtocolProviderService installAccount( if (isModification) { - providerFactory.uninstallAccount(protocolProvider.getAccountID()); - this.protocolProvider = null; + providerFactory.modifyAccount( protocolProvider, + accountProperties); + this.isModification = false; + + return protocolProvider; } try diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccountRegistrationWizard.java index 867c648e4..5b3482b70 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccountRegistrationWizard.java @@ -259,13 +259,9 @@ private ProtocolProviderService installAccount( if(isModification) { -// new ProviderUnRegistration(protocolProvider).unregister(); - providerFactory.modifyAccount( protocolProvider, accountProperties); -// new ProviderRegistration(protocolProvider).register(); - this.isModification = false; return protocolProvider; diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java index 3fd82ebd6..da0d8e1b6 100644 --- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java @@ -165,7 +165,6 @@ public ProtocolProviderService signin(String userName, String password) public ProtocolProviderService installAccount( ProtocolProviderFactory providerFactory, String user, String passwd) { - Hashtable accountProperties = new Hashtable(); if (registration.isRememberPassword()) @@ -175,9 +174,12 @@ public ProtocolProviderService installAccount( if (isModification) { - providerFactory.uninstallAccount(protocolProvider.getAccountID()); - this.protocolProvider = null; - this.isModification = false; + providerFactory.modifyAccount( protocolProvider, + accountProperties); + + this.isModification = false; + + return protocolProvider; } try