Added mime_type_accept_set interface 00/131500/5
authorInHong Han <inhong1.han@samsung.com>
Wed, 17 May 2017 01:52:58 +0000 (10:52 +0900)
committerInHong Han <inhong1.han@samsung.com>
Fri, 9 Jun 2017 08:34:04 +0000 (17:34 +0900)
Change-Id: Id042db30ff562916d43b066318a249a72ae724cc

20 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_context.h
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 f61d073..a0ab805 100644 (file)
@@ -216,6 +216,7 @@ struct _WaylandIMContext
 
     Eina_Bool has_conformant;
     char *prediction_hint;
+    char *mime_type;
     //
 };
 
@@ -1654,6 +1655,9 @@ show_input_panel(Ecore_IMF_Context *ctx)
 
     set_autocapital (ctx);
 
+    if (strlen(imcontext->mime_type) > 0)
+        wl_text_input_set_mime_type(imcontext->text_input, imcontext->mime_type);
+
     SECURE_LOGD ("ctx : %p, layout : %d, layout variation : %d\n", ctx,
             layout, layout_variation);
     SECURE_LOGD ("language : %d, cursor position : %d\n",
@@ -2635,6 +2639,11 @@ wayland_im_context_del (Ecore_IMF_Context *ctx)
         imcontext->prediction_hint = NULL;
     }
 
+    if (imcontext->mime_type) {
+        free (imcontext->mime_type);
+        imcontext->mime_type = NULL;
+    }
+
     if (imcontext->text_input)
         wl_text_input_destroy (imcontext->text_input);
 
@@ -2691,6 +2700,9 @@ wayland_im_context_focus_in(Ecore_IMF_Context *ctx)
 
         if (imcontext->prediction_hint)
             wl_text_input_prediction_hint(imcontext->text_input, imcontext->prediction_hint);
+
+        if (strlen(imcontext->mime_type) > 0)
+            wl_text_input_set_mime_type(imcontext->text_input, imcontext->mime_type);
     }
 
     if (ecore_imf_context_input_panel_enabled_get(ctx))
@@ -3439,6 +3451,20 @@ wayland_im_context_prediction_hint_set (Ecore_IMF_Context *ctx, const char *pred
     }
 }
 
+void
+wayland_im_context_mime_type_accept_set (Ecore_IMF_Context *ctx, const char *mime_type)
+{
+    WaylandIMContext *imcontext = (WaylandIMContext *)ecore_imf_context_data_get(ctx);
+    if (!imcontext) return;
+
+    imcontext->mime_type = strdup(mime_type);
+
+    if (imcontext->input && imcontext->text_input && (strlen(mime_type) > 0)) {
+        LOGD ("ctx : %p, mime_type : %s\n", ctx, imcontext->mime_type);
+        wl_text_input_set_mime_type(imcontext->text_input, imcontext->mime_type);
+    }
+}
+
 WaylandIMContext *wayland_im_context_new (struct wl_text_input_manager *text_input_manager)
 {
     WaylandIMContext *context = calloc(1, sizeof(WaylandIMContext));
index 19bfcec..ffd3c16 100644 (file)
@@ -125,6 +125,9 @@ 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);
 
+void
+wayland_im_context_mime_type_accept_set (Ecore_IMF_Context *ctx, const char *mime_type);
+
 WaylandIMContext *wayland_im_context_new        (struct wl_text_input_manager *text_input_manager);
 
 extern int _ecore_imf_wayland_log_dom;
index ebdbb66..3d7b744 100644 (file)
@@ -80,7 +80,8 @@ static Ecore_IMF_Context_Class wayland_imf_class =
     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_prediction_hint_set     /* prediction_hint_set */
+    wayland_im_context_prediction_hint_set,    /* prediction_hint_set */
+    wayland_im_context_mime_type_accept_set    /* mime_type_accept_set */
 };
 
 static struct wl_text_input_manager *text_input_manager = NULL;
index e2389bc..2e42ed7 100644 (file)
@@ -814,6 +814,19 @@ private:
         m_send_trans.write_to_socket(client_socket);
     }
 
