On Tue, Apr 17, 2018 at 02:04:21PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
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&quo...
+ <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#virDomainSetMemoryFl...
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);
This can be simplified into:
+ g_variant_get(inArgs, "(uu@auu)", &codeset, &holdtime, &v,
&flags);
+
+ keycodes = g_variant_get_fixed_array(v, &nkeycodes, sizeof(guint));
+ g_variant_unref(v);
+
+ domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+ if (!domain)
+ return;
+
+ ret = virDomainSendKey(domain, codeset, holdtime, (guint *)keycodes, nkeycodes,
flags);
Long line, it should not be longer than 80 chars.
Reviewed-by: Pavel Hrdina <phrdina(a)redhat.com>