2014-04-09 18:40:09 +00:00
|
|
|
/*
|
2016-03-25 19:59:40 +00:00
|
|
|
* 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
|
2014-04-09 18:40:09 +00:00
|
|
|
*
|
2016-03-25 19:59:40 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-04-09 18:40:09 +00:00
|
|
|
*
|
2016-03-25 19:59:40 +00:00
|
|
|
* 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.
|
2014-04-09 18:40:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "clipboard.h"
|
2016-03-01 05:51:42 +00:00
|
|
|
#include "ssh.h"
|
2014-06-11 17:06:18 +00:00
|
|
|
#include "terminal.h"
|
|
|
|
|
|
|
|
#include <guacamole/client.h>
|
|
|
|
#include <guacamole/stream.h>
|
2016-03-01 05:51:42 +00:00
|
|
|
#include <guacamole/user.h>
|
2014-04-09 18:40:09 +00:00
|
|
|
|
2016-03-01 05:51:42 +00:00
|
|
|
int guac_ssh_clipboard_handler(guac_user* user, guac_stream* stream,
|
2014-04-09 18:40:09 +00:00
|
|
|
char* mimetype) {
|
|
|
|
|
|
|
|
/* Clear clipboard and prepare for new data */
|
2016-03-01 05:51:42 +00:00
|
|
|
guac_client* client = user->client;
|
|
|
|
guac_ssh_client* ssh_client = (guac_ssh_client*) client->data;
|
|
|
|
guac_terminal_clipboard_reset(ssh_client->term, mimetype);
|
2014-04-09 18:40:09 +00:00
|
|
|
|
2014-04-10 20:47:36 +00:00
|
|
|
/* Set handlers for clipboard stream */
|
|
|
|
stream->blob_handler = guac_ssh_clipboard_blob_handler;
|
|
|
|
stream->end_handler = guac_ssh_clipboard_end_handler;
|
|
|
|
|
2014-04-09 18:40:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-01 05:51:42 +00:00
|
|
|
int guac_ssh_clipboard_blob_handler(guac_user* user, guac_stream* stream,
|
2014-04-09 18:40:09 +00:00
|
|
|
void* data, int length) {
|
|
|
|
|
|
|
|
/* Append new data */
|
2016-03-01 05:51:42 +00:00
|
|
|
guac_client* client = user->client;
|
|
|
|
guac_ssh_client* ssh_client = (guac_ssh_client*) client->data;
|
|
|
|
guac_terminal_clipboard_append(ssh_client->term, data, length);
|
2014-04-09 18:40:09 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-01 05:51:42 +00:00
|
|
|
int guac_ssh_clipboard_end_handler(guac_user* user, guac_stream* stream) {
|
2014-04-09 18:40:09 +00:00
|
|
|
|
|
|
|
/* Nothing to do - clipboard is implemented within client */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|