瀏覽代碼

Minor DCC tidying.

pull/219/head
Chris Smith 9 年之前
父節點
當前提交
dd01bebc83
共有 2 個檔案被更改,包括 10 行新增19 行删除
  1. 2
    2
      dcc/src/com/dmdirc/addons/dcc/DCCCommand.java
  2. 8
    17
      dcc/src/com/dmdirc/addons/dcc/io/DCCTransfer.java

+ 2
- 2
dcc/src/com/dmdirc/addons/dcc/DCCCommand.java 查看文件

@@ -136,9 +136,9 @@ public class DCCCommand extends Command implements IntelligentCommand {
136 136
                 return;
137 137
             }
138 138
             final String type = args.getArguments()[0];
139
-            if (type.equalsIgnoreCase("chat")) {
139
+            if ("chat".equalsIgnoreCase(type)) {
140 140
                 startChat(parser, connection, origin, myNickname, target, true);
141
-            } else if (type.equalsIgnoreCase("send")) {
141
+            } else if ("send".equalsIgnoreCase(type)) {
142 142
                 sendFile(target, origin, connection, true,
143 143
                         args.getArgumentsAsString(2));
144 144
             } else {

+ 8
- 17
dcc/src/com/dmdirc/addons/dcc/io/DCCTransfer.java 查看文件

@@ -24,6 +24,7 @@ package com.dmdirc.addons.dcc.io;
24 24
 
25 25
 import com.dmdirc.addons.dcc.DCCTransferHandler;
26 26
 import com.dmdirc.util.collections.ListenerList;
27
+import com.dmdirc.util.io.StreamUtils;
27 28
 
28 29
 import java.io.DataInputStream;
29 30
 import java.io.DataOutputStream;
@@ -298,7 +299,7 @@ public class DCCTransfer extends DCC {
298 299
      * @return starting position of file.
299 300
      */
300 301
     public int getFileStart() {
301
-        return this.startpos;
302
+        return startpos;
302 303
     }
303 304
 
304 305
     /**
@@ -317,7 +318,7 @@ public class DCCTransfer extends DCC {
317 318
             transferFile = new File(filename);
318 319
             if (transferType == TransferType.RECEIVE) {
319 320
                 fileOut = new DataOutputStream(new FileOutputStream(
320
-                        transferFile.getAbsolutePath(), (startpos > 0)));
321
+                        transferFile.getAbsolutePath(), startpos > 0));
321 322
             }
322 323
             out = new DataOutputStream(socket.getOutputStream());
323 324
             in = new DataInputStream(socket.getInputStream());
@@ -333,18 +334,8 @@ public class DCCTransfer extends DCC {
333 334
     @Override
334 335
     protected void socketClosed() {
335 336
         // Try to close both, even if one fails.
336
-        if (out != null) {
337
-            try {
338
-                out.close();
339
-            } catch (IOException e) {
340
-            }
341
-        }
342
-        if (in != null) {
343
-            try {
344
-                in.close();
345
-            } catch (IOException e) {
346
-            }
347
-        }
337
+        StreamUtils.close(out);
338
+        StreamUtils.close(in);
348 339
         out = null;
349 340
         in = null;
350 341
 
@@ -384,7 +375,7 @@ public class DCCTransfer extends DCC {
384 375
         try {
385 376
             final byte[] data = new byte[blockSize];
386 377
             final int bytesRead = in.read(data);
387
-            readSize = readSize + bytesRead;
378
+            readSize += bytesRead;
388 379
 
389 380
             if (bytesRead > 0) {
390 381
                 for (DCCTransferHandler handler : handlers.get(DCCTransferHandler.class)) {
@@ -443,7 +434,7 @@ public class DCCTransfer extends DCC {
443 434
                     int bytesReceived;
444 435
                     do {
445 436
                         bytesReceived = in.readInt();
446
-                    } while ((readSize - bytesReceived) > 0);
437
+                    } while (readSize - bytesReceived > 0);
447 438
                 }
448 439
 
449 440
                 if (readSize == size) {
@@ -462,7 +453,7 @@ public class DCCTransfer extends DCC {
462 453
                             } catch (IOException e) {
463 454
                                 break;
464 455
                             }
465
-                        } while (ack > 0 && (readSize - ack) > 0);
456
+                        } while (ack > 0 && readSize - ack > 0);
466 457
                     }
467 458
 
468 459
                     return false;

Loading…
取消
儲存