From e1eb8bfcbca8d48227bbb4eecf3a97f82f83b79d Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Wed, 22 Apr 2009 04:34:45 +0000 Subject: [PATCH] added device redir start files --- sesman/chansrv/Makefile.am | 3 +- sesman/chansrv/chansrv.c | 82 ++++++++++++++++++++++++++------------ sesman/chansrv/clipboard.c | 2 + sesman/chansrv/devredir.c | 53 ++++++++++++++++++++++++ sesman/chansrv/devredir.h | 18 +++++++++ sesman/chansrv/sound.c | 2 + 6 files changed, 133 insertions(+), 27 deletions(-) create mode 100644 sesman/chansrv/devredir.c create mode 100644 sesman/chansrv/devredir.h diff --git a/sesman/chansrv/Makefile.am b/sesman/chansrv/Makefile.am index 0ccf927a..8752e737 100644 --- a/sesman/chansrv/Makefile.am +++ b/sesman/chansrv/Makefile.am @@ -7,7 +7,8 @@ sbin_PROGRAMS = \ xrdp_chansrv_SOURCES = \ chansrv.c \ sound.c \ - clipboard.c + clipboard.c \ + devredir.c xrdp_chansrv_LDADD = \ $(top_srcdir)/common/libcommon.la diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index e890a0f0..84a973f0 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -24,19 +24,23 @@ #include "chansrv.h" #include "defines.h" #include "sound.h" +#include "clipboard.h" +#include "devredir.h" static tbus g_thread_done_event = 0; static struct trans* g_lis_trans = 0; static struct trans* g_con_trans = 0; static struct chan_item g_chan_items[32]; static int g_num_chan_items = 0; -static int g_clip_index = -1; -static int g_sound_index = -1; +static int g_cliprdr_index = -1; +static int g_rdpsnd_index = -1; +static int g_rdpdr_index = -1; tbus g_term_event = 0; int g_display = 0; -int g_clip_chan_id = -1; -int g_sound_chan_id = -1; +int g_cliprdr_chan_id = -1; /* cliprdr */ +int g_rdpsnd_chan_id = -1; /* rdpsnd */ +int g_rdpdr_chan_id = -1; /* rdpdr */ /*****************************************************************************/ /* returns error */ @@ -185,25 +189,34 @@ process_message_channel_setup(struct stream* s) ci->name, ci->id, ci->flags); if (g_strcasecmp(ci->name, "cliprdr") == 0) { - g_clip_index = g_num_chan_items; - g_clip_chan_id = ci->id; + g_cliprdr_index = g_num_chan_items; + g_cliprdr_chan_id = ci->id; } else if (g_strcasecmp(ci->name, "rdpsnd") == 0) { - g_sound_index = g_num_chan_items; - g_sound_chan_id = ci->id; + g_rdpsnd_index = g_num_chan_items; + g_rdpsnd_chan_id = ci->id; + } + else if (g_strcasecmp(ci->name, "rdpdr") == 0) + { + g_rdpdr_index = g_num_chan_items; + g_rdpdr_chan_id = ci->id; } g_num_chan_items++; } rv = send_channel_setup_response_message(); - if (g_clip_index >= 0) + if (g_cliprdr_index >= 0) { clipboard_init(); } - if (g_sound_index >= 0) + if (g_rdpsnd_index >= 0) { sound_init(); } + if (g_rdpdr_index >= 0) + { + dev_redir_init(); + } return rv; } @@ -227,14 +240,18 @@ process_message_channel_data(struct stream* s) rv = send_channel_data_response_message(); if (rv == 0) { - if (chan_id == g_clip_chan_id) + if (chan_id == g_cliprdr_chan_id) { rv = clipboard_data_in(s, chan_id, chan_flags, length, total_length); } - else if (chan_id == g_sound_chan_id) + else if (chan_id == g_rdpsnd_chan_id) { rv = sound_data_in(s, chan_id, chan_flags, length, total_length); } + else if (chan_id == g_rdpdr_chan_id) + { + rv = dev_redir_data_in(s, chan_id, chan_flags, length, total_length); + } } return rv; } @@ -365,18 +382,16 @@ my_trans_conn_in(struct trans* trans, struct trans* new_trans) } /*****************************************************************************/ -THREAD_RV THREAD_CC -channel_thread_loop(void* in_val) +static int APP_CC +setup_listen(void) { - tbus objs[32]; - int num_objs; - int timeout; - int error; char text[256]; - THREAD_RV rv; + int error; - g_writeln("xrdp-chansrv: thread start"); - rv = 0; + if (g_lis_trans != 0) + { + trans_delete(g_lis_trans); + } g_lis_trans = trans_create(1, 8192, 8192); g_lis_trans->trans_conn_in = my_trans_conn_in; g_snprintf(text, 255, "%d", 7200 + g_display); @@ -384,7 +399,24 @@ channel_thread_loop(void* in_val) if (error != 0) { g_writeln("xrdp-chansrv: trans_listen failed"); + return 1; } + return 0; +} + +/*****************************************************************************/ +THREAD_RV THREAD_CC +channel_thread_loop(void* in_val) +{ + tbus objs[32]; + int num_objs; + int timeout; + int error; + THREAD_RV rv; + + g_writeln("xrdp-chansrv: thread start"); + rv = 0; + error = setup_listen(); if (error == 0) { timeout = 0; @@ -415,19 +447,16 @@ channel_thread_loop(void* in_val) trans_delete(g_con_trans); g_con_trans = 0; /* create new listener */ - g_lis_trans = trans_create(1, 8192, 8192); - g_lis_trans->trans_conn_in = my_trans_conn_in; - g_snprintf(text, 255, "%d", 7200 + g_display); - error = trans_listen(g_lis_trans, text); + error = setup_listen(); if (error != 0) { - g_writeln("xrdp-chansrv: trans_listen failed"); break; } } } clipboard_check_wait_objs(); sound_check_wait_objs(); + dev_redir_check_wait_objs(); timeout = 0; num_objs = 0; objs[num_objs] = g_term_event; @@ -436,6 +465,7 @@ channel_thread_loop(void* in_val) trans_get_wait_objs(g_con_trans, objs, &num_objs, &timeout); clipboard_get_wait_objs(objs, &num_objs, &timeout); sound_get_wait_objs(objs, &num_objs, &timeout); + dev_redir_get_wait_objs(objs, &num_objs, &timeout); } } trans_delete(g_lis_trans); diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index 69096eab..59d39fbd 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -21,6 +21,8 @@ #include "parse.h" #include "os_calls.h" +extern int g_cliprdr_chan_id; /* in chansrv.c */ + /*****************************************************************************/ int APP_CC clipboard_init(void) diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c new file mode 100644 index 00000000..d938b5c4 --- /dev/null +++ b/sesman/chansrv/devredir.c @@ -0,0 +1,53 @@ +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + xrdp: A Remote Desktop Protocol server. + Copyright (C) Jay Sorg 2009 +*/ + +#include "arch.h" +#include "parse.h" +#include "os_calls.h" + +extern int g_rdpdr_chan_id; /* in chansrv.c */ + +/*****************************************************************************/ +int APP_CC +dev_redir_init(void) +{ + return 0; +} + +/*****************************************************************************/ +int APP_CC +dev_redir_data_in(struct stream* s, int chan_id, int chan_flags, int length, + int total_length) +{ + return 0; +} + +/*****************************************************************************/ +int APP_CC +dev_redir_get_wait_objs(tbus* objs, int* count, int* timeout) +{ + return 0; +} + +/*****************************************************************************/ +int APP_CC +dev_redir_check_wait_objs(void) +{ + return 0; +} diff --git a/sesman/chansrv/devredir.h b/sesman/chansrv/devredir.h new file mode 100644 index 00000000..43af7838 --- /dev/null +++ b/sesman/chansrv/devredir.h @@ -0,0 +1,18 @@ + +#if !defined(DEVREDIR_H) +#define DEVREDIR_H + +#include "arch.h" +#include "parse.h" + +int APP_CC +dev_redir_init(void); +int APP_CC +dev_redir_data_in(struct stream* s, int chan_id, int chan_flags, int length, + int total_length); +int APP_CC +dev_redir_get_wait_objs(tbus* objs, int* count, int* timeout); +int APP_CC +dev_redir_check_wait_objs(void); + +#endif diff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c index 6568e5ea..87832209 100644 --- a/sesman/chansrv/sound.c +++ b/sesman/chansrv/sound.c @@ -21,6 +21,8 @@ #include "parse.h" #include "os_calls.h" +extern int g_rdpsnd_chan_id; /* in chansrv.c */ + /*****************************************************************************/ int APP_CC sound_init(void)