diff options
Diffstat (limited to 'src/net/java/sip/communicator')
4 files changed, 243 insertions, 49 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java index a1767dd..e74ace1 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java @@ -26,7 +26,7 @@ import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.util.StringUtils; +import org.jivesoftware.smack.util.*; /** * Represents an <tt>OperationSet</tt> to query the <tt>OperationSet</tt>s @@ -52,6 +52,19 @@ public class OperationSetContactCapabilitiesJabberImpl = Logger.getLogger(OperationSetContactCapabilitiesJabberImpl.class); /** + * The name of the property used to control whether to use + * all resources to show capabilities + */ + public static final String PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES = + "net.java.sip.communicator.XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES"; + + /** + * The default value for the capabilities setting + */ + public static final boolean USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT = + true; + + /** * The list of <tt>OperationSet</tt> capabilities presumed to be supported * by a <tt>Contact</tt> when it is offline. */ @@ -295,13 +308,14 @@ public class OperationSetContactCapabilitiesJabberImpl { Map<String, OperationSet> supportedOperationSets = new HashMap<String, OperationSet>(); - if (fullJids!=null){ + if (fullJids!=null) + { for (String fullJid : fullJids) { Map<String, OperationSet> newSupportedOperationSets= getSupportedOperationSets(fullJid, true); if (newSupportedOperationSets.size()> - supportedOperationSets.size()) + supportedOperationSets.size()) { supportedOperationSets = newSupportedOperationSets; } @@ -466,40 +480,61 @@ public class OperationSetContactCapabilitiesJabberImpl * @param node the entity caps node#ver * @param online indicates if the given user is online */ - public void userCapsNodeChanged(String user, ArrayList<String> fullJids, String node, boolean online) + public void userCapsNodeChanged(String user, ArrayList<String> fullJids, + String node, boolean online) { OperationSetPresence opsetPresence - = parentProvider.getOperationSet(OperationSetPresence.class); - - if (opsetPresence != null) - { - String bareJid = StringUtils.parseBareAddress(user); - Contact contact = opsetPresence.findContactByID(bareJid); - - // If the contact isn't null and is online we try to discover the - // new set of operation sets and to notify interested parties. - // Otherwise we ignore the event. - if (contact != null) + = parentProvider.getOperationSet(OperationSetPresence.class); + if (opsetPresence != null) { + if(JabberActivator.getConfigurationService() + .getBoolean( + PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES, + USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT)) { - if(online) + String bareJid = StringUtils.parseBareAddress(user); + Contact contact = opsetPresence.findContactByID(bareJid); + if (contact != null) { - // when going online we have received a presence - // and make sure we discover this particular jid - // for getSupportedOperationSets fireContactCapabilitiesEvent( contact, - ContactCapabilitiesEvent.SUPPORTED_OPERATION_SETS_CHANGED, + ContactCapabilitiesEvent. + SUPPORTED_OPERATION_SETS_CHANGED, getLargestSupportedOperationSet(fullJids)); } - else + } + else + { + String jid = StringUtils.parseBareAddress(user); + Contact contact = opsetPresence.findContactByID(jid); + + // If the contact isn't null and is online we try to discover + // the new set of operation sets and to notify interested + // parties. Otherwise we ignore the event. + if (contact != null) { - // when offline, we use the contact, and selecting - // the most connected jid - // for getSupportedOperationSets - fireContactCapabilitiesEvent( - contact, - ContactCapabilitiesEvent.SUPPORTED_OPERATION_SETS_CHANGED, - getLargestSupportedOperationSet(fullJids)); + if(online) + { + // when going online we have received a presence + // and make sure we discover this particular jid + // for getSupportedOperationSets + fireContactCapabilitiesEvent( + contact, + ContactCapabilitiesEvent. + SUPPORTED_OPERATION_SETS_CHANGED, + getSupportedOperationSets(user, + online)); + } + else + { + // when offline, we use the contact, and selecting + // the most connected jid + // for getSupportedOperationSets + fireContactCapabilitiesEvent( + contact, + ContactCapabilitiesEvent. + SUPPORTED_OPERATION_SETS_CHANGED, + getSupportedOperationSets(contact)); + } } } } @@ -516,7 +551,8 @@ public class OperationSetContactCapabilitiesJabberImpl { // If the user goes offline we ensure to remove the caps node. if (capsManager != null - && evt.getNewStatus().getStatus() < PresenceStatus.ONLINE_THRESHOLD) + && evt.getNewStatus().getStatus() < PresenceStatus.ONLINE_THRESHOLD + && !evt.isResourceChanged()) { capsManager.removeContactCapsNode(evt.getSourceContact()); } @@ -525,31 +561,59 @@ public class OperationSetContactCapabilitiesJabberImpl /** * Fires event that contact capabilities has changed. * @param user the user to search for its contact. + * @param fullJids a list of all resources of the user (full JIDs) */ - public void fireContactCapabilitiesChanged(String user) + public void fireContactCapabilitiesChanged(String user, + ArrayList<String> fullJids) { - OperationSetPresence opsetPresence + if(!JabberActivator.getConfigurationService() + .getBoolean( + PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES, + USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT) + ||fullJids.isEmpty()) + { + OperationSetPresence opsetPresence = parentProvider.getOperationSet(OperationSetPresence.class); - if (opsetPresence != null) + if (opsetPresence != null) + { + String userID = StringUtils.parseBareAddress(user); + Contact contact = opsetPresence.findContactByID(userID); + + // this called by received discovery info for particular jid + // so we use its online and opsets for this particular jid + boolean online = false; + Presence presence = parentProvider.getConnection().getRoster() + .getPresence(user); + if(presence != null) + online = presence.isAvailable(); + + if(contact != null) + { + fireContactCapabilitiesEvent( + contact, + ContactCapabilitiesEvent. + SUPPORTED_OPERATION_SETS_CHANGED, + getSupportedOperationSets(user, online)); + } + } + } + else { - String userID = StringUtils.parseBareAddress(user); - Contact contact = opsetPresence.findContactByID(userID); - - // this called by received discovery info for particular jid - // so we use its online and opsets for this particular jid - boolean online = false; - Presence presence = parentProvider.getConnection().getRoster() - .getPresence(user); - if(presence != null) - online = presence.isAvailable(); - - if(contact != null) + OperationSetPresence opsetPresence + = parentProvider.getOperationSet(OperationSetPresence.class); + if (opsetPresence != null) { - fireContactCapabilitiesEvent( - contact, - ContactCapabilitiesEvent.SUPPORTED_OPERATION_SETS_CHANGED, - getSupportedOperationSets(user, online)); + String bareJid = StringUtils.parseBareAddress(user); + Contact contact = opsetPresence.findContactByID(bareJid); + if(contact != null) + { + fireContactCapabilitiesEvent( + contact, + ContactCapabilitiesEvent. + SUPPORTED_OPERATION_SETS_CHANGED, + getLargestSupportedOperationSet(fullJids)); + } } } } diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ScServiceDiscoveryManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/ScServiceDiscoveryManager.java index 9fdbea5..4b3edab 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ScServiceDiscoveryManager.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ScServiceDiscoveryManager.java @@ -27,6 +27,7 @@ import net.java.sip.communicator.util.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.filter.*; import org.jivesoftware.smack.packet.*; +import org.jivesoftware.smack.util.*; import org.jivesoftware.smackx.*; import org.jivesoftware.smackx.packet.*; @@ -791,7 +792,11 @@ public class ScServiceDiscoveryManager // fire event if(fireEvent && capabilitiesOpSet != null) { - capabilitiesOpSet.fireContactCapabilitiesChanged(entityID); + capabilitiesOpSet.fireContactCapabilitiesChanged( + entityID, + capsManager.getFullJidsByBareJid( + StringUtils.parseBareAddress(entityID)) + ); } } catch(XMPPException ex) diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java index 2f345d7..7222d97 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java @@ -108,6 +108,14 @@ public class GeneralConfigPluginActivator "net.java.sip.communicator.plugin.generalconfig.sipconfig.DISABLED"; /** + * Indicates if the XMPP configuration form should be disabled, i.e. + * not visible to the user. + */ + private static final String XMPP_CONFIG_DISABLED_PROP + = + "net.java.sip.communicator.plugin.generalconfig.xmppconfig.DISABLED"; + + /** * Starts this bundle. */ @Override @@ -155,6 +163,22 @@ public class GeneralConfigPluginActivator 52, true), properties); } + if (!getConfigurationService() + .getBoolean(XMPP_CONFIG_DISABLED_PROP, false)) + { + // Registers the XMPP config panel as advanced configuration form. + properties.put( ConfigurationForm.FORM_TYPE, + ConfigurationForm.ADVANCED_TYPE); + bundleContext.registerService( + ConfigurationForm.class.getName(), + new LazyConfigurationForm( + XMPPConfigForm.class.getName(), + getClass().getClassLoader(), + null, + "plugin.generalconfig.XMPP_CONFIG", + 52, true), + properties); + } properties.put( ConfigurationForm.FORM_TYPE, ConfigurationForm.ADVANCED_TYPE); bundleContext.registerService( diff --git a/src/net/java/sip/communicator/plugin/generalconfig/XMPPConfigForm.java b/src/net/java/sip/communicator/plugin/generalconfig/XMPPConfigForm.java new file mode 100644 index 0000000..0113232 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/generalconfig/XMPPConfigForm.java @@ -0,0 +1,101 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Copyright @ 2015 Atlassian Pty Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.java.sip.communicator.plugin.generalconfig; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + +import org.jitsi.service.configuration.*; + +import net.java.sip.communicator.plugin.desktoputil.*; + +/** + * Implementation of the configuration form. + * + * @author Timur Masar + */ +public class XMPPConfigForm +extends TransparentPanel +{ + /** + * Serial version UID. + */ + private static final long serialVersionUID = 0L; + + /** + * The name of the property used to control whether to use + * all resources to show capabilities + */ + public static final String PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES = + "net.java.sip.communicator.XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES"; + + /** + * The default value for the capabilities setting + */ + public static final boolean USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT = + true; + + /** + * The <tt>ConfigurationService</tt> to be used to access configuration + */ + private final ConfigurationService configurationService + = GeneralConfigPluginActivator.getConfigurationService(); + + /** + * Creates the form. + */ + public XMPPConfigForm() + { + super(new BorderLayout()); + Box box = Box.createVerticalBox(); + add(box, BorderLayout.NORTH); + + TransparentPanel contentPanel = new TransparentPanel(); + contentPanel.setLayout(new BorderLayout(10, 10)); + + box.add(contentPanel); + + TransparentPanel labelPanel + = new TransparentPanel(new GridLayout(0, 1, 2, 2)); + TransparentPanel valuePanel + = new TransparentPanel(new GridLayout(0, 1, 2, 2)); + + contentPanel.add(labelPanel, BorderLayout.CENTER); + contentPanel.add(valuePanel, BorderLayout.WEST); + + final JCheckBox useAllResourcesForCapabilitiesCheckbox = + new SIPCommCheckBox(Resources.getString( + "plugin.generalconfig.XMPP_USE_ALL_RESOURCES")); + + useAllResourcesForCapabilitiesCheckbox.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + configurationService.setProperty( + PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES, + useAllResourcesForCapabilitiesCheckbox.isSelected()); + } + }); + useAllResourcesForCapabilitiesCheckbox.setSelected( + configurationService.getBoolean( + PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES, + USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT)); + valuePanel.add(useAllResourcesForCapabilitiesCheckbox); + } +} |