Commit 84c6eb0e authored by Yuanle Song's avatar Yuanle Song

v0.9.3 removed FuzzyFlag property.

use fuzzy_flag param in a new method instead.
added GetCandidatesV2 method in service interface.
use this new method in zero-el.
parent de3d62bc
......@@ -4,13 +4,34 @@
<node>
<interface name="com.emacsos.zero.ZeroPinyinService1.ZeroPinyinServiceInterface">
<!--
FuzzyFlag: fuzzy matching flag for GetCandidates method.
0 0b0 no fuzzy matching
1 0b1 enable fuzzy match on z<->zh, c<->ch, s<->sh
2 0b10 enable fuzzy match on l<->n
flag numbers can be combined with bit or.
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
1 0b1 enable fuzzy match on z<->zh, c<->ch, s<->sh
2 0b10 enable fuzzy match on l<->n
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:
......
......@@ -19,11 +19,12 @@ typedef struct {
} AppData;
static gboolean
on_handle_get_candidates(ZeroPinyinService *object,
GDBusMethodInvocation *invocation,
const gchar *preedit_str,
guint fetch_size,
AppData *appdata)
on_handle_get_candidates_v2(ZeroPinyinService *object,
GDBusMethodInvocation *invocation,
const gchar *preedit_str,
guint fetch_size,
guint fuzzy_flag,
AppData *appdata)
{
if (preedit_str == NULL || fetch_size == 0) {
g_dbus_method_invocation_return_dbus_error(
......@@ -45,7 +46,7 @@ on_handle_get_candidates(ZeroPinyinService *object,
candidates_builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
matched_lengths_builder = g_variant_builder_new(G_VARIANT_TYPE("au"));
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);
g_assert_nonnull(result);
......@@ -60,6 +61,16 @@ on_handle_get_candidates(ZeroPinyinService *object,
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
on_handle_commit_candidate(ZeroPinyinService *object,
GDBusMethodInvocation *invocation,
......@@ -134,6 +145,10 @@ on_bus_acquired(GDBusConnection *connection,
g_message("on_bus_acquired() name=%s", name);
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,
"handle-get-candidates",
G_CALLBACK(on_handle_get_candidates),
......
# -*- mode: conf -*-
project('zero-pinyin-service', ['c', 'cpp'],
version: '0.9.2',
version: '0.9.3',
license: 'GPL',
default_options: [
'warning_level=2',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment