libguac
1.0.0
|
Defines the guac_user object, which represents a physical connection within a larger, possibly shared, logical connection represented by a guac_client. More...
Go to the source code of this file.
Data Structures | |
struct | guac_user_info |
Information exposed by the remote client during the connection handshake which can be used by a client plugin. More... | |
struct | guac_user |
Representation of a physical connection within a larger logical connection which may be shared. More... | |
Functions | |
guac_user * | guac_user_alloc () |
Allocates a new, blank user, not associated with any specific client or socket. More... | |
void | guac_user_free (guac_user *user) |
Frees the given user and all associated resources. More... | |
int | guac_user_handle_connection (guac_user *user, int usec_timeout) |
Handles all I/O for the portion of a user's Guacamole connection following the initial "select" instruction, including the rest of the handshake. More... | |
int | guac_user_handle_instruction (guac_user *user, const char *opcode, int argc, char **argv) |
Call the appropriate handler defined by the given user for the given instruction. More... | |
guac_stream * | guac_user_alloc_stream (guac_user *user) |
Allocates a new stream. More... | |
void | guac_user_free_stream (guac_user *user, guac_stream *stream) |
Returns the given stream to the pool of available streams, such that it can be reused by any subsequent call to guac_user_alloc_stream(). More... | |
void | guac_user_stop (guac_user *user) |
Signals the given user that it must disconnect, or advises cooperating services that the given user is no longer connected. More... | |
void | guac_user_abort (guac_user *user, guac_protocol_status status, const char *format,...) |
Signals the given user to stop gracefully, while also signalling via the Guacamole protocol that an error has occurred. More... | |
void | vguac_user_abort (guac_user *user, guac_protocol_status status, const char *format, va_list ap) |
Signals the given user to stop gracefully, while also signalling via the Guacamole protocol that an error has occurred. More... | |
void | guac_user_log (guac_user *user, guac_client_log_level level, const char *format,...) |
Writes a message in the log used by the given user. More... | |
void | vguac_user_log (guac_user *user, guac_client_log_level level, const char *format, va_list ap) |
Writes a message in the log used by the given user. More... | |
guac_object * | guac_user_alloc_object (guac_user *user) |
Allocates a new object. More... | |
void | guac_user_free_object (guac_user *user, guac_object *object) |
Returns the given object to the pool of available objects, such that it can be reused by any subsequent call to guac_user_alloc_object(). More... | |
void | guac_user_stream_png (guac_user *user, guac_socket *socket, guac_composite_mode mode, const guac_layer *layer, int x, int y, cairo_surface_t *surface) |
Streams the image data of the given surface over an image stream ("img" instruction) as PNG-encoded data. More... | |
void | guac_user_stream_jpeg (guac_user *user, guac_socket *socket, guac_composite_mode mode, const guac_layer *layer, int x, int y, cairo_surface_t *surface, int quality) |
Streams the image data of the given surface over an image stream ("img" instruction) as JPEG-encoded data at the given quality. More... | |
void | guac_user_stream_webp (guac_user *user, guac_socket *socket, guac_composite_mode mode, const guac_layer *layer, int x, int y, cairo_surface_t *surface, int quality, int lossless) |
Streams the image data of the given surface over an image stream ("img" instruction) as WebP-encoded data at the given quality. More... | |
int | guac_user_supports_webp (guac_user *user) |
Returns whether the given user supports WebP. More... | |
char * | guac_user_parse_args_string (guac_user *user, const char **arg_names, const char **argv, int index, const char *default_value) |
Automatically handles a single argument received from a joining user, returning a newly-allocated string containing that value. More... | |
int | guac_user_parse_args_int (guac_user *user, const char **arg_names, const char **argv, int index, int default_value) |
Automatically handles a single integer argument received from a joining user, returning the integer value of that argument. More... | |
int | guac_user_parse_args_boolean (guac_user *user, const char **arg_names, const char **argv, int index, int default_value) |
Automatically handles a single boolean argument received from a joining user, returning the value of that argument (either 1 for true or 0 for false). More... | |
Defines the guac_user object, which represents a physical connection within a larger, possibly shared, logical connection represented by a guac_client.
void guac_user_abort | ( | guac_user * | user, |
guac_protocol_status | status, | ||
const char * | format, | ||
... | |||
) |
Signals the given user to stop gracefully, while also signalling via the Guacamole protocol that an error has occurred.
Note that this is a completely cooperative signal, and can be ignored by the user or the hosting daemon. The message given will be logged to the system logs.
user | The user to signal to stop. |
status | The status to send over the Guacamole protocol. |
format | A printf-style format string to log. |
... | Arguments to use when filling the format string for printing. |
guac_user* guac_user_alloc | ( | ) |
Allocates a new, blank user, not associated with any specific client or socket.
guac_object* guac_user_alloc_object | ( | guac_user * | user | ) |
Allocates a new object.
An arbitrary index is automatically assigned if no previously-allocated object is available for use.
user | The user to allocate the object for. |
guac_stream* guac_user_alloc_stream | ( | guac_user * | user | ) |
Allocates a new stream.
An arbitrary index is automatically assigned if no previously-allocated stream is available for use.
user | The user to allocate the stream for. |
void guac_user_free | ( | guac_user * | user | ) |
Frees the given user and all associated resources.
user | The guac_user to free. |
void guac_user_free_object | ( | guac_user * | user, |
guac_object * | object | ||
) |
Returns the given object to the pool of available objects, such that it can be reused by any subsequent call to guac_user_alloc_object().
user | The user to return the object to. |
object | The object to return to the pool of available object. |
void guac_user_free_stream | ( | guac_user * | user, |
guac_stream * | stream | ||
) |
Returns the given stream to the pool of available streams, such that it can be reused by any subsequent call to guac_user_alloc_stream().
user | The user to return the stream to. |
stream | The stream to return to the pool of available stream. |
int guac_user_handle_connection | ( | guac_user * | user, |
int | usec_timeout | ||
) |
Handles all I/O for the portion of a user's Guacamole connection following the initial "select" instruction, including the rest of the handshake.
The handshake-related properties of the given guac_user are automatically populated, and guac_user_handle_instruction() is invoked for all instructions received after the handshake has completed. This function blocks until the connection/user is aborted or the user disconnects.
user | The user whose handshake and entire Guacamole protocol exchange should be handled. The user must already be associated with a guac_socket and guac_client, and the guac_client must already be fully initialized. |
usec_timeout | The number of microseconds to wait for instructions from the given user before closing the connection with an error. |
int guac_user_handle_instruction | ( | guac_user * | user, |
const char * | opcode, | ||
int | argc, | ||
char ** | argv | ||
) |
Call the appropriate handler defined by the given user for the given instruction.
A comparison is made between the instruction opcode and the initial handler lookup table defined in user-handlers.c. The intial handlers will in turn call the user's handler (if defined).
user | The user whose handlers should be called. |
opcode | The opcode of the instruction to pass to the user via the appropriate handler. |
argc | The number of arguments which are part of the instruction. |
argv | An array of all arguments which are part of the instruction. |
void guac_user_log | ( | guac_user * | user, |
guac_client_log_level | level, | ||
const char * | format, | ||
... | |||
) |
Writes a message in the log used by the given user.
The logger used will normally be defined by guacd (or whichever program loads the user) by setting the logging handlers of the user when it is loaded.
user | The user logging this message. |
level | The level at which to log this message. |
format | A printf-style format string to log. |
... | Arguments to use when filling the format string for printing. |
int guac_user_parse_args_boolean | ( | guac_user * | user, |
const char ** | arg_names, | ||
const char ** | argv, | ||
int | index, | ||
int | default_value | ||
) |
Automatically handles a single boolean argument received from a joining user, returning the value of that argument (either 1 for true or 0 for false).
Only "true" and "false" are legitimate values for a boolean argument. If the argument provided by the user is blank or invalid, the default value is returned.
user | The user joining the connection and providing the given arguments. |
arg_names | A NULL-terminated array of argument names, corresponding to the provided array of argument values. This array must be exactly the same size as the argument value array, with one additional entry for the NULL terminator. |
argv | An array of all argument values, corresponding to the provided array of argument names. This array must be exactly the same size as the argument name array, with the exception of the NULL terminator. |
index | The index of the entry in both the arg_names and argv arrays which corresponds to the argument being parsed. |
default_value | The value to return if the provided argument is blank or invalid. |
int guac_user_parse_args_int | ( | guac_user * | user, |
const char ** | arg_names, | ||
const char ** | argv, | ||
int | index, | ||
int | default_value | ||
) |
Automatically handles a single integer argument received from a joining user, returning the integer value of that argument.
If the argument provided by the user is blank or invalid, the default value is returned.
user | The user joining the connection and providing the given arguments. |
arg_names | A NULL-terminated array of argument names, corresponding to the provided array of argument values. This array must be exactly the same size as the argument value array, with one additional entry for the NULL terminator. |
argv | An array of all argument values, corresponding to the provided array of argument names. This array must be exactly the same size as the argument name array, with the exception of the NULL terminator. |
index | The index of the entry in both the arg_names and argv arrays which corresponds to the argument being parsed. |
default_value | The value to return if the provided argument is blank or invalid. |
char* guac_user_parse_args_string | ( | guac_user * | user, |
const char ** | arg_names, | ||
const char ** | argv, | ||
int | index, | ||
const char * | default_value | ||
) |
Automatically handles a single argument received from a joining user, returning a newly-allocated string containing that value.
If the argument provided by the user is blank, a newly-allocated string containing the default value is returned.
user | The user joining the connection and providing the given arguments. |
arg_names | A NULL-terminated array of argument names, corresponding to the provided array of argument values. This array must be exactly the same size as the argument value array, with one additional entry for the NULL terminator. |
argv | An array of all argument values, corresponding to the provided array of argument names. This array must be exactly the same size as the argument name array, with the exception of the NULL terminator. |
index | The index of the entry in both the arg_names and argv arrays which corresponds to the argument being parsed. |
default_value | The value to return if the provided argument is blank. If this value is not NULL, the returned value will be a newly-allocated string containing this value. |
void guac_user_stop | ( | guac_user * | user | ) |
Signals the given user that it must disconnect, or advises cooperating services that the given user is no longer connected.
user | The user to stop. |
void guac_user_stream_jpeg | ( | guac_user * | user, |
guac_socket * | socket, | ||
guac_composite_mode | mode, | ||
const guac_layer * | layer, | ||
int | x, | ||
int | y, | ||
cairo_surface_t * | surface, | ||
int | quality | ||
) |
Streams the image data of the given surface over an image stream ("img" instruction) as JPEG-encoded data at the given quality.
The image stream will be automatically allocated and freed.
user | The Guacamole user for whom the image stream should be allocated. |
socket | The socket over which instructions associated with the image stream should be sent. |
mode | The composite mode to use when rendering the image over the given layer. |
layer | The destination layer. |
x | The X coordinate of the upper-left corner of the destination rectangle within the given layer. |
y | The Y coordinate of the upper-left corner of the destination rectangle within the given layer. |
surface | A Cairo surface containing the image data to be streamed. |
quality | The JPEG image quality, which must be an integer value between 0 and 100 inclusive. Larger values indicate improving quality at the expense of larger file size. |
void guac_user_stream_png | ( | guac_user * | user, |
guac_socket * | socket, | ||
guac_composite_mode | mode, | ||
const guac_layer * | layer, | ||
int | x, | ||
int | y, | ||
cairo_surface_t * | surface | ||
) |
Streams the image data of the given surface over an image stream ("img" instruction) as PNG-encoded data.
The image stream will be automatically allocated and freed.
user | The Guacamole user for whom the image stream should be allocated. |
socket | The socket over which instructions associated with the image stream should be sent. |
mode | The composite mode to use when rendering the image over the given layer. |
layer | The destination layer. |
x | The X coordinate of the upper-left corner of the destination rectangle within the given layer. |
y | The Y coordinate of the upper-left corner of the destination rectangle within the given layer. |
surface | A Cairo surface containing the image data to be streamed. |
void guac_user_stream_webp | ( | guac_user * | user, |
guac_socket * | socket, | ||
guac_composite_mode | mode, | ||
const guac_layer * | layer, | ||
int | x, | ||
int | y, | ||
cairo_surface_t * | surface, | ||
int | quality, | ||
int | lossless | ||
) |
Streams the image data of the given surface over an image stream ("img" instruction) as WebP-encoded data at the given quality.
The image stream will be automatically allocated and freed. If the server does not support WebP, this function has no effect, so be sure to check the result of guac_user_supports_webp() or guac_client_supports_webp() prior to calling this function.
user | The Guacamole user for whom the image stream should be allocated. |
socket | The socket over which instructions associated with the image stream should be sent. |
mode | The composite mode to use when rendering the image over the given layer. |
layer | The destination layer. |
x | The X coordinate of the upper-left corner of the destination rectangle within the given layer. |
y | The Y coordinate of the upper-left corner of the destination rectangle within the given layer. |
surface | A Cairo surface containing the image data to be streamed. |
quality | The WebP image quality, which must be an integer value between 0 and 100 inclusive. For lossy images, larger values indicate improving quality at the expense of larger file size. For lossless images, this dictates the quality of compression, with larger values producing smaller files at the expense of speed. |
lossless | Zero to encode a lossy image, non-zero to encode losslessly. |
int guac_user_supports_webp | ( | guac_user * | user | ) |
Returns whether the given user supports WebP.
If the user does not support WebP, or the server cannot encode WebP images, zero is returned.
user | The Guacamole user to check for WebP support. |
void vguac_user_abort | ( | guac_user * | user, |
guac_protocol_status | status, | ||
const char * | format, | ||
va_list | ap | ||
) |
Signals the given user to stop gracefully, while also signalling via the Guacamole protocol that an error has occurred.
Note that this is a completely cooperative signal, and can be ignored by the user or the hosting daemon. The message given will be logged to the system logs.
user | The user to signal to stop. |
status | The status to send over the Guacamole protocol. |
format | A printf-style format string to log. |
ap | The va_list containing the arguments to be used when filling the format string for printing. |
void vguac_user_log | ( | guac_user * | user, |
guac_client_log_level | level, | ||
const char * | format, | ||
va_list | ap | ||
) |
Writes a message in the log used by the given user.
The logger used will normally be defined by guacd (or whichever program loads the user) by setting the logging handlers of the user when it is loaded.
user | The user logging this message. |
level | The level at which to log this message. |
format | A printf-style format string to log. |
ap | The va_list containing the arguments to be used when filling the format string for printing. |