-
Notifications
You must be signed in to change notification settings - Fork 661
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GUACAMOLE-261: Implement Spice protocol support.
- Loading branch information
1 parent
b20afa2
commit c6263a2
Showing
67 changed files
with
9,876 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# | ||
# 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 | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# 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. | ||
# | ||
# NOTE: Parts of this file (Makefile.am) are automatically transcluded verbatim | ||
# into Makefile.in. Though the build system (GNU Autotools) automatically adds | ||
# its own license boilerplate to the generated Makefile.in, that boilerplate | ||
# does not apply to the transcluded portions of Makefile.am which are licensed | ||
# to you by the ASF under the Apache License, Version 2.0, as described above. | ||
# | ||
|
||
AUTOMAKE_OPTIONS = foreign | ||
ACLOCAL_AMFLAGS = -I m4 | ||
|
||
lib_LTLIBRARIES = libguac-client-spice.la | ||
|
||
nodist_libguac_client_spice_la_SOURCES = \ | ||
_generated_keymaps.c | ||
|
||
libguac_client_spice_la_SOURCES = \ | ||
argv.c \ | ||
auth.c \ | ||
channels/audio.c \ | ||
channels/clipboard.c \ | ||
channels/cursor.c \ | ||
channels/display.c \ | ||
channels/file.c \ | ||
channels/file-download.c \ | ||
channels/file-ls.c \ | ||
channels/file-upload.c \ | ||
client.c \ | ||
decompose.c \ | ||
input.c \ | ||
keyboard.c \ | ||
keymap.c \ | ||
log.c \ | ||
settings.c \ | ||
spice.c \ | ||
user.c | ||
|
||
noinst_HEADERS = \ | ||
argv.h \ | ||
auth.h \ | ||
channels/audio.h \ | ||
channels/clipboard.h \ | ||
channels/cursor.h \ | ||
channels/display.h \ | ||
channels/file.h \ | ||
channels/file-download.h \ | ||
channels/file-ls.h \ | ||
channels/file-upload.h \ | ||
client.h \ | ||
decompose.h \ | ||
input.h \ | ||
keyboard.h \ | ||
keymap.h \ | ||
log.h \ | ||
settings.h \ | ||
spice.h \ | ||
user.h | ||
|
||
libguac_client_spice_la_CFLAGS = \ | ||
-Werror -Wall -pedantic -Iinclude \ | ||
@COMMON_INCLUDE@ \ | ||
@COMMON_SSH_INCLUDE@ \ | ||
@LIBGUAC_INCLUDE@ \ | ||
@GLIB2_CFLAGS@ \ | ||
@SPICE_CFLAGS@ | ||
|
||
libguac_client_spice_la_LDFLAGS = \ | ||
-version-info 0:0:0 \ | ||
@CAIRO_LIBS@ \ | ||
@GLIB2_LIBS@ \ | ||
@SPICE_LIBS@ | ||
|
||
libguac_client_spice_la_LIBADD = \ | ||
@COMMON_LTLIB@ \ | ||
@LIBGUAC_LTLIB@ | ||
|
||
# Optional SFTP support | ||
if ENABLE_COMMON_SSH | ||
libguac_client_spice_la_SOURCES += sftp.c | ||
noinst_HEADERS += sftp.h | ||
libguac_client_spice_la_LIBADD += @COMMON_SSH_LTLIB@ | ||
endif | ||
|
||
# | ||
# Autogenerated keymaps and channel wrapper functions | ||
# | ||
|
||
CLEANFILES = \ | ||
_generated_keymaps.c | ||
|
||
BUILT_SOURCES = \ | ||
_generated_keymaps.c | ||
|
||
spice_keymaps = \ | ||
$(srcdir)/keymaps/base.keymap \ | ||
$(srcdir)/keymaps/failsafe.keymap \ | ||
$(srcdir)/keymaps/de_de_qwertz.keymap \ | ||
$(srcdir)/keymaps/de_ch_qwertz.keymap \ | ||
$(srcdir)/keymaps/en_gb_qwerty.keymap \ | ||
$(srcdir)/keymaps/en_us_qwerty.keymap \ | ||
$(srcdir)/keymaps/es_es_qwerty.keymap \ | ||
$(srcdir)/keymaps/es_latam_qwerty.keymap \ | ||
$(srcdir)/keymaps/fr_be_azerty.keymap \ | ||
$(srcdir)/keymaps/fr_ca_qwerty.keymap \ | ||
$(srcdir)/keymaps/fr_ch_qwertz.keymap \ | ||
$(srcdir)/keymaps/fr_fr_azerty.keymap \ | ||
$(srcdir)/keymaps/hu_hu_qwertz.keymap \ | ||
$(srcdir)/keymaps/it_it_qwerty.keymap \ | ||
$(srcdir)/keymaps/ja_jp_qwerty.keymap \ | ||
$(srcdir)/keymaps/no_no_qwerty.keymap \ | ||
$(srcdir)/keymaps/pl_pl_qwerty.keymap \ | ||
$(srcdir)/keymaps/pt_br_qwerty.keymap \ | ||
$(srcdir)/keymaps/sv_se_qwerty.keymap \ | ||
$(srcdir)/keymaps/da_dk_qwerty.keymap \ | ||
$(srcdir)/keymaps/tr_tr_qwerty.keymap | ||
|
||
_generated_keymaps.c: $(spice_keymaps) $(srcdir)/keymaps/generate.pl | ||
$(AM_V_GEN) $(srcdir)/keymaps/generate.pl $(spice_keymaps) | ||
|
||
EXTRA_DIST = \ | ||
$(spice_keymaps) \ | ||
keymaps/generate.pl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "argv.h" | ||
#include "spice.h" | ||
|
||
#include <guacamole/protocol.h> | ||
#include <guacamole/socket.h> | ||
#include <guacamole/user.h> | ||
|
||
#include <pthread.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
int guac_spice_argv_callback(guac_user* user, const char* mimetype, | ||
const char* name, const char* value, void* data) { | ||
|
||
guac_client* client = user->client; | ||
guac_spice_client* spice_client = (guac_spice_client*) client->data; | ||
guac_spice_settings* settings = spice_client->settings; | ||
|
||
/* Update username */ | ||
if (strcmp(name, GUAC_SPICE_ARGV_USERNAME) == 0) { | ||
free(settings->username); | ||
settings->username = strdup(value); | ||
} | ||
|
||
/* Update password */ | ||
else if (strcmp(name, GUAC_SPICE_ARGV_PASSWORD) == 0) { | ||
free(settings->password); | ||
settings->password = strdup(value); | ||
} | ||
|
||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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. | ||
*/ | ||
|
||
#ifndef GUAC_SPICE_ARGV_H | ||
#define GUAC_SPICE_ARGV_H | ||
|
||
#include "config.h" | ||
|
||
#include <guacamole/argv.h> | ||
#include <guacamole/user.h> | ||
|
||
/** | ||
* Handles a received argument value from a Guacamole "argv" instruction, | ||
* updating the given connection parameter. | ||
*/ | ||
guac_argv_callback guac_spice_argv_callback; | ||
|
||
/** | ||
* The name of the parameter Guacamole will use to specify/update the username | ||
* for the Spice connection. | ||
*/ | ||
#define GUAC_SPICE_ARGV_USERNAME "username" | ||
|
||
/** | ||
* The name of the parameter Guacamole will use to specify/update the password | ||
* for the Spice connection. | ||
*/ | ||
#define GUAC_SPICE_ARGV_PASSWORD "password" | ||
|
||
#endif /* GUAC_SPICE_ARGV_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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. | ||
*/ | ||
|
||
#include "config.h" | ||
|
||
#include "argv.h" | ||
#include "auth.h" | ||
#include "spice.h" | ||
|
||
#include <guacamole/argv.h> | ||
#include <guacamole/client.h> | ||
#include <guacamole/protocol.h> | ||
#include <guacamole/socket.h> | ||
#include <guacamole/string.h> | ||
|
||
#include <glib-unix.h> | ||
#include <pthread.h> | ||
#include <string.h> | ||
|
||
gboolean guac_spice_get_credentials(guac_client* client) { | ||
|
||
guac_spice_client* spice_client = ((guac_spice_client*) client->data); | ||
guac_spice_settings* settings = spice_client->settings; | ||
|
||
char* params[3] = {NULL}; | ||
int i = 0; | ||
|
||
/* Check if username is not provided. */ | ||
if (settings->username == NULL) { | ||
guac_argv_register(GUAC_SPICE_ARGV_USERNAME, guac_spice_argv_callback, NULL, 0); | ||
params[i] = GUAC_SPICE_ARGV_USERNAME; | ||
i++; | ||
} | ||
|
||
/* Check if password is not provided. */ | ||
if (settings->password == NULL) { | ||
guac_argv_register(GUAC_SPICE_ARGV_PASSWORD, guac_spice_argv_callback, NULL, 0); | ||
params[i] = GUAC_SPICE_ARGV_PASSWORD; | ||
i++; | ||
} | ||
|
||
params[i] = NULL; | ||
|
||
/* If we have empty parameters, request them and await response. */ | ||
if (i > 0) { | ||
guac_client_owner_send_required(client, (const char**) params); | ||
guac_argv_await((const char**) params); | ||
return true; | ||
} | ||
|
||
guac_client_log(client, GUAC_LOG_DEBUG, | ||
"Unable to retrieve any credentials from the user."); | ||
return false; | ||
|
||
} |
Oops, something went wrong.