|
@@ -60,26 +60,17 @@ import javax.swing.JOptionPane;
|
60
|
60
|
|
61
|
61
|
/**
|
62
|
62
|
* This plugin adds DCC to dmdirc.
|
63
|
|
- *
|
64
|
|
- * @author Shane 'Dataforce' McCormack
|
65
|
63
|
*/
|
66
|
64
|
public final class DCCPlugin extends Plugin implements ActionListener {
|
67
|
65
|
|
68
|
66
|
/** The DCCCommand we created. */
|
69
|
67
|
private DCCCommand command;
|
70
|
|
-
|
71
|
68
|
/** Our DCC Container window. */
|
72
|
69
|
private PlaceholderContainer container;
|
73
|
70
|
|
74
|
71
|
/**
|
75
|
|
- * Creates a new instance of the DCC Plugin.
|
76
|
|
- */
|
77
|
|
- public DCCPlugin() {
|
78
|
|
- super();
|
79
|
|
- }
|
80
|
|
-
|
81
|
|
- /**
|
82
|
|
- * Ask a question, if the answer is the answer required, then recall handleProcessEvent.
|
|
72
|
+ * Ask a question, if the answer is the answer required, then recall
|
|
73
|
+ * handleProcessEvent.
|
83
|
74
|
*
|
84
|
75
|
* @param question Question to ask
|
85
|
76
|
* @param title Title of question dialog
|
|
@@ -88,22 +79,23 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
88
|
79
|
* @param format StringBuffer to pass back
|
89
|
80
|
* @param arguments arguments to pass back
|
90
|
81
|
*/
|
91
|
|
- public void askQuestion(final String question, final String title, final int desiredAnswer, final ActionType type, final StringBuffer format, final Object... arguments) {
|
|
82
|
+ public void askQuestion(final String question, final String title,
|
|
83
|
+ final int desiredAnswer, final ActionType type,
|
|
84
|
+ final StringBuffer format, final Object... arguments) {
|
92
|
85
|
// New thread to ask the question in to stop us locking the UI
|
93
|
|
- final Thread questionThread = new Thread(new Runnable() {
|
|
86
|
+ new Thread(new Runnable() {
|
94
|
87
|
|
95
|
88
|
/** {@inheritDoc} */
|
96
|
89
|
@Override
|
97
|
90
|
public void run() {
|
98
|
|
- int result = JOptionPane.showConfirmDialog(null, question, title, JOptionPane.YES_NO_OPTION);
|
|
91
|
+ final int result = JOptionPane.showConfirmDialog(null, question,
|
|
92
|
+ title, JOptionPane.YES_NO_OPTION);
|
99
|
93
|
if (result == desiredAnswer) {
|
100
|
94
|
handleProcessEvent(type, format, true, arguments);
|
101
|
95
|
}
|
102
|
96
|
}
|
103
|
97
|
|
104
|
|
- }, "QuestionThread: " + title);
|
105
|
|
- // Start the thread
|
106
|
|
- questionThread.start();
|
|
98
|
+ }, "QuestionThread: " + title).start();
|
107
|
99
|
}
|
108
|
100
|
|
109
|
101
|
/**
|
|
@@ -113,97 +105,164 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
113
|
105
|
* @param send The DCCSend to save for.
|
114
|
106
|
* @param parser The parser this send was received on
|
115
|
107
|
* @param reverse Is this a reverse dcc?
|
116
|
|
- * @param sendFilename The name of the file which is being received
|
117
|
108
|
* @param token Token used in reverse dcc.
|
118
|
109
|
*/
|
119
|
|
- public void saveFile(final String nickname, final DCCTransfer send, final Parser parser, final boolean reverse, final String sendFilename, final String token) {
|
|
110
|
+ public void saveFile(final String nickname, final DCCTransfer send,
|
|
111
|
+ final Parser parser, final boolean reverse, final String token) {
|
120
|
112
|
// New thread to ask the user where to save in to stop us locking the UI
|
121
|
|
- final Thread dccThread = new Thread(new Runnable() {
|
|
113
|
+ new Thread(new Runnable() {
|
122
|
114
|
|
123
|
115
|
/** {@inheritDoc} */
|
124
|
116
|
@Override
|
125
|
117
|
public void run() {
|
126
|
|
- final JFileChooser jc = KFileChooser.getFileChooser(DCCPlugin.this, IdentityManager.getGlobalConfig().getOption(getDomain(), "receive.savelocation"));
|
127
|
|
- jc.setDialogTitle("Save " + sendFilename + " As - DMDirc");
|
128
|
|
- jc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
129
|
|
- jc.setMultiSelectionEnabled(false);
|
130
|
|
- jc.setSelectedFile(new File(send.getFileName()));
|
|
118
|
+ final JFileChooser jc = KFileChooser.getFileChooser(
|
|
119
|
+ DCCPlugin.this, IdentityManager.getGlobalConfig()
|
|
120
|
+ .getOption(getDomain(), "receive.savelocation"));
|
131
|
121
|
int result;
|
132
|
|
- if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "receive.autoaccept")) {
|
|
122
|
+ if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(),
|
|
123
|
+ "receive.autoaccept")) {
|
133
|
124
|
result = JFileChooser.APPROVE_OPTION;
|
134
|
125
|
} else {
|
135
|
|
- result = jc.showSaveDialog(((SwingController) PluginManager
|
136
|
|
- .getPluginManager().getPluginInfoByName("ui_swing")
|
137
|
|
- .getPlugin()).getMainFrame());
|
|
126
|
+ result = showFileChooser(send, jc);
|
138
|
127
|
}
|
139
|
|
- if (result == JFileChooser.APPROVE_OPTION) {
|
140
|
|
- send.setFileName(jc.getSelectedFile().getPath());
|
141
|
|
- boolean resume = false;
|
142
|
|
- if (jc.getSelectedFile().exists()) {
|
143
|
|
- if (send.getFileSize() > -1 && send.getFileSize() <= jc.getSelectedFile().length()) {
|
144
|
|
- if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "receive.autoaccept")) {
|
145
|
|
- return;
|
146
|
|
- } else {
|
147
|
|
- JOptionPane.showMessageDialog(
|
148
|
|
- ((SwingController) PluginManager
|
149
|
|
- .getPluginManager().getPluginInfoByName("ui_swing")
|
150
|
|
- .getPlugin()).getMainFrame(), "This file has already been completed, or is longer than the file you are receiving.\nPlease choose a different file.", "Problem with selected file", JOptionPane.ERROR_MESSAGE);
|
151
|
|
- saveFile(nickname, send, parser, reverse, sendFilename, token);
|
152
|
|
- return;
|
153
|
|
- }
|
154
|
|
- } else {
|
155
|
|
- if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "receive.autoaccept")) {
|
156
|
|
- resume = true;
|
157
|
|
- } else {
|
158
|
|
- result = JOptionPane.showConfirmDialog(
|
159
|
|
- ((SwingController) PluginManager
|
160
|
|
- .getPluginManager().getPluginInfoByName("ui_swing")
|
161
|
|
- .getPlugin()).getMainFrame(), "This file exists already, do you want to resume an exisiting download?", "Resume Download?", JOptionPane.YES_NO_OPTION);
|
162
|
|
- resume = (result == JOptionPane.YES_OPTION);
|
163
|
|
- }
|
164
|
|
- }
|
165
|
|
- }
|
|
128
|
+ if (result != JFileChooser.APPROVE_OPTION) {
|
|
129
|
+ return;
|
|
130
|
+ }
|
|
131
|
+ send.setFileName(jc.getSelectedFile().getPath());
|
|
132
|
+ if (!handleExists(send, jc, nickname, parser,reverse, token)) {
|
|
133
|
+ return;
|
|
134
|
+ }
|
|
135
|
+ boolean resume = handleResume(jc);
|
166
|
136
|
if (reverse && !token.isEmpty()) {
|
167
|
|
- new TransferContainer(DCCPlugin.this, send, "*Receive: " + nickname, nickname, null);
|
|
137
|
+ new TransferContainer(DCCPlugin.this, send,
|
|
138
|
+ "*Receive: " + nickname, nickname, null);
|
168
|
139
|
send.setToken(token);
|
169
|
140
|
if (resume) {
|
170
|
|
- if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "receive.reverse.sendtoken")) {
|
171
|
|
- parser.sendCTCP(nickname, "DCC", "RESUME " + sendFilename + " 0 " + jc.getSelectedFile().length() + " " + token);
|
|
141
|
+ if (IdentityManager.getGlobalConfig().getOptionBool(
|
|
142
|
+ getDomain(), "receive.reverse.sendtoken")) {
|
|
143
|
+ parser.sendCTCP(nickname, "DCC", "RESUME "
|
|
144
|
+ + send.getShortFileName() + " 0 "
|
|
145
|
+ + jc.getSelectedFile().length() + " "
|
|
146
|
+ + token);
|
172
|
147
|
} else {
|
173
|
|
- parser.sendCTCP(nickname, "DCC", "RESUME " + sendFilename + " 0 " + jc.getSelectedFile().length());
|
|
148
|
+ parser.sendCTCP(nickname, "DCC", "RESUME "
|
|
149
|
+ + send.getShortFileName() + " 0 "
|
|
150
|
+ + jc.getSelectedFile().length());
|
174
|
151
|
}
|
175
|
152
|
} else {
|
176
|
153
|
if (listen(send)) {
|
177
|
|
- parser.sendCTCP(nickname, "DCC", "SEND " + sendFilename + " " + DCC.ipToLong(getListenIP(parser)) + " " + send.getPort() + " " + send.getFileSize() + " " + token);
|
178
|
|
- } else {
|
179
|
|
- // Listen failed.
|
|
154
|
+ parser.sendCTCP(nickname, "DCC", "SEND "
|
|
155
|
+ + send.getShortFileName() + " "
|
|
156
|
+ + DCC.ipToLong(getListenIP(parser))
|
|
157
|
+ + " " + send.getPort() + " "
|
|
158
|
+ + send.getFileSize() + " " + token);
|
180
|
159
|
}
|
181
|
160
|
}
|
182
|
161
|
} else {
|
183
|
|
- new TransferContainer(DCCPlugin.this, send, "Receive: " + nickname, nickname, null);
|
|
162
|
+ new TransferContainer(DCCPlugin.this, send, "Receive: "
|
|
163
|
+ + nickname, nickname, null);
|
184
|
164
|
if (resume) {
|
185
|
|
- parser.sendCTCP(nickname, "DCC", "RESUME " + sendFilename + " " + send.getPort() + " " + jc.getSelectedFile().length());
|
|
165
|
+ parser.sendCTCP(nickname, "DCC", "RESUME "
|
|
166
|
+ + send.getShortFileName() + " "
|
|
167
|
+ + send.getPort() + " "
|
|
168
|
+ + jc.getSelectedFile().length());
|
186
|
169
|
} else {
|
187
|
170
|
send.connect();
|
188
|
171
|
}
|
189
|
172
|
}
|
190
|
173
|
}
|
|
174
|
+
|
|
175
|
+ }, "saveFileThread: " + send.getShortFileName()).start();
|
|
176
|
+ }
|
|
177
|
+
|
|
178
|
+ /**
|
|
179
|
+ * Checks if the selected file exists and prompts the user as required.
|
|
180
|
+ *
|
|
181
|
+ * @param send DCC Transfer
|
|
182
|
+ * @param jc File chooser
|
|
183
|
+ * @param nickname Remote nickname
|
|
184
|
+ * @param parser Parser
|
|
185
|
+ * @param reverse Reverse DCC?
|
|
186
|
+ * @param token DCC token
|
|
187
|
+ *
|
|
188
|
+ * @return true if the user wants to continue, false if they wish to abort
|
|
189
|
+ */
|
|
190
|
+ private boolean handleExists(final DCCTransfer send, final JFileChooser jc,
|
|
191
|
+ final String nickname, final Parser parser, final boolean reverse,
|
|
192
|
+ final String token) {
|
|
193
|
+ if (jc.getSelectedFile().exists() && send.getFileSize() > -1
|
|
194
|
+ && send.getFileSize() <= jc.getSelectedFile().length()) {
|
|
195
|
+ if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(),
|
|
196
|
+ "receive.autoaccept")) {
|
|
197
|
+ return false;
|
|
198
|
+ } else {
|
|
199
|
+ JOptionPane.showMessageDialog(((SwingController) PluginManager
|
|
200
|
+ .getPluginManager().getPluginInfoByName("ui_swing")
|
|
201
|
+ .getPlugin()).getMainFrame(), "This file has already "
|
|
202
|
+ + "been completed, or is longer than the file you are "
|
|
203
|
+ + "receiving.\nPlease choose a different file.",
|
|
204
|
+ "Problem with selected file",
|
|
205
|
+ JOptionPane.ERROR_MESSAGE);
|
|
206
|
+ saveFile(nickname, send, parser, reverse, token);
|
|
207
|
+ return false;
|
191
|
208
|
}
|
|
209
|
+ }
|
|
210
|
+ return true;
|
|
211
|
+ }
|
192
|
212
|
|
193
|
|
- }, "saveFileThread: " + sendFilename);
|
194
|
|
- // Start the thread
|
195
|
|
- dccThread.start();
|
|
213
|
+ /**
|
|
214
|
+ * Prompts the user to resume a transfer if required.
|
|
215
|
+ *
|
|
216
|
+ * @param jc File chooser
|
|
217
|
+ *
|
|
218
|
+ * @return true if the user wants to continue the transfer false otherwise
|
|
219
|
+ */
|
|
220
|
+ private boolean handleResume(final JFileChooser jc) {
|
|
221
|
+ if (jc.getSelectedFile().exists()) {
|
|
222
|
+ if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(),
|
|
223
|
+ "receive.autoaccept")) {
|
|
224
|
+ return true;
|
|
225
|
+ } else {
|
|
226
|
+ final int result = JOptionPane.showConfirmDialog(
|
|
227
|
+ ((SwingController) PluginManager
|
|
228
|
+ .getPluginManager().getPluginInfoByName("ui_swing")
|
|
229
|
+ .getPlugin()).getMainFrame(), "This file exists already"
|
|
230
|
+ + ", do you want to resume an exisiting download?",
|
|
231
|
+ "Resume Download?", JOptionPane.YES_NO_OPTION);
|
|
232
|
+ return (result == JOptionPane.YES_OPTION);
|
|
233
|
+ }
|
|
234
|
+ }
|
|
235
|
+ return false;
|
196
|
236
|
}
|
197
|
237
|
|
198
|
238
|
/**
|
199
|
|
- * Process an event of the specified type.
|
|
239
|
+ * Sets up and display a file chooser.
|
200
|
240
|
*
|
201
|
|
- * @param type The type of the event to process
|
202
|
|
- * @param format Format of messages that are about to be sent. (May be null)
|
203
|
|
- * @param arguments The arguments for the event
|
|
241
|
+ * @param send DCCTransfer object sending the file
|
|
242
|
+ * @param jc File chooser
|
|
243
|
+ *
|
|
244
|
+ * @return the return state of the file chooser on popdown:
|
|
245
|
+ * <ul>
|
|
246
|
+ * <li>JFileChooser.CANCEL_OPTION
|
|
247
|
+ * <li>JFileChooser.APPROVE_OPTION
|
|
248
|
+ * <li>JFileChooser.ERROR_OPTION if an error occurs or the
|
|
249
|
+ * dialog is dismissed
|
|
250
|
+ * </ul>
|
204
|
251
|
*/
|
|
252
|
+ private int showFileChooser(final DCCTransfer send, final JFileChooser jc) {
|
|
253
|
+ jc.setDialogTitle("Save " + send.getShortFileName() + " As - DMDirc");
|
|
254
|
+ jc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
|
255
|
+ jc.setMultiSelectionEnabled(false);
|
|
256
|
+ jc.setSelectedFile(new File(send.getFileName()));
|
|
257
|
+ return jc.showSaveDialog(((SwingController) PluginManager
|
|
258
|
+ .getPluginManager().getPluginInfoByName("ui_swing")
|
|
259
|
+ .getPlugin()).getMainFrame());
|
|
260
|
+ }
|
|
261
|
+
|
|
262
|
+ /** {@inheritDoc} */
|
205
|
263
|
@Override
|
206
|
|
- public void processEvent(final ActionType type, final StringBuffer format, final Object... arguments) {
|
|
264
|
+ public void processEvent(final ActionType type, final StringBuffer format,
|
|
265
|
+ final Object... arguments) {
|
207
|
266
|
handleProcessEvent(type, format, false, arguments);
|
208
|
267
|
}
|
209
|
268
|
|
|
@@ -216,13 +275,14 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
216
|
275
|
* @return True if Socket was opened.
|
217
|
276
|
*/
|
218
|
277
|
protected boolean listen(final DCC dcc) {
|
219
|
|
-
|
220
|
|
- final boolean usePortRange = IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "firewall.ports.usePortRange");
|
221
|
|
- final int startPort = IdentityManager.getGlobalConfig().getOptionInt(getDomain(), "firewall.ports.startPort");
|
222
|
|
- final int endPort = IdentityManager.getGlobalConfig().getOptionInt(getDomain(), "firewall.ports.endPort");
|
223
|
|
-
|
|
278
|
+ final boolean usePortRange = IdentityManager.getGlobalConfig()
|
|
279
|
+ .getOptionBool(getDomain(), "firewall.ports.usePortRange");
|
224
|
280
|
try {
|
225
|
281
|
if (usePortRange) {
|
|
282
|
+ final int startPort = IdentityManager.getGlobalConfig()
|
|
283
|
+ .getOptionInt(getDomain(), "firewall.ports.startPort");
|
|
284
|
+ final int endPort = IdentityManager.getGlobalConfig()
|
|
285
|
+ .getOptionInt(getDomain(), "firewall.ports.endPort");
|
226
|
286
|
dcc.listen(startPort, endPort);
|
227
|
287
|
} else {
|
228
|
288
|
dcc.listen();
|
|
@@ -241,193 +301,280 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
241
|
301
|
* @param dontAsk Don't ask any questions, assume yes.
|
242
|
302
|
* @param arguments The arguments for the event
|
243
|
303
|
*/
|
244
|
|
- public void handleProcessEvent(final ActionType type, final StringBuffer format, final boolean dontAsk, final Object... arguments) {
|
245
|
|
- if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "receive.autoaccept") && !dontAsk) {
|
|
304
|
+ public void handleProcessEvent(final ActionType type,
|
|
305
|
+ final StringBuffer format, final boolean dontAsk,
|
|
306
|
+ final Object... arguments) {
|
|
307
|
+ if (IdentityManager.getGlobalConfig().getOptionBool(getDomain(),
|
|
308
|
+ "receive.autoaccept") && !dontAsk) {
|
246
|
309
|
handleProcessEvent(type, format, true, arguments);
|
247
|
310
|
return;
|
248
|
311
|
}
|
249
|
312
|
|
250
|
313
|
if (type == CoreActionType.SERVER_CTCP) {
|
251
|
|
- final String ctcpType = (String) arguments[2];
|
252
|
314
|
final String[] ctcpData = ((String) arguments[3]).split(" ");
|
253
|
|
- if (ctcpType.equalsIgnoreCase("DCC")) {
|
254
|
|
- if (ctcpData[0].equalsIgnoreCase("chat") && ctcpData.length > 3) {
|
255
|
|
- final String nickname = ((ClientInfo) arguments[1]).getNickname();
|
256
|
|
- if (dontAsk) {
|
257
|
|
- final DCCChat chat = new DCCChat();
|
258
|
|
- try {
|
259
|
|
- chat.setAddress(Long.parseLong(ctcpData[2]), Integer.parseInt(ctcpData[3]));
|
260
|
|
- } catch (NumberFormatException nfe) {
|
261
|
|
- return;
|
262
|
|
- }
|
263
|
|
- final String myNickname = ((Server) arguments[0]).getParser().getLocalClient().getNickname();
|
264
|
|
- final DCCFrameContainer<?> f = new ChatContainer(this, chat, "Chat: " + nickname, myNickname, nickname);
|
265
|
|
- f.addLine("DCCChatStarting", nickname, chat.getHost(), chat.getPort());
|
266
|
|
- chat.connect();
|
267
|
|
- } else {
|
268
|
|
- ActionManager.processEvent(DCCActions.DCC_CHAT_REQUEST, null, ((Server) arguments[0]), nickname);
|
269
|
|
- askQuestion("User " + nickname + " on " + ((Server) arguments[0]).toString() + " would like to start a DCC Chat with you.\n\nDo you want to continue?", "DCC Chat Request", JOptionPane.YES_OPTION, type, format, arguments);
|
270
|
|
- return;
|
271
|
|
- }
|
272
|
|
- } else if (ctcpData[0].equalsIgnoreCase("send") && ctcpData.length > 3) {
|
273
|
|
- final String nickname = ((ClientInfo) arguments[1]).getNickname();
|
274
|
|
- final String filename;
|
275
|
|
- String tmpFilename;
|
276
|
|
- // Clients tend to put files with spaces in the name in "" so lets look for that.
|
277
|
|
- final StringBuilder filenameBits = new StringBuilder();
|
278
|
|
- int i;
|
279
|
|
- final boolean quoted = ctcpData[1].startsWith("\"");
|
280
|
|
- if (quoted) {
|
281
|
|
- for (i = 1; i < ctcpData.length; i++) {
|
282
|
|
- String bit = ctcpData[i];
|
283
|
|
- if (i == 1) {
|
284
|
|
- bit = bit.substring(1);
|
285
|
|
- }
|
286
|
|
- if (bit.endsWith("\"")) {
|
287
|
|
- filenameBits.append(" " + bit.substring(0, bit.length() - 1));
|
288
|
|
- break;
|
289
|
|
- } else {
|
290
|
|
- filenameBits.append(" " + bit);
|
291
|
|
- }
|
292
|
|
- }
|
293
|
|
- tmpFilename = filenameBits.toString().trim();
|
294
|
|
- } else {
|
295
|
|
- tmpFilename = ctcpData[1];
|
296
|
|
- i = 1;
|
297
|
|
- }
|
|
315
|
+ if ("DCC".equalsIgnoreCase((String) arguments[2])) {
|
|
316
|
+ if ("chat".equalsIgnoreCase(ctcpData[0])
|
|
317
|
+ && ctcpData.length > 3) {
|
|
318
|
+ handleChat(type, format, dontAsk, ctcpData, arguments);
|
|
319
|
+ } else if ("send".equalsIgnoreCase(ctcpData[0])
|
|
320
|
+ && ctcpData.length > 3) {
|
|
321
|
+ handleSend(type, format, dontAsk, ctcpData, arguments);
|
|
322
|
+ } else if (("resume".equalsIgnoreCase(ctcpData[0])
|
|
323
|
+ || "accept".equalsIgnoreCase(ctcpData[0]))
|
|
324
|
+ && ctcpData.length > 2) {
|
|
325
|
+ handleReceive(ctcpData, arguments);
|
|
326
|
+ }
|
|
327
|
+ }
|
|
328
|
+ }
|
|
329
|
+ }
|
298
|
330
|
|
299
|
|
- // Try to remove path names if sent.
|
300
|
|
- // Change file separatorChar from other OSs first
|
301
|
|
- if (File.separatorChar == '/') {
|
302
|
|
- tmpFilename = tmpFilename.replace('\\', File.separatorChar);
|
303
|
|
- } else {
|
304
|
|
- tmpFilename = tmpFilename.replace('/', File.separatorChar);
|
305
|
|
- }
|
306
|
|
- // Then get just the name of the file.
|
307
|
|
- filename = (new File(tmpFilename)).getName();
|
308
|
|
-
|
309
|
|
- final String ip = ctcpData[++i];
|
310
|
|
- final String port = ctcpData[++i];
|
311
|
|
- long size;
|
312
|
|
- if (ctcpData.length + 1 > i) {
|
313
|
|
- try {
|
314
|
|
- size = Integer.parseInt(ctcpData[++i]);
|
315
|
|
- } catch (NumberFormatException nfe) {
|
316
|
|
- size = -1;
|
317
|
|
- }
|
318
|
|
- } else {
|
319
|
|
- size = -1;
|
320
|
|
- }
|
321
|
|
- final String token = (ctcpData.length - 1 > i && !ctcpData[i + 1].equals("T")) ? ctcpData[++i] : "";
|
|
331
|
+ /**
|
|
332
|
+ * Handles a DCC chat request.
|
|
333
|
+ *
|
|
334
|
+ * @param type The type of the event to process
|
|
335
|
+ * @param format Format of messages that are about to be sent. (May be null)
|
|
336
|
+ * @param dontAsk Don't ask any questions, assume yes.
|
|
337
|
+ * @param ctcpData CTCP data bits
|
|
338
|
+ * @param arguments The arguments for the event
|
|
339
|
+ */
|
|
340
|
+ private void handleChat(final ActionType type, final StringBuffer format,
|
|
341
|
+ final boolean dontAsk, final String[] ctcpData,
|
|
342
|
+ final Object... arguments) {
|
|
343
|
+ final String nickname = ((ClientInfo) arguments[1]).getNickname();
|
|
344
|
+ if (dontAsk) {
|
|
345
|
+ final DCCChat chat = new DCCChat();
|
|
346
|
+ try {
|
|
347
|
+ chat.setAddress(Long.parseLong(ctcpData[2]),
|
|
348
|
+ Integer.parseInt(ctcpData[3]));
|
|
349
|
+ } catch (NumberFormatException nfe) {
|
|
350
|
+ return;
|
|
351
|
+ }
|
|
352
|
+ final String myNickname = ((Server) arguments[0]).getParser()
|
|
353
|
+ .getLocalClient().getNickname();
|
|
354
|
+ final DCCFrameContainer<?> f = new ChatContainer(this, chat,
|
|
355
|
+ "Chat: " + nickname, myNickname, nickname);
|
|
356
|
+ f.addLine("DCCChatStarting", nickname, chat.getHost(),
|
|
357
|
+ chat.getPort());
|
|
358
|
+ chat.connect();
|
|
359
|
+ } else {
|
|
360
|
+ ActionManager.processEvent(DCCActions.DCC_CHAT_REQUEST, null,
|
|
361
|
+ ((Server) arguments[0]), nickname);
|
|
362
|
+ askQuestion("User " + nickname + " on "
|
|
363
|
+ + ((Server) arguments[0]).toString()
|
|
364
|
+ + " would like to start a DCC Chat with you.\n\n"
|
|
365
|
+ + "Do you want to continue?",
|
|
366
|
+ "DCC Chat Request", JOptionPane.YES_OPTION,
|
|
367
|
+ type, format, arguments);
|
|
368
|
+ return;
|
|
369
|
+ }
|
|
370
|
+ }
|
322
|
371
|
|
323
|
|
- // Ignore incorrect ports, or non-numeric IP/Port
|
324
|
|
- try {
|
325
|
|
- int portInt = Integer.parseInt(port);
|
326
|
|
- if (portInt > 65535 || portInt < 0) {
|
327
|
|
- return;
|
328
|
|
- }
|
329
|
|
- Long.parseLong(ip);
|
330
|
|
- } catch (NumberFormatException nfe) {
|
331
|
|
- return;
|
332
|
|
- }
|
|
372
|
+ /**
|
|
373
|
+ * Handles a DCC send request.
|
|
374
|
+ *
|
|
375
|
+ * @param type The type of the event to process
|
|
376
|
+ * @param format Format of messages that are about to be sent. (May be null)
|
|
377
|
+ * @param dontAsk Don't ask any questions, assume yes.
|
|
378
|
+ * @param ctcpData CTCP data bits
|
|
379
|
+ * @param arguments The arguments for the event
|
|
380
|
+ */
|
|
381
|
+ private void handleSend(final ActionType type, final StringBuffer format,
|
|
382
|
+ final boolean dontAsk, final String[] ctcpData,
|
|
383
|
+ final Object... arguments) {
|
|
384
|
+ final String nickname = ((ClientInfo) arguments[1]).getNickname();
|
|
385
|
+ final String filename;
|
|
386
|
+ String tmpFilename;
|
|
387
|
+ // Clients tend to put files with spaces in the name in ""
|
|
388
|
+ final StringBuilder filenameBits = new StringBuilder();
|
|
389
|
+ int i;
|
|
390
|
+ final boolean quoted = ctcpData[1].startsWith("\"");
|
|
391
|
+ if (quoted) {
|
|
392
|
+ for (i = 1; i < ctcpData.length; i++) {
|
|
393
|
+ String bit = ctcpData[i];
|
|
394
|
+ if (i == 1) {
|
|
395
|
+ bit = bit.substring(1);
|
|
396
|
+ }
|
|
397
|
+ if (bit.endsWith("\"")) {
|
|
398
|
+ filenameBits.append(" ")
|
|
399
|
+ .append(bit.substring(0, bit.length() - 1));
|
|
400
|
+ break;
|
|
401
|
+ } else {
|
|
402
|
+ filenameBits.append(" ").append(bit);
|
|
403
|
+ }
|
|
404
|
+ }
|
|
405
|
+ tmpFilename = filenameBits.toString().trim();
|
|
406
|
+ } else {
|
|
407
|
+ tmpFilename = ctcpData[1];
|
|
408
|
+ i = 1;
|
|
409
|
+ }
|
333
|
410
|
|
334
|
|
- DCCTransfer send = DCCTransfer.findByToken(token);
|
|
411
|
+ // Try to remove path names if sent.
|
|
412
|
+ // Change file separatorChar from other OSs first
|
|
413
|
+ if (File.separatorChar == '/') {
|
|
414
|
+ tmpFilename = tmpFilename.replace('\\', File.separatorChar);
|
|
415
|
+ } else {
|
|
416
|
+ tmpFilename = tmpFilename.replace('/', File.separatorChar);
|
|
417
|
+ }
|
|
418
|
+ // Then get just the name of the file.
|
|
419
|
+ filename = (new File(tmpFilename)).getName();
|
335
|
420
|
|
336
|
|
- if (send == null && !dontAsk) {
|
337
|
|
- if (!token.isEmpty() && !port.equals("0")) {
|
338
|
|
- // This is a reverse DCC Send that we no longer care about.
|
339
|
|
- return;
|
340
|
|
- } else {
|
341
|
|
- ActionManager.processEvent(DCCActions.DCC_SEND_REQUEST, null, ((Server) arguments[0]), nickname, filename);
|
342
|
|
- askQuestion("User " + nickname + " on " + ((Server) arguments[0]).toString() + " would like to send you a file over DCC.\n\nFile: " + filename + "\n\nDo you want to continue?", "DCC Send Request", JOptionPane.YES_OPTION, type, format, arguments);
|
343
|
|
- return;
|
344
|
|
- }
|
345
|
|
- } else {
|
346
|
|
- final boolean newSend = send == null;
|
347
|
|
- if (newSend) {
|
348
|
|
- send = new DCCTransfer(IdentityManager.getGlobalConfig().getOptionInt(getDomain(), "send.blocksize"));
|
349
|
|
- send.setTurbo(IdentityManager.getGlobalConfig().getOptionBool(getDomain(), "send.forceturbo"));
|
350
|
|
- }
|
351
|
|
- try {
|
352
|
|
- send.setAddress(Long.parseLong(ip), Integer.parseInt(port));
|
353
|
|
- } catch (NumberFormatException nfe) {
|
354
|
|
- return;
|
355
|
|
- }
|
356
|
|
- if (newSend) {
|
357
|
|
- send.setFileName(filename);
|
358
|
|
- send.setFileSize(size);
|
359
|
|
- saveFile(nickname, send, ((Server) arguments[0]).getParser(), "0".equals(port), (quoted) ? "\"" + filename + "\"" : filename, token);
|
360
|
|
- } else {
|
361
|
|
- send.connect();
|
362
|
|
- }
|
363
|
|
- }
|
364
|
|
- } else if ((ctcpData[0].equalsIgnoreCase("resume") || ctcpData[0].equalsIgnoreCase("accept")) && ctcpData.length > 2) {
|
365
|
|
-
|
366
|
|
- final String filename;
|
367
|
|
- // Clients tend to put files with spaces in the name in "" so lets look for that.
|
368
|
|
- final StringBuilder filenameBits = new StringBuilder();
|
369
|
|
- int i;
|
370
|
|
- final boolean quoted = ctcpData[1].startsWith("\"");
|
371
|
|
- if (quoted) {
|
372
|
|
- for (i = 1; i < ctcpData.length; i++) {
|
373
|
|
- String bit = ctcpData[i];
|
374
|
|
- if (i == 1) {
|
375
|
|
- bit = bit.substring(1);
|
376
|
|
- }
|
377
|
|
- if (bit.endsWith("\"")) {
|
378
|
|
- filenameBits.append(" " + bit.substring(0, bit.length() - 1));
|
379
|
|
- break;
|
|
421
|
+ final String ip = ctcpData[++i];
|
|
422
|
+ final String port = ctcpData[++i];
|
|
423
|
+ long size;
|
|
424
|
+ if (ctcpData.length + 1 > i) {
|
|
425
|
+ try {
|
|
426
|
+ size = Integer.parseInt(ctcpData[++i]);
|
|
427
|
+ } catch (NumberFormatException nfe) {
|
|
428
|
+ size = -1;
|
|
429
|
+ }
|
|
430
|
+ } else {
|
|
431
|
+ size = -1;
|
|
432
|
+ }
|
|
433
|
+ final String token = (ctcpData.length - 1 > i
|
|
434
|
+ && !ctcpData[i + 1].equals("T")) ? ctcpData[++i] : "";
|
|
435
|
+
|
|
436
|
+ // Ignore incorrect ports, or non-numeric IP/Port
|
|
437
|
+ try {
|
|
438
|
+ int portInt = Integer.parseInt(port);
|
|
439
|
+ if (portInt > 65535 || portInt < 0) {
|
|
440
|
+ return;
|
|
441
|
+ }
|
|
442
|
+ Long.parseLong(ip);
|
|
443
|
+ } catch (NumberFormatException nfe) {
|
|
444
|
+ return;
|
|
445
|
+ }
|
|
446
|
+
|
|
447
|
+ DCCTransfer send = DCCTransfer.findByToken(token);
|
|
448
|
+
|
|
449
|
+ if (send == null && !dontAsk) {
|
|
450
|
+ if (!token.isEmpty() && !port.equals("0")) {
|
|
451
|
+ // This is a reverse DCC Send that we no longer care about.
|
|
452
|
+ return;
|
|
453
|
+ } else {
|
|
454
|
+ ActionManager.processEvent(DCCActions.DCC_SEND_REQUEST, null,
|
|
455
|
+ ((Server) arguments[0]), nickname, filename);
|
|
456
|
+ askQuestion("User " + nickname + " on "
|
|
457
|
+ + ((Server) arguments[0]).toString()
|
|
458
|
+ + " would like to send you a file over DCC.\n\nFile: "
|
|
459
|
+ + filename + "\n\nDo you want to continue?",
|
|
460
|
+ "DCC Send Request", JOptionPane.YES_OPTION, type,
|
|
461
|
+ format, arguments);
|
|
462
|
+ return;
|
|
463
|
+ }
|
|
464
|
+ } else {
|
|
465
|
+ final boolean newSend = send == null;
|
|
466
|
+ if (newSend) {
|
|
467
|
+ send = new DCCTransfer(IdentityManager.getGlobalConfig()
|
|
468
|
+ .getOptionInt(getDomain(), "send.blocksize"));
|
|
469
|
+ send.setTurbo(IdentityManager.getGlobalConfig().getOptionBool(
|
|
470
|
+ getDomain(), "send.forceturbo"));
|
|
471
|
+ }
|
|
472
|
+ try {
|
|
473
|
+ send.setAddress(Long.parseLong(ip), Integer.parseInt(port));
|
|
474
|
+ } catch (NumberFormatException nfe) {
|
|
475
|
+ return;
|
|
476
|
+ }
|
|
477
|
+ if (newSend) {
|
|
478
|
+ send.setFileName(filename);
|
|
479
|
+ send.setFileSize(size);
|
|
480
|
+ saveFile(nickname, send, ((Server) arguments[0]).getParser(),
|
|
481
|
+ "0".equals(port), token);
|
|
482
|
+ } else {
|
|
483
|
+ send.connect();
|
|
484
|
+ }
|
|
485
|
+ }
|
|
486
|
+ }
|
|
487
|
+
|
|
488
|
+ /**
|
|
489
|
+ * Handles a DCC chat request.
|
|
490
|
+ *
|
|
491
|
+ * @param ctcpData CTCP data bits
|
|
492
|
+ * @param arguments The arguments for the event
|
|
493
|
+ */
|
|
494
|
+ private void handleReceive(final String[] ctcpData,
|
|
495
|
+ final Object... arguments) {
|
|
496
|
+ final String filename;
|
|
497
|
+ // Clients tend to put files with spaces in the name in ""
|
|
498
|
+ final StringBuilder filenameBits = new StringBuilder();
|
|
499
|
+ int i;
|
|
500
|
+ final boolean quoted = ctcpData[1].startsWith("\"");
|
|
501
|
+ if (quoted) {
|
|
502
|
+ for (i = 1; i < ctcpData.length; i++) {
|
|
503
|
+ String bit = ctcpData[i];
|
|
504
|
+ if (i == 1) {
|
|
505
|
+ bit = bit.substring(1);
|
|
506
|
+ }
|
|
507
|
+ if (bit.endsWith("\"")) {
|
|
508
|
+ filenameBits.append(" ")
|
|
509
|
+ .append(bit.substring(0, bit.length() - 1));
|
|
510
|
+ break;
|
|
511
|
+ } else {
|
|
512
|
+ filenameBits.append(" ").append(bit);
|
|
513
|
+ }
|
|
514
|
+ }
|
|
515
|
+ filename = filenameBits.toString().trim();
|
|
516
|
+ } else {
|
|
517
|
+ filename = ctcpData[1];
|
|
518
|
+ i = 1;
|
|
519
|
+ }
|
|
520
|
+
|
|
521
|
+ final int port;
|
|
522
|
+ final int position;
|
|
523
|
+ try {
|
|
524
|
+ port = Integer.parseInt(ctcpData[++i]);
|
|
525
|
+ position = Integer.parseInt(ctcpData[++i]);
|
|
526
|
+ } catch (NumberFormatException nfe) {
|
|
527
|
+ return;
|
|
528
|
+ }
|
|
529
|
+ final String token = (ctcpData.length - 1 > i) ? " "
|
|
530
|
+ + ctcpData[++i] : "";
|
|
531
|
+
|
|
532
|
+ // Now look for a dcc that matches.
|
|
533
|
+ for (DCCTransfer send : DCCTransfer.getTransfers()) {
|
|
534
|
+ if (send.getPort() == port && (new File(send.getFileName()))
|
|
535
|
+ .getName().equalsIgnoreCase(filename)) {
|
|
536
|
+ if ((!token.isEmpty() && !send.getToken().isEmpty())
|
|
537
|
+ && (!token.equals(send.getToken()))) {
|
|
538
|
+ continue;
|
|
539
|
+ }
|
|
540
|
+ final Parser parser = ((Server) arguments[0]).getParser();
|
|
541
|
+ final String nick = ((ClientInfo) arguments[1]).getNickname();
|
|
542
|
+ if (ctcpData[0].equalsIgnoreCase("resume")) {
|
|
543
|
+ parser.sendCTCP(nick, "DCC", "ACCEPT "+ ((quoted) ? "\""
|
|
544
|
+ + filename + "\"" : filename) + " " + port + " "
|
|
545
|
+ + send.setFileStart(position) + token);
|
|
546
|
+ } else {
|
|
547
|
+ send.setFileStart(position);
|
|
548
|
+ if (port == 0) {
|
|
549
|
+ // Reverse dcc
|
|
550
|
+ if (listen(send)) {
|
|
551
|
+ if (send.getToken().isEmpty()) {
|
|
552
|
+ parser.sendCTCP(nick, "DCC", "SEND "
|
|
553
|
+ + ((quoted) ? "\"" + filename
|
|
554
|
+ + "\"" : filename) + " "
|
|
555
|
+ + DCC.ipToLong(send.getHost())
|
|
556
|
+ + " " + send.getPort()
|
|
557
|
+ + " " + send.getFileSize());
|
380
|
558
|
} else {
|
381
|
|
- filenameBits.append(" " + bit);
|
|
559
|
+ parser.sendCTCP(nick, "DCC", "SEND "
|
|
560
|
+ + ((quoted) ? "\"" + filename
|
|
561
|
+ + "\"" : filename)
|
|
562
|
+ + " " + DCC.ipToLong(send.getHost())
|
|
563
|
+ + " " + send.getPort()
|
|
564
|
+ + " " + send.getFileSize() + " "
|
|
565
|
+ + send.getToken());
|
382
|
566
|
}
|
383
|
567
|
}
|
384
|
|
- filename = filenameBits.toString().trim();
|
385
|
568
|
} else {
|
386
|
|
- filename = ctcpData[1];
|
387
|
|
- i = 1;
|
388
|
|
- }
|
389
|
|
-
|
390
|
|
- try {
|
391
|
|
- final int port = Integer.parseInt(ctcpData[++i]);
|
392
|
|
- final int position = Integer.parseInt(ctcpData[++i]);
|
393
|
|
- final String token = (ctcpData.length - 1 > i) ? " " + ctcpData[++i] : "";
|
394
|
|
-
|
395
|
|
- // Now look for a dcc that matches.
|
396
|
|
- for (DCCTransfer send : DCCTransfer.getTransfers()) {
|
397
|
|
- if (send.getPort() == port && (new File(send.getFileName())).getName().equalsIgnoreCase(filename)) {
|
398
|
|
- if ((!token.isEmpty() && !send.getToken().isEmpty()) && (!token.equals(send.getToken()))) {
|
399
|
|
- continue;
|
400
|
|
- }
|
401
|
|
- final Parser parser = ((Server) arguments[0]).getParser();
|
402
|
|
- final String nickname = ((ClientInfo) arguments[1]).getNickname();
|
403
|
|
- if (ctcpData[0].equalsIgnoreCase("resume")) {
|
404
|
|
- parser.sendCTCP(nickname, "DCC", "ACCEPT " + ((quoted) ? "\"" + filename + "\"" : filename) + " " + port + " " + send.setFileStart(position) + token);
|
405
|
|
- } else {
|
406
|
|
- send.setFileStart(position);
|
407
|
|
- if (port == 0) {
|
408
|
|
- // Reverse dcc
|
409
|
|
- if (listen(send)) {
|
410
|
|
- if (send.getToken().isEmpty()) {
|
411
|
|
- parser.sendCTCP(nickname, "DCC", "SEND " + ((quoted) ? "\"" + filename + "\"" : filename) + " " + DCC.ipToLong(send.getHost()) + " " + send.getPort() + " " + send.getFileSize());
|
412
|
|
- } else {
|
413
|
|
- parser.sendCTCP(nickname, "DCC", "SEND " + ((quoted) ? "\"" + filename + "\"" : filename) + " " + DCC.ipToLong(send.getHost()) + " " + send.getPort() + " " + send.getFileSize() + " " + send.getToken());
|
414
|
|
- }
|
415
|
|
- } else {
|
416
|
|
- // Listen failed.
|
417
|
|
- }
|
418
|
|
- } else {
|
419
|
|
- send.connect();
|
420
|
|
- }
|
421
|
|
- }
|
422
|
|
- }
|
423
|
|
- }
|
424
|
|
- } catch (NumberFormatException nfe) {
|
|
569
|
+ send.connect();
|
425
|
570
|
}
|
426
|
571
|
}
|
427
|
572
|
}
|
428
|
573
|
}
|
429
|
574
|
}
|
430
|
575
|
|
|
576
|
+
|
|
577
|
+
|
431
|
578
|
/**
|
432
|
579
|
* Retrieves the container for the placeholder.
|
433
|
580
|
*
|
|
@@ -465,7 +612,8 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
465
|
612
|
final Identity defaults = IdentityManager.getAddonIdentity();
|
466
|
613
|
|
467
|
614
|
defaults.setOption(getDomain(), "receive.savelocation",
|
468
|
|
- Main.getConfigDir() + "downloads" + System.getProperty("file.separator"));
|
|
615
|
+ Main.getConfigDir() + "downloads"
|
|
616
|
+ + System.getProperty("file.separator"));
|
469
|
617
|
}
|
470
|
618
|
|
471
|
619
|
/**
|
|
@@ -473,17 +621,20 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
473
|
621
|
*/
|
474
|
622
|
@Override
|
475
|
623
|
public void onLoad() {
|
476
|
|
- final File dir = new File(IdentityManager.getGlobalConfig().getOption(getDomain(), "receive.savelocation"));
|
|
624
|
+ final File dir = new File(IdentityManager.getGlobalConfig()
|
|
625
|
+ .getOption(getDomain(), "receive.savelocation"));
|
477
|
626
|
if (dir.exists()) {
|
478
|
627
|
if (!dir.isDirectory()) {
|
479
|
|
- Logger.userError(ErrorLevel.LOW, "Unable to create download dir (file exists instead)");
|
|
628
|
+ Logger.userError(ErrorLevel.LOW,
|
|
629
|
+ "Unable to create download dir (file exists instead)");
|
480
|
630
|
}
|
481
|
631
|
} else {
|
482
|
632
|
try {
|
483
|
633
|
dir.mkdirs();
|
484
|
634
|
dir.createNewFile();
|
485
|
635
|
} catch (IOException ex) {
|
486
|
|
- Logger.userError(ErrorLevel.LOW, "Unable to create download dir");
|
|
636
|
+ Logger.userError(ErrorLevel.LOW,
|
|
637
|
+ "Unable to create download dir");
|
487
|
638
|
}
|
488
|
639
|
}
|
489
|
640
|
|
|
@@ -522,12 +673,13 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
522
|
673
|
* @return The IP Address we should send as our listening IP.
|
523
|
674
|
*/
|
524
|
675
|
public String getListenIP(final Parser parser) {
|
525
|
|
- final String configIP = IdentityManager.getGlobalConfig().getOption(getDomain(), "firewall.ip");
|
|
676
|
+ final String configIP = IdentityManager.getGlobalConfig().getOption(
|
|
677
|
+ getDomain(), "firewall.ip");
|
526
|
678
|
if (!configIP.isEmpty()) {
|
527
|
679
|
try {
|
528
|
680
|
return InetAddress.getByName(configIP).getHostAddress();
|
529
|
|
- } catch (UnknownHostException ex) {
|
530
|
|
- //Fallthrough
|
|
681
|
+ } catch (UnknownHostException ex) { //NOPMD - handled below
|
|
682
|
+ //Continue below
|
531
|
683
|
}
|
532
|
684
|
}
|
533
|
685
|
if (parser != null) {
|
|
@@ -535,7 +687,9 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
535
|
687
|
if (!myHost.isEmpty()) {
|
536
|
688
|
try {
|
537
|
689
|
return InetAddress.getByName(myHost).getHostAddress();
|
538
|
|
- } catch (UnknownHostException e) { /* Will return default host below */ }
|
|
690
|
+ } catch (UnknownHostException e) { //NOPMD - handled below
|
|
691
|
+ //Continue below
|
|
692
|
+ }
|
539
|
693
|
}
|
540
|
694
|
}
|
541
|
695
|
try {
|
|
@@ -543,17 +697,21 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
543
|
697
|
} catch (UnknownHostException e) {
|
544
|
698
|
// This is almost certainly not what we want, but we can't work out
|
545
|
699
|
// the right one.
|
546
|
|
- return "127.0.0.1";
|
|
700
|
+ return "127.0.0.1"; //NOPMD
|
547
|
701
|
}
|
548
|
702
|
}
|
549
|
703
|
|
550
|
704
|
/** {@inheritDoc} */
|
551
|
705
|
@Override
|
552
|
706
|
public void showConfig(final PreferencesDialogModel manager) {
|
553
|
|
- final PreferencesCategory general = new PluginPreferencesCategory(getPluginInfo(), "DCC", "", "category-dcc");
|
554
|
|
- final PreferencesCategory firewall = new PluginPreferencesCategory(getPluginInfo(), "Firewall", "");
|
555
|
|
- final PreferencesCategory sending = new PluginPreferencesCategory(getPluginInfo(), "Sending", "");
|
556
|
|
- final PreferencesCategory receiving = new PluginPreferencesCategory(getPluginInfo(), "Receiving", "");
|
|
707
|
+ final PreferencesCategory general = new PluginPreferencesCategory(
|
|
708
|
+ getPluginInfo(), "DCC", "", "category-dcc");
|
|
709
|
+ final PreferencesCategory firewall = new PluginPreferencesCategory(
|
|
710
|
+ getPluginInfo(), "Firewall", "");
|
|
711
|
+ final PreferencesCategory sending = new PluginPreferencesCategory(
|
|
712
|
+ getPluginInfo(), "Sending", "");
|
|
713
|
+ final PreferencesCategory receiving = new PluginPreferencesCategory(
|
|
714
|
+ getPluginInfo(), "Receiving", "");
|
557
|
715
|
|
558
|
716
|
manager.getCategory("Plugins").addSubCategory(general.setInlineAfter());
|
559
|
717
|
general.addSubCategory(firewall.setInline());
|
|
@@ -565,7 +723,8 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
565
|
723
|
"What IP should be sent as our IP (Blank = work it out)"));
|
566
|
724
|
firewall.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
567
|
725
|
getDomain(), "firewall.ports.usePortRange", "Use Port Range",
|
568
|
|
- "Useful if you have a firewall that only forwards specific ports"));
|
|
726
|
+ "Useful if you have a firewall that only forwards specific "
|
|
727
|
+ + "ports"));
|
569
|
728
|
firewall.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
|
570
|
729
|
getDomain(), "firewall.ports.startPort", "Start Port",
|
571
|
730
|
"Port to try to listen on first"));
|
|
@@ -577,25 +736,26 @@ public final class DCCPlugin extends Plugin implements ActionListener {
|
577
|
736
|
"Where the save as window defaults to?"));
|
578
|
737
|
sending.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
579
|
738
|
getDomain(), "send.reverse", "Reverse DCC",
|
580
|
|
- "With reverse DCC, the sender connects rather than " +
|
581
|
|
- "listens like normal dcc"));
|
|
739
|
+ "With reverse DCC, the sender connects rather than "
|
|
740
|
+ + "listens like normal dcc"));
|
582
|
741
|
sending.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
583
|
742
|
getDomain(), "send.forceturbo", "Use Turbo DCC",
|
584
|
|
- "Turbo DCC doesn't wait for ack packets. this is " +
|
585
|
|
- "faster but not always supported."));
|
|
743
|
+ "Turbo DCC doesn't wait for ack packets. this is "
|
|
744
|
+ + "faster but not always supported."));
|
586
|
745
|
receiving.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
587
|
746
|
getDomain(), "receive.reverse.sendtoken",
|
588
|
747
|
"Send token in reverse receive",
|
589
|
|
- "If you have problems with reverse dcc receive resume," +
|
590
|
|
- " try toggling this."));
|
|
748
|
+ "If you have problems with reverse dcc receive resume,"
|
|
749
|
+ + " try toggling this."));
|
591
|
750
|
general.addSetting(new PreferencesSetting(PreferencesType.INTEGER,
|
592
|
751
|
getDomain(), "send.blocksize", "Blocksize to use for DCC",
|
593
|
|
- "Change the block size for send/receive, this can " +
|
594
|
|
- "sometimes speed up transfers."));
|
|
752
|
+ "Change the block size for send/receive, this can "
|
|
753
|
+ + "sometimes speed up transfers."));
|
595
|
754
|
general.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
|
596
|
755
|
getDomain(), "general.percentageInTitle",
|
597
|
756
|
"Show percentage of transfers in the window title",
|
598
|
|
- "Show the current percentage of transfers in the DCC window title"));
|
|
757
|
+ "Show the current percentage of transfers in the DCC window "
|
|
758
|
+ + "title"));
|
599
|
759
|
}
|
600
|
760
|
|
601
|
|
-}
|
|
761
|
+}
|