jihoon pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4262c33bfcf161769069d7ad32f018f565496565

commit 4262c33bfcf161769069d7ad32f018f565496565
Author: Jihoon Kim <jihoon48....@samsung.com>
Date:   Fri Sep 15 16:18:15 2017 +0900

    ecore_imf: Add prediction hint hash APIs
    
    Change-Id: Id012fd172d3b15bfa3e9ea10c22216db10ba23b5
    Signed-off-by: Jihoon Kim <jihoon48....@samsung.com>
---
 src/lib/ecore_imf/Ecore_IMF.h         | 43 ++++++++++++++++++++++++
 src/lib/ecore_imf/ecore_imf_context.c | 63 ++++++++++++++++++++++++++++++++++-
 src/lib/ecore_imf/ecore_imf_private.h |  1 +
 3 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/src/lib/ecore_imf/Ecore_IMF.h b/src/lib/ecore_imf/Ecore_IMF.h
index 92c1bc6eac..0fc821da2f 100644
--- a/src/lib/ecore_imf/Ecore_IMF.h
+++ b/src/lib/ecore_imf/Ecore_IMF.h
@@ -1987,6 +1987,49 @@ EAPI void                         
ecore_imf_context_mime_type_accept_set(Ecore_I
  */
 EAPI void                         
ecore_imf_context_input_panel_position_set(Ecore_IMF_Context *ctx, int x, int 
y);
 
+/**
+ * @ingroup Ecore_IMF_Context_Group
+ * @brief Sets the prediction hint data at the specified key
+ *
+ * @since 1.21.0
+ *
+ * @param[in] ctx An #Ecore_IMF_Context
+ * @param key The key of the prediction hint
+ * @param data The data to replace
+ * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
+ *
+ * This function modifies the data of @p key with @p data in the hash 
associated @p
+ * ctx. If no entry is found, @p data is added to the hash associated @p ctx 
with the
+ * key @p key. On success this function returns EINA_TRUE,
+ * otherwise it returns @c EINA_FALSE.
+ */
+EAPI Eina_Bool                    
ecore_imf_context_prediction_hint_hash_set(Ecore_IMF_Context *ctx, const char 
*key, const char *value);
+
+/**
+ * @ingroup Ecore_IMF_Context_Group
+ * @brief Removes the prediction hint data identified by a key
+ *
+ * @since 1.21.0
+ *
+ * @param[in] ctx An #Ecore_IMF_Context
+ * @param key The key of the prediction hint
+ * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise
+ *
+ * This function removes the entry identified by @p key from the hash 
associated @p ctx.
+ */
+EAPI Eina_Bool                    
ecore_imf_context_prediction_hint_hash_del(Ecore_IMF_Context *ctx, const char 
*key);
+
+/**
+ * @ingroup Ecore_IMF_Context_Group
+ * @brief Gets the hash table of prediction hint data
+ *
+ * @since 1.21.0
+ *
+ * @param[in] ctx An #Ecore_IMF_Context
+ * @return The prediction hint hash table
+ */
+EAPI const Eina_Hash             
*ecore_imf_context_prediction_hint_hash_get(Ecore_IMF_Context *ctx);
+
 /* The following entry points must be exported by each input method module
  */
 
diff --git a/src/lib/ecore_imf/ecore_imf_context.c 
b/src/lib/ecore_imf/ecore_imf_context.c
index 1b34e0c01f..a04708fa8d 100644
--- a/src/lib/ecore_imf/ecore_imf_context.c
+++ b/src/lib/ecore_imf/ecore_imf_context.c
@@ -224,6 +224,9 @@ ecore_imf_context_del(Ecore_IMF_Context *ctx)
            free(fn);
      }
 
+   if (ctx->prediction_hint_hash)
+     eina_hash_free(ctx->prediction_hint_hash);
+
    ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE);
    free(ctx);
 }
@@ -1460,4 +1463,62 @@ 
ecore_imf_context_input_panel_position_set(Ecore_IMF_Context *ctx, int x, int y)
 
    if (ctx->klass->input_panel_position_set)
      ctx->klass->input_panel_position_set(ctx, x, y);
-}
\ No newline at end of file
+}
+
+static void
+_prediction_hint_hash_free_cb(void *data)
+{
+   free(data);
+}
+
+EAPI Eina_Bool
+ecore_imf_context_prediction_hint_hash_set(Ecore_IMF_Context *ctx, const char 
*key, const char *value)
+{
+   if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
+     {
+        ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
+                         "ecore_imf_context_prediction_hint_hash_set");
+        return EINA_FALSE;
+     }
+
+   if (!ctx->prediction_hint_hash)
+     ctx->prediction_hint_hash = 
eina_hash_string_superfast_new(_prediction_hint_hash_free_cb);
+
+   if (!ctx->prediction_hint_hash)
+     return EINA_FALSE;
+
+   char *old_value = eina_hash_set(ctx->prediction_hint_hash, key, value ? 
strdup(value) : strdup(""));
+   if (old_value)
+     free(old_value);
+
+   return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+ecore_imf_context_prediction_hint_hash_del(Ecore_IMF_Context *ctx, const char 
*key)
+{
+   if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
+     {
+        ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
+                         "ecore_imf_context_prediction_hint_hash_del");
+        return EINA_FALSE;
+     }
+
+   if (!ctx->prediction_hint_hash)
+     return EINA_FALSE;
+
+   return eina_hash_del(ctx->prediction_hint_hash, key, NULL);
+}
+
+EAPI const Eina_Hash *
+ecore_imf_context_prediction_hint_hash_get(Ecore_IMF_Context *ctx)
+{
+   if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
+     {
+        ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
+                         "ecore_imf_context_prediction_hint_hash_get");
+        return NULL;
+     }
+
+   return ctx->prediction_hint_hash;
+}
diff --git a/src/lib/ecore_imf/ecore_imf_private.h 
b/src/lib/ecore_imf/ecore_imf_private.h
index 611db426e7..22d2942109 100644
--- a/src/lib/ecore_imf/ecore_imf_private.h
+++ b/src/lib/ecore_imf/ecore_imf_private.h
@@ -60,6 +60,7 @@ struct _Ecore_IMF_Context
    int                            input_panel_layout_variation;
    Eina_Bool                    (*retrieve_selection_func)(void *data, 
Ecore_IMF_Context *ctx, char **text);
    void                          *retrieve_selection_data;
+   Eina_Hash                     *prediction_hint_hash;
    Eina_Bool                      allow_prediction : 1;
    Eina_Bool                      input_panel_enabled : 1;
    Eina_Bool                      input_panel_return_key_disabled : 1;

-- 


Reply via email to