cscg24-guacamole

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

vnc.h (4046B)


      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_VNC_VNC_H
     21#define GUAC_VNC_VNC_H
     22
     23#include "config.h"
     24
     25#include "common/clipboard.h"
     26#include "common/display.h"
     27#include "common/iconv.h"
     28#include "common/surface.h"
     29#include "settings.h"
     30
     31#include <guacamole/client.h>
     32#include <guacamole/layer.h>
     33#include <rfb/rfbclient.h>
     34
     35#ifdef ENABLE_PULSE
     36#include "pulse/pulse.h"
     37#endif
     38
     39#ifdef ENABLE_COMMON_SSH
     40#include "common-ssh/sftp.h"
     41#include "common-ssh/ssh.h"
     42#include "common-ssh/user.h"
     43#endif
     44
     45#include <guacamole/recording.h>
     46
     47#include <pthread.h>
     48
     49/**
     50 * VNC-specific client data.
     51 */
     52typedef struct guac_vnc_client {
     53
     54    /**
     55     * The VNC client thread.
     56     */
     57    pthread_t client_thread;
     58
     59#ifdef ENABLE_VNC_TLS_LOCKING
     60    /**
     61     * The TLS mutex lock for the client.
     62     */
     63    pthread_mutex_t tls_lock;
     64#endif
     65
     66    /**
     67     * The underlying VNC client.
     68     */
     69    rfbClient* rfb_client;
     70
     71    /**
     72     * The original framebuffer malloc procedure provided by the initialized
     73     * rfbClient.
     74     */
     75    MallocFrameBufferProc rfb_MallocFrameBuffer;
     76
     77    /**
     78     * Whether copyrect  was used to produce the latest update received
     79     * by the VNC server.
     80     */
     81    int copy_rect_used;
     82
     83    /**
     84     * Client settings, parsed from args.
     85     */
     86    guac_vnc_settings* settings;
     87
     88    /**
     89     * The current display state.
     90     */
     91    guac_common_display* display;
     92
     93    /**
     94     * Internal clipboard.
     95     */
     96    guac_common_clipboard* clipboard;
     97
     98#ifdef ENABLE_PULSE
     99    /**
    100     * PulseAudio output, if any.
    101     */
    102    guac_pa_stream* audio;
    103#endif
    104
    105#ifdef ENABLE_COMMON_SSH
    106    /**
    107     * The user and credentials used to authenticate for SFTP.
    108     */
    109    guac_common_ssh_user* sftp_user;
    110
    111    /**
    112     * The SSH session used for SFTP.
    113     */
    114    guac_common_ssh_session* sftp_session;
    115
    116    /**
    117     * An SFTP-based filesystem.
    118     */
    119    guac_common_ssh_sftp_filesystem* sftp_filesystem;
    120#endif
    121
    122    /**
    123     * The in-progress session recording, or NULL if no recording is in
    124     * progress.
    125     */
    126    guac_recording* recording;
    127
    128    /**
    129     * Clipboard encoding-specific reader.
    130     */
    131    guac_iconv_read* clipboard_reader;
    132
    133    /**
    134     * Clipboard encoding-specific writer.
    135     */
    136    guac_iconv_write* clipboard_writer;
    137
    138} guac_vnc_client;
    139
    140/**
    141 * Allocates a new rfbClient instance given the parameters stored within the
    142 * client, returning NULL on failure.
    143 *
    144 * @param client
    145 *     The guac_client associated with the settings of the desired VNC
    146 *     connection.
    147 *
    148 * @return
    149 *     A new rfbClient instance allocated and connected according to the
    150 *     parameters stored within the given client, or NULL if connecting to the
    151 *     VNC server fails.
    152 */
    153rfbClient* guac_vnc_get_client(guac_client* client);
    154
    155/**
    156 * VNC client thread. This thread initiates the VNC connection and ultimately
    157 * runs throughout the duration of the client, existing as a single instance,
    158 * shared by all users.
    159 *
    160 * @param data
    161 *     The guac_client instance associated with the requested VNC connection.
    162 *
    163 * @return
    164 *     Always NULL.
    165 */
    166void* guac_vnc_client_thread(void* data);
    167
    168/**
    169 * Key which can be used with the rfbClientGetClientData function to return
    170 * the associated guac_client.
    171 */
    172extern char* GUAC_VNC_CLIENT_KEY;
    173
    174#endif
    175