Fix issue not to launch IME setting application as group mode 06/245306/4
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 7 Oct 2020 03:15:51 +0000 (12:15 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 8 Oct 2020 04:44:57 +0000 (13:44 +0900)
Change-Id: Ia9321fc64a8465d8670326632f49b39c65a1af11
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
ism/extras/efl_panel/isf_panel_efl.cpp
ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
ism/src/Makefile.am
ism/src/isf_control.cpp
ism/src/isf_control.h
ism/src/isf_imcontrol_client.cpp
ism/src/isf_imcontrol_client.h
ism/src/isf_info_manager.cpp
ism/src/isf_info_manager.h
ism/src/scim_trans_commands.h

index 17af469..39155e0 100644 (file)
@@ -254,6 +254,7 @@ static void       slot_start_default_ise               (void);
 static void       slot_stop_default_ise                (bool is_exist);
 static void       slot_run_helper                      (const String &uuid, const String &config, const String &display);
 static bool       slot_launch_option_application       (String ime_appid);
+static bool       slot_get_ise_setting_appid           (String ime_appid, String &ime_setting_appid);
 
 #if ENABLE_REMOTE_INPUT
 static void       slot_send_remote_input_message       (const String &msg, bool len);
@@ -4307,6 +4308,7 @@ static bool initialize_panel_agent (const ConfigPointer& config, const String &d
 
     _info_manager->signal_connect_run_helper                 (slot (slot_run_helper));
     _info_manager->signal_connect_launch_option_application  (slot (slot_launch_option_application));
+    _info_manager->signal_connect_get_ise_setting_appid      (slot (slot_get_ise_setting_appid));
 
     LOGD ("initializing panel agent succeeded");
 
@@ -6502,9 +6504,9 @@ static bool app_control_launch (const char *app_id)
     app_control_destroy (app_control);
 
     if (ret != APP_CONTROL_ERROR_NONE) {
-        LOGW ("Failed to launch IME (%s)", app_id);
+        LOGW ("Failed to launch IME. appid(%s). reason(%s)", app_id, get_error_message(ret));
     } else {
-        LOGD ("Succeeded to launch IME (%s)", app_id);
+        LOGD ("Succeeded to launch IME. appid(%s)", app_id);
     }
 
     return (ret == APP_CONTROL_ERROR_NONE);
@@ -6617,6 +6619,14 @@ static bool slot_launch_option_application (String ime_appid)
     return false;
 }
 
+static bool slot_get_ise_setting_appid (String ime_appid, String &ime_setting_appid)
+{
+    ime_setting_appid = isf_pkg_get_setting_app (ime_appid);
+
+    LOGD ("IME appid : %s, IME setting app ID : %s", ime_appid.c_str(), ime_setting_appid.c_str());
+    return ime_setting_appid.length () > 0 ? true : false;
+}
+
 //////////////////////////////////////////////////////////////////////
 // End of PanelAgent-Functions
 //////////////////////////////////////////////////////////////////////
index 7279408..3474f4c 100644 (file)
@@ -3202,6 +3202,23 @@ private:
                         LOGW ("Access denied to check helper ise enabled");
                         send_fail_reply (client_id);
                     }
