1 #include "dbus-callback.h"
3 void get_ui_string(DBusMessage *message, DBusConnection *mim_conn) {
5 Composition composition;
7 dbus_message_iter_init(message, &iter);
8 dbus_message_iter_get_basic(&iter, &composition.unparsed);
10 g_printf("sigvalue = %s \n", composition.unparsed);
11 connection = mim_conn;
12 seg_string(composition);
15 /*seg the string that from ui model
20 static void seg_string(Composition composition) {
21 /* seg teh string that form ui model,
26 composition.En_Ch_Flag = FALSE;
27 str_len = strlen(composition.unparsed);
28 for (i = 0;i < str_len; i++)
30 gchar c = *(composition.unparsed + i);
31 composition.str_list[i][10] = c;
32 g_printf("seg_string c = %c \n", composition.str_list[i][10]);
34 if (composition.En_Ch_Flag)
36 DBusMessage *statu_message;
37 statu_message = dbus_message_new_signal ("/org/ifanr/mim/engine",
38 "org.ifanr.mim.engine",
41 dbus_connection_send (connection, statu_message, NULL);
42 dbus_message_unref (statu_message);
47 match_string(composition, i);
48 g_printf("str_len = %d \n", str_len);
52 /*when you seg string that from ui, match they with chunck
57 static void match_string(Composition composition, gint i){
58 /*invoke hua yang's API*/
59 g_printf("chinese string\n");
62 g_printf("strlist.length >= 3\n");
65 g_printf("strlist.length == 2\n");
67 g_printf("strlist.length == 1\n");
68 send_ch_string("chinese string");
71 static void send_ch_string(gchar *ch_string)
75 gchar *message_text = ch_string;
76 message = dbus_message_new_signal ("/org/ifanr/mim/engine",
77 "org.ifanr.mim.engine",
80 dbus_message_iter_init_append(message, &iter);
81 dbus_message_iter_append_basic(&iter,
84 dbus_connection_send (connection, message, NULL);
85 dbus_message_unref (message);
88 void priv_click_cb() {
89 g_printf("priv click cb\n");
92 void next_click_cb() {
93 g_printf("next click cb");
96 void user_select_cb(DBusMessage *message) {
97 g_printf("user select received\n");
101 dbus_message_iter_init(message, &iter);
102 dbus_message_iter_get_basic(&iter, &select_num);
104 g_printf("select_num = %d \n", select_num);
110 * input has finished;
111 * Word Priority Adjustment,
112 * or inserting newly built phrases into storage
113 * if need insert newly built phrases, we need invote the nominee.pop
118 /*engine pushes the selected candidate into Nominee,
119 * and then move the starting syllable cursor of the composition according
120 * to the char number of the selected candidate
125 /*if the backspace key clicked, invole this function
130 void backspace_key_cb() {
134 /*Check if the Nominee is empty,
135 * if not, this means user has wrongly selected some
136 * candidate and this operation should be rolled back.
139 if (he last key pressed is Mandatory Separator Key) {
140 remove it and update composition display;
143 remove the last key and;
146 /*The cursor of composition is moved back according
147 * to the Char number of the last element in Nominee,
148 * then Nominee.Pop() is triggered and the last element is removed.
154 /*the last char in last syllable should be removed,
156 if (composition empty now)
157 /*input is cancelled()*/
162 /*engine re-examine the C/E status*/
166 /*if the space key clicked, invole this function*/
167 void space_key_cb() {
180 void enter_key_cb() {
181 g_printf("user type the enter key\n");
182 DBusMessage *message;
183 DBusMessageIter iter;
184 const gint user_select = 1;
185 message = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
186 /* Send the signal */
187 dbus_message_iter_init_append(message, &iter);
188 dbus_message_iter_append_basic(&iter,
191 user_select_cb(message);