using namespace std;
-static string get_autofill_alias(const char *app_id, const char *res_id, Ecore_IMF_Input_Hints input_hints)
+static bool g_autofill_exist = false;
+static unsigned int g_autofill_hints = 0;
+
+static string g_app_id;
+static string g_resource_id;
+
+void ime_autofill_set_app_id(const char *app_id)
+{
+ g_app_id = string(app_id ? app_id : "");
+}
+
+void ime_autofill_set_resource_id(const char *resource_id)
{
- int autofill_hint = input_hints & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
+ g_resource_id = string(resource_id ? resource_id : "");
+}
+void ime_autofill_set_exist(bool exist)
+{
+ g_autofill_exist = exist;
+}
+
+bool ime_autofill_get_exist()
+{
+ return g_autofill_exist;
+}
+
+void ime_autofill_set_hint(unsigned int autofill_hints)
+{
+ g_autofill_hints = autofill_hints;
+}
+
+unsigned int ime_autofill_get_hint()
+{
+ return g_autofill_hints;
+}
+
+static string get_autofill_alias()
+{
char alias[1024] = { 0 };
- snprintf(alias, sizeof(alias), "autofill|%s|%s|%d", app_id ? app_id : "", res_id ? res_id : "", autofill_hint);
+ snprintf(alias, sizeof(alias), "autofill|%s|%s|%d", g_app_id.c_str(), g_resource_id.c_str(), g_autofill_hints);
return string(alias);
}
-Eina_Bool autofill_save_string(const char *app_id, const char *res_id, Ecore_IMF_Input_Hints input_hints, const char *text)
+Eina_Bool ime_autofill_save_string(const char *text)
{
- if ((input_hints & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK) == 0)
+ if (g_autofill_hints == 0)
return EINA_FALSE;
if (!text) return EINA_FALSE;
char *password = NULL;
ckmc_raw_buffer_s ckmc_data;
- string alias = get_autofill_alias(app_id, res_id, input_hints);
+ string alias = get_autofill_alias();
ckmc_policy_s ckmc_policy;
ckmc_policy.password = password;
ckmc_policy.extractable = true;
}
}
-char *autofill_get_string(const char *app_id, const char *res_id, Ecore_IMF_Input_Hints input_hints)
+string ime_autofill_get_string()
{
string alias;
string autofill_string;
ckmc_raw_buffer_s *ckmc_data = NULL;
int ret;
- int autofill_hint = input_hints & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
- LOGD("input_hints : %x, input_hints & mask : %x\n", input_hints, input_hints & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK);
+ LOGD("autofill_hints : %x\n", g_autofill_hints);
- if (autofill_hint == 0)
- return NULL;
+ if (g_autofill_hints == 0)
+ return string("");
- alias = get_autofill_alias(app_id, res_id, input_hints);
+ alias = get_autofill_alias();
- switch (autofill_hint)
+ switch (g_autofill_hints)
{
case ECORE_IMF_INPUT_HINT_AUTOFILL_NAME:
LOGD("autofill type : name");
ret = ckmc_get_data(alias.c_str(), password, &ckmc_data);
if (CKMC_ERROR_NONE != ret) {
LOGW("ckmc_get_data error: %d", ret);
- return NULL;
+ return string("");
} else {
if (!ckmc_data)
- return NULL;
+ return string("");
autofill_data = strndup((const char *)ckmc_data->data, ckmc_data->size);
SECURE_LOGD("data : '%s', len : %zu", autofill_data, ckmc_data->size);
autofill_string = string(autofill_data);
free(autofill_data);
} else {
- return NULL;
+ return string("");
}
- return strdup(autofill_string.c_str());
+ return autofill_string;
}
-Eina_Bool autofill_clear()
+Eina_Bool ime_autofill_clear()
{
int ret = CKMC_ERROR_NONE;
#define _AUTOFILL_H_
#include <Ecore_IMF.h>
+#include <string>
-#ifdef __cplusplus
-extern "C" {
-#endif
+using namespace std;
+
+bool ime_autofill_get_exist();
+void ime_autofill_set_exist(bool exist);
+
+void ime_autofill_set_app_id(const char *app_id);
+void ime_autofill_set_resource_id(const char *resource_id);
+
+void ime_autofill_set_hint(unsigned int input_hints);
+unsigned int ime_autofill_get_hint();
/**
* @brief Save autofill string.
*
* @privlevel internal
*
- * @param[in] app_id application ID
- * @param[in] res_id resource ID
- * @param[in] input_hints input hint
* @param[in] text autofill string
*/
-Eina_Bool autofill_save_string(const char *app_id, const char *res_id, Ecore_IMF_Input_Hints input_hints, const char *text);
+Eina_Bool ime_autofill_save_string(const char *text);
/**
* @brief Get autofill string.
*
* @privlevel internal
*
- * @param[in] app_id application ID
- * @param[in] res_id resource ID
- * @param[in] input_hints input hint
- *
- * @return a newly allocated autofill string. Free with free() when no longer needed.
+ * @return autofill string
*/
-char *autofill_get_string(const char *app_id, const char *res_id, Ecore_IMF_Input_Hints input_hints);
+string ime_autofill_get_string();
/**
* @brief Clear autofill data.
* @privlevel internal
*
*/
-Eina_Bool autofill_clear();
-
-#ifdef __cplusplus
-}
-#endif
+Eina_Bool ime_autofill_clear();
#endif
static bool g_candidate_more_view = false;
static bool g_ise_created = false;
-static bool g_autofill_exist = false;
-static int g_autofill_hint = 0;
-static string g_autofill_string;
static vector<string> g_lookup_table_strings;
static vector<string> g_smartreply_strings;
#if EXIT_ISE_ON_HIDE
static Ecore_Timer *exit_timer = NULL;
#endif
-static string g_app_id;
-static string g_resource_id;
-
#define SOFT_CANDIDATE_DELETE_TIME (100.0/1000)
static Ecore_Timer *g_softcandidate_hide_timer = NULL;
switch (multidesc.type) {
case MultiEventDesc::CANDIDATE_ITEM_MOUSE_DOWN:
- if (g_autofill_exist) {
+ if (ime_autofill_get_exist()) {
if (multidesc.index == 0) {
- char *text = autofill_get_string(g_app_id.c_str(), g_resource_id.c_str(), (Ecore_IMF_Input_Hints)g_autofill_hint);
- if (text) {
- ise_send_string(text);
- free(text);
- }
+ string autofill_string = ime_autofill_get_string();
+ ise_send_string(autofill_string.c_str());
} else if (multidesc.index < (int)smartreply_size + 1) {
ise_send_string(g_softcandidate_string[multidesc.index].c_str());
ise_update_table(g_smartreply_strings);
g_ic_smartreply = -1;
// add autofill string
- if (g_autofill_exist)
- g_softcandidate_string.push_back(g_autofill_string);
+ if (ime_autofill_get_exist())
+ g_softcandidate_string.push_back(ime_autofill_get_string());
// add lookup table string(s)
iter = g_lookup_table_strings.begin();
char *text = NULL;
int cursor;
- if (g_autofill_hint == 0)
+ if (ime_autofill_get_hint() == 0)
return;
ime_get_surrounding_text(-1, -1, &text, &cursor);
SECURE_LOGD("surrounding text : %s\n", text);
if (!text) return;
- autofill_save_string(g_app_id.c_str(), g_resource_id.c_str(), (Ecore_IMF_Input_Hints)g_autofill_hint, text);
+ ime_autofill_save_string(text);
free(text);
}
return;
}
- if (g_ic_smartreply != -1 || g_autofill_exist)
+ if (g_ic_smartreply != -1 || ime_autofill_get_exist())
return;
add_softcandidate_hide_timer();
clipboard_shutdown();
}
-static void show_autofill_data(Ecore_IMF_Input_Hints input_hints)
+static void show_autofill_data()
{
- g_autofill_exist = false;
- char *text = autofill_get_string(g_app_id.c_str(), g_resource_id.c_str(), input_hints);
+ ime_autofill_set_exist(false);
+ string autofill_string = ime_autofill_get_string();
- if (text) {
- g_autofill_string = string(text);
- free(text);
- } else {
- g_autofill_string = string("");
- }
- SECURE_LOGD("autofill string : %s", g_autofill_string.c_str());
+ SECURE_LOGD("autofill string : %s", autofill_string.c_str());
- if (g_autofill_string.length() > 0) {
- g_autofill_exist = true;
+ if (!autofill_string.empty()) {
+ ime_autofill_set_exist(true);
ise_app_candidate_show();
update_candidate_table();
g_ic = ic;
- g_autofill_hint = iseContext.input_hint & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
+ ime_autofill_set_hint(iseContext.input_hint & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK);
- LOGD("input hint : %x, autofill hint : %x\n", iseContext.input_hint, g_autofill_hint);
+ LOGD("input hint : %x, autofill hint : %x\n", iseContext.input_hint, ime_autofill_get_hint());
// show autofill data
- show_autofill_data((Ecore_IMF_Input_Hints)g_autofill_hint);
+ show_autofill_data();
//g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID);
input_smartreply_deinit();
g_ic_smartreply = -1;
- g_autofill_exist = false;
- g_autofill_hint = 0;
-
- g_app_id = string("");
- g_resource_id = string("");
+ ime_autofill_set_exist(false);
+ ime_autofill_set_hint(0);
+ ime_autofill_set_app_id("");
+ ime_autofill_set_resource_id("");
- g_autofill_string = string("");
g_smartreply_strings.clear();
g_lookup_table_strings.clear();
g_softcandidate_string.clear();
SECURE_LOGD("key : %s, value : %s\n", key, value);
if (string(key) == "appid")
- g_app_id = string(value ? value : "");
+ ime_autofill_set_app_id(value);
else if (string(key) == "res_id")
- g_resource_id = string(value ? value : "");
+ ime_autofill_set_resource_id(value);
}
static void ime_app_autocapital_type_set_cb(uint32_t type, void *user_data)
vconf_set_bool(VCONFKEY_AUTOPERIOD_ALLOW_BOOL, config_values->auto_punctuate);
}
- autofill_clear();
+ ime_autofill_clear();
Evas_Object *popup = (Evas_Object *)data;
if (popup)