Support prediction_hint_set interface 44/124444/6
authorInHong Han <inhong1.han@samsung.com>
Mon, 3 Apr 2017 01:25:51 +0000 (10:25 +0900)
committerInHong Han <inhong1.han@samsung.com>
Thu, 27 Apr 2017 09:31:38 +0000 (18:31 +0900)
Change-Id: I2bdca2c7805a1f9d7ddcfdba71b39bed5f24689b

19 files changed:
ism/extras/wayland_immodule/wayland_imcontext.c
ism/extras/wayland_immodule/wayland_imcontext.h
ism/extras/wayland_immodule/wayland_module.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 3465a6cd7bc773967312cacf7e9c217c21694062..33bcaca6f596cc4bf9a042d4e41cb014bee65cb3 100644 (file)
@@ -215,6 +215,7 @@ struct _WaylandIMContext
     uint32_t reset_serial;
 
     Eina_Bool has_conformant;
+    const char *prediction_hint;
     //
 };
 
@@ -2603,6 +2604,11 @@ wayland_im_context_del (Ecore_IMF_Context *ctx)
     }
     //
 
+    if (imcontext->prediction_hint) {
+        free (imcontext->prediction_hint);
+        imcontext->prediction_hint = NULL;
+    }
+
     if (imcontext->text_input)
         wl_text_input_destroy (imcontext->text_input);
 
@@ -2653,10 +2659,14 @@ wayland_im_context_focus_in(Ecore_IMF_Context *ctx)
     }
 
     WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx);
-    if (imcontext && imcontext->input && imcontext->text_input)
+    if (imcontext && imcontext->input && imcontext->text_input) {
         wl_text_input_set_return_key_disabled(imcontext->text_input,
                 imcontext->return_key_disabled);
 
+        if (imcontext->prediction_hint)
+            wl_text_input_prediction_hint(imcontext->text_input, imcontext->prediction_hint);
+    }
+
     if (ecore_imf_context_input_panel_enabled_get(ctx))
         if (!ecore_imf_context_input_panel_show_on_demand_get (ctx))
             show_input_panel(ctx);
@@ -3389,6 +3399,20 @@ wayland_im_context_input_panel_keyboard_mode_get(Ecore_IMF_Context *ctx EINA_UNU
     return hw_keyboard_mode ? ECORE_IMF_INPUT_PANEL_HW_KEYBOARD_MODE : ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE;
 }
 
+void
+wayland_im_context_prediction_hint_set (Ecore_IMF_Context *ctx, const char *prediction_hint)
+{
+    WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx);
+    if (!imcontext) return;
+
+    imcontext->prediction_hint = strdup(prediction_hint);
+
+    if (imcontext->input && imcontext->text_input) {
+        LOGD ("ctx : %p, prediction_hint : %s\n", ctx, imcontext->prediction_hint);
+        wl_text_input_prediction_hint(imcontext->text_input, imcontext->prediction_hint);
+    }
+}
+
 WaylandIMContext *wayland_im_context_new (struct wl_text_input_manager *text_input_manager)
 {
     WaylandIMContext *context = calloc(1, sizeof(WaylandIMContext));
index e0372f92f0c57fff125a1763bae76f43e8f37a7a..19bfcec5f2be5dea077bea59f19c7dabfc8855de 100644 (file)
@@ -122,6 +122,9 @@ wayland_im_context_bidi_direction_set(Ecore_IMF_Context *ctx, Ecore_IMF_BiDi_Dir
 Ecore_IMF_Input_Panel_Keyboard_Mode
 wayland_im_context_input_panel_keyboard_mode_get(Ecore_IMF_Context *ctx);
 
+void
+wayland_im_context_prediction_hint_set (Ecore_IMF_Context *ctx, const char *prediction_hint);
+
 WaylandIMContext *wayland_im_context_new        (struct wl_text_input_manager *text_input_manager);
 
 extern int _ecore_imf_wayland_log_dom;
index 7832b98ab49f670749efe84865826c836a9e6882..ebdbb66fe9787940ef8e4b328a496a56d8c4788a 100644 (file)
@@ -79,7 +79,8 @@ static Ecore_IMF_Context_Class wayland_imf_class =
     NULL,                                      /* candidate_window_geometry_get */
     wayland_im_context_input_hint_set,         /* input_hint_set */
     wayland_im_context_bidi_direction_set,     /* bidi_direction_set */
-    wayland_im_context_input_panel_keyboard_mode_get /* input_panel_keyboard_mode_get */
+    wayland_im_context_input_panel_keyboard_mode_get, /* input_panel_keyboard_mode_get */
+    wayland_im_context_prediction_hint_set     /* prediction_hint_set */
 };
 
 static struct wl_text_input_manager *text_input_manager = NULL;
index 5a82147f2e419625962a3deb1fb4e390020e9ff9..dfd7c10288999796496f4ef3fd731c03baf71406 100644 (file)
@@ -803,6 +803,19 @@ private:
         m_send_trans.write_to_socket(client_socket);
     }
 
+    void set_helper_prediction_hint(int client, uint32 context, const String& uuid, String& prediction_hint) {
+        LOGD ("client id:%d\n", client);
+
+        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);
+        m_send_trans.put_data(prediction_hint);
+        m_send_trans.write_to_socket(client_socket);
+    }
+
     bool process_key_event(int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial) {
         LOGD ("client id:%d\n", client);
 
index be8c9bda4bdff84f7ba8a50a023f4d59dc1a8582..0d040d0395b35ca7a0cd15a533d25cd2267819d7 100644 (file)
@@ -212,6 +212,12 @@ int _isf_wsc_context_process_input_device_event(int context, int type, const voi
     g_info_manager->process_input_device_event(context, (unsigned int)type, (const char*)data, (size_t)len, result);
     return 0;
 }
+
+int _isf_wsc_context_input_panel_prediction_hint_set (int context, const char *prediction_hint)
+{
+    g_info_manager->set_prediction_hint (get_panel_client_id (), String (prediction_hint));
+    return 0;
+}
 /*
 vi:ts=4:expandtab:nowrap
 */
index 29ba0b9cb5a35551e93660d812b6bb8dabfab3d4..4a85f4bb6a3ea84afeeb896c61413e54b884bee8 100644 (file)
@@ -64,6 +64,7 @@ extern "C"
 
     int _isf_wsc_context_input_panel_send_candidate_will_hide_ack (int context);
     int _isf_wsc_context_process_input_device_event(int context, int type, const void* data, int len);
+    int _isf_wsc_context_input_panel_prediction_hint_set (int context, const char *prediction_hint);
 
 #ifdef __cplusplus
 }
index 221922ef07f24db2b3b95f22b7e22086154404ce..efbfd1f46b6971dced5cf51cc3b20dbb69d5fe61 100644 (file)
@@ -273,3 +273,8 @@ void isf_wsc_context_process_input_device_event (WSCContextISF *ctx, uint32_t ty
 {
     _isf_wsc_context_process_input_device_event (_get_context_id(ctx), type, data, len);
 }
+
+void isf_wsc_context_input_panel_prediction_hint_set (WSCContextISF *ctx, const char *prediction_hint)
+{
+    _isf_wsc_context_input_panel_prediction_hint_set (_get_context_id(ctx), prediction_hint);
+}
index 4145eea2d6714d6607f1e9e8b34bcfe952968831..878c78ff0551905bbb5f79e52eba9cd18c681615 100644 (file)
@@ -54,6 +54,7 @@ extern "C"
     void isf_wsc_context_input_panel_imdata_set (WSCContextISF *ctx, const void *imdata, int len);
     void isf_wsc_context_input_panel_imdata_get (WSCContextISF *ctx, void **imdata, int* len);
     void isf_wsc_context_process_input_device_event (WSCContextISF *ctx, uint32_t type, const char *data, uint32_t len);
+    void isf_wsc_context_input_panel_prediction_hint_set (WSCContextISF *ctx, const char *prediction_hint);
 
 #ifdef __cplusplus
 }
index 40e8d5eee93836fb705fefe89c5e18956fab003d..ce5b2188d101db90477cba49d9d4f3ecc3f4e7e0 100644 (file)
@@ -468,6 +468,16 @@ _wsc_im_ctx_captial_mode (void *data, struct wl_input_method_context *im_ctx, ui
     isf_wsc_context_input_panel_caps_mode_set (wsc_ctx, mode);
 }
 
+static void
+_wsc_im_ctx_prediction_hint (void *data, struct wl_input_method_context *im_ctx, const char *prediction_hint)
+{
+    LOGD ("im_context = %p, prediction hint = %s\n", im_ctx, prediction_hint);
+    WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+    if (!wsc_ctx) return;
+
+    isf_wsc_context_input_panel_prediction_hint_set (wsc_ctx, prediction_hint);
+}
+
 static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_reset,
      _wsc_im_ctx_content_type,
@@ -481,7 +491,8 @@ static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_cursor_position,
      _wsc_im_ctx_process_input_device_event,
      _wsc_im_ctx_filter_key_event,
-     _wsc_im_ctx_captial_mode
+     _wsc_im_ctx_captial_mode,
+     _wsc_im_ctx_prediction_hint
 };
 
 #if ENABLE_GRAB_KEYBOARD
index ff1fd7a7ec41e3c5ae9203834b604f5448ab061a..1fc454854a2037677f00d4f1cca91ecab5352aa0 100644 (file)
@@ -1308,6 +1308,23 @@ public:
         return false;
     }
 
+    bool set_helper_prediction_hint (const String& uuid, String prediction_hint) {
+        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);
+            LOGD ("Send ISM_TRANS_CMD_SET_PREDICTION_HINT message");
+            m_panel_agent_manager.set_helper_prediction_hint (it->second.id, ctx, uuid, prediction_hint);
+            return true;
+        }
+
+        return false;
+    }
+
     //ISM_TRANS_CMD_SHOW_ISF_CONTROL
     void show_isf_panel (int client_id) {
         LOGD ("");
@@ -1987,6 +2004,14 @@ public:
             set_helper_keyboard_mode (m_current_helper_uuid, mode);
     }
 
+    //ISM_TRANS_CMD_SET_PREDICTION_HINT
+    void set_prediction_hint (int client_id, String prediction_hint) {
+        SCIM_DEBUG_MAIN (4) << "InfoManager::set_prediction_hint ()\n";
+        LOGD ("");
+        if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode || m_current_helper_option & ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT)
+            set_helper_prediction_hint (m_current_helper_uuid, prediction_hint);
+    }
+
     //ISM_TRANS_CMD_EXPAND_CANDIDATE
     void expand_candidate () {
         LOGD ("");
@@ -4770,6 +4795,12 @@ void InfoManager::set_ise_keyboard_mode (int client_id, uint32 mode)
     m_impl->set_ise_keyboard_mode (client_id, mode);
 }
 
+//ISM_TRANS_CMD_SET_PREDICTION_HINT
+void InfoManager::set_prediction_hint (int client_id, String prediction_hint)
+{
+    m_impl->set_prediction_hint (client_id, prediction_hint);
+}
+
 //ISM_TRANS_CMD_EXPAND_CANDIDATE
 void InfoManager::expand_candidate ()
 {
index bb20de247982a47004e9dd57c8a9fac6c3f288a4..483a337eeb4ca26959fbe757c2963d60dd1fda4c 100644 (file)
@@ -735,6 +735,9 @@ public:
     //ISM_TRANS_CMD_SET_KEYBOARD_MODE
     void set_ise_keyboard_mode (int client_id, uint32 mode);
 
+    //ISM_TRANS_CMD_SET_PREDICTION_HINT
+    void set_prediction_hint (int client_id, String prediction_hint);
+
     //ISM_TRANS_CMD_EXPAND_CANDIDATE
     void expand_candidate ();
 
index 90411cfd7fd4eb2a70466ce2e2632e5cc5fa3476..d74c6681e850c88ea98d87ff90a4656697c7bc15 100644 (file)
@@ -706,6 +706,18 @@ class MessageItemFlushBuffer : public MessageItemHelper
 {
 };
 
+/* ISM_TRANS_CMD_SET_PREDICTION_HINT */
+class MessageItemSetPredictionHint : public MessageItemHelper
+{
+public:
+    MessageItemSetPredictionHint() {}
+    virtual ~MessageItemSetPredictionHint() {}
+
+    String& get_message_ptr() { return m_prediction_hint; }
+protected:
+    String m_prediction_hint;
+};
+
 template <typename T>
 inline T*
 alloc_message() /* We could use memory pool in the future for performance enhancement */
@@ -1640,6 +1652,20 @@ public:
                     }
                     break;
                 }