+    void set_helper_mime_type (int client, uint32 context, const String& uuid, String& mime_type) {
+        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_MIME_TYPE);
+        m_send_trans.put_data(mime_type);
+        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 2703834..4ff2119 100644 (file)
@@ -154,6 +154,7 @@ int get_panel_client_id ();
 WSCContextISF *get_focused_ic ();
 
 void context_scim_imdata_get (WSCContextISF *wsc_ctx, void* data, int* length);
+void context_scim_mime_type_get (WSCContextISF *wsc_ctx, const char *mime_types);
 
 void isf_wsc_context_add (WSCContextISF *wsc_ctx);
 void isf_wsc_context_del (WSCContextISF *wsc_ctx);
index 0d040d0..72d0579 100644 (file)
@@ -218,6 +218,12 @@ int _isf_wsc_context_input_panel_prediction_hint_set (int context, const char *p
     g_info_manager->set_prediction_hint (get_panel_client_id (), String (prediction_hint));
     return 0;
 }
+
+int _isf_wsc_context_input_panel_mime_type_accept_set (int context, const char *mime_type)
+{
+    g_info_manager->set_ise_mime_type (get_panel_client_id (), String (mime_type));
+    return 0;
+}
 /*
 vi:ts=4:expandtab:nowrap
 */
index 4a85f4b..6192683 100644 (file)
@@ -65,6 +65,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);
+    int _isf_wsc_context_input_panel_mime_type_accept_set (int context, const char *mime_type);
 
 #ifdef __cplusplus
 }
index efbfd1f..18fa620 100644 (file)
@@ -101,6 +101,7 @@ void isf_wsc_context_input_panel_show (WSCContextISF* wsc_ctx)
     int length = -1;
     void *packet = NULL;
     char imdata[1024] = {0};
+    char mime_type[1024] = {0};
     bool input_panel_show = false;
     input_panel_ctx = wsc_ctx;
     Ise_Context iseContext;
@@ -147,6 +148,9 @@ void isf_wsc_context_input_panel_show (WSCContextISF* wsc_ctx)
     /* set the size of imdata */
     context_scim_imdata_get (wsc_ctx, (void *)imdata, &iseContext.imdata_size);
 
+    /* set the length of mime type */
+    context_scim_mime_type_get (wsc_ctx, mime_type);
+
     /* set the cursor position of the editable widget */
     wsc_context_surrounding_get (wsc_ctx, NULL, &iseContext.cursor_pos);
 
@@ -166,6 +170,7 @@ void isf_wsc_context_input_panel_show (WSCContextISF* wsc_ctx)
     /* calculate packet size */
     length = sizeof (iseContext);
     length += iseContext.imdata_size;
+    length += strlen (mime_type);
 
     /* create packet */
     packet = calloc (1, length);
@@ -174,6 +179,7 @@ void isf_wsc_context_input_panel_show (WSCContextISF* wsc_ctx)
 
     memcpy (packet, (void *)&iseContext, sizeof (iseContext));
     memcpy ((void *)((char *)packet + sizeof (iseContext)), (void *)imdata, iseContext.imdata_size);
+    memcpy ((void *)((char *)packet + sizeof (iseContext) + iseContext.imdata_size), mime_type, strlen (mime_type));
 
     int context_id = _get_context_id (wsc_ctx);
 
@@ -278,3 +284,8 @@ void isf_wsc_context_input_panel_prediction_hint_set (WSCContextISF *ctx, const
 {
     _isf_wsc_context_input_panel_prediction_hint_set (_get_context_id(ctx), prediction_hint);
 }
+
+void isf_wsc_context_input_panel_mime_type_accept_set (WSCContextISF *ctx, const char *mime_type)
+{
+    _isf_wsc_context_input_panel_mime_type_accept_set (_get_context_id(ctx), mime_type);
+}
index 878c78f..5a742f7 100644 (file)
@@ -55,6 +55,7 @@ extern "C"
     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);
+    void isf_wsc_context_input_panel_mime_type_accept_set (WSCContextISF *ctx, const char *mime_type);
 
 #ifdef __cplusplus
 }
