/* * @(#)ReadImage.java * * This file is part of webCDwriter - Network CD/DVD Writing. * * Copyright (C) 2006 Jörg P. M. Haeger * * webCDwriter is free software. See CDcreator.java for details. */ /** * This class sets the options of a readImage command * on the server. * * @version 20060420 * @author Jörg P. M. Haeger */ public class ReadImage extends Burn { private long length = 0; private String volumeID = "image.iso"; protected void execBurnCommand() { execCommand("readImage"); } protected void execOptions() { if (Options.acceptKey.length() > 0) execCommand("setAcceptKey " + spaceToEsc(Options.acceptKey)); if (CDcreator.writeProtection) execCommand("setRejectEmptyCD"); if (Options.writer.length() > 0) execCommand("setWriter " + spaceToEsc(Options.writer)); } public long getLength() { return length; } public String getVolumeID() { return volumeID; } protected void handleWindowEvent(java.awt.event.WindowEvent e) { if (mode == DONE) closeDialog(); else cancelCommand(); } protected void process(int code, String text) { String prefix = ""; if (writer >= 0) prefix = "W" + writer + " "; switch (code) { case 901: writeHint(prefix + "setAcceptMedium"); break; case 905: String userID = "unknown"; int p0 = text.indexOf("\""); if (p0 >= 0) { int p1 = text.indexOf("\"", p0 + 1); if (p1 > p0) userID = text.substring(p0 + 1, p1); } writeHint(prefix + "setAcceptKey2 " + userID); break; default: super.process(code, text); } } void processHint(String str) { Integer value = parse(str, "size/KB", 1); if (value != null) length = 1024L * value.intValue(); else if (str.startsWith("volumeID")) volumeID = str.substring(9).trim() + ".iso"; else if (str.equals(hintCDdetected)) { mode = MEDIUM_DETECTED; toLog("Medium detected"); setProgress(0, 100); } else if (str.equals("readcd started")) { toLog(""); toLog("readcd started ==>"); show(burnDialog, i18n("titleRead")); setMessage(i18n("reading")); setProgress(0, 100); burnDialog.addButton(cancelButton); } else { Version.debug("readImage", str); super.processHint(str); } } void showResult() { if (cancel || table != null) { execSemaphore.setDone(); return; } if (!burnSessionResultOK) super.showResult(); execSemaphore.setDone(); } }