+                case ISM_TRANS_CMD_SET_PREDICTION_HINT:
+                {
+                    MessageItemSetPredictionHint *message = alloc_message<MessageItemSetPredictionHint>();
+                    if (message) {
+                        message->get_command_ref() = cmd;
+                        if (transaction.get_data(message->get_message_ptr())) {
+                            m_list_messages.push_back(message);
+                        } else {
+                            LOGW("wrong format of transaction\n");
+                            dealloc_message<MessageItemSetPredictionHint>(message);
+                        }
+                    }
+                    break;
+                }
             }
         }
 
index 5863a38dc7053f6844a82b8c4cd1499baf7ed57e..591445b0027a75a070c9e6a39234f0312108d1cf 100644 (file)
@@ -311,6 +311,11 @@ void PanelAgentBase::set_helper_keyboard_mode (int client, uint32 context, const
     LOGW ("not implemented for %s", m_name.c_str ());
 }
 
+void PanelAgentBase::set_helper_prediction_hint (int client, uint32 context, const String& uuid, String& prediction_hint)
+{
+    LOGW ("not implemented for %s", m_name.c_str ());
+}
+
 bool PanelAgentBase::process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial)
 {
     LOGW ("not implemented for %s", m_name.c_str ());
index 5c8496781d8a0f1e86ba3fa8508a43eeb0829690..880a0f4ce367e334cc64f36c6b1721ca90a6282c 100644 (file)
@@ -484,6 +484,15 @@ public:
      */
     virtual void set_helper_keyboard_mode (int client, uint32 context, const String& uuid, uint32& mode);
 
+    /**
+     * @brief set_helper_prediction_hint.
+     *
+     * @param
+     *
+     * @return none.
+     */
+    virtual void set_helper_prediction_hint (int client, uint32 context, const String& uuid, String& prediction_hint);
+
     /**
      * @brief process_key_event.
      *
index 655ab94c4fbe0566c1420d2d5c5a60c18749f5a5..e92c409cfe6775273b24ec8fcc40ce9fc3cfa675 100644 (file)
@@ -506,6 +506,14 @@ void PanelAgentManager::set_helper_keyboard_mode (int id, uint32 context_id, con
         _p->set_helper_keyboard_mode (id, context_id, uuid, mode);
 }
 
+void PanelAgentManager::set_helper_prediction_hint (int id, uint32 context_id, const String& uuid, String& prediction_hint)
+{
+    PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
+
+    if (!_p.null ())
+        _p->set_helper_prediction_hint (id, context_id, uuid, prediction_hint);
+}
+
 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 fa798437b1db519ae05460665d3977c2470f6ba0..80b4a2a8aea1f1ac500e9d8159af356ea9123f85 100644 (file)
@@ -308,6 +308,7 @@ public:
     void show_helper_option_window (int client, uint32 context, const String& uuid);
     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);
     bool process_key_event (int client, uint32 context, const String& uuid, KeyEvent& key, uint32 serial);
     bool get_helper_geometry (int client, uint32 context, String& uuid, _OUT_ struct rectinfo& info);
     void get_helper_imdata (int client, uint32 context, String& uuid, _OUT_ char** imdata, _OUT_ size_t& len);
index 8a05438ba46ae559c861a3be9fabfa2bea3e021c..9b69c5178a54c8614a3da972e88a0fd914a27039 100644 (file)
@@ -133,6 +133,9 @@ typedef Signal3<void, const HelperAgent *, KeyEvent &, uint32 &>
 typedef Signal5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
         HelperAgentSignalUintCharSizeUint;
 
+typedef Signal2<void, const HelperAgent *, const String &>
+        HelperAgentSignalStringVoid;
+
 class HelperAgent::HelperAgentImpl
 {
 public:
@@ -219,6 +222,7 @@ public:
     HelperAgentSignalVoid               signal_resume_option_window;
     HelperAgentSignalUintVoid           signal_check_option_window;
     HelperAgentSignalUintCharSizeUint   signal_process_input_device_event;
+    HelperAgentSignalStringVoid         signal_set_prediction_hint;
 
 public:
     HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
@@ -1440,6 +1444,13 @@ HelperAgent::handle_message (MessageItem *message)
                 m_impl->hw_keyboard_mode = true;
             break;
         }
+        case ISM_TRANS_CMD_SET_PREDICTION_HINT:
+        {
+            MessageItemSetPredictionHint *subclass = static_cast<MessageItemSetPredictionHint*>(message);
+            LOGD("prediction_hint : %s\n", strdup (subclass->get_message_ptr().c_str ()));
+            m_impl->signal_set_prediction_hint (this, subclass->get_message_ptr());
+            break;
+        }
         default:
             break;
     }
@@ -3459,6 +3470,20 @@ HelperAgent::signal_connect_process_input_device_event (HelperAgentSlotUintCharS
     return m_impl->signal_process_input_device_event.connect (slot);
 }
 
+/**
+ * @brief Connect a slot to Helper set prediction hint signal.
+ *
+ * This signal is used to send prediction hint to Helper ISE.
+ *
+ * The prototype of the slot is:
+ * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
+ */
+Connection
+HelperAgent::signal_connect_set_prediction_hint (HelperAgentSlotStringVoid *slot)
+{
+    return m_impl->signal_set_prediction_hint.connect (slot);
+}
+
 } /* namespace scim */
 
 /*
index 8985bc333220d7716b25ca82d7acdf173871add1..a765fef4783278f48253ff13a5cd16ed8bae3573 100644 (file)
@@ -216,6 +216,9 @@ typedef Slot3<void, const HelperAgent *, KeyEvent &, uint32 &>
 typedef Slot5<void, const HelperAgent *, uint32 &, char *, size_t &, uint32 &>
         HelperAgentSlotUintCharSizeUint;
 
+typedef Slot2<void, const HelperAgent *, const String &>
+        HelperAgentSlotStringVoid;
+
 /**
  * @brief The accessory class to write a Helper object.
  *
@@ -1366,6 +1369,16 @@ public:
     * void process_input_device_event (const HelperAgent *, uint32 &type, char *data, size_t &size, uint32 &ret);
     */
     Connection signal_connect_process_input_device_event            (HelperAgentSlotUintCharSizeUint *slot);
+
+    /**
+     * @brief Connect a slot to Helper set prediction hint signal.
+     *
+     * This signal is used to send prediction hint to Helper ISE.
+     *
+     * The prototype of the slot is:
+     * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
+     */
+    Connection signal_connect_set_prediction_hint                   (HelperAgentSlotStringVoid          *slot);
 };
 
 /**  @} */
index 24fa30ee16ee7fefbed90930feeac0819d3f4c96..40959f63ba2c37bc8a3ba0646873925ae3029054 100644 (file)
@@ -668,6 +668,7 @@ const int ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW            = 1125;
 const int ISM_TRANS_CMD_PROCESS_INPUT_DEVICE_EVENT        = 1126;
 const int ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW          = 1127;
 const int ISM_TRANS_CMD_SET_KEYBOARD_MODE                 = 1128;
+const int ISM_TRANS_CMD_SET_PREDICTION_HINT               = 1129;
 
 /* ISE/Panel to IMControl */
 const int ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT          = 1151;