diff mbox

[RFC,v2,2/6] vnc: add a new QMP command for changing keyboard layout

Message ID 1417589746-12176-3-git-send-email-arei.gonglei@huawei.com
State New
Headers show

Commit Message

Gonglei (Arei) Dec. 3, 2014, 6:55 a.m. UTC
From: Gonglei <arei.gonglei@huawei.com>

Example QMP command of Change VNC keyboard layout:
-> { "execute": "change-vnc-kbd-layout",
                "arguments": { "keymap": "de" } }
<- { "return": {}

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 qapi-schema.json | 17 +++++++++++++++++
 qmp-commands.hx  | 23 +++++++++++++++++++++++
 qmp.c            | 13 +++++++++++++
 3 files changed, 53 insertions(+)
diff mbox

Patch

diff --git a/qapi-schema.json b/qapi-schema.json
index 9ffdcf8..0d89b63 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1543,6 +1543,23 @@ 
 { 'command': 'change-vnc-password', 'data': {'password': 'str'} }
 
 ##
+# @change-vnc-kbd-layout:
+#
+# Change the VNC server keyboard layout.
+#
+# @keymap:  the new VNC keyboard layout to set.
+#
+# Returns: Nothing on success
+#          If VNC is not active, DeviceNotFound.
+#
+# Since: 2.3
+#
+# Notes:  Nothing will be changed on failure.
+#
+##
+{ 'command': 'change-vnc-kbd-layout', 'data': {'keymap': 'str'} }
+
+##
 # @change:
 #
 # This command is multiple commands multiplexed together.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 718dd92..54fe230 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3854,3 +3854,26 @@  Move mouse pointer to absolute coordinates (20000, 400).
 <- { "return": {} }
 
 EQMP
+
+    {
+        .name       = "change-vnc-kbd-layout",
+        .args_type  = "keymap:s",
+        .mhandler.cmd_new = qmp_marshal_input_change_vnc_kbd_layout,
+    },
+
+SQMP
+change-vnc-kbd-layout
+---------------------
+
+Change VNC keyboard layout.
+
+Arguments:
+
+- "keymap": the new VNC keyboard layout to set.
+
+Example:
+
+-> { "execute": "change-vnc-kbd-layout", "arguments": { "keymap": "de" } }
+<- { "return": {} }
+
+EQMP
diff --git a/qmp.c b/qmp.c
index 3fda973..812ded7 100644
--- a/qmp.c
+++ b/qmp.c
@@ -366,6 +366,13 @@  void qmp_change_vnc_password(const char *password, Error **errp)
     }
 }
 
+void qmp_change_vnc_kbd_layout(const char *keymap, Error **errp)
+{
+    if (vnc_display_kbd_layout(NULL, keymap) < 0) {
+        error_setg(errp, "keyboard layout '%s' set failed", keymap);
+    }
+}
+
 static void qmp_change_vnc_listen(const char *target, Error **errp)
 {
     QemuOptsList *olist = qemu_find_opts("vnc");
@@ -402,6 +409,12 @@  void qmp_change_vnc_password(const char *password, Error **errp)
 {
     error_set(errp, QERR_FEATURE_DISABLED, "vnc");
 }
+
+void qmp_change_vnc_kbd_layout(const char *keymap, Error **errp)
+{
+    error_set(errp, QERR_FEATURE_DISABLED, "vnc");
+}
+
 static void qmp_change_vnc(const char *target, bool has_arg, const char *arg,
                            Error **errp)
 {