|
@@ -41,6 +41,12 @@ import com.dmdirc.addons.ui_swing.injection.MainWindow;
|
41
|
41
|
import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
|
42
|
42
|
import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
|
43
|
43
|
import com.dmdirc.commandparser.parsers.GlobalCommandParser;
|
|
44
|
+import com.dmdirc.config.prefs.PluginPreferencesCategory;
|
|
45
|
+import com.dmdirc.config.prefs.PreferencesCategory;
|
|
46
|
+import com.dmdirc.config.prefs.PreferencesDialogModel;
|
|
47
|
+import com.dmdirc.config.prefs.PreferencesSetting;
|
|
48
|
+import com.dmdirc.config.prefs.PreferencesType;
|
|
49
|
+import com.dmdirc.events.ClientPrefsOpenedEvent;
|
44
|
50
|
import com.dmdirc.events.ServerCtcpEvent;
|
45
|
51
|
import com.dmdirc.events.UserErrorEvent;
|
46
|
52
|
import com.dmdirc.interfaces.CommandController;
|
|
@@ -56,7 +62,6 @@ import com.dmdirc.ui.WindowManager;
|
56
|
62
|
import com.dmdirc.ui.input.TabCompleterFactory;
|
57
|
63
|
import com.dmdirc.ui.messages.BackBufferFactory;
|
58
|
64
|
import com.dmdirc.ui.messages.sink.MessageSinkManager;
|
59
|
|
-import com.dmdirc.util.URLBuilder;
|
60
|
65
|
|
61
|
66
|
import com.google.common.collect.Lists;
|
62
|
67
|
|
|
@@ -66,7 +71,7 @@ import java.io.File;
|
66
|
71
|
import java.io.IOException;
|
67
|
72
|
import java.net.InetAddress;
|
68
|
73
|
import java.net.UnknownHostException;
|
69
|
|
-import java.util.Arrays;
|
|
74
|
+import java.util.Collections;
|
70
|
75
|
import java.util.HashSet;
|
71
|
76
|
import java.util.Set;
|
72
|
77
|
import java.util.function.Supplier;
|
|
@@ -104,6 +109,8 @@ public class DCCManager {
|
104
|
109
|
private final String domain;
|
105
|
110
|
/** The bus to dispatch events on. */
|
106
|
111
|
private final DMDircMBassador eventBus;
|
|
112
|
+ /** Plugin info. */
|
|
113
|
+ private final PluginInfo pluginInfo;
|
107
|
114
|
|
108
|
115
|
/**
|
109
|
116
|
* Creates a new instance of this plugin.
|
|
@@ -120,7 +127,6 @@ public class DCCManager {
|
120
|
127
|
final TabCompleterFactory tabCompleterFactory,
|
121
|
128
|
final SwingWindowFactory windowFactory,
|
122
|
129
|
final ComponentFrameFactory componentFrameFactory,
|
123
|
|
- final URLBuilder urlBuilder,
|
124
|
130
|
final DMDircMBassador eventBus,
|
125
|
131
|
final GlobalCommandParser commandParser,
|
126
|
132
|
@Directory(DirectoryType.BASE) final String baseDirectory,
|
|
@@ -130,6 +136,7 @@ public class DCCManager {
|
130
|
136
|
this.windowManager = windowManager;
|
131
|
137
|
this.commandController = commandController;
|
132
|
138
|
this.tabCompleterFactory = tabCompleterFactory;
|
|
139
|
+ this.pluginInfo = pluginInfo;
|
133
|
140
|
this.domain = pluginInfo.getDomain();
|
134
|
141
|
this.config = globalConfig;
|
135
|
142
|
this.eventBus = eventBus;
|
|
@@ -146,7 +153,7 @@ public class DCCManager {
|
146
|
153
|
|
147
|
154
|
@Override
|
148
|
155
|
public Set<String> getComponents() {
|
149
|
|
- return new HashSet<>(Arrays.asList(
|
|
156
|
+ return new HashSet<>(Collections.singletonList(
|
150
|
157
|
"com.dmdirc.addons.dcc.ui.PlaceholderPanel"));
|
151
|
158
|
}
|
152
|
159
|
});
|
|
@@ -161,7 +168,7 @@ public class DCCManager {
|
161
|
168
|
|
162
|
169
|
@Override
|
163
|
170
|
public Set<String> getComponents() {
|
164
|
|
- return new HashSet<>(Arrays.asList(
|
|
171
|
+ return new HashSet<>(Collections.singletonList(
|
165
|
172
|
"com.dmdirc.addons.dcc.ui.TransferPanel"));
|
166
|
173
|
}
|
167
|
174
|
});
|
|
@@ -171,6 +178,71 @@ public class DCCManager {
|
171
|
178
|
baseDirectory + "downloads" + File.separator);
|
172
|
179
|
}
|
173
|
180
|
|
|
181
|
+ @Handler
|
|
182
|
+ public void handlePrefsOpened(final ClientPrefsOpenedEvent event) {
|
|
183
|
+ final PreferencesDialogModel manager = event.getModel();
|
|
184
|
+ final PreferencesCategory general = new PluginPreferencesCategory(
|
|
185
|
+ pluginInfo, "DCC", "", "category-dcc");
|
|
186
|
+ final PreferencesCategory firewall = new PluginPreferencesCategory(
|
|
187
|
+ pluginInfo, "Firewall", "");
|
|
188
|
+ final PreferencesCategory sending = new PluginPreferencesCategory(
|
|
189
|
+ pluginInfo, "Sending", "");
|
|
190
|
+ final PreferencesCategory receiving = new PluginPreferencesCategory(
|
|
191
|
+ pluginInfo, "Receiving", "");
|
|
192
|
+
|
|
193
|
+ manager.getCategory("Plugins").addSubCategory(general.setInlineAfter());
|
|
194
|
+ general.addSubCategory(firewall.setInline());
|
|
195
|
+ general.addSubCategory(sending.setInline());
|
|
196
|
+ general.addSubCategory(receiving.setInline());
|
|
197
|
+
|
|
198
|
+ firewall.addSetting(new PreferencesSetting(PreferencesType.TEXT,
|
|
199
|
+ pluginInfo.getDomain(), "firewall.ip", "Forced IP",
|
|
200
|
+ "What IP should be sent as our IP (Blank = work it out)",
|
|
201
|
+ manager.getConfigManager(), manager.getIdentity()));
|
|
202
|
+ firewall.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
|
203
|
+ pluginInfo.getDomain(), "firewall.ports.usePortRange", "Use Port Range",
|
|
204
|
+ "Useful if you have a firewall that only forwards specific "
|
|
205
|
+ + "ports", manager.getConfigManager(), manager.getIdentity()));
|
|
206
|
+ firewall.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
|
|
207
|
+ pluginInfo.getDomain(), "firewall.ports.startPort", "Start Port",
|
|
208
|
+ "Port to try to listen on first", manager.getConfigManager(),
|
|
209
|
+ manager.getIdentity()));
|
|
210
|
+ firewall.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
|
|
211
|
+ pluginInfo.getDomain(), "firewall.ports.endPort", "End Port",
|
|
212
|
+ "Port to try to listen on last", manager.getConfigManager(),
|
|
213
|
+ manager.getIdentity()));
|
|
214
|
+ receiving.addSetting(new PreferencesSetting(PreferencesType.DIRECTORY,
|
|
215
|
+ pluginInfo.getDomain(), "receive.savelocation", "Default save location",
|
|
216
|
+ "Where the save as window defaults to?",
|
|
217
|
+ manager.getConfigManager(), manager.getIdentity()));
|
|
218
|
+ sending.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
|
219
|
+ pluginInfo.getDomain(), "send.reverse", "Reverse DCC",
|
|
220
|
+ "With reverse DCC, the sender connects rather than "
|
|
221
|
+ + "listens like normal dcc", manager.getConfigManager(),
|
|
222
|
+ manager.getIdentity()));
|
|
223
|
+ sending.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
|
224
|
+ pluginInfo.getDomain(), "send.forceturbo", "Use Turbo DCC",
|
|
225
|
+ "Turbo DCC doesn't wait for ack packets. this is "
|
|
226
|
+ + "faster but not always supported.",
|
|
227
|
+ manager.getConfigManager(), manager.getIdentity()));
|
|
228
|
+ receiving.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
|
229
|
+ pluginInfo.getDomain(), "receive.reverse.sendtoken",
|
|
230
|
+ "Send token in reverse receive",
|
|
231
|
+ "If you have problems with reverse dcc receive resume,"
|
|
232
|
+ + " try toggling this.", manager.getConfigManager(),
|
|
233
|
+ manager.getIdentity()));
|
|
234
|
+ general.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
|
|
235
|
+ pluginInfo.getDomain(), "send.blocksize", "Blocksize to use for DCC",
|
|
236
|
+ "Change the block size for send/receive, this can "
|
|
237
|
+ + "sometimes speed up transfers.", manager.getConfigManager(),
|
|
238
|
+ manager.getIdentity()));
|
|
239
|
+ general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
|
240
|
+ pluginInfo.getDomain(), "general.percentageInTitle",
|
|
241
|
+ "Show percentage of transfers in the window title",
|
|
242
|
+ "Show the current percentage of transfers in the DCC window "
|
|
243
|
+ + "title", manager.getConfigManager(), manager.getIdentity()));
|
|
244
|
+ }
|
|
245
|
+
|
174
|
246
|
public String getDomain() {
|
175
|
247
|
return domain;
|
176
|
248
|
}
|