summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/libvirt/domain/device/Graphics.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openslx/libvirt/domain/device/Graphics.java')
-rw-r--r--src/main/java/org/openslx/libvirt/domain/device/Graphics.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/libvirt/domain/device/Graphics.java b/src/main/java/org/openslx/libvirt/domain/device/Graphics.java
index d10eb3f..3fd2f81 100644
--- a/src/main/java/org/openslx/libvirt/domain/device/Graphics.java
+++ b/src/main/java/org/openslx/libvirt/domain/device/Graphics.java
@@ -1,5 +1,8 @@
package org.openslx.libvirt.domain.device;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
import org.openslx.libvirt.xml.LibvirtXmlNode;
/**
@@ -50,6 +53,66 @@ public class Graphics extends Device
}
/**
+ * Returns the listen address of the graphics device.
+ *
+ * @return listen address of the graphics device.
+ */
+ public InetAddress getListenAddress()
+ {
+ InetAddress parsedListenAddress = null;
+
+ if ( this.getListenType() == ListenType.ADDRESS ) {
+ // only read listen address, if address listen type is set
+ final String rawListenAddress = this.getXmlElementAttributeValue( "listen", "address" );
+
+ try {
+ parsedListenAddress = InetAddress.getByName( rawListenAddress );
+ } catch ( UnknownHostException e ) {
+ parsedListenAddress = null;
+ }
+ }
+
+ return parsedListenAddress;
+ }
+
+ /**
+ * Sets the listen address for the graphics device.
+ *
+ * @param listenAddress listen address for the graphics device.
+ */
+ public void setListenAddress( InetAddress listenAddress )
+ {
+ if ( this.getListenType() == ListenType.ADDRESS && listenAddress != null ) {
+ // only set listen address, if address listen type is set
+ this.setXmlElementAttributeValue( "listen", "address", listenAddress.getHostAddress() );
+ }
+ }
+
+ /**
+ * Returns the listen port of the graphics device.
+ *
+ * @return listen port of the graphics device.
+ */
+ public int getListenPort()
+ {
+ final String listenPort = this.getXmlElementAttributeValue( "port" );
+ return Integer.valueOf( listenPort );
+ }
+
+ /**
+ * Sets the listen port for the graphics device.
+ *
+ * @param listenPort listen port for the graphics device.
+ */
+ public void setListenPort( int listenPort )
+ {
+ if ( this.getListenType() == ListenType.ADDRESS ) {
+ // only set listen port, if address listen type is set
+ this.setXmlElementAttributeValue( "port", Integer.toString( listenPort ) );
+ }
+ }
+
+ /**
* Creates a non-existent graphics device as Libvirt XML device element.
*
* @param graphics graphics device that is created.