GUAC-1172: Implement filesystem, body, and undefine instructions.

This commit is contained in:
Michael Jumper 2015-06-19 14:35:30 -07:00
parent f7e6deeaf4
commit 6e3a12b604
2 changed files with 127 additions and 0 deletions

View File

@ -32,6 +32,7 @@
*/ */
#include "layer-types.h" #include "layer-types.h"
#include "object-types.h"
#include "protocol-types.h" #include "protocol-types.h"
#include "socket-types.h" #include "socket-types.h"
#include "stream-types.h" #include "stream-types.h"
@ -217,6 +218,75 @@ int guac_protocol_send_select(guac_socket* socket, const char* protocol);
*/ */
int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp); int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp);
/* OBJECT INSTRUCTIONS */
/**
* Sends a body instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket
* The guac_socket connection to use.
*
* @param object
* The object to associated with the stream being used.
*
* @param stream
* The stream to use.
*
* @param mimetype
* The mimetype of the data being sent.
*
* @param name
* The name of the stream whose body is being sent, as requested by a "get"
* instruction.
*
* @return
* Zero on success, non-zero on error.
*/
int guac_protocol_send_body(guac_socket* socket, const guac_object* object,
const guac_stream* stream, const char* mimetype, const char* name);
/**
* Sends a filesystem instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket
* The guac_socket connection to use.
*
* @param object
* The object representing the filesystem being exposed.
*
* @param name
* A name describing the filesystem being exposed.
*
* @return
* Zero on success, non-zero on error.
*/
int guac_protocol_send_filesystem(guac_socket* socket,
const guac_object* object, const char* name);
/**
* Sends an undefine instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket
* The guac_socket connection to use.
*
* @param object
* The object being undefined.
*
* @return
* Zero on success, non-zero on error.
*/
int guac_protocol_send_undefine(guac_socket* socket,
const guac_object* object);
/* MEDIA INSTRUCTIONS */ /* MEDIA INSTRUCTIONS */
/** /**

View File

@ -24,6 +24,7 @@
#include "error.h" #include "error.h"
#include "layer.h" #include "layer.h"
#include "object.h"
#include "palette.h" #include "palette.h"
#include "protocol.h" #include "protocol.h"
#include "socket.h" #include "socket.h"
@ -463,6 +464,28 @@ int guac_protocol_send_blob(guac_socket* socket, const guac_stream* stream,
} }
int guac_protocol_send_body(guac_socket* socket, const guac_object* object,
const guac_stream* stream, const char* mimetype, const char* name) {
int ret_val;
guac_socket_instruction_begin(socket);
ret_val =
guac_socket_write_string(socket, "4.body,")
|| __guac_socket_write_length_int(socket, object->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, stream->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_string(socket, mimetype)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_string(socket, name)
|| guac_socket_write_string(socket, ";");
guac_socket_instruction_end(socket);
return ret_val;
}
int guac_protocol_send_cfill(guac_socket* socket, int guac_protocol_send_cfill(guac_socket* socket,
guac_composite_mode mode, const guac_layer* layer, guac_composite_mode mode, const guac_layer* layer,
int r, int g, int b, int a) { int r, int g, int b, int a) {
@ -833,6 +856,24 @@ int guac_protocol_send_file(guac_socket* socket, const guac_stream* stream,
} }
int guac_protocol_send_filesystem(guac_socket* socket,
const guac_object* object, const char* name) {
int ret_val;
guac_socket_instruction_begin(socket);
ret_val =
guac_socket_write_string(socket, "10.filesystem,")
|| __guac_socket_write_length_int(socket, object->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_string(socket, name)
|| guac_socket_write_string(socket, ";");
guac_socket_instruction_end(socket);
return ret_val;
}
int guac_protocol_send_identity(guac_socket* socket, const guac_layer* layer) { int guac_protocol_send_identity(guac_socket* socket, const guac_layer* layer) {
int ret_val; int ret_val;
@ -1284,6 +1325,22 @@ int guac_protocol_send_transform(guac_socket* socket, const guac_layer* layer,
} }
int guac_protocol_send_undefine(guac_socket* socket,
const guac_object* object) {
int ret_val;
guac_socket_instruction_begin(socket);
ret_val =
guac_socket_write_string(socket, "8.undefine,")
|| __guac_socket_write_length_int(socket, object->index)
|| guac_socket_write_string(socket, ";");
guac_socket_instruction_end(socket);
return ret_val;
}
int guac_protocol_send_video(guac_socket* socket, const guac_stream* stream, int guac_protocol_send_video(guac_socket* socket, const guac_stream* stream,
const guac_layer* layer, const char* mimetype, double duration) { const guac_layer* layer, const char* mimetype, double duration) {