Support prediction hint data interface 51/160851/17
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 20 Nov 2017 08:35:12 +0000 (17:35 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 19 Dec 2017 01:23:28 +0000 (10:23 +0900)
Change-Id: Ic75d5db6ac4f467592da0eec0a4ec6ba09b6c7a3
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
19 files changed:
configure.ac
ism/extras/wayland_immodule/Makefile.am
ism/extras/wayland_immodule/wayland_imcontext.c
ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
ism/modules/panelagent/wayland/isf_wsc_control.cpp
ism/modules/panelagent/wayland/isf_wsc_control.h
ism/modules/panelagent/wayland/isf_wsc_control_ui.cpp
ism/modules/panelagent/wayland/isf_wsc_control_ui.h
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp
ism/src/isf_info_manager.cpp
ism/src/isf_info_manager.h
ism/src/isf_message_queue.h
ism/src/isf_panel_agent_base.cpp
ism/src/isf_panel_agent_base.h
ism/src/isf_panel_agent_manager.cpp
ism/src/isf_panel_agent_manager.h
ism/src/scim_helper.cpp
ism/src/scim_helper.h
ism/src/scim_trans_commands.h

index 496a266..d223b87 100644 (file)
@@ -289,6 +289,8 @@ PKG_CHECK_MODULES(GLIB, [glib-2.0])
 # Check tzplatform-config library
 PKG_CHECK_MODULES(TZPLATFORM_CONFIG, [libtzplatform-config])
 
+PKG_CHECK_MODULES(APPFW_APPLICATION, [capi-appfw-application])
+
 # Check dlog library
 PKG_CHECK_MODULES(DLOG, [dlog >= 0])
 
index d22ec54..80d6fa3 100644 (file)
@@ -28,7 +28,8 @@ module_la_CFLAGS = @ECORE_CFLAGS@ \
                    @ECORE_WL_CFLAGS@ \
                    @WL_TEXT_INPUT_CFLAGS@ \
                    @DLOG_CFLAGS@ \
-                   @VCONF_CFLAGS@
+                   @VCONF_CFLAGS@ \
+                   @APPFW_APPLICATION_CFLAGS@
 
 module_la_LDFLAGS  = -rpath $(moduledir) \
                      -avoid-version \
@@ -42,4 +43,5 @@ module_la_LIBADD   = $(LD_VERSION_SCRIPT_OPTION) \
                      @WL_TEXT_INPUT_LIBS@ \
                      @DLOG_LIBS@ \
                      @VCONF_LIBS@ \
+                     @APPFW_APPLICATION_LIBS@ \
                      $(top_builddir)/ism/src/libprofile.la
index ba5aa01..a222f2a 100644 (file)
@@ -29,6 +29,7 @@
 #include <Ecore_Wayland.h>
 #include <dlog.h>
 #include <wctype.h>
+#include <app_common.h>
 #ifdef HAVE_VCONF
 #include <vconf.h>
 #endif
@@ -2638,6 +2639,7 @@ void
 wayland_im_context_add(Ecore_IMF_Context *ctx)
 {
     WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx);
+    char *appid = NULL;
 
     LOGD("ctx : %p", ctx);
 
@@ -2662,6 +2664,14 @@ wayland_im_context_add(Ecore_IMF_Context *ctx)
     if (imcontext->text_input)
         wl_text_input_add_listener(imcontext->text_input,
                                    &text_input_listener, imcontext);
+
+    app_get_id(&appid);
+    LOGD("app id : %s\n", appid);
+
+    ecore_imf_context_prediction_hint_hash_set(ctx, "appid", appid ? appid : "");
+
+    if (appid)
+        free (appid);
 }
 
 void
@@ -2758,6 +2768,23 @@ wayland_im_context_reset(Ecore_IMF_Context *ctx)
     imcontext->reset_serial = imcontext->serial;
 }
 
+static Eina_Bool
+_prediction_hint_data_foreach_cb(const Eina_Hash *hash, const void *key,
+                                 void *data, void *fdata)
+{
+    const char *key_str = key;
+    const char *value = data;
+    Ecore_IMF_Context *ctx = (Ecore_IMF_Context *)fdata;
+    WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx);
+
+    SECURE_LOGD("key : %s, value : %s\n", key_str, value);
+
+    if (imcontext && imcontext->text_input)
+        wl_text_input_prediction_hint_data(imcontext->text_input, key_str, value);
+
+    return EINA_TRUE;
+}
+
 void
 wayland_im_context_focus_in(Ecore_IMF_Context *ctx)
 {
@@ -2795,6 +2822,10 @@ wayland_im_context_focus_in(Ecore_IMF_Context *ctx)
         if (imcontext->input_panel_position.x >= 0 && imcontext->input_panel_position.y >= 0)
             wl_text_input_set_input_panel_position(imcontext->text_input,
                 imcontext->input_panel_position.x, imcontext->input_panel_position.y);
+
+        const Eina_Hash *hash = ecore_imf_context_prediction_hint_hash_get(ctx);
+        if (hash)
+            eina_hash_foreach(hash, _prediction_hint_data_foreach_cb, ctx);
     }
 
     if (ecore_imf_context_input_panel_enabled_get(ctx))
