1 /** @file scim_panel.cpp
2 * @brief Implementation of class PanelAgent.
5 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
8 * Smart Common Input Method
10 * Copyright (c) 2005 James Su <suzhe@tsinghua.org.cn>
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this program; if not, write to the
25 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
26 * Boston, MA 02111-1307 USA
28 * $Id: scim_panel_agent.cpp,v 1.8.2.1 2006/01/09 14:32:18 suzhe Exp $
32 #define Uses_SCIM_TRANSACTION
33 #define Uses_SCIM_TRANS_COMMANDS
34 #define Uses_SCIM_PANEL_AGENT
35 #define Uses_SCIM_HELPER
36 #define Uses_SCIM_SOCKET
37 #define Uses_SCIM_EVENT
38 #define Uses_SCIM_CONFIG
39 #define Uses_SCIM_CONFIG_MODULE
40 #define Uses_SCIM_CONFIG_PATH
41 #define Uses_SCIM_UTILITY
44 #include <sys/types.h>
46 #include "scim_private.h"
48 #include "scim_stl_map.h"
51 scim::CommonLookupTable g_isf_candidate_table;
59 typedef Signal1<void, int>
62 typedef Signal1<void, const String &>
63 PanelAgentSignalString;
65 typedef Signal2<void, const String &, bool>
66 PanelAgentSignalStringBool;
68 typedef Signal2<void, String &, String &>
69 PanelAgentSignalString2;
71 typedef Signal2<void, int, const String &>
72 PanelAgentSignalIntString;
74 typedef Signal1<void, const PanelFactoryInfo &>
75 PanelAgentSignalFactoryInfo;
77 typedef Signal1<void, const std::vector <PanelFactoryInfo> &>
78 PanelAgentSignalFactoryInfoVector;
80 typedef Signal1<void, const LookupTable &>
81 PanelAgentSignalLookupTable;
83 typedef Signal1<void, const Property &>
84 PanelAgentSignalProperty;
86 typedef Signal1<void, const PropertyList &>
87 PanelAgentSignalPropertyList;
89 typedef Signal2<void, int, int>
90 PanelAgentSignalIntInt;
92 typedef Signal2<void, int &, int &>
93 PanelAgentSignalIntInt2;
95 typedef Signal3<void, int, int, int>
96 PanelAgentSignalIntIntInt;
98 typedef Signal4<void, int, int, int, int>
99 PanelAgentSignalIntIntIntInt;
101 typedef Signal2<void, int, const Property &>
102 PanelAgentSignalIntProperty;
104 typedef Signal2<void, int, const PropertyList &>
105 PanelAgentSignalIntPropertyList;
107 typedef Signal2<void, int, const HelperInfo &>
108 PanelAgentSignalIntHelperInfo;
110 typedef Signal2<void, const String &, const AttributeList &>
111 PanelAgentSignalAttributeString;
113 typedef Signal1<void, std::vector <String> &>
114 PanelAgentSignalStringVector;
116 typedef Signal1<bool, std::vector <String> &>
117 PanelAgentSignalBoolStringVector;
119 typedef Signal2<void, char *, std::vector <String> &>
120 PanelAgentSignalStrStringVector;
122 typedef Signal2<bool, const String &, ISE_INFO &>
123 PanelAgentSignalStringISEINFO;
125 typedef Signal1<void, const KeyEvent &>
126 PanelAgentSignalKeyEvent;
128 typedef Signal1<void, struct rectinfo &>
129 PanelAgentSignalRect;
136 IMCONTROL_ACT_CLIENT,
145 struct HelperClientStub {
149 HelperClientStub (int i = 0, int r = 0) : id (i), ref (r) { }
152 struct IMControlStub {
153 std::vector<ISE_INFO> info;
154 std::vector<int> count;
157 static int _id_count = -4;
159 #define DEFAULT_CONTEXT_VALUE 0xfff
161 #if SCIM_USE_STL_EXT_HASH_MAP
162 typedef __gnu_cxx::hash_map <int, ClientInfo, __gnu_cxx::hash <int> > ClientRepository;
163 typedef __gnu_cxx::hash_map <int, HelperInfo, __gnu_cxx::hash <int> > HelperInfoRepository;
164 typedef __gnu_cxx::hash_map <uint32, String, __gnu_cxx::hash <unsigned int> > ClientContextUUIDRepository;
165 typedef __gnu_cxx::hash_map <String, HelperClientStub, scim_hash_string> HelperClientIndex;
166 typedef __gnu_cxx::hash_map <String, std::vector < std::pair <uint32, String> >, scim_hash_string> StartHelperICIndex;
167 #elif SCIM_USE_STL_HASH_MAP
168 typedef std::hash_map <int, ClientInfo, std::hash <int> > ClientRepository;
169 typedef std::hash_map <int, HelperInfo, std::hash <int> > HelperInfoRepository;
170 typedef std::hash_map <uint32, String, std::hash <unsigned int> > ClientContextUUIDRepository;
171 typedef std::hash_map <String, HelperClientStub, scim_hash_string> HelperClientIndex;
172 typedef std::hash_map <String, std::vector < std::pair <uint32, String> >, scim_hash_string> StartHelperICIndex;
174 typedef std::map <int, ClientInfo> ClientRepository;
175 typedef std::map <int, HelperInfo> HelperInfoRepository;
176 typedef std::map <uint32, String> ClientContextUUIDRepository;
177 typedef std::map <String, HelperClientStub> HelperClientIndex;
178 typedef std::map <String, std::vector < std::pair <uint32, String> > > StartHelperICIndex;
181 typedef std::map <String, uint32> UUIDCountRepository;
182 typedef std::map <String, enum HelperState> UUIDStateRepository;
183 typedef std::map <String, int> StringIntRepository;
184 typedef std::map <int, struct IMControlStub> IMControlRepository;
185 typedef std::map <int, int> IntIntRepository;
188 get_helper_ic (int client, uint32 context)
190 return (uint32) (client & 0xFFFF) | ((context & 0x7FFF) << 16);
194 get_imengine_client_context (uint32 helper_ic, int &client, uint32 &context)
196 client = (int) (helper_ic & 0xFFFF);
197 context = ((helper_ic >> 16) & 0x7FFF);
200 //==================================== PanelAgent ===========================
201 class PanelAgent::PanelAgentImpl
204 bool m_should_resident;
206 int m_current_screen;
208 String m_config_name;
209 String m_display_name;
211 int m_socket_timeout;
212 String m_socket_address;
213 SocketServer m_socket_server;
215 Transaction m_send_trans;
216 Transaction m_recv_trans;
217 Transaction m_nest_trans;
219 int m_current_socket_client;
220 uint32 m_current_client_context;
221 String m_current_context_uuid;
222 TOOLBAR_MODE_T m_current_toolbar_mode;
223 String m_current_factory_icon;
224 String m_current_helper_uuid;
225 String m_last_helper_uuid;
226 String m_current_ise_name;
227 uint32 m_current_ise_style;
228 int m_current_active_imcontrol_id;
229 int m_pending_active_imcontrol_id;
230 IntIntRepository m_imcontrol_map;
231 DEFAULT_ISE_T m_default_ise;
232 bool m_should_shared_ise;
233 char * m_ise_settings;
234 size_t m_ise_settings_len;
238 int m_last_socket_client;
239 uint32 m_last_client_context;
240 String m_last_context_uuid;
242 ClientRepository m_client_repository;
244 * Each Helper ISE has two socket connect between PanelAgent and HelperAgent.
245 * m_helper_info_repository records the active connection.
246 * m_helper_active_info_repository records the passive connection.
248 HelperInfoRepository m_helper_info_repository;
249 HelperInfoRepository m_helper_active_info_repository;
250 HelperClientIndex m_helper_client_index;
252 /* when helper register, notify imcontrol client */
253 StringIntRepository m_ise_pending_repository;
254 IMControlRepository m_imcontrol_repository;
256 StartHelperICIndex m_start_helper_ic_index;
259 ClientContextUUIDRepository m_client_context_uuids;
262 ClientContextUUIDRepository m_client_context_helper;
263 UUIDCountRepository m_helper_uuid_count;
264 UUIDStateRepository m_helper_uuid_state;
266 HelperManager m_helper_manager;
268 PanelAgentSignalVoid m_signal_reload_config;
269 PanelAgentSignalVoid m_signal_turn_on;
270 PanelAgentSignalVoid m_signal_turn_off;
271 PanelAgentSignalVoid m_signal_show_panel;
272 PanelAgentSignalVoid m_signal_hide_panel;
273 PanelAgentSignalInt m_signal_update_screen;
274 PanelAgentSignalIntIntInt m_signal_update_spot_location;
275 PanelAgentSignalFactoryInfo m_signal_update_factory_info;
276 PanelAgentSignalVoid m_signal_start_default_ise;
277 PanelAgentSignalIntInt m_signal_update_input_context;
278 PanelAgentSignalIntInt m_signal_set_candidate_ui;
279 PanelAgentSignalIntInt2 m_signal_get_candidate_ui;
280 PanelAgentSignalIntInt m_signal_set_candidate_position;
281 PanelAgentSignalRect m_signal_get_candidate_geometry;
282 PanelAgentSignalRect m_signal_get_input_panel_geometry;
283 PanelAgentSignalIntString m_signal_set_keyboard_ise;
284 PanelAgentSignalString2 m_signal_get_keyboard_ise;
285 PanelAgentSignalString m_signal_show_help;
286 PanelAgentSignalFactoryInfoVector m_signal_show_factory_menu;
287 PanelAgentSignalVoid m_signal_show_preedit_string;
288 PanelAgentSignalVoid m_signal_show_aux_string;
289 PanelAgentSignalVoid m_signal_show_lookup_table;
290 PanelAgentSignalVoid m_signal_show_associate_table;
291 PanelAgentSignalVoid m_signal_hide_preedit_string;
292 PanelAgentSignalVoid m_signal_hide_aux_string;
293 PanelAgentSignalVoid m_signal_hide_lookup_table;
294 PanelAgentSignalVoid m_signal_hide_associate_table;
295 PanelAgentSignalAttributeString m_signal_update_preedit_string;
296 PanelAgentSignalInt m_signal_update_preedit_caret;
297 PanelAgentSignalAttributeString m_signal_update_aux_string;
298 PanelAgentSignalLookupTable m_signal_update_lookup_table;
299 PanelAgentSignalLookupTable m_signal_update_associate_table;
300 PanelAgentSignalPropertyList m_signal_register_properties;
301 PanelAgentSignalProperty m_signal_update_property;
302 PanelAgentSignalIntPropertyList m_signal_register_helper_properties;
303 PanelAgentSignalIntProperty m_signal_update_helper_property;
304 PanelAgentSignalIntHelperInfo m_signal_register_helper;
305 PanelAgentSignalInt m_signal_remove_helper;
306 PanelAgentSignalStringBool m_signal_set_active_ise_by_uuid;
307 PanelAgentSignalString m_signal_set_active_ise_by_name;
308 PanelAgentSignalVoid m_signal_focus_in;
309 PanelAgentSignalVoid m_signal_focus_out;
310 PanelAgentSignalVoid m_signal_expand_candidate;
311 PanelAgentSignalVoid m_signal_contract_candidate;
312 PanelAgentSignalBoolStringVector m_signal_get_ise_list;
313 PanelAgentSignalBoolStringVector m_signal_get_keyboard_ise_list;
314 PanelAgentSignalIntIntIntInt m_signal_update_ise_geometry;
315 PanelAgentSignalStringVector m_signal_get_language_list;
316 PanelAgentSignalStringVector m_signal_get_all_language;
317 PanelAgentSignalStrStringVector m_signal_get_ise_language;
318 PanelAgentSignalString m_signal_set_isf_language;
319 PanelAgentSignalStringISEINFO m_signal_get_ise_info_by_uuid;
320 PanelAgentSignalStringISEINFO m_signal_get_ise_info_by_name;
321 PanelAgentSignalKeyEvent m_signal_send_key_event;
323 PanelAgentSignalInt m_signal_accept_connection;
324 PanelAgentSignalInt m_signal_close_connection;
325 PanelAgentSignalVoid m_signal_exit;
327 PanelAgentSignalVoid m_signal_transaction_start;
328 PanelAgentSignalVoid m_signal_transaction_end;
330 PanelAgentSignalVoid m_signal_lock;
331 PanelAgentSignalVoid m_signal_unlock;
335 : m_should_exit (false),
336 m_should_resident (false),
337 m_current_screen (0),
338 m_socket_timeout (scim_get_default_socket_timeout ()),
339 m_current_socket_client (-1), m_current_client_context (0),
340 m_current_toolbar_mode (TOOLBAR_KEYBOARD_MODE),
341 m_current_ise_style (0),
342 m_current_active_imcontrol_id (-1), m_pending_active_imcontrol_id (-1),
343 m_should_shared_ise (false),
344 m_ise_settings (NULL), m_ise_settings_len (0),
345 m_ise_changing (false), m_ise_exiting (false),
346 m_last_socket_client (-1), m_last_client_context (0)
348 m_current_ise_name = String (_("English/Keyboard"));
349 m_imcontrol_repository.clear ();
350 m_imcontrol_map.clear ();
351 m_socket_server.signal_connect_accept (slot (this, &PanelAgentImpl::socket_accept_callback));
352 m_socket_server.signal_connect_receive (slot (this, &PanelAgentImpl::socket_receive_callback));
353 m_socket_server.signal_connect_exception (slot (this, &PanelAgentImpl::socket_exception_callback));
356 bool initialize (const String &config, const String &display, bool resident)
358 m_config_name = config;
359 m_display_name = display;
360 m_should_resident = resident;
362 m_socket_address = scim_get_default_panel_socket_address (display);
364 m_socket_server.shutdown ();
366 return m_socket_server.create (SocketAddress (m_socket_address));
369 bool valid (void) const
371 return m_socket_server.valid ();
377 SCIM_DEBUG_MAIN (1) << "PanelAgent::run ()\n";
379 return m_socket_server.run ();
384 SCIM_DEBUG_MAIN(1) << "PanelAgent::stop ()\n";
387 m_should_exit = true;
392 if (client.connect (SocketAddress (m_socket_address))) {
396 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode) {
397 String helper_uuid = get_current_helper_uuid ();
398 hide_helper (helper_uuid);
399 stop_helper (helper_uuid, -2, 0);
403 int get_helper_list (std::vector <HelperInfo> & helpers) const
405 SCIM_DEBUG_MAIN (1) << "PanelAgent::get_helper_list ()\n";
409 m_helper_manager.get_helper_list ();
410 unsigned int num = m_helper_manager.number_of_helpers ();
413 SCIM_DEBUG_MAIN (2) << "Found " << num << " Helper objects\n";
415 for (unsigned int i = 0; i < num; ++i) {
416 if (m_helper_manager.get_helper_info (i, info) && info.uuid.length ()
417 && (info.option & SCIM_HELPER_STAND_ALONE))
418 helpers.push_back (info);
420 SCIM_DEBUG_MAIN (3) << "Helper " << i << " : " << info.uuid << " : " << info.name << " : "
421 << ((info.option & SCIM_HELPER_STAND_ALONE) ? "SA " : "")
422 << ((info.option & SCIM_HELPER_AUTO_START) ? "AS " : "")
423 << ((info.option & SCIM_HELPER_AUTO_RESTART) ? "AR " : "") << "\n";
426 return (int)(helpers.size ());
429 TOOLBAR_MODE_T get_current_toolbar_mode () const
431 return m_current_toolbar_mode;
434 String get_current_ise_name () const
436 return m_current_ise_name;
439 String get_current_factory_icon () const
441 return m_current_factory_icon;
444 String get_current_helper_uuid () const
446 return m_current_helper_uuid;
449 String get_current_helper_name () const
451 std::vector<HelperInfo> helpers;
453 get_helper_list (helpers);
455 std::vector<HelperInfo>::iterator iter;
457 for (iter = helpers.begin (); iter != helpers.end (); iter++) {
458 if (iter->uuid == m_current_helper_uuid)
465 void set_current_ise_name (String &name)
467 m_current_ise_name = name;
470 void set_current_ise_style (uint32 &style)
472 m_current_ise_style = style;
475 void set_current_toolbar_mode (TOOLBAR_MODE_T mode)
477 m_current_toolbar_mode = mode;
480 void update_ise_name (String &name)
482 ClientRepository::iterator iter = m_client_repository.begin ();
484 for (; iter != m_client_repository.end (); iter++)
486 if (IMCONTROL_CLIENT == iter->second.type
487 && iter->first == m_imcontrol_map[m_current_active_imcontrol_id])
489 Socket client_socket (iter->first);
493 trans.put_command (SCIM_TRANS_CMD_REQUEST);
494 trans.put_command (ISM_TRANS_CMD_ISE_CHANGED);
495 trans.put_data (name);
497 trans.write_to_socket (client_socket);
503 void update_ise_style (uint32 &style)
505 ClientRepository::iterator iter = m_client_repository.begin ();
507 for (; iter != m_client_repository.end (); iter++)
509 if (IMCONTROL_CLIENT == iter->second.type &&
510 iter->first == m_imcontrol_map[m_current_active_imcontrol_id])
512 Socket client_socket (iter->first);
516 trans.put_command (SCIM_TRANS_CMD_REQUEST);
517 trans.put_command (ISM_TRANS_CMD_UPDATE_ISE_STYLE);
518 trans.put_data (style);
520 trans.write_to_socket (client_socket);
526 void update_panel_event (int cmd, uint32 nType, uint32 nValue)
528 SCIM_DEBUG_MAIN(1) << __func__ << " (" << nType << ", " << nValue << ")\n";
529 ClientRepository::iterator iter = m_client_repository.begin ();
531 for (; iter != m_client_repository.end (); iter++)
533 if (IMCONTROL_CLIENT == iter->second.type &&
534 iter->first == m_imcontrol_map[m_current_active_imcontrol_id])
536 Socket client_socket (iter->first);
540 trans.put_command (SCIM_TRANS_CMD_REQUEST);
541 trans.put_command (cmd);
542 trans.put_data (nType);
543 trans.put_data (nValue);
545 trans.write_to_socket (client_socket);
551 void set_current_factory_icon (String &icon)
553 m_current_factory_icon = icon;
556 bool move_preedit_caret (uint32 position)
558 SCIM_DEBUG_MAIN(1) << "PanelAgent::move_preedit_caret (" << position << ")\n";
565 get_focused_context (client, context);
568 Socket client_socket (client);
569 m_send_trans.clear ();
570 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
571 m_send_trans.put_data ((uint32) context);
572 m_send_trans.put_command (SCIM_TRANS_CMD_MOVE_PREEDIT_CARET);
573 m_send_trans.put_data ((uint32) position);
574 m_send_trans.write_to_socket (client_socket);
582 bool request_help (void)
584 SCIM_DEBUG_MAIN(1) << "PanelAgent::request_help ()\n";
591 get_focused_context (client, context);
594 Socket client_socket (client);
595 m_send_trans.clear ();
596 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
597 m_send_trans.put_data ((uint32) context);
598 m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_REQUEST_HELP);
599 m_send_trans.write_to_socket (client_socket);
607 bool request_factory_menu (void)
609 SCIM_DEBUG_MAIN(1) << "PanelAgent::request_factory_menu ()\n";
616 get_focused_context (client, context);
619 Socket client_socket (client);
620 m_send_trans.clear ();
621 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
622 m_send_trans.put_data ((uint32) context);
623 m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_REQUEST_FACTORY_MENU);
624 m_send_trans.write_to_socket (client_socket);
632 bool reset_keyboard_ise (void)
634 SCIM_DEBUG_MAIN(1) << "PanelAgent::reset_keyboard_ise ()\n";
640 get_focused_context (client, context);
642 Socket client_socket (client);
643 m_send_trans.clear ();
644 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
645 m_send_trans.put_data ((uint32) context);
646 m_send_trans.put_command (ISM_TRANS_CMD_PANEL_REQUEST_RESET_ISE);
647 m_send_trans.write_to_socket (client_socket);
655 bool update_keyboard_ise_list (void)
657 SCIM_DEBUG_MAIN(1) << "PanelAgent::update_keyboard_ise_list ()\n";
663 get_focused_context (client, context);
665 Socket client_socket (client);
666 m_send_trans.clear ();
667 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
668 m_send_trans.put_data ((uint32) context);
669 m_send_trans.put_command (ISM_TRANS_CMD_PANEL_UPDATE_KEYBOARD_ISE);
670 m_send_trans.write_to_socket (client_socket);
678 bool change_factory (const String &uuid)
680 SCIM_DEBUG_MAIN(1) << "PanelAgent::change_factory (" << uuid << ")\n";
687 get_focused_context (client, context);
690 Socket client_socket (client);
691 m_send_trans.clear ();
692 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
693 m_send_trans.put_data ((uint32) context);
694 m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_CHANGE_FACTORY);
695 m_send_trans.put_data (uuid);
696 m_send_trans.write_to_socket (client_socket);
704 bool candidate_more_window_show (void)
706 SCIM_DEBUG_MAIN(4) << __FUNCTION__ << "...\n";
708 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
710 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
712 if (it != m_helper_client_index.end ())
716 Socket client_socket (it->second.id);
719 get_focused_context (client, context);
720 ctx = get_helper_ic (client, context);
722 m_send_trans.clear ();
723 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
724 m_send_trans.put_data (ctx);
725 m_send_trans.put_data (m_current_helper_uuid);
726 m_send_trans.put_command (ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_SHOW);
727 m_send_trans.write_to_socket (client_socket);
736 bool candidate_more_window_hide (void)
738 SCIM_DEBUG_MAIN(4) << __FUNCTION__ << "...\n";
740 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
742 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
744 if (it != m_helper_client_index.end ())
748 Socket client_socket (it->second.id);
751 get_focused_context (client, context);
752 ctx = get_helper_ic (client, context);
754 m_send_trans.clear ();
755 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
756 m_send_trans.put_data (ctx);
757 m_send_trans.put_data (m_current_helper_uuid);
758 m_send_trans.put_command (ISM_TRANS_CMD_CANDIDATE_MORE_WINDOW_HIDE);
759 m_send_trans.write_to_socket (client_socket);
768 bool select_aux (uint32 item)
770 SCIM_DEBUG_MAIN(1) << "PanelAgent::select_aux (" << item << ")\n";
777 get_focused_context (client, context);
780 Socket client_socket (client);
781 m_send_trans.clear ();
782 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
783 m_send_trans.put_data ((uint32) context);
784 m_send_trans.put_command (ISM_TRANS_CMD_SELECT_AUX);
785 m_send_trans.put_data ((uint32)item);
786 m_send_trans.write_to_socket (client_socket);
791 helper_select_aux (item);
796 bool select_candidate (uint32 item)
798 SCIM_DEBUG_MAIN(1) << "PanelAgent::select_candidate (" << item << ")\n";
805 get_focused_context (client, context);
808 Socket client_socket (client);
809 m_send_trans.clear ();
810 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
811 m_send_trans.put_data ((uint32) context);
812 m_send_trans.put_command (SCIM_TRANS_CMD_SELECT_CANDIDATE);
813 m_send_trans.put_data ((uint32)item);
814 m_send_trans.write_to_socket (client_socket);
819 helper_select_candidate (item);
824 bool lookup_table_page_up (void)
826 SCIM_DEBUG_MAIN(1) << "PanelAgent::lookup_table_page_up ()\n";
833 get_focused_context (client, context);
836 Socket client_socket (client);
837 m_send_trans.clear ();
838 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
839 m_send_trans.put_data ((uint32) context);
840 m_send_trans.put_command (SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP);
841 m_send_trans.write_to_socket (client_socket);
846 helper_lookup_table_page_up ();
851 bool lookup_table_page_down (void)
853 SCIM_DEBUG_MAIN(1) << "PanelAgent::lookup_table_page_down ()\n";
860 get_focused_context (client, context);
863 Socket client_socket (client);
864 m_send_trans.clear ();
865 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
866 m_send_trans.put_data ((uint32) context);
867 m_send_trans.put_command (SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN);
868 m_send_trans.write_to_socket (client_socket);
873 helper_lookup_table_page_down ();
878 bool update_lookup_table_page_size (uint32 size)
880 SCIM_DEBUG_MAIN(1) << "PanelAgent::update_lookup_table_page_size (" << size << ")\n";
887 get_focused_context (client, context);
890 Socket client_socket (client);
891 m_send_trans.clear ();
892 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
893 m_send_trans.put_data ((uint32) context);
894 m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE);
895 m_send_trans.put_data (size);
896 m_send_trans.write_to_socket (client_socket);
901 helper_update_lookup_table_page_size (size);
906 bool select_associate (uint32 item)
908 SCIM_DEBUG_MAIN(1) << "PanelAgent::select_associate (" << item << ")\n";
915 get_focused_context (client, context);
918 Socket client_socket (client);
919 m_send_trans.clear ();
920 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
921 m_send_trans.put_data ((uint32) context);
922 m_send_trans.put_command (ISM_TRANS_CMD_SELECT_ASSOCIATE);
923 m_send_trans.put_data ((uint32)item);
924 m_send_trans.write_to_socket (client_socket);
929 helper_select_associate (item);
934 bool associate_table_page_up (void)
936 SCIM_DEBUG_MAIN(1) << "PanelAgent::associate_table_page_up ()\n";
943 get_focused_context (client, context);
946 Socket client_socket (client);
947 m_send_trans.clear ();
948 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
949 m_send_trans.put_data ((uint32) context);
950 m_send_trans.put_command (ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP);
951 m_send_trans.write_to_socket (client_socket);
956 helper_associate_table_page_up ();
961 bool associate_table_page_down (void)
963 SCIM_DEBUG_MAIN(1) << "PanelAgent::associate_table_page_down ()\n";
970 get_focused_context (client, context);
973 Socket client_socket (client);
974 m_send_trans.clear ();
975 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
976 m_send_trans.put_data ((uint32) context);
977 m_send_trans.put_command (ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN);
978 m_send_trans.write_to_socket (client_socket);
983 helper_associate_table_page_down ();
988 bool update_associate_table_page_size (uint32 size)
990 SCIM_DEBUG_MAIN(1) << "PanelAgent::update_associate_table_page_size (" << size << ")\n";
997 get_focused_context (client, context);
1000 Socket client_socket (client);
1001 m_send_trans.clear ();
1002 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1003 m_send_trans.put_data ((uint32) context);
1004 m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE);
1005 m_send_trans.put_data (size);
1006 m_send_trans.write_to_socket (client_socket);
1011 helper_update_associate_table_page_size (size);
1016 bool update_displayed_candidate_number (uint32 size)
1018 SCIM_DEBUG_MAIN(1) << __func__ << " (" << size << ")\n";
1024 get_focused_context (client, context);
1027 helper_update_displayed_candidate_number (size);
1032 bool trigger_property (const String &property)
1034 SCIM_DEBUG_MAIN(1) << "PanelAgent::trigger_property (" << property << ")\n";
1041 get_focused_context (client, context);
1044 Socket client_socket (client);
1045 m_send_trans.clear ();
1046 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1047 m_send_trans.put_data ((uint32) context);
1048 m_send_trans.put_command (SCIM_TRANS_CMD_TRIGGER_PROPERTY);
1049 m_send_trans.put_data (property);
1050 m_send_trans.write_to_socket (client_socket);
1058 bool trigger_helper_property (int client,
1059 const String &property)
1061 SCIM_DEBUG_MAIN(1) << "PanelAgent::trigger_helper_property (" << client << "," << property << ")\n";
1065 ClientInfo info = socket_get_client_info (client);
1067 if (client >= 0 && info.type == HELPER_CLIENT) {
1072 fe_uuid = get_focused_context (fe_client, fe_context);
1074 Socket client_socket (client);
1075 m_send_trans.clear ();
1076 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1078 /* FIXME: We presume that client and context are both less than 65536.
1079 * Hopefully, it should be true in any UNIXs.
1080 * So it's ok to combine client and context into one uint32.*/
1081 m_send_trans.put_data (get_helper_ic (fe_client, fe_context));
1082 m_send_trans.put_data (fe_uuid);
1083 m_send_trans.put_command (SCIM_TRANS_CMD_TRIGGER_PROPERTY);
1084 m_send_trans.put_data (property);
1085 m_send_trans.write_to_socket (client_socket);
1090 return client >= 0 && info.type == HELPER_CLIENT;
1093 bool start_helper (const String &uuid, int client, uint32 context)
1095 SCIM_DEBUG_MAIN(1) << "PanelAgent::start_helper (" << uuid << ")\n";
1096 if (uuid.length () <= 0)
1101 if (m_current_toolbar_mode != TOOLBAR_HELPER_MODE || m_current_helper_uuid.compare (uuid) != 0)
1103 SCIM_DEBUG_MAIN(1) << uuid.c_str () << ".....enter run_helper ..............\n";
1104 m_helper_manager.run_helper (uuid, m_config_name, m_display_name);
1106 m_current_helper_uuid = uuid;
1107 #ifdef ONE_HELPER_ISE_PROCESS
1109 get_focused_context (client, context);
1111 SCIM_DEBUG_MAIN(1) << "[start helper] client : " << client << " context : " << context << "\n";
1112 uint32 ctx = get_helper_ic (client, context);
1114 /*HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
1115 if (it == m_helper_client_index.end ())*/
1116 if (m_helper_uuid_count.find (uuid) == m_helper_uuid_count.end ())
1118 m_client_context_helper[ctx] = uuid;
1119 m_current_helper_uuid = uuid;
1120 m_helper_uuid_count[uuid] = 1;
1121 m_helper_uuid_state[uuid] = HELPER_HIDED;
1123 m_helper_manager.run_helper (uuid, m_config_name, m_display_name);
1124 SCIM_DEBUG_MAIN(1) << "Start HelperISE " << uuid << " ...\n";
1128 ClientContextUUIDRepository::iterator it2 = m_client_context_helper.find (ctx);
1129 if (it2 == m_client_context_helper.end ())
1131 m_client_context_helper[ctx] = uuid;
1132 m_current_helper_uuid = uuid;
1133 m_helper_uuid_count[uuid] = m_helper_uuid_count[uuid] + 1;
1136 if (m_current_active_imcontrol_id != -1
1137 && m_ise_settings != NULL && m_ise_changing)
1139 show_helper (uuid, m_ise_settings, m_ise_settings_len);
1140 m_ise_changing = false;
1143 SCIM_DEBUG_MAIN(1) << "Increment usage count of HelperISE " << uuid << " to "
1144 << m_helper_uuid_count[uuid] << "\n";
1152 bool stop_helper (const String &helper_uuid, int client, uint32 context)
1154 String uuid = helper_uuid;
1155 SCIM_DEBUG_MAIN(1) << "PanelAgent::stop_helper (" << uuid << ")\n";
1156 if (uuid.length () <= 0)
1161 uint32 ctx = get_helper_ic (client, context);
1162 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
1163 if (it != m_helper_client_index.end ())
1165 Socket client_socket (it->second.id);
1166 m_send_trans.clear ();
1167 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1168 m_send_trans.put_data (ctx);
1169 m_send_trans.put_data (uuid);
1171 m_ise_exiting = true;
1172 m_send_trans.put_command (SCIM_TRANS_CMD_EXIT);
1173 m_send_trans.write_to_socket (client_socket);
1174 SCIM_DEBUG_MAIN(1) << "Stop HelperISE " << uuid << " ...\n";
1176 #ifdef ONE_HELPER_ISE_PROCESS
1178 get_focused_context (client, context);
1180 SCIM_DEBUG_MAIN(1) << "[stop helper] client : " << client << " context : " << context << "\n";
1181 uint32 ctx = get_helper_ic (client, context);
1183 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
1184 /*if (it != m_helper_client_index.end ())*/
1185 if (m_helper_uuid_count.find (uuid) != m_helper_uuid_count.end ())
1187 m_client_context_helper.erase (ctx);
1189 uint32 count = m_helper_uuid_count[uuid];
1192 m_helper_uuid_count.erase (uuid);
1194 if (it != m_helper_client_index.end ())
1196 Socket client_socket (it->second.id);
1197 m_send_trans.clear ();
1198 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1199 m_send_trans.put_data (ctx);
1200 m_send_trans.put_data (uuid);
1201 m_send_trans.put_command (SCIM_TRANS_CMD_EXIT);
1202 m_send_trans.write_to_socket (client_socket);
1203 SCIM_DEBUG_MAIN(1) << "Stop HelperISE " << uuid << " ...\n";
1208 m_helper_uuid_count[uuid] = count - 1;
1209 SCIM_DEBUG_MAIN(1) << "Decrement usage count of HelperISE " << uuid
1210 << " to " << m_helper_uuid_count[uuid] << "\n";
1219 void focus_out_helper (const String &uuid, int client, uint32 context)
1221 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1223 if (it != m_helper_client_index.end ())
1225 Socket client_socket (it->second.id);
1226 uint32 ctx = get_helper_ic (client, context);
1228 m_send_trans.clear ();
1229 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1230 m_send_trans.put_data (ctx);
1231 m_send_trans.put_data (uuid);
1232 m_send_trans.put_command (SCIM_TRANS_CMD_FOCUS_OUT);
1233 m_send_trans.write_to_socket (client_socket);
1237 void focus_in_helper (const String &uuid, int client, uint32 context)
1239 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1241 if (it != m_helper_client_index.end ())
1243 Socket client_socket (it->second.id);
1244 uint32 ctx = get_helper_ic (client, context);
1246 m_send_trans.clear ();
1247 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1248 m_send_trans.put_data (ctx);
1249 m_send_trans.put_data (uuid);
1250 m_send_trans.put_command (SCIM_TRANS_CMD_FOCUS_IN);
1251 m_send_trans.write_to_socket (client_socket);
1255 void show_helper (const String &uuid, char *data, size_t &len)
1257 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1259 if (it != m_helper_client_index.end ())
1263 Socket client_socket (it->second.id);
1266 m_helper_uuid_state[uuid] = HELPER_SHOWED;
1268 get_focused_context (client, context);
1269 ctx = get_helper_ic (client, context);
1271 m_send_trans.clear ();
1272 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1273 m_send_trans.put_data (ctx);
1274 m_send_trans.put_data (uuid);
1275 m_send_trans.put_command (ISM_TRANS_CMD_SHOW_ISE);
1276 m_send_trans.put_data (data, len);
1277 m_send_trans.write_to_socket (client_socket);
1282 void hide_helper (const String &uuid)
1284 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1286 if (it != m_helper_client_index.end ())
1290 Socket client_socket (it->second.id);
1293 m_helper_uuid_state[uuid] = HELPER_HIDED;
1295 get_focused_context (client, context);
1296 ctx = get_helper_ic (client, context);
1298 m_send_trans.clear ();
1299 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1300 m_send_trans.put_data (ctx);
1301 m_send_trans.put_data (uuid);
1302 m_send_trans.put_command (ISM_TRANS_CMD_HIDE_ISE);
1303 m_send_trans.write_to_socket (client_socket);
1307 bool set_helper_mode (const String &uuid, uint32 &mode)
1309 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1311 if (it != m_helper_client_index.end ())
1315 Socket client_socket (it->second.id);
1318 get_focused_context (client, context);
1319 ctx = get_helper_ic (client, context);
1321 m_send_trans.clear ();
1322 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1323 m_send_trans.put_data (ctx);
1324 m_send_trans.put_data (uuid);
1325 m_send_trans.put_command (ISM_TRANS_CMD_SET_ISE_MODE);
1326 m_send_trans.put_data (mode);
1327 m_send_trans.write_to_socket (client_socket);
1334 bool set_helper_language (const String &uuid, uint32 &language)
1336 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1338 if (it != m_helper_client_index.end ())
1342 Socket client_socket (it->second.id);
1345 get_focused_context (client, context);
1346 ctx = get_helper_ic (client, context);
1348 m_send_trans.clear ();
1349 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1350 m_send_trans.put_data (ctx);
1351 m_send_trans.put_data (uuid);
1352 m_send_trans.put_command (ISM_TRANS_CMD_SET_ISE_LANGUAGE);
1353 m_send_trans.put_data (language);
1354 m_send_trans.write_to_socket (client_socket);
1360 bool set_helper_imdata (const String &uuid, char *imdata, size_t &len)
1362 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1364 if (it != m_helper_client_index.end ())
1368 Socket client_socket (it->second.id);
1371 get_focused_context (client, context);
1372 ctx = get_helper_ic (client, context);
1374 m_send_trans.clear ();
1375 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1376 m_send_trans.put_data (ctx);
1377 m_send_trans.put_data (uuid);
1378 m_send_trans.put_command (ISM_TRANS_CMD_SET_ISE_IMDATA);
1379 m_send_trans.put_data (imdata, len);
1380 m_send_trans.write_to_socket (client_socket);
1386 bool set_helper_return_key_type (const String &uuid, int type)
1388 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1390 if (it != m_helper_client_index.end ())
1394 Socket client_socket (it->second.id);
1397 get_focused_context (client, context);
1398 ctx = get_helper_ic (client, context);
1400 m_send_trans.clear ();
1401 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1402 m_send_trans.put_data (ctx);
1403 m_send_trans.put_data (uuid);
1404 m_send_trans.put_command (ISM_TRANS_CMD_SET_RETURN_KEY_TYPE);
1405 m_send_trans.put_data (type);
1406 m_send_trans.write_to_socket (client_socket);
1414 bool get_helper_return_key_type (const String &uuid, uint32 &type)
1416 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1418 if (it != m_helper_client_index.end ()) {
1422 Socket client_socket (it->second.id);
1426 get_focused_context (client, context);
1427 ctx = get_helper_ic (client, context);
1430 trans.put_command (SCIM_TRANS_CMD_REPLY);
1431 trans.put_data (ctx);
1432 trans.put_data (uuid);
1433 trans.put_command (ISM_TRANS_CMD_GET_RETURN_KEY_TYPE);
1436 if (trans.write_to_socket (client_socket)
1437 && trans.read_from_socket (client_socket)
1438 && trans.get_command(cmd) && cmd == SCIM_TRANS_CMD_REPLY
1439 && trans.get_data (type)) {
1440 SCIM_DEBUG_MAIN (1) << __func__ << " success\n";
1443 std::cerr << __func__ << " failed\n";
1449 bool set_helper_return_key_disable (const String &uuid, bool disabled)
1451 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1453 if (it != m_helper_client_index.end ())
1457 Socket client_socket (it->second.id);
1460 get_focused_context (client, context);
1461 ctx = get_helper_ic (client, context);
1463 m_send_trans.clear ();
1464 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1465 m_send_trans.put_data (ctx);
1466 m_send_trans.put_data (uuid);
1467 m_send_trans.put_command (ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE);
1468 m_send_trans.put_data (disabled);
1469 m_send_trans.write_to_socket (client_socket);
1477 bool get_helper_return_key_disable (const String &uuid, uint32 &disabled)
1479 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1481 if (it != m_helper_client_index.end ()) {
1485 Socket client_socket (it->second.id);
1489 get_focused_context (client, context);
1490 ctx = get_helper_ic (client, context);
1493 trans.put_command (SCIM_TRANS_CMD_REPLY);
1494 trans.put_data (ctx);
1495 trans.put_data (uuid);
1496 trans.put_command (ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE);
1499 if (trans.write_to_socket (client_socket)
1500 && trans.read_from_socket (client_socket)
1501 && trans.get_command(cmd) && cmd == SCIM_TRANS_CMD_REPLY
1502 && trans.get_data (disabled)) {
1503 SCIM_DEBUG_MAIN (1) << __func__ << " success\n";
1506 std::cerr << __func__ << " failed\n";
1512 bool set_helper_layout (const String &uuid, uint32 &layout)
1514 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1516 if (it != m_helper_client_index.end ())
1520 Socket client_socket (it->second.id);
1523 get_focused_context (client, context);
1524 ctx = get_helper_ic (client, context);
1526 m_send_trans.clear ();
1527 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1528 m_send_trans.put_data (ctx);
1529 m_send_trans.put_data (uuid);
1530 m_send_trans.put_command (ISM_TRANS_CMD_SET_LAYOUT);
1531 m_send_trans.put_data (layout);
1532 m_send_trans.write_to_socket (client_socket);
1539 bool set_helper_caps_mode (const String &uuid, uint32 &mode)
1541 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1543 if (it != m_helper_client_index.end ())
1547 Socket client_socket (it->second.id);
1550 get_focused_context (client, context);
1551 ctx = get_helper_ic (client, context);
1553 m_send_trans.clear ();
1554 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
1555 m_send_trans.put_data (ctx);
1556 m_send_trans.put_data (uuid);
1557 m_send_trans.put_command (ISM_TRANS_CMD_SET_CAPS_MODE);
1558 m_send_trans.put_data (mode);
1559 m_send_trans.write_to_socket (client_socket);
1566 void show_isf_panel (int client_id)
1568 SCIM_DEBUG_MAIN(4) << "PanelAgent::show_isf_panel ()\n";
1570 Socket client_socket (client_id);
1572 m_signal_show_panel ();
1575 void hide_isf_panel (int client_id)
1577 SCIM_DEBUG_MAIN(4) << "PanelAgent::hide_isf_panel ()\n";
1579 Socket client_socket (client_id);
1581 m_signal_hide_panel ();
1584 void show_ise_panel (int client_id)
1586 SCIM_DEBUG_MAIN(4) << "PanelAgent::show_ise_panel ()\n";
1590 m_current_active_imcontrol_id = client_id;
1592 if (m_recv_trans.get_data (&data, len))
1594 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
1595 show_helper (m_current_helper_uuid, data, len);
1600 if (m_ise_settings != NULL)
1601 delete [] m_ise_settings;
1602 m_ise_settings = data;
1603 m_ise_settings_len = len;
1607 void hide_ise_panel (int client_id)
1609 SCIM_DEBUG_MAIN(4) << "PanelAgent::hide_ise_panel ()\n";
1610 TOOLBAR_MODE_T mode;
1612 mode = m_current_toolbar_mode;
1614 if (client_id == m_current_active_imcontrol_id &&
1615 TOOLBAR_HELPER_MODE == mode)
1617 hide_helper (m_current_helper_uuid);
1621 void set_default_ise (const DEFAULT_ISE_T &ise)
1623 m_default_ise.type = ise.type;
1624 m_default_ise.uuid = ise.uuid;
1625 m_default_ise.name = ise.name;
1627 scim_global_config_write (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_TYPE), (int)m_default_ise.type);
1628 scim_global_config_write (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), m_default_ise.uuid);
1629 scim_global_config_write (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_NAME), m_default_ise.name);
1630 scim_global_config_flush ();
1633 void set_should_shared_ise (const bool should_shared_ise)
1635 m_should_shared_ise = should_shared_ise;
1638 bool get_helper_geometry (String &uuid, struct rectinfo &info)
1640 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1642 if (it != m_helper_client_index.end ()) {
1645 Socket client_socket (it->second.id);
1649 get_focused_context (client, context);
1650 ctx = get_helper_ic (client, context);
1653 trans.put_command (SCIM_TRANS_CMD_REPLY);
1654 trans.put_data (ctx);
1655 trans.put_data (uuid);
1656 trans.put_command (ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY);
1658 if (trans.write_to_socket (client_socket)) {
1662 if (trans.read_from_socket (client_socket)
1663 && trans.get_command(cmd) && cmd == SCIM_TRANS_CMD_REPLY
1664 && trans.get_data (info.pos_x)
1665 && trans.get_data (info.pos_y)
1666 && trans.get_data (info.width)
1667 && trans.get_data (info.height)) {
1668 SCIM_DEBUG_MAIN (1) << __func__ << " is successful\n";
1671 std::cerr << __func__ << " is failed!!!\n";
1679 bool get_helper_imdata (String &uuid, char **imdata, size_t &len)
1681 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1683 if (it != m_helper_client_index.end ()) {
1687 Socket client_socket (it->second.id);
1691 get_focused_context (client, context);
1692 ctx = get_helper_ic (client, context);
1695 trans.put_command (SCIM_TRANS_CMD_REPLY);
1696 trans.put_data (ctx);
1697 trans.put_data (uuid);
1698 trans.put_command (ISM_TRANS_CMD_GET_ISE_IMDATA);
1701 if (trans.write_to_socket (client_socket)
1702 && trans.read_from_socket (client_socket)
1703 && trans.get_command(cmd) && cmd == SCIM_TRANS_CMD_REPLY
1704 && trans.get_data (imdata, len))
1706 SCIM_DEBUG_MAIN (1) << "get_helper_imdata success\n";
1711 std::cerr << "get_helper_imdata failed\n";
1717 bool get_helper_layout (String &uuid, uint32 &layout)
1719 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1721 if (it != m_helper_client_index.end ()) {
1725 Socket client_socket (it->second.id);
1729 get_focused_context (client, context);
1730 ctx = get_helper_ic (client, context);
1733 trans.put_command (SCIM_TRANS_CMD_REPLY);
1734 trans.put_data (ctx);
1735 trans.put_data (uuid);
1736 trans.put_command (ISM_TRANS_CMD_GET_LAYOUT);
1739 if (trans.write_to_socket (client_socket)
1740 && trans.read_from_socket (client_socket)
1741 && trans.get_command(cmd) && cmd == SCIM_TRANS_CMD_REPLY
1742 && trans.get_data (layout))
1744 SCIM_DEBUG_MAIN (1) << "get_helper_layout success\n";
1749 std::cerr << "get_helper_layout failed\n";
1755 bool get_helper_layout_list (String &uuid, std::vector<uint32> &list)
1757 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
1759 if (it != m_helper_client_index.end ()) {
1763 Socket client_socket (it->second.id);
1767 get_focused_context (client, context);
1768 ctx = get_helper_ic (client, context);
1771 trans.put_command (SCIM_TRANS_CMD_REPLY);
1772 trans.put_data (ctx);
1773 trans.put_data (uuid);
1774 trans.put_command (ISM_TRANS_CMD_GET_LAYOUT_LIST);
1777 if (trans.write_to_socket (client_socket)
1778 && trans.read_from_socket (client_socket, 500)
1779 && trans.get_command(cmd) && cmd == SCIM_TRANS_CMD_REPLY
1780 && trans.get_data (list))
1782 SCIM_DEBUG_MAIN (1) << "get_helper_layout_list success\n";
1787 std::cerr << "get_helper_layout_list failed\n";
1793 void get_input_panel_geometry (int client_id)
1795 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
1797 struct rectinfo info = {0, 0, 0, 0};
1798 m_signal_get_input_panel_geometry (info);
1801 Socket client_socket (client_id);
1804 trans.put_command (SCIM_TRANS_CMD_REPLY);
1805 trans.put_command (SCIM_TRANS_CMD_OK);
1806 trans.put_data (info.pos_x);
1807 trans.put_data (info.pos_y);
1808 trans.put_data (info.width);
1809 trans.put_data (info.height);
1810 trans.write_to_socket (client_socket);
1813 void get_candidate_window_geometry (int client_id)
1815 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
1817 struct rectinfo info = {0, 0, 0, 0};
1818 m_signal_get_candidate_geometry (info);
1821 Socket client_socket (client_id);
1824 trans.put_command (SCIM_TRANS_CMD_REPLY);
1825 trans.put_command (SCIM_TRANS_CMD_OK);
1826 trans.put_data (info.pos_x);
1827 trans.put_data (info.pos_y);
1828 trans.put_data (info.width);
1829 trans.put_data (info.height);
1830 trans.write_to_socket (client_socket);
1833 void get_ise_language_locale (int client_id)
1835 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
1842 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode) {
1843 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
1845 if (it != m_helper_client_index.end ()) {
1848 get_focused_context (client, context);
1850 uint32 ctx = get_helper_ic (client, context);
1853 trans.put_command (SCIM_TRANS_CMD_REPLY);
1854 trans.put_data (ctx);
1855 trans.put_data (m_current_helper_uuid);
1856 trans.put_command (ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE);
1859 Socket client_socket (it->second.id);
1860 if (trans.write_to_socket (client_socket)
1861 && trans.read_from_socket (client_socket)
1862 && trans.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY
1863 && trans.get_data (&data, len)) {
1866 std::cerr << "Get ISE language locale is failed!!!\n";
1872 trans.put_command (SCIM_TRANS_CMD_REPLY);
1873 if (data != NULL && len > 0) {
1874 trans.put_command (SCIM_TRANS_CMD_OK);
1875 trans.put_data (data, len);
1877 trans.put_command (SCIM_TRANS_CMD_FAIL);
1880 Socket client_socket (client_id);
1881 trans.write_to_socket (client_socket);
1887 void get_current_ise_geometry (rectinfo &rect)
1889 SCIM_DEBUG_MAIN(4) << __func__ << " \n";
1890 TOOLBAR_MODE_T mode = m_current_toolbar_mode;
1893 if (TOOLBAR_HELPER_MODE == mode)
1894 ret = get_helper_geometry (m_current_helper_uuid, rect);
1904 void set_ise_mode (int client_id)
1906 SCIM_DEBUG_MAIN(4) << "PanelAgent::set_ise_mode ()\n";
1909 if (m_recv_trans.get_data (mode))
1911 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
1912 set_helper_mode (m_current_helper_uuid, mode);
1916 void set_ise_layout (int client_id)
1918 SCIM_DEBUG_MAIN(4) << "PanelAgent::set_ise_layout ()\n";
1921 if (m_recv_trans.get_data (layout))
1923 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
1924 set_helper_layout (m_current_helper_uuid, layout);
1928 void set_ise_language (int client_id)
1930 SCIM_DEBUG_MAIN(4) << "PanelAgent::set_ise_language ()\n";
1933 if (m_recv_trans.get_data (language))
1935 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
1936 set_helper_language (m_current_helper_uuid, language);
1940 void set_isf_language (int client_id)
1942 SCIM_DEBUG_MAIN(4) << "PanelAgent::set_isf_language ()\n";
1946 if (m_recv_trans.get_data (&buf, len))
1949 m_signal_set_isf_language (lang);
1956 void set_ise_imdata (int client_id)
1958 SCIM_DEBUG_MAIN(4) << "PanelAgent::set_ise_imdata ()\n";
1959 char *imdata = NULL;
1962 if (m_recv_trans.get_data (&imdata, len))
1964 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
1965 set_helper_imdata (m_current_helper_uuid, imdata, len);
1972 void get_ise_imdata (int client_id)
1974 SCIM_DEBUG_MAIN(4) << "PanelAgent::get_ise_imdata ()\n";
1975 char *imdata = NULL;
1979 TOOLBAR_MODE_T mode;
1981 mode = m_current_toolbar_mode;
1983 if (TOOLBAR_HELPER_MODE == mode)
1985 ret = get_helper_imdata (m_current_helper_uuid, &imdata, len);
1989 Socket client_socket (client_id);
1992 trans.put_command (SCIM_TRANS_CMD_REPLY);
1995 trans.put_command (SCIM_TRANS_CMD_OK);
1996 trans.put_data (imdata, len);
1999 trans.put_command (SCIM_TRANS_CMD_FAIL);
2001 trans.write_to_socket (client_socket);
2007 void get_ise_layout (int client_id)
2009 SCIM_DEBUG_MAIN(4) << "PanelAgent::get_ise_layout ()\n";
2013 TOOLBAR_MODE_T mode = m_current_toolbar_mode;
2015 if (TOOLBAR_HELPER_MODE == mode)
2016 ret = get_helper_layout (m_current_helper_uuid, layout);
2019 Socket client_socket (client_id);
2022 trans.put_command (SCIM_TRANS_CMD_REPLY);
2024 trans.put_command (SCIM_TRANS_CMD_OK);
2025 trans.put_data (layout);
2027 trans.put_command (SCIM_TRANS_CMD_FAIL);
2030 trans.write_to_socket (client_socket);
2033 bool get_ise_layout_list (std::vector<uint32> &list)
2037 TOOLBAR_MODE_T mode = m_current_toolbar_mode;
2039 if (TOOLBAR_HELPER_MODE == mode)
2040 ret = get_helper_layout_list (m_current_helper_uuid, list);
2045 void get_active_ise_name (int client_id)
2047 SCIM_DEBUG_MAIN(4) << "PanelAgent::get_active_ise_name ()\n";
2049 Socket client_socket (client_id);
2050 char *name = const_cast<char *> (m_current_ise_name.c_str ());
2051 size_t len = strlen (name) + 1;
2054 trans.put_command (SCIM_TRANS_CMD_REPLY);
2055 trans.put_command (SCIM_TRANS_CMD_OK);
2056 trans.put_data (name, len);
2057 trans.write_to_socket (client_socket);
2060 void get_ise_list (int client_id)
2062 SCIM_DEBUG_MAIN(4) << "PanelAgent::get_ise_list ()\n";
2063 std::vector<String> strlist;
2064 m_signal_get_ise_list (strlist);
2067 Socket client_socket (client_id);
2073 trans.put_command (SCIM_TRANS_CMD_REPLY);
2074 trans.put_command (SCIM_TRANS_CMD_OK);
2076 num = strlist.size ();
2077 trans.put_data (num);
2078 for (unsigned int i = 0; i < num; i++)
2080 buf = const_cast<char *>(strlist[i].c_str ());
2081 len = strlen (buf) + 1;
2082 trans.put_data (buf, len);
2085 trans.write_to_socket (client_socket);
2088 void get_language_list (int client_id)
2090 SCIM_DEBUG_MAIN(4) << "PanelAgent::get_language_list ()\n";
2091 std::vector<String> strlist;
2093 m_signal_get_language_list (strlist);
2096 Socket client_socket (client_id);
2102 trans.put_command (SCIM_TRANS_CMD_REPLY);
2103 trans.put_command (SCIM_TRANS_CMD_OK);
2105 num = strlist.size ();
2106 trans.put_data (num);
2107 for (unsigned int i = 0; i < num; i++)
2109 buf = const_cast<char *>(strlist[i].c_str ());
2110 len = strlen (buf) + 1;
2111 trans.put_data (buf, len);
2114 trans.write_to_socket (client_socket);
2117 void get_all_language (int client_id)
2119 SCIM_DEBUG_MAIN(4) << "PanelAgent::get_all_language ()\n";
2120 std::vector<String> strlist;
2122 m_signal_get_all_language (strlist);
2125 Socket client_socket (client_id);
2131 trans.put_command (SCIM_TRANS_CMD_REPLY);
2132 trans.put_command (SCIM_TRANS_CMD_OK);
2134 num = strlist.size ();
2135 trans.put_data (num);
2136 for (unsigned int i = 0; i < num; i++)
2138 buf = const_cast<char *>(strlist[i].c_str ());
2139 len = strlen (buf) + 1;
2140 trans.put_data (buf, len);
2143 trans.write_to_socket (client_socket);
2146 void get_ise_language (int client_id)
2148 SCIM_DEBUG_MAIN(4) << "PanelAgent::get_ise_language ()\n";
2149 std::vector<String> strlist;
2153 Socket client_socket (client_id);
2155 if (!(m_recv_trans.get_data (&buf, len)))
2158 trans.put_command (SCIM_TRANS_CMD_REPLY);
2159 trans.put_command (SCIM_TRANS_CMD_FAIL);
2160 trans.write_to_socket (client_socket);
2166 m_signal_get_ise_language (buf, strlist);
2177 trans.put_command (SCIM_TRANS_CMD_REPLY);
2178 trans.put_command (SCIM_TRANS_CMD_OK);
2180 num = strlist.size ();
2181 trans.put_data (num);
2182 for (unsigned int i = 0; i < num; i++)
2184 buf = const_cast<char *>(strlist[i].c_str ());
2185 len = strlen (buf) + 1;
2186 trans.put_data (buf, len);
2189 trans.write_to_socket (client_socket);
2192 bool reset_ise_option (int client_id)
2194 SCIM_DEBUG_MAIN(1) << "PanelAgent::resect_ise_option ()\n";
2201 ClientContextUUIDRepository::iterator it = m_client_context_uuids.begin ();
2202 if (it != m_client_context_uuids.end ()) {
2203 get_imengine_client_context (it->first, client, context);
2207 Socket client_socket (client);
2208 m_send_trans.clear ();
2209 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
2210 m_send_trans.put_data ((uint32) context);
2211 m_send_trans.put_command (ISM_TRANS_CMD_RESET_ISE_OPTION);
2212 m_send_trans.write_to_socket (client_socket);
2219 trans.put_command (SCIM_TRANS_CMD_REPLY);
2220 trans.put_command (SCIM_TRANS_CMD_OK);
2221 Socket client_socket (client_id);
2222 trans.write_to_socket (client_socket);
2227 bool find_active_ise_by_uuid (String uuid)
2229 HelperInfoRepository::iterator iter = m_helper_info_repository.begin ();
2230 for (; iter != m_helper_info_repository.end (); iter++)
2232 if (!uuid.compare (iter->second.uuid))
2239 void set_active_ise_by_uuid (int client_id)
2241 SCIM_DEBUG_MAIN(4) << "PanelAgent::set_active_ise_by_uuid ()\n";
2245 Socket client_socket (client_id);
2246 m_current_active_imcontrol_id = client_id;
2249 trans.put_command (SCIM_TRANS_CMD_REPLY);
2250 if (!(m_recv_trans.get_data (&buf, len)))
2252 trans.put_command (SCIM_TRANS_CMD_FAIL);
2253 trans.write_to_socket (client_socket);
2262 if (!m_signal_get_ise_info_by_uuid (uuid, info))
2264 trans.put_command (SCIM_TRANS_CMD_FAIL);
2265 trans.write_to_socket (client_socket);
2271 if (info.type == TOOLBAR_KEYBOARD_MODE)
2273 m_signal_set_active_ise_by_uuid (uuid, 1);
2274 trans.put_command (SCIM_TRANS_CMD_OK);
2275 trans.write_to_socket (client_socket);
2280 else if (info.option & ISM_ISE_HIDE_IN_CONTROL_PANEL)
2282 int count = _id_count--;
2283 if (info.type == TOOLBAR_HELPER_MODE)
2285 m_current_toolbar_mode = TOOLBAR_HELPER_MODE;
2286 if (uuid != m_current_helper_uuid)
2287 m_last_helper_uuid = m_current_helper_uuid;
2288 start_helper (uuid, count, DEFAULT_CONTEXT_VALUE);
2289 IMControlRepository::iterator iter = m_imcontrol_repository.find (client_id);
2290 if (iter == m_imcontrol_repository.end ())
2292 struct IMControlStub stub;
2293 stub.count.clear ();
2295 stub.info.push_back (info);
2296 stub.count.push_back (count);
2297 m_imcontrol_repository[client_id] = stub;
2301 iter->second.info.push_back (info);
2302 iter->second.count.push_back (count);
2307 m_signal_set_active_ise_by_uuid (uuid, 1);
2309 if (find_active_ise_by_uuid (uuid))
2311 trans.put_command (SCIM_TRANS_CMD_OK);
2312 trans.write_to_socket (client_socket);
2315 m_ise_pending_repository[uuid] = client_id;
2321 bool find_active_ise_by_name (String name)
2323 HelperInfoRepository::iterator iter = m_helper_info_repository.begin ();
2324 for (; iter != m_helper_info_repository.end (); iter++)
2326 if (!name.compare (iter->second.name))
2333 void set_active_ise_by_name (int client_id)
2338 Socket client_socket (client_id);
2339 m_current_active_imcontrol_id = client_id;
2342 trans.put_command (SCIM_TRANS_CMD_REPLY);
2343 if (!(m_recv_trans.get_data (&buf, len)))
2345 trans.put_command (SCIM_TRANS_CMD_FAIL);
2346 trans.write_to_socket (client_socket);
2355 if (!m_signal_get_ise_info_by_name (name, info))
2357 trans.put_command (SCIM_TRANS_CMD_FAIL);
2358 trans.write_to_socket (client_socket);
2364 if (info.type == TOOLBAR_KEYBOARD_MODE)
2366 m_signal_set_keyboard_ise (ISM_TRANS_CMD_SET_KEYBOARD_ISE_BY_NAME, name);
2367 trans.put_command (SCIM_TRANS_CMD_OK);
2368 trans.write_to_socket (client_socket);
2373 else if (info.option & ISM_ISE_HIDE_IN_CONTROL_PANEL)
2375 int count = _id_count--;
2376 if (info.type == TOOLBAR_HELPER_MODE)
2378 m_current_toolbar_mode = TOOLBAR_HELPER_MODE;
2379 if (info.uuid != m_current_helper_uuid)
2380 m_last_helper_uuid = m_current_helper_uuid;
2381 start_helper (info.uuid, count, DEFAULT_CONTEXT_VALUE);
2382 IMControlRepository::iterator iter = m_imcontrol_repository.find (client_id);
2383 if (iter == m_imcontrol_repository.end ())
2385 struct IMControlStub stub;
2386 stub.count.clear ();
2388 stub.info.push_back (info);
2389 stub.count.push_back (count);
2390 m_imcontrol_repository[client_id] = stub;
2394 iter->second.info.push_back (info);
2395 iter->second.count.push_back (count);
2400 m_signal_set_active_ise_by_name (name);
2402 if (find_active_ise_by_name (name))
2404 trans.put_command (SCIM_TRANS_CMD_OK);
2405 trans.write_to_socket (client_socket);
2408 m_ise_pending_repository[name] = client_id;
2414 void update_isf_control_status (const bool showed)
2416 for (ClientRepository::iterator iter = m_client_repository.begin ();
2417 iter != m_client_repository.end (); ++iter)
2419 if (IMCONTROL_CLIENT == iter->second.type
2420 && iter->first == m_imcontrol_map[m_current_active_imcontrol_id])
2422 Socket client_socket (iter->first);
2426 trans.put_command (SCIM_TRANS_CMD_REQUEST);
2428 trans.put_command (ISM_TRANS_CMD_ISF_CONTROL_SHOWED);
2430 trans.put_command (ISM_TRANS_CMD_ISF_CONTROL_HIDED);
2431 trans.write_to_socket (client_socket);
2438 void set_ise_return_key_type (int client_id)
2440 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
2443 if (m_recv_trans.get_data (type)) {
2444 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
2445 set_helper_return_key_type (m_current_helper_uuid, type);
2449 void get_ise_return_key_type (int client_id)
2451 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
2455 TOOLBAR_MODE_T mode = m_current_toolbar_mode;
2457 if (TOOLBAR_HELPER_MODE == mode)
2458 ret = get_helper_return_key_type (m_current_helper_uuid, type);
2461 Socket client_socket (client_id);
2464 trans.put_command (SCIM_TRANS_CMD_REPLY);
2466 trans.put_command (SCIM_TRANS_CMD_OK);
2467 trans.put_data (type);
2469 trans.put_command (SCIM_TRANS_CMD_FAIL);
2472 trans.write_to_socket (client_socket);
2475 void set_ise_return_key_disable (int client_id)
2477 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
2480 if (m_recv_trans.get_data (disabled)) {
2481 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
2482 set_helper_return_key_disable (m_current_helper_uuid, disabled);
2486 void get_ise_return_key_disable (int client_id)
2488 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
2489 uint32 disabled = 0;
2492 TOOLBAR_MODE_T mode = m_current_toolbar_mode;
2494 if (TOOLBAR_HELPER_MODE == mode)
2495 ret = get_helper_return_key_disable (m_current_helper_uuid, disabled);
2498 Socket client_socket (client_id);
2501 trans.put_command (SCIM_TRANS_CMD_REPLY);
2503 trans.put_command (SCIM_TRANS_CMD_OK);
2504 trans.put_data (disabled);
2506 trans.put_command (SCIM_TRANS_CMD_FAIL);
2509 trans.write_to_socket (client_socket);
2512 int get_active_ise_list (std::vector<String> &strlist)
2515 m_helper_manager.get_active_ise_list (strlist);
2516 return (int)(strlist.size ());
2519 int get_helper_manager_id (void)
2521 return m_helper_manager.get_connection_number ();
2524 bool has_helper_manager_pending_event (void)
2526 return m_helper_manager.has_pending_event ();
2529 bool filter_helper_manager_event (void)
2531 return m_helper_manager.filter_event ();
2534 void reset_helper_context (const String &uuid)
2536 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
2538 if (it != m_helper_client_index.end ())
2542 Socket client_socket (it->second.id);
2545 get_focused_context (client, context);
2546 ctx = get_helper_ic (client, context);
2548 m_send_trans.clear ();
2549 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
2550 m_send_trans.put_data (ctx);
2551 m_send_trans.put_data (uuid);
2552 m_send_trans.put_command (ISM_TRANS_CMD_RESET_ISE_CONTEXT);
2553 m_send_trans.write_to_socket (client_socket);
2557 void reset_ise_context (int client_id)
2559 SCIM_DEBUG_MAIN(4) << "PanelAgent::reset_ise_context ()\n";
2560 TOOLBAR_MODE_T mode;
2562 mode = m_current_toolbar_mode;
2564 if (TOOLBAR_HELPER_MODE == mode)
2566 reset_helper_context (m_current_helper_uuid);
2570 void set_ise_caps_mode (int client_id)
2572 SCIM_DEBUG_MAIN(4) << "PanelAgent::set_ise_caps_mode ()\n";
2575 if (m_recv_trans.get_data (mode))
2577 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
2578 set_helper_caps_mode (m_current_helper_uuid, mode);
2582 int send_display_name (String &name)
2584 return m_helper_manager.send_display_name (name);
2587 bool reload_config (void)
2589 SCIM_DEBUG_MAIN(1) << "PanelAgent::reload_config ()\n";
2593 m_send_trans.clear ();
2594 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
2595 m_send_trans.put_command (SCIM_TRANS_CMD_RELOAD_CONFIG);
2597 for (ClientRepository::iterator it = m_client_repository.begin ();
2598 it != m_client_repository.end (); ++it) {
2600 if (it->second.type == IMCONTROL_ACT_CLIENT
2601 || it->second.type == IMCONTROL_CLIENT
2602 || it->second.type == HELPER_ACT_CLIENT)
2605 Socket client_socket (it->first);
2606 m_send_trans.write_to_socket (client_socket);
2615 SCIM_DEBUG_MAIN(1) << "PanelAgent::exit ()\n";
2619 m_send_trans.clear ();
2620 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
2621 m_send_trans.put_command (SCIM_TRANS_CMD_EXIT);
2623 for (ClientRepository::iterator it = m_client_repository.begin ();
2624 it != m_client_repository.end (); ++it) {
2625 Socket client_socket (it->first);
2626 m_send_trans.write_to_socket (client_socket);
2636 bool filter_event (int fd)
2638 SCIM_DEBUG_MAIN (1) << "PanelAgent::filter_event ()\n";
2640 return m_socket_server.filter_event (fd);
2643 bool filter_exception_event (int fd)
2645 SCIM_DEBUG_MAIN (1) << "PanelAgent::filter_exception_event ()\n";
2647 return m_socket_server.filter_exception_event (fd);
2650 int get_server_id ()
2652 SCIM_DEBUG_MAIN (1) << "PanelAgent::get_server_id ()\n";
2654 return m_socket_server.get_id ();
2657 void set_ise_changing (bool changing)
2659 SCIM_DEBUG_MAIN (1) << "PanelAgent::set_ise_changing ()\n";
2660 m_ise_changing = changing;
2663 void update_ise_list (std::vector<String> &strList)
2665 /* send ise list to frontend */
2666 String dst_str = scim_combine_string_list (strList);
2667 m_helper_manager.send_ise_list (dst_str);
2669 /* request PanelClient to update keyboard ise list */
2670 update_keyboard_ise_list ();
2673 Connection signal_connect_reload_config (PanelAgentSlotVoid *slot)
2675 return m_signal_reload_config.connect (slot);
2678 Connection signal_connect_turn_on (PanelAgentSlotVoid *slot)
2680 return m_signal_turn_on.connect (slot);
2683 Connection signal_connect_turn_off (PanelAgentSlotVoid *slot)
2685 return m_signal_turn_off.connect (slot);
2688 Connection signal_connect_show_panel (PanelAgentSlotVoid *slot)
2690 return m_signal_show_panel.connect (slot);
2693 Connection signal_connect_hide_panel (PanelAgentSlotVoid *slot)
2695 return m_signal_hide_panel.connect (slot);
2698 Connection signal_connect_update_screen (PanelAgentSlotInt *slot)
2700 return m_signal_update_screen.connect (slot);
2703 Connection signal_connect_update_spot_location (PanelAgentSlotIntIntInt *slot)
2705 return m_signal_update_spot_location.connect (slot);
2708 Connection signal_connect_update_factory_info (PanelAgentSlotFactoryInfo *slot)
2710 return m_signal_update_factory_info.connect (slot);
2713 Connection signal_connect_start_default_ise (PanelAgentSlotVoid *slot)
2715 return m_signal_start_default_ise.connect (slot);
2718 Connection signal_connect_set_candidate_ui (PanelAgentSlotIntInt *slot)
2720 return m_signal_set_candidate_ui.connect (slot);
2723 Connection signal_connect_get_candidate_ui (PanelAgentSlotIntInt2 *slot)
2725 return m_signal_get_candidate_ui.connect (slot);
2728 Connection signal_connect_set_candidate_position (PanelAgentSlotIntInt *slot)
2730 return m_signal_set_candidate_position.connect (slot);
2733 Connection signal_connect_get_candidate_geometry (PanelAgentSlotRect *slot)
2735 return m_signal_get_candidate_geometry.connect (slot);
2738 Connection signal_connect_get_input_panel_geometry (PanelAgentSlotRect *slot)
2740 return m_signal_get_input_panel_geometry.connect (slot);
2743 Connection signal_connect_set_keyboard_ise (PanelAgentSlotIntString *slot)
2745 return m_signal_set_keyboard_ise.connect (slot);
2748 Connection signal_connect_get_keyboard_ise (PanelAgentSlotString2 *slot)
2750 return m_signal_get_keyboard_ise.connect (slot);
2753 Connection signal_connect_show_help (PanelAgentSlotString *slot)
2755 return m_signal_show_help.connect (slot);
2758 Connection signal_connect_show_factory_menu (PanelAgentSlotFactoryInfoVector *slot)
2760 return m_signal_show_factory_menu.connect (slot);
2763 Connection signal_connect_show_preedit_string (PanelAgentSlotVoid *slot)
2765 return m_signal_show_preedit_string.connect (slot);
2768 Connection signal_connect_show_aux_string (PanelAgentSlotVoid *slot)
2770 return m_signal_show_aux_string.connect (slot);
2773 Connection signal_connect_show_lookup_table (PanelAgentSlotVoid *slot)
2775 return m_signal_show_lookup_table.connect (slot);
2778 Connection signal_connect_show_associate_table (PanelAgentSlotVoid *slot)
2780 return m_signal_show_associate_table.connect (slot);
2783 Connection signal_connect_hide_preedit_string (PanelAgentSlotVoid *slot)
2785 return m_signal_hide_preedit_string.connect (slot);
2788 Connection signal_connect_hide_aux_string (PanelAgentSlotVoid *slot)
2790 return m_signal_hide_aux_string.connect (slot);
2793 Connection signal_connect_hide_lookup_table (PanelAgentSlotVoid *slot)
2795 return m_signal_hide_lookup_table.connect (slot);
2798 Connection signal_connect_hide_associate_table (PanelAgentSlotVoid *slot)
2800 return m_signal_hide_associate_table.connect (slot);
2803 Connection signal_connect_update_preedit_string (PanelAgentSlotAttributeString *slot)
2805 return m_signal_update_preedit_string.connect (slot);
2808 Connection signal_connect_update_preedit_caret (PanelAgentSlotInt *slot)
2810 return m_signal_update_preedit_caret.connect (slot);
2813 Connection signal_connect_update_aux_string (PanelAgentSlotAttributeString *slot)
2815 return m_signal_update_aux_string.connect (slot);
2818 Connection signal_connect_update_lookup_table (PanelAgentSlotLookupTable *slot)
2820 return m_signal_update_lookup_table.connect (slot);
2823 Connection signal_connect_update_associate_table (PanelAgentSlotLookupTable *slot)
2825 return m_signal_update_associate_table.connect (slot);
2828 Connection signal_connect_register_properties (PanelAgentSlotPropertyList *slot)
2830 return m_signal_register_properties.connect (slot);
2833 Connection signal_connect_update_property (PanelAgentSlotProperty *slot)
2835 return m_signal_update_property.connect (slot);
2838 Connection signal_connect_register_helper_properties (PanelAgentSlotIntPropertyList *slot)
2840 return m_signal_register_helper_properties.connect (slot);
2843 Connection signal_connect_update_helper_property (PanelAgentSlotIntProperty *slot)
2845 return m_signal_update_helper_property.connect (slot);
2848 Connection signal_connect_register_helper (PanelAgentSlotIntHelperInfo *slot)
2850 return m_signal_register_helper.connect (slot);
2853 Connection signal_connect_remove_helper (PanelAgentSlotInt *slot)
2855 return m_signal_remove_helper.connect (slot);
2858 Connection signal_connect_set_active_ise_by_uuid (PanelAgentSlotStringBool *slot)
2860 return m_signal_set_active_ise_by_uuid.connect (slot);
2863 Connection signal_connect_set_active_ise_by_name (PanelAgentSlotString *slot)
2865 return m_signal_set_active_ise_by_name.connect (slot);
2868 Connection signal_connect_focus_in (PanelAgentSlotVoid *slot)
2870 return m_signal_focus_in.connect (slot);
2873 Connection signal_connect_focus_out (PanelAgentSlotVoid *slot)
2875 return m_signal_focus_out.connect (slot);
2878 Connection signal_connect_expand_candidate (PanelAgentSlotVoid *slot)
2880 return m_signal_expand_candidate.connect (slot);
2883 Connection signal_connect_contract_candidate (PanelAgentSlotVoid *slot)
2885 return m_signal_contract_candidate.connect (slot);
2888 Connection signal_connect_get_ise_list (PanelAgentSlotBoolStringVector *slot)
2890 return m_signal_get_ise_list.connect (slot);
2893 Connection signal_connect_get_keyboard_ise_list (PanelAgentSlotBoolStringVector *slot)
2895 return m_signal_get_keyboard_ise_list.connect (slot);
2898 Connection signal_connect_update_ise_geometry (PanelAgentSlotIntIntIntInt *slot)
2900 return m_signal_update_ise_geometry.connect (slot);
2903 Connection signal_connect_get_language_list (PanelAgentSlotStringVector *slot)
2905 return m_signal_get_language_list.connect (slot);
2908 Connection signal_connect_get_all_language (PanelAgentSlotStringVector *slot)
2910 return m_signal_get_all_language.connect (slot);
2913 Connection signal_connect_get_ise_language (PanelAgentSlotStrStringVector *slot)
2915 return m_signal_get_ise_language.connect (slot);
2918 Connection signal_connect_set_isf_language (PanelAgentSlotString *slot)
2920 return m_signal_set_isf_language.connect (slot);
2923 Connection signal_connect_get_ise_info_by_uuid (PanelAgentSlotStringISEINFO *slot)
2925 return m_signal_get_ise_info_by_uuid.connect (slot);
2928 Connection signal_connect_get_ise_info_by_name (PanelAgentSlotStringISEINFO *slot)
2930 return m_signal_get_ise_info_by_name.connect (slot);
2933 Connection signal_connect_send_key_event (PanelAgentSlotKeyEvent *slot)
2935 return m_signal_send_key_event.connect (slot);
2938 Connection signal_connect_accept_connection (PanelAgentSlotInt *slot)
2940 return m_signal_accept_connection.connect (slot);
2943 Connection signal_connect_close_connection (PanelAgentSlotInt *slot)
2945 return m_signal_close_connection.connect (slot);
2948 Connection signal_connect_exit (PanelAgentSlotVoid *slot)
2950 return m_signal_exit.connect (slot);
2953 Connection signal_connect_transaction_start (PanelAgentSlotVoid *slot)
2955 return m_signal_transaction_start.connect (slot);
2958 Connection signal_connect_transaction_end (PanelAgentSlotVoid *slot)
2960 return m_signal_transaction_end.connect (slot);
2963 Connection signal_connect_lock (PanelAgentSlotVoid *slot)
2965 return m_signal_lock.connect (slot);
2968 Connection signal_connect_unlock (PanelAgentSlotVoid *slot)
2970 return m_signal_unlock.connect (slot);
2973 Connection signal_connect_update_input_context (PanelAgentSlotIntInt *slot)
2975 return m_signal_update_input_context.connect (slot);
2979 bool socket_check_client_connection (const Socket &client)
2981 SCIM_DEBUG_MAIN (3) << "PanelAgent::socket_check_client_connection (" << client.get_id () << ")\n";
2983 unsigned char buf [sizeof(uint32)];
2985 int nbytes = client.read_with_timeout (buf, sizeof(uint32), m_socket_timeout);
2987 if (nbytes == sizeof (uint32))
2991 SCIM_DEBUG_MAIN (4) << "Error occurred when reading socket: " << client.get_error_message () << ".\n";
2993 SCIM_DEBUG_MAIN (4) << "Timeout when reading socket.\n";
2999 void socket_accept_callback (SocketServer *server,
3000 const Socket &client)
3002 SCIM_DEBUG_MAIN (2) << "PanelAgent::socket_accept_callback (" << client.get_id () << ")\n";
3005 if (m_should_exit) {
3006 SCIM_DEBUG_MAIN (3) << "Exit Socket Server Thread.\n";
3007 server->shutdown ();
3009 m_signal_accept_connection (client.get_id ());
3013 void socket_receive_callback (SocketServer *server,
3014 const Socket &client)
3016 int client_id = client.get_id ();
3021 bool current = false;
3024 ClientInfo client_info;
3026 SCIM_DEBUG_MAIN (1) << "PanelAgent::socket_receive_callback (" << client_id << ")\n";
3028 /* If the connection is closed then close this client. */
3029 if (!socket_check_client_connection (client)) {
3030 socket_close_connection (server, client);
3034 client_info = socket_get_client_info (client_id);
3036 /* If it's a new client, then request to open the connection first. */
3037 if (client_info.type == UNKNOWN_CLIENT) {
3038 socket_open_connection (server, client);
3042 /* If can not read the transaction,
3043 * or the transaction is not started with SCIM_TRANS_CMD_REQUEST,
3044 * or the key is mismatch,
3046 if (!m_recv_trans.read_from_socket (client, m_socket_timeout) ||
3047 !m_recv_trans.get_command (cmd) || cmd != SCIM_TRANS_CMD_REQUEST ||
3048 !m_recv_trans.get_data (key) || key != (uint32) client_info.key)
3051 if (client_info.type == FRONTEND_CLIENT) {
3052 if (m_recv_trans.get_data (context)) {
3053 SCIM_DEBUG_MAIN (1) << "PanelAgent::FrontEnd Client, context = " << context << "\n";
3054 socket_transaction_start();
3055 while (m_recv_trans.get_command (cmd)) {
3056 SCIM_DEBUG_MAIN (3) << "PanelAgent::cmd = " << cmd << "\n";
3058 if (cmd == SCIM_TRANS_CMD_PANEL_REGISTER_INPUT_CONTEXT) {
3059 if (m_recv_trans.get_data (uuid)) {
3060 SCIM_DEBUG_MAIN (2) << "PanelAgent::register_input_context (" << client_id << "," << "," << context << "," << uuid << ")\n";
3061 uint32 ctx = get_helper_ic (client_id, context);
3062 m_client_context_uuids [ctx] = uuid;
3067 if (cmd == ISM_TRANS_CMD_PANEL_START_DEFAULT_ISE) {
3068 if ((m_default_ise.type == TOOLBAR_HELPER_MODE) && (m_default_ise.uuid.length () > 0))
3070 m_current_toolbar_mode = TOOLBAR_HELPER_MODE;
3071 start_helper (m_default_ise.uuid, client_id, context);
3073 else if (m_default_ise.type == TOOLBAR_KEYBOARD_MODE)
3075 m_current_toolbar_mode = TOOLBAR_KEYBOARD_MODE;
3080 if (cmd == SCIM_TRANS_CMD_PANEL_REMOVE_INPUT_CONTEXT) {
3081 uint32 ctx = get_helper_ic (client_id, context);
3082 m_client_context_uuids.erase (ctx);
3083 #ifdef ONE_HELPER_ISE_PROCESS
3084 if (m_client_context_helper.find (ctx) != m_client_context_helper.end ())
3085 stop_helper (m_client_context_helper[ctx], client_id, context);
3087 if (ctx == get_helper_ic (m_current_socket_client, m_current_client_context))
3090 m_current_socket_client = m_last_socket_client;
3091 m_current_client_context = m_last_client_context;
3092 m_current_context_uuid = m_last_context_uuid;
3093 m_last_socket_client = -1;
3094 m_last_client_context = 0;
3095 m_last_context_uuid = String ("");
3096 if (m_current_socket_client == -1)
3099 socket_update_control_panel ();
3104 else if (ctx == get_helper_ic (m_last_socket_client, m_last_client_context))
3107 m_last_socket_client = -1;
3108 m_last_client_context = 0;
3109 m_last_context_uuid = String ("");
3115 if (cmd == SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT) {
3116 socket_reset_input_context (client_id, context);
3120 if (cmd == SCIM_TRANS_CMD_FOCUS_IN) {
3121 get_helper_ic (client_id, context);
3122 m_signal_focus_in ();
3123 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
3124 focus_in_helper (m_current_helper_uuid, client_id, context);
3125 #ifdef ONE_HELPER_ISE_PROCESS
3126 uint32 ctx = get_helper_ic (client_id, context);
3127 ClientContextUUIDRepository::iterator it = m_client_context_helper.find (ctx);
3128 if (it != m_client_context_helper.end ())
3130 if (m_should_shared_ise)
3132 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
3134 if (m_current_helper_uuid != it->second)
3136 stop_helper (it->second, client_id, context);
3137 start_helper (m_current_helper_uuid, client_id, context);
3139 focus_in_helper (m_current_helper_uuid, client_id, context);
3141 else if (TOOLBAR_KEYBOARD_MODE == m_current_toolbar_mode)
3142 stop_helper (it->second, client_id, context);
3146 /* focus in the helper if the context is associated with some helper */
3147 m_current_toolbar_mode = TOOLBAR_HELPER_MODE;
3148 m_current_helper_uuid = it->second;
3149 focus_in_helper (m_current_helper_uuid, client_id, context);
3154 if (m_should_shared_ise)
3156 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
3158 start_helper (m_current_helper_uuid, client_id, context);
3159 focus_in_helper (m_current_helper_uuid, client_id, context);
3164 /* come here if the context is associated with some imengine */
3165 m_current_toolbar_mode = TOOLBAR_KEYBOARD_MODE;
3169 if (m_recv_trans.get_data (uuid)) {
3170 SCIM_DEBUG_MAIN (2) << "PanelAgent::focus_in (" << client_id << "," << "," << context << "," << uuid << ")\n";
3172 if (m_current_socket_client >= 0) {
3173 m_last_socket_client = m_current_socket_client;
3174 m_last_client_context = m_current_client_context;
3175 m_last_context_uuid = m_current_context_uuid;
3177 m_current_socket_client = client_id;
3178 m_current_client_context = context;
3179 m_current_context_uuid = uuid;
3185 if (cmd == ISM_TRANS_CMD_TURN_ON_LOG) {
3186 socket_turn_on_log ();
3190 current = last = false;
3193 /* Get the context uuid from the client context registration table. */
3195 ClientContextUUIDRepository::iterator it = m_client_context_uuids.find (get_helper_ic (client_id, context));
3196 if (it != m_client_context_uuids.end ())
3200 if (m_current_socket_client == client_id && m_current_client_context == context) {
3202 if (!uuid.length ()) uuid = m_current_context_uuid;
3203 } else if (m_last_socket_client == client_id && m_last_client_context == context) {
3205 if (!uuid.length ()) uuid = m_last_context_uuid;
3208 /* Skip to the next command and continue, if it's not current or last focused. */
3209 if (!uuid.length ()) {
3210 SCIM_DEBUG_MAIN (3) << "PanelAgent:: Couldn't find context uuid.\n";
3211 while (m_recv_trans.get_data_type () != SCIM_TRANS_DATA_COMMAND && m_recv_trans.get_data_type () != SCIM_TRANS_DATA_UNKNOWN)
3212 m_recv_trans.skip_data ();
3216 if (cmd == SCIM_TRANS_CMD_START_HELPER) {
3217 socket_start_helper (client_id, context, uuid);
3220 else if (cmd == SCIM_TRANS_CMD_SEND_HELPER_EVENT) {
3221 socket_send_helper_event (client_id, context, uuid);
3224 else if (cmd == SCIM_TRANS_CMD_STOP_HELPER) {
3225 socket_stop_helper (client_id, context, uuid);
3229 /* If it's not focused, just continue. */
3230 if ((!current && !last) || (last && m_current_socket_client >= 0)) {
3231 SCIM_DEBUG_MAIN (3) << "PanelAgent::Not current focused.\n";
3232 while (m_recv_trans.get_data_type () != SCIM_TRANS_DATA_COMMAND && m_recv_trans.get_data_type () != SCIM_TRANS_DATA_UNKNOWN)
3233 m_recv_trans.skip_data ();
3237 /* Client must focus in before do any other things. */
3238 if (cmd == SCIM_TRANS_CMD_PANEL_TURN_ON)
3240 else if (cmd == SCIM_TRANS_CMD_PANEL_TURN_OFF)
3242 else if (cmd == SCIM_TRANS_CMD_UPDATE_SCREEN)
3243 socket_update_screen ();
3244 else if (cmd == SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION)
3245 socket_update_spot_location ();
3246 else if (cmd == ISM_TRANS_CMD_UPDATE_CURSOR_POSITION)
3247 socket_update_cursor_position ();
3248 else if (cmd == ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT)
3249 socket_update_surrounding_text ();
3250 else if (cmd == SCIM_TRANS_CMD_PANEL_UPDATE_FACTORY_INFO)
3251 socket_update_factory_info ();
3252 else if (cmd == SCIM_TRANS_CMD_SHOW_PREEDIT_STRING)
3253 socket_show_preedit_string ();
3254 else if (cmd == SCIM_TRANS_CMD_SHOW_AUX_STRING)
3255 socket_show_aux_string ();
3256 else if (cmd == SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE)
3257 socket_show_lookup_table ();
3258 else if (cmd == ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE)
3259 socket_show_associate_table ();
3260 else if (cmd == SCIM_TRANS_CMD_HIDE_PREEDIT_STRING)
3261 socket_hide_preedit_string ();
3262 else if (cmd == SCIM_TRANS_CMD_HIDE_AUX_STRING)
3263 socket_hide_aux_string ();
3264 else if (cmd == SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE)
3265 socket_hide_lookup_table ();
3266 else if (cmd == ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE)
3267 socket_hide_associate_table ();
3268 else if (cmd == SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING)
3269 socket_update_preedit_string ();
3270 else if (cmd == SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET)
3271 socket_update_preedit_caret ();
3272 else if (cmd == SCIM_TRANS_CMD_UPDATE_AUX_STRING)
3273 socket_update_aux_string ();
3274 else if (cmd == SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE)
3275 socket_update_lookup_table ();
3276 else if (cmd == ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE)
3277 socket_update_associate_table ();
3278 else if (cmd == SCIM_TRANS_CMD_REGISTER_PROPERTIES)
3279 socket_register_properties ();
3280 else if (cmd == SCIM_TRANS_CMD_UPDATE_PROPERTY)
3281 socket_update_property ();
3282 else if (cmd == SCIM_TRANS_CMD_PANEL_SHOW_HELP)
3283 socket_show_help ();
3284 else if (cmd == SCIM_TRANS_CMD_PANEL_SHOW_FACTORY_MENU)
3285 socket_show_factory_menu ();
3286 else if (cmd == SCIM_TRANS_CMD_FOCUS_OUT) {
3287 m_signal_focus_out ();
3289 TOOLBAR_MODE_T mode = m_current_toolbar_mode;
3291 if (TOOLBAR_HELPER_MODE == mode)
3292 focus_out_helper (m_current_helper_uuid, client_id, context);
3294 if (m_current_socket_client >= 0) {
3295 m_last_socket_client = m_current_socket_client;
3296 m_last_client_context = m_current_client_context;
3297 m_last_context_uuid = m_current_context_uuid;
3299 m_current_socket_client = -1;
3300 m_current_client_context = 0;
3301 m_current_context_uuid = String ("");
3305 socket_transaction_end ();
3307 } else if (client_info.type == HELPER_CLIENT) {
3308 socket_transaction_start ();
3309 while (m_recv_trans.get_command (cmd)) {
3310 if (cmd == SCIM_TRANS_CMD_PANEL_REGISTER_HELPER) {
3311 socket_helper_register_helper (client_id);
3314 socket_transaction_end ();
3315 }else if (client_info.type == HELPER_ACT_CLIENT) {
3316 socket_transaction_start ();
3317 while (m_recv_trans.get_command (cmd)) {
3318 if (cmd == SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER) {
3319 socket_helper_register_helper_passive (client_id);
3320 } else if (cmd == SCIM_TRANS_CMD_COMMIT_STRING) {
3321 socket_helper_commit_string (client_id);
3322 } else if (cmd == SCIM_TRANS_CMD_SHOW_PREEDIT_STRING) {
3323 socket_helper_show_preedit_string (client_id);
3324 } else if (cmd == SCIM_TRANS_CMD_SHOW_AUX_STRING) {
3325 socket_show_aux_string ();
3326 } else if (cmd == SCIM_TRANS_CMD_SHOW_LOOKUP_TABLE) {
3327 socket_show_lookup_table ();
3328 } else if (cmd == ISM_TRANS_CMD_SHOW_ASSOCIATE_TABLE) {
3329 socket_show_associate_table ();
3330 } else if (cmd == SCIM_TRANS_CMD_HIDE_PREEDIT_STRING) {
3331 socket_helper_hide_preedit_string (client_id);
3332 } else if (cmd == SCIM_TRANS_CMD_HIDE_AUX_STRING) {
3333 socket_hide_aux_string ();
3334 } else if (cmd == SCIM_TRANS_CMD_HIDE_LOOKUP_TABLE) {
3335 socket_hide_lookup_table ();
3336 } else if (cmd == ISM_TRANS_CMD_HIDE_ASSOCIATE_TABLE) {
3337 socket_hide_associate_table ();
3338 } else if (cmd == SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING) {
3339 socket_helper_update_preedit_string (client_id);
3340 } else if (cmd == SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET) {
3341 socket_helper_update_preedit_caret (client_id);
3342 } else if (cmd == SCIM_TRANS_CMD_UPDATE_AUX_STRING) {
3343 socket_update_aux_string ();
3344 } else if (cmd == SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE) {
3345 socket_update_lookup_table ();
3346 } else if (cmd == ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE) {
3347 socket_update_associate_table ();
3348 } else if (cmd == SCIM_TRANS_CMD_PROCESS_KEY_EVENT ||
3349 cmd == SCIM_TRANS_CMD_PANEL_SEND_KEY_EVENT) {
3350 socket_helper_send_key_event (client_id);
3351 } else if (cmd == SCIM_TRANS_CMD_FORWARD_KEY_EVENT) {
3352 socket_helper_forward_key_event (client_id);
3353 } else if (cmd == SCIM_TRANS_CMD_PANEL_SEND_IMENGINE_EVENT) {
3354 socket_helper_send_imengine_event (client_id);
3355 } else if (cmd == SCIM_TRANS_CMD_REGISTER_PROPERTIES) {
3356 socket_helper_register_properties (client_id);
3357 } else if (cmd == SCIM_TRANS_CMD_UPDATE_PROPERTY) {
3358 socket_helper_update_property (client_id);
3359 } else if (cmd == SCIM_TRANS_CMD_RELOAD_CONFIG) {
3361 m_signal_reload_config ();
3362 } else if (cmd == ISM_TRANS_CMD_ISE_PANEL_HIDED) {
3363 socket_helper_update_state_hided (client_id);
3364 } else if (cmd == ISM_TRANS_CMD_ISE_PANEL_SHOWED) {
3365 socket_helper_update_state_showed (client_id);
3366 } else if (cmd == ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT) {
3367 socket_helper_update_input_context (client_id);
3368 } else if (cmd == ISM_TRANS_CMD_ISE_RESULT_TO_IMCONTROL) {
3369 socket_helper_commit_ise_result_to_imcontrol (client_id);
3370 } else if (cmd == ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST) {
3371 socket_get_keyboard_ise_list ();
3372 } else if (cmd == ISM_TRANS_CMD_SET_CANDIDATE_UI) {
3373 socket_set_candidate_ui ();
3374 } else if (cmd == ISM_TRANS_CMD_GET_CANDIDATE_UI) {
3375 socket_get_candidate_ui ();
3376 } else if (cmd == ISM_TRANS_CMD_SET_CANDIDATE_POSITION) {
3377 socket_set_candidate_position ();
3378 } else if (cmd == ISM_TRANS_CMD_HIDE_CANDIDATE) {
3379 socket_hide_candidate ();
3380 } else if (cmd == ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY) {
3381 socket_get_candidate_geometry ();
3382 } else if (cmd == ISM_TRANS_CMD_SET_KEYBOARD_ISE_BY_NAME) {
3383 socket_set_keyboard_ise (ISM_TRANS_CMD_SET_KEYBOARD_ISE_BY_NAME);
3384 } else if (cmd == ISM_TRANS_CMD_SET_KEYBOARD_ISE_BY_UUID) {
3385 socket_set_keyboard_ise (ISM_TRANS_CMD_SET_KEYBOARD_ISE_BY_UUID);
3386 } else if (cmd == ISM_TRANS_CMD_GET_KEYBOARD_ISE) {
3387 socket_get_keyboard_ise ();
3388 } else if (cmd == ISM_TRANS_CMD_UPDATE_ISE_GEOMETRY) {
3389 socket_helper_update_ise_geometry (client_id);
3390 } else if (cmd == ISM_TRANS_CMD_EXPAND_CANDIDATE) {
3391 socket_helper_expand_candidate (client_id);
3392 } else if (cmd == ISM_TRANS_CMD_CONTRACT_CANDIDATE) {
3393 socket_helper_contract_candidate (client_id);
3394 } else if (cmd == SCIM_TRANS_CMD_GET_SURROUNDING_TEXT) {
3395 socket_helper_get_surrounding_text (client_id);
3396 } else if (cmd == SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT) {
3397 socket_helper_delete_surrounding_text (client_id);
3400 socket_transaction_end ();
3402 else if (client_info.type == IMCONTROL_ACT_CLIENT)
3404 socket_transaction_start ();
3406 while (m_recv_trans.get_command (cmd))
3408 if (cmd == ISM_TRANS_CMD_SHOW_ISF_CONTROL)
3409 show_isf_panel (client_id);
3410 else if (cmd == ISM_TRANS_CMD_HIDE_ISF_CONTROL)
3411 hide_isf_panel (client_id);
3412 else if (cmd == ISM_TRANS_CMD_SHOW_ISE_PANEL)
3413 show_ise_panel (client_id);
3414 else if (cmd == ISM_TRANS_CMD_HIDE_ISE_PANEL)
3415 hide_ise_panel (client_id);
3416 else if (cmd == ISM_TRANS_CMD_GET_ACTIVE_ISE_GEOMETRY)
3417 get_input_panel_geometry (client_id);
3418 else if (cmd == ISM_TRANS_CMD_GET_CANDIDATE_GEOMETRY)
3419 get_candidate_window_geometry (client_id);
3420 else if (cmd == ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE)
3421 get_ise_language_locale (client_id);
3422 else if (cmd == ISM_TRANS_CMD_SET_ISE_MODE)
3423 set_ise_mode (client_id);
3424 else if (cmd == ISM_TRANS_CMD_SET_ISE_LANGUAGE)
3425 set_ise_language (client_id);
3426 else if (cmd == ISM_TRANS_CMD_SET_ISE_IMDATA)
3427 set_ise_imdata (client_id);
3428 else if (cmd == ISM_TRANS_CMD_GET_ISE_IMDATA)
3429 get_ise_imdata (client_id);
3430 else if (cmd == ISM_TRANS_CMD_GET_ACTIVE_ISE_NAME)
3431 get_active_ise_name (client_id);
3432 else if (cmd == ISM_TRANS_CMD_SET_ACTIVE_ISE_BY_NAME)
3433 set_active_ise_by_name (client_id);
3434 else if (cmd == ISM_TRANS_CMD_SET_ACTIVE_ISE_BY_UUID)
3435 set_active_ise_by_uuid (client_id);
3436 else if (cmd == ISM_TRANS_CMD_SET_RETURN_KEY_TYPE)
3437 set_ise_return_key_type (client_id);
3438 else if (cmd == ISM_TRANS_CMD_GET_RETURN_KEY_TYPE)
3439 get_ise_return_key_type (client_id);
3440 else if (cmd == ISM_TRANS_CMD_SET_RETURN_KEY_DISABLE)
3441 set_ise_return_key_disable (client_id);
3442 else if (cmd == ISM_TRANS_CMD_GET_RETURN_KEY_DISABLE)
3443 get_ise_return_key_disable (client_id);
3444 else if (cmd == ISM_TRANS_CMD_GET_LAYOUT)
3445 get_ise_layout (client_id);
3446 else if (cmd == ISM_TRANS_CMD_SET_LAYOUT)
3447 set_ise_layout (client_id);
3448 else if (cmd == ISM_TRANS_CMD_SET_CAPS_MODE)
3449 set_ise_caps_mode (client_id);
3450 else if (cmd == ISM_TRANS_CMD_GET_ISE_LIST)
3451 get_ise_list (client_id);
3452 else if (cmd == ISM_TRANS_CMD_RESET_ISE_OPTION)
3453 reset_ise_option (client_id);
3454 else if (cmd == ISM_TRANS_CMD_GET_LANGUAGE_LIST)
3455 get_language_list (client_id);
3456 else if (cmd == ISM_TRANS_CMD_GET_ALL_LANGUAGE_LIST)
3457 get_all_language (client_id);
3458 else if (cmd == ISM_TRANS_CMD_GET_ISE_LANGUAGE)
3459 get_ise_language (client_id);
3460 else if (cmd == ISM_TRANS_CMD_SET_ISF_LANGUAGE)
3461 set_isf_language (client_id);
3462 else if (cmd == ISM_TRANS_CMD_RESET_ISE_CONTEXT)
3463 reset_ise_context (client_id);
3466 socket_transaction_end ();
3470 void socket_exception_callback (SocketServer *server,
3471 const Socket &client)
3473 SCIM_DEBUG_MAIN (2) << "PanelAgent::socket_exception_callback (" << client.get_id () << ")\n";
3475 socket_close_connection (server, client);
3478 bool socket_open_connection (SocketServer *server,
3479 const Socket &client)
3481 SCIM_DEBUG_MAIN (3) << "PanelAgent::socket_open_connection (" << client.get_id () << ")\n";
3484 String type = scim_socket_accept_connection (key,
3486 String ("FrontEnd,Helper,Helper_Active,IMControl_Active,IMControl_Passive"),
3490 if (type.length ()) {
3493 info.type = ((type == "FrontEnd") ? FRONTEND_CLIENT :
3494 ((type == "IMControl_Active") ? IMCONTROL_ACT_CLIENT :
3495 ((type == "Helper_Active") ? HELPER_ACT_CLIENT :
3496 ((type == "IMControl_Passive") ? IMCONTROL_CLIENT : HELPER_CLIENT))));
3498 SCIM_DEBUG_MAIN (4) << "Add client to repository. Type=" << type << " key=" << key << "\n";
3500 m_client_repository [client.get_id ()] = info;
3502 if (info.type == IMCONTROL_ACT_CLIENT) {
3503 m_pending_active_imcontrol_id = client.get_id ();
3504 } else if (info.type == IMCONTROL_CLIENT) {
3505 m_imcontrol_map [m_pending_active_imcontrol_id] = client.get_id ();
3506 m_pending_active_imcontrol_id = -1;
3509 const_cast<Socket &>(client).set_nonblock_mode ();
3515 SCIM_DEBUG_MAIN (4) << "Close client connection " << client.get_id () << "\n";
3516 server->close_connection (client);
3520 void socket_close_connection (SocketServer *server,
3521 const Socket &client)
3523 SCIM_DEBUG_MAIN (3) << "PanelAgent::socket_close_connection (" << client.get_id () << ")\n";
3527 m_signal_close_connection (client.get_id ());
3529 ClientInfo client_info = socket_get_client_info (client.get_id ());
3531 m_client_repository.erase (client.get_id ());
3533 server->close_connection (client);
3535 /* Exit panel if there is no connected client anymore. */
3536 if (client_info.type != UNKNOWN_CLIENT && m_client_repository.size () == 0 && !m_should_resident) {
3537 SCIM_DEBUG_MAIN (4) << "Exit Socket Server Thread.\n";
3538 server->shutdown ();
3539 m_signal_exit.emit ();
3544 if (client_info.type == FRONTEND_CLIENT) {
3545 SCIM_DEBUG_MAIN(4) << "It's a FrontEnd client.\n";
3546 /* The focused client is closed. */
3547 if (m_current_socket_client == client.get_id ()) {
3549 m_current_socket_client = -1;
3550 m_current_client_context = 0;
3551 m_current_context_uuid = String ("");
3554 socket_transaction_start ();
3556 socket_transaction_end ();
3559 if (m_last_socket_client == client.get_id ()) {
3561 m_last_socket_client = -1;
3562 m_last_client_context = 0;
3563 m_last_context_uuid = String ("");
3567 /* Erase all associated Client Context UUIDs. */
3568 std::vector <uint32> ctx_list;
3569 ClientContextUUIDRepository::iterator it = m_client_context_uuids.begin ();
3570 for (; it != m_client_context_uuids.end (); ++it) {
3571 if ((it->first & 0xFFFF) == (client.get_id () & 0xFFFF))
3572 ctx_list.push_back (it->first);
3575 for (size_t i = 0; i < ctx_list.size (); ++i)
3576 m_client_context_uuids.erase (ctx_list [i]);
3578 int client_id = client.get_id ();
3580 /* Erase all helperise info associated with the client */
3582 it = m_client_context_helper.begin ();
3583 for (; it != m_client_context_helper.end (); ++it) {
3584 if ((it->first & 0xFFFF) == (client_id & 0xFFFF)) {
3585 ctx_list.push_back (it->first);
3587 /* similar to stop_helper except that it will not call get_focused_context() */
3588 String uuid = it->second;
3589 if (m_helper_uuid_count.find (uuid) != m_helper_uuid_count.end ()) {
3590 uint32 count = m_helper_uuid_count[uuid];
3592 m_helper_uuid_count.erase (uuid);
3594 HelperClientIndex::iterator pise = m_helper_client_index.find (uuid);
3595 if (pise != m_helper_client_index.end ())
3597 m_send_trans.clear ();
3598 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
3599 m_send_trans.put_data (it->first);
3600 m_send_trans.put_data (uuid);
3601 m_send_trans.put_command (SCIM_TRANS_CMD_EXIT);
3602 m_send_trans.write_to_socket (pise->second.id);
3604 SCIM_DEBUG_MAIN(1) << "Stop HelperISE " << uuid << " ...\n";
3608 m_helper_uuid_count[uuid] = count - 1;
3609 focus_out_helper (uuid, (it->first & 0xFFFF), ((it->first >> 16) & 0x7FFF));
3610 SCIM_DEBUG_MAIN(1) << "Decrement usage count of HelperISE " << uuid
3611 << " to " << m_helper_uuid_count[uuid] << "\n";
3617 for (size_t i = 0; i < ctx_list.size (); ++i)
3618 m_client_context_helper.erase (ctx_list [i]);
3620 HelperInfoRepository::iterator iter = m_helper_info_repository.begin ();
3621 for (; iter != m_helper_info_repository.end (); iter++)
3623 if (!m_current_helper_uuid.compare (iter->second.uuid))
3624 if (!(iter->second.option & ISM_ISE_HIDE_IN_CONTROL_PANEL))
3625 socket_update_control_panel ();
3627 } else if (client_info.type == HELPER_CLIENT) {
3628 SCIM_DEBUG_MAIN(4) << "It's a Helper client.\n";
3632 HelperInfoRepository::iterator hiit = m_helper_info_repository.find (client.get_id ());
3634 if (hiit != m_helper_info_repository.end ()) {
3635 bool restart = false;
3636 String uuid = hiit->second.uuid;
3638 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
3639 if ((hiit->second.option & SCIM_HELPER_AUTO_RESTART) &&
3640 (it != m_helper_client_index.end () && it->second.ref > 0))
3643 m_helper_manager.stop_helper (hiit->second.name);
3645 m_helper_client_index.erase (uuid);
3646 m_helper_info_repository.erase (hiit);
3648 if (restart && !m_ise_exiting) {
3649 m_helper_manager.run_helper (uuid, m_config_name, m_display_name);
3650 std::cerr << "Auto restart soft ISE:" << uuid << "\n";
3654 m_ise_exiting = false;
3657 socket_transaction_start ();
3658 m_signal_remove_helper (client.get_id ());
3659 socket_transaction_end ();
3660 } else if (client_info.type == HELPER_ACT_CLIENT) {
3661 SCIM_DEBUG_MAIN(4) << "It's a Helper passive client.\n";
3665 HelperInfoRepository::iterator hiit = m_helper_active_info_repository.find (client.get_id ());
3666 if (hiit != m_helper_active_info_repository.end ())
3667 m_helper_active_info_repository.erase (hiit);
3670 } else if (client_info.type == IMCONTROL_ACT_CLIENT) {
3671 SCIM_DEBUG_MAIN(4) << "It's a IMCONTROL_ACT_CLIENT client.\n";
3672 int client_id = client.get_id ();
3674 if (client_id == m_current_active_imcontrol_id
3675 && TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
3676 hide_helper (m_current_helper_uuid);
3678 IMControlRepository::iterator iter = m_imcontrol_repository.find (client_id);
3679 if (iter != m_imcontrol_repository.end ())
3681 int size = iter->second.info.size ();
3684 stop_helper ((iter->second.info)[i].uuid, (iter->second.count)[i], DEFAULT_CONTEXT_VALUE);
3685 if ((iter->second.info)[i].option & ISM_ISE_HIDE_IN_CONTROL_PANEL)
3686 m_current_helper_uuid = m_last_helper_uuid;
3689 m_imcontrol_repository.erase (iter);
3692 IntIntRepository::iterator iter2 = m_imcontrol_map.find (client_id);
3693 if (iter2 != m_imcontrol_map.end ())
3694 m_imcontrol_map.erase (iter2);
3698 const ClientInfo & socket_get_client_info (int client)
3700 static ClientInfo null_client = { 0, UNKNOWN_CLIENT };
3702 ClientRepository::iterator it = m_client_repository.find (client);
3704 if (it != m_client_repository.end ())
3711 void socket_turn_on (void)
3713 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_turn_on ()\n";
3715 m_signal_turn_on ();
3718 void socket_turn_off (void)
3720 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_turn_off ()\n";
3722 m_signal_turn_off ();
3725 void socket_update_screen (void)
3727 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_screen ()\n";
3730 if (m_recv_trans.get_data (num) && ((int) num) != m_current_screen) {
3731 SCIM_DEBUG_MAIN(4) << "New Screen number = " << num << "\n";
3732 m_signal_update_screen ((int) num);
3733 helper_all_update_screen ((int) num);
3734 m_current_screen = (num);
3738 void socket_update_spot_location (void)
3740 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_spot_location ()\n";
3743 if (m_recv_trans.get_data (x) && m_recv_trans.get_data (y) && m_recv_trans.get_data (top_y)) {
3744 SCIM_DEBUG_MAIN(4) << "New Spot location x=" << x << " y=" << y << "\n";
3745 m_signal_update_spot_location ((int)x, (int)y, (int)top_y);
3746 helper_all_update_spot_location ((int)x, (int)y);
3750 void socket_update_cursor_position (void)
3752 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_cursor_position ()\n";
3755 if (m_recv_trans.get_data (cursor_pos)) {
3756 SCIM_DEBUG_MAIN(4) << "New cursor position pos=" << cursor_pos << "\n";
3757 helper_all_update_cursor_position ((int)cursor_pos);
3761 void socket_update_surrounding_text (void)
3763 SCIM_DEBUG_MAIN(4) << __FUNCTION__ << "...\n";
3767 if (m_recv_trans.get_data (text) && m_recv_trans.get_data (cursor)) {
3768 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
3770 if (it != m_helper_client_index.end ())
3774 Socket client_socket (it->second.id);
3779 get_focused_context (client, context);
3780 ctx = get_helper_ic (client, context);
3782 m_send_trans.clear ();
3783 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
3784 m_send_trans.put_data (ctx);
3785 m_send_trans.put_data (m_current_helper_uuid);
3786 m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_SURROUNDING_TEXT);
3787 m_send_trans.put_data (text);
3788 m_send_trans.put_data (cursor);
3789 m_send_trans.write_to_socket (client_socket);
3796 void socket_update_factory_info (void)
3798 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_factory_info ()\n";
3800 PanelFactoryInfo info;
3801 if (m_recv_trans.get_data (info.uuid) && m_recv_trans.get_data (info.name) &&
3802 m_recv_trans.get_data (info.lang) && m_recv_trans.get_data (info.icon)) {
3803 SCIM_DEBUG_MAIN(4) << "New Factory info uuid=" << info.uuid << " name=" << info.name << "\n";
3804 info.lang = scim_get_normalized_language (info.lang);
3805 m_signal_update_factory_info (info);
3809 void socket_show_help (void)
3811 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_show_help ()\n";
3814 if (m_recv_trans.get_data (help))
3815 m_signal_show_help (help);
3818 void socket_show_factory_menu (void)
3820 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_show_factory_menu ()\n";
3822 PanelFactoryInfo info;
3823 std::vector <PanelFactoryInfo> vec;
3825 while (m_recv_trans.get_data (info.uuid) && m_recv_trans.get_data (info.name) &&
3826 m_recv_trans.get_data (info.lang) && m_recv_trans.get_data (info.icon)) {
3827 info.lang = scim_get_normalized_language (info.lang);
3828 vec.push_back (info);
3832 m_signal_show_factory_menu (vec);
3835 void socket_turn_on_log (void)
3838 if (m_recv_trans.get_data (isOn)) {
3840 DebugOutput::enable_debug (SCIM_DEBUG_AllMask);
3841 DebugOutput::set_verbose_level (7);
3842 SCIM_DEBUG_MAIN(4) << __func__ << " on\n";
3844 SCIM_DEBUG_MAIN(4) << __func__ << " off\n";
3845 DebugOutput::disable_debug (SCIM_DEBUG_AllMask);
3846 DebugOutput::set_verbose_level (0);
3850 uint32 focused_context;
3852 get_focused_context (focused_client, focused_context);
3854 if (focused_client == -1) {
3855 std::cerr << __func__ << " get_focused_context is failed!!!\n";
3859 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
3861 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
3863 if (it != m_helper_client_index.end ())
3865 Socket client_socket (it->second.id);
3868 ctx = get_helper_ic (focused_client, focused_context);
3870 m_send_trans.clear ();
3871 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
3872 m_send_trans.put_data (ctx);
3873 m_send_trans.put_data (m_current_helper_uuid);
3874 m_send_trans.put_command (ISM_TRANS_CMD_TURN_ON_LOG);
3875 m_send_trans.put_data (isOn);
3876 m_send_trans.write_to_socket (client_socket);
3880 ClientInfo client_info = socket_get_client_info (focused_client);
3881 if (client_info.type == FRONTEND_CLIENT) {
3882 Socket socket_client (focused_client);
3884 m_send_trans.clear ();
3885 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
3886 m_send_trans.put_data (focused_context);
3887 m_send_trans.put_command (ISM_TRANS_CMD_TURN_ON_LOG);
3888 m_send_trans.put_data (isOn);
3889 m_send_trans.write_to_socket (socket_client);
3895 void socket_show_preedit_string (void)
3897 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_show_preedit_string ()\n";
3898 m_signal_show_preedit_string ();
3901 void socket_show_aux_string (void)
3903 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_show_aux_string ()\n";
3904 m_signal_show_aux_string ();
3907 void socket_show_lookup_table (void)
3909 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_show_lookup_table ()\n";
3910 m_signal_show_lookup_table ();
3913 void socket_show_associate_table (void)
3915 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_show_associate_table ()\n";
3916 m_signal_show_associate_table ();
3919 void socket_hide_preedit_string (void)
3921 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_hide_preedit_string ()\n";
3922 m_signal_hide_preedit_string ();
3925 void socket_hide_aux_string (void)
3927 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_hide_aux_string ()\n";
3928 m_signal_hide_aux_string ();
3931 void socket_hide_lookup_table (void)
3933 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_hide_lookup_table ()\n";
3934 m_signal_hide_lookup_table ();
3937 void socket_hide_associate_table (void)
3939 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_hide_associate_table ()\n";
3940 m_signal_hide_associate_table ();
3943 void socket_update_preedit_string (void)
3945 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_preedit_string ()\n";
3948 AttributeList attrs;
3949 if (m_recv_trans.get_data (str) && m_recv_trans.get_data (attrs))
3950 m_signal_update_preedit_string (str, attrs);
3953 void socket_update_preedit_caret (void)
3955 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_preedit_caret ()\n";
3958 if (m_recv_trans.get_data (caret))
3959 m_signal_update_preedit_caret ((int) caret);
3962 void socket_update_aux_string (void)
3964 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_aux_string ()\n";
3967 AttributeList attrs;
3968 if (m_recv_trans.get_data (str) && m_recv_trans.get_data (attrs))
3969 m_signal_update_aux_string (str, attrs);
3972 void socket_update_lookup_table (void)
3974 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_lookup_table ()\n";
3977 if (m_recv_trans.get_data (g_isf_candidate_table))
3980 m_signal_update_lookup_table (g_isf_candidate_table);
3988 void socket_update_associate_table (void)
3990 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_associate_table ()\n";
3992 CommonLookupTable table;
3993 if (m_recv_trans.get_data (table))
3994 m_signal_update_associate_table (table);
3997 void socket_update_control_panel (void)
3999 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_control_panel ()\n";
4000 /* Check default ISE for no context app */
4001 #ifdef ONE_HELPER_ISE_PROCESS
4002 uint32 ctx = get_helper_ic (-1, 0);
4003 ClientContextUUIDRepository::iterator it = m_client_context_helper.find (ctx);
4004 if (it != m_client_context_helper.end ())
4006 if (m_should_shared_ise)
4008 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
4010 if (m_current_helper_uuid != it->second)
4012 stop_helper (it->second, -1, 0);
4013 start_helper (m_current_helper_uuid, -1, 0);
4016 else if (TOOLBAR_KEYBOARD_MODE == m_current_toolbar_mode)
4017 stop_helper (it->second, -1, 0);
4021 m_current_toolbar_mode = TOOLBAR_HELPER_MODE;
4022 m_current_helper_uuid = it->second;
4027 if (m_should_shared_ise)
4029 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
4030 start_helper (m_current_helper_uuid, -1, 0);
4034 m_current_toolbar_mode = TOOLBAR_KEYBOARD_MODE;
4040 m_signal_get_keyboard_ise (name, uuid);
4042 PanelFactoryInfo info;
4043 if (name.length () > 0)
4044 info = PanelFactoryInfo (uuid, name, String (""), String (""));
4046 info = PanelFactoryInfo (String (""), String (_("English/Keyboard")), String ("C"), String (SCIM_KEYBOARD_ICON_FILE));
4047 m_signal_update_factory_info (info);
4050 void socket_register_properties (void)
4052 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_register_properties ()\n";
4054 PropertyList properties;
4056 if (m_recv_trans.get_data (properties))
4057 m_signal_register_properties (properties);
4060 void socket_update_property (void)
4062 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_update_property ()\n";
4065 if (m_recv_trans.get_data (property))
4066 m_signal_update_property (property);
4069 void socket_get_keyboard_ise_list (void)
4071 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_get_keyboard_ise_list ()\n";
4073 std::vector<String> list;
4075 m_signal_get_keyboard_ise_list (list);
4078 if (m_recv_trans.get_data (uuid))
4080 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
4081 if (it != m_helper_client_index.end ())
4085 get_focused_context (client, context);
4086 uint32 ctx = get_helper_ic (client, context);
4087 Socket socket_client (it->second.id);
4088 m_send_trans.clear ();
4089 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4090 m_send_trans.put_data (ctx);
4091 m_send_trans.put_data (uuid);
4092 m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE_LIST);
4093 m_send_trans.put_data (list.size ());
4094 for (unsigned int i = 0; i < list.size (); i++)
4095 m_send_trans.put_data (list[i]);
4096 m_send_trans.write_to_socket (socket_client);
4101 void socket_set_candidate_ui (void)
4103 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_set_candidate_ui ()\n";
4106 if (m_recv_trans.get_data (style) && m_recv_trans.get_data (mode))
4108 m_signal_set_candidate_ui (style, mode);
4112 void socket_get_candidate_ui (void)
4114 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_get_candidate_ui ()\n";
4116 int style = 0, mode = 0;
4117 m_signal_get_candidate_ui (style, mode);
4120 if (m_recv_trans.get_data (uuid))
4122 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
4123 if (it != m_helper_client_index.end ())
4127 get_focused_context (client, context);
4128 uint32 ctx = get_helper_ic (client, context);
4129 Socket socket_client (it->second.id);
4130 m_send_trans.clear ();
4131 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4132 m_send_trans.put_data (ctx);
4133 m_send_trans.put_data (uuid);
4134 m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_CANDIDATE_UI);
4135 m_send_trans.put_data (style);
4136 m_send_trans.put_data (mode);
4137 m_send_trans.write_to_socket (socket_client);
4142 void socket_set_candidate_position (void)
4144 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_set_candidate_position ()\n";
4147 if (m_recv_trans.get_data (left) && m_recv_trans.get_data (top))
4149 m_signal_set_candidate_position (left, top);
4153 void socket_hide_candidate (void)
4155 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_hide_candidate ()\n";
4157 m_signal_hide_preedit_string ();
4158 m_signal_hide_aux_string ();
4159 m_signal_hide_lookup_table ();
4160 m_signal_hide_associate_table ();
4163 void socket_get_candidate_geometry (void)
4165 SCIM_DEBUG_MAIN(4) << __func__ << " \n";
4168 if (m_recv_trans.get_data (uuid)) {
4169 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
4170 if (it != m_helper_client_index.end ()) {
4171 struct rectinfo info = {0, 0, 0, 0};
4172 m_signal_get_candidate_geometry (info);
4176 get_focused_context (client, context);
4177 uint32 ctx = get_helper_ic (client, context);
4178 Socket socket_client (it->second.id);
4179 m_send_trans.clear ();
4180 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4181 m_send_trans.put_data (ctx);
4182 m_send_trans.put_data (uuid);
4183 m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_CANDIDATE_GEOMETRY);
4184 m_send_trans.put_data (info.pos_x);
4185 m_send_trans.put_data (info.pos_y);
4186 m_send_trans.put_data (info.width);
4187 m_send_trans.put_data (info.height);
4188 m_send_trans.write_to_socket (socket_client);
4193 void socket_set_keyboard_ise (int type)
4195 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_set_keyboard_ise ()\n";
4198 if (m_recv_trans.get_data (ise))
4199 m_signal_set_keyboard_ise (type, ise);
4202 void socket_helper_update_ise_geometry (int client)
4204 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
4206 uint32 x, y, width, height;
4207 if (m_recv_trans.get_data (x) && m_recv_trans.get_data (y) &&
4208 m_recv_trans.get_data (width) && m_recv_trans.get_data (height)) {
4209 HelperInfoRepository::iterator it = m_helper_active_info_repository.find (client);
4210 if (it != m_helper_active_info_repository.end ()) {
4211 if (it->second.uuid == m_current_helper_uuid)
4212 m_signal_update_ise_geometry (x, y, width, height);
4217 void socket_helper_expand_candidate (int client)
4219 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
4221 HelperInfoRepository::iterator it = m_helper_active_info_repository.find (client);
4222 if (it != m_helper_active_info_repository.end ()) {
4223 if (it->second.uuid == m_current_helper_uuid)
4224 m_signal_expand_candidate ();
4228 void socket_helper_contract_candidate (int client)
4230 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
4232 HelperInfoRepository::iterator it = m_helper_active_info_repository.find (client);
4233 if (it != m_helper_active_info_repository.end ()) {
4234 if (it->second.uuid == m_current_helper_uuid)
4235 m_signal_contract_candidate ();
4239 void socket_get_keyboard_ise (void)
4241 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_get_keyboard_ise ()\n";
4243 String ise_name, ise_uuid;
4248 get_focused_context (client, context);
4249 ctx = get_helper_ic (client, context);
4251 if (m_client_context_uuids.find (ctx) != m_client_context_uuids.end ())
4252 ise_uuid = m_client_context_uuids[ctx];
4253 m_signal_get_keyboard_ise (ise_name, ise_uuid);
4256 if (m_recv_trans.get_data (uuid))
4258 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
4259 if (it != m_helper_client_index.end ())
4263 get_focused_context (client, context);
4264 uint32 ctx = get_helper_ic (client, context);
4265 Socket socket_client (it->second.id);
4266 m_send_trans.clear ();
4267 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4268 m_send_trans.put_data (ctx);
4269 m_send_trans.put_data (uuid);
4270 m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_KEYBOARD_ISE);
4271 m_send_trans.put_data (ise_name);
4272 m_send_trans.put_data (ise_uuid);
4273 m_send_trans.write_to_socket (socket_client);
4278 void socket_start_helper (int client, uint32 context, const String &ic_uuid)
4280 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_start_helper ()\n";
4283 if (m_recv_trans.get_data (uuid) && uuid.length ()) {
4284 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
4288 uint32 ic = get_helper_ic (client, context);
4290 SCIM_DEBUG_MAIN(5) << "Helper UUID =" << uuid << " IC UUID =" << ic_uuid <<"\n";
4292 if (it == m_helper_client_index.end ()) {
4293 SCIM_DEBUG_MAIN(5) << "Run this Helper.\n";
4294 m_start_helper_ic_index [uuid].push_back (std::make_pair (ic, ic_uuid));
4295 m_helper_manager.run_helper (uuid, m_config_name, m_display_name);
4297 SCIM_DEBUG_MAIN(5) << "Increase the Reference count.\n";
4298 Socket client_socket (it->second.id);
4299 m_send_trans.clear ();
4300 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4301 m_send_trans.put_data (ic);
4302 m_send_trans.put_data (ic_uuid);
4303 m_send_trans.put_command (SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT);
4304 m_send_trans.write_to_socket (client_socket);
4312 void socket_stop_helper (int client, uint32 context, const String &ic_uuid)
4314 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_stop_helper ()\n";
4317 if (m_recv_trans.get_data (uuid) && uuid.length ()) {
4318 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
4322 uint32 ic = get_helper_ic (client, context);
4324 SCIM_DEBUG_MAIN(5) << "Helper UUID =" << uuid << " IC UUID =" << ic_uuid <<"\n";
4326 if (it != m_helper_client_index.end ()) {
4327 SCIM_DEBUG_MAIN(5) << "Decrase the Reference count.\n";
4329 Socket client_socket (it->second.id);
4330 m_send_trans.clear ();
4331 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4332 m_send_trans.put_data (ic);
4333 m_send_trans.put_data (ic_uuid);
4334 m_send_trans.put_command (SCIM_TRANS_CMD_HELPER_DETACH_INPUT_CONTEXT);
4335 if (it->second.ref <= 0)
4336 m_send_trans.put_command (SCIM_TRANS_CMD_EXIT);
4337 m_send_trans.write_to_socket (client_socket);
4344 void socket_send_helper_event (int client, uint32 context, const String &ic_uuid)
4346 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_send_helper_event ()\n";
4349 if (m_recv_trans.get_data (uuid) && m_recv_trans.get_data (m_nest_trans) &&
4350 uuid.length () && m_nest_trans.valid ()) {
4351 HelperClientIndex::iterator it = m_helper_client_index.find (uuid);
4352 if (it != m_helper_client_index.end ()) {
4353 Socket client_socket (it->second.id);
4357 m_send_trans.clear ();
4358 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4360 /* FIXME: We presume that client and context are both less than 65536.
4361 * Hopefully, it should be true in any UNIXs.
4362 * So it's ok to combine client and context into one uint32. */
4363 m_send_trans.put_data (get_helper_ic (client, context));
4364 m_send_trans.put_data (ic_uuid);
4365 m_send_trans.put_command (SCIM_TRANS_CMD_HELPER_PROCESS_IMENGINE_EVENT);
4366 m_send_trans.put_data (m_nest_trans);
4367 m_send_trans.write_to_socket (client_socket);
4374 void socket_helper_register_properties (int client)
4376 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_register_properties (" << client << ")\n";
4378 PropertyList properties;
4379 if (m_recv_trans.get_data (properties))
4380 m_signal_register_helper_properties (client, properties);
4383 void socket_helper_update_property (int client)
4385 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_update_property (" << client << ")\n";
4388 if (m_recv_trans.get_data (property))
4389 m_signal_update_helper_property (client, property);
4392 void socket_helper_send_imengine_event (int client)
4394 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_send_imengine_event (" << client << ")\n";
4399 HelperInfoRepository::iterator hiit = m_helper_active_info_repository.find (client);
4401 if (m_recv_trans.get_data (target_ic) &&
4402 m_recv_trans.get_data (target_uuid) &&
4403 m_recv_trans.get_data (m_nest_trans) &&
4404 m_nest_trans.valid () &&
4405 hiit != m_helper_active_info_repository.end ()) {
4408 uint32 target_context;
4410 get_imengine_client_context (target_ic, target_client, target_context);
4413 uint32 focused_context;
4414 String focused_uuid;
4416 focused_uuid = get_focused_context (focused_client, focused_context);
4418 if (target_ic == (uint32) (-1)) {
4419 target_client = focused_client;
4420 target_context = focused_context;
4423 if (target_uuid.length () == 0)
4424 target_uuid = focused_uuid;
4426 ClientInfo client_info = socket_get_client_info (target_client);
4428 SCIM_DEBUG_MAIN(5) << "Target UUID = " << target_uuid << " Focused UUId = " << focused_uuid << "\nTarget Client = " << target_client << "\n";
4430 if (client_info.type == FRONTEND_CLIENT) {
4431 Socket socket_client (target_client);
4433 m_send_trans.clear ();
4434 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4435 m_send_trans.put_data (target_context);
4436 m_send_trans.put_command (SCIM_TRANS_CMD_PROCESS_HELPER_EVENT);
4437 m_send_trans.put_data (target_uuid);
4438 m_send_trans.put_data (hiit->second.uuid);
4439 m_send_trans.put_data (m_nest_trans);
4440 m_send_trans.write_to_socket (socket_client);
4446 void socket_helper_key_event_op (int client, int cmd)
4452 if (m_recv_trans.get_data (target_ic) &&
4453 m_recv_trans.get_data (target_uuid) &&
4454 m_recv_trans.get_data (key) &&
4458 uint32 target_context;
4460 get_imengine_client_context (target_ic, target_client, target_context);
4463 uint32 focused_context;
4464 String focused_uuid;
4466 focused_uuid = get_focused_context (focused_client, focused_context);
4468 if (target_ic == (uint32) (-1)) {
4469 target_client = focused_client;
4470 target_context = focused_context;
4473 if (target_uuid.length () == 0)
4474 target_uuid = focused_uuid;
4476 if (target_client == -1)
4478 /* FIXUP: monitor 'Invalid Window' error */
4479 std::cerr << "focused target client is NULL" << "\n";
4481 else if (target_client == focused_client &&
4482 target_context == focused_context &&
4483 target_uuid == focused_uuid)
4485 ClientInfo client_info = socket_get_client_info (target_client);
4486 if (client_info.type == FRONTEND_CLIENT) {
4487 Socket socket_client (target_client);
4489 m_send_trans.clear ();
4490 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4491 m_send_trans.put_data (target_context);
4492 m_send_trans.put_command (cmd);
4493 m_send_trans.put_data (key);
4494 m_send_trans.write_to_socket (socket_client);
4501 void socket_helper_send_key_event (int client)
4503 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_send_key_event (" << client << ")\n";
4504 ISF_PROF_DEBUG("first message")
4506 socket_helper_key_event_op (client, SCIM_TRANS_CMD_PROCESS_KEY_EVENT);
4509 void socket_helper_forward_key_event (int client)
4511 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_forward_key_event (" << client << ")\n";
4513 socket_helper_key_event_op (client, SCIM_TRANS_CMD_FORWARD_KEY_EVENT);
4516 void socket_helper_commit_string (int client)
4518 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_commit_string (" << client << ")\n";
4524 if (m_recv_trans.get_data (target_ic) &&
4525 m_recv_trans.get_data (target_uuid) &&
4526 m_recv_trans.get_data (wstr) &&
4530 uint32 target_context;
4532 get_imengine_client_context (target_ic, target_client, target_context);
4535 uint32 focused_context;
4536 String focused_uuid;
4538 focused_uuid = get_focused_context (focused_client, focused_context);
4540 if (target_ic == (uint32) (-1)) {
4541 target_client = focused_client;
4542 target_context = focused_context;
4545 if (target_uuid.length () == 0)
4546 target_uuid = focused_uuid;
4548 if (target_client == focused_client &&
4549 target_context == focused_context &&
4550 target_uuid == focused_uuid) {
4551 ClientInfo client_info = socket_get_client_info (target_client);
4552 if (client_info.type == FRONTEND_CLIENT) {
4553 Socket socket_client (target_client);
4555 m_send_trans.clear ();
4556 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4557 m_send_trans.put_data (target_context);
4558 m_send_trans.put_command (SCIM_TRANS_CMD_COMMIT_STRING);
4559 m_send_trans.put_data (wstr);
4560 m_send_trans.write_to_socket (socket_client);
4567 void socket_helper_get_surrounding_text (int client)
4569 SCIM_DEBUG_MAIN(4) << __FUNCTION__ << " (" << client << ")\n";
4572 uint32 maxlen_before;
4573 uint32 maxlen_after;
4575 if (m_recv_trans.get_data (uuid) &&
4576 m_recv_trans.get_data (maxlen_before) &&
4577 m_recv_trans.get_data (maxlen_after)) {
4580 uint32 focused_context;
4581 String focused_uuid;
4583 focused_uuid = get_focused_context (focused_client, focused_context);
4585 ClientInfo client_info = socket_get_client_info (focused_client);
4586 if (client_info.type == FRONTEND_CLIENT) {
4587 Socket socket_client (focused_client);
4589 m_send_trans.clear ();
4590 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4591 m_send_trans.put_data (focused_context);
4592 m_send_trans.put_command (SCIM_TRANS_CMD_GET_SURROUNDING_TEXT);
4593 m_send_trans.put_data (maxlen_before);
4594 m_send_trans.put_data (maxlen_after);
4595 m_send_trans.write_to_socket (socket_client);
4601 void socket_helper_delete_surrounding_text (int client)
4603 SCIM_DEBUG_MAIN(4) << __FUNCTION__ << " (" << client << ")\n";
4608 if (m_recv_trans.get_data (offset) && m_recv_trans.get_data (len)) {
4611 uint32 focused_context;
4612 String focused_uuid;
4614 focused_uuid = get_focused_context (focused_client, focused_context);
4616 ClientInfo client_info = socket_get_client_info (focused_client);
4617 if (client_info.type == FRONTEND_CLIENT) {
4618 Socket socket_client (focused_client);
4620 m_send_trans.clear ();
4621 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4622 m_send_trans.put_data (focused_context);
4623 m_send_trans.put_command (SCIM_TRANS_CMD_DELETE_SURROUNDING_TEXT);
4624 m_send_trans.put_data (offset);
4625 m_send_trans.put_data (len);
4626 m_send_trans.write_to_socket (socket_client);
4632 void socket_helper_show_preedit_string (int client)
4634 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_show_preedit_string (" << client << ")\n";
4639 if (m_recv_trans.get_data (target_ic) && m_recv_trans.get_data (target_uuid)) {
4641 uint32 target_context;
4643 get_imengine_client_context (target_ic, target_client, target_context);
4646 uint32 focused_context;
4647 String focused_uuid;
4649 focused_uuid = get_focused_context (focused_client, focused_context);
4651 if (target_ic == (uint32) (-1)) {
4652 target_client = focused_client;
4653 target_context = focused_context;
4656 if (target_uuid.length () == 0)
4657 target_uuid = focused_uuid;
4659 if (target_client == focused_client &&
4660 target_context == focused_context &&
4661 target_uuid == focused_uuid) {
4662 ClientInfo client_info = socket_get_client_info (target_client);
4663 if (client_info.type == FRONTEND_CLIENT) {
4664 Socket socket_client (target_client);
4666 m_send_trans.clear ();
4667 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4668 m_send_trans.put_data (target_context);
4669 m_send_trans.put_command (SCIM_TRANS_CMD_SHOW_PREEDIT_STRING);
4670 m_send_trans.write_to_socket (socket_client);
4677 void socket_helper_hide_preedit_string (int client)
4679 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_hide_preedit_string (" << client << ")\n";
4684 if (m_recv_trans.get_data (target_ic) && m_recv_trans.get_data (target_uuid)) {
4686 uint32 target_context;
4688 get_imengine_client_context (target_ic, target_client, target_context);
4691 uint32 focused_context;
4692 String focused_uuid;
4694 focused_uuid = get_focused_context (focused_client, focused_context);
4696 if (target_ic == (uint32) (-1)) {
4697 target_client = focused_client;
4698 target_context = focused_context;
4701 if (target_uuid.length () == 0)
4702 target_uuid = focused_uuid;
4704 if (target_client == focused_client &&
4705 target_context == focused_context &&
4706 target_uuid == focused_uuid) {
4707 ClientInfo client_info = socket_get_client_info (target_client);
4708 if (client_info.type == FRONTEND_CLIENT) {
4709 Socket socket_client (target_client);
4711 m_send_trans.clear ();
4712 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4713 m_send_trans.put_data (target_context);
4714 m_send_trans.put_command (SCIM_TRANS_CMD_HIDE_PREEDIT_STRING);
4715 m_send_trans.write_to_socket (socket_client);
4722 void socket_helper_update_preedit_string (int client)
4724 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_update_preedit_string (" << client << ")\n";
4729 AttributeList attrs;
4731 if (m_recv_trans.get_data (target_ic) &&
4732 m_recv_trans.get_data (target_uuid) &&
4733 m_recv_trans.get_data (wstr) && wstr.length () &&
4734 m_recv_trans.get_data (attrs)) {
4737 uint32 target_context;
4739 get_imengine_client_context (target_ic, target_client, target_context);
4742 uint32 focused_context;
4743 String focused_uuid;
4745 focused_uuid = get_focused_context (focused_client, focused_context);
4747 if (target_ic == (uint32) (-1)) {
4748 target_client = focused_client;
4749 target_context = focused_context;
4752 if (target_uuid.length () == 0)
4753 target_uuid = focused_uuid;
4755 if (target_client == focused_client &&
4756 target_context == focused_context &&
4757 target_uuid == focused_uuid) {
4758 ClientInfo client_info = socket_get_client_info (target_client);
4759 if (client_info.type == FRONTEND_CLIENT) {
4760 Socket socket_client (target_client);
4762 m_send_trans.clear ();
4763 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4764 m_send_trans.put_data (target_context);
4765 m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_STRING);
4766 m_send_trans.put_data (wstr);
4767 m_send_trans.put_data (attrs);
4768 m_send_trans.write_to_socket (socket_client);
4775 void socket_helper_update_preedit_caret (int client)
4777 SCIM_DEBUG_MAIN(4) << __func__ << " (" << client << ")\n";
4781 if (m_recv_trans.get_data (caret)) {
4783 uint32 focused_context;
4784 String focused_uuid;
4785 focused_uuid = get_focused_context (focused_client, focused_context);
4787 ClientInfo client_info = socket_get_client_info (focused_client);
4788 if (client_info.type == FRONTEND_CLIENT) {
4789 Socket socket_client (focused_client);
4791 m_send_trans.clear ();
4792 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4793 m_send_trans.put_data (focused_context);
4794 m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_PREEDIT_CARET);
4795 m_send_trans.put_data (caret);
4796 m_send_trans.write_to_socket (socket_client);
4802 void socket_helper_register_helper (int client)
4804 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_register_helper (" << client << ")\n";
4808 bool result = false;
4812 Socket socket_client (client);
4813 m_send_trans.clear ();
4814 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
4816 if (m_recv_trans.get_data (info.uuid) &&
4817 m_recv_trans.get_data (info.name) &&
4818 m_recv_trans.get_data (info.icon) &&
4819 m_recv_trans.get_data (info.description) &&
4820 m_recv_trans.get_data (info.option) &&
4821 info.uuid.length () &&
4822 info.name.length ()) {
4824 SCIM_DEBUG_MAIN(4) << "New Helper uuid=" << info.uuid << " name=" << info.name << "\n";
4826 HelperClientIndex::iterator it = m_helper_client_index.find (info.uuid);
4828 if (it == m_helper_client_index.end ()) {
4829 m_helper_info_repository [client] = info;
4830 m_helper_client_index [info.uuid] = HelperClientStub (client, 1);
4831 m_send_trans.put_command (SCIM_TRANS_CMD_OK);
4833 StartHelperICIndex::iterator icit = m_start_helper_ic_index.find (info.uuid);
4835 if (icit != m_start_helper_ic_index.end ()) {
4836 m_send_trans.put_command (SCIM_TRANS_CMD_HELPER_ATTACH_INPUT_CONTEXT);
4837 for (size_t i = 0; i < icit->second.size (); ++i) {
4838 m_send_trans.put_data (icit->second [i].first);
4839 m_send_trans.put_data (icit->second [i].second);
4841 m_start_helper_ic_index.erase (icit);
4844 m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_SCREEN);
4845 m_send_trans.put_data ((uint32)m_current_screen);
4849 m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
4853 m_send_trans.write_to_socket (socket_client);
4858 m_signal_register_helper (client, info);
4861 void socket_helper_register_helper_passive (int client)
4863 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_register_helper_passive (" << client << ")\n";
4869 if (m_recv_trans.get_data (info.uuid) &&
4870 m_recv_trans.get_data (info.name) &&
4871 m_recv_trans.get_data (info.icon) &&
4872 m_recv_trans.get_data (info.description) &&
4873 m_recv_trans.get_data (info.option) &&
4874 info.uuid.length () &&
4875 info.name.length ()) {
4877 SCIM_DEBUG_MAIN(4) << "New Helper Passive uuid=" << info.uuid << " name=" << info.name << "\n";
4879 HelperInfoRepository::iterator it = m_helper_active_info_repository.find (client);
4880 if (it == m_helper_active_info_repository.end ()) {
4881 m_helper_active_info_repository[client] = info;
4884 StringIntRepository::iterator iter = m_ise_pending_repository.find (info.uuid);
4885 if (iter != m_ise_pending_repository.end ())
4888 Socket client_socket (iter->second);
4890 trans.put_command (SCIM_TRANS_CMD_REPLY);
4891 trans.put_command (SCIM_TRANS_CMD_OK);
4892 trans.write_to_socket (client_socket);
4893 m_ise_pending_repository.erase (iter);
4896 iter = m_ise_pending_repository.find (info.name);
4897 if (iter != m_ise_pending_repository.end ())
4900 Socket client_socket (iter->second);
4902 trans.put_command (SCIM_TRANS_CMD_REPLY);
4903 trans.put_command (SCIM_TRANS_CMD_OK);
4904 trans.write_to_socket (client_socket);
4905 m_ise_pending_repository.erase (iter);
4908 if (m_current_active_imcontrol_id != -1 &&
4909 m_ise_settings != NULL && m_ise_changing)
4911 show_helper (info.uuid, m_ise_settings, m_ise_settings_len);
4912 m_ise_changing = false;
4919 void socket_helper_update_state_hided (int client)
4921 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_update_state_hided (" << client << ")\n";
4923 ClientRepository::iterator iter = m_client_repository.begin ();
4925 for (; iter != m_client_repository.end (); iter++)
4927 if (IMCONTROL_CLIENT == iter->second.type
4928 && iter->first == m_imcontrol_map[m_current_active_imcontrol_id])
4930 Socket client_socket (iter->first);
4934 trans.put_command (SCIM_TRANS_CMD_REQUEST);
4935 trans.put_command (ISM_TRANS_CMD_ISE_PANEL_HIDED);
4937 trans.write_to_socket (client_socket);
4943 void socket_helper_update_state_showed (int client)
4945 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_update_state_showed (" << client << ")\n";
4947 ClientRepository::iterator iter = m_client_repository.begin ();
4949 for (; iter != m_client_repository.end (); iter++)
4951 if (IMCONTROL_CLIENT == iter->second.type &&
4952 iter->first == m_imcontrol_map[m_current_active_imcontrol_id])
4954 Socket client_socket (iter->first);
4958 trans.put_command (SCIM_TRANS_CMD_REQUEST);
4959 trans.put_command (ISM_TRANS_CMD_ISE_PANEL_SHOWED);
4961 trans.write_to_socket (client_socket);
4967 void socket_helper_update_input_context (int client)
4969 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_update_input_context (" << client << ")\n";
4974 if (m_recv_trans.get_data (type) && m_recv_trans.get_data (value))
4976 m_signal_update_input_context ((int)type, (int)value);
4977 ClientRepository::iterator iter = m_client_repository.begin ();
4979 for (; iter != m_client_repository.end (); iter++)
4981 if (IMCONTROL_CLIENT == iter->second.type &&
4982 iter->first == m_imcontrol_map[m_current_active_imcontrol_id])
4984 Socket client_socket (iter->first);
4988 trans.put_command (SCIM_TRANS_CMD_REQUEST);
4989 trans.put_command (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT);
4990 trans.put_data (type);
4991 trans.put_data (value);
4993 trans.write_to_socket (client_socket);
5000 void socket_helper_commit_ise_result_to_imcontrol (int client)
5002 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_helper_commit_ise_result_to_imcontrol (" << client << ")\n";
5007 if (m_recv_trans.get_data (&buf, len))
5009 ClientRepository::iterator iter = m_client_repository.begin ();
5011 for (; iter != m_client_repository.end (); iter++)
5013 if (IMCONTROL_CLIENT == iter->second.type &&
5014 iter->first == m_imcontrol_map[m_current_active_imcontrol_id])
5016 Socket client_socket (iter->first);
5020 trans.put_command (SCIM_TRANS_CMD_REQUEST);
5021 trans.put_command (ISM_TRANS_CMD_ISE_RESULT_TO_IMCONTROL);
5022 trans.put_data (buf, len);
5023 trans.write_to_socket (client_socket);
5033 void socket_reset_helper_input_context (const String &uuid, int client, uint32 context)
5035 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5037 if (it != m_helper_client_index.end ())
5039 Socket client_socket (it->second.id);
5040 uint32 ctx = get_helper_ic (client, context);
5042 m_send_trans.clear ();
5043 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5044 m_send_trans.put_data (ctx);
5045 m_send_trans.put_data (uuid);
5046 m_send_trans.put_command (SCIM_TRANS_CMD_PANEL_RESET_INPUT_CONTEXT);
5047 m_send_trans.write_to_socket (client_socket);
5051 void socket_reset_input_context (int client, uint32 context)
5053 SCIM_DEBUG_MAIN(4) << "PanelAgent::socket_reset_input_context \n";
5055 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5056 socket_reset_helper_input_context (m_current_helper_uuid, client, context);
5059 bool helper_select_aux (uint32 item)
5061 SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_select_aux \n";
5063 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5065 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5067 if (it != m_helper_client_index.end ())
5071 Socket client_socket (it->second.id);
5074 get_focused_context (client, context);
5075 ctx = get_helper_ic (client, context);
5077 m_send_trans.clear ();
5078 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5079 m_send_trans.put_data (ctx);
5080 m_send_trans.put_data (m_current_helper_uuid);
5081 m_send_trans.put_command (ISM_TRANS_CMD_SELECT_AUX);
5082 m_send_trans.put_data ((uint32)item);
5083 m_send_trans.write_to_socket (client_socket);
5092 bool helper_select_candidate (uint32 item)
5094 SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_select_candidate \n";
5096 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5098 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5100 if (it != m_helper_client_index.end ())
5104 Socket client_socket (it->second.id);
5107 get_focused_context (client, context);
5108 ctx = get_helper_ic (client, context);
5110 m_send_trans.clear ();
5111 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5112 m_send_trans.put_data (ctx);
5113 m_send_trans.put_data (m_current_helper_uuid);
5114 m_send_trans.put_command (SCIM_TRANS_CMD_SELECT_CANDIDATE);
5115 m_send_trans.put_data ((uint32)item);
5116 m_send_trans.write_to_socket (client_socket);
5125 bool helper_lookup_table_page_up (void)
5127 SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_lookup_table_page_up \n";
5129 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5131 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5133 if (it != m_helper_client_index.end ())
5137 Socket client_socket (it->second.id);
5140 get_focused_context (client, context);
5141 ctx = get_helper_ic (client, context);
5143 m_send_trans.clear ();
5144 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5145 m_send_trans.put_data (ctx);
5146 m_send_trans.put_data (m_current_helper_uuid);
5147 m_send_trans.put_command (SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_UP);
5148 m_send_trans.write_to_socket (client_socket);
5157 bool helper_lookup_table_page_down (void)
5159 SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_lookup_table_page_down \n";
5161 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5163 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5165 if (it != m_helper_client_index.end ())
5169 Socket client_socket (it->second.id);
5172 get_focused_context (client, context);
5173 ctx = get_helper_ic (client, context);
5175 m_send_trans.clear ();
5176 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5177 m_send_trans.put_data (ctx);
5178 m_send_trans.put_data (m_current_helper_uuid);
5179 m_send_trans.put_command (SCIM_TRANS_CMD_LOOKUP_TABLE_PAGE_DOWN);
5180 m_send_trans.write_to_socket (client_socket);
5189 bool helper_update_lookup_table_page_size (uint32 size)
5191 SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_update_lookup_table_page_size \n";
5193 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5195 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5197 if (it != m_helper_client_index.end ())
5201 Socket client_socket (it->second.id);
5204 get_focused_context (client, context);
5205 ctx = get_helper_ic (client, context);
5207 m_send_trans.clear ();
5208 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5209 m_send_trans.put_data (ctx);
5210 m_send_trans.put_data (m_current_helper_uuid);
5211 m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_LOOKUP_TABLE_PAGE_SIZE);
5212 m_send_trans.put_data (size);
5213 m_send_trans.write_to_socket (client_socket);
5222 bool helper_select_associate (uint32 item)
5224 SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_select_associate \n";
5226 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5228 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5230 if (it != m_helper_client_index.end ())
5234 Socket client_socket (it->second.id);
5237 get_focused_context (client, context);
5238 ctx = get_helper_ic (client, context);
5240 m_send_trans.clear ();
5241 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5242 m_send_trans.put_data (ctx);
5243 m_send_trans.put_data (m_current_helper_uuid);
5244 m_send_trans.put_command (ISM_TRANS_CMD_SELECT_ASSOCIATE);
5245 m_send_trans.put_data ((uint32)item);
5246 m_send_trans.write_to_socket (client_socket);
5255 bool helper_associate_table_page_up (void)
5257 SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_associate_table_page_up \n";
5259 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5261 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5263 if (it != m_helper_client_index.end ())
5267 Socket client_socket (it->second.id);
5270 get_focused_context (client, context);
5271 ctx = get_helper_ic (client, context);
5273 m_send_trans.clear ();
5274 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5275 m_send_trans.put_data (ctx);
5276 m_send_trans.put_data (m_current_helper_uuid);
5277 m_send_trans.put_command (ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_UP);
5278 m_send_trans.write_to_socket (client_socket);
5287 bool helper_associate_table_page_down (void)
5289 SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_associate_table_page_down \n";
5291 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5293 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5295 if (it != m_helper_client_index.end ())
5299 Socket client_socket (it->second.id);
5302 get_focused_context (client, context);
5303 ctx = get_helper_ic (client, context);
5305 m_send_trans.clear ();
5306 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5307 m_send_trans.put_data (ctx);
5308 m_send_trans.put_data (m_current_helper_uuid);
5309 m_send_trans.put_command (ISM_TRANS_CMD_ASSOCIATE_TABLE_PAGE_DOWN);
5310 m_send_trans.write_to_socket (client_socket);
5319 bool helper_update_associate_table_page_size (uint32 size)
5321 SCIM_DEBUG_MAIN(4) << "PanelAgent::helper_update_associate_table_page_size \n";
5323 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode)
5325 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5327 if (it != m_helper_client_index.end ())
5331 Socket client_socket (it->second.id);
5334 get_focused_context (client, context);
5335 ctx = get_helper_ic (client, context);
5337 m_send_trans.clear ();
5338 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5339 m_send_trans.put_data (ctx);
5340 m_send_trans.put_data (m_current_helper_uuid);
5341 m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_ASSOCIATE_TABLE_PAGE_SIZE);
5342 m_send_trans.put_data (size);
5343 m_send_trans.write_to_socket (client_socket);
5352 bool helper_update_displayed_candidate_number (uint32 size)
5354 SCIM_DEBUG_MAIN(4) << __func__ << "\n";
5356 if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode) {
5357 HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
5359 if (it != m_helper_client_index.end ()) {
5362 Socket client_socket (it->second.id);
5365 get_focused_context (client, context);
5366 ctx = get_helper_ic (client, context);
5368 m_send_trans.clear ();
5369 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5370 m_send_trans.put_data (ctx);
5371 m_send_trans.put_data (m_current_helper_uuid);
5372 m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_DISPLAYED_CANDIDATE);
5373 m_send_trans.put_data (size);
5374 m_send_trans.write_to_socket (client_socket);
5383 void helper_all_update_spot_location (int x, int y)
5385 SCIM_DEBUG_MAIN (5) << "PanelAgent::helper_all_update_spot_location (" << x << "," << y << ")\n";
5387 HelperInfoRepository::iterator hiit = m_helper_info_repository.begin ();
5391 String uuid = get_focused_context (client, context);
5395 m_send_trans.clear ();
5396 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5398 /* FIXME: We presume that client and context are both less than 65536.
5399 * Hopefully, it should be true in any UNIXs.
5400 * So it's ok to combine client and context into one uint32. */
5401 m_send_trans.put_data (get_helper_ic (client, context));
5402 m_send_trans.put_data (uuid);
5403 m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION);
5404 m_send_trans.put_data ((uint32) x);
5405 m_send_trans.put_data ((uint32) y);
5407 for (; hiit != m_helper_info_repository.end (); ++ hiit) {
5408 if (hiit->second.option & SCIM_HELPER_NEED_SPOT_LOCATION_INFO) {
5409 Socket client_socket (hiit->first);
5410 m_send_trans.write_to_socket (client_socket);
5417 void helper_all_update_cursor_position (int cursor_pos)
5419 SCIM_DEBUG_MAIN (5) << "PanelAgent::helper_all_update_cursor_position (" << cursor_pos << ")\n";
5421 HelperInfoRepository::iterator hiit = m_helper_info_repository.begin ();
5425 String uuid = get_focused_context (client, context);
5429 m_send_trans.clear ();
5430 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5431 m_send_trans.put_data (get_helper_ic (client, context));
5432 m_send_trans.put_data (uuid);
5433 m_send_trans.put_command (ISM_TRANS_CMD_UPDATE_CURSOR_POSITION);
5434 m_send_trans.put_data ((uint32) cursor_pos);
5436 for (; hiit != m_helper_info_repository.end (); ++ hiit) {
5437 Socket client_socket (hiit->first);
5438 m_send_trans.write_to_socket (client_socket);
5444 void helper_all_update_screen (int screen)
5446 SCIM_DEBUG_MAIN (5) << "PanelAgent::helper_all_update_screen (" << screen << ")\n";
5448 HelperInfoRepository::iterator hiit = m_helper_info_repository.begin ();
5456 uuid = get_focused_context (client, context);
5458 m_send_trans.clear ();
5459 m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
5461 /* FIXME: We presume that client and context are both less than 65536.
5462 * Hopefully, it should be true in any UNIXs.
5463 * So it's ok to combine client and context into one uint32. */
5464 m_send_trans.put_data (get_helper_ic (client, context));
5465 m_send_trans.put_data (uuid);
5466 m_send_trans.put_command (SCIM_TRANS_CMD_UPDATE_SCREEN);
5467 m_send_trans.put_data ((uint32) screen);
5469 for (; hiit != m_helper_info_repository.end (); ++ hiit) {
5470 if (hiit->second.option & SCIM_HELPER_NEED_SCREEN_INFO) {
5471 Socket client_socket (hiit->first);
5472 m_send_trans.write_to_socket (client_socket);
5479 const String & get_focused_context (int &client, uint32 &context, bool force_last_context = false) const
5481 if (m_current_socket_client >= 0) {
5482 client = m_current_socket_client;
5483 context = m_current_client_context;
5484 return m_current_context_uuid;
5486 client = m_last_socket_client;
5487 context = m_last_client_context;
5488 return m_last_context_uuid;
5493 void socket_transaction_start (void)
5495 m_signal_transaction_start ();
5498 void socket_transaction_end (void)
5500 m_signal_transaction_end ();
5513 PanelAgent::PanelAgent ()
5514 : m_impl (new PanelAgentImpl ())
5518 PanelAgent::~PanelAgent ()
5524 PanelAgent::initialize (const String &config, const String &display, bool resident)
5526 return m_impl->initialize (config, display, resident);
5530 PanelAgent::valid (void) const
5532 return m_impl->valid ();
5536 PanelAgent::run (void)
5538 return m_impl->run ();
5542 PanelAgent::stop (void)
5549 PanelAgent::get_helper_list (std::vector <HelperInfo> & helpers) const
5551 return m_impl->get_helper_list (helpers);
5554 void PanelAgent::hide_helper (const String &uuid)
5556 m_impl->hide_helper (uuid);
5559 PanelAgent::get_current_toolbar_mode () const
5561 return m_impl->get_current_toolbar_mode ();
5565 PanelAgent::get_current_ise_geometry (rectinfo &rect)
5567 m_impl->get_current_ise_geometry (rect);
5571 PanelAgent::get_current_helper_uuid () const
5573 return m_impl->get_current_helper_uuid ();
5577 PanelAgent::get_current_helper_name () const
5579 return m_impl->get_current_helper_name ();
5583 PanelAgent::get_current_factory_icon () const
5585 return m_impl->get_current_factory_icon ();
5589 PanelAgent::get_current_ise_name () const
5591 return m_impl->get_current_ise_name ();
5595 PanelAgent::set_current_toolbar_mode (TOOLBAR_MODE_T mode)
5597 m_impl->set_current_toolbar_mode (mode);
5601 PanelAgent::set_current_ise_name (String &name)
5603 m_impl->set_current_ise_name (name);
5607 PanelAgent::set_current_ise_style (uint32 &style)
5609 m_impl->set_current_ise_style (style);
5613 PanelAgent::update_ise_name (String &name)
5615 m_impl->update_ise_name (name);
5619 PanelAgent::update_ise_style (uint32 &style)
5621 m_impl->update_ise_style (style);
5625 PanelAgent::update_candidate_panel_event (uint32 nType, uint32 nValue)
5627 m_impl->update_panel_event (ISM_TRANS_CMD_UPDATE_ISF_CANDIDATE_PANEL, nType, nValue);
5631 PanelAgent::update_input_panel_event (uint32 nType, uint32 nValue)
5633 m_impl->update_panel_event (ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT, nType, nValue);
5637 PanelAgent::set_current_factory_icon (String &icon)
5639 m_impl->set_current_factory_icon (icon);
5643 PanelAgent::move_preedit_caret (uint32 position)
5645 return m_impl->move_preedit_caret (position);
5649 PanelAgent::request_help (void)
5651 return m_impl->request_help ();
5655 PanelAgent::request_factory_menu (void)
5657 return m_impl->request_factory_menu ();
5661 PanelAgent::change_factory (const String &uuid)
5663 return m_impl->change_factory (uuid);
5667 PanelAgent::candidate_more_window_show (void)
5669 return m_impl->candidate_more_window_show ();
5673 PanelAgent::candidate_more_window_hide (void)
5675 return m_impl->candidate_more_window_hide ();
5679 PanelAgent::select_aux (uint32 item)
5681 return m_impl->select_aux (item);
5685 PanelAgent::select_candidate (uint32 item)
5687 return m_impl->select_candidate (item);
5691 PanelAgent::lookup_table_page_up (void)
5693 return m_impl->lookup_table_page_up ();
5697 PanelAgent::lookup_table_page_down (void)
5699 return m_impl->lookup_table_page_down ();
5703 PanelAgent::update_lookup_table_page_size (uint32 size)
5705 return m_impl->update_lookup_table_page_size (size);
5709 PanelAgent::select_associate (uint32 item)
5711 return m_impl->select_associate (item);
5715 PanelAgent::associate_table_page_up (void)
5717 return m_impl->associate_table_page_up ();
5721 PanelAgent::associate_table_page_down (void)
5723 return m_impl->associate_table_page_down ();
5727 PanelAgent::update_associate_table_page_size (uint32 size)
5729 return m_impl->update_associate_table_page_size (size);
5733 PanelAgent::update_displayed_candidate_number (uint32 size)
5735 return m_impl->update_displayed_candidate_number (size);
5739 PanelAgent::trigger_property (const String &property)
5741 return m_impl->trigger_property (property);
5745 PanelAgent::trigger_helper_property (int client,
5746 const String &property)
5748 return m_impl->trigger_helper_property (client, property);
5752 PanelAgent::start_helper (const String &uuid)
5754 return m_impl->start_helper (uuid, -2, 0);
5758 PanelAgent::stop_helper (const String &uuid)
5760 return m_impl->stop_helper (uuid, -2, 0);
5764 PanelAgent::set_default_ise (const DEFAULT_ISE_T &ise)
5766 m_impl->set_default_ise (ise);
5770 PanelAgent::set_should_shared_ise (const bool should_shared_ise)
5772 m_impl->set_should_shared_ise (should_shared_ise);
5776 PanelAgent::reset_keyboard_ise () const
5778 return m_impl->reset_keyboard_ise ();
5782 PanelAgent::get_active_ise_list (std::vector<String> &strlist)
5784 return m_impl->get_active_ise_list (strlist);
5788 PanelAgent::get_helper_manager_id (void)
5790 return m_impl->get_helper_manager_id ();
5794 PanelAgent::has_helper_manager_pending_event (void)
5796 return m_impl->has_helper_manager_pending_event ();
5800 PanelAgent::filter_helper_manager_event (void)
5802 return m_impl->filter_helper_manager_event ();
5806 PanelAgent::update_isf_control_status (const bool showed)
5808 m_impl->update_isf_control_status (showed);
5812 PanelAgent::send_display_name (String &name)
5814 return m_impl->send_display_name (name);
5818 PanelAgent::reload_config (void)
5820 return m_impl->reload_config ();
5824 PanelAgent::exit (void)
5826 return m_impl->exit ();
5830 PanelAgent::filter_event (int fd)
5832 return m_impl->filter_event (fd);
5836 PanelAgent::filter_exception_event (int fd)
5838 return m_impl->filter_exception_event (fd);
5842 PanelAgent::get_server_id (void)
5844 return m_impl->get_server_id ();
5848 PanelAgent::update_ise_list (std::vector<String> &strList)
5850 m_impl->update_ise_list (strList);
5854 PanelAgent::set_ise_changing (bool changing)
5856 m_impl->set_ise_changing (changing);
5860 PanelAgent::signal_connect_reload_config (PanelAgentSlotVoid *slot)
5862 return m_impl->signal_connect_reload_config (slot);
5866 PanelAgent::signal_connect_turn_on (PanelAgentSlotVoid *slot)
5868 return m_impl->signal_connect_turn_on (slot);
5872 PanelAgent::signal_connect_turn_off (PanelAgentSlotVoid *slot)
5874 return m_impl->signal_connect_turn_off (slot);
5878 PanelAgent::signal_connect_show_panel (PanelAgentSlotVoid *slot)
5880 return m_impl->signal_connect_show_panel (slot);
5884 PanelAgent::signal_connect_hide_panel (PanelAgentSlotVoid *slot)
5886 return m_impl->signal_connect_hide_panel (slot);
5890 PanelAgent::signal_connect_update_screen (PanelAgentSlotInt *slot)
5892 return m_impl->signal_connect_update_screen (slot);
5896 PanelAgent::signal_connect_update_spot_location (PanelAgentSlotIntIntInt *slot)
5898 return m_impl->signal_connect_update_spot_location (slot);
5902 PanelAgent::signal_connect_update_factory_info (PanelAgentSlotFactoryInfo *slot)
5904 return m_impl->signal_connect_update_factory_info (slot);
5908 PanelAgent::signal_connect_start_default_ise (PanelAgentSlotVoid *slot)
5910 return m_impl->signal_connect_start_default_ise (slot);
5914 PanelAgent::signal_connect_set_candidate_ui (PanelAgentSlotIntInt *slot)
5916 return m_impl->signal_connect_set_candidate_ui (slot);
5920 PanelAgent::signal_connect_get_candidate_ui (PanelAgentSlotIntInt2 *slot)
5922 return m_impl->signal_connect_get_candidate_ui (slot);
5926 PanelAgent::signal_connect_set_candidate_position (PanelAgentSlotIntInt *slot)
5928 return m_impl->signal_connect_set_candidate_position (slot);
5932 PanelAgent::signal_connect_get_candidate_geometry (PanelAgentSlotRect *slot)
5934 return m_impl->signal_connect_get_candidate_geometry (slot);
5938 PanelAgent::signal_connect_get_input_panel_geometry (PanelAgentSlotRect *slot)
5940 return m_impl->signal_connect_get_input_panel_geometry (slot);
5944 PanelAgent::signal_connect_set_keyboard_ise (PanelAgentSlotIntString *slot)
5946 return m_impl->signal_connect_set_keyboard_ise (slot);
5950 PanelAgent::signal_connect_get_keyboard_ise (PanelAgentSlotString2 *slot)
5952 return m_impl->signal_connect_get_keyboard_ise (slot);
5956 PanelAgent::signal_connect_show_help (PanelAgentSlotString *slot)
5958 return m_impl->signal_connect_show_help (slot);
5962 PanelAgent::signal_connect_show_factory_menu (PanelAgentSlotFactoryInfoVector *slot)
5964 return m_impl->signal_connect_show_factory_menu (slot);
5968 PanelAgent::signal_connect_show_preedit_string (PanelAgentSlotVoid *slot)
5970 return m_impl->signal_connect_show_preedit_string (slot);
5974 PanelAgent::signal_connect_show_aux_string (PanelAgentSlotVoid *slot)
5976 return m_impl->signal_connect_show_aux_string (slot);
5980 PanelAgent::signal_connect_show_lookup_table (PanelAgentSlotVoid *slot)
5982 return m_impl->signal_connect_show_lookup_table (slot);
5986 PanelAgent::signal_connect_show_associate_table (PanelAgentSlotVoid *slot)
5988 return m_impl->signal_connect_show_associate_table (slot);
5992 PanelAgent::signal_connect_hide_preedit_string (PanelAgentSlotVoid *slot)
5994 return m_impl->signal_connect_hide_preedit_string (slot);
5998 PanelAgent::signal_connect_hide_aux_string (PanelAgentSlotVoid *slot)
6000 return m_impl->signal_connect_hide_aux_string (slot);
6004 PanelAgent::signal_connect_hide_lookup_table (PanelAgentSlotVoid *slot)
6006 return m_impl->signal_connect_hide_lookup_table (slot);
6010 PanelAgent::signal_connect_hide_associate_table (PanelAgentSlotVoid *slot)
6012 return m_impl->signal_connect_hide_associate_table (slot);
6016 PanelAgent::signal_connect_update_preedit_string (PanelAgentSlotAttributeString *slot)
6018 return m_impl->signal_connect_update_preedit_string (slot);
6022 PanelAgent::signal_connect_update_preedit_caret (PanelAgentSlotInt *slot)
6024 return m_impl->signal_connect_update_preedit_caret (slot);
6028 PanelAgent::signal_connect_update_aux_string (PanelAgentSlotAttributeString *slot)
6030 return m_impl->signal_connect_update_aux_string (slot);
6034 PanelAgent::signal_connect_update_lookup_table (PanelAgentSlotLookupTable *slot)
6036 return m_impl->signal_connect_update_lookup_table (slot);
6040 PanelAgent::signal_connect_update_associate_table (PanelAgentSlotLookupTable *slot)
6042 return m_impl->signal_connect_update_associate_table (slot);
6046 PanelAgent::signal_connect_register_properties (PanelAgentSlotPropertyList *slot)
6048 return m_impl->signal_connect_register_properties (slot);
6052 PanelAgent::signal_connect_update_property (PanelAgentSlotProperty *slot)
6054 return m_impl->signal_connect_update_property (slot);
6058 PanelAgent::signal_connect_register_helper_properties (PanelAgentSlotIntPropertyList *slot)
6060 return m_impl->signal_connect_register_helper_properties (slot);
6064 PanelAgent::signal_connect_update_helper_property (PanelAgentSlotIntProperty *slot)
6066 return m_impl->signal_connect_update_helper_property (slot);
6070 PanelAgent::signal_connect_register_helper (PanelAgentSlotIntHelperInfo *slot)
6072 return m_impl->signal_connect_register_helper (slot);
6076 PanelAgent::signal_connect_remove_helper (PanelAgentSlotInt *slot)
6078 return m_impl->signal_connect_remove_helper (slot);
6082 PanelAgent::signal_connect_set_active_ise_by_uuid (PanelAgentSlotStringBool *slot)
6084 return m_impl->signal_connect_set_active_ise_by_uuid (slot);
6088 PanelAgent::signal_connect_set_active_ise_by_name (PanelAgentSlotString *slot)
6090 return m_impl->signal_connect_set_active_ise_by_name (slot);
6094 PanelAgent::signal_connect_focus_in (PanelAgentSlotVoid *slot)
6096 return m_impl->signal_connect_focus_in (slot);
6100 PanelAgent::signal_connect_focus_out (PanelAgentSlotVoid *slot)
6102 return m_impl->signal_connect_focus_out (slot);
6106 PanelAgent::signal_connect_expand_candidate (PanelAgentSlotVoid *slot)
6108 return m_impl->signal_connect_expand_candidate (slot);
6112 PanelAgent::signal_connect_contract_candidate (PanelAgentSlotVoid *slot)
6114 return m_impl->signal_connect_contract_candidate (slot);
6118 PanelAgent::signal_connect_get_ise_list (PanelAgentSlotBoolStringVector *slot)
6120 return m_impl->signal_connect_get_ise_list (slot);
6124 PanelAgent::signal_connect_get_keyboard_ise_list (PanelAgentSlotBoolStringVector *slot)
6126 return m_impl->signal_connect_get_keyboard_ise_list (slot);
6130 PanelAgent::signal_connect_update_ise_geometry (PanelAgentSlotIntIntIntInt *slot)
6132 return m_impl->signal_connect_update_ise_geometry (slot);
6136 PanelAgent::signal_connect_get_language_list (PanelAgentSlotStringVector *slot)
6138 return m_impl->signal_connect_get_language_list (slot);
6142 PanelAgent::signal_connect_get_all_language (PanelAgentSlotStringVector *slot)
6144 return m_impl->signal_connect_get_all_language (slot);
6148 PanelAgent::signal_connect_get_ise_language (PanelAgentSlotStrStringVector *slot)
6150 return m_impl->signal_connect_get_ise_language (slot);
6154 PanelAgent::signal_connect_set_isf_language (PanelAgentSlotString *slot)
6156 return m_impl->signal_connect_set_isf_language (slot);
6160 PanelAgent::signal_connect_get_ise_info_by_uuid (PanelAgentSlotStringISEINFO *slot)
6162 return m_impl->signal_connect_get_ise_info_by_uuid (slot);
6166 PanelAgent::signal_connect_get_ise_info_by_name (PanelAgentSlotStringISEINFO *slot)
6168 return m_impl->signal_connect_get_ise_info_by_name (slot);
6172 PanelAgent::signal_connect_send_key_event (PanelAgentSlotKeyEvent *slot)
6174 return m_impl->signal_connect_send_key_event (slot);
6178 PanelAgent::signal_connect_accept_connection (PanelAgentSlotInt *slot)
6180 return m_impl->signal_connect_accept_connection (slot);
6184 PanelAgent::signal_connect_close_connection (PanelAgentSlotInt *slot)
6186 return m_impl->signal_connect_close_connection (slot);
6190 PanelAgent::signal_connect_exit (PanelAgentSlotVoid *slot)
6192 return m_impl->signal_connect_exit (slot);
6196 PanelAgent::signal_connect_transaction_start (PanelAgentSlotVoid *slot)
6198 return m_impl->signal_connect_transaction_start (slot);
6202 PanelAgent::signal_connect_transaction_end (PanelAgentSlotVoid *slot)
6204 return m_impl->signal_connect_transaction_end (slot);
6208 PanelAgent::signal_connect_lock (PanelAgentSlotVoid *slot)
6210 return m_impl->signal_connect_lock (slot);
6214 PanelAgent::signal_connect_unlock (PanelAgentSlotVoid *slot)
6216 return m_impl->signal_connect_unlock (slot);
6220 PanelAgent::signal_connect_update_input_context (PanelAgentSlotIntInt *slot)
6222 return m_impl->signal_connect_update_input_context (slot);
6225 } /* namespace scim */
6228 vi:ts=4:nowrap:ai:expandtab