Directly using VirtualBox from Java #5

Merged
NorbiPeti merged 60 commits from directvb into master 2019-04-18 23:29:21 +00:00
6 changed files with 21 additions and 20 deletions
Showing only changes of commit 5d6b705299 - Show all commits

View file

@ -40,11 +40,6 @@
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration> <configuration>
<artifactSet>
<includes>
<include>org.virtualbox:VirtualBox</include>
</includes>
</artifactSet>
<pluginExecution> <pluginExecution>
<action> <action>
<execute /> <execute />
@ -105,12 +100,6 @@
<version>1.12.2-R0.1-SNAPSHOT</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.4.0</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View file

@ -41,11 +41,6 @@
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration> <configuration>
<artifactSet>
<includes>
<include>org.virtualbox:VirtualBox</include>
</includes>
</artifactSet>
<pluginExecution> <pluginExecution>
<action> <action>
<execute /> <execute />
@ -91,6 +86,11 @@
<artifactId>jna</artifactId> <artifactId>jna</artifactId>
<version>4.4.0</version> <version>4.4.0</version>
</dependency> </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>
</dependencies> </dependencies>
</project> </project>

View file

@ -63,7 +63,8 @@ public class DirectRenderer implements IRenderer {
wmap.flagDirty(0, 0); wmap.flagDirty(0, 0);
wmap.flagDirty(128, 128); // Send the whole image - TODO: Only send changes wmap.flagDirty(128, 128); // Send the whole image - TODO: Only send changes
} catch (Exception e) { } catch (Exception e) {
if (ex != null && e.getMessage().equals(ex.getMessage())) if (ex != null && (e.getMessage() == ex.getMessage()
|| (e.getMessage() != null && e.getMessage().equals(ex.getMessage()))))
return; return;
(ex = e).printStackTrace(); (ex = e).printStackTrace();
} }

View file

@ -9,7 +9,7 @@ import org.virtualbox_5_2.*;
public class MCFrameBuffer implements IFramebuffer { public class MCFrameBuffer implements IFramebuffer {
private IDisplay display; private IDisplay display;
private Holder<IDisplaySourceBitmap> holder; private Holder<IDisplaySourceBitmap> holder = new Holder<>();
public MCFrameBuffer(IDisplay display) { public MCFrameBuffer(IDisplay display) {
this.display = display; this.display = display;

View file

@ -11,10 +11,14 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.mozilla.xpcom.Mozilla;
import org.mozilla.xpcom.internal.XPCOMImpl;
import org.virtualbox_5_2.*; import org.virtualbox_5_2.*;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import jnr.ffi.LibraryLoader;
public class PluginMain extends JavaPlugin { public class PluginMain extends JavaPlugin {
private IVirtualBox vbox; private IVirtualBox vbox;
private ISession session; private ISession session;
@ -49,6 +53,8 @@ public class PluginMain extends JavaPlugin {
System.setProperty("java.library.path", vbpath); System.setProperty("java.library.path", vbpath);
addLibraryPath(vbpath); addLibraryPath(vbpath);
final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath()); final VirtualBoxManager manager = VirtualBoxManager.createInstance(getDataFolder().getAbsolutePath());
VBoxLib vbl = LibraryLoader.create(VBoxLib.class).load(vbpath + "/libvboxjxpcom.so");
vbl.RTR3InitExe(0, "", 0);
vbox = manager.getVBox(); vbox = manager.getVBox();
session = manager.getSessionObject(); // TODO: Events session = manager.getSessionObject(); // TODO: Events
ccs.sendMessage("§bLoading Screen..."); ccs.sendMessage("§bLoading Screen...");
@ -104,7 +110,7 @@ public class PluginMain extends JavaPlugin {
sender.sendMessage("B: " + machine.getState().toString()); sender.sendMessage("B: " + machine.getState().toString());
final IConsole console = session.getConsole(); final IConsole console = session.getConsole();
sender.sendMessage("1: " + console.getState().toString()); sender.sendMessage("1: " + console.getState().toString());
console.powerUp(); console.powerUp(); // https://marc.info/?l=vbox-dev&m=142780789819967&w=2
sender.sendMessage("2: " + console.getState().toString()); sender.sendMessage("2: " + console.getState().toString());
console.getDisplay().attachFramebuffer(0L, console.getDisplay().attachFramebuffer(0L,
new IFramebuffer(new MCFrameBuffer(console.getDisplay()))); new IFramebuffer(new MCFrameBuffer(console.getDisplay())));

View file

@ -0,0 +1,5 @@
package sznp.virtualcomputer;
public interface VBoxLib {
void RTR3InitExe(int argc, String argv, int somethingzero);
}