static sysevent_info_s s_info;
static int __eventsystem_check_user_send_validation(const char *event_name);
-static int __eventsystem_requet_destination_list(const char *event_name, GList **dest_list);
+static int __eventsystem_request_destination_list(const char *event_name, GList **dest_list);
static int __eventsystem_check_sender_validation(int sender_pid,
const char *event_name, char **sender);
static eventmap_s *__create_eventmap(const char *interface_name,
const char *member_name, const char *event_name,
int event_type, eventsystem_cb callback, void *user_data);
static void __destroy_eventmap(gpointer data);
+static int __eventsystem_launch_on_event_for_userevent(const char *event_name,
+ bundle *data, const bool trusted);
static int __event_compare_reg_id_cb(gconstpointer a, gconstpointer b)
{
}
tmp_list = g_list_next(tmp_list);
}
- g_list_free_full(dest_list, __eventsystem_free_trusted_list);
} else {
_E("dest_list is null");
}
*/
int eventsystem_send_user_event(const char *event_name, bundle *data, bool is_trusted)
{
- int ret = 0;
+ int ret = ES_R_OK;
eventinfo_s *evti = NULL;
struct last_data_item *item;
bundle_raw *raw = NULL;
int len;
+ GDBusConnection *conn = NULL;
+ GList *trusted_dest_list = NULL;
/* check validation */
retvm_if(!event_name, ES_R_EINVAL, "Invalid argument : event_name is NULL");
if (!evti->event_name) {
_E("memory alloc failed");
ret = ES_R_ENOMEM;
- goto out_1;
+ goto out;
}
evti->interface_name = __get_encoded_interface_name(evti->event_name);
if (!evti->interface_name) {
_E("interface_name is NULL");
ret = ES_R_ERROR;
- goto out_2;
+ goto out;
}
evti->member_name = strdup(EVENT_SYSTEM_MEMBER);
if (!evti->member_name) {
_E("memory alloc failed");
ret = ES_R_ENOMEM;
- goto out_3;
+ goto out;
}
evti->object_path = __get_object_path(evti->interface_name);
if (!evti->object_path) {
_E("object_path is NULL");
ret = ES_R_ERROR;
- goto out_4;
+ goto out;
}
evti->destination_name = NULL;
evti->is_user_event = true;
evti->is_trusted = is_trusted;
- GDBusConnection *conn = NULL;
if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SESSION, ES_TYPE_USER) == ES_R_OK) {
- if (is_trusted) {
- GList *dest_list = NULL;
- ret = __eventsystem_requet_destination_list(evti->event_name, &dest_list);
- if (ret < 0) {
- _E("failed to get dest list");
- ret = ES_R_ERROR;
- } else {
- ret = __eventsystem_send_trusted_event(conn, evti,
- data, dest_list);
- }
- } else {
- ret = __eventsystem_send_event(conn, evti, data);
- }
-
if (bundle_encode(data, &raw, &len)) {
_E("Unable to encode bundle");
ret = ES_R_ERROR;
- goto out_5;
+ goto out;
}
item = (struct last_data_item *)g_hash_table_lookup(last_data_tbl,
}
bundle_free_encoded_rawdata(&raw);
+
+ if (is_trusted) {
+ if (__eventsystem_request_destination_list(evti->event_name, &trusted_dest_list) < 0) {
+ _E("failed to get dest list");
+ ret = ES_R_ERROR;
+ goto out;
+ }
+ if (__eventsystem_send_trusted_event(conn, evti, data, trusted_dest_list) < 0) {
+ _E("failed to send trusted event");
+ ret = ES_R_ERROR;
+ goto out;
+ }
+
+ if (__eventsystem_launch_on_event_for_userevent(evti->event_name, data, true) < 0)
+ _E("Failed to launch on event for userevent");
+ } else {
+ if (__eventsystem_send_event(conn, evti, data) < 0) {
+ _E("failed to send event");
+ ret = ES_R_ERROR;
+ goto out;
+ }
+
+ if (__eventsystem_launch_on_event_for_userevent(evti->event_name, data, false) < 0)
+ _E("Failed to launch on event for userevent");
+ }
} else {
_E("getting gdbus-connetion error");
ret = ES_R_ERROR;
}
+out:
if (conn)
g_object_unref(conn);
-
-out_5:
+ if (trusted_dest_list)
+ g_list_free_full(trusted_dest_list, __eventsystem_free_trusted_list);
FREE_AND_NULL(evti->object_path);
-out_4:
FREE_AND_NULL(evti->member_name);
-out_3:
FREE_AND_NULL(evti->interface_name);
-out_2:
FREE_AND_NULL(evti->event_name);
-out_1:
FREE_AND_NULL(evti);
return ret;
return ret;
}
-static int __eventsystem_requet_destination_list(const char *event_name, GList **dest_list)
+static int __eventsystem_request_destination_list(const char *event_name, GList **dest_list)
{
int ret = ES_R_ERROR;
GDBusConnection *conn = NULL;
return ret;
}
+static int __eventsystem_launch_on_event_for_userevent(const char *event_name,
+ bundle *data, const bool trusted)
+{
+ int ret = ES_R_EINVAL;
+ GDBusConnection *conn = NULL;
+ GError *error = NULL;
+ GDBusProxy *proxy = NULL;
+ GVariant *param = NULL;
+ GVariant *value = NULL;
+ gint result = 0;
+ bundle_raw *raw = NULL;
+ bundle *buf = data;
+ int len;
+
+ if (!_initialized)
+ __initialize();
+
+ if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) < 0) {
+ _E("getting gdbus-connetion error");
+ ret = ES_R_ERROR;
+ goto out_1;
+ }
+
+ proxy = g_dbus_proxy_new_sync(conn,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL,
+ ESD_BUS_NAME, ESD_OBJECT_PATH, ESD_INTERFACE_NAME,
+ NULL, &error);
+ if (proxy == NULL) {
+ _E("failed to create new proxy, error(%s)", error->message);
+ g_error_free(error);
+ ret = ES_R_ERROR;
+ goto out_1;
+ }
+
+ bundle_encode(buf, &raw, &len);
+
+ param = g_variant_new("(ssib)", event_name, raw, len, trusted);
+ value = g_dbus_proxy_call_sync(proxy, "LaunchOnEventFromUserEvent", param,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (error != NULL) {
+ _E("proxy call sync error(%s)", error->message);
+ g_error_free(error);
+ ret = ES_R_ERROR;
+ goto out_2;
+ }
+
+ _D("Launch on event from user event (%s)", event_name);
+
+ g_variant_get(value, "(i)", &result);
+
+ _D("result(%d)", result);
+
+ ret = result;
+
+out_2:
+ bundle_free_encoded_rawdata(&raw);
+ g_object_unref(proxy);
+ g_variant_unref(value);
+out_1:
+ if (conn)
+ g_object_unref(conn);
+}
+
+
static void _send_last_user_event(const char *event_name,
bundle *data, void *user_data)
{