index d95544f..015d323 100644 (file)
@@ -87,6 +87,7 @@ struct _WSCContextISFImpl {
     Ecore_IMF_Input_Hints    input_hint;
     Ecore_IMF_BiDi_Direction bidi_direction;
     Ecore_IMF_Input_Panel_Layout panel_layout;
+    String                   mime_type;
     void                    *imdata;
     int                      imdata_size;
     int                      preedit_caret;
@@ -468,13 +469,29 @@ _wsc_im_ctx_captial_mode (void *data, struct wl_input_method_context *im_ctx, ui
 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;
+
+    LOGD ("im_context = %p, prediction hint = %s\n", im_ctx, prediction_hint);
     if (!wsc_ctx) return;
 
     isf_wsc_context_input_panel_prediction_hint_set (wsc_ctx, prediction_hint);
 }
 
+static void
+_wsc_im_ctx_mime_type (void *data, struct wl_input_method_context *im_ctx, const char *mime_type)
+{
+    WSCContextISF *wsc_ctx = (WSCContextISF*)data;
+
+    LOGD ("im_context = %p, mime_type = %s\n", im_ctx, mime_type);
+    if (!wsc_ctx) return;
+
+    if (wsc_ctx->impl) {
+        wsc_ctx->impl->mime_type = strdup (mime_type);
+    }
+
+    isf_wsc_context_input_panel_mime_type_accept_set (wsc_ctx, mime_type);
+}
+
 static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_reset,
      _wsc_im_ctx_content_type,
@@ -489,7 +506,8 @@ static const struct wl_input_method_context_listener wsc_im_context_listener = {
      _wsc_im_ctx_process_input_device_event,
      _wsc_im_ctx_filter_key_event,
      _wsc_im_ctx_captial_mode,
-     _wsc_im_ctx_prediction_hint
+     _wsc_im_ctx_prediction_hint,
+     _wsc_im_ctx_mime_type
 };
 
 #if ENABLE_GRAB_KEYBOARD
@@ -997,6 +1015,7 @@ delete_ic_impl (WSCContextISFImpl *impl)
             rec->imdata_size = 0;
             rec->parent = 0;
             rec->client_window = 0;
+            rec->mime_type = String ();
             rec->surrounding_text = WideString ();
             rec->preedit_string = WideString ();
             rec->preedit_attrlist.clear ();
@@ -1064,6 +1083,19 @@ void context_scim_imdata_get (WSCContextISF *wsc_ctx, void* data, int* length)
     }
 }
 
+void context_scim_mime_type_get (WSCContextISF *wsc_ctx, const char *mime_type)
+{
+    WSCContextISF* context_scim = wsc_ctx;
+    LOGD ("");
+    SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
+
+    if (context_scim && context_scim->impl) {
+        if (!(context_scim->impl->mime_type).empty ())
+            memcpy ((void *)mime_type ,(context_scim->impl->mime_type).c_str (),
+                strlen ((context_scim->impl->mime_type).c_str ()));
+    }
+}
+
 static char *
 insert_text (const char *text, uint32_t offset, const char *insert)
 {
index 5f90f5a..12e5c5b 100644 (file)
@@ -1325,6 +1325,23 @@ public:
         return false;
     }
 
+    bool set_helper_mime_type (const String& uuid, String mime_type) {
+        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_MIME_TYPE message");
+            m_panel_agent_manager.set_helper_mime_type (it->second.id, ctx, uuid, mime_type);
+            return true;
+        }
+
+        return false;
+    }
+
     //ISM_TRANS_CMD_SHOW_ISF_CONTROL
     void show_isf_panel (int client_id) {
         LOGD ("");
@@ -2012,6 +2029,14 @@ public:
             set_helper_prediction_hint (m_current_helper_uuid, prediction_hint);
     }
 
