i++;
}
else if (i == 0 && firsttry) {
- LOGD("sqlite3_step returned %d, empty DB", ret);
+ LOGD("sqlite3_step returned %d, mode=%d, empty DB", ret, mode);
firsttry = false;
sqlite3_reset(pStmt);
} while (ret == SQLITE_ROW);
if (ret != SQLITE_DONE) {
- LOGE("sqlite3_step: %s", sqlite3_errmsg(databaseInfo.pHandle));
+ LOGW("sqlite3_step returned %d, mode=%d, %s", ret, mode, sqlite3_errmsg(databaseInfo.pHandle));
}
out:
return i;
}
+/**
+ * @brief Gets the count of the same module name in ime_info table.
+ *
+ * @param module_name Module name
+ *
+ * @return the number of selected row.
+ */
+static int _db_select_count_by_module_name(const char *module_name)
+{
+ int ret = 0, i = 0;
+ sqlite3_stmt* pStmt = NULL;
+ static const char* pQuery = "SELECT COUNT(*) FROM ime_info WHERE mname = ?";
+
+ ret = sqlite3_prepare_v2(databaseInfo.pHandle, pQuery, -1, &pStmt, NULL);
+ if (ret != SQLITE_OK) {
+ LOGE("%s", sqlite3_errmsg(databaseInfo.pHandle));
+ return 0;
+ }
+
+ ret = sqlite3_bind_text(pStmt, 1, module_name, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ LOGE("%s", sqlite3_errmsg(databaseInfo.pHandle));
+ goto out;
+ }
+
+ ret = sqlite3_step(pStmt);
+ if (ret != SQLITE_ROW) {
+ LOGE("sqlite3_step: %s", sqlite3_errmsg(databaseInfo.pHandle));
+ }
+ else {
+ i = sqlite3_column_int(pStmt, 0);
+ }
+
+out:
+ sqlite3_reset(pStmt);
+ sqlite3_clear_bindings(pStmt);
+ sqlite3_finalize(pStmt);
+ return i;
+}
+
/**
* @brief Update label data by appid in ime_info table.
*
ret = sqlite3_step(pStmt);
if (ret != SQLITE_DONE) {
- ISF_SAVE_LOG("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
+ ISF_SAVE_LOG("sqlite3_step returned %d, %s\n", ret, sqlite3_errmsg(databaseInfo.pHandle));
LOGE("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
ret = 0;
}
ret = sqlite3_step(pStmt);
if (ret != SQLITE_DONE) {
- ISF_SAVE_LOG("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
+ ISF_SAVE_LOG("sqlite3_step returned %d, %s\n", ret, sqlite3_errmsg(databaseInfo.pHandle));
LOGE("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
ret = 0;
}
ret = sqlite3_step(pStmt);
if (ret != SQLITE_DONE) {
- ISF_SAVE_LOG("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
+ ISF_SAVE_LOG("sqlite3_step returned %d, %s\n", ret, sqlite3_errmsg(databaseInfo.pHandle));
LOGE("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
ret = 0;
}
ret = sqlite3_step(pStmt);
if (ret != SQLITE_DONE) {
- ISF_SAVE_LOG("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
- LOGE("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
+ ISF_SAVE_LOG("sqlite3_step returned %d, appid=%s, %s\n", ret, iter->appid.c_str(), sqlite3_errmsg(databaseInfo.pHandle));
+ LOGE("sqlite3_step returned %d, appid=%s, %s", ret, iter->appid.c_str(), sqlite3_errmsg(databaseInfo.pHandle));
ret = SQLITE_ERROR;
goto out;
}
ret = _db_select_all_ime_info(ime_info);
_db_disconnect();
}
+ else
+ LOGW("failed");
return ret;
}
ret = _db_select_ime_info_by_appid(appid, pImeInfo);
_db_disconnect();
}
+ else
+ LOGW("failed");
+
return ret;
}
ret = _db_select_module_name_by_mode(mode, mname);
_db_disconnect();
}
+ else
+ LOGW("failed");
return ret;
}
ret = _db_select_module_path_by_mode(mode, mpath);
_db_disconnect();
}
+ else
+ LOGW("failed");
return ret;
}
ret = _db_select_appids_by_pkgid(pkgid, appids);
_db_disconnect();
}
+ else
+ LOGW("failed");
+
+ return ret;
+}
+
+/**
+ * @brief Gets the count of the same module name in ime_info table.
+ *
+ * @param module_name Module name
+ *
+ * @return the number of selected row.
+ */
+EAPI int isf_db_select_count_by_module_name(const char *module_name)
+{
+ int ret = 0;
+
+ if (!module_name) {
+ LOGW("module_name is null.");
+ return 0;
+ }
+
+ if (_db_connect() == 0) {
+ ret = _db_select_count_by_module_name(module_name);
+ _db_disconnect();
+ }
+ else
+ LOGW("failed");
return ret;
}
EAPI int isf_db_update_label_by_appid(const char *appid, const char *label)
{
int ret = 0;
+
if (_db_connect() == 0) {
ret = _db_update_label_by_appid(appid, label);
_db_disconnect();
}
+ else
+ LOGW("failed");
+
return ret;
}
EAPI int isf_db_update_is_enabled_by_appid(const char *appid, bool is_enabled)
{
int ret = 0;
+
if (_db_connect() == 0) {
ret = _db_update_is_enabled_by_appid(appid, is_enabled);
_db_disconnect();
}
+ else
+ LOGW("failed");
+
return ret;
}
EAPI int isf_db_update_has_option_by_appid(const char *appid, bool has_option)
{
int ret = 0;
+
if (_db_connect() == 0) {
ret = _db_update_has_option_by_appid(appid, has_option);
_db_disconnect();
}
+ else
+ LOGW("failed");
+
return ret;
}
_db_disconnect();
}
+ else
+ LOGW("failed");
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
ret = _db_delete_ime_info_by_pkgid(pkgid);
_db_disconnect();
}
+ else
+ LOGW("failed");
return ret;
}
#include "scim_private.h"
#include "scim.h"
+#include <scim_panel_common.h>
+#include "isf_query_utility.h"
EAPI scim::CommonLookupTable g_helper_candidate_table;
ISF_LOG ("scim_socket_open_connection () is successful.\n");
ISF_SAVE_LOG ("scim_socket_open_connection successful\n");
+ bool match = false;
+ std::vector<ImeInfoDB> ime_info_db;
+ isf_db_select_all_ime_info (ime_info_db);
+ for (i = 0; i < (int)ime_info_db.size (); i++) {
+ if (ime_info_db[i].appid.compare (info.uuid) == 0) {
+ match = true;
+ break;
+ }
+ }
+
m_impl->send.clear ();
m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
m_impl->send.put_data (magic);
m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_HELPER);
m_impl->send.put_data (info.uuid);
- m_impl->send.put_data (info.name);
- m_impl->send.put_data (info.icon);
+ m_impl->send.put_data (match? ime_info_db[i].label : info.name);
+ m_impl->send.put_data (match? ime_info_db[i].iconpath : info.icon);
m_impl->send.put_data (info.description);
- m_impl->send.put_data (info.option);
+ m_impl->send.put_data (match? ime_info_db[i].options : info.option);
if (!m_impl->send.write_to_socket (m_impl->socket, magic)) {
m_impl->socket.close ();
m_impl->send.put_data (magic);
m_impl->send.put_command (SCIM_TRANS_CMD_PANEL_REGISTER_ACTIVE_HELPER);
m_impl->send.put_data (info.uuid);
- m_impl->send.put_data (info.name);
- m_impl->send.put_data (info.icon);
+ m_impl->send.put_data (match? ime_info_db[i].label : info.name);
+ m_impl->send.put_data (match? ime_info_db[i].iconpath : info.icon);
m_impl->send.put_data (info.description);
- m_impl->send.put_data (info.option);
+ m_impl->send.put_data (match? ime_info_db[i].options : info.option);
if (!m_impl->send.write_to_socket (m_impl->socket_active, magic)) {
ISF_SAVE_LOG ("Helper_Active write_to_socket() failed\n");
namespace scim {
HelperModule::HelperModule (const String &name)
- : appid (""),
+ : module_name (""),
m_number_of_helpers (0),
m_get_helper_info (0),
m_get_helper_lang (0),
if (!m_module.load (name, "Helper"))
return false;
- appid = name;
-
+ module_name = name; // Module name is PkgID for Inhouse IME, "ise-web-helper-agent" for Web IME or AppID for Native IME.
m_run_helper =
(HelperModuleRunHelperFunc) m_module.symbol ("scim_helper_module_run_helper");
if (!m_run_helper) {
m_module.unload ();
- appid = "";
+ module_name = "";
m_number_of_helpers = 0;
m_get_helper_info = 0;
m_get_helper_lang = 0;
}
} catch (...) {
m_module.unload ();
- appid = "";
+ module_name = "";
m_number_of_helpers = 0;
m_get_helper_info = 0;
m_get_helper_lang = 0;
HelperModule::valid () const
{
return (m_module.valid () &&
- appid.length () > 0 &&
+ module_name.length () > 0 &&
m_run_helper);
}
unsigned int
HelperModule::number_of_helpers () const
{
- return static_cast<unsigned int>(1);
+ const char *web_ime_module_name = "ise-web-helper-agent"; // Only Web IME can have multiple helpers.
+ if (module_name.compare (web_ime_module_name) == 0) {
+ return static_cast<unsigned int>(isf_db_select_count_by_module_name (web_ime_module_name));
+ }
+
+ return 1u;
}
bool
HelperModule::get_helper_info (unsigned int idx, HelperInfo &info) const
{
- if (m_module.valid () && m_run_helper && appid.length () > 0) {
- std::vector<ImeInfoDB> ime_info;
- std::vector<ImeInfoDB>::iterator iter;
+ if (m_module.valid () && m_run_helper && module_name.length () > 0) {
- isf_db_select_all_ime_info (ime_info);
- for (iter = ime_info.begin (); iter != ime_info.end (); iter++) {
- if (iter->appid.compare(appid) == 0) {
+ std::vector<ImeInfoDB> ime_info_db;
+ isf_db_select_all_ime_info (ime_info_db);
+ for (std::vector<ImeInfoDB>::iterator iter = ime_info_db.begin (); iter != ime_info_db.end (); iter++) {
+ if (iter->module_name.compare (module_name) == 0) {
info.uuid = iter->appid;
info.name = iter->label;
info.icon = iter->iconpath;