+                } else if (cmd == ISM_TRANS_CMD_GET_ISE_SETTING_APPID) {
+                    if (m_info_manager->check_privilege_by_sockfd(client_id, IMEMANAGER_PRIVILEGE)) {
+                        String ime_setting_appid;
+                        m_info_manager->get_ise_setting_appid(client_id, ime_setting_appid);
+
+                        Transaction trans;
+                        Socket client_socket(client_id);
+                        trans.clear();
+                        trans.put_command(SCIM_TRANS_CMD_REPLY);
+                        trans.put_command(SCIM_TRANS_CMD_OK);
+                        trans.put_data(ime_setting_appid);
+                        trans.write_to_socket(client_socket);
+                    }
+                    else {
+                        LOGW ("Access denied to get ise setting appid");
+                        send_fail_reply (client_id);
+                    }
                 } else if (cmd == ISM_TRANS_CMD_GET_RECENT_ISE_GEOMETRY) {
                     uint32 angle;
 
index 92422d1..96e2b28 100644 (file)
@@ -260,7 +260,8 @@ lib@ISF_CONTROL@_la_SOURCES = \
 
 lib@ISF_CONTROL@_la_CXXFLAGS = @EINA_CFLAGS@ \
                           @DLOG_CFLAGS@ \
-                          @VCONF_CFLAGS@
+                          @VCONF_CFLAGS@ \
+                          @APP_CONTROL_CFLAGS@
 
 lib@ISF_CONTROL@_la_LDFLAGS  = -version-info $(SCIM_CURRENT):$(SCIM_REVISION):$(SCIM_AGE) \
                           -export-dynamic \
@@ -268,6 +269,7 @@ lib@ISF_CONTROL@_la_LDFLAGS  = -version-info $(SCIM_CURRENT):$(SCIM_REVISION):$(
                           @EINA_LIBS@ \
                           @DLOG_LIBS@ \
                           @VCONF_LIBS@ \
+                          @APP_CONTROL_LIBS@ \
                           -lstdc++
 
 lib@ISF_CONTROL@_la_LIBADD   = libltdlc.la libprofile.la
index 877a58f..af50ebc 100644 (file)
@@ -28,6 +28,7 @@
 #define Uses_SCIM_COMPOSE_KEY
 #define Uses_SCIM_PANEL_AGENT
 
+#include <app_control.h>
 #include <string.h>
 #include "scim.h"
 #include "isf_control.h"
 
 using namespace scim;
 
+static bool app_control_launch (const char *app_id, app_control_launch_mode_e mode)
+{
+    app_control_h app_control;
+    int ret;
+
+    ret = app_control_create (&app_control);
+    if (ret != APP_CONTROL_ERROR_NONE) {
+        LOGW ("app_control_create returned %08x", ret);
+        return false;
+    }
+
+    ret = app_control_set_operation (app_control, APP_CONTROL_OPERATION_DEFAULT);
+    if (ret != APP_CONTROL_ERROR_NONE) {
+        LOGW ("app_control_set_operation returned %08x", ret);
+        app_control_destroy (app_control);
+        return false;
+    }
+
+    ret = app_control_set_app_id (app_control, app_id);
+    if (ret != APP_CONTROL_ERROR_NONE) {
+        LOGW ("app_control_set_app_id returned %08x", ret);
+        app_control_destroy (app_control);
+        return false;
+    }
+
+    LOGD("launch mode : %d", mode);
+
+    ret = app_control_set_launch_mode (app_control, mode);
+    if (ret != APP_CONTROL_ERROR_NONE) {
+        LOGW ("app_control_set_launch_mode returned %08x", ret);
+        app_control_destroy (app_control);
+        return false;
+    }
+
+    ret = app_control_send_launch_request(app_control, NULL, NULL);
+    if (ret != APP_CONTROL_ERROR_NONE) {
+        LOGW ("Failed to launch application (%s). reason : %s", app_id, get_error_message(ret));
+    } else {
+        LOGI ("Succeeded to launch application (%s)", app_id);
+    }
+
+    app_control_destroy (app_control);
+
+    return (ret == APP_CONTROL_ERROR_NONE);
+}
 
 EXAPI int isf_control_set_active_ise_by_uuid (const char *uuid)
 {
@@ -262,11 +308,26 @@ EXAPI int isf_control_show_ise_option_window (void)
 {
     IMControlClient imcontrol_client;
     int ret = 0;
+    String ime_setting_appid;
+
     if (!imcontrol_client.open_connection ())
         return -1;
 
     imcontrol_client.prepare ();
-    imcontrol_client.show_ise_option_window ();
+    if (imcontrol_client.get_ise_setting_appid (ime_setting_appid)) {
+        if (app_control_launch (ime_setting_appid.c_str(), APP_CONTROL_LAUNCH_MODE_GROUP)) {
+            LOGI("Succeeded to launch IME setting app : %s", ime_setting_appid.c_str());
+        }
+        else {
+            LOGE("Failed to launch IME setting app : %s", ime_setting_appid.c_str());
+            ret = -1;
+        }
+    }
+    else {
+        LOGD("No setting app ID");
+        imcontrol_client.show_ise_option_window ();
+    }
+
     if (!imcontrol_client.send ())
         ret = -1;
 
index 9301a55..8171e94 100644 (file)
@@ -211,9 +211,13 @@ int isf_control_get_all_ime_info (ime_info_s **info);
  *
  * @since_tizen 2.4
  *
+ * @privlevel public
+ *
+ * @privilege %http://tizen.org/privilege/appmanager.launch
+ *
  * @return 0 on success, otherwise return -1
  *
- * @pre The availibility of IME option can be found using isf_control_get_all_ime_info() and isf_control_get_active_ime() functions.
+ * @pre The availability of IME option can be found using isf_control_get_all_ime_info() and isf_control_get_active_ime() functions.
  */
 int isf_control_open_ime_option_window (void);
 
@@ -226,7 +230,7 @@ int isf_control_open_ime_option_window (void);
  *
  * @return 0 on success, otherwise return -1
  *
- * @pre The availibility of IME option can be found using isf_control_get_all_ime_info() and isf_control_get_active_ime() functions.
+ * @pre The availability of IME option can be found using isf_control_get_all_ime_info() and isf_control_get_active_ime() functions.
  */
 int isf_control_resume_ime_option_window (void);
 
index 6d1e8a8..e0b326c 100644 (file)
@@ -390,6 +390,29 @@ public:
         m_trans.put_command (ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW);
     }
 
+    bool get_ise_setting_appid (String &ime_setting_appid) {
+        int    cmd;
+        String strTemp;
+
+        m_trans.put_command (ISM_TRANS_CMD_GET_ISE_SETTING_APPID);
+        m_trans.write_to_socket (m_socket_imclient2panel);
+        if (!m_trans.read_from_socket (m_socket_imclient2panel, m_socket_timeout)) {
+            std::cerr << __func__ << " read_from_socket() may be timeout \n";
+            return false;
+        }
+
+        if (m_trans.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY &&
+                m_trans.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK &&
+                m_trans.get_data (strTemp)) {
+            ime_setting_appid = strTemp;
+        } else {
+            std::cerr << __func__ << " get_command() or get_data() may fail!!!\n";
+            return false;
+        }
+
+        return true;
+    }
+
     void resume_ise_option_window (void) {
         m_trans.put_command (ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW);
     }
@@ -693,6 +716,11 @@ void IMControlClient::show_ise_option_window (void)
     m_impl->show_ise_option_window ();
 }
 
+bool IMControlClient::get_ise_setting_appid (String &ime_setting_appid)
+{
+    return m_impl->get_ise_setting_appid (ime_setting_appid);
+}
+
 void IMControlClient::resume_ise_option_window (void)
 {
     m_impl->resume_ise_option_window ();
index 6a202df..227f25d 100644 (file)
@@ -56,6 +56,7 @@ public:
     bool set_initial_ise_by_uuid (const char* uuid);
     void show_ise_selector ();
     void show_ise_option_window ();
+    bool get_ise_setting_appid (String &ime_setting_appid);
     void resume_ise_option_window ();
 
     bool get_all_helper_ise_info (HELPER_ISE_INFO &info);
index e980e27..d5282bf 100644 (file)
@@ -185,6 +185,9 @@ InfoManagerSignalIntString2;
 typedef Signal1<bool, String>
 InfoManagerSignalBoolString;
 
+typedef Signal2<bool, String, String&>
+InfoManagerSignalBoolString2;
+
 typedef Signal1<void, bool>
 InfoManagerSignalBool;
 
@@ -410,6 +413,7 @@ class InfoManager::InfoManagerImpl
     InfoManagerSignalIntString2          m_signal_check_privilege_by_sockfd;
 
     InfoManagerSignalBoolString          m_signal_launch_option_application;
+    InfoManagerSignalBoolString2         m_signal_get_ise_setting_appid;
 
     PanelAgentManager                    m_panel_agent_manager;
 
@@ -2105,6 +2109,12 @@ public:
         }
     }
 
+    //ISM_TRANS_CMD_GET_ISE_SETTING_APPID
+    void get_ise_setting_appid (int client_id, _OUT_ String &ime_setting_appid) {
+        SCIM_DEBUG_MAIN (4) << __func__ << "\n";
+        m_signal_get_ise_setting_appid (m_current_helper_uuid, ime_setting_appid);
+    }
+
     //ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW
     void resume_ise_option_window (int client_id) {
         SCIM_DEBUG_MAIN (4) << "InfoManager::resume_ise_option_window ()\n";
@@ -2606,6 +2616,11 @@ public:
         return m_signal_launch_option_application.connect (slot);
     }
 
+    Connection signal_connect_get_ise_setting_appid (InfoManagerSlotBoolString2*                slot)
+    {
+        return m_signal_get_ise_setting_appid.connect (slot);
+    }
+
     Connection signal_connect_get_recent_ise_geometry (InfoManagerSlotIntRect*                slot) {
         return m_signal_get_recent_ise_geometry.connect (slot);
     }
@@ -4825,7 +4840,6 @@ void InfoManager::get_ise_list (int client_id, _OUT_ std::vector<String>& strlis
     m_impl->get_ise_list (client_id, strlist);
 }
 
-
 //ISM_TRANS_CMD_GET_ALL_HELPER_ISE_INFO
 void InfoManager::get_all_helper_ise_info (int client_id, _OUT_ HELPER_ISE_INFO& info)
 {
@@ -4846,7 +4860,6 @@ void InfoManager::show_helper_ise_list (int client_id)
     m_impl->show_helper_ise_list (client_id);
 }
 
-
 //ISM_TRANS_CMD_SHOW_HELPER_ISE_SELECTOR
 //reply SCIM_TRANS_CMD_FAIL or SCIM_TRANS_CMD_OK
 void InfoManager::show_helper_ise_selector (int client_id)
@@ -4969,6 +4982,12 @@ void InfoManager::show_ise_option_window (int client_id)
     m_impl->show_ise_option_window (client_id);
 }
 