+    //ISM_TRANS_CMD_SET_MIME_TYPE
+    void set_ise_mime_type (int client_id, String mime_type) {
+        SCIM_DEBUG_MAIN (4) << "InfoManager::set_mime_type ()\n";
+        LOGD ("");
+        if (TOOLBAR_HELPER_MODE == m_current_toolbar_mode || m_current_helper_option & ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT)
+            set_helper_mime_type (m_current_helper_uuid, mime_type);
+    }
+
     //ISM_TRANS_CMD_EXPAND_CANDIDATE
     void expand_candidate () {
         LOGD ("");
@@ -4814,6 +4839,12 @@ void InfoManager::set_prediction_hint (int client_id, String prediction_hint)
     m_impl->set_prediction_hint (client_id, prediction_hint);
 }
 
+//ISM_TRANS_CMD_SET_MIME_TYPE
+void InfoManager::set_ise_mime_type (int client_id, String mime_type)
+{
+    m_impl->set_ise_mime_type (client_id, mime_type);
+}
+
 //ISM_TRANS_CMD_EXPAND_CANDIDATE
 void InfoManager::expand_candidate ()
 {
index 5f2cf1a..f2dd1bc 100644 (file)
@@ -738,6 +738,9 @@ public:
     //ISM_TRANS_CMD_SET_PREDICTION_HINT
     void set_prediction_hint (int client_id, String prediction_hint);
 
+    //ISM_TRANS_CMD_SET_MIME_TYPE
+    void set_ise_mime_type (int client_id, String mime_type);
+
     //ISM_TRANS_CMD_EXPAND_CANDIDATE
     void expand_candidate ();
 
index d74c668..c75d7d6 100644 (file)
@@ -713,11 +713,23 @@ public:
     MessageItemSetPredictionHint() {}
     virtual ~MessageItemSetPredictionHint() {}
 
-    String& get_message_ptr() { return m_prediction_hint; }
+    String& get_message_ref() { return m_prediction_hint; }
 protected:
     String m_prediction_hint;
 };
 
+/* ISM_TRANS_CMD_SET_MIME_TYPE */
+class MessageItemSetMimeType : public MessageItemHelper
+{
+public:
+    MessageItemSetMimeType() {}
+    virtual ~MessageItemSetMimeType() {}
+
+    String& get_mime_type_ref() { return m_mime_type; }
+protected:
+    String m_mime_type;
+};
+
 template <typename T>
 inline T*
 alloc_message() /* We could use memory pool in the future for performance enhancement */
@@ -1657,7 +1669,7 @@ public:
                     MessageItemSetPredictionHint *message = alloc_message<MessageItemSetPredictionHint>();
                     if (message) {
                         message->get_command_ref() = cmd;
-                        if (transaction.get_data(message->get_message_ptr())) {
+                        if (transaction.get_data(message->get_message_ref())) {
                             m_list_messages.push_back(message);
                         } else {
                             LOGW("wrong format of transaction\n");
@@ -1666,6 +1678,20 @@ public:
                     }
                     break;
                 }
+                case ISM_TRANS_CMD_SET_MIME_TYPE:
+                {
+                    MessageItemSetMimeType *message = alloc_message<MessageItemSetMimeType>();
+                    if (message) {
+                        message->get_command_ref() = cmd;
+                        if (transaction.get_data(message->get_mime_type_ref())) {
+                            m_list_messages.push_back(message);
+                        } else {
+                            LOGW("wrong format of transaction\n");
+                            dealloc_message<MessageItemSetMimeType>(message);
+                        }
+                    }
+                    break;
+                }
             }
         }
 
index dbc34c3..5d14a87 100644 (file)
@@ -316,6 +316,11 @@ void PanelAgentBase::set_helper_prediction_hint (int client, uint32 context, con
     LOGW ("not implemented for %s", m_name.c_str ());
 }
 
