void set_candidate_item_layout(std::vector<uint32_t> item);
void change_candidate_number(uint32_t page_num);
void long_press_candidate_item(uint32_t index);
+ void get_surrounding_text(int maxlen_before, int maxlen_after, scim::String &text, int &cursor);
+ void set_surrounding_text(char* text, int cursor);
};
#endif /* __ENGINE_LOADER_H */
\ No newline at end of file
int engine_loader_change_candidate_page_size(GVariant *parameters, GVariant **reply_body);
int engine_loader_set_candidate_item_layout(GVariant *parameters, GVariant **reply_body);
int engine_loader_change_candidate_number(GVariant *parameters, GVariant **reply_body);
-int engine_loader_long_press_candidate_item(GVariant *parameters, GVariant **reply_body);
\ No newline at end of file
+int engine_loader_long_press_candidate_item(GVariant *parameters, GVariant **reply_body);
+int engine_loader_set_surrounding_text(GVariant *parameters, GVariant **reply_body);
\ No newline at end of file
IMEngineModule engine_module;
uint32 layout;
+ uint32 cursor_pos;
bool is_focused;
+ char* surrounding_text;
- EngineLoaderImpl(EngineLoader *thiz) : thiz(thiz), layout(0), is_focused(false)
+ EngineLoaderImpl(EngineLoader *thiz) : thiz(thiz), layout(0), cursor_pos(0), is_focused(false), surrounding_text(NULL)
{
m_config = ConfigBase::get(false, "socket");
if (m_config.null())
if (engine_module.valid()) {
engine_module.unload();
}
+
+ if (surrounding_text != NULL)
+ free(surrounding_text);
}
void slot_show_preedit_string(IMEngineInstanceBase *si)
int maxlen_before,
int maxlen_after)
{
+ scim::String _text;
+ thiz->get_surrounding_text(maxlen_before, maxlen_after, _text, cursor);
+ text = utf8_mbstowcs(_text);
return true;
}
slot(this, &EngineLoader::EngineLoaderImpl::slot_send_private_command));
}
private:
- EngineLoaderImpl() : thiz(NULL), layout(0), is_focused(false) { }
+ EngineLoaderImpl() : thiz(NULL), layout(0), cursor_pos(0), is_focused(false), surrounding_text(NULL) { }
};
EngineLoader::EngineLoader()
if (!m_impl->si.null()) {
m_impl->si->longpress_candidate(index);
}
+}
+
+void EngineLoader::get_surrounding_text(int maxlen_before, int maxlen_after, scim::String &text, int &cursor)
+{
+ text = m_impl->surrounding_text;
+ cursor = m_impl->cursor_pos;
+}
+
+void EngineLoader::set_surrounding_text(char* text, int cursor)
+{
+ if (m_impl->surrounding_text) {
+ free(m_impl->surrounding_text);
+ m_impl->surrounding_text = NULL;
+ }
+
+ SECURE_LOGD("surrounding_text : %s", text);
+ m_impl->surrounding_text = strdup(text);
+ m_impl->cursor_pos = cursor;
}
\ No newline at end of file
ret = engine_loader_change_candidate_number(parameters, &reply_body);
} else if (g_strcmp0(method_name, "long_press_candidate_item") == 0) {
ret = engine_loader_long_press_candidate_item(parameters, &reply_body);
+ } else if (g_strcmp0(method_name, "set_surrounding_text") == 0) {
+ ret = engine_loader_set_surrounding_text(parameters, &reply_body);
}
if (ret == ENGINE_LOADER_ERROR_NONE)
" <method name='long_press_candidate_item'>"
" <arg type='u' name='index' direction='in'/>"
" </method>"
+
+ " <method name='set_surrounding_text'>"
+ " <arg type='s' name='text' direction='in'/>"
+ " <arg type='i' name='cursor' direction='in'/>"
+ " <arg type='b' name='result' direction='out'/>"
+ " </method>"
" </interface>"
" </node>";
return ENGINE_LOADER_ERROR_NONE;
}
+
+int engine_loader_set_surrounding_text(GVariant *parameters, GVariant **reply_body)
+{
+ char *text;
+ int cursor;
+
+ g_variant_get(parameters, "(&si)", &text, &cursor);
+ m_engine_loader.set_surrounding_text(text, cursor);
+
+ *reply_body = g_variant_new("(b)", true);
+ if (*reply_body == NULL) {
+ LOGE("Failed to create reply_body");
+ return ENGINE_LOADER_ERROR_OUT_OF_MEMORY;
+ }
+
+ return ENGINE_LOADER_ERROR_NONE;
+}