You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by mike-jumper <gi...@git.apache.org> on 2016/08/15 01:57:22 UTC

[GitHub] incubator-guacamole-server pull request #18: GUACAMOLE-51: Separate RDP keyb...

GitHub user mike-jumper opened a pull request:

    https://github.com/apache/incubator-guacamole-server/pull/18

    GUACAMOLE-51: Separate RDP keyboard handling into dedicated files / structures.

    Finishing the RDP portion of [GUACAMOLE-51](https://issues.apache.org/jira/browse/GUACAMOLE-51) is getting a bit hairy since the keymap structures are interwoven with the rest of the RDP client code. Really shouldn't have done it that way.
    
    This change moves the main keymap-driven keyboard translation code into its own files and structures, centered around the `guac_rdp_keyboard` abstraction.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mike-jumper/incubator-guacamole-server cleanup-rdp-keyboard

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-guacamole-server/pull/18.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #18
    
----
commit 78a696a86fc41139c219431485318ce0dbd8cbf2
Author: Michael Jumper <mj...@apache.org>
Date:   2016-08-14T00:33:30Z

    GUACAMOLE-51: Abstract away RDP keyboard state tracking with dedicated guac_rdp_keyboard structure.

commit 41bc0addbd6bcef7dbe5517dc3179ac9748b6087
Author: Michael Jumper <mj...@apache.org>
Date:   2016-08-14T20:17:34Z

    GUACAMOLE-51: Isolate sending of specific RDP events within own functions.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-guacamole-server pull request #18: GUACAMOLE-51: Separate RDP keyb...

Posted by jmuehlner <gi...@git.apache.org>.
Github user jmuehlner commented on a diff in the pull request:

    https://github.com/apache/incubator-guacamole-server/pull/18#discussion_r75054973
  
    --- Diff: src/protocols/rdp/keyboard.c ---
    @@ -0,0 +1,283 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +#include "config.h"
    +
    +#include "client.h"
    +#include "keyboard.h"
    +#include "rdp.h"
    +#include "rdp_keymap.h"
    +
    +#include <freerdp/freerdp.h>
    +#include <freerdp/input.h>
    +#include <guacamole/client.h>
    +
    +#include <pthread.h>
    +#include <stdlib.h>
    +
    +/**
    + * Immediately sends an RDP key event having the given scancode and flags.
    + *
    + * @param rdp_client
    + *     The RDP client instance associated with the RDP session along which the
    + *     key event should be sent.
    + *
    + * @param scancode
    + *     The scancode of the key to press or release via the RDP key event.
    + *
    + * @param flags
    + *     Any RDP-specific flags required for the provided scancode to have the
    + *     intended meaning, such as KBD_FLAGS_EXTENDED. The possible flags and
    + *     their meanings are dictated by RDP. KBD_FLAGS_DOWN and KBD_FLAGS_UP
    + *     need not be specified here - they will automatically be added depending
    + *     on the value specified for the pressed parameter.
    + *
    + * @param pressed
    + *     Non-zero if the key is being pressed, zero if the key is being released.
    + */
    +static void guac_rdp_send_key_event(guac_rdp_client* rdp_client,
    +        int scancode, int flags, int pressed) {
    +
    +    /* Determine proper event flag for pressed state */
    +    int pressed_flags;
    +    if (pressed)
    +        pressed_flags = KBD_FLAGS_DOWN;
    +    else
    +        pressed_flags = KBD_FLAGS_RELEASE;
    +
    +    pthread_mutex_lock(&(rdp_client->rdp_lock));
    +
    +    /* Skip if not yet connected */
    +    freerdp* rdp_inst = rdp_client->rdp_inst;
    +    if (rdp_inst == NULL) {
    +        pthread_mutex_unlock(&(rdp_client->rdp_lock));
    +        return;
    +    }
    +
    +    /* Send actual key */
    +    rdp_inst->input->KeyboardEvent(rdp_inst->input,
    +            flags | pressed_flags, scancode);
    +
    +    pthread_mutex_unlock(&(rdp_client->rdp_lock));
    +
    +}
    +
    +/**
    + * Immediately sends an RDP Unicode event having the given Unicode codepoint.
    + * Unlike key events, RDP Unicode events do not a pressed or released state.
    --- End diff --
    
    This sentence no verb.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-guacamole-server pull request #18: GUACAMOLE-51: Separate RDP keyb...

Posted by mike-jumper <gi...@git.apache.org>.
Github user mike-jumper commented on a diff in the pull request:

    https://github.com/apache/incubator-guacamole-server/pull/18#discussion_r75055525
  
    --- Diff: src/protocols/rdp/keyboard.c ---
    @@ -0,0 +1,283 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +#include "config.h"
    +
    +#include "client.h"
    +#include "keyboard.h"
    +#include "rdp.h"
    +#include "rdp_keymap.h"
    +
    +#include <freerdp/freerdp.h>
    +#include <freerdp/input.h>
    +#include <guacamole/client.h>
    +
    +#include <pthread.h>
    +#include <stdlib.h>
    +
    +/**
    + * Immediately sends an RDP key event having the given scancode and flags.
    + *
    + * @param rdp_client
    + *     The RDP client instance associated with the RDP session along which the
    + *     key event should be sent.
    + *
    + * @param scancode
    + *     The scancode of the key to press or release via the RDP key event.
    + *
    + * @param flags
    + *     Any RDP-specific flags required for the provided scancode to have the
    + *     intended meaning, such as KBD_FLAGS_EXTENDED. The possible flags and
    + *     their meanings are dictated by RDP. KBD_FLAGS_DOWN and KBD_FLAGS_UP
    + *     need not be specified here - they will automatically be added depending
    + *     on the value specified for the pressed parameter.
    + *
    + * @param pressed
    + *     Non-zero if the key is being pressed, zero if the key is being released.
    + */
    +static void guac_rdp_send_key_event(guac_rdp_client* rdp_client,
    +        int scancode, int flags, int pressed) {
    +
    +    /* Determine proper event flag for pressed state */
    +    int pressed_flags;
    +    if (pressed)
    +        pressed_flags = KBD_FLAGS_DOWN;
    +    else
    +        pressed_flags = KBD_FLAGS_RELEASE;
    +
    +    pthread_mutex_lock(&(rdp_client->rdp_lock));
    +
    +    /* Skip if not yet connected */
    +    freerdp* rdp_inst = rdp_client->rdp_inst;
    +    if (rdp_inst == NULL) {
    +        pthread_mutex_unlock(&(rdp_client->rdp_lock));
    +        return;
    +    }
    +
    +    /* Send actual key */
    +    rdp_inst->input->KeyboardEvent(rdp_inst->input,
    +            flags | pressed_flags, scancode);
    +
    +    pthread_mutex_unlock(&(rdp_client->rdp_lock));
    +
    +}
    +
    +/**
    + * Immediately sends an RDP Unicode event having the given Unicode codepoint.
    + * Unlike key events, RDP Unicode events do not a pressed or released state.
    --- End diff --
    
    It has a verb, but it actually two.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-guacamole-server pull request #18: GUACAMOLE-51: Separate RDP keyb...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-guacamole-server/pull/18


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---