Changeset 448
- Timestamp:
- 06/03/09 17:17:13 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LogicMail-1.1/LogicMail/src/org/logicprobe/LogicMail/util/Connection.java
r423 r448 70 70 import net.rim.device.api.ui.UiApplication; 71 71 import net.rim.device.api.ui.component.Dialog; 72 import net.rim.device.api.util.DataBuffer; 73 72 74 import org.logicprobe.LogicMail.AppInfo; 73 75 import org.logicprobe.LogicMail.conf.GlobalConfig; … … 113 115 */ 114 116 private byte[] buffer = new byte[128]; 115 117 118 /** 119 * Provides a dynamic buffer for building results 120 */ 121 DataBuffer resultBuffer = new DataBuffer(); 122 116 123 /** 117 124 * Holds the actual number of bytes in the buffer. … … 138 145 * Opens a connection. 139 146 */ 140 public void open() throws IOException {147 public synchronized void open() throws IOException { 141 148 if(input != null || output != null || socket != null) { 142 149 close(); … … 194 201 * Closes a connection. 195 202 */ 196 public void close() throws IOException {203 public synchronized void close() throws IOException { 197 204 try { 198 205 if(input != null) { … … 293 300 * @see #receive 294 301 */ 295 public void send(String s) throws IOException {302 public synchronized void send(String s) throws IOException { 296 303 byte[] bytes = s.getBytes(); 297 304 int length = bytes.length; … … 350 357 * is a prepared protocol command. 351 358 */ 352 public void sendCommand(String s) throws IOException {359 public synchronized void sendCommand(String s) throws IOException { 353 360 if(globalConfig.getConnDebug()) { 354 361 EventLogger.logEvent(AppInfo.GUID, ("[SEND CMD] " + s).getBytes(), EventLogger.DEBUG_INFO); … … 372 379 * @see #send 373 380 */ 374 public void sendRaw(String s) throws IOException {381 public synchronized void sendRaw(String s) throws IOException { 375 382 byte[] bytes = s.getBytes(); 376 383 … … 393 400 * @see #send 394 401 */ 395 public String receive() throws IOException {402 public synchronized String receive() throws IOException { 396 403 /** 397 404 * A note on how this method works and why it is designed the … … 421 428 * but there's not much one can about that. 422 429 */ 423 StringBuffer resultBuffer = new StringBuffer();424 430 boolean stop = false; 431 resultBuffer.reset(); 425 432 426 433 /** … … 470 477 */ 471 478 // Note: We really should look for CRLF, and not use this 472 // half-assed approach which screws up on mid-li me LFs. (DK)479 // half-assed approach which screws up on mid-line LFs. (DK) 473 480 else { 474 481 byte b = buffer[count]; … … 498 505 } 499 506 } 500 resultBuffer.append(new String(buffer, 0, count)); 501 } 507 resultBuffer.write(buffer, 0, count); 508 } 509 510 String result = new String(resultBuffer.toArray()); 502 511 503 512 if(globalConfig.getConnDebug()) { 504 EventLogger.logEvent(AppInfo.GUID, ("[RECV] " + result Buffer.toString()).getBytes(), EventLogger.DEBUG_INFO);505 } 506 507 return result Buffer.toString();513 EventLogger.logEvent(AppInfo.GUID, ("[RECV] " + result).getBytes(), EventLogger.DEBUG_INFO); 514 } 515 516 return result; 508 517 } 509 518 }
Note: See TracChangeset
for help on using the changeset viewer.
