[libvirt-java] [PATCH 2/3] Domain: add screenshot method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This wraps the native virDomainScreenshot function.
---
 src/main/java/org/libvirt/Domain.java      | 11 +++++++++++
 src/main/java/org/libvirt/Stream.java      |  4 ++++
 src/main/java/org/libvirt/jna/Libvirt.java |  1 +
 3 files changed, 16 insertions(+)

diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java
index 2f70bf2..a57f7ca 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -1074,6 +1074,17 @@ public class Domain {
         processError();
     }
 
+    public String screenshot(Stream stream, int screen) throws LibvirtException {
+        Pointer ptr = org.libvirt.jna.LibvirtDirect.virDomainScreenshot(this.VDP, stream.getVSP(), screen, 0);
+        if (ptr == null) processError();
+        stream.markReadable();
+        try {
+            return Library.getString(ptr);
+        } finally {
+            Library.free(ptr);
+        }
+    }
+
     /**
      * Configures the network to be automatically started when the host machine
      * boots.
diff --git a/src/main/java/org/libvirt/Stream.java b/src/main/java/org/libvirt/Stream.java
index 975e1b6..aacaba1 100644
--- a/src/main/java/org/libvirt/Stream.java
+++ b/src/main/java/org/libvirt/Stream.java
@@ -180,6 +180,10 @@ public class Stream implements ByteChannel {
         return success;
     }
 
+    StreamPointer getVSP() {
+        return VSP;
+    }
+
     /**
      * Error handling logic to throw errors. Must be called after every libvirt
      * call.
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index fe74087..c161b27 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -236,6 +236,7 @@ public interface Libvirt extends Library {
     int virDomainRevertToSnapshot(DomainSnapshotPointer virDomainSnapshotPtr, int flags);
     int virDomainResume(DomainPointer virDomainPtr);
     int virDomainSave(DomainPointer virDomainPtr, String to);
+    Pointer virDomainScreenshot(DomainPointer virDomainPtr, StreamPointer virStreamPtr, int screen, int flags);
     int virDomainSetAutostart(DomainPointer virDomainPtr, int autoStart);
     int virDomainSetMaxMemory(DomainPointer virDomainPtr, NativeLong maxMemory);
     int virDomainSetMemory(DomainPointer virDomainPtr, NativeLong maxMemory);
-- 
1.8.5.2.msysgit.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]