aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-08-13 19:09:38 +0200
committerMattias Andrée <maandree@operamail.com>2014-08-13 19:09:38 +0200
commita0e72d1d8081e0a2a73691fd33a54f0f30510785 (patch)
tree9f09f4a4c4e48944aef928eb3f1693c2395eb59d
parentm (diff)
downloadmds-a0e72d1d8081e0a2a73691fd33a54f0f30510785.tar.gz
mds-a0e72d1d8081e0a2a73691fd33a54f0f30510785.tar.bz2
mds-a0e72d1d8081e0a2a73691fd33a54f0f30510785.tar.xz
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--doc/protocols5
-rw-r--r--src/mds-kkbd.c44
-rw-r--r--src/mds-kkbd.h19
3 files changed, 50 insertions, 18 deletions
diff --git a/doc/protocols b/doc/protocols
index 3b33a17..46dca32 100644
--- a/doc/protocols
+++ b/doc/protocols
@@ -618,6 +618,11 @@ Optional header: Keyboard
A string that identifies the keyboard that should be
affected. If omitted all keyboard are affected.
+Conditionally required header: Client ID
+ Required if: `Action: query`
+ Your ID, provided by `ID assignment`
+ in response to `Command: assign-id`
+
Conditionally optional header: Length
Available and optional if: `Action: remap`
The length of the message
diff --git a/src/mds-kkbd.c b/src/mds-kkbd.c
index 0d72093..094a4f9 100644
--- a/src/mds-kkbd.c
+++ b/src/mds-kkbd.c
@@ -538,7 +538,7 @@ int handle_message(void)
if (strequals(recv_command, "get-keyboard-leds"))
return handle_get_keyboard_leds(recv_client_id, recv_message_id, recv_keyboard);
if (strequals(recv_command, "keycode-map"))
- return handle_keycode_map(recv_action, recv_keyboard);
+ return handle_keycode_map(recv_client_id, recv_message_id, recv_action, recv_keyboard);
return 0; /* How did that get here, not matter, just ignore it? */
}
@@ -573,8 +573,8 @@ static int ensure_send_buffer_size(size_t size)
* Handle the received message after it has been
* identified to contain `Command: enumerate-keyboards`
*
- * @param recv_client_id The value of the `Client ID`-header, `NULL` if omitted
- * @param recv_message_id The value of the `Message ID`-header, `NULL` if omitted
+ * @param recv_client_id The value of the `Client ID`-header, "0:0" if omitted
+ * @param recv_message_id The value of the `Message ID`-header
* @param recv_modify_id The value of the `Modify ID`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
@@ -809,8 +809,8 @@ int handle_set_keyboard_leds(const char* recv_active, const char* recv_mask,
* Handle the received message after it has been
* identified to contain `Command: get-keyboard-leds`
*
- * @param recv_client_id The value of the `Client ID`-header, `NULL` if omitted
- * @param recv_message_id The value of the `Message ID`-header, `NULL` if omitted
+ * @param recv_client_id The value of the `Client ID`-header, "0:0" if omitted
+ * @param recv_message_id The value of the `Message ID`-header
* @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
@@ -997,14 +997,31 @@ static int remap(char* table, size_t n)
/**
+ * Responde to a keycode mapping query
+ *
+ * @param recv_client_id The value of the `Client ID`-header
+ * @param recv_message_id The value of the `Message ID`-header
+ * @return Zero on success, -1 on error
+ */
+static int mapping_query(const char* recv_client_id, const char* recv_message_id)
+{
+ /* FIXME */
+ return 0;
+}
+
+
+/**
* Handle the received message after it has been
* identified to contain `Command: keycode-map`
*
- * @param recv_action The value of the `Action`-header, `NULL` if omitted
- * @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
- * @return Zero on success, -1 on error
+ * @param recv_client_id The value of the `Client ID`-header, "0:0" if omitted
+ * @param recv_message_id The value of the `Message ID`-header
+ * @param recv_action The value of the `Action`-header, `NULL` if omitted
+ * @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
+ * @return Zero on success, -1 on error
*/
-int handle_keycode_map(const char* recv_action, const char* recv_keyboard)
+int handle_keycode_map(const char* recv_client_id, const char* recv_message_id,
+ const char* recv_action, const char* recv_keyboard)
{
int r = 0;
@@ -1032,8 +1049,15 @@ int handle_keycode_map(const char* recv_action, const char* recv_keyboard)
mapping_size = 0;
);
}
- else if (strequals(recv_action, "query")) /* FIXME */
+ else if (strequals(recv_action, "query"))
{
+ if (strequals(recv_client_id, "0:0"))
+ {
+ eprint("received information request from an anonymous client, ignoring.");
+ return 0;
+ }
+
+ r = mapping_query(recv_client_id, recv_message_id);
}
else
eprint("received keycode map request with invalid action, ignoring.");
diff --git a/src/mds-kkbd.h b/src/mds-kkbd.h
index 60e936a..237efdd 100644
--- a/src/mds-kkbd.h
+++ b/src/mds-kkbd.h
@@ -41,8 +41,8 @@ int handle_message(void);
* Handle the received message after it has been
* identified to contain `Command: enumerate-keyboards`
*
- * @param recv_client_id The value of the `Client ID`-header, `NULL` if omitted
- * @param recv_message_id The value of the `Message ID`-header, `NULL` if omitted
+ * @param recv_client_id The value of the `Client ID`-header, "0:0" if omitted
+ * @param recv_message_id The value of the `Message ID`-header
* @param recv_modify_id The value of the `Modify ID`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
@@ -74,8 +74,8 @@ int handle_set_keyboard_leds(const char* recv_active, const char* recv_mask,
* Handle the received message after it has been
* identified to contain `Command: get-keyboard-leds`
*
- * @param recv_client_id The value of the `Client ID`-header, `NULL` if omitted
- * @param recv_message_id The value of the `Message ID`-header, `NULL` if omitted
+ * @param recv_client_id The value of the `Client ID`-header, "0:0" if omitted
+ * @param recv_message_id The value of the `Message ID`-header
* @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
@@ -86,11 +86,14 @@ int handle_get_keyboard_leds(const char* recv_client_id, const char* recv_messag
* Handle the received message after it has been
* identified to contain `Command: keycode-map`
*
- * @param recv_action The value of the `Action`-header, `NULL` if omitted
- * @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
- * @return Zero on success, -1 on error
+ * @param recv_client_id The value of the `Client ID`-header, "0:0" if omitted
+ * @param recv_message_id The value of the `Message ID`-header
+ * @param recv_action The value of the `Action`-header, `NULL` if omitted
+ * @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
+ * @return Zero on success, -1 on error
*/
-int handle_keycode_map(const char* recv_action, const char* recv_keyboard);
+int handle_keycode_map(const char* recv_client_id, const char* recv_message_id,
+ const char* recv_action, const char* recv_keyboard);
/**
* Send a full message even if interrupted