+//ISM_TRANS_CMD_GET_ISE_SETTING_APPID
+void InfoManager::get_ise_setting_appid (int client_id, String &ime_setting_appid)
+{
+    m_impl->get_ise_setting_appid (client_id, ime_setting_appid);
+}
+
 //ISM_TRANS_CMD_RESUME_ISE_OPTION_WINDOW
 void InfoManager::resume_ise_option_window (int client_id)
 {
@@ -5977,6 +5996,12 @@ InfoManager::signal_connect_launch_option_application (InfoManagerSlotBoolString
 }
 
 Connection
+InfoManager::signal_connect_get_ise_setting_appid (InfoManagerSlotBoolString2*                slot)
+{
+    return m_impl->signal_connect_get_ise_setting_appid (slot);
+}
+
+Connection
 InfoManager::signal_connect_get_recent_ise_geometry (InfoManagerSlotIntRect*             slot)
 {
     return m_impl->signal_connect_get_recent_ise_geometry (slot);
index 88751fa..b85bb4f 100644 (file)
@@ -193,6 +193,9 @@ InfoManagerSlotIntString2;
 typedef Slot1<bool, String>
 InfoManagerSlotBoolString;
 
+typedef Slot2<bool, String, String&>
+InfoManagerSlotBoolString2;
+
 typedef Slot1<void, bool>
 InfoManagerSlotBool;
 
@@ -735,6 +738,9 @@ public:
     //ISM_TRANS_CMD_GET_ACTIVE_HELPER_OPTION
     void get_active_helper_option (int client_id, _OUT_ uint32& option);
 
+    //ISM_TRANS_CMD_GET_ISE_SETTING_APPID
+    void get_ise_setting_appid (int client_id, String &ime_setting_appid);
+
     //ISM_TRANS_CMD_SHOW_ISE_OPTION_WINDOW
     void show_ise_option_window (int client_id);
 
@@ -1558,6 +1564,8 @@ public:
 
     Connection signal_connect_launch_option_application (InfoManagerSlotBoolString*                slot);
 
+    Connection signal_connect_get_ise_setting_appid (InfoManagerSlotBoolString2*                slot);
+
     /**
      * @brief Signal: Get the recent input panel geometry information.
      *
index 22e4e55..4eb040d 100644 (file)
@@ -677,6 +677,7 @@ 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;
 const int ISM_TRANS_CMD_SET_OPTIMIZATION_HINT             = 1133;
+const int ISM_TRANS_CMD_GET_ISE_SETTING_APPID             = 1134;
 
 /* ISE/Panel to IMControl */
 const int ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT          = 1151;