Implement "Modify" for Jabber, MSN, SIP and Yahoo.

cusax-fix
Yana Stamcheva 18 years ago
parent 225b7b6710
commit 2b835083ad

@ -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);
}
}

@ -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);
}
}

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

@ -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);
}
}

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

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

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

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

Loading…
Cancel
Save