#ifdef HAVE_CBHM
#include <cbhm.h>
#endif
+#include <ckmc/ckmc-manager.h>
#include "ise.h"
#include "utils.h"
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;
#ifdef _MOBILE
static Ecore_Timer *guideline_timer = NULL;
#endif
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;
const MultiEventDesc &multidesc = dynamic_cast<const MultiEventDesc &>(desc);
switch (multidesc.type) {
case MultiEventDesc::CANDIDATE_ITEM_MOUSE_DOWN:
- if (multidesc.index < (int)g_smartreply_size)
- ise_send_string(g_softcandidate_string[multidesc.index].c_str());
- else
- ime_select_candidate(multidesc.index - g_smartreply_size);
+ if (g_autofill_exist) {
+ if (multidesc.index == 0)
+ ise_send_string(g_autofill_string.c_str());
+ else if (multidesc.index < (int)g_smartreply_size + 1)
+ ise_send_string(g_softcandidate_string[multidesc.index].c_str());
+ else
+ ime_select_candidate(multidesc.index - g_smartreply_size - 1);
+ } else {
+ if (multidesc.index < (int)g_smartreply_size)
+ ise_send_string(g_softcandidate_string[multidesc.index].c_str());
+ else
+ ime_select_candidate(multidesc.index - g_smartreply_size);
+ }
break;
case MultiEventDesc::CANDIDATE_MORE_VIEW_SHOW:
// when more parts shows, click on the candidate will
static CUIEventCallback callback;
+static void update_candidate_table()
+{
+ g_softcandidate_string.clear();
+ vector<string>::iterator iter;
+
+ // add autofill string
+ if (g_autofill_exist)
+ g_softcandidate_string.push_back(g_autofill_string);
+
+ // add lookup table string(s)
+ iter = g_lookup_table_strings.begin();
+ for (; iter != g_lookup_table_strings.end(); ++iter)
+ {
+ g_softcandidate_string.push_back(string(iter->c_str()));
+ }
+
+ ise_update_table(g_softcandidate_string);
+}
+
static void _input_smartreply_notify_cb(void *user_data)
{
- vector<string> candidate_strings;
+ g_smartreply_strings.clear();
char *candidate;
if (input_smartreply_is_enabled()) {
SECURE_LOGD("SmartReply = [%d] %s", i, reply);
candidate = reply;
if (candidate) {
- candidate_strings.push_back(string(candidate));
+ g_smartreply_strings.push_back(string(candidate));
g_smartreply_size++;
}
}
g_smartreply_reply_exist = true;
ise_app_candidate_show();
- g_softcandidate_string = candidate_strings;
- ise_update_table(candidate_strings);
+ g_softcandidate_string = g_smartreply_strings;
+ ise_update_table(g_softcandidate_string);
}
}
}
g_keyboard_state.focused_ic = ic;
}
+static string get_autofill_alias()
+{
+ char alias[1024] = { 0 };
+ snprintf(alias, sizeof(alias), "%d", g_autofill_hint);
+
+ return string(alias);
+}
+
+static void save_autofill_data()
+{
+ char *text = NULL;
+ int cursor;
+ ime_get_surrounding_text(-1, -1, &text, &cursor);
+ SECURE_LOGD("surrounding text : %s\n", text);
+ if (!text) return;
+
+ char *password = NULL;
+ ckmc_raw_buffer_s ckmc_data;
+ string alias = get_autofill_alias();
+ ckmc_policy_s ckmc_policy;
+ ckmc_policy.password = password;
+ ckmc_policy.extractable = true;
+
+ ckmc_data.data = (unsigned char *)text;
+ ckmc_data.size = strlen(text);
+
+ if (ckmc_data.size > 0) {
+ // Remove from the key manager
+ ckmc_remove_alias(alias.c_str());
+
+ // Save new data
+ ckmc_save_data(alias.c_str(), ckmc_data, ckmc_policy);
+ }
+
+ free(text);
+}
+
void
ise_focus_out(int ic)
{
g_keyboard_state.focused_ic = 0;
_reset_multitap_state(true);
+
+ save_autofill_data();
}
bool ise_is_guideline_popup_enable_layout(void)
return;
}
- if (g_ic_smartreply != -1)
+ if (g_ic_smartreply != -1 || g_autofill_exist)
return;
add_softcandidate_hide_timer();
#endif
}
+static void show_autofill_data(Ecore_IMF_Input_Hints input_hints)
+{
+ g_autofill_exist = false;
+ g_autofill_string = string("");
+ string alias;
+
+ alias = get_autofill_alias();
+
+ LOGD("input_hints : %x, input_hints & mask : %x\n", input_hints, input_hints & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK);
+
+ switch (g_autofill_hint)
+ {
+ case ECORE_IMF_INPUT_HINT_AUTOFILL_NAME:
+ LOGD("autofill type : name");
+ break;
+ case ECORE_IMF_INPUT_HINT_AUTOFILL_POSTAL_ADDRESS:
+ LOGD("autofill type : postal address");
+ break;
+ case ECORE_IMF_INPUT_HINT_AUTOFILL_EMAIL_ADDRESS:
+ LOGD("autofill type : email address");
+ break;
+ }
+
+ char *autofill_data = NULL;
+ char *password = NULL;
+ ckmc_raw_buffer_s *test_data2;
+ int ret;
+
+ ret = ckmc_get_data(alias.c_str(), password, &test_data2);
+ if (CKMC_ERROR_NONE != ret) {
+ LOGW("ckmc_get_data error: %d", ret);
+ return;
+ } else {
+ autofill_data = strndup((const char *)test_data2->data, test_data2->size);
+ SECURE_LOGD("data : '%s', len : %d", autofill_data, test_data2->size);
+ }
+
+ if (!autofill_data) {
+ return;
+ }
+
+ g_autofill_string = string(autofill_data);
+ free(autofill_data);
+
+ g_autofill_exist = true;
+ ise_app_candidate_show();
+ update_candidate_table();
+}
+
static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data)
{
Ise_Context iseContext;
g_ic = ic;
+ g_autofill_hint = iseContext.input_hint & ECORE_IMF_INPUT_HINT_AUTOFILL_MASK;
+
+ LOGD("input hint : %x, autofill hint : %x\n", iseContext.input_hint, g_autofill_hint);
+
+ if (g_autofill_hint == 0) {
+ switch (iseContext.layout) {
+ case ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL:
+ g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_EMAIL_ADDRESS;
+ break;
+ case ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER:
+ g_autofill_hint = ECORE_IMF_INPUT_HINT_AUTOFILL_PHONE;
+ break;
+ default:
+ break;
+ }
+ }
+
+ // show autofill data
+ show_autofill_data(iseContext.input_hint);
+
//g_ise_common->set_keyboard_ise_by_uuid(KEYBD_ISE_UUID);
/* Don't update screen until all the information is correctly set */
g_smartreply_size = 0;
input_smartreply_deinit();
g_ic_smartreply = -1;
+
+ g_autofill_exist = false;
+ g_autofill_hint = 0;
+
+ g_app_id = string("");
+ g_resource_id = string("");
+
+ g_autofill_string = string("");
+ g_smartreply_strings.clear();
+ g_lookup_table_strings.clear();
+ g_softcandidate_string.clear();
}
static void ime_app_layout_set_cb(Ecore_IMF_Input_Panel_Layout layout, void *user_data)
void *data;
Eina_List *l;
+ g_lookup_table_strings.clear();
+
if (list) {
EINA_LIST_FOREACH(list, l, data) {
candidate = (char *)data;
if (candidate) {
+ g_lookup_table_strings.push_back(string(candidate));
candidate_strings.push_back(string(candidate));
}
}
}
}
- g_softcandidate_string = candidate_strings;
- ise_update_table(candidate_strings);
+ update_candidate_table();
}
#ifdef _WEARABLE
#endif
}
+static void ime_app_prediction_hint_data_set_cb(const char *key, const char *value, void *user_data)
+{
+ SECURE_LOGD("key : %s, value : %s\n", key, value);
+
+ if (string(key) == "appid")
+ g_app_id = string(value ? value : "");
+ else if (string(key) == "res_id")
+ g_resource_id = string(value ? value : "");
+}
+
#ifdef __cplusplus
extern "C"{
#endif
ime_event_set_prediction_hint_set_cb(ime_app_prediction_hint_set_cb, NULL);
ime_event_set_mime_type_set_request_cb(ime_app_mime_type_set_request_cb, NULL);
+ ime_event_set_prediction_hint_data_set_cb(ime_app_prediction_hint_data_set_cb, NULL);
#if DEFER_ISE_CREATION
ime_set_window_creation_defer_flag(TRUE);
#endif
+
ime_run(&basic_callback, NULL);
}
#ifdef __cplusplus