diff options
Diffstat (limited to 'src/net/java/sip/communicator/impl')
13 files changed, 371 insertions, 39 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java b/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java index c5a545a..d395cd5 100644 --- a/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java +++ b/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java @@ -171,10 +171,10 @@ public class AccountsConfigurationForm extends JPanel boolean isHidden = accountID.getAccountProperties(). get("HIDDEN_PROTOCOL") != null; - + if(isHidden) continue; - + serRef = providerFactory .getProviderForAccount(accountID); @@ -398,13 +398,6 @@ public class AccountsConfigurationForm extends JPanel } } - if(sourceFactory.getRegisteredAccounts().contains( - pps.getAccountID())) - { - //the account is still installed. we don't need to do anything. - return; - } - tableModel.removeRow(tableModel.rowIndexOf(pps)); } } diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderFactoryDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderFactoryDictImpl.java index 17a1253..8560aba 100644 --- a/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderFactoryDictImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/dict/ProtocolProviderFactoryDictImpl.java @@ -8,7 +8,6 @@ package net.java.sip.communicator.impl.protocol.dict; import java.util.*; -import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -348,4 +347,11 @@ public class ProtocolProviderFactoryDictImpl // Rename the default contact. mcl.renameMetaContact(group.getMetaContact(protocolProvider, dict_uin), accountID.getUserID() + "_default_dictionary"); } + + @Override + public void modifyAccount(ProtocolProviderService protocolProvider, + Map accountProperties) throws NullPointerException + { + // TODO Auto-generated method stub + } } diff --git a/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderFactoryGibberishImpl.java b/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderFactoryGibberishImpl.java index 43a2440..0d9e68d 100644 --- a/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderFactoryGibberishImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderFactoryGibberishImpl.java @@ -9,6 +9,7 @@ package net.java.sip.communicator.impl.protocol.gibberish; import java.util.*; import org.osgi.framework.*; + import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -126,6 +127,88 @@ public class ProtocolProviderFactoryGibberishImpl return accountID; } + + /** + * Modifies the account corresponding to the specified accountID. This + * method is meant to be used to change properties of already existing + * accounts. Note that if the given accountID doesn't correspond to any + * registered account this method would do nothing. + * + * @param accountID the user identifier uniquely representing the newly + * created account within the protocol namespace. + * @param accountProperties a set of protocol (or implementation) specific + * properties defining the new account. + * + * @throws java.lang.NullPointerException if any of the arguments is null. + */ + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + { + BundleContext context + = GibberishActivator.getBundleContext(); + + if (context == null) + throw new NullPointerException( + "The specified BundleContext was null"); + + if (protocolProvider == null) + throw new NullPointerException( + "The specified Protocol Provider was null"); + + GibberishAccountID accountID + = (GibberishAccountID) 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(); + + accountProperties.put(USER_ID, accountID.getUserID()); + + if (accountProperties == null) + throw new NullPointerException( + "The specified property map was null"); + + if (!accountProperties.containsKey(PROTOCOL)) + accountProperties.put(PROTOCOL, ProtocolNames.GIBBERISH); + + 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(GibberishActivator.getBundleContext(), accountID); + + Hashtable properties = new Hashtable(); + properties.put(PROTOCOL, ProtocolNames.GIBBERISH); + properties.put(USER_ID, accountID.getUserID()); + + ((ProtocolProviderServiceGibberishImpl) protocolProvider) + .initialize(accountID.getUserID(), accountID); + + // We store again the account in order to store all properties added + // during the protocol provider initialization. + this.storeAccount( + GibberishActivator.getBundleContext(), accountID); + + registration + = context.registerService( + ProtocolProviderService.class.getName(), + protocolProvider, + properties); + + // We store the modified account registration. + registeredAccounts.put(accountID, registration); + } + /** * Initializes and creates an account corresponding to the specified * accountProperties and registers the resulting ProtocolProvider in the diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderFactoryIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderFactoryIcqImpl.java index 2391b1b..8668290 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderFactoryIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderFactoryIcqImpl.java @@ -146,7 +146,10 @@ public class ProtocolProviderFactoryIcqImpl if((IcqAccountID.isAIM(accountProperties) && !isAimFactory) || (!IcqAccountID.isAIM(accountProperties) && isAimFactory)) return null; - + + if (!accountProperties.containsKey(PROTOCOL)) + accountProperties.put(PROTOCOL, ProtocolNames.ICQ); + String userIDStr = (String)accountProperties.get(USER_ID); AccountID accountID = new IcqAccountID(userIDStr, accountProperties); @@ -302,4 +305,71 @@ public class ProtocolProviderFactoryIcqImpl , accountID ); } + @Override + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + throws NullPointerException + { + BundleContext context + = IcqActivator.getBundleContext(); + + if (context == null) + throw new NullPointerException( + "The specified BundleContext was null"); + + if (protocolProvider == null) + throw new NullPointerException( + "The specified Protocol Provider was null"); + + IcqAccountID accountID = (IcqAccountID) 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(); + + accountProperties.put(USER_ID, accountID.getUserID()); + + if (accountProperties == null) + throw new NullPointerException( + "The specified property map was null"); + + if (!accountProperties.containsKey(PROTOCOL)) + accountProperties.put(PROTOCOL, ProtocolNames.ICQ); + + 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(IcqActivator.getBundleContext(), accountID); + + Hashtable properties = new Hashtable(); + properties.put(PROTOCOL, ProtocolNames.ICQ); + properties.put(USER_ID, accountID.getUserID()); + + ((ProtocolProviderServiceIcqImpl) protocolProvider) + .initialize(accountID.getUserID(), accountID); + + // We store again the account in order to store all properties added + // during the protocol provider initialization. + this.storeAccount( + IcqActivator.getBundleContext(), accountID); + + registration + = context.registerService( + ProtocolProviderService.class.getName(), + protocolProvider, + properties); + + registeredAccounts.put(accountID, registration); + } } diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java index 8d47dc0..3527d8c 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderFactoryIrcImpl.java @@ -236,4 +236,13 @@ public class ProtocolProviderFactoryIrcImpl return super.loadPassword(IrcActivator.bundleContext, accountID ); } + @Override + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + throws NullPointerException + { + // TODO Auto-generated method stub + + } + }
\ No newline at end of file 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 132ff35..a4c4481 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderFactoryJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderFactoryJabberImpl.java @@ -299,4 +299,13 @@ public class ProtocolProviderFactoryJabberImpl return super.loadPassword(JabberActivator.getBundleContext() , accountID ); } + + @Override + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + throws NullPointerException + { + // TODO Auto-generated method stub + + } } 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 9e79536..9d4d83e 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java @@ -261,4 +261,13 @@ public class ProtocolProviderFactoryMsnImpl return super.loadPassword(MsnActivator.getBundleContext() , accountID ); } + + @Override + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + throws NullPointerException + { + // TODO Auto-generated method stub + + } } diff --git a/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderFactoryRssImpl.java b/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderFactoryRssImpl.java index 81d43db..3b8007e 100644 --- a/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderFactoryRssImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderFactoryRssImpl.java @@ -270,4 +270,13 @@ public class ProtocolProviderFactoryRssImpl } } + @Override + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + throws NullPointerException + { + // TODO Auto-generated method stub + + } + } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java index a024cce..17a0b7e 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java @@ -588,23 +588,23 @@ public class OperationSetPresenceSipImpl String oldMessage = this.statusMessage; this.statusMessage = statusMsg; - // inform the listeners of these changes - this.fireProviderStatusChangeEvent(oldStatus); - this.fireProviderMsgStatusChangeEvent(oldMessage); - - if (this.presenceEnabled == false) { + if (this.presenceEnabled == false) + { return; } // in the offline status, the protocol provider is already unregistered - if (!status.equals(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE))) { + if (!status.equals(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE))) + { assertConnected(); } // now inform our distant presence agent if we have one - if (this.useDistantPA) { + if (this.useDistantPA) + { Request req = null; - if (status.equals(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE))) { + if (status.equals(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE))) + { // unpublish our state req = createPublish(0, false); @@ -614,10 +614,12 @@ public class OperationSetPresenceSipImpl this.waitedCallIds.add(((CallIdHeader) req.getHeader(CallIdHeader.NAME)).getCallId()); } - } else { + } + else + { req = createPublish(this.subscriptionDuration, true); } - + ClientTransaction transac = null; try { transac = this.parentProvider @@ -629,9 +631,12 @@ public class OperationSetPresenceSipImpl OperationFailedException.NETWORK_FAILURE); } - try { + try + { transac.sendRequest(); - } catch (SipException e) { + } + catch (SipException e) + { logger.error("can't send the PUBLISH request", e); throw new OperationFailedException( "can't send the PUBLISH request", @@ -639,13 +644,17 @@ public class OperationSetPresenceSipImpl } // no distant presence agent, send notify to every one - } else { - synchronized (this.ourWatchers) { // avoid any modification during - // the parsing of ourWatchers + } + else + { + synchronized (this.ourWatchers) + { // avoid any modification during + // the parsing of ourWatchers Iterator iter = this.ourWatchers.iterator(); ContactSipImpl me = (ContactSipImpl) getLocalContact(); - while (iter.hasNext()) { + while (iter.hasNext()) + { ContactSipImpl contact = (ContactSipImpl) iter.next(); // let the subscription end before sending him a new status @@ -654,9 +663,11 @@ public class OperationSetPresenceSipImpl } ClientTransaction transac = null; - try { + try + { if (status.equals(sipStatusEnum.getStatus( - SipStatusEnum.OFFLINE))) { + SipStatusEnum.OFFLINE))) + { transac = createNotify(contact, getPidfPresenceStatus(me), SubscriptionStateHeader.TERMINATED, @@ -667,7 +678,9 @@ public class OperationSetPresenceSipImpl this.waitedCallIds.add(transac.getDialog() .getCallId().getCallId()); } - } else { + } + else + { transac = createNotify(contact, getPidfPresenceStatus(me), SubscriptionStateHeader.ACTIVE, null); @@ -677,15 +690,19 @@ public class OperationSetPresenceSipImpl return; } - try { + try + { contact.getServerDialog().sendRequest(transac); - } catch (Exception e) { + } + catch (Exception e) + { logger.error("Can't send the request", e); return; } } - if (status.equals(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE))) { + if (status.equals(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE))) + { this.ourWatchers.removeAllElements(); } } @@ -693,9 +710,14 @@ public class OperationSetPresenceSipImpl // must be done in last to avoid some problem when terminating a // subscription of a contact who is also one of our watchers - if (status.equals(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE))) { + if (status.equals(sipStatusEnum.getStatus(SipStatusEnum.OFFLINE))) + { unsubscribeToAllContact(); } + + // inform the listeners of these changes + this.fireProviderStatusChangeEvent(oldStatus); + this.fireProviderMsgStatusChangeEvent(oldMessage); } /** @@ -4029,7 +4051,7 @@ public class OperationSetPresenceSipImpl logger.debug("no valid status in this tuple"); } else { Element status = (Element) statusNode; - + // <basic> NodeList basicList = getPidfChilds(status, BASIC_ELEMENT); @@ -4045,7 +4067,7 @@ public class OperationSetPresenceSipImpl } index--; } while (index >= 0); - + if (basicNode == null) { logger.debug("no valid <basic> in this status"); } else { @@ -4324,7 +4346,8 @@ public class OperationSetPresenceSipImpl /** * Unsubscribe to every contact. */ - public void unsubscribeToAllContact() { + public void unsubscribeToAllContact() + { logger.debug("trying to unsubscribe to every contact"); // send event notifications saying that all our buddies are @@ -4333,13 +4356,15 @@ public class OperationSetPresenceSipImpl // would be enough. Iterator groupsIter = getServerStoredContactListRoot() .subgroups(); - while (groupsIter.hasNext()) { + while (groupsIter.hasNext()) + { ContactGroupSipImpl group = (ContactGroupSipImpl) groupsIter.next(); Iterator contactsIter = group.contacts(); - while (contactsIter.hasNext()) { + while (contactsIter.hasNext()) + { ContactSipImpl contact = (ContactSipImpl) contactsIter.next(); 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 63e4df2..1c3a4be 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java @@ -143,7 +143,99 @@ public class ProtocolProviderFactorySipImpl return accountID; } + /** + * Modifies the account corresponding to the specified accountID. This + * method is meant to be used to change properties of already existing + * accounts. Note that if the given accountID doesn't correspond to any + * registered account this method would do nothing. + * + * @param protocolProvider the protocol provider service corresponding to + * the modified account. + * @param accountProperties a set of protocol (or implementation) specific + * properties defining the new account. + * + * @throws java.lang.NullPointerException if any of the arguments is null. + */ + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + { + BundleContext context + = SipActivator.getBundleContext(); + + if (context == null) + throw new NullPointerException( + "The specified BundleContext was null"); + + if (protocolProvider == null) + throw new NullPointerException( + "The specified Protocol Provider was null"); + + SipAccountID accountID = (SipAccountID) 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(); + + accountProperties.put(USER_ID, accountID.getUserID()); + + if (accountProperties == null) + throw new NullPointerException( + "The specified property map was null"); + + String serverAddress = (String) accountProperties.get(SERVER_ADDRESS); + + if(serverAddress == null) + throw new NullPointerException("null is not a valid ServerAddress"); + if (!accountProperties.containsKey(PROTOCOL)) + accountProperties.put(PROTOCOL, ProtocolNames.SIP); + + 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(SipActivator.getBundleContext(), accountID); + + Hashtable properties = new Hashtable(); + properties.put(PROTOCOL, ProtocolNames.SIP); + properties.put(USER_ID, accountID.getUserID()); + + try + { + ((ProtocolProviderServiceSipImpl)protocolProvider) + .initialize(accountID.getUserID(), accountID); + + // We store again the account in order to store all properties added + // during the protocol provider initialization. + this.storeAccount( + SipActivator.getBundleContext(), accountID); + + registration + = context.registerService( + ProtocolProviderService.class.getName(), + protocolProvider, + properties); + + registeredAccounts.put(accountID, registration); + } + catch (OperationFailedException ex) + { + logger.error("Failed to initialize account", ex); + throw new IllegalArgumentException("Failed to initialize account" + + ex.getMessage()); + } + } + /** * Initializes and creates an account corresponding to the specified * accountProperties and registers the resulting ProtocolProvider in the diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSHImpl.java index a3536d3..529176d 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSHImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderFactorySSHImpl.java @@ -302,5 +302,14 @@ public class ProtocolProviderFactorySSHImpl registeredAccounts.remove(idEnum.nextElement()); } } + + @Override + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + throws NullPointerException + { + // TODO Auto-generated method stub + + } } 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 b037a6f..4c6ae4c 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderFactoryYahooImpl.java @@ -261,4 +261,13 @@ public class ProtocolProviderFactoryYahooImpl return super.loadPassword(YahooActivator.getBundleContext() , accountID ); } + + @Override + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + throws NullPointerException + { + // TODO Auto-generated method stub + + } } diff --git a/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderFactoryZeroconfImpl.java b/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderFactoryZeroconfImpl.java index e900129..008c531 100644 --- a/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderFactoryZeroconfImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderFactoryZeroconfImpl.java @@ -292,4 +292,13 @@ public class ProtocolProviderFactoryZeroconfImpl registeredAccounts.clear(); } + @Override + public void modifyAccount( ProtocolProviderService protocolProvider, + Map accountProperties) + throws NullPointerException + { + // TODO Auto-generated method stub + + } + } |