format code

This commit is contained in:
seflerZ 2024-04-17 13:56:52 +08:00 committed by sefler
parent d4e2e0a093
commit 3b1cc551e4
4 changed files with 73 additions and 74 deletions

View File

@ -21,6 +21,10 @@
#include <config_ac.h>
#endif
#ifdef XRDP_IBUS
#include "input.h"
#endif
#include "arch.h"
#include "os_calls.h"
#include "string_calls.h"
@ -40,7 +44,6 @@
#include "chansrv_config.h"
#include "xrdp_sockets.h"
#include "audin.h"
#include "input.h"
#include "ms-rdpbcgr.h"

View File

@ -30,7 +30,7 @@
static IBusBus *bus;
static IBusEngine *g_engine;
// This is the engine name enabled before unicode engine enabled
/* This is the engine name enabled before unicode engine enabled */
static const gchar *ori_name;
static int id = 0;
@ -42,7 +42,7 @@ xrdp_input_enable()
if (ori_name)
{
// already enabled
/* already enabled */
return 0;
}
@ -59,7 +59,7 @@ xrdp_input_enable()
return 0;
}
// remember user's input method, will switch back when disconnect
/* remember user's input method, will switch back when disconnect */
ori_name = name;
if (!ibus_bus_set_global_engine(bus, "XrdpIme"))
@ -115,14 +115,14 @@ gboolean engine_process_key_event_cb(IBusEngine *engine,
guint keycode,
guint state)
{
// Pass the keyboard event to system
/* Pass the keyboard event to system */
return FALSE;
}
IBusEngine *
xrdp_input_ibus_create_engine(IBusFactory *factory,
gchar *engine_name,
gpointer user_data)
gchar *engine_name,
gpointer user_data)
{
IBusEngine *engine;
gchar *path = g_strdup_printf("/org/freedesktop/IBus/Engine/%i", 1);
@ -160,23 +160,23 @@ xrdp_input_main_loop()
ibus_factory_add_engine(factory, "XrdpIme", IBUS_TYPE_ENGINE);
component = ibus_component_new("org.freedesktop.IBus.XrdpIme", // name
"Xrdp input method", // description
"1.1", // version
"MIT", // license
"seflerZ", // author
"fake_page", // homepage
"/exec/fake_path", // cmd
"xrdpime"); // text domain
component = ibus_component_new("org.freedesktop.IBus.XrdpIme", /* name */
"Xrdp input method", /* description */
"1.1", /* version */
"MIT", /* license */
"seflerZ", /* author */
"default", /* homepage */
"default", /* cmd */
"xrdpime"); /* text domain */
desc = ibus_engine_desc_new("XrdpIme",
"unicode input method for xrdp",
"unicode input method for xrdp",
"unicode",
"MIT",
"seflerZ",
"fake_icon.png",
"default"); // layout
"unicode input method for xrdp",
"unicode input method for xrdp",
"unicode",
"MIT",
"seflerZ",
"default", /* icon */
"default"); /* layout */
ibus_component_add_engine(component, desc);
ibus_bus_register_component(bus, component);
@ -213,16 +213,15 @@ xrdp_input_unicode_destory()
int
xrdp_input_unicode_init()
{
int retry = 10;
if (bus)
{
// Already initialized, just re-enable it
/* Already initialized, just re-enable it */
xrdp_input_enable();
return 0;
}
sleep(5);
/* Wait becasue ibus daemon may not be ready in first login. Do we have a flag to avoid busy waiting? */
sleep(3);
LOG(LOG_LEVEL_INFO, "xrdp_ibus_init: Initializing the iBus engine");
ibus_init();
@ -239,20 +238,9 @@ xrdp_input_unicode_init()
tc_thread_create(xrdp_input_main_loop, NULL);
// session may not be ready, repeat until input method enabled
while (retry--)
if (!ibus_bus_get_global_engine(bus))
{
if (ibus_bus_get_global_engine(bus))
{
break;
}
sleep(1);
}
if (retry == 0)
{
LOG(LOG_LEVEL_ERROR, "xrdp_ibus_init: failed to connect to ibus");
LOG(LOG_LEVEL_ERROR, "xrdp_ibus_init: failed to get origin global engine");
return 1;
}

View File

@ -42,8 +42,11 @@ static int
xrdp_mm_chansrv_connect(struct xrdp_mm *self, const char *port);
static void
xrdp_mm_connect_sm(struct xrdp_mm *self);
#ifdef XRDP_IBUS
static int
xrdp_mm_send_unicode_shutdown(struct xrdp_mm *self, struct trans *trans);
#endif
/*****************************************************************************/
struct xrdp_mm *
@ -148,8 +151,10 @@ xrdp_mm_delete(struct xrdp_mm *self)
return;
}
#ifdef XRDP_IBUS
/* shutdown input method */
xrdp_mm_send_unicode_shutdown(self, self->chan_trans);
#endif
/* free any module stuff */
xrdp_mm_module_cleanup(self);
@ -662,7 +667,7 @@ xrdp_mm_trans_process_channel_data(struct xrdp_mm *self, struct stream *s)
return rv;
}
#ifdef XRDP_IBUS
/*****************************************************************************/
static int
xrdp_mm_send_unicode_shutdown(struct xrdp_mm *self, struct trans *trans)
@ -673,10 +678,10 @@ xrdp_mm_send_unicode_shutdown(struct xrdp_mm *self, struct trans *trans)
return 1;
}
out_uint32_le(s, 0); /* version */
out_uint32_le(s, 0); /* version */
out_uint32_le(s, 8 + 8); /* size */
out_uint32_le(s, 25); /* msg id */
out_uint32_le(s, 8); /* size */
out_uint32_le(s, 25); /* msg id */
out_uint32_le(s, 8); /* size */
s_mark_end(s);
return trans_write_copy(self->chan_trans);
@ -701,6 +706,27 @@ xrdp_mm_send_unicode_setup(struct xrdp_mm *self, struct trans *trans)
return trans_write_copy(self->chan_trans);
}
/******************************************************************************/
int xrdp_mm_send_unicode_to_chansrv(struct xrdp_mm *self,
int key_down,
char32_t unicode)
{
struct stream *s = trans_get_out_s(self->chan_trans, 8192);
if (s == NULL)
{
return 1;
}
out_uint32_le(s, 0); /* version */
out_uint32_le(s, 24); /* size */
out_uint32_le(s, 23); /* msg id */
out_uint32_le(s, 16); /* size */
out_uint32_le(s, key_down);
out_uint32_le(s, unicode);
s_mark_end(s);
return trans_write_copy(self->chan_trans);
}
#endif
/*****************************************************************************/
/* returns error
process rail create window order */
@ -2147,26 +2173,6 @@ xrdp_mm_up_and_running(struct xrdp_mm *self)
return 0;
}
/******************************************************************************/
int xrdp_mm_send_unicode_to_chansrv(struct xrdp_mm *self,
int key_down,
char32_t unicode)
{
struct stream *s = trans_get_out_s(self->chan_trans, 8192);
if (s == NULL)
{
return 1;
}
out_uint32_le(s, 0); /* version */
out_uint32_le(s, 24); /* size */
out_uint32_le(s, 23); /* msg id */
out_uint32_le(s, 16); /* size */
out_uint32_le(s, key_down);
out_uint32_le(s, unicode);
s_mark_end(s);
return trans_write_copy(self->chan_trans);
}
/*****************************************************************************/
/* open response from client going to channel server */
static int
@ -3034,21 +3040,23 @@ xrdp_mm_chansrv_connect(struct xrdp_mm *self, const char *port)
"connect successful");
}
#ifdef XRDP_IBUS
/* if client supports unicode input, initialize the input method */
if (1)
{
LOG(LOG_LEVEL_INFO, "xrdp_mm_chansrv_connect: chansrv "
"client support unicode input, init the input method");
"client support unicode input, init the input method");
if (xrdp_mm_send_unicode_setup(self, self->chan_trans) != 0)
{
LOG(LOG_LEVEL_ERROR, "xrdp_mm_chansrv_connect: error in "
"xrdp_mm_send_unicode_setup");
"xrdp_mm_send_unicode_setup");
/* disable unicode input */
// self->wm->client_info->unicode_input = 0;
}
}
#endif
return 0;
}

View File

@ -1801,7 +1801,7 @@ xrdp_wm_key_unicode(struct xrdp_wm *self, int device_flags, char32_t c16)
#ifdef XRDP_IBUS
if (self->mm->chan_trans != NULL &&
self->mm->chan_trans->status == TRANS_STATUS_UP)
self->mm->chan_trans->status == TRANS_STATUS_UP)
{
xrdp_mm_send_unicode_to_chansrv(self->mm,
!(device_flags & KBD_FLAG_UP), c32);