GError *error = NULL;
int watch_id = 0;
+ if (!dbus_info) {
+ LOGW("dbus info is not allocated.");
+ return false;
+ }
+
if (dbus_info->gdbus_connection == NULL) {
GDBusConnection *conn = NULL;
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
static bool _dbus_signal_init()
{
- if (dbus_info->monitor_id == 0) {
+ if (dbus_info && dbus_info->monitor_id == 0) {
int id = g_dbus_connection_signal_subscribe(dbus_info->gdbus_connection,
ENGINE_LOADER_DBUS_NAME,
ENGINE_LOADER_ISE_INTERFACE_NAME,
GDBusMessage *reply = NULL;
GVariant *reply_body = NULL;
+ if (!dbus_info) {
+ LOGW("dbus info is not allocated.");
+ return false;
+ }
+
ret = _send_sync_message(gdbus_connection, g_variant_new("()"), &reply, "loader_service_register");
if (!ret) {
LOGE("_send_sync_message() failed");
const gchar *name_owner,
gpointer user_data)
{
+ if (!dbus_info) {
+ LOGW("dbus info is not allocated.");
+ return;
+ }
+
if (!is_server_started) {
dbus_info->server_watcher_id = (intptr_t)user_data;
_monitor_register(connection);
bool engine_loader_dbus_shutdown()
{
- bool ret;
+ bool ret = false;
- if (dbus_info->server_watcher_id) {
- ret = _send_async_message(dbus_info->gdbus_connection, g_variant_new("(i)", dbus_info->server_watcher_id), "loader_service_unregister");
- if (!ret) {
- LOGE("Failed to unregister client");
- return ret;
+ if (dbus_info) {
+ if (dbus_info->server_watcher_id) {
+ ret = _send_async_message(dbus_info->gdbus_connection, g_variant_new("(i)", dbus_info->server_watcher_id), "loader_service_unregister");
+ if (!ret) {
+ LOGE("Failed to unregister client");
+ return ret;
+ }
}
- }
- if (dbus_info->server_monitor_id)
- g_bus_unwatch_name(dbus_info->server_monitor_id);
+ if (dbus_info->server_monitor_id)
+ g_bus_unwatch_name(dbus_info->server_monitor_id);
- if (dbus_info->monitor_id)
- g_dbus_connection_signal_unsubscribe(dbus_info->gdbus_connection, dbus_info->monitor_id);
+ if (dbus_info->monitor_id)
+ g_dbus_connection_signal_unsubscribe(dbus_info->gdbus_connection, dbus_info->monitor_id);
- free(dbus_info);
+ free(dbus_info);
+ }
dbus_info = NULL;
return true;
GVariant *reply_body = NULL;
bool result = false;
+ if (!dbus_info) {
+ LOGW("dbus info is not allocated.");
+ return;
+ }
+
if (_send_sync_message(dbus_info->gdbus_connection, g_variant_new("(ss)", engine_id, module_name), &reply, "set_imengine")) {
reply_body = g_dbus_message_get_body(reply);
g_variant_get(reply_body, "(b)", &result);
void engine_loader_flush_imengine()
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "flush_imengine"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "flush_imengine"))
LOGE("Failed to flush imengine");
}
void engine_loader_reset_imengine()
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "reset_imengine"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "reset_imengine"))
LOGE("Failed to reset imengine");
}
void engine_loader_send_imengine_event(int command, uint32_t value)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(iu)", command, value), "send_imengine_event"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(iu)", command, value), "send_imengine_event"))
LOGE("Failed to send imengine event");
}
GVariant *reply_body = NULL;
GVariantBuilder *key_event_builder = NULL;
+ if (!dbus_info) {
+ LOGW("dbus info is not allocated.");
+ return false;
+ }
+
key_event_builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
g_variant_builder_add(key_event_builder, "{sv}", "key_code", g_variant_new_uint32(key.code));
g_variant_builder_add(key_event_builder, "{sv}", "key_mask", g_variant_new_uint16(key.mask));
void engine_loader_focus_in()
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "focus_in"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "focus_in"))
LOGE("Failed to send focus_in event");
}
void engine_loader_focus_out()
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "focus_out"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "focus_out"))
LOGE("Failed to send focus_out event");
}
void engine_loader_update_cursor_position(int cursor_pos)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(i)", cursor_pos), "update_cursor_position"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(i)", cursor_pos), "update_cursor_position"))
LOGE("Failed to update cursor position");
}
void engine_loader_set_autocapital_type(uint32_t type)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", type), "set_autocapital_type"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", type), "set_autocapital_type"))
LOGE("Failed to send autocapital type");
}
void engine_loader_set_prediction_allow(uint32_t prediction_allow)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", prediction_allow), "set_prediction_allow"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", prediction_allow), "set_prediction_allow"))
LOGE("Failed to send prediction allow");
}
void engine_loader_reset_input_context()
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "reset_input_context"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "reset_input_context"))
LOGE("Failed to reset input context");
}
void engine_loader_set_layout(uint32_t layout)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", layout), "set_layout"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", layout), "set_layout"))
LOGE("Failed to set layout");
}
void engine_loader_set_imdata(const char *imdata, uint32_t len)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(su)", imdata, len), "set_imdata"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(su)", imdata, len), "set_imdata"))
LOGE("Failed to set imdata");
}
void engine_loader_set_input_hint(uint32_t input_hint)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", input_hint), "set_input_hint"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", input_hint), "set_input_hint"))
LOGE("Failed to set input hint");
}
void engine_loader_update_bidi_direction(uint32_t direction)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", direction), "update_bidi_direction"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", direction), "update_bidi_direction"))
LOGE("Failed to update bidi direction");
}
void engine_loader_trigger_property(const char *property)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(s)", property), "trigger_property"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(s)", property), "trigger_property"))
LOGE("Failed to send trigger property");
}
void engine_loader_show_candidate_more_window()
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "show_candidate_more_window"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "show_candidate_more_window"))
LOGE("Failed to show candidate more window");
}
void engine_loader_hide_candidate_more_window()
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "hide_candidate_more_window"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "hide_candidate_more_window"))
LOGE("Failed to hide candidate more window");
}
void engine_loader_select_aux(uint32_t item)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", item), "select_aux"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", item), "select_aux"))
LOGE("Failed to select aux");
}
void engine_loader_select_candidate(uint32_t item)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", item), "select_candidate"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", item), "select_candidate"))
LOGE("Failed to select candidate");
}
void engine_loader_candidate_table_page_up()
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "candidate_table_page_up"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "candidate_table_page_up"))
LOGE("Failed to page up the candidate table");
}
void engine_loader_candidate_table_page_down()
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "candidate_table_page_down"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("()"), "candidate_table_page_down"))
LOGE("Failed to page down the candidate table");
}
void engine_loader_change_candidate_page_size(uint32_t size)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", size), "change_candidate_page_size"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", size), "change_candidate_page_size"))
LOGE("Failed to change candidate page size");
}
GVariant *body = NULL;
std::vector<uint32_t>::iterator it;
+ if (!dbus_info) {
+ LOGW("dbus info is not allocated.");
+ return;
+ }
+
item_builder = g_variant_builder_new(G_VARIANT_TYPE("a(v)"));
for (it = item.begin(); it != item.end(); ++it) {
body = g_variant_new("(u)", *it);
void engine_loader_change_candidate_number(uint32_t page_num)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", page_num), "change_candidate_number"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", page_num), "change_candidate_number"))
LOGE("Failed to change candidate number");
}
void engine_loader_long_press_candidate_item(uint32_t index)
{
- if (!_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", index), "long_press_candidate_item"))
+ if (!dbus_info || !_send_async_message(dbus_info->gdbus_connection, g_variant_new("(u)", index), "long_press_candidate_item"))
LOGE("Failed to send long pressed item");
}