Преглед на файлове

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
                 return;
136
                 return;
137
             }
137
             }
138
             final String type = args.getArguments()[0];
138
             final String type = args.getArguments()[0];
139
-            if (type.equalsIgnoreCase("chat")) {
139
+            if ("chat".equalsIgnoreCase(type)) {
140
                 startChat(parser, connection, origin, myNickname, target, true);
140
                 startChat(parser, connection, origin, myNickname, target, true);
141
-            } else if (type.equalsIgnoreCase("send")) {
141
+            } else if ("send".equalsIgnoreCase(type)) {
142
                 sendFile(target, origin, connection, true,
142
                 sendFile(target, origin, connection, true,
143
                         args.getArgumentsAsString(2));
143
                         args.getArgumentsAsString(2));
144
             } else {
144
             } else {

+ 8
- 17
dcc/src/com/dmdirc/addons/dcc/io/DCCTransfer.java Целия файл

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

Loading…
Отказ
Запис