GUACAMOLE-1293: Update struct member that stores human-readable name.

This commit is contained in:
Virtually Nick 2022-04-01 19:30:31 -04:00
parent 6312e1720d
commit 6d7156bc70
5 changed files with 22 additions and 20 deletions

View File

@ -763,12 +763,12 @@ static void* guac_client_owner_notify_join_callback(guac_user* user, void* data)
int retval = 0;
char* owner = "owner";
if (user->info.name != NULL)
owner = strdup(user->info.name);
if (user->info.username != NULL)
owner = strdup(user->info.username);
char* joinName = "anonymous";
if (joiner->info.name != NULL)
joinName = strdup(joiner->info.name);
if (joiner->info.username != NULL)
joinName = strdup(joiner->info.username);
guac_user_log(user, GUAC_LOG_DEBUG, "Notifying %s of %s joining.", owner, joinName);
@ -826,12 +826,12 @@ static void* guac_client_owner_notify_leave_callback(guac_user* user, void* data
const guac_user* quitter = (const guac_user *) data;
char* owner = "owner";
if (user->info.name != NULL)
owner = strdup(user->info.name);
if (user->info.username != NULL)
owner = strdup(user->info.username);
char* quitterName = "anonymous";
if (quitter->info.name != NULL)
quitterName = strdup(quitter->info.name);
if (quitter->info.username != NULL)
quitterName = strdup(quitter->info.username);
guac_user_log(user, GUAC_LOG_DEBUG, "Notifying %s of %s leaving.", owner, quitterName);

View File

@ -93,7 +93,7 @@ struct guac_user_info {
* The human-readable name of the Guacamole user. If the client does not
* provide a name then this will be NULL.
*/
const char* name;
const char* username;
/**
* The timezone of the remote system. If the client does not provide

View File

@ -64,7 +64,7 @@ __guac_instruction_handler_mapping __guac_handshake_handler_map[] = {
{"video", __guac_handshake_video_handler},
{"image", __guac_handshake_image_handler},
{"timezone", __guac_handshake_timezone_handler},
{"name", __guac_handshake_name_handler},
{"username", __guac_handshake_username_handler},
{NULL, NULL}
};
@ -677,16 +677,18 @@ int __guac_handshake_image_handler(guac_user* user, int argc, char** argv) {
}
int __guac_handshake_name_handler(guac_user* user, int argc, char** argv) {
int __guac_handshake_username_handler(guac_user* user, int argc, char** argv) {
/* Free any past value */
free((char *) user->info.name);
/* Free any past value for the user's name */
free((char *) user->info.username);
/* If a value is provided for the username, copy it into guac_user. */
if (argc > 0 && strcmp(argv[0], ""))
user->info.name = (const char*) strdup(argv[0]);
user->info.username = (const char*) strdup(argv[0]);
/* No or empty value was provided, so make sure this is NULLed out. */
else
user->info.name = NULL;
user->info.username = NULL;
return 0;

View File

@ -219,11 +219,11 @@ __guac_instruction_handler __guac_handshake_video_handler;
__guac_instruction_handler __guac_handshake_image_handler;
/**
* Internal handler function that is called when the name instruction is
* Internal handler function that is called when the username instruction is
* received during the handshake process, specifying the name of the Guacamole
* user establishing the connection.
*/
__guac_instruction_handler __guac_handshake_name_handler;
__guac_instruction_handler __guac_handshake_username_handler;
/**
* Internal handler function that is called when the timezone instruction is

View File

@ -296,7 +296,7 @@ int guac_user_handle_connection(guac_user* user, int usec_timeout) {
user->info.audio_mimetypes = NULL;
user->info.image_mimetypes = NULL;
user->info.video_mimetypes = NULL;
user->info.name = NULL;
user->info.username = NULL;
user->info.timezone = NULL;
/* Count number of arguments. */
@ -371,8 +371,8 @@ int guac_user_handle_connection(guac_user* user, int usec_timeout) {
guac_free_mimetypes((char **) user->info.image_mimetypes);
guac_free_mimetypes((char **) user->info.video_mimetypes);
/* Free name and timezone info. */
free((char *) user->info.name);
/* Free username and timezone info. */
free((char *) user->info.username);
free((char *) user->info.timezone);
guac_parser_free(parser);