From f312da089e8b077275cd06bd9daa86c3b6daf561 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 21 Sep 2022 18:20:17 +0900 Subject: [PATCH] Hide nmt agent support log Change-Id: I52c03da9d6696d8696dd740c1e981eb61c7d9fad Signed-off-by: Jihoon Kim --- CMakeLists.txt | 1 + packaging/ise-default.spec | 1 + src/include/nmt.h | 2 ++ src/ise.cpp | 3 ++- src/nmt.cpp | 25 ++++++++++++++++++++++++- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42c2fb4..124fdee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/packaging/ise-default.spec b/packaging/ise-default.spec index 6497a87..70b554f 100644 --- a/packaging/ise-default.spec +++ b/packaging/ise-default.spec @@ -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) diff --git a/src/include/nmt.h b/src/include/nmt.h index 546b97a..a61d0c5 100644 --- a/src/include/nmt.h +++ b/src/include/nmt.h @@ -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(); diff --git a/src/ise.cpp b/src/ise.cpp index 7e47d95..4ffcc15 100644 --- a/src/ise.cpp +++ b/src/ise.cpp @@ -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) diff --git a/src/nmt.cpp b/src/nmt.cpp index ea9ad61..07a96d5 100644 --- a/src/nmt.cpp +++ b/src/nmt.cpp @@ -20,13 +20,16 @@ #include #include #include -#include "ise.h" +#include +#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 -- 2.7.4