Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Domain.xml | 9 +++++++ src/events.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index db5da09..a9a6f5c 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -630,6 +630,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="TrayChange"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventTrayChangeCallback"/> diff --git a/src/events.c b/src/events.c index b47a4a1..f927b26 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", local->node); + g_variant_builder_add(&builder, "s", 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", remote->node); + g_variant_builder_add(&builder, "s", 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, "ss", subject->identities[i].type); + g_variant_builder_add(&builder, "ss", 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 virtDBusEventsDomainTrayChange(virConnectPtr connection G_GNUC_UNUSED, virDomainPtr domain, @@ -428,6 +484,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_TRAY_CHANGE, VIR_DOMAIN_EVENT_CALLBACK(virtDBusEventsDomainTrayChange)); -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list