cscg24-guacamole

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

clipboard.c (2017B)


      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#include "config.h"
     21#include "clipboard.h"
     22#include "telnet.h"
     23#include "terminal/terminal.h"
     24
     25#include <guacamole/client.h>
     26#include <guacamole/stream.h>
     27#include <guacamole/user.h>
     28
     29int guac_telnet_clipboard_handler(guac_user* user, guac_stream* stream,
     30        char* mimetype) {
     31
     32    /* Clear clipboard and prepare for new data */
     33    guac_client* client = user->client;
     34    guac_telnet_client* telnet_client = (guac_telnet_client*) client->data;
     35    guac_terminal_clipboard_reset(telnet_client->term, mimetype);
     36
     37    /* Set handlers for clipboard stream */
     38    stream->blob_handler = guac_telnet_clipboard_blob_handler;
     39    stream->end_handler = guac_telnet_clipboard_end_handler;
     40
     41    return 0;
     42}
     43
     44int guac_telnet_clipboard_blob_handler(guac_user* user, guac_stream* stream,
     45        void* data, int length) {
     46
     47    /* Append new data */
     48    guac_client* client = user->client;
     49    guac_telnet_client* telnet_client = (guac_telnet_client*) client->data;
     50    guac_terminal_clipboard_append(telnet_client->term, data, length);
     51
     52    return 0;
     53}
     54
     55int guac_telnet_clipboard_end_handler(guac_user* user, guac_stream* stream) {
     56
     57    /* Nothing to do - clipboard is implemented within client */
     58
     59    return 0;
     60}
     61