[dbus PATCH v2 2/3] events: Register VIR_DOMAIN_EVENT_ID_GRAPHICS

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

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
Return empty string when variable is NULL

 data/org.libvirt.Domain.xml |  9 +++++++
 src/events.c                | 60 +++++++++++++++++++++++++++++++++++++++++++++
 src/util.h                  |  2 ++
 3 files changed, 71 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index f5e49b0..824ab82 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -648,6 +648,15 @@
       <arg name="device" type="s"/>
       <arg name="reason" type="u"/>
     </signal>
+    <signal name="Graphics">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventGraphicsCallback"/>
+      <arg name="phase" type="i"/>
+      <arg name="local" type="(iss)"/>
+      <arg name="remote" type="(iss)"/>
+      <arg name="authScheme" type="s"/>
+      <arg name="identities" type="a(ss)"/>
+    </signal>
     <signal name="JobCompleted">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventJobCompletedCallback"/>
diff --git a/src/events.c b/src/events.c
index 21d6d07..f206d8a 100644
--- a/src/events.c
+++ b/src/events.c
@@ -184,6 +184,62 @@ virtDBusEventsDomainDeviceRemoved(virConnectPtr connection G_GNUC_UNUSED,
     return 0;
 }
 
+static gint
+virtDBusEventsDomainGraphics(virConnectPtr connection G_GNUC_UNUSED,
+                             virDomainPtr domain,
+                             gint phase,
+                             const virDomainEventGraphicsAddress *local,
+                             const virDomainEventGraphicsAddress *remote,
+                             const gchar *authScheme,
+                             const virDomainEventGraphicsSubject *subject,
+                             gpointer opaque)
+{
+    virtDBusConnect *connect = opaque;
+    g_autofree gchar *path = NULL;
+    GVariantBuilder builder;
+    GVariant *gret;
+
+    path = virtDBusUtilBusPathForVirDomain(domain, connect->domainPath);
+
+    g_variant_builder_init(&builder, G_VARIANT_TYPE("(i(iss)(iss)sa(ss))"));
+
+    g_variant_builder_add(&builder, "i", phase);
+
+    g_variant_builder_open(&builder, G_VARIANT_TYPE("(iss)"));
+    g_variant_builder_add(&builder, "i", local->family);
+    g_variant_builder_add(&builder, "s", VIRT_DBUS_EMPTY_STR(local->node));
+    g_variant_builder_add(&builder, "s", VIRT_DBUS_EMPTY_STR(local->service));
+    g_variant_builder_close(&builder);
+
+    g_variant_builder_open(&builder, G_VARIANT_TYPE("(iss)"));
+    g_variant_builder_add(&builder, "i", remote->family);
+    g_variant_builder_add(&builder, "s", VIRT_DBUS_EMPTY_STR(remote->node));
+    g_variant_builder_add(&builder, "s", VIRT_DBUS_EMPTY_STR(remote->service));
+    g_variant_builder_close(&builder);
+
+    g_variant_builder_add(&builder, "s", authScheme);
+
+    g_variant_builder_open(&builder, G_VARIANT_TYPE("a(ss)"));
+    for (gint i = 0; i < subject->nidentity; i++) {
+        g_variant_builder_open(&builder, G_VARIANT_TYPE("(ss)"));
+        g_variant_builder_add(&builder, "s", subject->identities[i].type);
+        g_variant_builder_add(&builder, "s", subject->identities[i].name);
+        g_variant_builder_close(&builder);
+    }
+    g_variant_builder_close(&builder);
+    gret = g_variant_builder_end(&builder);
+
+    g_dbus_connection_emit_signal(connect->bus,
+                                  NULL,
+                                  path,
+                                  VIRT_DBUS_DOMAIN_INTERFACE,
+                                  "Graphics",
+                                  gret,
+                                  NULL);
+
+    return 0;
+}
+
 static gint
 virtDBusEventsDomainJobCompleted(virConnectPtr connection G_GNUC_UNUSED,
                                  virDomainPtr domain,
@@ -652,6 +708,10 @@ virtDBusEventsRegister(virtDBusConnect *connect)
                                       VIR_DOMAIN_EVENT_ID_DISK_CHANGE,
                                       VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainDiskChange));
 
+    virtDBusEventsRegisterDomainEvent(connect,
+                                      VIR_DOMAIN_EVENT_ID_GRAPHICS,
+                                      VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainGraphics));
+
     virtDBusEventsRegisterDomainEvent(connect,
                                       VIR_DOMAIN_EVENT_ID_JOB_COMPLETED,
                                       VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainJobCompleted));
diff --git a/src/util.h b/src/util.h
index 2f37933..729d933 100644
--- a/src/util.h
+++ b/src/util.h
@@ -4,6 +4,8 @@
 
 #include <libvirt/libvirt.h>
 
+#define VIRT_DBUS_EMPTY_STR(s) ((s) ? (s) : "")
+
 #define VIRT_DBUS_ERROR virtDBusErrorQuark()
 
 #define virtDBusUtilAutoLock g_autoptr(GMutexLocker) G_GNUC_UNUSED
-- 
2.15.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]

  Powered by Linux