Re: [dbus PATCH 02/25] Implement SendKey method for Domain Interface

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

 



On Tue, Apr 17, 2018 at 02:04:21PM +0200, Katerina Koukiou wrote:
> 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);

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@xxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature

--
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