cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

cliprdr.h (5445B)


      1/*
      2 * Licensed to the Apache Software Foundation (ASF) under one
      3 * or more contributor license agreements.  See the NOTICE file
      4 * distributed with this work for additional information
      5 * regarding copyright ownership.  The ASF licenses this file
      6 * to you under the Apache License, Version 2.0 (the
      7 * "License"); you may not use this file except in compliance
      8 * with the License.  You may obtain a copy of the License at
      9 *
     10 *   http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing,
     13 * software distributed under the License is distributed on an
     14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15 * KIND, either express or implied.  See the License for the
     16 * specific language governing permissions and limitations
     17 * under the License.
     18 */
     19
     20#ifndef GUAC_RDP_CHANNELS_CLIPRDR_H
     21#define GUAC_RDP_CHANNELS_CLIPRDR_H
     22
     23#include "common/clipboard.h"
     24
     25#include <freerdp/client/cliprdr.h>
     26#include <freerdp/freerdp.h>
     27#include <guacamole/client.h>
     28#include <guacamole/user.h>
     29#include <winpr/stream.h>
     30#include <winpr/wtypes.h>
     31
     32/**
     33 * RDP clipboard, leveraging the "CLIPRDR" channel.
     34 */
     35typedef struct guac_rdp_clipboard {
     36
     37    /**
     38     * The guac_client associated with the RDP connection. The broadcast
     39     * socket of this client will receive any clipboard data received from the
     40     * RDP server.
     41     */
     42    guac_client* client;
     43
     44    /**
     45     * CLIPRDR control interface.
     46     */
     47    CliprdrClientContext* cliprdr;
     48
     49    /**
     50     * The current clipboard contents.
     51     */
     52    guac_common_clipboard* clipboard;
     53
     54    /**
     55     * The format of the clipboard which was requested. Data received from
     56     * the RDP server should conform to this format. This will be one of
     57     * several legal clipboard format values defined within FreeRDP's WinPR
     58     * library, such as CF_TEXT.
     59     */
     60    UINT requested_format;
     61
     62} guac_rdp_clipboard;
     63
     64/**
     65 * Allocates a new guac_rdp_clipboard which has been initialized for processing
     66 * of Guacamole clipboard data. Support for the RDP side of the clipboard (the
     67 * CLIPRDR channel) must be loaded separately during FreeRDP's PreConnect event
     68 * using guac_rdp_clipboard_load_plugin().
     69 *
     70 * @param client
     71 *     The guac_client associated with the Guacamole side of the RDP
     72 *     connection.
     73 *
     74 * @return
     75 *     A newly-allocated instance of guac_rdp_clipboard which has been
     76 *     initialized for processing Guacamole clipboard data.
     77 */
     78guac_rdp_clipboard* guac_rdp_clipboard_alloc(guac_client* client);
     79
     80/**
     81 * Initializes clipboard support for RDP and handling of the CLIPRDR channel.
     82 * If failures occur, messages noting the specifics of those failures will be
     83 * logged, and the RDP side of clipboard support will not be functional.
     84 *
     85 * This MUST be called within the PreConnect callback of the freerdp instance
     86 * for CLIPRDR support to be loaded.
     87 *
     88 * @param clipboard
     89 *     The guac_rdp_clipboard instance which has been allocated for the current
     90 *     RDP connection.
     91 *
     92 * @param context
     93 *     The rdpContext associated with the FreeRDP side of the RDP connection.
     94 */
     95void guac_rdp_clipboard_load_plugin(guac_rdp_clipboard* clipboard,
     96        rdpContext* context);
     97
     98/**
     99 * Frees the resources associated with clipboard support for RDP and handling
    100 * of the CLIPRDR channel. Only resources specific to Guacamole are freed.
    101 * Resources specific to FreeRDP's handling of the CLIPRDR channel will be
    102 * freed by FreeRDP. If the provided guac_rdp_clipboard is NULL, this function
    103 * has no effect.
    104 *
    105 * @param clipboard
    106 *     The guac_rdp_clipboard instance which was been allocated for the current
    107 *     RDP connection.
    108 */
    109void guac_rdp_clipboard_free(guac_rdp_clipboard* clipboard);
    110
    111/**
    112 * Handler for inbound clipboard data, received via the stream created by an
    113 * inbound "clipboard" instruction. This handler will assign the
    114 * stream-specific handlers for processing "blob" and "end" instructions which
    115 * will eventually be received as clipboard data is sent. This specific handler
    116 * is expected to be assigned to the guac_user object of any user that may send
    117 * clipboard data. The guac_rdp_clipboard instance which will receive this data
    118 * MUST already be stored on the guac_rdp_client structure associated with the
    119 * current RDP connection.
    120 */
    121guac_user_clipboard_handler guac_rdp_clipboard_handler;
    122
    123/**
    124 * Handler for stream data related to clipboard, received via "blob"
    125 * instructions for a stream which has already been created with an inbound
    126 * "clipboard" instruction. This specific handler is assigned to the
    127 * guac_stream structure associated with that clipboard stream by
    128 * guac_rdp_clipboard_handler(). The guac_rdp_clipboard instance which will
    129 * receive this data MUST already be stored on the guac_rdp_client structure
    130 * associated with the current RDP connection.
    131 */
    132guac_user_blob_handler guac_rdp_clipboard_blob_handler;
    133
    134/**
    135 * Handler for end-of-stream related to clipboard, indicated via an "end"
    136 * instruction for a stream which has already been created with an inbound
    137 * "clipboard" instruction. This specific handler is assigned to the
    138 * guac_stream structure associated with that clipboard stream by
    139 * guac_rdp_clipboard_handler(). The guac_rdp_clipboard instance which will
    140 * receive this data MUST already be stored on the guac_rdp_client structure
    141 * associated with the current RDP connection.
    142 */
    143guac_user_end_handler guac_rdp_clipboard_end_handler;
    144
    145#endif
    146