1 
2 /*
3   Copyright (c) 2005-2013 uim Project https://github.com/uim/uim
4 
5   All rights reserved.
6 
7   Redistribution and use in source and binary forms, with or
8   without modification, are permitted provided that the
9   following conditions are met:
10 
11   1. Redistributions of source code must retain the above
12      copyright notice, this list of conditions and the
13      following disclaimer.
14   2. Redistributions in binary form must reproduce the above
15      copyright notice, this list of conditions and the
16      following disclaimer in the documentation and/or other
17      materials provided with the distribution.
18   3. Neither the name of authors nor the names of its
19      contributors may be used to endorse or promote products
20      derived from this software without specific prior written
21      permission.
22 
23   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37 
38 #include "callback.h"
39 
40 void
commit_cb(void * ptr,const char * str)41 commit_cb(void *ptr, const char *str)
42 {
43   uim_agent_context *ua = (uim_agent_context *)ptr;
44 
45   debug_printf(DEBUG_NOTE, "commit_cb\n");
46 
47   ua->comstr = add_commit_string(ua->comstr, str);
48 }
49 
50 
51 void
preedit_clear_cb(void * ptr)52 preedit_clear_cb(void *ptr)
53 {
54   uim_agent_context *ua = (uim_agent_context *)ptr;
55 
56   debug_printf(DEBUG_NOTE, "preedit_clear_cb\n");
57 
58   clear_preedit(ua->pe);
59 }
60 
61 
62 void
preedit_pushback_cb(void * ptr,int attr,const char * str)63 preedit_pushback_cb(void *ptr, int attr, const char * str)
64 {
65   uim_agent_context *ua = (uim_agent_context *)ptr;
66 
67   debug_printf(DEBUG_NOTE,
68 			   "preedit_pushback_cb \"%s\" (attr: %d)\n", str, attr);
69 
70   add_preedit(ua->pe, attr, str);
71 }
72 
73 
74 void
preedit_update_cb(void * ptr)75 preedit_update_cb(void *ptr)
76 {
77   uim_agent_context *ua = (uim_agent_context *)ptr;
78 
79   debug_printf(DEBUG_NOTE, "preedit_update_cb (ua = %p)\n", ua);
80 
81   /* do nothing */
82 }
83 
84 
85 void
candidate_activate_cb(void * ptr,int num,int limit)86 candidate_activate_cb(void *ptr, int num, int limit)
87 {
88   /*
89 	 num:   total number of candidates
90 	 limit: candidates per page
91   */
92   uim_agent_context *ua = (uim_agent_context *)ptr;
93 
94   debug_printf(DEBUG_NOTE,
95 			   "candidate_activate_cb (num=%d,limit=%d)\n", num, limit);
96 
97   new_candidate(ua->context, ua->cand, num, limit);
98 }
99 
100 
101 
102 void
candidate_select_cb(void * ptr,int index)103 candidate_select_cb(void *ptr, int index)
104 {
105   uim_agent_context *ua = (uim_agent_context *)ptr;
106 
107   debug_printf(DEBUG_NOTE, "candidate_select_cb (index: %d)\n", index);
108 
109 #if !UIM_EL_USE_NEW_PAGE_HANDLING
110   ua->cand->index = index;
111 #else
112   select_candidate(ua->context, ua->cand, index);
113 #endif
114 }
115 
116 
117 void
candidate_shift_page_cb(void * ptr,int direction)118 candidate_shift_page_cb(void *ptr, int direction)
119 {
120   uim_agent_context *ua = (uim_agent_context *)ptr;
121 
122   debug_printf(DEBUG_NOTE, "candidate_shift_page_cb\n");
123 
124   shift_candidate_page(ua->context, ua->cand, direction);
125 }
126 
127 
128 void
candidate_deactivate_cb(void * ptr)129 candidate_deactivate_cb(void *ptr)
130 {
131   uim_agent_context *ua = (uim_agent_context *)ptr;
132 
133   debug_printf(DEBUG_NOTE, "candidate_deactivate_cb\n");
134 
135   clear_candidate(ua->cand);
136 }
137 
138 
139 void
prop_list_update_cb(void * ptr,const char * str)140 prop_list_update_cb(void *ptr, const char *str)
141 {
142   uim_agent_context *ua = (uim_agent_context *)ptr;
143 
144   debug_printf(DEBUG_NOTE, "prop_list_update_cb\n");
145 
146   update_prop_list(ua->prop, ua->encoding, str);
147 }
148 
149 
150 void
configuration_changed_cb(void * ptr)151 configuration_changed_cb(void *ptr)
152 {
153   uim_agent_context *ua = (uim_agent_context *)ptr;
154 
155   /* configuration of context has changed at uim side */
156   debug_printf(DEBUG_NOTE, "configuration_changed_cb\n");
157 
158   update_context_configuration(ua);
159 }
160 
161 
162 void
switch_app_global_im_cb(void * ptr,const char * name)163 switch_app_global_im_cb(void *ptr, const char *name)
164 {
165   /* change default */
166   update_default_engine(name);
167 
168   switch_context_im_all(name);
169 }
170 
171 
172 void
switch_system_global_im_cb(void * ptr,const char * name)173 switch_system_global_im_cb(void *ptr, const char *name)
174 {
175   /* change default */
176   update_default_engine(name);
177 
178   switch_context_im_all(name);
179 
180   helper_send_im_change_whole_desktop(name);
181 }
182 
183