Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Domain.xml | 8 ++++++++ src/domain.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index 74b0a62..0b23e75 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -178,6 +178,14 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainResume"/> </method> + <method name="SendKey"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSendKey"/> + <arg name="codeset" type="u" direction="in"/> + <arg name="holdtime" type="u" direction="in"/> + <arg name="keycodes" type="au" direction="in"/> + <arg name="flags" type="u" direction="in"/> + </method> <method name="SetMemory"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSetMemoryFlags"/> diff --git a/src/domain.c b/src/domain.c index 5ec7686..0c8e1ce 100644 --- a/src/domain.c +++ b/src/domain.c @@ -1002,6 +1002,51 @@ virtDBusDomainResume(GVariant *inArgs G_GNUC_UNUSED, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusDomainSendKey(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) + +{ + virtDBusConnect *connect = userData; + g_autoptr(virDomain) domain = NULL; + guint codeset; + guint holdtime; + const guint *keycodes; + gsize nkeycodes = 0; + gint ret; + guint flags; + GVariant *v; + + v = g_variant_get_child_value(inArgs, 0); + codeset = g_variant_get_uint32(v); + g_variant_unref(v); + + v = g_variant_get_child_value(inArgs, 1); + holdtime = g_variant_get_uint32(v); + g_variant_unref(v); + + v = g_variant_get_child_value(inArgs, 2); + keycodes = g_variant_get_fixed_array(v, &nkeycodes, sizeof(guint)); + g_variant_unref(v); + + v = g_variant_get_child_value(inArgs, 3); + flags = g_variant_get_uint32(v); + g_variant_unref(v); + + domain = virtDBusDomainGetVirDomain(connect, objectPath, error); + if (!domain) + return; + + ret = virDomainSendKey(domain, codeset, holdtime, (guint *)keycodes, nkeycodes, flags); + if (ret < 0) + virtDBusUtilSetLastVirtError(error); +} + static void virtDBusDomainSetMemory(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1157,6 +1202,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = { { "Reboot", virtDBusDomainReboot }, { "Reset", virtDBusDomainReset }, { "Resume", virtDBusDomainResume }, + { "SendKey", virtDBusDomainSendKey }, { "SetVcpus", virtDBusDomainSetVcpus }, { "SetMemory", virtDBusDomainSetMemory }, { "Shutdown", virtDBusDomainShutdown }, -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list