|
@@ -42,18 +42,17 @@ import com.dmdirc.commandparser.commands.context.CommandContext;
|
42
|
42
|
import com.dmdirc.commandparser.commands.context.ServerCommandContext;
|
43
|
43
|
import com.dmdirc.interfaces.CommandController;
|
44
|
44
|
import com.dmdirc.interfaces.Connection;
|
45
|
|
-import com.dmdirc.ui.messages.sink.MessageSinkManager;
|
46
|
45
|
import com.dmdirc.parser.interfaces.Parser;
|
47
|
46
|
import com.dmdirc.ui.WindowManager;
|
48
|
47
|
import com.dmdirc.ui.input.AdditionalTabTargets;
|
49
|
48
|
import com.dmdirc.ui.input.TabCompleterFactory;
|
50
|
49
|
import com.dmdirc.ui.input.TabCompletionType;
|
51
|
50
|
import com.dmdirc.ui.messages.ColourManagerFactory;
|
|
51
|
+import com.dmdirc.ui.messages.sink.MessageSinkManager;
|
52
|
52
|
import com.dmdirc.util.URLBuilder;
|
53
|
53
|
|
54
|
54
|
import java.awt.Window;
|
55
|
55
|
import java.io.File;
|
56
|
|
-import java.util.concurrent.Callable;
|
57
|
56
|
|
58
|
57
|
import javax.annotation.Nonnull;
|
59
|
58
|
import javax.inject.Inject;
|
|
@@ -131,20 +130,16 @@ public class DCCCommand extends Command implements IntelligentCommand {
|
131
|
130
|
if (parser.isValidChannelName(target)
|
132
|
131
|
|| parser.getStringConverter().equalsIgnoreCase(target,
|
133
|
132
|
myNickname)) {
|
134
|
|
- new Thread(new Runnable() {
|
135
|
|
-
|
136
|
|
- @Override
|
137
|
|
- public void run() {
|
138
|
|
- if (parser.getStringConverter().equalsIgnoreCase(target,
|
139
|
|
- myNickname)) {
|
140
|
|
- JOptionPane.showMessageDialog(null,
|
141
|
|
- "You can't DCC yourself.", "DCC Error",
|
142
|
|
- JOptionPane.ERROR_MESSAGE);
|
143
|
|
- } else {
|
144
|
|
- JOptionPane.showMessageDialog(null,
|
145
|
|
- "You can't DCC a channel.", "DCC Error",
|
146
|
|
- JOptionPane.ERROR_MESSAGE);
|
147
|
|
- }
|
|
133
|
+ new Thread(() -> {
|
|
134
|
+ if (parser.getStringConverter().equalsIgnoreCase(target,
|
|
135
|
+ myNickname)) {
|
|
136
|
+ JOptionPane.showMessageDialog(null,
|
|
137
|
+ "You can't DCC yourself.", "DCC Error",
|
|
138
|
+ JOptionPane.ERROR_MESSAGE);
|
|
139
|
+ } else {
|
|
140
|
+ JOptionPane.showMessageDialog(null,
|
|
141
|
+ "You can't DCC a channel.", "DCC Error",
|
|
142
|
+ JOptionPane.ERROR_MESSAGE);
|
148
|
143
|
}
|
149
|
144
|
}, "DCC-Error-Message").start();
|
150
|
145
|
return;
|
|
@@ -220,76 +215,69 @@ public class DCCCommand extends Command implements IntelligentCommand {
|
220
|
215
|
final Connection connection, final boolean isSilent, final String filename) {
|
221
|
216
|
// New thread to ask the user what file to send
|
222
|
217
|
final File givenFile = new File(filename);
|
223
|
|
- final File selectedFile = UIUtilities.invokeAndWait(new Callable<File>() {
|
224
|
|
- @Override
|
225
|
|
- public File call() {
|
226
|
|
- final JFileChooser jc = givenFile.exists()
|
227
|
|
- ? KFileChooser.getFileChooser(origin.getConfigManager(),
|
228
|
|
- myPlugin, givenFile)
|
229
|
|
- : KFileChooser.getFileChooser(origin.getConfigManager(),
|
230
|
|
- myPlugin);
|
231
|
|
- final int result = showFileChooser(givenFile, target, jc);
|
|
218
|
+ final File selectedFile = UIUtilities.invokeAndWait(() -> {
|
|
219
|
+ final JFileChooser jc = givenFile.exists()
|
|
220
|
+ ? KFileChooser.getFileChooser(origin.getConfigManager(),
|
|
221
|
+ myPlugin, givenFile)
|
|
222
|
+ : KFileChooser.getFileChooser(origin.getConfigManager(),
|
|
223
|
+ myPlugin);
|
|
224
|
+ final int result = showFileChooser(givenFile, target, jc);
|
232
|
225
|
|
233
|
|
- if (result != JFileChooser.APPROVE_OPTION
|
234
|
|
- || !handleInvalidItems(jc)) {
|
235
|
|
- return null;
|
236
|
|
- }
|
237
|
|
- return jc.getSelectedFile();
|
|
226
|
+ if (result != JFileChooser.APPROVE_OPTION
|
|
227
|
+ || !handleInvalidItems(jc)) {
|
|
228
|
+ return null;
|
238
|
229
|
}
|
|
230
|
+ return jc.getSelectedFile();
|
239
|
231
|
});
|
240
|
232
|
if (selectedFile == null) {
|
241
|
233
|
return;
|
242
|
234
|
}
|
243
|
|
- new Thread(new Runnable() {
|
244
|
|
-
|
245
|
|
- @Override
|
246
|
|
- public void run() {
|
247
|
|
- final DCCTransfer send = new DCCTransfer(origin
|
248
|
|
- .getConfigManager().getOptionInt(myPlugin.getDomain(),
|
249
|
|
- "send.blocksize"));
|
250
|
|
- send.setTurbo(origin.getConfigManager().getOptionBool(
|
251
|
|
- myPlugin.getDomain(), "send.forceturbo"));
|
252
|
|
- send.setType(DCCTransfer.TransferType.SEND);
|
|
235
|
+ new Thread(() -> {
|
|
236
|
+ final DCCTransfer send = new DCCTransfer(origin
|
|
237
|
+ .getConfigManager().getOptionInt(myPlugin.getDomain(),
|
|
238
|
+ "send.blocksize"));
|
|
239
|
+ send.setTurbo(origin.getConfigManager().getOptionBool(
|
|
240
|
+ myPlugin.getDomain(), "send.forceturbo"));
|
|
241
|
+ send.setType(DCCTransfer.TransferType.SEND);
|
253
|
242
|
|
254
|
|
- eventBus.publish(new DccSendRequestEvent(connection, target, selectedFile.
|
255
|
|
- getAbsolutePath()));
|
|
243
|
+ eventBus.publish(new DccSendRequestEvent(connection, target, selectedFile.
|
|
244
|
+ getAbsolutePath()));
|
256
|
245
|
|
257
|
|
- sendLine(origin, isSilent, FORMAT_OUTPUT,
|
258
|
|
- "Starting DCC Send with: " + target);
|
|
246
|
+ sendLine(origin, isSilent, FORMAT_OUTPUT,
|
|
247
|
+ "Starting DCC Send with: " + target);
|
259
|
248
|
|
260
|
|
- send.setFileName(selectedFile.getAbsolutePath());
|
261
|
|
- send.setFileSize(selectedFile.length());
|
|
249
|
+ send.setFileName(selectedFile.getAbsolutePath());
|
|
250
|
+ send.setFileSize(selectedFile.length());
|
262
|
251
|
|
263
|
|
- if (origin.getConfigManager().getOptionBool(
|
264
|
|
- myPlugin.getDomain(), "send.reverse")) {
|
265
|
|
- final Parser parser = connection.getParser();
|
|
252
|
+ if (origin.getConfigManager().getOptionBool(
|
|
253
|
+ myPlugin.getDomain(), "send.reverse")) {
|
|
254
|
+ final Parser parser = connection.getParser();
|
|
255
|
+ final TransferContainer container = new TransferContainer(myPlugin, send,
|
|
256
|
+ origin.getConfigManager(), colourManagerFactory, "Send: " + target,
|
|
257
|
+ target, connection, urlBuilder, eventBus);
|
|
258
|
+ windowManager.addWindow(myPlugin.getContainer(), container);
|
|
259
|
+ parser.sendCTCP(target, "DCC", "SEND \""
|
|
260
|
+ + selectedFile.getName() + "\" "
|
|
261
|
+ + DCC.ipToLong(myPlugin.getListenIP(parser))
|
|
262
|
+ + " 0 " + send.getFileSize() + " "
|
|
263
|
+ + send.makeToken()
|
|
264
|
+ + (send.isTurbo() ? " T" : ""));
|
|
265
|
+ } else {
|
|
266
|
+ final Parser parser = connection.getParser();
|
|
267
|
+ if (myPlugin.listen(send)) {
|
266
|
268
|
final TransferContainer container = new TransferContainer(myPlugin, send,
|
267
|
|
- origin.getConfigManager(), colourManagerFactory, "Send: " + target,
|
268
|
|
- target, connection, urlBuilder, eventBus);
|
|
269
|
+ origin.getConfigManager(), colourManagerFactory, "*Send: "
|
|
270
|
+ + target, target, connection, urlBuilder, eventBus);
|
269
|
271
|
windowManager.addWindow(myPlugin.getContainer(), container);
|
270
|
272
|
parser.sendCTCP(target, "DCC", "SEND \""
|
271
|
273
|
+ selectedFile.getName() + "\" "
|
272
|
274
|
+ DCC.ipToLong(myPlugin.getListenIP(parser))
|
273
|
|
- + " 0 " + send.getFileSize() + " "
|
274
|
|
- + send.makeToken()
|
|
275
|
+ + " " + send.getPort() + " " + send.getFileSize()
|
275
|
276
|
+ (send.isTurbo() ? " T" : ""));
|
276
|
277
|
} else {
|
277
|
|
- final Parser parser = connection.getParser();
|
278
|
|
- if (myPlugin.listen(send)) {
|
279
|
|
- final TransferContainer container = new TransferContainer(myPlugin, send,
|
280
|
|
- origin.getConfigManager(), colourManagerFactory, "*Send: "
|
281
|
|
- + target, target, connection, urlBuilder, eventBus);
|
282
|
|
- windowManager.addWindow(myPlugin.getContainer(), container);
|
283
|
|
- parser.sendCTCP(target, "DCC", "SEND \""
|
284
|
|
- + selectedFile.getName() + "\" "
|
285
|
|
- + DCC.ipToLong(myPlugin.getListenIP(parser))
|
286
|
|
- + " " + send.getPort() + " " + send.getFileSize()
|
287
|
|
- + (send.isTurbo() ? " T" : ""));
|
288
|
|
- } else {
|
289
|
|
- sendLine(origin, isSilent, "DCCSendError",
|
290
|
|
- "Unable to start dcc send with " + target
|
291
|
|
- + " - unable to create listen socket");
|
292
|
|
- }
|
|
278
|
+ sendLine(origin, isSilent, "DCCSendError",
|
|
279
|
+ "Unable to start dcc send with " + target
|
|
280
|
+ + " - unable to create listen socket");
|
293
|
281
|
}
|
294
|
282
|
}
|
295
|
283
|
}, "openFileThread").start();
|