[libvirt-java] [PATCH 59/65] Implement Domain.screenshot

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

 



This wraps the native virDomainScreenshot libvirt function available
since version 0.9.2.

Signed-off-by: Claudio Bley <cbley@xxxxxxxxxx>
---
 src/main/java/org/libvirt/Domain.java      |   10 ++++++++++
 src/main/java/org/libvirt/Stream.java      |    4 ++++
 src/main/java/org/libvirt/jna/Libvirt.java |    1 +
 3 files changed, 15 insertions(+)

diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java
index 1c0af91..a9113cf 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -1285,6 +1285,16 @@ public class Domain {
         processError(libvirt.virDomainSave(VDP, to));
     }
 
+    public String screenshot(Stream stream, int screen) throws LibvirtException {
+        Pointer ptr = processError(libvirt.virDomainScreenshot(this.VDP, stream.getVSP(), screen, 0));
+        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 71a2a6e..97bebdd 100644
--- a/src/main/java/org/libvirt/Stream.java
+++ b/src/main/java/org/libvirt/Stream.java
@@ -175,6 +175,10 @@ public class Stream implements ByteChannel {
         return success;
     }
 
+    StreamPointer getVSP() {
+        return VSP;
+    }
+
     /**
      * Receives data from the stream into the buffer provided.
      *
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index c383ba6..80dacdb 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -305,6 +305,7 @@ public interface Libvirt extends Library {
     int virDomainResume(DomainPointer virDomainPtr);
     int virDomainSave(DomainPointer virDomainPtr, String to);
     int virDomainSendKey(DomainPointer virDomainPtr, int codeset, int holdtime, int[] keycodes, int nkeycodes, int flags);
+    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.7.9.5

--
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]