function initPrefs()

in suite/chatzilla/content/prefs.js [9:265]


function initPrefs() {
  function makeLogNameClient() {
    return makeLogName(client, "client");
  }

  client.prefManager = new PrefManager("extensions.irc.", client.defaultBundle);
  client.prefManagers = [client.prefManager];

  client.prefs = client.prefManager.prefs;

  let profilePath = Services.dirsvc.get("ProfD", Ci.nsIFile);
  profilePath.append("chatzilla");

  client.prefManager.addPref(
    "profilePath",
    profilePath.path,
    null,
    null,
    "hidden"
  );

  profilePath = new nsLocalFile(client.prefs.profilePath);

  if (!profilePath.exists()) {
    mkdir(profilePath);
  }

  client.prefManager.profilePath = profilePath;

  var scriptPath = profilePath.clone();
  scriptPath.append("scripts");
  if (!scriptPath.exists()) {
    mkdir(scriptPath);
  }

  var logPath = profilePath.clone();
  logPath.append("logs");
  if (!logPath.exists()) {
    mkdir(logPath);
  }
  client.prefManager.logPath = logPath;

  var downloadsPath = profilePath.clone();
  downloadsPath.append("downloads");
  if (!downloadsPath.exists()) {
    mkdir(downloadsPath);
  }

  var logDefault = client.prefManager.logPath.clone();
  logDefault.append("client.log");

  // Set up default nickname, if possible.
  var defaultNick = DEFAULT_NICK;
  let env = Cc["@mozilla.org/process/environment;1"].getService(
    Ci.nsIEnvironment
  );
  /* Get the enviroment variables used by various OSes:
   *   USER     - Linux, macOS and other *nix-types.
   *   USERNAME - Windows.
   *   LOGNAME  - *nix again.
   */
  const vars = ["USER", "USERNAME", "LOGNAME"];

  for (let varName of vars) {
    let nick = env.get(varName);
    if (nick) {
      defaultNick = nick.replace(/ /g, "_");
      break;
    }
  }

  // Set a property so network ident prefs get the same group later:
  client.prefManager.identGroup = ".connect";
  // Linux and OS X won't let non-root listen on port 113.
  if (client.platform == "Linux" || client.platform == "Mac") {
    client.prefManager.identGroup = "hidden";
  }

  var prefs = [
    ["activityFlashDelay", 200, "hidden"],
    ["alert.overlapDelay", 50, "hidden"],
    ["alert.floodDensity", 290, "hidden"],
    ["alert.floodDispersion", 200, "hidden"],
    ["alert.enabled", true, ".palert"],
    ["alert.globalEnabled", true, "global.palertconfig"],
    ["alert.clickable", true, "hidden"],
    ["alert.nonFocusedOnly", true, "global.palertconfig"],
    ["alert.channel.event", false, ".palert"],
    ["alert.channel.chat", false, ".palert"],
    ["alert.channel.stalk", true, ".palert"],
    ["alert.user.chat", true, ".palert"],
    ["aliases", [], "lists.aliases"],
    ["autoAwayCap", 300, "global"],
    ["autoAwayPeriod", 2, "appearance.misc"],
    ["autoMarker", false, "appearance.misc"],
    ["autoperform.channel", [], "lists.autoperform"],
    ["autoperform.client", [], "lists.autoperform"],
    ["autoperform.network", [], "lists.autoperform"],
    ["autoperform.user", ["whois"], "lists.autoperform"],
    ["autoRejoin", false, ".connect"],
    ["away", "", "hidden"],
    ["awayIdleMsg", "", ".ident"],
    ["awayIdleTime", 0, ".ident"],
    ["awayNick", "", ".ident"],
    ["bugKeyword", "bug", "appearance.misc"],
    [
      "bugURL",
      "https://bugzilla.mozilla.org/show_bug.cgi?id=%s",
      "appearance.misc",
    ],
    ["bugURL.comment", "#c%s", "appearance.misc"],
    ["channelHeader", true, "global.header"],
    ["channelLog", false, "global.log"],
    ["channelMaxLines", 500, "global.maxLines"],
    ["charset", "utf-8", ".connect"],
    ["clientMaxLines", 200, "global.maxLines"],
    ["collapseActions", true, "appearance.misc"],
    ["collapseMsgs", false, "appearance.misc"],
    ["conference.limit", 150, "appearance.misc"],
    ["connectTries", -1, ".connect"],
    ["copyMessages", true, "global"],
    ["dcc.autoAccept.delay", 10000, "hidden"],
    ["dcc.downloadsFolder", getURLSpecFromFile(downloadsPath.path), "dcc"],
    ["dcc.enabled", true, "dcc"],
    ["dcc.listenPorts", [], "dcc.ports"],
    ["dcc.useServerIP", true, "dcc"],
    ["dccUserHeader", true, "global.header"],
    ["dccUserLog", false, "global.log"],
    ["dccUserMaxLines", 500, "global.maxLines"],
    ["debugMode", "", "hidden"],
    ["defaultQuitMsg", "", ".connect"],
    ["deleteOnPart", true, "global"],
    ["desc", "New Now Know How", ".ident"],
    ["displayHeader", true, "appearance.misc"],
    ["font.family", "default", "appearance.misc"],
    ["font.size", 0, "appearance.misc"],
    ["guessCommands", true, "hidden"],
    ["hasPrefs", false, "hidden"],
    ["identd.enabled", false, client.prefManager.identGroup],
    ["initialScripts", ["scripts/"], "startup.initialScripts"],
    ["initialURLs", [], "startup.initialURLs"],
    ["inputSpellcheck", true, "global"],
    ["log", false, ".log"],
    [
      "logFile.channel",
      "$(network)/channels/$(channel).$y-$m-$d.log",
      "hidden",
    ],
    ["logFile.client", "client.$y-$m-$d.log", "hidden"],
    ["logFile.dccuser", "dcc/$(user)/$(user).$y-$m-$d.log", "hidden"],
    ["logFile.network", "$(network)/$(network).$y-$m-$d.log", "hidden"],
    ["logFile.user", "$(network)/users/$(user).$y-$m-$d.log", "hidden"],
    ["logFileName", makeLogNameClient, "hidden"],
    ["logFolder", getURLSpecFromFile(logPath.path), ".log"],
    ["login.promptToSave", true, "global.security"],
    [
      "motif.current",
      "chrome://chatzilla/skin/output-light.css",
      "appearance.motif",
    ],
    [
      "motif.dark",
      "chrome://chatzilla/skin/output-dark.css",
      "appearance.motif",
    ],
    [
      "motif.light",
      "chrome://chatzilla/skin/output-light.css",
      "appearance.motif",
    ],
    ["multiline", false, "hidden"],
    ["munger.bold", true, "munger"],
    ["munger.bugzilla-link", true, "munger"],
    ["munger.channel-link", true, "munger"],
    ["munger.colorCodes", true, "munger"],
    ["munger.ctrl-char", true, "munger"],
    ["munger.face", true, "munger"],
    ["munger.italic", true, "munger"],
    ["munger.link", true, "munger"],
    ["munger.mailto", true, "munger"],
    ["munger.quote", true, "munger"],
    ["munger.rheet", true, "munger"],
    ["munger.talkback-link", true, "munger"],
    ["munger.teletype", true, "munger"],
    ["munger.underline", true, "munger"],
    ["munger.word-hyphenator", true, "munger"],
    ["networkHeader", true, "global.header"],
    ["networkLog", false, "global.log"],
    ["networkMaxLines", 200, "global.maxLines"],
    ["newTabLimit", 30, "global"],
    ["nickCompleteStr", ":", "global"],
    ["nickname", defaultNick, ".ident"],
    ["nicknameList", [], "lists.nicknameList"],
    ["notify.aggressive", true, "global"],
    ["outgoing.colorCodes", true, "global"],
    ["proxy.typeOverride", "", ".connect"],
    ["reconnect", true, ".connect"],
    ["sasl.plain.enabled", false, ".ident"],
    ["showModeSymbols", false, "appearance.userlist"],
    ["sortUsersByMode", true, "appearance.userlist"],
    // Chat  == "Activity" activity.
    // Event == "Superfluous" activity.
    // Stalk == "Attention" activity.
    // Start == When view it opened.
    ["sound.channel.chat", "", ".soundEvts"],
    ["sound.channel.event", "", ".soundEvts"],
    ["sound.channel.stalk", "beep", ".soundEvts"],
    ["sound.channel.start", "", ".soundEvts"],
    ["sound.enabled", true, "global.sounds"],
    ["sound.overlapDelay", 2000, "global.sounds"],
    ["sound.user.stalk", "beep", ".soundEvts"],
    ["sound.user.start", "beep beep", ".soundEvts"],
    ["stalkWholeWords", true, "lists.stalkWords"],
    ["stalkWords", [], "lists.stalkWords"],
    ["sts.enabled", true, ".connect"],
    ["tabLabel", "", "hidden"],
    ["tabGotoKeyModifiers", 0, "hidden"],
    ["timestamps", false, "appearance.timestamps"],
    ["timestamps.display", "[%H:%M]", "appearance.timestamps"],
    ["timestamps.log", "[%Y-%m-%d %H:%M:%S]", "hidden"],
    ["upgrade-insecure", false, ".connect"],
    ["urls.display", 10, "hidden"],
    ["urls.store.max", 100, "global"],
    ["userHeader", true, "global.header"],
    ["userlistLeft", true, "appearance.userlist"],
    ["userLog", false, "global.log"],
    ["userMaxLines", 200, "global.maxLines"],
    ["usermode", "+i", ".ident"],
    ["username", "chatzilla", ".ident"],
    ["warnOnClose", true, "global"],
  ];

  client.prefManager.addPrefs(prefs);
  client.prefManager.addObserver({ onPrefChanged });

  CIRCNetwork.prototype.stayingPower = client.prefs.reconnect;
  CIRCNetwork.prototype.MAX_CONNECT_ATTEMPTS = client.prefs.connectTries;
  CIRCNetwork.prototype.INITIAL_NICK = client.prefs.nickname;
  CIRCNetwork.prototype.INITIAL_NAME = client.prefs.username;
  CIRCNetwork.prototype.INITIAL_DESC = client.prefs.desc;
  CIRCNetwork.prototype.INITIAL_UMODE = client.prefs.usermode;
  CIRCNetwork.prototype.MAX_MESSAGES = client.prefs.networkMaxLines;
  CIRCNetwork.prototype.PROXY_TYPE_OVERRIDE =
    client.prefs["proxy.typeOverride"];
  CIRCNetwork.prototype.USE_SASL = client.prefs["sasl.plain.enabled"];
  CIRCNetwork.prototype.UPGRADE_INSECURE = client.prefs["upgrade-insecure"];
  CIRCNetwork.prototype.STS_MODULE.ENABLED = client.prefs["sts.enabled"];
  CIRCChannel.prototype.MAX_MESSAGES = client.prefs.channelMaxLines;
  CIRCUser.prototype.MAX_MESSAGES = client.prefs.userMaxLines;
  CIRCDCCChat.prototype.MAX_MESSAGES = client.prefs.dccUserMaxLines;
  CIRCDCCFileTransfer.prototype.MAX_MESSAGES = client.prefs.dccUserMaxLines;
  CIRCDCC.prototype.listenPorts = client.prefs["dcc.listenPorts"];
  client.MAX_MESSAGES = client.prefs.clientMaxLines;
  client.charset = client.prefs.charset;

  initAliases();
}