Add optional fd parameter to mod_connect() method

The fd parameter can be used to immediately connect to a display
server, if an fd was obtained from sesman
This commit is contained in:
matt335672
2025-06-20 12:10:13 +01:00
parent 09e4a99bac
commit 3425ab6166
9 changed files with 45 additions and 14 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ lib_mod_start(struct mod *mod, int w, int h, int bpp)
/******************************************************************************/ /******************************************************************************/
/* return error */ /* return error */
static int static int
lib_mod_connect(struct mod *mod) lib_mod_connect(struct mod *mod, int fd)
{ {
LOG_DEVEL(LOG_LEVEL_TRACE, "in lib_mod_connect"); LOG_DEVEL(LOG_LEVEL_TRACE, "in lib_mod_connect");
LOG_DEVEL(LOG_LEVEL_TRACE, "out lib_mod_connect"); LOG_DEVEL(LOG_LEVEL_TRACE, "out lib_mod_connect");
+1 -1
View File
@@ -41,7 +41,7 @@ struct mod
int version; /* internal version */ int version; /* internal version */
/* client functions */ /* client functions */
int (*mod_start)(struct mod *v, int w, int h, int bpp); int (*mod_start)(struct mod *v, int w, int h, int bpp);
int (*mod_connect)(struct mod *v); int (*mod_connect)(struct mod *v, int fd);
int (*mod_event)(struct mod *v, int msg, long param1, long param2, int (*mod_event)(struct mod *v, int msg, long param1, long param2,
long param3, long param4); long param3, long param4);
int (*mod_signal)(struct mod *v); int (*mod_signal)(struct mod *v);
+13 -3
View File
@@ -182,15 +182,25 @@ set_keyboard_overrides(struct mod *mod)
} }
static int static int
lxrdp_connect(struct mod *mod) lxrdp_connect(struct mod *mod, int fd)
{ {
boolean ok; boolean ok;
set_keyboard_overrides(mod); set_keyboard_overrides(mod);
LOG_DEVEL(LOG_LEVEL_TRACE, "lxrdp_connect:"); LOG_DEVEL(LOG_LEVEL_TRACE, "lxrdp_connect:");
ok = freerdp_connect(mod->inst); if (fd >= 0)
LOG_DEVEL(LOG_LEVEL_INFO, "lxrdp_connect: freerdp_connect returned %d", ok); {
LOG(LOG_LEVEL_ERROR,
"NeutrinoRDP : Can't connect to a file descriptor");
ok = 0;
}
else
{
ok = freerdp_connect(mod->inst);
LOG_DEVEL(LOG_LEVEL_INFO,
"lxrdp_connect: freerdp_connect returned %d", ok);
}
if (!ok) if (!ok)
{ {
+1 -1
View File
@@ -74,7 +74,7 @@ struct mod
int version; /* internal version */ int version; /* internal version */
/* client functions */ /* client functions */
int (*mod_start)(struct mod *v, int w, int h, int bpp); int (*mod_start)(struct mod *v, int w, int h, int bpp);
int (*mod_connect)(struct mod *v); int (*mod_connect)(struct mod *v, int fd);
int (*mod_event)(struct mod *v, int msg, long param1, long param2, int (*mod_event)(struct mod *v, int msg, long param1, long param2,
long param3, long param4); long param3, long param4);
int (*mod_signal)(struct mod *v); int (*mod_signal)(struct mod *v);
+12 -2
View File
@@ -2237,7 +2237,7 @@ set_encodings(struct vnc *v)
return error return error
*/ */
static int static int
lib_mod_connect(struct vnc *v) lib_mod_connect(struct vnc *v, int fd)
{ {
char cursor_data[32 * (32 * 3)]; char cursor_data[32 * (32 * 3)];
char cursor_mask[32 * (32 / 8)]; char cursor_mask[32 * (32 / 8)];
@@ -2298,7 +2298,17 @@ lib_mod_connect(struct vnc *v)
v->trans->si = v->si; v->trans->si = v->si;
v->trans->my_source = XRDP_SOURCE_MOD; v->trans->my_source = XRDP_SOURCE_MOD;
error = trans_connect(v->trans, v->ip, con_port, 3000); if (fd >= 0)
{
v->trans->sck = fd;
v->trans->status = TRANS_STATUS_UP; /* ok */
v->trans->type1 = TRANS_TYPE_CLIENT; /* client */
error = 0;
}
else
{
error = trans_connect(v->trans, v->ip, con_port, 3000);
}
if (error != 0) if (error != 0)
{ {
+1 -1
View File
@@ -83,7 +83,7 @@ struct vnc
int version; /* internal version */ int version; /* internal version */
/* client functions */ /* client functions */
int (*mod_start)(struct vnc *v, int w, int h, int bpp); int (*mod_start)(struct vnc *v, int w, int h, int bpp);
int (*mod_connect)(struct vnc *v); int (*mod_connect)(struct vnc *v, int fd);
int (*mod_event)(struct vnc *v, int msg, long param1, long param2, int (*mod_event)(struct vnc *v, int msg, long param1, long param2,
long param3, long param4); long param3, long param4);
int (*mod_signal)(struct vnc *v); int (*mod_signal)(struct vnc *v);
+1 -1
View File
@@ -55,7 +55,7 @@ struct xrdp_mod
int version; /* internal version */ int version; /* internal version */
/* client functions */ /* client functions */
int (*mod_start)(struct xrdp_mod *v, int w, int h, int bpp); int (*mod_start)(struct xrdp_mod *v, int w, int h, int bpp);
int (*mod_connect)(struct xrdp_mod *v); int (*mod_connect)(struct xrdp_mod *v, int fd);
int (*mod_event)(struct xrdp_mod *v, int msg, long param1, long param2, int (*mod_event)(struct xrdp_mod *v, int msg, long param1, long param2,
long param3, long param4); long param3, long param4);
int (*mod_signal)(struct xrdp_mod *v); int (*mod_signal)(struct xrdp_mod *v);
+14 -3
View File
@@ -261,7 +261,7 @@ lib_send_client_info(struct mod *mod)
/******************************************************************************/ /******************************************************************************/
/* return error */ /* return error */
static int static int
lib_mod_connect(struct mod *mod) lib_mod_connect(struct mod *mod, int fd)
{ {
int error; int error;
int socket_mode; int socket_mode;
@@ -356,8 +356,19 @@ lib_mod_connect(struct mod *mod)
mod->trans->no_stream_init_on_data_in = 1; mod->trans->no_stream_init_on_data_in = 1;
mod->trans->extra_flags = 1; mod->trans->extra_flags = 1;
/* Give the X server a bit of time to start */ if (fd >= 0)
error = trans_connect(mod->trans, mod->ip, con_port, 30 * 1000); {
mod->trans->sck = fd;
mod->trans->status = TRANS_STATUS_UP; /* ok */
mod->trans->type1 = TRANS_TYPE_CLIENT; /* client */
error = 0;
}
else
{
/* Give the X server a bit of time to start */
error = trans_connect(mod->trans, mod->ip, con_port, 30 * 1000);
}
if (error == 0) if (error == 0)
{ {
LOG_DEVEL(LOG_LEVEL_INFO, "lib_mod_connect: connected to Xserver " LOG_DEVEL(LOG_LEVEL_INFO, "lib_mod_connect: connected to Xserver "
+1 -1
View File
@@ -53,7 +53,7 @@ struct mod
int version; /* internal version */ int version; /* internal version */
/* client functions */ /* client functions */
int (*mod_start)(struct mod *v, int w, int h, int bpp); int (*mod_start)(struct mod *v, int w, int h, int bpp);
int (*mod_connect)(struct mod *v); int (*mod_connect)(struct mod *v, int fd);
int (*mod_event)(struct mod *v, int msg, tbus param1, tbus param2, int (*mod_event)(struct mod *v, int msg, tbus param1, tbus param2,
tbus param3, tbus param4); tbus param3, tbus param4);
int (*mod_signal)(struct mod *v); int (*mod_signal)(struct mod *v);