Implement file/blob/end subprotocol.
This commit is contained in:
parent
06ef43bd2c
commit
9e88ae4f60
@ -74,5 +74,5 @@ libguac_la_SOURCES = \
|
|||||||
unicode.c
|
unicode.c
|
||||||
|
|
||||||
lib_LTLIBRARIES = libguac.la
|
lib_LTLIBRARIES = libguac.la
|
||||||
libguac_la_LDFLAGS = -version-info 4:0:0 @PTHREAD_LIBS@
|
libguac_la_LDFLAGS = -version-info 5:0:0 @PTHREAD_LIBS@
|
||||||
|
|
||||||
|
@ -356,59 +356,30 @@ int guac_protocol_send_audio_end(guac_socket* socket);
|
|||||||
* returned, and guac_error is set appropriately.
|
* returned, and guac_error is set appropriately.
|
||||||
*
|
*
|
||||||
* @param socket The guac_socket connection to use.
|
* @param socket The guac_socket connection to use.
|
||||||
|
* @param index The index of the blob that will contain the contents
|
||||||
|
* of this file.
|
||||||
* @param name A name describing the file being sent.
|
* @param name A name describing the file being sent.
|
||||||
* @param mimetype The mimetype of the data being sent.
|
* @param mimetype The mimetype of the data being sent.
|
||||||
* @param data The file data to be sent.
|
|
||||||
* @param size The number of bytes of file data to send.
|
|
||||||
* @return Zero on success, non-zero on error.
|
* @return Zero on success, non-zero on error.
|
||||||
*/
|
*/
|
||||||
int guac_protocol_send_file(guac_socket* socket, const char* name,
|
int guac_protocol_send_file(guac_socket* socket, int index,
|
||||||
const char* mimetype, void* data, int size);
|
const char* name, const char* mimetype);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins a file instruction over the given guac_socket connection. Only the
|
* Writes a block of data to the currently in-progress blob which was already
|
||||||
* initial non-data part of the instruction and the length of the data part
|
* created.
|
||||||
* of the instruction are sent. The actual contents of the data must be
|
|
||||||
* sent with guac_protocol_send_file_data(), and the instruction must be
|
|
||||||
* completed with guac_protocol_send_file_end().
|
|
||||||
*
|
|
||||||
* Note that the size of the file to be sent MUST be known ahead of time,
|
|
||||||
* even though the data of the file may be sent in chunks.
|
|
||||||
*
|
|
||||||
* No further instruction data may be sent along the givven guac_socket
|
|
||||||
* except via guac_protocol_send_file_data() until the file instruction
|
|
||||||
* is completed with guac_protocol_send_file_end().
|
|
||||||
*
|
|
||||||
* 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 name A name describing the file being sent.
|
|
||||||
* @param mimetype The mimetype of the data being sent.
|
|
||||||
* @param size The number of bytes of file data to send.
|
|
||||||
* @return Zero on success, non-zero on error.
|
|
||||||
*/
|
|
||||||
int guac_protocol_send_file_header(guac_socket* socket, const char* name,
|
|
||||||
const char* mimetype, int size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a block of file data to the currently in-progress file instruction
|
|
||||||
* which was started with guac_protocol_send_file_header(). Exactly the
|
|
||||||
* number of requested bytes are written unless an error occurs. This function
|
|
||||||
* may be called multiple times per file instruction for each chunk of file
|
|
||||||
* data being written, allowing the potentially huge file instruction to be
|
|
||||||
* split across multiple writes.
|
|
||||||
*
|
*
|
||||||
* If an error occurs sending the instruction, a non-zero value is
|
* If an error occurs sending the instruction, a non-zero value is
|
||||||
* returned, and guac_error is set appropriately.
|
* returned, and guac_error is set appropriately.
|
||||||
*
|
*
|
||||||
* @param socket The guac_socket connection to use.
|
* @param socket The guac_socket connection to use.
|
||||||
|
* @param index The index of the blob to append data to.
|
||||||
* @param data The file data to write.
|
* @param data The file data to write.
|
||||||
* @param count The number of bytes within the given buffer of file data
|
* @param count The number of bytes within the given buffer of file data
|
||||||
* that must be written.
|
* that must be written.
|
||||||
* @return Zero on success, non-zero on error.
|
* @return Zero on success, non-zero on error.
|
||||||
*/
|
*/
|
||||||
int guac_protocol_send_file_data(guac_socket* socket, void* data, int count);
|
int guac_protocol_send_blob(guac_socket* socket, int index, void* data, int count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Completes the file instruction which was started with
|
* Completes the file instruction which was started with
|
||||||
@ -419,9 +390,10 @@ int guac_protocol_send_file_data(guac_socket* socket, void* data, int count);
|
|||||||
* returned, and guac_error is set appropriately.
|
* returned, and guac_error is set appropriately.
|
||||||
*
|
*
|
||||||
* @param socket The guac_socket connection to use.
|
* @param socket The guac_socket connection to use.
|
||||||
|
* @param index The index of the blob which is now complete.
|
||||||
* @return Zero on success, non-zero on error.
|
* @return Zero on success, non-zero on error.
|
||||||
*/
|
*/
|
||||||
int guac_protocol_send_file_end(guac_socket* socket);
|
int guac_protocol_send_end(guac_socket* socket, int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a video instruction over the given guac_socket connection.
|
* Sends a video instruction over the given guac_socket connection.
|
||||||
|
@ -442,6 +442,22 @@ int guac_protocol_send_audio_end(guac_socket* socket) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int guac_protocol_send_blob(guac_socket* socket, int index, void* data, int count) {
|
||||||
|
|
||||||
|
int base64_length = (count + 2) / 3 * 4;
|
||||||
|
|
||||||
|
return
|
||||||
|
guac_socket_write_string(socket, "4.blob,")
|
||||||
|
|| __guac_socket_write_length_int(socket, index)
|
||||||
|
|| guac_socket_write_string(socket, ",")
|
||||||
|
|| guac_socket_write_int(socket, base64_length)
|
||||||
|
|| guac_socket_write_string(socket, ".")
|
||||||
|
|| guac_socket_write_base64(socket, data, count)
|
||||||
|
|| guac_socket_flush_base64(socket)
|
||||||
|
|| guac_socket_write_string(socket, ";");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@ -656,6 +672,16 @@ int guac_protocol_send_distort(guac_socket* socket, const guac_layer* layer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int guac_protocol_send_end(guac_socket* socket, int index) {
|
||||||
|
|
||||||
|
return
|
||||||
|
guac_socket_write_string(socket, "3.end,")
|
||||||
|
|| __guac_socket_write_length_int(socket, index)
|
||||||
|
|| guac_socket_write_string(socket, ";");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int guac_protocol_send_error(guac_socket* socket, const char* error) {
|
int guac_protocol_send_error(guac_socket* socket, const char* error) {
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -665,43 +691,15 @@ int guac_protocol_send_error(guac_socket* socket, const char* error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int guac_protocol_send_file(guac_socket* socket, const char* name,
|
int guac_protocol_send_file(guac_socket* socket, int index, const char* name, const char* mimetype) {
|
||||||
const char* mimetype, void* data, int size) {
|
|
||||||
|
|
||||||
return
|
|
||||||
guac_protocol_send_file_header(socket, name,
|
|
||||||
mimetype, size)
|
|
||||||
|| guac_protocol_send_file_data(socket, data, size)
|
|
||||||
|| guac_protocol_send_file_end(socket);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int guac_protocol_send_file_header(guac_socket* socket, const char* name,
|
|
||||||
const char* mimetype, int size) {
|
|
||||||
|
|
||||||
int base64_length = (size + 2) / 3 * 4;
|
|
||||||
|
|
||||||
return
|
return
|
||||||
guac_socket_write_string(socket, "4.file,")
|
guac_socket_write_string(socket, "4.file,")
|
||||||
|
|| __guac_socket_write_length_int(socket, index)
|
||||||
|
|| guac_socket_write_string(socket, ",")
|
||||||
|| __guac_socket_write_length_string(socket, name)
|
|| __guac_socket_write_length_string(socket, name)
|
||||||
|| guac_socket_write_string(socket, ",")
|
|| guac_socket_write_string(socket, ",")
|
||||||
|| __guac_socket_write_length_string(socket, mimetype)
|
|| __guac_socket_write_length_string(socket, mimetype)
|
||||||
|| guac_socket_write_string(socket, ",")
|
|
||||||
|| guac_socket_write_int(socket, base64_length)
|
|
||||||
|| guac_socket_write_string(socket, ".");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int guac_protocol_send_file_data(guac_socket* socket, void* data, int count) {
|
|
||||||
|
|
||||||
return guac_socket_write_base64(socket, data, count);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int guac_protocol_send_file_end(guac_socket* socket) {
|
|
||||||
|
|
||||||
return
|
|
||||||
guac_socket_flush_base64(socket)
|
|
||||||
|| guac_socket_write_string(socket, ";");
|
|| guac_socket_write_string(socket, ";");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user