Loading com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface.xml +27 −6 Original line number Original line Diff line number Diff line Loading @@ -4,13 +4,34 @@ <node> <node> <interface name="com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface"> <interface name="com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface"> <!-- <!-- FuzzyFlag: fuzzy matching flag for GetCandidates method. GetCandidatesV2: Difference to GetCandidates: A fuzzy_flag param is added. @preedit_str: the preedit string @fetch_size: how many candidates to fetch @fuzzy_flag: fuzzy flag when matching candidate 0 0b0 no fuzzy matching 0 0b0 no fuzzy matching 1 0b1 enable fuzzy match on z<->zh, c<->ch, s<->sh 1 0b1 enable fuzzy match on z<->zh, c<->ch, s<->sh 2 0b10 enable fuzzy match on l<->n 2 0b10 enable fuzzy match on l<->n flag numbers can be combined with bit or. fuzzy flag numbers can be combined with bit or. @candidates: the candidates @matched_preedit_str_lengths: the matched str length in preedit str for each candidate Get candidates for a preedit string. This method will fetch at least fetch_size candidates if they exists. However, this method is allowed to return more candidates than fetch_size. --> --> <property name="FuzzyFlag" type="u" access="readwrite"></property> <method name="GetCandidatesV2"> <arg type="s" name="preedit_str"/> <arg type="u" name="fetch_size"/> <arg type="u" name="fuzzy_flag"/> <arg type="as" name="candidates" direction="out"/> <arg type="au" name="matched_preedit_str_lengths" direction="out"/> <arg type="aa(ii)" name="candidates_pinyin_indices" direction="out"/> </method> <!-- <!-- GetCandidates: GetCandidates: Loading main.c +21 −6 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,11 @@ typedef struct { } AppData; } AppData; static gboolean static gboolean on_handle_get_candidates(ZeroPinyinService *object, on_handle_get_candidates_v2(ZeroPinyinService *object, GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation, const gchar *preedit_str, const gchar *preedit_str, guint fetch_size, guint fetch_size, guint fuzzy_flag, AppData *appdata) AppData *appdata) { { if (preedit_str == NULL || fetch_size == 0) { if (preedit_str == NULL || fetch_size == 0) { Loading @@ -45,7 +46,7 @@ on_handle_get_candidates(ZeroPinyinService *object, candidates_builder = g_variant_builder_new(G_VARIANT_TYPE("as")); candidates_builder = g_variant_builder_new(G_VARIANT_TYPE("as")); matched_lengths_builder = g_variant_builder_new(G_VARIANT_TYPE("au")); matched_lengths_builder = g_variant_builder_new(G_VARIANT_TYPE("au")); candidates_pinyin_indices = g_variant_builder_new(G_VARIANT_TYPE("aa(ii)")); candidates_pinyin_indices = g_variant_builder_new(G_VARIANT_TYPE("aa(ii)")); get_candidates(appdata->db, preedit_str, fetch_size, zero_pinyin_service_get_fuzzy_flag(object), candidates_builder, matched_lengths_builder, candidates_pinyin_indices); get_candidates(appdata->db, preedit_str, fetch_size, fuzzy_flag, candidates_builder, matched_lengths_builder, candidates_pinyin_indices); result = g_variant_new("(asauaa(ii))", candidates_builder, matched_lengths_builder, candidates_pinyin_indices); result = g_variant_new("(asauaa(ii))", candidates_builder, matched_lengths_builder, candidates_pinyin_indices); g_assert_nonnull(result); g_assert_nonnull(result); Loading @@ -60,6 +61,16 @@ on_handle_get_candidates(ZeroPinyinService *object, return TRUE; return TRUE; } } static gboolean on_handle_get_candidates(ZeroPinyinService *object, GDBusMethodInvocation *invocation, const gchar *preedit_str, guint fetch_size, AppData *appdata) { return on_handle_get_candidates_v2(object, invocation, preedit_str, fetch_size, 0, appdata); } static gboolean static gboolean on_handle_commit_candidate(ZeroPinyinService *object, on_handle_commit_candidate(ZeroPinyinService *object, GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation, Loading Loading @@ -134,6 +145,10 @@ on_bus_acquired(GDBusConnection *connection, g_message("on_bus_acquired() name=%s", name); g_message("on_bus_acquired() name=%s", name); appdata->interface = zero_pinyin_service_skeleton_new(); appdata->interface = zero_pinyin_service_skeleton_new(); g_signal_connect(appdata->interface, "handle-get-candidates-v2", G_CALLBACK(on_handle_get_candidates_v2), appdata); g_signal_connect(appdata->interface, g_signal_connect(appdata->interface, "handle-get-candidates", "handle-get-candidates", G_CALLBACK(on_handle_get_candidates), G_CALLBACK(on_handle_get_candidates), Loading meson.build +1 −1 Original line number Original line Diff line number Diff line # -*- mode: conf -*- # -*- mode: conf -*- project('zero-pinyin-service', ['c', 'cpp'], project('zero-pinyin-service', ['c', 'cpp'], version: '0.9.2', version: '0.9.3', license: 'GPL', license: 'GPL', default_options: [ default_options: [ 'warning_level=2', 'warning_level=2', Loading Loading
com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface.xml +27 −6 Original line number Original line Diff line number Diff line Loading @@ -4,13 +4,34 @@ <node> <node> <interface name="com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface"> <interface name="com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface"> <!-- <!-- FuzzyFlag: fuzzy matching flag for GetCandidates method. GetCandidatesV2: Difference to GetCandidates: A fuzzy_flag param is added. @preedit_str: the preedit string @fetch_size: how many candidates to fetch @fuzzy_flag: fuzzy flag when matching candidate 0 0b0 no fuzzy matching 0 0b0 no fuzzy matching 1 0b1 enable fuzzy match on z<->zh, c<->ch, s<->sh 1 0b1 enable fuzzy match on z<->zh, c<->ch, s<->sh 2 0b10 enable fuzzy match on l<->n 2 0b10 enable fuzzy match on l<->n flag numbers can be combined with bit or. fuzzy flag numbers can be combined with bit or. @candidates: the candidates @matched_preedit_str_lengths: the matched str length in preedit str for each candidate Get candidates for a preedit string. This method will fetch at least fetch_size candidates if they exists. However, this method is allowed to return more candidates than fetch_size. --> --> <property name="FuzzyFlag" type="u" access="readwrite"></property> <method name="GetCandidatesV2"> <arg type="s" name="preedit_str"/> <arg type="u" name="fetch_size"/> <arg type="u" name="fuzzy_flag"/> <arg type="as" name="candidates" direction="out"/> <arg type="au" name="matched_preedit_str_lengths" direction="out"/> <arg type="aa(ii)" name="candidates_pinyin_indices" direction="out"/> </method> <!-- <!-- GetCandidates: GetCandidates: Loading
main.c +21 −6 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,11 @@ typedef struct { } AppData; } AppData; static gboolean static gboolean on_handle_get_candidates(ZeroPinyinService *object, on_handle_get_candidates_v2(ZeroPinyinService *object, GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation, const gchar *preedit_str, const gchar *preedit_str, guint fetch_size, guint fetch_size, guint fuzzy_flag, AppData *appdata) AppData *appdata) { { if (preedit_str == NULL || fetch_size == 0) { if (preedit_str == NULL || fetch_size == 0) { Loading @@ -45,7 +46,7 @@ on_handle_get_candidates(ZeroPinyinService *object, candidates_builder = g_variant_builder_new(G_VARIANT_TYPE("as")); candidates_builder = g_variant_builder_new(G_VARIANT_TYPE("as")); matched_lengths_builder = g_variant_builder_new(G_VARIANT_TYPE("au")); matched_lengths_builder = g_variant_builder_new(G_VARIANT_TYPE("au")); candidates_pinyin_indices = g_variant_builder_new(G_VARIANT_TYPE("aa(ii)")); candidates_pinyin_indices = g_variant_builder_new(G_VARIANT_TYPE("aa(ii)")); get_candidates(appdata->db, preedit_str, fetch_size, zero_pinyin_service_get_fuzzy_flag(object), candidates_builder, matched_lengths_builder, candidates_pinyin_indices); get_candidates(appdata->db, preedit_str, fetch_size, fuzzy_flag, candidates_builder, matched_lengths_builder, candidates_pinyin_indices); result = g_variant_new("(asauaa(ii))", candidates_builder, matched_lengths_builder, candidates_pinyin_indices); result = g_variant_new("(asauaa(ii))", candidates_builder, matched_lengths_builder, candidates_pinyin_indices); g_assert_nonnull(result); g_assert_nonnull(result); Loading @@ -60,6 +61,16 @@ on_handle_get_candidates(ZeroPinyinService *object, return TRUE; return TRUE; } } static gboolean on_handle_get_candidates(ZeroPinyinService *object, GDBusMethodInvocation *invocation, const gchar *preedit_str, guint fetch_size, AppData *appdata) { return on_handle_get_candidates_v2(object, invocation, preedit_str, fetch_size, 0, appdata); } static gboolean static gboolean on_handle_commit_candidate(ZeroPinyinService *object, on_handle_commit_candidate(ZeroPinyinService *object, GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation, Loading Loading @@ -134,6 +145,10 @@ on_bus_acquired(GDBusConnection *connection, g_message("on_bus_acquired() name=%s", name); g_message("on_bus_acquired() name=%s", name); appdata->interface = zero_pinyin_service_skeleton_new(); appdata->interface = zero_pinyin_service_skeleton_new(); g_signal_connect(appdata->interface, "handle-get-candidates-v2", G_CALLBACK(on_handle_get_candidates_v2), appdata); g_signal_connect(appdata->interface, g_signal_connect(appdata->interface, "handle-get-candidates", "handle-get-candidates", G_CALLBACK(on_handle_get_candidates), G_CALLBACK(on_handle_get_candidates), Loading
meson.build +1 −1 Original line number Original line Diff line number Diff line # -*- mode: conf -*- # -*- mode: conf -*- project('zero-pinyin-service', ['c', 'cpp'], project('zero-pinyin-service', ['c', 'cpp'], version: '0.9.2', version: '0.9.3', license: 'GPL', license: 'GPL', default_options: [ default_options: [ 'warning_level=2', 'warning_level=2', Loading