/**
   * Checks to see if all file transfer related services are enabled on the connection.
   *
   * @param connection The connection to check
   * @return True if all related services are enabled, false if they are not.
   */
  public static boolean isServiceEnabled(final Connection connection) {
    final ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(connection);

    final List<String> namespaces = new ArrayList<String>();
    namespaces.addAll(Arrays.asList(NAMESPACE));
    namespaces.add(InBandBytestreamManager.NAMESPACE);
    if (!IBB_ONLY) {
      namespaces.add(Socks5BytestreamManager.NAMESPACE);
    }

    for (final String namespace : namespaces) {
      if (!manager.includesFeature(namespace)) {
        return false;
      }
    }
    return true;
  }
  /**
   * Enable the Jabber services related to file transfer on the particular connection.
   *
   * @param connection The connection on which to enable or disable the services.
   * @param isEnabled True to enable, false to disable.
   */
  public static void setServiceEnabled(final Connection connection, final boolean isEnabled) {
    final ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(connection);

    final List<String> namespaces = new ArrayList<String>();
    namespaces.addAll(Arrays.asList(NAMESPACE));
    namespaces.add(InBandBytestreamManager.NAMESPACE);
    if (!IBB_ONLY) {
      namespaces.add(Socks5BytestreamManager.NAMESPACE);
    }

    for (final String namespace : namespaces) {
      if (isEnabled) {
        if (!manager.includesFeature(namespace)) {
          manager.addFeature(namespace);
        }
      } else {
        manager.removeFeature(namespace);
      }
    }
  }