/** Settings related to content management. */
public class ContentSettings extends LimeProps {
  private ContentSettings() {}

  /** The list of default content authorities. */
  public static final StringArraySetting AUTHORITIES =
      FACTORY.createRemoteStringArraySetting(
          "CONTENT_AUTHORITIES", new String[0], "content.authorities");

  /** Whether or not we want to use content management. */
  public static final BooleanSetting CONTENT_MANAGEMENT_ACTIVE =
      FACTORY.createRemoteBooleanSetting(
          "CONTENT_MANAGEMENT_ACTIVE", true, "content.managementActive");

  /**
   * Whether or not the user is enabling management. Both this & the above must be on for management
   * to be active.
   */
  public static final BooleanSetting USER_WANTS_MANAGEMENTS =
      FACTORY.createBooleanSetting("USER_WANTS_MANAGEMENTS", true);

  /**
   * Returns true if content management is active.
   *
   * @return
   */
  public static boolean isManagementActive() {
    return CONTENT_MANAGEMENT_ACTIVE.getValue() && USER_WANTS_MANAGEMENTS.getValue();
  }
}
/** Settings to deal with UI. */
public final class UISettings extends LimeProps {

  private UISettings() {}

  /** Setting for autocompletion */
  public static final BooleanSetting AUTOCOMPLETE_ENABLED =
      FACTORY.createBooleanSetting("AUTOCOMPLETE_ENABLED", true);

  /** Setting for search-result filters. */
  public static final BooleanSetting SEARCH_RESULT_FILTERS =
      FACTORY.createBooleanSetting("SEARCH_RESULT_FILTERS", true);

  /** Setting for the magnetmix button. */
  public static final BooleanSetting MAGNETMIX_BUTTON =
      FACTORY.createBooleanSetting(
          "SEARCH_MAGNETMIX_BUTTON", !CommonUtils.isPro() && !isResolutionLow());

  /** Setting for using small icons. */
  public static final BooleanSetting SMALL_ICONS =
      FACTORY.createBooleanSetting("UI_SMALL_ICONS", isResolutionLow());

  /** Setting for displaying text under icons. */
  public static final BooleanSetting TEXT_WITH_ICONS =
      FACTORY.createBooleanSetting("UI_TEXT_WITH_ICONS", true);

  /** Setting for not grouping search results in GUI */
  public static final BooleanSetting UI_GROUP_RESULTS =
      FACTORY.createBooleanSetting("UI_GROUP_RESULTS", true);

  /** Setting to allow ignoring of alt-locs in replies. */
  public static final BooleanSetting UI_ADD_REPLY_ALT_LOCS =
      FACTORY.createBooleanSetting("UI_ADD_REPLY_ALT_LOCS", true);

  /** For people with bad eyes. */
  private static boolean isResolutionLow() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    return screenSize.width <= 800 || screenSize.height <= 600;
  }

  /** Setting to persist monitor check box state. */
  public static final BooleanSetting UI_MONITOR_SHOW_INCOMING_SEARCHES =
      FACTORY.createBooleanSetting("UI_MONITOR_SHOW_INCOMING_SEARCHES", false);

  /** Setting for the divider location between library tree and table. */
  public static final IntSetting UI_LIBRARY_TREE_DIVIDER_LOCATION =
      FACTORY.createIntSetting("UI_LIBRARY_TREE_DIVIDER_LOCATION", -1);

  /** Setting for the divider location between library and playlist. */
  public static final IntSetting UI_LIBRARY_PLAY_LIST_TAB_DIVIDER_LOCATION =
      FACTORY.createIntSetting("UI_LIBRARY_PLAY_LIST_TAB_DIVIDER_LOCATION", 300);

  /** Setting for the divider location between incoming query monitors and upload panel. */
  public static final IntSetting UI_MONITOR_UPLOAD_TAB_DIVIDER_LOCATION =
      FACTORY.createIntSetting("UI_MONITOR_UPLOAD_TAB_DIVIDER_LOCATION", 300);
}
/** Settings for iTunes */
public class iTunesSettings extends LimeProps {

  private iTunesSettings() {}

  /** Whether or not player should be enabled. */
  public static BooleanSetting ITUNES_SUPPORT_ENABLED =
      FACTORY.createBooleanSetting("ITUNES_SUPPORT_ENABLED", true);

  /** The name of the Playlist where songs shall be imported */
  public static StringSetting ITUNES_PLAYLIST =
      FACTORY.createStringSetting("ITUNES_PLAYLIST", "LimeWire");

  /** Supported file types */
  public static StringArraySetting ITUNES_SUPPORTED_FILE_TYPES =
      FACTORY.createStringArraySetting(
          "ITUNES_SUPPORTED_FILE_TYPES",
          new String[] {
            ".mp3", ".aif", ".aiff", ".wav", ".mp2", ".mp4", ".aac", ".mid", ".m4a", ".m4p", ".ogg"
          });
}
/** Settings for Ultrapeers. */
public final class UltrapeerSettings extends LimeProps {

