*
* @param pkgid pkgid to insert/update ime_info table.
*
- * @return 1 on success, -1 if pkgid is not IME package, otherwise return 0.
+ * @return 1 on successfull insert, 2 on successful update, -1 if pkgid is not IME package, otherwise return 0.
*/
-int _isf_insert_ime_info_by_pkgid(const char *pkgid)
+static int _isf_insert_ime_info_by_pkgid(const char *pkgid)
{
int ret = -1;
pkgmgrinfo_pkginfo_h handle = NULL;
- bool isImePkg = false;
+ int result = 0; // 0: not IME, 1: Inserted, 2: Updated (because of the same appid)
if (!pkgid) {
LOGW("pkgid is null.");
return 0;
}
- ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, isf_pkg_ime_app_list_cb, (void *)&isImePkg);
+ ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, isf_pkg_ime_app_list_cb, (void *)&result);
if (ret != PMINFO_R_OK) {
LOGW("pkgmgrinfo_appinfo_get_list failed(%d)", ret);
ret = 0;
}
- else if (isImePkg)
- ret = 1;
+ else if (result)
+ ret = result;
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
Install and Uninstall are obviously simple.
Install: just INSTALL
Uninstall: just UNINSTALL
-Update package (change the source codes in IME project and Run As again), there are three scenarios:
+Update package (change the source codes in IME project and Run As again), there are four scenarios:
1. UPDATE
+ Source code change
2. UNINSTALL -> INSTALL
This happens when Tizen IDE Property > Tizen SDK > Rapid Development Support > Check "Enable Project specific settings"
and change Application ID in tizen-manifest.xml file and Run As.
This happens when Tizen IDE Property > Tizen SDK > Rapid Development Support > Uncheck "Enable Project specific settings"
and change Application ID in tizen-manifest.xml file and Run As.
At UPDATE event, pkgid (package parameter) is invalid...
+4. UPDATE
+ Exceptionally, only UPDATE can be called when Application ID in tizen-manifest.xml file is changed.
+ At UPDATE event, pkgid (package parameter) is valid, and only appid is changed; the previous appid is invalid.
If multiple packages (including non-IME pkgs) are uninstalled and installed; Z300H UPS (ultra power saving) mode scenario.
For example, A and B packages are uninstalled and installed, the package manager works in this order: A UNINSTALL ¡æB UNINSTALL ¡æA INSTALL ¡æB INSTALL
if (event_state == PACKAGE_MANAGER_EVENT_STATE_COMPLETED) {
LOGD ("type=%s package=%s event_type=UPDATE event_state=COMPLETED progress=%d error=%d", type, package, progress, error);
- ret = _isf_insert_ime_info_by_pkgid(package); // If package is not IME, -1 would be returned.
- if (ret == 1) { // In case IME package is updated...
- _update_ime_info();
+ ret = _isf_insert_ime_info_by_pkgid (package); // If package is not IME, -1 would be returned.
+ if (ret == 1) { // In case the package is updated with the changed appid. In this case, there will be two IMEs
+ ret = isf_db_select_appids_by_pkgid (package, appids);
+ if (ret > 1) {
+ if (_ime_info.size () > 0 && _ime_info [get_ise_index (appids.front ())].is_enabled)
+ isf_db_update_is_enabled_by_appid(appids.back ().c_str (), true);
+ isf_db_delete_ime_info_by_appid (appids.front ().c_str ());
+ }
+
+ _update_ime_info ();
+
+ /* Let panel know that ise list is changed... */
+ for (it = _ime_info.begin(); it != _ime_info.end(); it++) {
+ total_appids.push_back(it->appid);
+ }
+ if (total_appids.size() > 0)
+ _panel_agent->update_ise_list (total_appids);
+
+ if (ret > 1 && _soft_keyboard_launched) { // If the previous appid of pkgid is the current IME, restart it with new appid.
+ current_ime_appid = scim_global_config_read(String(SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), _initial_ise_uuid);
+ if (current_ime_appid.compare (appids.front ()) == 0) {
+ LOGD("Stop IME(%s)", current_ime_appid.c_str ());
+ _panel_agent->hide_helper (current_ime_appid);
+ _panel_agent->stop_helper (current_ime_appid);
+ LOGD("Start IME(%s)", appids.back ().c_str ());
+ scim_global_config_write (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), appids.back ());
+ set_keyboard_engine (String (SCIM_COMPOSE_KEY_FACTORY_UUID));
+ _panel_agent->start_helper (appids.back ());
+ }
+ }
+ }
+ else if (ret == 2) { // In case IME package is just updated...
+ _update_ime_info ();
if (_soft_keyboard_launched) { // If package is the current IME, restart it.
current_ime_appid = scim_global_config_read(String(SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), _initial_ise_uuid);
g_stopped_helper_pkgid = "";
ret = _isf_insert_ime_info_by_pkgid(package);
- if (ret) {
+ if (ret > 0) {
/* Find appid by pkgid. There might be multiple appid, but assume Helper always has one appid.
And appid can be changed, but pkgid won't be changed. */
ret = isf_db_select_appids_by_pkgid(package, appids);
}
else { // If new package is installed...
ret = _isf_insert_ime_info_by_pkgid(package); // If package is not IME, -1 would be returned.
- if (ret == 1) { // In case package is IME...
+ if (ret > 0) { // In case package is IME...
///////////////// INSTALL /////////////////
_update_ime_info();
SocketFrontEnd::socket_update_ise_list (int /*client_id*/)
{
String strName;
- std::vector<String> install_modules;
- std::vector<String> imengine_list;
- std::vector<String> helper_list;
- size_t i = 0, j = 0;
+ size_t i = 0;
if (m_receive_trans.get_data (strName) && strName.length () > 0) {
//std::cout << "ISE name list:" << strName << "\n";
//scim_split_string_list (name_list, strName);
- scim_get_imengine_module_list (imengine_list);
- scim_get_helper_module_list (helper_list);
-
- for (i = 0; i < imengine_list.size (); ++i) {
- install_modules.push_back (imengine_list [i]);
- if (std::find (__load_engine_list.begin (), __load_engine_list.end (), imengine_list [i]) == __load_engine_list.end ()) {
- SCIM_DEBUG_FRONTEND (3) << "add_module " << imengine_list [i] << " in " << __FUNCTION__ << "\n";
- //add_module (m_config, imengine_list [i], true);
- add_module_info (m_config, imengine_list [i]);
- __load_engine_list.push_back (imengine_list [i]);
- }
- }
-
- ImeInfoDB imeInfo;
+ /* The strName has all appids but here module name is necessary. */
HelperInfo info;
- for (i = 0; i < helper_list.size (); ++i) {
- install_modules.push_back (helper_list [i]);
- if (std::find (__load_engine_list.begin (), __load_engine_list.end (), helper_list [i]) == __load_engine_list.end ()) {
- if (isf_db_select_ime_info_by_module_name (helper_list [i].c_str (), &imeInfo)) {
- info.uuid = imeInfo.appid;
- info.name = imeInfo.label;
- info.icon = imeInfo.iconpath;
- info.description = "";
- info.option = imeInfo.options;
- __helpers.push_back (std::make_pair (info, helper_list [i]));
- __load_engine_list.push_back (helper_list [i]);
+ std::vector<ImeInfoDB> ime_info;
+ isf_db_select_all_ime_info(ime_info);
+ if (ime_info.size () > 0) {
+ __load_engine_list.clear ();
+ __helpers.clear ();
+
+ for (i = 0; i < ime_info.size (); ++i) {
+ if (ime_info [i].mode == TOOLBAR_KEYBOARD_MODE) {
+ /* add_module_info (m_config, ime_info [i].module_name); This seems unnecessary because IMEngine will not be added or deleted. */
+ __load_engine_list.push_back (ime_info [i].module_name);
}
}
- }
-
- /* Try to find uninstall ISEs */
- for (i = 0; i < __load_engine_list.size (); ++i) {
- if (std::find (install_modules.begin (), install_modules.end (), __load_engine_list [i]) == install_modules.end ()) {
- HelperRepository tmp_helpers = __helpers;
- __helpers.clear ();
- for (j = 0; j < tmp_helpers.size (); ++j) {
- if (std::find (install_modules.begin (), install_modules.end (), tmp_helpers [j].second) != install_modules.end ())
- __helpers.push_back (tmp_helpers [j]);
+ for (i = 0; i < ime_info.size (); ++i) {
+ if (ime_info [i].mode == TOOLBAR_HELPER_MODE) {
+ info.uuid = ime_info [i].appid;
+ info.name = ime_info [i].label;
+ info.icon = ime_info [i].iconpath;
+ info.description = "";
+ info.option = ime_info [i].options;
+ __helpers.push_back (std::make_pair (info, ime_info [i].module_name));
+ __load_engine_list.push_back (ime_info [i].module_name);
}
- __load_engine_list = install_modules;
- break;
}
}
}
char *appid = NULL, *pkgid = NULL, *pkgtype = NULL, *exec = NULL, *label = NULL, *path = NULL;
pkgmgrinfo_pkginfo_h pkginfo_handle = NULL;
ImeInfoDB ime_db;
- bool *result = static_cast<bool*>(user_data);
+ int *result = static_cast<int*>(user_data); // 0: not IME, 1: Inserted, 2: Updated
if (result) /* in this case, need to check category */ {
bool exist = true;
ret = isf_db_insert_ime_info (&ime_db);
if (ret < 1) {
- if (result)
+ if (result) {
ret = isf_db_update_ime_info (&ime_db);
- if (ret < 1)
+ if (ret) {
+ *result = 2; // Updated
+ }
+ }
+ if (ret < 1) {
ISF_SAVE_LOG("isf_db_%s_ime_info failed(%d). appid=%s pkgid=%s\n", (result? "update" : "insert"), ret, ime_db.appid.c_str(), ime_db.pkgid.c_str());
+ }
+ }
+ else if (result && ret) {
+ *result = 1; // Inserted
}
if (pkginfo_handle) {
pkginfo_handle = NULL;
}
- if (result && ret)
- *result = true;
-
return 0;
}
}
/**
- * @brief Select ime_info table with mname.
+ * @brief Select ime_info table with module name.
*
* @remarks There can be multiple ime_info tables for one module naume. For now, assuming the module name is unique.
*
return i;
}
+/**
+ * @brief Delete ime_info data with appid.
+ *
+ * @param appid appid to delete ime_info table.
+ *
+ * @return 1 if it is successful, otherwise return 0.
+ */
+static int _db_delete_ime_info_by_appid(const char *appid)
+{
+ int i = 0, ret = 0;
+ sqlite3_stmt* pStmt = NULL;
+ static const char* pQuery = "DELETE FROM ime_info WHERE appid = ?;";
+
+ ret = sqlite3_prepare_v2(databaseInfo.pHandle, pQuery, -1, &pStmt, NULL);
+ if (ret != SQLITE_OK) {
+ LOGE("%s", sqlite3_errmsg(databaseInfo.pHandle));
+ return i;
+ }
+
+ ret = sqlite3_bind_text(pStmt, 1, appid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ LOGE("sqlite3_bind_text: %s", sqlite3_errmsg(databaseInfo.pHandle));
+ goto out;
+ }
+
+ ret = sqlite3_step(pStmt);
+ if (ret != SQLITE_DONE) {
+ LOGE("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
+ }
+ else {
+ // If there is no appid to delete, ret is still SQLITE_DONE.
+ SECURE_LOGD("DELETE FROM ime_info WHERE appid = %s;", appid);
+ i = 1;
+ }
+
+out:
+ sqlite3_reset(pStmt);
+ sqlite3_clear_bindings(pStmt);
+ sqlite3_finalize(pStmt);
+ return i;
+}
+
/**
* @brief Delete all ime_info data.
*
}
/**
- * @brief Select ime_info table with mname.
+ * @brief Select ime_info table with module name.
*
* @remarks There can be multiple ime_info tables for one module naume. For now, assuming the module name is unique.
*
return ret;
}
+/**
+ * @brief Delete ime_info data with appid.
+ *
+ * @param appid appid to delete ime_info table.
+ *
+ * @return 1 if it is successful, otherwise return 0.
+ */
+EXAPI int isf_db_delete_ime_info_by_appid(const char *appid)
+{
+ int ret = 0;
+
+ if (!appid) {
+ LOGW("Input parameter is null.");
+ return ret;
+ }
+
+ if (_db_connect() == 0) {
+ ret = _db_delete_ime_info_by_appid(appid);
+ _db_disconnect();
+ }
+ else
+ LOGW("failed");
+
+ return ret;
+}
+
+/**
+ * @brief Delete all ime_info data.
+ *
+ * @return 1 if it is successful, otherwise return 0.
+ */
EXAPI int isf_db_delete_ime_info(void)
{
int ret = 0;
EXAPI int isf_db_update_ime_info(ImeInfoDB *ime_db);
EXAPI int isf_db_insert_ime_info(ImeInfoDB *ime_db);
EXAPI int isf_db_delete_ime_info_by_pkgid(const char *pkgid);
+EXAPI int isf_db_delete_ime_info_by_appid(const char *appid);
EXAPI int isf_db_delete_ime_info(void);
#endif /* __ISF_QUERY_UTILITY_H__ */