Moving XPCOM stuff
This commit is contained in:
parent
515fb1f4d1
commit
9ba0c3e820
29 changed files with 317 additions and 212 deletions
|
@ -1,9 +1,13 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.github.NorbiPeti</groupId>
|
||||
<artifactId>VirtualComputer-Core</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>io.github.NorbiPeti</groupId>
|
||||
<artifactId>VirtualComputer</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -34,40 +38,11 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repo</id>
|
||||
<url>file://${basedir}/repo</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- <dependency> - Not using anything from here directly so we're not that dependent on versions
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency> -->
|
||||
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.jnr/jnr-ffi -->
|
||||
<dependency>
|
||||
<groupId>com.github.jnr</groupId>
|
||||
<artifactId>jnr-ffi</artifactId>
|
||||
<version>2.1.7</version>
|
||||
<dependency> <!-- This has the least additional (platform-dependent) code -->
|
||||
<groupId>org.virtualbox</groupId>
|
||||
<artifactId>VirtualBox-MSCOM</artifactId>
|
||||
<version>6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aparapi</groupId>
|
||||
|
@ -75,14 +50,14 @@
|
|||
<version>1.10.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.16.16</version>
|
||||
<groupId>io.github.NorbiPeti</groupId>
|
||||
<artifactId>VirtualComputer-XPCOM</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency> <!-- javax.annotations.Nullable -->
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<dependency>
|
||||
<groupId>sznp.virtualcomputer</groupId>
|
||||
<artifactId>VirtualComputer-MSCOM</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
|
@ -102,6 +77,7 @@
|
|||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>org.virtualbox:VirtualBox-MSCOM</exclude>
|
||||
<exclude>sznp.virtualcomputer.VirtualComputer-MSCOM</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
|
@ -127,6 +103,7 @@
|
|||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>org.virtualbox:VirtualBox</exclude>
|
||||
<exclude>sznp.virtualcomputer.VirtualComputer-XPCOM</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.virtualbox</groupId>
|
||||
<artifactId>VirtualBox</artifactId>
|
||||
<version>5.1</version>
|
||||
<description>POM was created from install:install-file</description>
|
||||
</project>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.virtualbox</groupId>
|
||||
<artifactId>VirtualBox</artifactId>
|
||||
<version>5.2</version>
|
||||
<description>POM was created from install:install-file</description>
|
||||
</project>
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.virtualbox</groupId>
|
||||
<artifactId>VirtualBox</artifactId>
|
||||
<versioning>
|
||||
<release>6.0</release>
|
||||
<versions>
|
||||
<version>5.1</version>
|
||||
<version>5.2</version>
|
||||
<version>6.0</version>
|
||||
</versions>
|
||||
<lastUpdated>20181221211412</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -9,7 +9,6 @@ import org.virtualbox_6_0.*;
|
|||
import sznp.virtualcomputer.events.MachineEventHandler;
|
||||
import sznp.virtualcomputer.events.VBoxEventHandler;
|
||||
import sznp.virtualcomputer.renderer.GPURenderer;
|
||||
import sznp.virtualcomputer.renderer.MCFrameBuffer;
|
||||
import sznp.virtualcomputer.util.Scancode;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -61,7 +60,7 @@ public final class Computer {
|
|||
//TODO: If we have VirtualBox open, it won't close the server's port
|
||||
//TODO: "The object in question already exists." on second start
|
||||
//machine.launchVMProcess(session, "headless", "").waitForCompletion(10000); //No privileges, start the 'old' way
|
||||
//session.getConsole().getDisplay().attachFramebuffer(0L, new IFramebuffer(new MCFrameBuffer(session.getConsole().getDisplay(), false)));
|
||||
//session.getConsole().getDisplay().attachFramebuffer(0L, new IFramebuffer(new COMFrameBuffer(session.getConsole().getDisplay(), false)));
|
||||
//sendMessage(sender, "§6Computer started with slower screen. Run as root to use a faster method.");
|
||||
} else {
|
||||
sendMessage(sender, "§cFailed to start computer: " + e.getMessage());
|
||||
|
@ -86,7 +85,7 @@ public final class Computer {
|
|||
handler.setProgress(progress);
|
||||
handler.registerTo(progress.getEventSource()); //TODO: Show progress bar some way?
|
||||
console.getDisplay().attachFramebuffer(0L,
|
||||
new IFramebuffer(new MCFrameBuffer(console.getDisplay(), true)));
|
||||
new IFramebuffer(new COMFrameBuffer(console.getDisplay(), true)));
|
||||
}
|
||||
|
||||
private void sendMessage(@Nullable CommandSender sender, String message) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import sznp.virtualcomputer.events.VBoxEventHandler;
|
|||
import sznp.virtualcomputer.renderer.BukkitRenderer;
|
||||
import sznp.virtualcomputer.renderer.GPURenderer;
|
||||
import sznp.virtualcomputer.renderer.IRenderer;
|
||||
import sznp.virtualcomputer.util.Utils;
|
||||
import sznp.virtualcomputer.util.COMUtils;
|
||||
import sznp.virtualcomputer.util.VBoxLib;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -67,7 +67,7 @@ public class PluginMain extends JavaPlugin {
|
|||
System.setProperty("sun.boot.library.path", vbpath);
|
||||
if (System.getProperty("java.library.path") == null || System.getProperty("java.library.path").isEmpty())
|
||||
System.setProperty("java.library.path", vbpath);
|
||||
Utils.addLibraryPath(vbpath);
|
||||
COMUtils.addLibraryPath(vbpath);
|
||||
final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath());
|
||||
VBoxLib vbl = LibraryLoader.create(VBoxLib.class).load("vboxjxpcom"); //TODO: Test for MSCOM
|
||||
vbl.RTR3InitExe(0, "", 0);
|
||||
|
|
|
@ -2,12 +2,11 @@ package sznp.virtualcomputer.events;
|
|||
|
||||
import lombok.val;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.mozilla.interfaces.IEvent;
|
||||
import org.mozilla.interfaces.IEventListener;
|
||||
import org.virtualbox_6_0.IEvent;
|
||||
import org.virtualbox_6_0.IEventSource;
|
||||
import org.virtualbox_6_0.VBoxEventType;
|
||||
import sznp.virtualcomputer.util.COMObjectBase;
|
||||
import sznp.virtualcomputer.util.Utils;
|
||||
import sznp.virtualcomputer.util.COMUtils;
|
||||
import sznp.virtualcomputer.util.IEventHandler;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -17,7 +16,7 @@ import java.util.Map;
|
|||
/**
|
||||
* A Bukkit-like event system which calls the appropriate methods on an event.
|
||||
*/
|
||||
public abstract class EventHandlerBase extends COMObjectBase implements IEventListener {
|
||||
public abstract class EventHandlerBase implements IEventHandler {
|
||||
/**
|
||||
* The events to listen for. It will only look for these handlers.
|
||||
*/
|
||||
|
@ -25,23 +24,21 @@ public abstract class EventHandlerBase extends COMObjectBase implements IEventLi
|
|||
private boolean enabled = true;
|
||||
|
||||
protected EventHandlerBase(Map<VBoxEventType, Class<? extends org.virtualbox_6_0.IEvent>> eventMap) {
|
||||
//this.eventMap = eventMap.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().value(), Map.Entry::getValue));
|
||||
this.eventMap = eventMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleEvent(IEvent iEvent) {
|
||||
//val cl=eventMap.get((int)iEvent.getType()); - We can afford to search through the events for this handler
|
||||
if (!enabled)
|
||||
return;
|
||||
val kv = eventMap.entrySet().stream().filter(e -> e.getKey().value() == iEvent.getType()).findAny();
|
||||
val kv = eventMap.entrySet().stream().filter(e -> e.getKey().value() == iEvent.getType().value()).findAny();
|
||||
if (!kv.isPresent()) return; //Event not supported
|
||||
val cl = kv.get().getValue();
|
||||
for (Method method : getClass().getMethods()) {
|
||||
if (method.isAnnotationPresent(org.bukkit.event.EventHandler.class)
|
||||
&& method.getParameterCount() == 1 && method.getParameterTypes()[0] == cl) {
|
||||
try {
|
||||
method.invoke(this, Utils.getEvent(iEvent, cl));
|
||||
method.invoke(this, COMUtils.getEvent(iEvent, cl));
|
||||
return;
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -54,7 +51,7 @@ public abstract class EventHandlerBase extends COMObjectBase implements IEventLi
|
|||
}
|
||||
|
||||
public <T extends EventHandlerBase> org.virtualbox_6_0.IEventListener registerTo(IEventSource source) {
|
||||
return Utils.registerListener(source, this, new ArrayList<>(eventMap.keySet()));
|
||||
return COMUtils.registerListener(source, this, new ArrayList<>(eventMap.keySet()));
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
|
|
|
@ -1,93 +1,21 @@
|
|||
package sznp.virtualcomputer.renderer;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.mozilla.interfaces.IFramebuffer;
|
||||
import org.mozilla.interfaces.IFramebufferOverlay;
|
||||
import org.mozilla.interfaces.nsISupports;
|
||||
import org.mozilla.xpcom.Mozilla;
|
||||
import org.virtualbox_6_0.*;
|
||||
import org.virtualbox_6_0.Holder;
|
||||
import org.virtualbox_6_0.IDisplay;
|
||||
import org.virtualbox_6_0.IDisplaySourceBitmap;
|
||||
import org.virtualbox_6_0.VBoxException;
|
||||
import sznp.virtualcomputer.PluginMain;
|
||||
import sznp.virtualcomputer.util.IMCFrameBuffer;
|
||||
import sznp.virtualcomputer.util.Timing;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MCFrameBuffer implements IFramebuffer {
|
||||
private IDisplay display;
|
||||
@RequiredArgsConstructor
|
||||
public class MCFrameBuffer implements IMCFrameBuffer {
|
||||
private final IDisplay display;
|
||||
private Holder<IDisplaySourceBitmap> holder = new Holder<>();
|
||||
|
||||
public MCFrameBuffer(IDisplay display, boolean VBoxDirect) { //TODO: Implement param
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public nsISupports queryInterface(String id) {
|
||||
return Mozilla.queryInterface(this, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBitsPerPixel() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytesPerLine() {
|
||||
return 640L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] getCapabilities(long[] arg0) {
|
||||
try {
|
||||
System.out.println("Capabilities queried");
|
||||
System.out.println("Capabilities: " + Arrays.toString(arg0));
|
||||
return new long[]{FramebufferCapabilities.UpdateImage.value()};
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return new long[]{};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHeight() {
|
||||
return 480;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHeightReduction() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFramebufferOverlay getOverlay() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPixelFormat() {
|
||||
return BitmapFormat.BGRA.value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVisibleRegion(byte arg0, long arg1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWidth() {
|
||||
return 640;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWinId() {
|
||||
return 0; // Zero means no win id
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notify3DEvent(long arg0, byte[] arg1) {
|
||||
}
|
||||
|
||||
private BukkitTask tt;
|
||||
private Pointer pointer;
|
||||
private int width;
|
||||
|
@ -135,20 +63,7 @@ public class MCFrameBuffer implements IFramebuffer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void notifyUpdateImage(long arg0, long arg1, long arg2, long arg3, byte[] arg4) {
|
||||
public void notifyUpdateImage(long x, long y, long width, long height, byte[] image) {
|
||||
System.out.println("Update image!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleRegion(byte arg0, long arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processVHWACommand(byte b, int i, boolean b1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean videoModeSupported(long arg0, long arg1, long arg2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
package sznp.virtualcomputer.util;
|
||||
|
||||
import lombok.val;
|
||||
import org.mozilla.interfaces.IEventListener;
|
||||
import org.virtualbox_6_0.IEvent;
|
||||
import org.virtualbox_6_0.IEventSource;
|
||||
import org.virtualbox_6_0.VBoxEventType;
|
||||
import org.virtualbox_6_0.xpcom.IUnknown;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Utils {
|
||||
/**
|
||||
|
@ -38,24 +29,4 @@ public class Utils {
|
|||
newPaths[newPaths.length - 1] = pathToAdd;
|
||||
usrPathsField.set(null, newPaths);
|
||||
}
|
||||
|
||||
//public static void registerListener(IEventSource source, IEventListener listener, VBoxEventType... types) {
|
||||
public static org.virtualbox_6_0.IEventListener registerListener(IEventSource source, IEventListener listener, List<VBoxEventType> types) {
|
||||
val ret = new org.virtualbox_6_0.IEventListener(listener);
|
||||
source.registerListener(ret, types, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends IEvent> T getEvent(org.mozilla.interfaces.IEvent event, Class<T> cl) {
|
||||
//if (event.getType() != type.value()) return null;
|
||||
//return (T) T.queryInterface(new IEvent(event)); - Probably won't work
|
||||
try {
|
||||
val method = cl.getMethod("queryInterface", IUnknown.class);
|
||||
return (T) method.invoke(null, new IEvent(event));
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<groupId>org.virtualbox</groupId>
|
||||
<artifactId>VirtualBox-MSCOM</artifactId>
|
||||
<version>6.0</version>
|
||||
<optional>true
|
||||
</optional> <!-- https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<groupId>org.virtualbox</groupId>
|
||||
<artifactId>VirtualBox</artifactId>
|
||||
<version>6.0</version>
|
||||
<optional>true
|
||||
</optional> <!-- https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package sznp.virtualcomputer;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.mozilla.interfaces.IFramebuffer;
|
||||
import org.mozilla.interfaces.IFramebufferOverlay;
|
||||
import org.mozilla.interfaces.nsISupports;
|
||||
import org.mozilla.xpcom.Mozilla;
|
||||
import org.virtualbox_6_0.BitmapFormat;
|
||||
import org.virtualbox_6_0.FramebufferCapabilities;
|
||||
import sznp.virtualcomputer.util.IMCFrameBuffer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class COMFrameBuffer implements IFramebuffer {
|
||||
private final IMCFrameBuffer frameBuffer;
|
||||
|
||||
@Override
|
||||
public nsISupports queryInterface(String id) {
|
||||
return Mozilla.queryInterface(this, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBitsPerPixel() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBytesPerLine() {
|
||||
return 640L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] getCapabilities(long[] arg0) {
|
||||
try {
|
||||
System.out.println("Capabilities queried");
|
||||
System.out.println("Capabilities: " + Arrays.toString(arg0));
|
||||
return new long[]{FramebufferCapabilities.UpdateImage.value()};
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new long[]{};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHeight() {
|
||||
return 480;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHeightReduction() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFramebufferOverlay getOverlay() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPixelFormat() {
|
||||
return BitmapFormat.BGRA.value();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVisibleRegion(byte arg0, long arg1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWidth() {
|
||||
return 640;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWinId() {
|
||||
return 0; // Zero means no win id
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notify3DEvent(long arg0, byte[] arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyChange(long screenId, long xOrigin, long yOrigin, long width, long height) {
|
||||
frameBuffer.notifyChange(screenId, xOrigin, yOrigin, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUpdate(long x, long y, long width, long height) {
|
||||
frameBuffer.notifyUpdate(x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUpdateImage(long arg0, long arg1, long arg2, long arg3, byte[] arg4) {
|
||||
frameBuffer.notifyUpdateImage(arg0, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleRegion(byte arg0, long arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processVHWACommand(byte b, int i, boolean b1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean videoModeSupported(long arg0, long arg1, long arg2) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package sznp.virtualcomputer;
|
||||
|
||||
import org.mozilla.interfaces.IEvent;
|
||||
import org.mozilla.interfaces.IEventListener;
|
||||
import sznp.virtualcomputer.util.COMObjectBase;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* A Bukkit-like event system which calls the appropriate methods on an event.
|
||||
*/
|
||||
public final class EventHandler extends COMObjectBase implements IEventListener {
|
||||
private final Consumer<org.virtualbox_6_0.IEvent> handler;
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
* New XPCOM event handler.
|
||||
*
|
||||
* @param handler The handle method that handles what needs to be handled
|
||||
*/
|
||||
public EventHandler(Consumer<org.virtualbox_6_0.IEvent> handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleEvent(IEvent iEvent) {
|
||||
if (!enabled)
|
||||
return;
|
||||
handler.accept(new org.virtualbox_6_0.IEvent(iEvent));
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package sznp.virtualcomputer.util;
|
||||
|
||||
import lombok.val;
|
||||
import org.virtualbox_6_0.IEvent;
|
||||
import org.virtualbox_6_0.IEventSource;
|
||||
import org.virtualbox_6_0.VBoxEventType;
|
||||
import org.virtualbox_6_0.xpcom.IUnknown;
|
||||
import sznp.virtualcomputer.EventHandler;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
public final class COMUtils {
|
||||
private COMUtils() {}
|
||||
|
||||
//public static void registerListener(IEventSource source, IEventListener listener, VBoxEventType... types) {
|
||||
public static org.virtualbox_6_0.IEventListener registerListener(IEventSource source, IEventHandler listener, List<VBoxEventType> types) {
|
||||
val ret = new org.virtualbox_6_0.IEventListener(new EventHandler(listener::handleEvent));
|
||||
source.registerListener(ret, types, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends IEvent> T getEvent(IEvent event, Class<T> cl) {
|
||||
try {
|
||||
val method = cl.getMethod("queryInterface", IUnknown.class);
|
||||
return (T) method.invoke(null, event);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package sznp.virtualcomputer.util;
|
||||
|
||||
import org.virtualbox_6_0.IEvent;
|
||||
|
||||
public interface IEventHandler {
|
||||
void handleEvent(IEvent iEvent);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package sznp.virtualcomputer.util;
|
||||
|
||||
public interface IMCFrameBuffer {
|
||||
void notifyUpdate(long x, long y, long width, long height);
|
||||
|
||||
void notifyUpdateImage(long x, long y, long width, long height, byte[] image);
|
||||
|
||||
void notifyChange(long screenId, long xOrigin, long yOrigin, long width, long height);
|
||||
}
|
45
pom.xml
45
pom.xml
|
@ -24,6 +24,17 @@
|
|||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo</id>
|
||||
<url>file://${basedir}/repo</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
@ -31,6 +42,40 @@
|
|||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.16.16</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna</artifactId>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.jnr/jnr-ffi -->
|
||||
<dependency>
|
||||
<groupId>com.github.jnr</groupId>
|
||||
<artifactId>jnr-ffi</artifactId>
|
||||
<version>2.1.7</version>
|
||||
</dependency>
|
||||
<dependency> <!-- javax.annotations.Nullable -->
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- <dependency> - Not using anything from here directly so we're not that dependent on versions
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency> -->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
10
repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1.pom
Normal file
10
repo/org/virtualbox/VirtualBox/5.1/VirtualBox-5.1.pom
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.virtualbox</groupId>
|
||||
<artifactId>VirtualBox</artifactId>
|
||||
<version>5.1</version>
|
||||
<description>POM was created from install:install-file</description>
|
||||
</project>
|
10
repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.pom
Executable file
10
repo/org/virtualbox/VirtualBox/5.2/VirtualBox-5.2.pom
Executable file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.virtualbox</groupId>
|
||||
<artifactId>VirtualBox</artifactId>
|
||||
<version>5.2</version>
|
||||
<description>POM was created from install:install-file</description>
|
||||
</project>
|
14
repo/org/virtualbox/VirtualBox/maven-metadata-local.xml
Normal file
14
repo/org/virtualbox/VirtualBox/maven-metadata-local.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>org.virtualbox</groupId>
|
||||
<artifactId>VirtualBox</artifactId>
|
||||
<versioning>
|
||||
<release>6.0</release>
|
||||
<versions>
|
||||
<version>5.1</version>
|
||||
<version>5.2</version>
|
||||
<version>6.0</version>
|
||||
</versions>
|
||||
<lastUpdated>20181221211412</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
Loading…
Reference in a new issue