index 73c926c..2a0f3ff 100644 (file)
@@ -823,6 +823,18 @@ private:
         m_send_trans.write_to_socket(client_socket);
     }
 
+    void set_helper_prediction_hint_data(int client, uint32 context, const String& uuid, String& key, String &value) {
+        Socket client_socket(client);
+        m_send_trans.clear();
+        m_send_trans.put_command(SCIM_TRANS_CMD_REPLY);
+        m_send_trans.put_data(context);
+        m_send_trans.put_data(uuid);
+        m_send_trans.put_command(ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA);
+        m_send_trans.put_data(key);
+        m_send_trans.put_data(value);
+        m_send_trans.write_to_socket(client_socket);
+    }
+
     void finalize_content_helper(int client, uint32 context, const String& uuid, String& text, uint32& cursor_pos) {
         LOGD("client id:%d", client);
 
index aa2bf34..0a198c8 100644 (file)
@@ -230,6 +230,13 @@ int _isf_wsc_context_input_panel_finalize_content (int context, const char *text
     g_info_manager->finalize_content (get_panel_client_id (), String (text), cursor_pos);
     return 0;
 }
+
+int _isf_wsc_context_input_panel_prediction_hint_data_set (int context, const char *key, const char *value)
+{
+    g_info_manager->set_prediction_hint_data (get_panel_client_id (), String (key), String (value));
+    return 0;
+}
+
 /*
 vi:ts=4:expandtab:nowrap
 */
index f127e26..d284c1e 100644 (file)
@@ -67,6 +67,7 @@ extern "C"
     int _isf_wsc_context_input_panel_prediction_hint_set (int context, const char *prediction_hint);
     int _isf_wsc_context_input_panel_mime_type_accept_set (int context, const char *mime_type);
     int _isf_wsc_context_input_panel_finalize_content (int context, const char *text, int cursor_pos);
+    int _isf_wsc_context_input_panel_prediction_hint_data_set (int context, const char *key, const char *value);
 
 #ifdef __cplusplus
 }
index 7c55a3b..01ef0f1 100644 (file)
@@ -305,3 +305,8 @@ void isf_wsc_context_input_panel_finalize_content (WSCContextISF *ctx, const cha
 {
     _isf_wsc_context_input_panel_finalize_content (_get_context_id(ctx), text, cursor_pos);
 }
+
+void isf_wsc_context_input_panel_prediction_hint_data_set (WSCContextISF *ctx, const char *key, const char *value)
+{
+    _isf_wsc_context_input_panel_prediction_hint_data_set (_get_context_id(ctx), key, value);
+}
index 21062b2..fc39f17 100644 (file)
@@ -57,6 +57,7 @@ extern "C"
     void isf_wsc_context_input_panel_prediction_hint_set (WSCContextISF *ctx, const char *prediction_hint);
     void isf_wsc_context_input_panel_mime_type_accept_set (WSCContextISF *ctx, const char *mime_type);
     void isf_wsc_context_input_panel_finalize_content (WSCContextISF *ctx, const char *text, int cursor_pos);
+    void isf_wsc_context_input_panel_prediction_hint_data_set (WSCContextISF *ctx, const char *key, const char *value);
 
 #ifdef __cplusplus
 }
index 50cb648..b9a9654 100644 (file)
@@ -503,6 +503,15 @@ _wsc_im_ctx_finalized_content (void *data, struct wl_input_method_context *im_ct
     isf_wsc_context_input_panel_finalize_content (wsc_ctx, text, cursor_pos);
 }
 
+static void
+_wsc_im_ctx_prediction_hint_data (void *data, struct wl_input_method_context *im_ctx, const char *key, const char * value)
+{
+    WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+    if (!wsc_ctx) return;
+
+    isf_wsc_context_input_panel_prediction_hint_data_set (wsc_ctx, key, value);
+}
+
 static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_reset,
      _wsc_im_ctx_content_type,
@@ -519,7 +528,8 @@ static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_capital_mode,
      _wsc_im_ctx_prediction_hint,
      _wsc_im_ctx_mime_type,
-     _wsc_im_ctx_finalized_content
+     _wsc_im_ctx_finalized_content,
+     _wsc_im_ctx_prediction_hint_data
 };
 
 #if ENABLE_GRAB_KEYBOARD
index f1d1528..14d24a8 100644 (file)
@@ -1367,6 +1367,22 @@ public:
         return false;
     }
 
+    bool set_helper_prediction_hint_data (const String& uuid, String key, String value) {
+        HelperClientIndex::iterator it = m_helper_client_index.find (m_current_helper_uuid);
+
+        if (it != m_helper_client_index.end ()) {
+            int client;
+            uint32 context;
+            uint32 ctx;
+            get_focused_context (client, context);
+            ctx = get_helper_ic (client, context);
+            m_panel_agent_manager.set_helper_prediction_hint_data (it->second.id, ctx, uuid, key, value);
+            return true;
+        }
+
+        return false;
+    }
+
     //ISM_TRANS_CMD_SHOW_ISF_CONTROL
     void show_isf_panel (int client_id) {
         SCIM_DEBUG_MAIN (4) << "InfoManager::show_isf_panel ()\n";
@@ -2025,6 +2041,13 @@ public:
             finalize_content_helper (m_current_helper_uuid, text, cursor_pos);
     }
 
+    //ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA
+    void set_prediction_hint_data (int client_id, String key, String value) {
+        SCIM_DEBUG_MAIN (4) << "InfoManager::set_prediction_hint_data ()\n";
+        if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode || m_current_helper_option & ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT)
+            set_helper_prediction_hint_data (m_current_helper_uuid, key, value);
+    }
+
     //ISM_TRANS_CMD_EXPAND_CANDIDATE
     void expand_candidate () {
         LOGD ("");
@@ -4553,7 +4576,6 @@ void InfoManager::get_candidate_window_geometry (int client_id, _OUT_ struct rec
     m_impl->get_candidate_window_geometry (client_id, info);
 }
 
-
 //ISM_TRANS_CMD_GET_ISE_LANGUAGE_LOCALE
 void InfoManager::get_ise_language_locale (int client_id, _OUT_ char** data, _OUT_ size_t& len)
 {
@@ -4801,6 +4823,12 @@ void InfoManager::finalize_content (int client_id, String text, uint32 cursor_po
     m_impl->finalize_content (client_id, text, cursor_pos);
 }
 
+//ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA
+void InfoManager::set_prediction_hint_data (int client_id, String key, String value)
+{
+    m_impl->set_prediction_hint_data (client_id, key, value);
+}
+
 //ISM_TRANS_CMD_EXPAND_CANDIDATE
 void InfoManager::expand_candidate ()
 {
index 9f50a0b..8e0f6ec 100644 (file)
@@ -747,6 +747,9 @@ public:
     //ISM_TRANS_CMD_FINALIZE_CONTENT
     void finalize_content(int client_id, String text, uint32 cursor_pos);
 
+    //ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA
+    void set_prediction_hint_data (int client_id, String key, String value);
+
     //ISM_TRANS_CMD_EXPAND_CANDIDATE
     void expand_candidate ();
 
index b9c9104..018c9cc 100644 (file)
@@ -744,6 +744,20 @@ protected:
     uint32 m_cursor_pos;
 };
 
+/* ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA */
+class MessageItemSetPredictionHintData : public MessageItemHelper
+{
+public:
+    MessageItemSetPredictionHintData() {}
+    virtual ~MessageItemSetPredictionHintData() {}
+
+    String& get_key_ref() { return m_key; }
+    String& get_value_ref() { return m_value; }
+protected:
+    String m_key;
+    String m_value;
+};
+
 template <typename T>
 inline T*
 alloc_message() /* We could use memory pool in the future for performance enhancement */
@@ -1721,6 +1735,21 @@ public:
                     }
                     break;
                 }
+                case ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA:
+                {
+                    MessageItemSetPredictionHintData *message = alloc_message<MessageItemSetPredictionHintData>();
+                    if (message) {
+                        message->get_command_ref() = cmd;
+                        if (transaction.get_data(message->get_key_ref()) &&
+                            transaction.get_data(message->get_value_ref())) {
+                            m_list_messages.push_back(message);
+                        } else {
+                            LOGW("wrong format of transaction\n");
+                            dealloc_message<MessageItemSetPredictionHintData>(message);
+                        }
+                    }
+                    break;
+                }
             }
         }
 
