Merging isf-wsc-efl and scim-panel-efl processes
[platform/core/uifw/isf.git] / ism / src / isf_panel_agent_base.h
1 /**
2  * @file scim_panel_agent.h
3  * @brief Defines scim::PanelAgent and their related types.
4  *
5  * scim::PanelAgent is a class used to write Panel daemons.
6  * It acts like a Socket Server and handles all socket clients
7  * issues.
8  */
9
10 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
11
12 /*
13  * Smart Common Input Method
14  *
15  * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
16  * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
17  *
18  *
19  * This library is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU Lesser General Public
21  * License as published by the Free Software Foundation; either
22  * version 2 of the License, or (at your option) any later version.
23  *
24  * This library is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public
30  * License along with this program; if not, write to the
31  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
32  * Boston, MA  02111-1307  USA
33  *
34  * Modifications by Samsung Electronics Co., Ltd.
35  * 1. Add new signals
36  *    a. m_signal_set_keyboard_ise and m_signal_get_keyboard_ise
37  *    b. m_signal_focus_in and m_signal_focus_out
38  *    c. m_signal_expand_candidate, m_signal_contract_candidate and m_signal_set_candidate_ui
39  *    d. m_signal_get_ise_list, m_signal_get_keyboard_ise_list, m_signal_update_ise_geometry and m_signal_get_ise_information
40  *    e. m_signal_set_active_ise_by_uuid and m_signal_get_ise_info_by_uuid
41  *    f. m_signal_accept_connection, m_signal_close_connection and m_signal_exit
42  * 2. Add new interface APIs in PanelClient class
43  *    a. get_helper_manager_id (), has_helper_manager_pending_event () and filter_helper_manager_event ()
44  *    b. update_candidate_panel_event (), update_input_panel_event () and select_aux ()
45  *    c. candidate_more_window_show () and candidate_more_window_hide ()
46  *    d. update_displayed_candidate_number () and update_candidate_item_layout ()
47  *    e. stop_helper (), send_longpress_event () and update_ise_list ()
48  *    f. filter_event (), filter_exception_event () and get_server_id ()
49  * 3. Donot use thread to receive message
50  * 4. Monitor socket frontend for self-recovery function
51  *
52  * $Id: scim_panel_agent.h,v 1.2 2005/06/11 14:50:31 suzhe Exp $
53  */
54
55 #ifndef __ISF_PANEL_AGENT_BASE_H
56 #define __ISF_PANEL_AGENT_BASE_H
57
58 #include <scim_panel_common.h>
59
60 #ifndef _OUT_
61 #define _OUT_
62 #endif
63
64 namespace scim
65 {
66
67 /**
68  * @addtogroup Panel
69  * @ingroup InputServiceFramework
70  * The accessory classes to help develop Panel daemons and FrontEnds
71  * which need to communicate with Panel daemons.
72  * @{
73  */
74
75 typedef struct _ISE_INFO {
76     String uuid;
77     String name;
78     String lang;
79     String icon;
80     uint32 option;
81     TOOLBAR_MODE_T type;
82 } ISE_INFO;
83
84 typedef struct _HELPER_ISE_INFO {
85     std::vector<String> appid;
86     std::vector<String> label;
87     std::vector<uint32> is_enabled;
88     std::vector<uint32> is_preinstalled;
89     std::vector<uint32> has_option;
90 } HELPER_ISE_INFO;
91
92
93 typedef struct DefaultIse {
94     TOOLBAR_MODE_T type;
95     String         uuid;
96     String         name;
97     DefaultIse () : type (TOOLBAR_KEYBOARD_MODE), uuid (""), name ("") { }
98 } DEFAULT_ISE_T;
99
100
101 class PanelAgentBase;
102 class InfoManager;
103 /**
104  * @typedef typedef Pointer <PanelAgentBase> PanelAgentPointer;
105  *
106  * A smart pointer for scim::PanelAgentBase and its derived classes.
107  */
108 typedef Pointer <PanelAgentBase>  PanelAgentPointer;
109
110 /**
111  * @brief The class to implement all socket protocol in Panel.
112  *
113  * This class acts like a stand alone SocketServer.
114  * It has its own dedicated main loop, and will be blocked when run () is called.
115  * So run () must be called within a separated thread, in order to not block
116  * the main loop of the Panel program itself.
117  *
118  * Before calling run (), the panel must hook the callback functions to the
119  * corresponding signals.
120  *
121  * Note that, there are two special signals: lock(void) and unlock(void). These
122  * two signals are used to provide a thread lock to PanelAgent, so that PanelAgent
123  * can run correctly within a multi-threading Panel program.
124  */
125 class EXAPI PanelAgentBase : public ReferencedObject
126 {
127     class PanelAgentBaseImpl;
128     PanelAgentBaseImpl* m_impl;
129
130     PanelAgentBase (const PanelAgentBase&);
131     const PanelAgentBase& operator = (const PanelAgentBase&);
132     String m_name;
133 public:
134     PanelAgentBase (const String& name);
135     virtual ~PanelAgentBase ();
136
137     /**
138     * @brief Initialize this PanelAgent.
139     *
140     * @param config The name of the config module to be used by Helpers.
141     * @param display The name of display, on which the Panel should run.
142     * @param resident If this is true then this PanelAgent will keep running
143     *                 even if there is no more client connected.
144     *
145     * @return true if the PanelAgent is initialized correctly and ready to run.
146     */
147     virtual bool initialize (InfoManager* info_manager, const String& display, bool resident = false);
148
149     /**
150      * @brief Check if this PanelAgent is initialized correctly and ready to run.
151      *
152      * @return true if this PanelAgent is ready to run.
153      */
154     virtual bool valid (void) const;
155
156     /**
157      * @brief Stop this PanelAgent.
158      */
159     virtual void stop (void);
160
161 public:
162
163     /**
164      * @brief Notice helper ISE to focus out.
165      *
166      * @param uuid The helper ISE uuid.
167      */
168     virtual void focus_out_helper (int client, uint32 context, const String& uuid);
169
170     /**
171      * @brief Notice helper ISE to focus in.
172      *
173      * @param uuid The helper ISE uuid.
174      */
175     virtual void focus_in_helper (int client, uint32 context, const String& uuid);
176
177     /**
178      * @brief Notice helper ISE to show window.
179      *
180      * @param uuid The helper ISE uuid.
181      */
182     virtual void show_helper (int client, uint32 context, const String& uuid, char* data, size_t& len);
183
184     /**
185      * @brief Notice helper ISE to hide window.
186      *
187      * @param uuid The helper ISE uuid.
188      */
189     virtual void hide_helper (int client, uint32 context, const String& uuid);
190
191     /**
192      * @brief Reset keyboard ISE.
193      *
194      * @return true if this operation is successful, otherwise return false.
195      */
196     virtual void reset_keyboard_ise (int client, uint32 context);
197
198     /**
199      * @brief Change the factory used by the focused IMEngineInstance object.
200      *
201      * @param uuid The uuid of the new factory.
202      * @return true if the command was sent correctly.
203      */
204     virtual void change_factory (int client, uint32 context, const String&  uuid);
205
206     /**
207      * @brief Notice Helper ISE that candidate more window is showed.
208      * @return true if the command was sent correctly.
209      */
210     virtual void candidate_more_window_show (int client, uint32 context);
211
212     /**
213      * @brief Notice Helper ISE that candidate more window is hidden.
214      * @return true if the command was sent correctly.
215      */
216     virtual void candidate_more_window_hide (int client, uint32 context);
217
218     /**
219      * @brief Notice Helper ISE that show candidate.
220      * @return true if the command was sent correctly.
221      */
222     virtual void helper_candidate_show (int client, uint32 context, const String&  uuid);
223
224     /**
225      * @brief Notice Helper ISE that hide candidate.
226      * @return true if the command was sent correctly.
227      */
228     virtual void helper_candidate_hide (int client, uint32 context, const String&  uuid);
229
230     /**
231      * @brief Update helper lookup table.
232      * @return true if the command was sent correctly.
233      */
234     virtual void update_helper_lookup_table (int client, uint32 context, const String&  uuid, const LookupTable& table);
235
236     /**
237      * @brief Let the focused IMEngineInstance object
238      *        select a aux in current aux string.
239      *
240      * @param item The index of the selected aux.
241      * @return true if the command was sent correctly.
242      */
243     virtual void select_aux (int client, uint32 context, uint32         item);
244
245     /**
246      * @brief Let the focused IMEngineInstance object
247      *        select a candidate in current lookup table.
248      *
249      * @param item The index of the selected candidate.
250      * @return true if the command was sent correctly.
251      */
252     virtual void select_candidate (int client, uint32 context, uint32         item);
253
254     /**
255      * @brief Let the focused IMEngineInstance object
256      *        flip the LookupTable to previous page.
257      * @return true if the command was sent correctly.
258      */
259     virtual void lookup_table_page_up (int client, uint32 context);
260
261     /**
262      * @brief Let the focused IMEngineInstance object
263      *        flip the LookupTable to next page.
264      * @return true if the command was sent correctly.
265      */
266     virtual void lookup_table_page_down (int client, uint32 context);
267
268     /**
269      * @brief Let the focused IMEngineInstance object
270      *        update the page size of the LookupTable.
271      *
272      * @param size The new page size.
273      * @return true if the command was sent correctly.
274      */
275     virtual void update_lookup_table_page_size (int client, uint32 context, uint32         size);
276
277     /**
278      * @brief Let the focused IMEngineInstance object
279      *        update candidate items layout.
280      *
281      * @param row_items The items of each row.
282      * @return true if the command was sent correctly.
283      */
284     virtual void update_candidate_item_layout (int client, uint32 context, const std::vector<uint32>& row_items);
285
286     /**
287      * @brief Let the focused IMEngineInstance object
288      *        select a associate in current associate table.
289      *
290      * @param item The index of the selected associate.
291      * @return true if the command was sent correctly.
292      */
293     virtual void select_associate (int client, uint32 context, uint32         item);
294
295     /**
296      * @brief Let the focused IMEngineInstance object
297      *        flip the AssociateTable to previous page.
298      * @return true if the command was sent correctly.
299      */
300     virtual void associate_table_page_up (int client, uint32 context);
301
302     /**
303      * @brief Let the focused IMEngineInstance object
304      *        flip the AssociateTable to next page.
305      * @return true if the command was sent correctly.
306      */
307     virtual void associate_table_page_down (int client, uint32 context);
308
309     /**
310      * @brief Let the focused IMEngineInstance object
311      *        update the page size of the AssociateTable.
312      *
313      * @param size The new page size.
314      * @return true if the command was sent correctly.
315      */
316     virtual void update_associate_table_page_size (int client, uint32 context, uint32       size);
317
318     /**
319      * @brief Inform helper ISE to update displayed candidate number.
320      *
321      * @param size The displayed candidate number.
322      * @return true if the command was sent correctly.
323      */
324     virtual void update_displayed_candidate_number (int client, uint32 context, uint32      size);
325
326     /**
327      * @brief Trigger a property of the focused IMEngineInstance object.
328      *
329      * @param property The property key to be triggered.
330      * @return true if the command was sent correctly.
331      */
332     virtual void trigger_property (int client, uint32 context, const String&  property);
333
334     /**
335      * @brief Let all FrontEnds and Helpers reload configuration.
336      * @return true if the command was sent correctly.
337      */
338     virtual void reload_config (int client);
339
340     /**
341      * @brief Let all FrontEnds, Helpers and this Panel exit.
342      * @return true if the command was sent correctly.
343      */
344     virtual void exit (int client, uint32 context);
345
346     /**
347      * @brief Send candidate longpress event to ISE.
348      *
349      * @param index The candidate object index.
350      *
351      * @return none.
352      */
353     virtual void send_longpress_event (int client, uint32 context, uint32 index);
354
355     /**
356      * @brief update_panel_event.
357      *
358      * @param
359      *
360      * @return none.
361      */
362     virtual void update_panel_event (int client,  uint32 context, int cmd, uint32 nType, uint32 nValue);
363
364     /**
365      * @brief update_keyboard_ise_list.
366      *
367      * @param
368      *
369      * @return none.
370      */
371     virtual void update_keyboard_ise_list (int client, uint32 context);
372
373     /**
374      * @brief set_helper_mode.
375      *
376      * @param
377      *
378      * @return none.
379      */
380     virtual void set_helper_mode (int client, uint32 context, const String& uuid, uint32& mode);
381
382     /**
383      * @brief set_helper_language.
384      *
385      * @param
386      *
387      * @return none.
388      */
389     virtual void set_helper_language (int client, uint32 context, const String& uuid, uint32& language);
390
391     /**
392      * @brief set_helper_imdata.
393      *
394      * @param
395      *
396      * @return none.
397      */
398     virtual void set_helper_imdata (int client, uint32 context, const String& uuid, const char* imdata, size_t& len);
399
400     /**
401      * @brief set_helper_return_key_type.
402      *
403      * @param
404      *
405      * @return none.
406      */
407     virtual void set_helper_return_key_type (int client, uint32 context, const String& uuid, uint32 type);
408
409     /**
410      * @brief get_helper_return_key_type.
411      *
412      * @param
413      *
414      * @return none.
415      */
416     virtual void get_helper_return_key_type (int client, uint32 context, const String& uuid, _OUT_ uint32& type);
417
418     /**
419      * @brief set_helper_return_key_disable.
420      *
421      * @param
422      *
423      * @return none.
424      */
425     virtual void set_helper_return_key_disable (int client, uint32 context, const String& uuid, uint32 disabled);
426
427     /**
428      * @brief get_helper_return_key_disable.
429      *
430      * @param
431      *
432      * @return none.
433      */
434     virtual void get_helper_return_key_disable (int client, uint32 context, const String& uuid, _OUT_ uint32& disabled);
435
436     /**
437      * @brief set_helper_layout.
438      *
439      * @param
440      *
441      * @return none.
442      */
443     virtual void set_helper_layout (int client, uint32 context, const String& uuid, uint32& layout);
444
445     /**
446      * @brief set_helper_input_mode.
447      *
448      * @param
449      *
450      * @return none.
451      */
452     virtual void set_helper_input_mode (int client, uint32 context, const String& uuid, uint32& mode);
453
454     /**
455      * @brief set_helper_input_hint.
456      *
457      * @param
458      *
459      * @return none.
460      */
461     virtual void set_helper_input_hint (int client, uint32 context, const String& uuid, uint32& hint);
462
463     /**
464      * @brief set_helper_bidi_direction.
465      *
466      * @param
467      *
468      * @return none.
469      */
470     virtual void set_helper_bidi_direction (int client, uint32 context, const String& uuid, uint32& direction);
471
472     /**
473      * @brief set_helper_caps_mode.
474      *
475      * @param
476      *
477      * @return none.
478      */
479     virtual void set_helper_caps_mode (int client, uint32 context, const String& uuid, uint32& mode);
480
481     /**
482      * @brief show_helper_option_window.
483      *
484      * @param
485      *
486      * @return none.
487      */
488     virtual void show_helper_option_window (int client, uint32 context, const String& uuid);
489
490     /**
491      * @brief process_key_event.
492      *
493      * @param
494      *
495      * @return none.
496      */
497     virtual bool process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, _OUT_ uint32& result);
498
499     /**
500      * @brief get_helper_geometry.
501      *
502      * @param
503      *
504      * @return none.
505      */
506     virtual bool get_helper_geometry (int client, uint32 context, String& uuid, _OUT_ struct rectinfo& info);
507
508     /**
509      * @brief get_helper_imdata.
510      *
511      * @param
512      *
513      * @return none.
514      */
515     virtual void get_helper_imdata (int client, uint32 context, String& uuid, _OUT_ char** imdata, _OUT_ size_t& len);
516
517     /**
518      * @brief get_helper_layout.
519      *
520      * @param
521      *
522      * @return none.
523      */
524     virtual void get_helper_layout (int client, uint32 context, String& uuid, uint32& layout);
525
526     /**
527      * @brief get_ise_language_locale.
528      *
529      * @param
530      *
531      * @return none.
532      */
533     virtual void get_ise_language_locale (int client, uint32 context, String& uuid, _OUT_ char* data, _OUT_ size_t& len);
534
535     /**
536      * @brief check_option_window.
537      *
538      * @param
539      *
540      * @return none.
541      */
542     virtual void check_option_window (int client, uint32 context, String& uuid, _OUT_ uint32& avail);
543
544     /**
545      * @brief reset_ise_option.
546      *
547      * @param
548      *
549      * @return none.
550      */
551     virtual void reset_ise_option (int client, uint32 context);
552
553     /**
554      * @brief reset_helper_context.
555      *
556      * @param
557      *
558      * @return none.
559      */
560     virtual void reset_helper_context (int client, uint32 context, const String& uuid);
561
562     /**
563      * @brief socket_update_surrounding_text.
564      *
565      * @param
566      *
567      * @return none.
568      */
569     virtual void socket_update_surrounding_text (int client, uint32 context, String& uuid, String text, uint32 cursor);
570
571     /**
572      * @brief socket_update_selection.
573      *
574      * @param
575      *
576      * @return none.
577      */
578     virtual void socket_update_selection (int client, uint32 context, String& uuid, String text);
579
580     /**
581      * @brief socket_get_keyboard_ise_list.
582      *
583      * @param
584      *
585      * @return none.
586      */
587     virtual  void socket_get_keyboard_ise_list (int client, uint32 context, const String& uuid, std::vector<String>& list);
588
589     /**
590      * @brief socket_get_candidate_ui.
591      *
592      * @param
593      *
594      * @return none.
595      */
596     virtual void socket_get_candidate_ui (int client, uint32 context, const String& uuid,  int style,  int mode);
597
598     /**
599      * @brief socket_get_candidate_geometry.
600      *
601      * @param
602      *
603      * @return none.
604      */
605     virtual void socket_get_candidate_geometry (int client, uint32 context, const String& uuid, struct rectinfo& info);
606
607     /**
608      * @brief socket_get_keyboard_ise.
609      *
610      * @param
611      *
612      * @return none.
613      */
614     virtual void socket_get_keyboard_ise (int client, uint32 context, const String& uuid, String& ise_name, String& ise_uuid);
615
616     /**
617      * @brief socket_start_helper.
618      *
619      * @param
620      *
621      * @return none.
622      */
623     virtual void socket_start_helper (int client, uint32 context, const String& ic_uuid);
624
625     /**
626      * @brief helper_detach_input_context.
627      *
628      * @param
629      *
630      * @return none.
631      */
632     virtual void helper_detach_input_context (int client, uint32 context, const String& ic_uuid);
633
634     /**
635      * @brief helper_process_imengine_event.
636      *
637      * @param
638      *
639      * @return none.
640      */
641     virtual void helper_process_imengine_event (int client, uint32 context, const String& ic_uuid, const Transaction& nest_transaction);
642
643     /**
644      * @brief process_helper_event.
645      *
646      * @param
647      *
648      * @return none.
649      */
650     virtual void process_helper_event (int client, uint32 context,  String target_uuid, String active_uuid, Transaction& nest_trans);
651
652     /**
653      * @brief socket_helper_key_event.
654      *
655      * @param
656      *
657      * @return none.
658      */
659     virtual void socket_helper_key_event (int client, uint32 context, int cmd , KeyEvent& key);
660
661     /**
662      * @brief socket_helper_get_surrounding_text.
663      *
664      * @param
665      *
666      * @return none.
667      */
668     virtual void socket_helper_get_surrounding_text (int client, uint32 context, uint32 maxlen_before, uint32 maxlen_after);
669
670     /**
671      * @brief socket_helper_delete_surrounding_text.
672      *
673      * @param
674      *
675      * @return none.
676      */
677     virtual void socket_helper_delete_surrounding_text (int client, uint32 context, uint32 offset, uint32 len);
678
679     /**
680      * @brief socket_helper_get_selection.
681      *
682      * @param
683      *
684      * @return none.
685      */
686     virtual void socket_helper_get_selection (int client, uint32 context);
687
688     /**
689      * @brief socket_helper_set_selection.
690      *
691      * @param
692      *
693      * @return none.
694      */
695     virtual void socket_helper_set_selection (int client, uint32 context, uint32 start, uint32 end);
696
697     /**
698      * @brief update_ise_input_context.
699      *
700      * @param
701      *
702      * @return none.
703      */
704     virtual void update_ise_input_context (int client, uint32 context, uint32 type, uint32 value);
705
706     /**
707      * @brief send_private_command.
708      *
709      * @param
710      *
711      * @return none.
712      */
713     virtual void send_private_command (int client, uint32 context, String command);
714
715     /**
716      * @brief helper_all_update_spot_location.
717      *
718      * @param
719      *
720      * @return none.
721      */
722     virtual void helper_all_update_spot_location (int client, uint32 context, String uuid, int x, int y);
723
724     /**
725      * @brief helper_all_update_cursor_position.
726      *
727      * @param
728      *
729      * @return none.
730      */
731     virtual void helper_all_update_cursor_position (int client, uint32 context, String uuid, int cursor_pos);
732
733     /**
734      * @brief helper_all_update_screen.
735      *
736      * @param
737      *
738      * @return none.
739      */
740     virtual void helper_all_update_screen (int client, uint32 context, String uuid, int screen);
741
742     /**
743      * @brief commit_string.
744      *
745      * @param
746      *
747      * @return none.
748      */
749     virtual void commit_string (int client, uint32 context,const WideString& wstr);
750
751     /**
752      * @brief show_preedit_string.
753      *
754      * @param
755      *
756      * @return none.
757      */
758     virtual void show_preedit_string (int client, uint32 context);
759
760     /**
761      * @brief hide_preedit_string.
762      *
763      * @param
764      *
765      * @return none.
766      */
767     virtual void hide_preedit_string (int client, uint32 context);
768
769     /**
770      * @brief update_preedit_string.
771      *
772      * @param
773      *
774      * @return none.
775      */
776     virtual void update_preedit_string (int client, uint32  context, WideString wstr, AttributeList& attrs, uint32 caret);
777
778     /**
779      * @brief update_preedit_caret.
780      *
781      * @param
782      *
783      * @return none.
784      */
785     virtual void update_preedit_caret (int client, uint32 context, uint32 caret);
786
787     /**
788      * @brief attach_input_context and update_screen.
789      *
790      * @param
791      *
792      * @return none.
793      */
794     virtual void helper_attach_input_context_and_update_screen (int client, std::vector < std::pair <uint32, String> >& helper_ic_index, uint32 current_screen);
795
796 };
797
798 /**  @} */
799
800 } /* namespace scim */
801
802 #endif /* __SCIM_PANEL_AGENT_H */
803
804 /*
805 vi:ts=4:nowrap:ai:expandtab
806 */