  private UltrapeerSettings() {}

  /** Setting for whether or not we've ever been Ultrapeer capable. */
  public static final BooleanSetting EVER_ULTRAPEER_CAPABLE =
      FACTORY.createExpirableBooleanSetting("EVER_SUPERNODE_CAPABLE", false);

  /** Setting for whether or not to force Ultrapeer mode. */
  public static final BooleanSetting FORCE_ULTRAPEER_MODE =
      FACTORY.createBooleanSetting("FORCE_SUPERNODE_MODE", false);

  /** Setting for whether or not to disable Ultrapeer mode. */
  public static final BooleanSetting DISABLE_ULTRAPEER_MODE =
      FACTORY.createBooleanSetting("DISABLE_SUPERNODE_MODE", false);

  /** Setting for the maximum leaf connections. */
  public static final IntSetting MAX_LEAVES =
      FACTORY.createRemoteIntSetting("MAX_LEAVES", 30, "UltrapeerSettings.maxLeavesV2", 16, 96);

  /**
   * The minimum number of upstream kbytes per second that a node must be able to transfer in order
   * to qualify as a ultrapeer.
   */
  public static final IntSetting MIN_UPSTREAM_REQUIRED =
      FACTORY.createRemoteIntSetting(
          "MIN_UPSTREAM_REQUIRED", 10, "UltrapeerSettings.MinUpstream", 8, 32);

  /**
   * The minimum number of downlstream kbytes per second that a node must be able to transfer in
   * order to qualify as a ultrapeer.
   */
  public static final IntSetting MIN_DOWNSTREAM_REQUIRED =
      FACTORY.createRemoteIntSetting(
          "MIN_DOWNSTREAM_REQUIRED", 20, "UltrapeerSettings.MinDownstream", 16, 64);

  /**
   * The minimum average uptime in seconds that a node must have to qualify for ultrapeer status.
   */
  public static final IntSetting MIN_AVG_UPTIME =
      FACTORY.createRemoteIntSetting(
          "MIN_AVG_UPTIME", 3600, "UltrapeerSettings.MinAvgUptime", 3600, 48 * 3600);

  /** Setting for whether or not the MIN_CONNECT_TIME is required. */
  public static final BooleanSetting NEED_MIN_CONNECT_TIME =
      FACTORY.createBooleanSetting("NEED_MIN_CONNECT_TIME", true);

  /**
   * The minimum time in seconds that a node must have tried to connect before it can qualify for
   * Ultrapeer status.
   */
  public static final IntSetting MIN_CONNECT_TIME =
      FACTORY.createRemoteIntSetting(
          "MIN_CONNECT_TIME", 10, "UltrapeerSettings.MinConnectTime", 0, 30);

  /**
   * The minimum current uptime in seconds that a node must have to qualify for Ultrapeer status.
   */
  public static final IntSetting MIN_INITIAL_UPTIME =
      FACTORY.createRemoteIntSetting(
          "MIN_INITIAL_UPTIME",
          120 * 60,
          "UltrapeerSettings.MinInitialUptime",
          120 * 60,
          48 * 3600);

  /** The amount of time to wait between attempts to become an Ultrapeer, in milliseconds. */
  public static final IntSetting UP_RETRY_TIME =
      FACTORY.createRemoteIntSetting(
          "UP_RETRY_TIME",
          180 * 60 * 1000,
          "UltrapeerSettings.UpRetryTime",
          180 * 60 * 1000,
          24 * 3600 * 1000);
}
/** Settings for filters */
public class FilterSettings extends LimeProps {

  private FilterSettings() {}

  public static final BooleanSetting USE_NETWORK_FILTER =
      FACTORY.createBooleanSetting("USE_NETWORK_FILTER", true);

  /**
   * Sets whether or not search results including "adult content" are banned in What's New queries.
   */
  public static final BooleanSetting FILTER_WHATS_NEW_ADULT =
      FACTORY.createBooleanSetting("FILTER_WHATS_NEW_ADULT", true);

  /** Sets whether or not search results including "adult content" are banned. */
  public static final BooleanSetting FILTER_ADULT =
      FACTORY.createBooleanSetting("FILTER_ADULT", false);

  /** Sets whether or not known spam and malware URNs are banned. */
  public static final BooleanSetting FILTER_URNS =
      FACTORY.createBooleanSetting("FILTER_URNS", true);

  /** An array of URNs that should not be displayed (local setting). */
  public static final StringArraySetting FILTERED_URNS_LOCAL =
      FACTORY.createStringArraySetting("FILTERED_URNS_LOCAL", new String[0]);

