Second pass
Build and Test j3270 / Build JAR & Run Tests (push) Successful in 5m57s

This commit is contained in:
2026-08-20 18:37:22 -04:00
parent a1b1273022
commit cc2ee5d2d9
9 changed files with 143 additions and 52 deletions
@@ -284,12 +284,14 @@ public class FTDft {
String msg = sb.toString().trim();
log.info("DFT message: " + msg);
if (msg.startsWith(END_TRANSFER)) {
String msgLower = msg.toLowerCase();
if (msg.startsWith(END_TRANSFER) || msgLower.contains("complete") || msgLower.contains("transferred") || msgLower.contains("success")) {
listener.onTransferComplete(null);
} else if (listener.getCurrentState() == FTState.ABORT_SENT) {
} else if (listener.getCurrentState() == FTState.ABORT_SENT || msgLower.contains("error") || msgLower.contains("failed") || msgLower.contains("abort")) {
listener.onTransferAborted(msg.isEmpty() ? "Transfer aborted" : msg);
} else {
listener.onTransferComplete(msg);
// Informational message (default success)
listener.onTransferComplete(null);
}
}
@@ -492,6 +494,11 @@ public class FTDft {
out.write(TR_CLOSE_REPLY & 0xFF);
input.sendStructuredFieldData(out.toByteArray());
if (!messageFlag) {
log.info("DFT: File transfer completed on close request (" + bytesTransferred + " bytes)");
listener.onTransferComplete(null);
}
}
// ========== Data Acknowledgement ==========
@@ -165,6 +165,41 @@ public class InputProcessor {
return;
}
if (fsm != null && fsm.getConnectionState() != null && fsm.getConnectionState().isSscp()) {
// SSCP-LU Mode (e.g. VM line mode / CP console before conmode 3270):
// Per RFC 2355: Send raw EBCDIC line data without AID or 3270 cursor address.
int cols = screen.getCols();
int curAddr = screen.getCursorAddress();
int row = curAddr / cols;
int rowStart = row * cols;
int rowEnd = rowStart + cols;
// Find last non-null, non-blank character in the current row
int lastChar = rowStart - 1;
for (int i = rowEnd - 1; i >= rowStart; i--) {
int ec = screen.getCell(i).ec & 0xFF;
if (ec != 0x00 && ec != 0x40) {
lastChar = i;
break;
}
}
ByteArrayOutputStream sscpData = new ByteArrayOutputStream();
for (int i = rowStart; i <= lastChar; i++) {
int ec = screen.getCell(i).ec & 0xFF;
sscpData.write(ec != 0x00 ? ec : 0x40);
}
fsm.sendSscpLuData(sscpData.toByteArray());
// Advance cursor to beginning of next row
int nextRowAddr = ((row + 1) % screen.getRows()) * cols;
screen.setCursorAddress(nextRowAddr);
screen.markAllChanged();
setKeyboardLocked(false);
return;
}
if (aidCode == AID_PA1 || aidCode == AID_PA2 || aidCode == AID_PA3) {
// PA keys: send AID + cursor address only (no modified data)
byte[] caddr = encodeAddress(screen.getCursorAddress(), screen.getRows(), screen.getCols());
@@ -220,10 +255,21 @@ public class InputProcessor {
}
}
} else {
// Unformatted screen: send all data
// Unformatted screen in 3270 mode:
// Send character data from address 0 up to last non-null character
int size = screen.getRows() * screen.getCols();
for (int i = 0; i < size; i++) {
out.write(screen.getCell(i).ec & 0xFF);
int lastNonNull = -1;
for (int i = size - 1; i >= 0; i--) {
if (screen.getCell(i).ec != 0) {
lastNonNull = i;
break;
}
}
if (lastNonNull >= 0) {
for (int i = 0; i <= lastNonNull; i++) {
int b = screen.getCell(i).ec & 0xFF;
out.write(b != 0 ? b : 0x40);
}
}
}
@@ -231,9 +277,9 @@ public class InputProcessor {
}
private void sendAidResponse(byte[] data) {
if (fsm.getConnectionState().isSscp()) {
if (fsm != null && fsm.getConnectionState() != null && fsm.getConnectionState().isSscp()) {
fsm.sendSscpLuData(data);
} else {
} else if (fsm != null) {
fsm.send3270Data(data);
}
}