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