  /** An array of URNs that should not be displayed (remote setting). */
  public static final StringArraySetting FILTERED_URNS_REMOTE =
      FACTORY.createRemoteStringArraySetting(
          "FILTERED_URNS_REMOTE", new String[0], "FilterSettings.filteredUrnsRemote");

  /** Sets whether or not results with filtered URNs are considered spam. */
  public static final BooleanSetting FILTERED_URNS_ARE_SPAM =
      FACTORY.createRemoteBooleanSetting(
          "FILTERED_URNS_ARE_SPAM", true, "FilterSettings.filteredUrnsAreSpam");
  /** Sets whether or not duplicate search results are banned. */
  public static final BooleanSetting FILTER_DUPLICATES =
      FACTORY.createBooleanSetting("FILTER_DUPLICATES", true);

  /** Sets whether or not greedy queries a filtered. */
  public static final BooleanSetting FILTER_GREEDY_QUERIES =
      FACTORY.createBooleanSetting("FILTER_GREEDY_QUERIES", true);

  /** Sets whether or not anomalous queries are filtered. */
  public static final BooleanSetting FILTER_ANOMALOUS_QUERIES =
      FACTORY.createRemoteBooleanSetting(
          "FILTER_ANOMALOUS_QUERIES", true, "FilterSettings.filterAnomalousQueries");

  /** An array of ip addresses that the user has banned. */
  @InspectablePrimitive("blacklisted hosts")
  public static final StringArraySetting BLACK_LISTED_IP_ADDRESSES =
      FACTORY.createStringArraySetting("BLACK_LISTED_IP_ADDRESSES", new String[0]);

  /** An array of ip addresses that the user has allowed. (Array of String!) */
  public static final StringArraySetting WHITE_LISTED_IP_ADDRESSES =
      FACTORY.createStringArraySetting("WHITE_LISTED_IP_ADDRESSES", new String[0]);

  /** An array of words that the user has banned from appearing in search results. */
  public static final StringArraySetting BANNED_WORDS =
      FACTORY.createStringArraySetting("BANNED_WORDS", new String[0]);

  /** An array of extensions that the user has banned from appearing in search results. */
  public static final StringArraySetting BANNED_EXTENSIONS =
      FACTORY.createStringArraySetting(
          "BANNED_EXTENSIONS",
          new String[] {".vbs", ".asf", ".asx", ".wm", ".wma", ".wmv", ".htm", ".html"});

  /** Whether to filter queries containing hashes. TODO: naming convention for SIMPP keys? */
  public static final BooleanSetting FILTER_HASH_QUERIES =
      FACTORY.createRemoteBooleanSetting("FILTER_HASH_QUERIES", false, "filter_hash");

  public static final IntSetting MIN_MATCHING_WORDS =
      FACTORY.createRemoteIntSetting(
          "MIN_MATCHING_WORDS", 0, "FilterSettings.minMatchingWords", 0, 30);

  /** An array of ip addresses that LimeWire will respond to. */
  public static final StringArraySetting CRAWLER_IP_ADDRESSES =
      FACTORY.createRemoteStringArraySetting(
          "CRAWLER_IPS", new String[] {"*.*.*.*"}, "FilterSettings.crawlerIps");

  /** An array of ip addresses that LimeWire will respond to with inspection responses. */
  public static final StringArraySetting INSPECTOR_IP_ADDRESSES =
      FACTORY.createRemoteStringArraySetting(
          "INSPECTOR_IPS", new String[0], "FilterSettings.inspectorIps");

  /** An array of hostile ip addresses. */
  public static final StringArraySetting HOSTILE_IPS =
      FACTORY.createRemoteStringArraySetting(
          "HOSTILE_IPS", new String[0], "FilterSettings.hostileIps");

  /** How many alts to allow per response. */
  public static final IntSetting MAX_ALTS_PER_RESPONSE =
      FACTORY.createRemoteIntSetting(
          "MAX_ALTS_PER_RESPONSE", 50, "FilterSettings.maxAltsPerResponse", 10, 100);

  /** How many responses to allow per QueryReply message. */
  public static final IntSetting MAX_RESPONSES_PER_REPLY =
      FACTORY.createRemoteIntSetting(
          "MAX_RESPONSES_PER_REPLY", 10, "FilterSettings.maxResponsesPerReply", 10, 256);

  /**
   * Base32-encoded, deflated, bencoded description of dangerous file types. See
   * DangerousFileTypeEncoder.
   */
  public static final StringSetting DANGEROUS_FILE_TYPES =
      FACTORY.createRemoteStringSetting(
          "DANGEROUS_FILE_TYPES",
          "PCOEWMNUJLG4SMNWJIWE4M5SFLHTKBXCIQIFDFU2NJUJLG3DNBTGLIFWVG2C73N44CZJWDFLDCJM5ZNEUYBABWCDCMGA",
          "FilterSettings.DangerousFileTypes");
}