Hide nmt agent support log 48/281748/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 21 Sep 2022 09:20:17 +0000 (18:20 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Wed, 21 Sep 2022 09:21:23 +0000 (18:21 +0900)
Change-Id: I52c03da9d6696d8696dd740c1e981eb61c7d9fad
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
CMakeLists.txt
packaging/ise-default.spec
src/include/nmt.h
src/ise.cpp
src/nmt.cpp

index 42c2fb4..124fdee 100644 (file)
@@ -88,6 +88,7 @@ SET(PKGS_CHECK_MODULES
         stt
         capi-appfw-application
         capi-appfw-preference
+        capi-appfw-package-manager
         capi-media-sound-manager
         capi-ui-inputmethod
         capi-system-system-settings
index 6497a87..70b554f 100644 (file)
@@ -19,6 +19,7 @@ BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(stt)
 BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(capi-appfw-preference)
+BuildRequires:  pkgconfig(capi-appfw-package-manager)
 BuildRequires:  pkgconfig(capi-media-sound-manager)
 BuildRequires:  pkgconfig(capi-ui-inputmethod)
 BuildRequires:  pkgconfig(smartreply)
index 546b97a..a61d0c5 100644 (file)
@@ -21,6 +21,8 @@
 bool nmt_init();
 void nmt_shutdown();
 
+bool nmt_check_agent_install();
+
 void nmt_translate(const char *source_language, const char *target_language);
 bool nmt_is_disabled();
 
index 7e47d95..4ffcc15 100644 (file)
@@ -2593,7 +2593,8 @@ static void ime_app_create_cb(void *user_data)
 
     clipboard_init();
 
-    nmt_init();
+    if (nmt_check_agent_install())
+        nmt_init();
 }
 
 static void ime_app_exit_cb(void *user_data)
index ea9ad61..07a96d5 100644 (file)
 #include <samsung_ai_nmt.h>
 #include <inputmethod.h>
 #include <Ecore.h>
-#include "ise.h"
+#include <package_manager.h>
 
+#include "ise.h"
 #include "nmt.h"
 
 #undef LOG_TAG
 #define LOG_TAG "ISE_DEFAULT"
 
+#define NMT_AGENT_APP_ID "com.samsung.tizen.samsung-ai-nmt"
+
 #ifdef SUPPORT_NMT
 static samsung_ai_nmt_h g_nmt_h = NULL;
 static bool g_selected_text_exist = false;
@@ -101,6 +104,26 @@ static void _nmt_translate_result_cb(samsung_ai_nmt_h nmt_h, unsigned int reques
 }
 #endif
 
+bool nmt_check_agent_install()
+{
+    bool nmt_agent_install = false;
+    package_info_h pih = NULL;
+
+    LOGD("check nmt agent");
+
+    int ret = package_info_create(NMT_AGENT_APP_ID, &pih);
+    if (ret == PACKAGE_MANAGER_ERROR_NONE) {
+        nmt_agent_install = true;
+    }
+
+    if (pih)
+        package_info_destroy(pih);
+
+    LOGD("NMT agent %s", nmt_agent_install ? "found" : "not found");
+
+    return nmt_agent_install;
+}
+
 bool nmt_init()
 {
 #ifdef SUPPORT_NMT