You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IdentdPlugin.java 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (c) 2006-2014 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.addons.identd;
  23. import com.dmdirc.config.prefs.PluginPreferencesCategory;
  24. import com.dmdirc.config.prefs.PreferencesCategory;
  25. import com.dmdirc.config.prefs.PreferencesDialogModel;
  26. import com.dmdirc.config.prefs.PreferencesSetting;
  27. import com.dmdirc.config.prefs.PreferencesType;
  28. import com.dmdirc.plugins.PluginInfo;
  29. import com.dmdirc.plugins.implementations.BasePlugin;
  30. import com.dmdirc.util.validators.PortValidator;
  31. import dagger.ObjectGraph;
  32. /**
  33. * The Identd plugin answers ident requests from IRC servers.
  34. */
  35. public class IdentdPlugin extends BasePlugin {
  36. /** This plugin's plugin info. */
  37. private final PluginInfo pluginInfo;
  38. /** This plugin's settings domain. */
  39. private final String domain;
  40. /** Identd Manager. */
  41. private IdentdManager identdManager;
  42. /**
  43. * Creates a new instance of this plugin.
  44. *
  45. * @param pluginInfo This plugin's plugin info
  46. */
  47. public IdentdPlugin(final PluginInfo pluginInfo) {
  48. this.pluginInfo = pluginInfo;
  49. domain = pluginInfo.getDomain();
  50. }
  51. @Override
  52. public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
  53. super.load(pluginInfo, graph);
  54. setObjectGraph(graph.plus(new IdentModule(pluginInfo)));
  55. identdManager = getObjectGraph().get(IdentdManager.class);
  56. }
  57. @Override
  58. public void onUnload() {
  59. super.onUnload();
  60. identdManager.onUnload();
  61. }
  62. @Override
  63. public void onLoad() {
  64. super.onLoad();
  65. identdManager.onLoad();
  66. }
  67. @Override
  68. public void showConfig(final PreferencesDialogModel manager) {
  69. final PreferencesCategory general = new PluginPreferencesCategory(
  70. pluginInfo, "Identd",
  71. "General Identd Plugin config ('Lower' options take priority "
  72. + "over those above them)");
  73. final PreferencesCategory advanced = new PluginPreferencesCategory(
  74. pluginInfo, "Advanced",
  75. "Advanced Identd Plugin config - Only edit these if you need "
  76. + "to/know what you are doing. Editing these could prevent "
  77. + "access to some servers. ('Lower' options take priority over "
  78. + "those above them)");
  79. general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  80. domain, "general.useUsername", "Use connection "
  81. + "username rather than system username", "If this is enabled,"
  82. + " the username for the connection will be used rather than '"
  83. + System.getProperty("user.name") + '\'',
  84. manager.getConfigManager(), manager.getIdentity()));
  85. general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  86. domain, "general.useNickname", "Use connection "
  87. + "nickname rather than system username", "If this is enabled, "
  88. + "the nickname for the connection will be used rather than '"
  89. + System.getProperty("user.name") + '\'',
  90. manager.getConfigManager(), manager.getIdentity()));
  91. general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  92. domain, "general.useCustomName", "Use custom name" + " all the time",
  93. "If this is enabled, the name specified below" + " will be used all the time",
  94. manager.getConfigManager(),
  95. manager.getIdentity()));
  96. general.addSetting(new PreferencesSetting(PreferencesType.TEXT,
  97. domain, "general.customName", "Custom Name to use",
  98. "The custom name to use when 'Use Custom Name' is enabled",
  99. manager.getConfigManager(), manager.getIdentity()));
  100. advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  101. domain, "advanced.alwaysOn", "Always have ident " + "port open",
  102. "By default the identd only runs when there are "
  103. + "active connection attempts. This overrides that.",
  104. manager.getConfigManager(), manager.getIdentity()));
  105. advanced.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
  106. new PortValidator(), domain, "advanced.port",
  107. "What port should the identd listen on", "Default port is 113,"
  108. + " this is probably useless if changed unless you port forward"
  109. + " ident to a different port", manager.getConfigManager(),
  110. manager.getIdentity()));
  111. advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  112. domain, "advanced.useCustomSystem", "Use custom OS",
  113. "By default the plugin uses 'UNIX' or 'WIN32' as the system "
  114. + "type, this can be overridden by enabling this.",
  115. manager.getConfigManager(), manager.getIdentity()));
  116. advanced.addSetting(new PreferencesSetting(PreferencesType.TEXT,
  117. domain, "advanced.customSystem", "Custom OS to use",
  118. "The custom system to use when 'Use Custom System' is enabled",
  119. manager.getConfigManager(), manager.getIdentity()));
  120. advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  121. domain, "advanced.isHiddenUser", "Respond to ident"
  122. + " requests with HIDDEN-USER error", "By default the plugin will"
  123. + " give a USERID response, this can force an 'ERROR :"
  124. + " HIDDEN-USER' response instead.", manager.getConfigManager(),
  125. manager.getIdentity()));
  126. advanced.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  127. domain, "advanced.isNoUser", "Respond to ident"
  128. + " requests with NO-USER error", "By default the plugin will"
  129. + " give a USERID response, this can force an 'ERROR : NO-USER'"
  130. + " response instead. (Overrides HIDDEN-USER)",
  131. manager.getConfigManager(), manager.getIdentity()));
  132. manager.getCategory("Plugins").addSubCategory(general);
  133. general.addSubCategory(advanced);
  134. }
  135. }