+void PanelAgentBase::set_helper_mime_type (int client, uint32 context, const String& uuid, String& mime_type)
+{
+    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 b7bf445..2d262be 100644 (file)
@@ -494,6 +494,15 @@ public:
     virtual void set_helper_prediction_hint (int client, uint32 context, const String& uuid, String& prediction_hint);
 
     /**
+     * @brief set_helper_mime_type.
+     *
+     * @param
+     *
+     * @return none.
+     */
+    virtual void set_helper_mime_type (int client, uint32 context, const String& uuid, String& mime_type);
+
+    /**
      * @brief process_key_event.
      *
      * @param
index 1b4dc5d..d6e1978 100644 (file)
@@ -514,6 +514,14 @@ void PanelAgentManager::set_helper_prediction_hint (int id, uint32 context_id, c
         _p->set_helper_prediction_hint (id, context_id, uuid, prediction_hint);
 }
 
+void PanelAgentManager::set_helper_mime_type (int id, uint32 context_id, const String& uuid, String& mime_type)
+{
+    PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
+
+    if (!_p.null ())
+        _p->set_helper_mime_type (id, context_id, uuid, mime_type);
+}
+
 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 5085c06..506c980 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_mime_type (int client, uint32 context, const String& uuid, String& mime_type);
     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 4b9cea7..ddaadd7 100644 (file)
@@ -224,6 +224,7 @@ public:
     HelperAgentSignalUintVoid           signal_check_option_window;
     HelperAgentSignalUintCharSizeUint   signal_process_input_device_event;
     HelperAgentSignalStringVoid         signal_set_prediction_hint;
+    HelperAgentSignalStringVoid         signal_set_mime_type;
 
 public:
     HelperAgentImpl (HelperAgent* thiz) : magic(0), magic_active(0), timeout(-1), focused_ic ((uint32) -1), thiz (thiz),
@@ -1457,7 +1458,15 @@ HelperAgent::handle_message (MessageItem *message)
         case ISM_TRANS_CMD_SET_PREDICTION_HINT:
         {
             MessageItemSetPredictionHint *subclass = static_cast<MessageItemSetPredictionHint*>(message);
-            m_impl->signal_set_prediction_hint (this, subclass->get_message_ptr());
+            m_impl->signal_set_prediction_hint (this, subclass->get_message_ref());
+            break;
+        }
+        case ISM_TRANS_CMD_SET_MIME_TYPE:
+        {
+            MessageItemSetMimeType *subclass = static_cast<MessageItemSetMimeType*>(message);
+            if (m_impl->ise_show_flag || m_impl->hw_keyboard_mode) {
+                m_impl->signal_set_mime_type (this, subclass->get_mime_type_ref());
+            }
             break;
         }
         default:
@@ -3513,6 +3522,20 @@ HelperAgent::signal_connect_set_prediction_hint (HelperAgentSlotStringVoid *slot
     return m_impl->signal_set_prediction_hint.connect (slot);
 }
 
+/**
+ * @brief Connect a slot to Helper set mime type signal.
+ *
+ * This signal is used to send mime type to Helper ISE.
+ *
+ * The prototype of the slot is:
+ * void set_mime_type (const HelperAgent *agent, char *mime_type);
+ */
+Connection
+HelperAgent::signal_connect_set_mime_type (HelperAgentSlotStringVoid *slot)
+{
+    return m_impl->signal_set_mime_type.connect (slot);
+}
+
 } /* namespace scim */
 
 /*
index 564210c..ec3dd70 100644 (file)
@@ -1388,6 +1388,16 @@ public:
      * void set_prediction_hint (const HelperAgent *agent, char *prediction_hint);
      */
     Connection signal_connect_set_prediction_hint                   (HelperAgentSlotStringVoid          *slot);
+
+    /**
+     * @brief Connect a slot to Helper set mime type signal.
+     *
+     * This signal is used to send mime type to Helper ISE.
+     *
+     * The prototype of the slot is:
+     * void set_mime_type (const HelperAgent *agent, char *mime_type);
+     */
+    Connection signal_connect_set_mime_type                         (HelperAgentSlotStringVoid          *slot);
 };
 
 /**  @} */
index 8f24dcb..3b65925 100644 (file)
@@ -670,6 +670,7 @@ 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;
+const int ISM_TRANS_CMD_SET_MIME_TYPE                     = 1130;
 
 /* ISE/Panel to IMControl */
 const int ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT          = 1151;