Add stub client thread.

This commit is contained in:
Michael Jumper 2013-05-17 20:47:05 -07:00
parent 0dbcdabe40
commit 96edfad7c0
7 changed files with 122 additions and 0 deletions

View File

@ -49,6 +49,7 @@ libguac_client_ssh_la_SOURCES = \
src/display.c \ src/display.c \
src/guac_handlers.c \ src/guac_handlers.c \
src/ibar.c \ src/ibar.c \
src/ssh_client.c \
src/terminal.c \ src/terminal.c \
src/terminal_handlers.c src/terminal_handlers.c
@ -61,6 +62,7 @@ noinst_HEADERS = \
include/display.h \ include/display.h \
include/guac_handlers.h \ include/guac_handlers.h \
include/ibar.h \ include/ibar.h \
include/ssh_client.h \
include/terminal.h \ include/terminal.h \
include/terminal_handlers.h \ include/terminal_handlers.h \
include/types.h include/types.h

View File

@ -47,6 +47,7 @@ AC_PROG_LIBTOOL
AC_CHECK_LIB([guac], [guac_client_plugin_open],, AC_MSG_ERROR("libguac must be installed first")) AC_CHECK_LIB([guac], [guac_client_plugin_open],, AC_MSG_ERROR("libguac must be installed first"))
AC_CHECK_LIB([cairo], [cairo_create],, AC_MSG_ERROR("cairo is required for drawing instructions")) AC_CHECK_LIB([cairo], [cairo_create],, AC_MSG_ERROR("cairo is required for drawing instructions"))
AC_CHECK_LIB([ssh], [ssh_new],, AC_MSG_ERROR("libssh is required")) AC_CHECK_LIB([ssh], [ssh_new],, AC_MSG_ERROR("libssh is required"))
AC_CHECK_LIB([pthread], [pthread_create])
PKG_CHECK_MODULES([PANGO], pango); PKG_CHECK_MODULES([PANGO], pango);
PKG_CHECK_MODULES([PANGOCAIRO], pangocairo); PKG_CHECK_MODULES([PANGOCAIRO], pangocairo);

View File

@ -39,6 +39,7 @@
#ifndef _SSH_GUAC_CLIENT_H #ifndef _SSH_GUAC_CLIENT_H
#define _SSH_GUAC_CLIENT_H #define _SSH_GUAC_CLIENT_H
#include <pthread.h>
#include <libssh/libssh.h> #include <libssh/libssh.h>
#include "terminal.h" #include "terminal.h"
@ -49,6 +50,8 @@
*/ */
typedef struct ssh_guac_client_data { typedef struct ssh_guac_client_data {
pthread_t client_thread;
ssh_session session; ssh_session session;
ssh_channel term_channel; ssh_channel term_channel;

View File

@ -0,0 +1,49 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is libguac-client-ssh.
*
* The Initial Developer of the Original Code is
* Michael Jumper.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __SSH_CLIENT_H
#define __SSH_CLIENT_H
#include <guacamole/client.h>
/**
* Main SSH client thread, handling transfer of SSH output to STDOUT.
*/
void* ssh_client_thread(void* data);
#endif

View File

@ -39,6 +39,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <pthread.h>
#include <guacamole/socket.h> #include <guacamole/socket.h>
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
@ -50,6 +51,7 @@
#include "terminal.h" #include "terminal.h"
#include "blank.h" #include "blank.h"
#include "ibar.h" #include "ibar.h"
#include "ssh_client.h"
/* Client plugin arguments */ /* Client plugin arguments */
const char* GUAC_CLIENT_ARGS[] = { const char* GUAC_CLIENT_ARGS[] = {
@ -124,6 +126,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
client->size_handler = ssh_guac_client_size_handler; client->size_handler = ssh_guac_client_size_handler;
client->free_handler = ssh_guac_client_free_handler; client->free_handler = ssh_guac_client_free_handler;
/* Start client thread */
if (pthread_create(&(client_data->client_thread), NULL, ssh_client_thread, (void*) client)) {
guac_client_log_error(client, "Unable to SSH client thread");
return -1;
}
/* Success */ /* Success */
return 0; return 0;

View File

@ -349,6 +349,11 @@ int ssh_guac_client_free_handler(guac_client* client) {
ssh_guac_client_data* guac_client_data = (ssh_guac_client_data*) client->data; ssh_guac_client_data* guac_client_data = (ssh_guac_client_data*) client->data;
/* Close SSH client */
close(STDOUT_FILENO);
close(STDIN_FILENO);
pthread_join(guac_client_data->client_thread, NULL);
/* Free terminal */ /* Free terminal */
guac_terminal_free(guac_client_data->term); guac_terminal_free(guac_client_data->term);

View File

@ -0,0 +1,54 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is libguac-client-ssh.
*
* The Initial Developer of the Original Code is
* Michael Jumper.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* James Muehlner <dagger10k@users.sourceforge.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdio.h>
#include <guacamole/client.h>
#include "client.h"
void* ssh_client_thread(void* data) {
/* STUB */
printf("--- STUB! ---\n");
fflush(stdout);
return NULL;
}