index 26393f7..19a2668 100644 (file)
@@ -275,6 +275,10 @@ void PanelAgentBase::finalize_content_helper (int client, uint32 context, const
 {
 }
 
+void PanelAgentBase::set_helper_prediction_hint_data (int client, uint32 context, const String& uuid, String& key, String& value)
+{
+}
+
 bool PanelAgentBase::process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial)
 {
     return false;
index fb35a6d..15f55ad 100644 (file)
@@ -512,6 +512,15 @@ public:
     virtual void finalize_content_helper (int client, uint32 context, const String& uuid, String& text, uint32& cursor_pos);
 
     /**
+     * @brief set_helper_prediction_hint_data.
+     *
+     * @param
+     *
+     * @return none.
+     */
+    virtual void set_helper_prediction_hint_data (int client, uint32 context, const String& uuid, String& key, String &value);
+
+    /**
      * @brief process_key_event.
      *
      * @param
index 43a6482..eb66fc9 100644 (file)
@@ -530,6 +530,14 @@ void PanelAgentManager::finalize_content_helper (int id, uint32 context_id, cons
         _p->finalize_content_helper (id, context_id, uuid, text, cursor_pos);
 }
 
+void PanelAgentManager::set_helper_prediction_hint_data (int id, uint32 context_id, const String& uuid, String& key, String& value)
+{
+    PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
+
+    if (!_p.null ())
+        _p->set_helper_prediction_hint_data (id, context_id, uuid, key, value);
+}
+
 bool PanelAgentManager::process_key_event (int id, uint32 context_id, const String& uuid, KeyEvent& key, uint32 serial)
 {
     PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
index fa767d0..7f3e4fc 100644 (file)
@@ -309,6 +309,7 @@ public:
     void resume_helper_option_window (int client, uint32 context, const String& uuid);
     void set_helper_keyboard_mode (int client, uint32 context, const String& uuid, uint32& mode);
     void set_helper_prediction_hint (int client, uint32 context, const String& uuid, String& prediction_hint);
+    void set_helper_prediction_hint_data (int id, uint32 context_id, const String& uuid, String& key, String& value);
     void set_helper_mime_type (int client, uint32 context, const String& uuid, String& mime_type);
     void finalize_content_helper (int client, uint32 context, const String& uuid, String& text, uint32& cursor_pos);
     bool process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial);
index 2d778a3..5b908c5 100644 (file)
@@ -229,6 +229,7 @@ public:
     HelperAgentSignalUintCharSizeUint   signal_process_input_device_event;
     HelperAgentSignalStringVoid         signal_set_prediction_hint;
     HelperAgentSignalStringVoid         signal_set_mime_type;
+    HelperAgentSignalString             signal_set_prediction_hint_data;
 
 public:
     HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
@@ -1464,6 +1465,12 @@ HelperAgent::handle_message (MessageItem *message)
             }
             break;
         }
+        case ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA:
+        {
+            MessageItemSetPredictionHintData *subclass = static_cast<MessageItemSetPredictionHintData*>(message);
+            m_impl->signal_set_prediction_hint_data (this, 0, subclass->get_key_ref(), subclass->get_value_ref());
+            break;
+        }
         default:
             break;
     }
@@ -3501,6 +3508,20 @@ HelperAgent::signal_connect_set_mime_type (HelperAgentSlotStringVoid *slot)
     return m_impl->signal_set_mime_type.connect (slot);
 }
 
+/**
+ * @brief Connect a slot to Helper set prediction hint data signal.
+ *
+ * This signal is used to send prediction hint data to Helper ISE.
+ *
+ * The prototype of the slot is:
+ * void set_prediction_hint_data (const HelperAgent *agent, char *key, char *value);
+ */
+Connection
+HelperAgent::signal_connect_set_prediction_hint_data (HelperAgentSlotString *slot)
+{
+    return m_impl->signal_set_prediction_hint_data.connect (slot);
+}
+
 } /* namespace scim */
 
 /*
index ec3dd70..ea831e1 100644 (file)
@@ -1398,6 +1398,16 @@ public:
      * void set_mime_type (const HelperAgent *agent, char *mime_type);
      */
     Connection signal_connect_set_mime_type                         (HelperAgentSlotStringVoid          *slot);
+
+    /**
+     * @brief Connect a slot to Helper set prediction hint data signal.
+     *
+     * This signal is used to send prediction hint data to Helper ISE.
+     *
+     * The prototype of the slot is:
+     * void set_prediction_hint_data (const HelperAgent *agent, char *key, char *value);
+     */
+    Connection signal_connect_set_prediction_hint_data              (HelperAgentSlotString              *slot);
 };
 
 /**  @} */
index 32e52cb..119da05 100644 (file)
@@ -672,6 +672,7 @@ const int ISM_TRANS_CMD_SET_KEYBOARD_MODE                 = 1128;
 const int ISM_TRANS_CMD_SET_PREDICTION_HINT               = 1129;
 const int ISM_TRANS_CMD_SET_MIME_TYPE                     = 1130;
 const int ISM_TRANS_CMD_FINALIZE_CONTENT                  = 1131;
+const int ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA          = 1132;
 
 /* ISE/Panel to IMControl */
 const int ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT          = 1151;