Add commit content API for sending content in IME 04/129204/7
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 15 May 2017 11:12:04 +0000 (20:12 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 6 Jun 2017 23:20:28 +0000 (23:20 +0000)
Change-Id: I7d2d1d6e76d41d46ea594fc0623caf22ea8067d4
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
15 files changed:
ism/demos/isf_layout_efl.cpp
ism/extras/wayland_immodule/wayland_imcontext.c
ism/modules/frontend/scim_socket_frontend.cpp
ism/modules/frontend/scim_socket_frontend.h
ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp
ism/src/isf_info_manager.cpp
ism/src/isf_info_manager.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 2e082a2..0905e16 100644 (file)
@@ -219,6 +219,14 @@ static void entry_cursor_changed_cb (void *data, Evas_Object *obj, void *event_i
     LOGD ("cursor pos : %d\n", elm_entry_cursor_pos_get (obj));
 }
 
+static void _commit_content_cb (void *data, Ecore_IMF_Context *ctx, void *event)
+{
+    Ecore_IMF_Event_Commit_Content *commit_content = (Ecore_IMF_Event_Commit_Content *)event;
+    if (!commit_content) return;
+
+    LOGD ("content : %s, description : %s, mime types : %s\n", commit_content->content_uri, commit_content->description, commit_content->mime_types);
+}
+
 static Evas_Object *_create_ef_layout (Evas_Object *parent, const char *label, const char *guide_text, Elm_Input_Panel_Layout layout, int layout_variation = 0)
 {
     Evas_Object *en;
@@ -237,6 +245,8 @@ static Evas_Object *_create_ef_layout (Evas_Object *parent, const char *label, c
     ic = (Ecore_IMF_Context *)elm_entry_imf_context_get (en);
 
     if (ic != NULL) {
+        ecore_imf_context_event_callback_add (ic, ECORE_IMF_CALLBACK_COMMIT_CONTENT, _commit_content_cb, NULL);
+
         ecore_imf_context_input_panel_event_callback_add (ic, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_cb, NULL);
         ecore_imf_context_input_panel_event_callback_add (ic, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, _input_panel_resize_cb, NULL);
         ecore_imf_context_input_panel_event_callback_add (ic, ECORE_IMF_INPUT_PANEL_SHIFT_MODE_EVENT, _shift_mode_cb, NULL);
index 13a9693..f61d073 100644 (file)
@@ -2141,6 +2141,27 @@ text_input_private_command(void                 *data,
 }
 
 static void
+text_input_commit_content(void                 *data,
+                          struct wl_text_input *text_input EINA_UNUSED,
+                          uint32_t              serial EINA_UNUSED,
+                          const char           *content,
+                          const char           *description,
+                          const char           *mime_types)
+{
+    WaylandIMContext *imcontext = (WaylandIMContext *)data;
+    if (!imcontext || !imcontext->ctx) return;
+
+    Ecore_IMF_Event_Commit_Content ev;
+    ev.content_uri = content;
+    ev.mime_types = mime_types;
+    ev.description = description;
+
+    SECURE_LOGD("commit content : %s, description : %s, mime types : %s\n", content, description, mime_types);
+
+    ecore_imf_context_event_callback_call(imcontext->ctx, ECORE_IMF_CALLBACK_COMMIT_CONTENT, (void *)&ev);
+}
+
+static void
 text_input_input_panel_data(void                 *data,
                             struct wl_text_input *text_input EINA_UNUSED,
                             uint32_t              serial EINA_UNUSED,
@@ -2398,7 +2419,8 @@ static const struct wl_text_input_listener text_input_listener =
     text_input_get_surrounding_text,
     text_input_filter_key_event_done,
     text_input_hide_permission,
-    text_input_recapture_string
+    text_input_recapture_string,
+    text_input_commit_content
     //
 };
 
index 83da5e9..6edf02f 100644 (file)
@@ -794,6 +794,17 @@ SocketFrontEnd::send_private_command (int id, const String &command)
 }
 
 void
+SocketFrontEnd::commit_content (int id, const String &content, const String &description, const String &mime_types)
+{
+    if (m_current_instance == id) {
+        m_send_trans.put_command (SCIM_TRANS_CMD_COMMIT_CONTENT);
+        m_temp_trans.put_data (content);
+        m_temp_trans.put_data (description);
+        m_temp_trans.put_data (mime_types);
+    }
+}
+
+void
 SocketFrontEnd::expand_candidate (int id)
 {
     if (m_current_instance == id)
index 17941b8..f2d1641 100644 (file)
@@ -161,6 +161,7 @@ protected:
                                           ISF_CANDIDATE_MODE_T          mode);
 
     virtual void send_private_command    (int id, const String &command);
+    virtual void commit_content          (int id, const String &content, const String &description, const String &mime_types);
 
 public:
     virtual void init (int argc, char **argv);
index c061a3e..e2389bc 100644 (file)
@@ -1505,6 +1505,21 @@ private:
         m_send_trans.write_to_socket(socket_client);
     }
 
+    void commit_content(int client, uint32 focused_context, String content, String description, String mime_types) {
+        LOGD ("client id:%d\n", client);
+
+        Socket socket_client(client);
+        lock();
+        m_send_trans.clear();
+        m_send_trans.put_command(SCIM_TRANS_CMD_REPLY);
+        m_send_trans.put_data(focused_context);
+        m_send_trans.put_command(SCIM_TRANS_CMD_COMMIT_CONTENT);
+        m_send_trans.put_data(content);
+        m_send_trans.put_data(description);
+        m_send_trans.put_data(mime_types);
+        m_send_trans.write_to_socket(socket_client);
+    }
+
     void helper_all_update_spot_location(int client, uint32 context_id, String uuid, int x, int y) {
         LOGD ("client id:%d\n", client);
 
@@ -2791,6 +2806,18 @@ private:
                 //FIXME: useless
                 //} else if (cmd == ISM_TRANS_CMD_UPDATE_ISE_EXIT) {
                 //    m_info_manager->UPDATE_ISE_EXIT(client_id);
+                } else if (cmd == SCIM_TRANS_CMD_COMMIT_CONTENT) {
+                    String content;
+                    String description;
+                    String mime_types;
+
+                    if (m_recv_trans.get_data(content) &&
+                        m_recv_trans.get_data(description) &&
+                        m_recv_trans.get_data(mime_types)) {
+                        m_info_manager->socket_helper_commit_content(client_id, content, description, mime_types);
+                    } else {
+                        LOGW ("wrong format of transaction\n");
+                    }
                 } else if (cmd == ISM_TRANS_CMD_PROCESS_KEY_EVENT_DONE) {
                     KeyEvent key;
                     uint32 ret;
index 97d7193..a97340a 100644 (file)
@@ -3171,6 +3171,13 @@ public:
     }
 
     void
+    commit_content (int id, uint32 context_id, const String& content, const String& description, const String& mime_types) {
+        LOGD ("client id:%d", id);
+        if (_focused_ic && _focused_ic->im_ctx)
+            wl_input_method_context_commit_content (_focused_ic->im_ctx, _focused_ic->serial, content.c_str (), description.c_str (), mime_types.c_str ());
+    }
+
+    void
     hide_helper_ise (int id, uint32 context_id)
     {
         LOGD ("client id:%d", id);
index 1fc4548..5f90f5a 100644 (file)
@@ -3806,6 +3806,19 @@ client context helpers: %d, helpers uuid count: %d",
             m_panel_agent_manager.send_private_command (focused_client, focused_context, command);
         }
     }
+    //SCIM_TRANS_CMD_COMMIT_CONTENT
+    void socket_helper_commit_content (int client, String content, String description, String mime_types) {
+        SCIM_DEBUG_MAIN (4) << __FUNCTION__ << " (" << client << ")\n";
+        LOGD ("");
+        int     focused_client;
+        uint32  focused_context;
+        String  focused_uuid = get_focused_context (focused_client, focused_context);
+        ClientInfo client_info = socket_get_client_info (focused_client);
+
+        if (client_info.type == FRONTEND_CLIENT) {
+            m_panel_agent_manager.commit_content (focused_client, focused_context, content, description, mime_types);
+        }
+    }
     //ISM_TRANS_CMD_UPDATE_ISE_EXIT
     //void UPDATE_ISE_EXIT (int client) {
     //    LOGD ("");
@@ -5255,6 +5268,12 @@ void InfoManager::socket_helper_send_private_command (int client, String command
     m_impl->socket_helper_send_private_command (client, command);
 }
 
+//SCIM_TRANS_CMD_COMMIT_CONTENT
+void InfoManager::socket_helper_commit_content (int client, String content, String description, String mime_types)
+{
+    m_impl->socket_helper_commit_content (client, content, description, mime_types);
+}
+
 //ISM_TRANS_CMD_UPDATE_ISE_EXIT
 //void InfoManager::UPDATE_ISE_EXIT (int client)
 //{
index 483a337..5f2cf1a 100644 (file)
@@ -946,6 +946,9 @@ public:
     //SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND
     void socket_helper_send_private_command (int client, String command);
 
+    //SCIM_TRANS_CMD_SEND_COMMIT_CONTENT
+    void socket_helper_commit_content (int client, String content, String description, String mime_types);
+
     //ISM_TRANS_CMD_UPDATE_ISE_EXIT
     //void UPDATE_ISE_EXIT (int client);
 
index fa2da75..dbc34c3 100644 (file)
@@ -475,6 +475,13 @@ void PanelAgentBase::send_private_command (int client, uint32 context, const Str
     LOGW ("not implemented for %s", m_name.c_str ());
 }
 
+//socket_helper_commit_content
+//SCIM_TRANS_CMD_COMMIT_CONTENT
+void PanelAgentBase::commit_content (int client, uint32 context, const String& content, const String& description, const String& mime_types)
+{
+    LOGW ("not implemented for %s", m_name.c_str ());
+}
+
 //SCIM_TRANS_CMD_UPDATE_SPOT_LOCATION
 void PanelAgentBase::helper_all_update_spot_location (int client, uint32 context, String uuid, int x, int y)
 {
index 880a0f4..b7bf445 100644 (file)
@@ -971,6 +971,14 @@ public:
     */
     virtual void send_fail_reply (int client);
 
+    /**
+     * @brief commit_content.
+     *
+     * @param
+     *
+     * @return none.
+     */
+    virtual void commit_content (int client, uint32 context, const String& content, const String& description, const String& mime_types);
 };
 
 /**  @} */
index e92c409..1b4dc5d 100644 (file)
@@ -765,6 +765,14 @@ void PanelAgentManager::send_private_command (int id, uint32 context_id, String
         _p->send_private_command (id, context_id, command);
 }
 
+void PanelAgentManager::commit_content (int id, uint32 context_id, String content, String description, String mime_types)
+{
+    PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
+
+    if (!_p.null ())
+        _p->commit_content (id, context_id, content, description, mime_types);
+}
+
 void PanelAgentManager::helper_all_update_spot_location (int id, uint32 context_id, String uuid, int x, int y)
 {
     PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
index eec8799..5085c06 100644 (file)
@@ -339,6 +339,7 @@ public:
     void socket_helper_set_selection (int client, uint32 context_id, uint32 start, uint32 end);
     void update_ise_input_context (int    focused_client, uint32 focused_context, uint32 type, uint32 value);
     void send_private_command (int    focused_client, uint32 focused_context, String command);
+    void commit_content (int    focused_client, uint32 focused_context, String content, String description, String mime_types);
     void helper_all_update_spot_location (int client_id, uint32 context_id, String uuid, int x, int y);
     void helper_all_update_cursor_position (int client_id, uint32 context_id, String uuid, int cursor_pos);
     void helper_all_update_screen (int client_id, uint32 context_id, String uuid, int screen);
index b6514a6..4b9cea7 100644 (file)
@@ -486,6 +486,16 @@ public:
     }
 
     void
+    slot_commit_content (IMEngineInstanceBase *si,
+                         const String &content,
+                         const String &description,
+                         const String &mime_types)
+    {
+        LOGD ("");
+        thiz->commit_content (content, description, mime_types);
+    }
+
+    void
     attach_instance ()
     {
         si->signal_connect_show_preedit_string (
@@ -2222,6 +2232,27 @@ HelperAgent::send_private_command (const String &command) const
 }
 
 /**
+ * @brief Commit content to an application.
+ *
+ * @param content The content sent from IME.
+ */
+void
+HelperAgent::commit_content (const String &content, const String &description, const String &mime_types) const
+{
+    LOGD ("");
+    if (m_impl->socket_active.is_connected ()) {
+        m_impl->send.clear ();
+        m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
+        m_impl->send.put_data (m_impl->magic_active);
+        m_impl->send.put_command (SCIM_TRANS_CMD_COMMIT_CONTENT);
+        m_impl->send.put_data (content);
+        m_impl->send.put_data (description);
+        m_impl->send.put_data (mime_types);
+        m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
+    }
+}
+
+/**
  * @brief Request to get uuid list of all keyboard ISEs.
  *
  * @param uuid The helper ISE UUID.
index a765fef..564210c 100644 (file)
@@ -753,6 +753,15 @@ public:
     void send_private_command     (const String                &command) const;
 
     /**
+     * @brief Commit content to an application
+     *
+     * @param content The content sent from IME.
+     */
+    void commit_content           (const String                &content,
+                                   const String                &description,
+                                   const String                &mime_types) const;
+
+    /**
      * @brief Request panel to hide ISE, since in some cases ISE cannot hide itself (e.g. WAYLAND)
      */
     void request_ise_hide         (void) const;
index 40959f6..8f24dcb 100644 (file)
@@ -532,6 +532,7 @@ const int ISM_TRANS_CMD_TRANSACTION_CONTINUE              = 173;
 const int SCIM_TRANS_CMD_GET_SELECTION                    = 174;
 const int SCIM_TRANS_CMD_SET_SELECTION                    = 175;
 const int SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND             = 176;
+const int SCIM_TRANS_CMD_COMMIT_CONTENT                   = 177;
 
 // Socket IMEngine to Socket FrontEnd
 const int SCIM_TRANS_CMD_NEW_INSTANCE                     = 200;