Replace X11 display number with a display string
As far as possible, use of the X11 display number is kept to X11-specific routines. This is to make it easier to restructure the code to add non-X11 display support.
This commit is contained in:
+17
-10
@@ -273,7 +273,7 @@ eicp_send_logout_request(struct trans *trans)
|
||||
|
||||
int
|
||||
eicp_send_create_session_request(struct trans *trans,
|
||||
unsigned int display,
|
||||
int x11_display,
|
||||
enum scp_session_type type,
|
||||
unsigned short width,
|
||||
unsigned short height,
|
||||
@@ -285,8 +285,8 @@ eicp_send_create_session_request(struct trans *trans,
|
||||
return libipm_msg_out_simple_send(
|
||||
trans,
|
||||
(int)E_EICP_CREATE_SESSION_REQUEST,
|
||||
"uyqqysss",
|
||||
display,
|
||||
"iyqqysss",
|
||||
x11_display,
|
||||
type,
|
||||
width,
|
||||
height,
|
||||
@@ -300,7 +300,7 @@ eicp_send_create_session_request(struct trans *trans,
|
||||
|
||||
int
|
||||
eicp_get_create_session_request(struct trans *trans,
|
||||
unsigned int *display,
|
||||
int *x11_display,
|
||||
enum scp_session_type *type,
|
||||
unsigned short *width,
|
||||
unsigned short *height,
|
||||
@@ -310,7 +310,7 @@ eicp_get_create_session_request(struct trans *trans,
|
||||
const char **instance_name)
|
||||
{
|
||||
/* Intermediate values */
|
||||
uint32_t i_display;
|
||||
int32_t i_x11_display;
|
||||
uint8_t i_type;
|
||||
uint16_t i_width;
|
||||
uint16_t i_height;
|
||||
@@ -318,8 +318,8 @@ eicp_get_create_session_request(struct trans *trans,
|
||||
|
||||
int rv = libipm_msg_in_parse(
|
||||
trans,
|
||||
"uyqqysss",
|
||||
&i_display,
|
||||
"iyqqysss",
|
||||
&i_x11_display,
|
||||
&i_type,
|
||||
&i_width,
|
||||
&i_height,
|
||||
@@ -330,7 +330,7 @@ eicp_get_create_session_request(struct trans *trans,
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
*display = i_display;
|
||||
*x11_display = i_x11_display;
|
||||
*type = (enum scp_session_type)i_type;
|
||||
*width = i_width;
|
||||
*height = i_height;
|
||||
@@ -345,12 +345,13 @@ eicp_get_create_session_request(struct trans *trans,
|
||||
int
|
||||
eicp_send_create_session_response(struct trans *trans,
|
||||
enum scp_screate_status status,
|
||||
const char *display,
|
||||
const struct guid *guid)
|
||||
{
|
||||
struct libipm_fsb guid_descriptor = { (void *)guid, sizeof(*guid) };
|
||||
return libipm_msg_out_simple_send(
|
||||
trans, (int)E_EICP_CREATE_SESSION_RESPONSE,
|
||||
"iB", status, &guid_descriptor);
|
||||
"isB", status, display, &guid_descriptor);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -358,6 +359,7 @@ eicp_send_create_session_response(struct trans *trans,
|
||||
int
|
||||
eicp_get_create_session_response(struct trans *trans,
|
||||
enum scp_screate_status *status,
|
||||
const char **display,
|
||||
struct guid *guid)
|
||||
{
|
||||
/* Intermediate values */
|
||||
@@ -366,14 +368,19 @@ eicp_get_create_session_response(struct trans *trans,
|
||||
const struct libipm_fsb guid_descriptor = { (void *)guid, sizeof(*guid) };
|
||||
int rv = libipm_msg_in_parse(
|
||||
trans,
|
||||
"iB",
|
||||
"isB",
|
||||
&i_status,
|
||||
display,
|
||||
&guid_descriptor);
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
*status = (enum scp_screate_status)i_status;
|
||||
}
|
||||
else
|
||||
{
|
||||
*display = "";
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
+10
-4
@@ -272,7 +272,7 @@ eicp_send_logout_request(struct trans *trans);
|
||||
* Send an E_EICP_CREATE_SESSION_REQUEST (sesman)
|
||||
*
|
||||
* @param trans EICP transport
|
||||
* @param display X display number to use
|
||||
* @param x11_display X display number to use, or -1 if not X11
|
||||
* @param type Session type
|
||||
* @param width Initial session width
|
||||
* @param height Initial session height
|
||||
@@ -293,7 +293,7 @@ eicp_send_logout_request(struct trans *trans);
|
||||
*/
|
||||
int
|
||||
eicp_send_create_session_request(struct trans *trans,
|
||||
unsigned int display,
|
||||
int x11_display,
|
||||
enum scp_session_type type,
|
||||
unsigned short width,
|
||||
unsigned short height,
|
||||
@@ -307,7 +307,7 @@ eicp_send_create_session_request(struct trans *trans,
|
||||
* Parse an incoming E_EICP_CREATE_SESSION_REQUEST (sesexec)
|
||||
*
|
||||
* @param trans EICP transport
|
||||
* @param[out] display X display number to use
|
||||
* @param[out] x11_display X display number to use
|
||||
* @param[out] type Session type
|
||||
* @param[out] width Initial session width
|
||||
* @param[out] height Initial session height
|
||||
@@ -322,7 +322,7 @@ eicp_send_create_session_request(struct trans *trans,
|
||||
*/
|
||||
int
|
||||
eicp_get_create_session_request(struct trans *trans,
|
||||
unsigned int *display,
|
||||
int *x11_display,
|
||||
enum scp_session_type *type,
|
||||
unsigned short *width,
|
||||
unsigned short *height,
|
||||
@@ -340,12 +340,15 @@ eicp_get_create_session_request(struct trans *trans,
|
||||
*
|
||||
* @param trans EICP transport
|
||||
* @param status Status of creation request
|
||||
* @param display Display name, either (e.g.) "X11-n" (X11)
|
||||
* or "wayland-n" (Wayland)
|
||||
* @param guid GUID of session
|
||||
* @return != 0 for error
|
||||
*/
|
||||
int
|
||||
eicp_send_create_session_response(struct trans *trans,
|
||||
enum scp_screate_status status,
|
||||
const char *display,
|
||||
const struct guid *guid);
|
||||
|
||||
|
||||
@@ -358,12 +361,15 @@ eicp_send_create_session_response(struct trans *trans,
|
||||
*
|
||||
* @param trans EICP transport
|
||||
* @param[out] status Status of creation request
|
||||
* @param[out] display Display name, either (e.g.) "X11-n" (X11)
|
||||
* or "wayland-n" (Wayland)
|
||||
* @param[out] guid GUID of session
|
||||
* @return != 0 for error
|
||||
*/
|
||||
int
|
||||
eicp_get_create_session_response(struct trans *trans,
|
||||
enum scp_screate_status *status,
|
||||
const char **display,
|
||||
struct guid *guid);
|
||||
|
||||
#endif /* EICP_H */
|
||||
|
||||
+9
-7
@@ -147,7 +147,7 @@ ercp_msg_in_reset(struct trans *trans)
|
||||
|
||||
int
|
||||
ercp_send_session_announce_event(struct trans *trans,
|
||||
unsigned int display,
|
||||
const char *display,
|
||||
uid_t uid,
|
||||
enum scp_session_type type,
|
||||
unsigned short start_width,
|
||||
@@ -163,7 +163,7 @@ ercp_send_session_announce_event(struct trans *trans,
|
||||
return libipm_msg_out_simple_send(
|
||||
trans,
|
||||
(int)E_ERCP_SESSION_ANNOUNCE_EVENT,
|
||||
"uiyqqyBsxs",
|
||||
"siyqqyBsxs",
|
||||
display,
|
||||
uid,
|
||||
type,
|
||||
@@ -180,7 +180,7 @@ ercp_send_session_announce_event(struct trans *trans,
|
||||
|
||||
int
|
||||
ercp_get_session_announce_event(struct trans *trans,
|
||||
unsigned int *display,
|
||||
const char **display,
|
||||
uid_t *uid,
|
||||
enum scp_session_type *type,
|
||||
unsigned short *start_width,
|
||||
@@ -192,7 +192,6 @@ ercp_get_session_announce_event(struct trans *trans,
|
||||
const char **instance_name)
|
||||
{
|
||||
/* Intermediate values */
|
||||
uint32_t i_display;
|
||||
int32_t i_uid;
|
||||
uint8_t i_type;
|
||||
uint16_t i_width;
|
||||
@@ -204,8 +203,8 @@ ercp_get_session_announce_event(struct trans *trans,
|
||||
|
||||
int rv = libipm_msg_in_parse(
|
||||
trans,
|
||||
"uiyqqyBsxs",
|
||||
&i_display,
|
||||
"siyqqyBsxs",
|
||||
display,
|
||||
&i_uid,
|
||||
&i_type,
|
||||
&i_width,
|
||||
@@ -218,7 +217,6 @@ ercp_get_session_announce_event(struct trans *trans,
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
*display = i_display;
|
||||
*uid = (uid_t)i_uid;
|
||||
*type = (enum scp_session_type)i_type;
|
||||
*start_width = i_width;
|
||||
@@ -226,6 +224,10 @@ ercp_get_session_announce_event(struct trans *trans,
|
||||
*bpp = i_bpp;
|
||||
*start_time = (time_t)i_start_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
*display = "";
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
+2
-2
@@ -177,7 +177,7 @@ ercp_msg_in_reset(struct trans *trans);
|
||||
*/
|
||||
int
|
||||
ercp_send_session_announce_event(struct trans *trans,
|
||||
unsigned int display,
|
||||
const char *display,
|
||||
uid_t uid,
|
||||
enum scp_session_type type,
|
||||
unsigned short start_width,
|
||||
@@ -209,7 +209,7 @@ ercp_send_session_announce_event(struct trans *trans,
|
||||
*/
|
||||
int
|
||||
ercp_get_session_announce_event(struct trans *trans,
|
||||
unsigned int *display,
|
||||
const char **display,
|
||||
uid_t *uid,
|
||||
enum scp_session_type *type,
|
||||
unsigned short *start_width,
|
||||
|
||||
+14
-11
@@ -481,7 +481,7 @@ scp_get_create_session_request(struct trans *trans,
|
||||
int
|
||||
scp_send_create_session_response(struct trans *trans,
|
||||
enum scp_screate_status status,
|
||||
int display,
|
||||
const char *display,
|
||||
const struct guid *guid)
|
||||
{
|
||||
struct libipm_fsb guid_descriptor = { (void *)guid, sizeof(*guid) };
|
||||
@@ -489,7 +489,7 @@ scp_send_create_session_response(struct trans *trans,
|
||||
return libipm_msg_out_simple_send(
|
||||
trans,
|
||||
(int)E_SCP_CREATE_SESSION_RESPONSE,
|
||||
"iiB",
|
||||
"isB",
|
||||
status,
|
||||
display,
|
||||
&guid_descriptor);
|
||||
@@ -500,25 +500,27 @@ scp_send_create_session_response(struct trans *trans,
|
||||
int
|
||||
scp_get_create_session_response(struct trans *trans,
|
||||
enum scp_screate_status *status,
|
||||
int *display,
|
||||
const char **display,
|
||||
struct guid *guid)
|
||||
{
|
||||
/* Intermediate values */
|
||||
int32_t i_status;
|
||||
int32_t i_display;
|
||||
|
||||
const struct libipm_fsb guid_descriptor = { (void *)guid, sizeof(*guid) };
|
||||
|
||||
int rv = libipm_msg_in_parse(
|
||||
trans,
|
||||
"iiB",
|
||||
"isB",
|
||||
&i_status,
|
||||
&i_display,
|
||||
display,
|
||||
&guid_descriptor);
|
||||
if (rv == 0)
|
||||
{
|
||||
*status = (enum scp_screate_status)i_status;
|
||||
*display = i_display;
|
||||
}
|
||||
else
|
||||
{
|
||||
*display = "";
|
||||
}
|
||||
|
||||
return rv;
|
||||
@@ -747,7 +749,7 @@ scp_send_list_sessions_response(
|
||||
rv = libipm_msg_out_simple_send(
|
||||
trans,
|
||||
(int)E_SCP_LIST_SESSIONS_RESPONSE,
|
||||
"iiuyqqyxisssxs",
|
||||
"iisyqqyxisssxs",
|
||||
status,
|
||||
info->sid,
|
||||
info->display,
|
||||
@@ -791,7 +793,7 @@ scp_get_list_sessions_response(
|
||||
if (*status == E_SCP_LS_SESSION_INFO)
|
||||
{
|
||||
int32_t i_sid;
|
||||
uint32_t i_display;
|
||||
char *i_display;
|
||||
uint8_t i_type;
|
||||
uint16_t i_width;
|
||||
uint16_t i_height;
|
||||
@@ -806,7 +808,7 @@ scp_get_list_sessions_response(
|
||||
|
||||
rv = libipm_msg_in_parse(
|
||||
trans,
|
||||
"iuyqqyxisssxs",
|
||||
"isyqqyxisssxs",
|
||||
&i_sid,
|
||||
&i_display,
|
||||
&i_type,
|
||||
@@ -826,6 +828,7 @@ scp_get_list_sessions_response(
|
||||
/* Allocate a block of memory large enough for the
|
||||
* structure result, and the strings it contains */
|
||||
unsigned int len = sizeof(struct scp_session_info) +
|
||||
g_strlen(i_display) + 1 +
|
||||
g_strlen(i_start_ip_addr) + 1 +
|
||||
g_strlen(i_client_ip) + 1 +
|
||||
g_strlen(i_client_name) + 1 +
|
||||
@@ -848,7 +851,7 @@ scp_get_list_sessions_response(
|
||||
}
|
||||
/* Copy the data over */
|
||||
p->sid = i_sid;
|
||||
p->display = i_display;
|
||||
COPY_STRING(p->display, i_display);
|
||||
p->type = (enum scp_session_type)i_type;
|
||||
p->width = i_width;
|
||||
p->height = i_height;
|
||||
|
||||
+6
-4
@@ -391,15 +391,17 @@ scp_get_create_session_request(struct trans *trans,
|
||||
*
|
||||
* @param trans SCP transport
|
||||
* @param status Status of creation request
|
||||
* @param display Should be zero if create session failed.
|
||||
* @param display Will be "" if create session failed
|
||||
* @param guid Guid for session. Should be all zeros if create session failed
|
||||
*
|
||||
* @return != 0 for error
|
||||
*
|
||||
* The display will be either "X11-n" (X11) or (e.g) "wayland-0" (Wayland)
|
||||
*/
|
||||
int
|
||||
scp_send_create_session_response(struct trans *trans,
|
||||
enum scp_screate_status status,
|
||||
int display,
|
||||
const char *display,
|
||||
const struct guid *guid);
|
||||
|
||||
|
||||
@@ -408,7 +410,7 @@ scp_send_create_session_response(struct trans *trans,
|
||||
*
|
||||
* @param trans SCP transport
|
||||
* @param[out] status Status of creation request
|
||||
* @param[out] display Should be zero if create session failed.
|
||||
* @param[out] display Will be "" if create session failed
|
||||
* @param[out] guid Guid for session. Should be all zeros if create session
|
||||
* failed
|
||||
*
|
||||
@@ -417,7 +419,7 @@ scp_send_create_session_response(struct trans *trans,
|
||||
int
|
||||
scp_get_create_session_response(struct trans *trans,
|
||||
enum scp_screate_status *status,
|
||||
int *display,
|
||||
const char **display,
|
||||
struct guid *guid);
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,13 +45,16 @@ enum scp_session_type
|
||||
"unknown" \
|
||||
)
|
||||
|
||||
#define SCP_SESSION_TYPE_IS_X11(t) \
|
||||
((t) >= SCP_SESSION_TYPE_XVNC && (t) <= SCP_SESSION_TYPE_XORG)
|
||||
|
||||
/**
|
||||
* @brief Information to display about a particular sesman session
|
||||
*/
|
||||
struct scp_session_info
|
||||
{
|
||||
int sid; ///< Session ID
|
||||
unsigned int display; ///< Display number
|
||||
char *display; ///< Display name ("X11-n" or "wayland-n")
|
||||
enum scp_session_type type; ///< Session type
|
||||
unsigned short width; ///< Initial session width
|
||||
unsigned short height; ///< Initial session height
|
||||
|
||||
Reference in New Issue
Block a user