static void ise_selected_cb (unsigned int index)
{
- set_active_ise (_ime_info[index].uuid, _soft_keyboard_launched);
+ set_active_ise (_ime_info[index].appid, _soft_keyboard_launched);
_ise_launch_timer = ecore_timer_add (ISE_LAUNCH_TIMEOUT, ise_launch_timeout, NULL);
}
unsigned int index = 0;
if (uuid.length () > 0) {
for (unsigned int i = 0; i < _ime_info.size (); i++) {
- if (uuid == _ime_info[i].uuid) {
+ if (uuid == _ime_info[i].appid) {
index = i;
break;
}
* @brief Set keyboard ISE.
*
* @param uuid The keyboard ISE's uuid.
- * @param module_name The keyboard ISE's module name.
*
* @return false if keyboard ISE change is failed, otherwise return true.
*/
-static bool set_keyboard_ise (const String &uuid, const String &module_name)
+static bool set_keyboard_ise (const String &uuid)
{
SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n";
* @brief Set helper ISE.
*
* @param uuid The helper ISE's uuid.
- * @param module_name The helper ISE's module name.
* @param launch_ise The flag for launching helper ISE.
*
* @return false if helper ISE change is failed, otherwise return true.
*/
-static bool set_helper_ise (const String &uuid, const String &module_name, bool launch_ise)
+static bool set_helper_ise (const String &uuid, bool launch_ise)
{
SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n";
bool ise_changed = false;
for (unsigned int i = 0; i < _ime_info.size (); i++) {
- if (!uuid.compare (_ime_info[i].uuid)) {
+ if (!uuid.compare (_ime_info[i].appid)) {
if (TOOLBAR_KEYBOARD_MODE == _ime_info[i].mode)
- ise_changed = set_keyboard_ise (_ime_info[i].uuid, _ime_info[i].module_name);
+ ise_changed = set_keyboard_ise (_ime_info[i].appid);
else if (TOOLBAR_HELPER_MODE == _ime_info[i].mode)
- ise_changed = set_helper_ise (_ime_info[i].uuid, _ime_info[i].module_name, launch_ise);
+ ise_changed = set_helper_ise (_ime_info[i].appid, launch_ise);
_panel_agent->set_current_toolbar_mode (_ime_info[i].mode);
if (ise_changed) {
_panel_agent->set_current_helper_option (_ime_info[i].options);
if (_candidate_window)
ui_create_candidate_window ();
- scim_global_config_write (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), _ime_info[i].uuid);
+ scim_global_config_write (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), _ime_info[i].appid);
scim_global_config_flush ();
_config->flush ();
}
for (iter = _ime_info.begin (); iter != _ime_info.end (); iter++) {
- uuids.push_back(iter->uuid);
+ uuids.push_back(iter->appid);
modes.push_back(iter->mode);
}
- list.clear ();
- list = uuids;
- _panel_agent->update_ise_list (list);
+ if (uuids.size() > 0) {
+ list.clear ();
+ list = uuids;
- if (_initial_ise_uuid.length () > 0) {
- String active_uuid = _initial_ise_uuid;
- String default_uuid = scim_global_config_read (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), String (""));
- if (std::find (uuids.begin (), uuids.end (), default_uuid) == uuids.end ()) {
- if ((_panel_agent->get_current_toolbar_mode () == TOOLBAR_KEYBOARD_MODE) && (modes[get_ise_index (_initial_ise_uuid)] != TOOLBAR_KEYBOARD_MODE)) {
- active_uuid = String (SCIM_COMPOSE_KEY_FACTORY_UUID);
- }
- set_active_ise (active_uuid, _soft_keyboard_launched);
- } else if (_panel_agent->get_current_toolbar_mode () == TOOLBAR_HELPER_MODE) { // Check whether keyboard engine is installed
- String IMENGINE_KEY = String (SCIM_CONFIG_DEFAULT_IMENGINE_FACTORY) + String ("/") + String ("~other");
- String keyboard_uuid = _config->read (IMENGINE_KEY, String (""));
- if (std::find (uuids.begin (), uuids.end (), keyboard_uuid) == uuids.end ()) {
- active_uuid = String (SCIM_COMPOSE_KEY_FACTORY_UUID);
- _panel_agent->change_factory (active_uuid);
- _config->write (IMENGINE_KEY, active_uuid);
- _config->flush ();
+ _panel_agent->update_ise_list (list);
+
+ if (_initial_ise_uuid.length () > 0) {
+ String active_uuid = _initial_ise_uuid;
+ String default_uuid = scim_global_config_read (String (SCIM_GLOBAL_CONFIG_DEFAULT_ISE_UUID), String (""));
+ if (std::find (uuids.begin (), uuids.end (), default_uuid) == uuids.end ()) {
+ if ((_panel_agent->get_current_toolbar_mode () == TOOLBAR_KEYBOARD_MODE) && (modes[get_ise_index (_initial_ise_uuid)] != TOOLBAR_KEYBOARD_MODE)) {
+ active_uuid = String (SCIM_COMPOSE_KEY_FACTORY_UUID);
+ }
+ set_active_ise (active_uuid, _soft_keyboard_launched);
+ } else if (_panel_agent->get_current_toolbar_mode () == TOOLBAR_HELPER_MODE) { // Check whether keyboard engine is installed
+ String IMENGINE_KEY = String (SCIM_CONFIG_DEFAULT_IMENGINE_FACTORY) + String ("/") + String ("~other");
+ String keyboard_uuid = _config->read (IMENGINE_KEY, String (""));
+ if (std::find (uuids.begin (), uuids.end (), keyboard_uuid) == uuids.end ()) {
+ active_uuid = String (SCIM_COMPOSE_KEY_FACTORY_UUID);
+ _panel_agent->change_factory (active_uuid);
+ _config->write (IMENGINE_KEY, active_uuid);
+ _config->flush ();
+ }
}
}
}
std::vector<String> uuids;
for (std::vector<ImeInfoDB>::iterator iter = _ime_info.begin(); iter != _ime_info.end(); iter++) {
- uuids.push_back(iter->uuid);
+ uuids.push_back(iter->appid);
}
if (_ime_info.size () > 0) {
list = uuids;
update_ise_locale ();
for (unsigned int i = 0; i < _ime_info.size (); i++) {
- if (uuid == _ime_info[i].uuid) {
+ if (uuid == _ime_info[i].appid) {
name = _ime_info[i].label;
language = _ime_info[i].languages;
type = _ime_info[i].mode;
SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n";
for (unsigned int i = 0; i < _ime_info.size (); i++) {
- if (!uuid.compare (_ime_info[i].uuid)) {
- info.uuid = _ime_info[i].uuid;
+ if (!uuid.compare (_ime_info[i].appid)) {
+ info.uuid = _ime_info[i].appid;
info.name = _ime_info[i].label;
info.icon = _ime_info[i].iconpath;
info.lang = _ime_info[i].languages;
std::vector<String> uuids;
std::vector<ImeInfoDB>::iterator iter;
for (iter = _ime_info.begin(); iter != _ime_info.end(); iter++) {
- uuids.push_back(iter->uuid);
+ uuids.push_back(iter->appid);
}
if (uuid.length () <= 0 || std::find (uuids.begin (), uuids.end (), uuid) == uuids.end ())
scim_split_string_list (ise_langs, helper_language);
for (size_t i = 0; i < _groups[ise_langs[0]].size (); ++i) {
int j = _groups[ise_langs[0]][i];
- if (_ime_info[j].uuid != uuid && _ime_info[j].mode == TOOLBAR_KEYBOARD_MODE) {
- uuid = _ime_info[j].uuid;
+ if (_ime_info[j].appid != uuid && _ime_info[j].mode == TOOLBAR_KEYBOARD_MODE) {
+ uuid = _ime_info[j].appid;
break;
}
}
* DB Table schema
*
* ime_info
- * +-------+------+-------+-----------+-----------+-------+-------------+-----------+-----------+
- * | appid | uuid | label | languages | iconpath | pkgid | pkgrootpath | pkgtype | kbdtype |
- * +-------+------+-------+-----------+-----------+-------+-------------+-----------+-----------+
- * | - | - | - | - | - | - | - | - | - |
- * +-------+------+-------+-----------+-----------+-------+-------------+-----------+-----------+
+ * +-------+------+-------+-----------+-----------+-------+-------------+-----------+
+ * | appid | uuid | label | languages | iconpath | pkgid | pkgrootpath | pkgtype |
+ * +-------+------+-------+-----------+-----------+-------+-------------+-----------+
+ * | - | - | - | - | - | - | - | - |
+ * +-------+------+-------+-----------+-----------+-------+-------------+-----------+
*
- * CREATE TABLE ime_info ( appid TEXT PRIMARY KEY NOT NULL, uuid TEXT, label TEXT, languages TEXT, iconpath TEXT, pkgid TEXT, pkgrootpath TEXT, pkgtype TEXT, kbdtype TEXT)
+ * CREATE TABLE ime_info ( appid TEXT PRIMARY KEY NOT NULL, uuid TEXT, label TEXT, languages TEXT, iconpath TEXT, pkgid TEXT, pkgrootpath TEXT, pkgtype TEXT)
*
*/
///////////////////////////////////////////////////////////////////////////////////////////////////
// DATABASE
///////////////////////////////////////////////////////////////////////////////////////////////////
-#define DB_PATH "/opt/usr/dbspace/.ime_parser.db"
+#define DB_PATH "/opt/usr/dbspace/.ime_info.db"
static struct {
const char* pPath;
sqlite3* pHandle;
static inline int _db_create_ime_info(void)
{
char* pException = NULL;
- static const char* pQuery = "CREATE TABLE ime_info (appid TEXT PRIMARY KEY NOT NULL, uuid TEXT, label TEXT, languages TEXT, iconpath TEXT, pkgid TEXT, pkgrootpath TEXT, pkgtype TEXT, kbdtype TEXT)";
+ static const char* pQuery = "CREATE TABLE ime_info (appid TEXT PRIMARY KEY NOT NULL, uuid TEXT, label TEXT, languages TEXT, iconpath TEXT, pkgid TEXT, pkgrootpath TEXT, pkgtype TEXT)";
if (sqlite3_exec(databaseInfo.pHandle, pQuery, NULL, NULL, &pException) != SQLITE_OK) {
LOGE("%s", pException);
+ sqlite3_free(pException);
return -EIO;
}
int ret = db_util_open(databaseInfo.pPath, &databaseInfo.pHandle, DB_UTIL_REGISTER_HOOK_METHOD);
if (ret != SQLITE_OK) {
- LOGE("sqlite3 return code: %d", ret);
+ LOGE("db_util_open returned code: %d", ret);
return -EIO;
}
int ret = 0, i = 0;
sqlite3_stmt* pStmt = NULL;
std::vector<ImeInfoDB>::iterator iter;
- static const char* pQuery = "INSERT INTO ime_info (appid, uuid, label, languages, iconpath, pkgid, pkgrootpath, pkgtype, kbdtype) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ static const char* pQuery = "INSERT INTO ime_info (appid, uuid, label, languages, iconpath, pkgid, pkgrootpath, pkgtype) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
ret = sqlite3_prepare_v2(databaseInfo.pHandle, pQuery, -1, &pStmt, NULL);
if (ret != SQLITE_OK) {
goto out;
}
- if (sqlite3_step(pStmt) != SQLITE_DONE) {
- LOGE("sqlite3_step: %s", sqlite3_errmsg(databaseInfo.pHandle));
+ ret = sqlite3_step(pStmt);
+ if (ret != SQLITE_DONE) {
+ char buf[256] = {0};
+ snprintf (buf, sizeof (buf), "pid:%d %s %s sqlite3_step returned %d, %s\n",
+ getpid (), __FILE__, __func__, ret, sqlite3_errmsg(databaseInfo.pHandle));
+ isf_save_log(buf);
+ LOGE("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
ret = SQLITE_ERROR;
goto out;
}
else {
- LOGD("Insert \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",
+ LOGD("Insert \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",
iter->appid.c_str(), iter->uuid.c_str(), iter->label.c_str(), iter->languages.c_str(),
- iter->iconpath.c_str(), iter->pkgid.c_str(), iter->pkgrootpath.c_str(), iter->pkgtype.c_str(),
- iter->kbdtype.c_str());
+ iter->iconpath.c_str(), iter->pkgid.c_str(), iter->pkgrootpath.c_str(), iter->pkgtype.c_str());
+ ret = SQLITE_OK;
}
sqlite3_reset(pStmt);
sqlite3_clear_bindings(pStmt);
ret = sqlite3_step(pStmt);
if (ret != SQLITE_DONE) {
- LOGE("sqlite3_step: %s", sqlite3_errmsg(databaseInfo.pHandle));
+ char buf[256] = {0};
+ snprintf (buf, sizeof (buf), "pid:%d %s %s sqlite3_step returned %d, %s\n",
+ getpid (), __FILE__, __func__, ret, sqlite3_errmsg(databaseInfo.pHandle));
+ isf_save_log(buf);
+ LOGE("sqlite3_step returned %d, %s", ret, sqlite3_errmsg(databaseInfo.pHandle));
ret = 0;
}
else {
return ret;
}
-static int filtered_app_list_cb (const pkgmgrinfo_appinfo_h handle, void *user_data)
+/**
+ * @brief Read data from ime category manifest and insert initial db
+ *
+ * @param handle pkgmgrinfo_appinfo_h pointer
+ * @param user_data The data to pass to this callback.
+ *
+ * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative.
+ */
+static int _filtered_app_list_cb (const pkgmgrinfo_appinfo_h handle, void *user_data)
{
int ret = 0;
char *appid = NULL, *icon = NULL, *pkgid = NULL, *pkgtype = NULL, *label = NULL, *path = NULL;
}
ime_db.languages = String("en");
+// TODO: Need to remove these after replace uuid with appid...
+ ime_db.uuid = ime_db.appid;
ime_info.push_back(ime_db);
_db_insert_ime_info(ime_info);
size_t found = 0;
static const char* pQuery = "SELECT * FROM ime_info";
-
do {
if (i == 0) {
ret = sqlite3_prepare_v2(databaseInfo.pHandle, pQuery, -1, &pStmt, NULL);
info.pkgid = String((char *)sqlite3_column_text(pStmt, 5));
info.pkgrootpath = String((char *)sqlite3_column_text(pStmt, 6));
info.pkgtype = String((char *)sqlite3_column_text(pStmt, 7));
- info.kbdtype = String((char *)sqlite3_column_text(pStmt, 8));
- LOGD("appid=\"%s\", uuid=\"%s\", label=\"%s\", languages=\"%s\", iconpath=\"%s\", pkgid=\"%s\", pkgrootpath=\"%s\", pkgtype=\"%s\", kbdtype=\"%s\"",
- info.appid.c_str(),
- info.uuid.c_str(),
- info.label.c_str(),
- info.languages.c_str(),
- info.iconpath.c_str(),
- info.pkgid.c_str(),
- info.pkgrootpath.c_str(),
- info.pkgtype.c_str(),
- info.kbdtype.c_str());
+ if (info.pkgtype.compare("rpm") == 0 && info.appid.find("ise-engine") != String::npos) {
+ info.mode = TOOLBAR_KEYBOARD_MODE;
+ info.options = 0;
+
+ found = info.appid.find_last_of('.');
+ if (found != String::npos)
+ info.module_name = info.appid.substr(found+1);
+ else
+ info.module_name = info.appid;
- if (info.kbdtype.compare("SOFTWARE_KEYBOARD_ISE") == 0) {
+ if (scim_get_imengine_module_list(module_list)) {
+ if (std::find (module_list.begin(), module_list.end(), info.module_name) == module_list.end())
+ LOGE("Module name \"%s\" can't be found in scim_get_imengine_module_list().", info.module_name.c_str());
+ }
+ }
+ else {
info.mode = TOOLBAR_HELPER_MODE;
- info.options = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_AUTO_RESTART;
if (info.pkgtype.compare("wgt") == 0) {
- info.options = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_NEED_SPOT_LOCATION_INFO | SCIM_HELPER_AUTO_RESTART;
+ info.options = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_AUTO_RESTART | SCIM_HELPER_NEED_SPOT_LOCATION_INFO;
info.module_name = String("ise-web-helper-agent");
}
- else {
+ else {
info.options = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_AUTO_RESTART;
found = info.appid.find_last_of('.');
}
}
}
- else /*if (info.kbdtype.compare("HARDWARE_KEYBOARD_ISE") == 0)*/ {
- info.mode = TOOLBAR_KEYBOARD_MODE;
- info.options = 0;
-
- found = info.appid.find_last_of('.');
- if (found != String::npos)
- info.module_name = info.appid.substr(found+1);
- else
- info.module_name = info.appid;
- if (scim_get_imengine_module_list(module_list)) {
- if (std::find (module_list.begin(), module_list.end(), info.module_name) == module_list.end())
- LOGE("Module name \"%s\" can't be found in scim_get_imengine_module_list().", info.module_name.c_str());
- }
- }
+ LOGD("appid=\"%s\", uuid=\"%s\", label=\"%s\", languages=\"%s\", iconpath=\"%s\", pkgid=\"%s\", pkgrootpath=\"%s\", pkgtype=\"%s\", module_name=\"%s\", mode=%d, options=%u",
+ info.appid.c_str(),
+ info.uuid.c_str(),
+ info.label.c_str(),
+ info.languages.c_str(),
+ info.iconpath.c_str(),
+ info.pkgid.c_str(),
+ info.pkgrootpath.c_str(),
+ info.pkgtype.c_str(),
+ info.module_name.c_str(),
+ info.mode,
+ info.options);
ime_info.push_back(info);
i++;
if (ret == PMINFO_R_OK) {
ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, "http://tizen.org/category/ime");
if (ret == PMINFO_R_OK) {
- ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, filtered_app_list_cb, NULL);
+ ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, _filtered_app_list_cb, NULL);
}
pkgmgrinfo_appinfo_filter_destroy(handle);
}
pImeInfo->pkgid.clear();
pImeInfo->pkgrootpath.clear();
pImeInfo->pkgtype.clear();
- pImeInfo->kbdtype.clear();
ret = sqlite3_prepare_v2(databaseInfo.pHandle, pQuery, -1, &pStmt, NULL);
if (ret != SQLITE_OK) {
pImeInfo->pkgid = String((char*)sqlite3_column_text(pStmt, 5));
pImeInfo->pkgrootpath = String((char*)sqlite3_column_text(pStmt, 6));
pImeInfo->pkgtype = String((char*)sqlite3_column_text(pStmt, 7));
- pImeInfo->kbdtype = String((char*)sqlite3_column_text(pStmt, 8));
- LOGD("appid=\"%s\", uuid=\"%s\", label=\"%s\", languages=\"%s\", iconpath=\"%s\", pkgid=\"%s\", pkgrootpath=\"%s\", pkgtype=\"%s\", kbdtype=\"%s\"",
+ LOGD("appid=\"%s\", uuid=\"%s\", label=\"%s\", languages=\"%s\", iconpath=\"%s\", pkgid=\"%s\", pkgrootpath=\"%s\", pkgtype=\"%s\"",
pImeInfo->appid.c_str(),
pImeInfo->uuid.c_str(),
pImeInfo->label.c_str(),
pImeInfo->iconpath.c_str(),
pImeInfo->pkgid.c_str(),
pImeInfo->pkgrootpath.c_str(),
- pImeInfo->pkgtype.c_str(),
- pImeInfo->kbdtype.c_str());
+ pImeInfo->pkgtype.c_str());
out:
sqlite3_reset(pStmt);