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