Skip to content

Commit

Permalink
refactoring codes
Browse files Browse the repository at this point in the history
  • Loading branch information
seflerZ committed Apr 14, 2024
1 parent b0dea18 commit 942513b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 24 deletions.
1 change: 0 additions & 1 deletion common/xrdp_client_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ struct xrdp_client_info

int keyboard_type;
int keyboard_subtype;
// int use_unicode_input; /* 0 = no , 1 = yes */

int png_codec_id;
int png_prop_len;
Expand Down
1 change: 0 additions & 1 deletion libxrdp/xrdp_caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ xrdp_caps_process_input(struct xrdp_rdp *self, struct stream *s,
{
self->client_info.use_fast_path &= ~2;
}

return 0;
}

Expand Down
3 changes: 3 additions & 0 deletions sesman/chansrv/chansrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,14 @@ send_rail_drawing_orders(char *data, int size)
return 0;
}

/*****************************************************************************/
static int
process_message_unicode_setup(struct stream *s)
{
return xrdp_input_unicode_init();
}

/*****************************************************************************/
static int
process_message_unicode_shutdown(struct stream *s)
{
Expand Down Expand Up @@ -831,6 +833,7 @@ chansrv_drdynvc_send_data(int chan_id, const char *data, int data_bytes)
return 0;
}

/*****************************************************************************/
static int
process_message_unicode_data(struct stream *s)
{
Expand Down
59 changes: 37 additions & 22 deletions sesman/chansrv/input_ibus.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2009-2013
* Copyright (C) Laxmikant Rashinkar 2009-2012
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#if defined(HAVE_CONFIG_H)
#include <config_ac.h>
#endif
Expand Down Expand Up @@ -29,7 +48,7 @@ xrdp_input_enable()

if (!bus)
{
LOG(LOG_LEVEL_INFO, "xrdp_ibus_init: input method switched failed, ibus not connected");
LOG(LOG_LEVEL_ERROR, "xrdp_ibus_init: input method switched failed, ibus not connected");
return 1;
}

Expand All @@ -45,7 +64,7 @@ xrdp_input_enable()

if (!ibus_bus_set_global_engine(bus, "XrdpIme"))
{
LOG(LOG_LEVEL_INFO, "xrdp_input_enable: input method enable failed");
LOG(LOG_LEVEL_ERROR, "xrdp_input_enable: input method enable failed");
return 1;
}

Expand All @@ -57,7 +76,7 @@ xrdp_input_enable()
int
xrdp_input_send_unicode(uint32_t unicode)
{
LOG(LOG_LEVEL_INFO, "xrdp_input_send_unicode: received unicode input %i", unicode);
LOG(LOG_LEVEL_DEBUG, "xrdp_input_send_unicode: received unicode input %i", unicode);

if (xrdp_input_enable())
{
Expand Down Expand Up @@ -96,10 +115,6 @@ gboolean engine_process_key_event_cb(IBusEngine *engine,
guint keycode,
guint state)
{
if(state & IBUS_RELEASE_MASK) {
return FALSE;
}

// Pass the keyboard event to system
return FALSE;
}
Expand All @@ -115,7 +130,7 @@ xrdp_input_ibus_create_engine(IBusFactory *factory,
path,
ibus_bus_get_connection(bus));

LOG(LOG_LEVEL_INFO, "xrdp_input_ibus_create_engine: Creating IM Engine with name:%s and id:%d\n", engine_name, ++id);
LOG(LOG_LEVEL_DEBUG, "xrdp_input_ibus_create_engine: Creating IM Engine with name:%s and id:%d\n", engine_name, ++id);

g_signal_connect(engine, "process-key-event", G_CALLBACK(engine_process_key_event_cb), NULL);
g_signal_connect(engine, "enable", G_CALLBACK(xrdp_input_ibus_engine_enable), NULL);
Expand All @@ -133,7 +148,7 @@ xrdp_input_main_loop()
IBusEngineDesc *desc;
THREAD_RV rv = 0;

LOG(LOG_LEVEL_INFO, "xrdp_input_main_loop: Entering ibus loop");
LOG(LOG_LEVEL_DEBUG, "xrdp_input_main_loop: Entering ibus loop");

g_signal_connect(bus, "disconnected", G_CALLBACK(xrdp_input_ibus_disconnect), NULL);

Expand All @@ -145,14 +160,14 @@ xrdp_input_main_loop()

ibus_factory_add_engine(factory, "XrdpIme", IBUS_TYPE_ENGINE);

component = ibus_component_new("org.freedesktop.IBus.XrdpIme",
"Xrdp input method",
"1.1",
"MIT",
"seflerZ",
"fake_icon",
"/exec/fake_path",
"xrdpime");
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

desc = ibus_engine_desc_new("XrdpIme",
"unicode input method for xrdp",
Expand All @@ -161,7 +176,7 @@ xrdp_input_main_loop()
"MIT",
"seflerZ",
"fake_icon.png",
"default");
"default"); // layout

ibus_component_add_engine(component, desc);
ibus_bus_register_component(bus, component);
Expand All @@ -178,7 +193,7 @@ xrdp_input_main_loop()
int
xrdp_input_unicode_destory()
{
LOG(LOG_LEVEL_INFO, "xrdp_input_unicode_destory: ibus input is under destory");
LOG(LOG_LEVEL_DEBUG, "xrdp_input_unicode_destory: ibus input is under destory");
if (ori_name)
{
LOG(LOG_LEVEL_INFO, "xrdp_input_unicode_destory: ibus engine rolling back to origin: %s", ori_name);
Expand Down Expand Up @@ -207,14 +222,14 @@ xrdp_input_unicode_init()
return 0;
}

LOG(LOG_LEVEL_INFO, "xrdp_ibus_init: Initializing the iBus engine");
LOG(LOG_LEVEL_DEBUG, "xrdp_ibus_init: Initializing the iBus engine");
ibus_init();
bus = ibus_bus_new();
g_object_ref_sink(bus);

if (!ibus_bus_is_connected(bus))
{
LOG(LOG_LEVEL_INFO, "xrdp_ibus_init: Connect to iBus failed");
LOG(LOG_LEVEL_ERROR, "xrdp_ibus_init: Connect to iBus failed");
return 1;
}

Expand All @@ -235,7 +250,7 @@ xrdp_input_unicode_init()

if (retry == 0)
{
LOG(LOG_LEVEL_INFO, "xrdp_ibus_init: failed to connect to ibus");
LOG(LOG_LEVEL_ERROR, "xrdp_ibus_init: failed to connect to ibus");
return 1;
}

Expand Down
2 changes: 2 additions & 0 deletions xrdp/xrdp_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,8 @@ xrdp_mm_drdynvc_data(intptr_t id, int chan_id, char *data, int bytes)
return trans_write_copy(trans);
}

/*****************************************************************************/
/* open message from channel server going to client */
int
xrdp_mm_send_unicode_to_chansrv(struct xrdp_mm *self,
int key_down,
Expand Down

0 comments on commit 942513b

Please sign in to comment.