Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

DCCPlugin.java 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright (c) 2006-2015 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.dcc;
  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.BaseCommandPlugin;
  30. import dagger.ObjectGraph;
  31. /**
  32. * Adds support for DCC transfers and chats.
  33. */
  34. public class DCCPlugin extends BaseCommandPlugin {
  35. private final PluginInfo pluginInfo;
  36. private DCCManager dccManager;
  37. public DCCPlugin(final PluginInfo pluginInfo) {
  38. this.pluginInfo = pluginInfo;
  39. }
  40. @Override
  41. public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
  42. super.load(pluginInfo, graph);
  43. setObjectGraph(graph.plus(new DCCPluginModule(pluginInfo)));
  44. dccManager = getObjectGraph().get(DCCManager.class);
  45. registerCommand(DCCCommand.class, DCCCommand.INFO);
  46. }
  47. @Override
  48. public void onLoad() {
  49. super.onLoad();
  50. dccManager.onLoad();
  51. }
  52. @Override
  53. public void onUnload() {
  54. super.onUnload();
  55. dccManager.onUnload();
  56. }
  57. @Override
  58. public void showConfig(final PreferencesDialogModel manager) {
  59. final PreferencesCategory general = new PluginPreferencesCategory(
  60. pluginInfo, "DCC", "", "category-dcc");
  61. final PreferencesCategory firewall = new PluginPreferencesCategory(
  62. pluginInfo, "Firewall", "");
  63. final PreferencesCategory sending = new PluginPreferencesCategory(
  64. pluginInfo, "Sending", "");
  65. final PreferencesCategory receiving = new PluginPreferencesCategory(
  66. pluginInfo, "Receiving", "");
  67. manager.getCategory("Plugins").addSubCategory(general.setInlineAfter());
  68. general.addSubCategory(firewall.setInline());
  69. general.addSubCategory(sending.setInline());
  70. general.addSubCategory(receiving.setInline());
  71. firewall.addSetting(new PreferencesSetting(PreferencesType.TEXT,
  72. pluginInfo.getDomain(), "firewall.ip", "Forced IP",
  73. "What IP should be sent as our IP (Blank = work it out)",
  74. manager.getConfigManager(), manager.getIdentity()));
  75. firewall.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  76. pluginInfo.getDomain(), "firewall.ports.usePortRange", "Use Port Range",
  77. "Useful if you have a firewall that only forwards specific "
  78. + "ports", manager.getConfigManager(), manager.getIdentity()));
  79. firewall.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
  80. pluginInfo.getDomain(), "firewall.ports.startPort", "Start Port",
  81. "Port to try to listen on first", manager.getConfigManager(),
  82. manager.getIdentity()));
  83. firewall.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
  84. pluginInfo.getDomain(), "firewall.ports.endPort", "End Port",
  85. "Port to try to listen on last", manager.getConfigManager(),
  86. manager.getIdentity()));
  87. receiving.addSetting(new PreferencesSetting(PreferencesType.DIRECTORY,
  88. pluginInfo.getDomain(), "receive.savelocation", "Default save location",
  89. "Where the save as window defaults to?",
  90. manager.getConfigManager(), manager.getIdentity()));
  91. sending.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  92. pluginInfo.getDomain(), "send.reverse", "Reverse DCC",
  93. "With reverse DCC, the sender connects rather than "
  94. + "listens like normal dcc", manager.getConfigManager(),
  95. manager.getIdentity()));
  96. sending.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  97. pluginInfo.getDomain(), "send.forceturbo", "Use Turbo DCC",
  98. "Turbo DCC doesn't wait for ack packets. this is "
  99. + "faster but not always supported.",
  100. manager.getConfigManager(), manager.getIdentity()));
  101. receiving.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  102. pluginInfo.getDomain(), "receive.reverse.sendtoken",
  103. "Send token in reverse receive",
  104. "If you have problems with reverse dcc receive resume,"
  105. + " try toggling this.", manager.getConfigManager(),
  106. manager.getIdentity()));
  107. general.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
  108. pluginInfo.getDomain(), "send.blocksize", "Blocksize to use for DCC",
  109. "Change the block size for send/receive, this can "
  110. + "sometimes speed up transfers.", manager.getConfigManager(),
  111. manager.getIdentity()));
  112. general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  113. pluginInfo.getDomain(), "general.percentageInTitle",
  114. "Show percentage of transfers in the window title",
  115. "Show the current percentage of transfers in the DCC window "
  116. + "title", manager.getConfigManager(), manager.getIdentity()));
  117. }
  118. }