static char *__get_object_path(char *interface_name)
{
int i;
- char *object_path = (char *)calloc(strlen(interface_name), sizeof(char)+2);
+ char *object_path = (char *)calloc(strlen(interface_name), sizeof(char) + 2);
if (object_path == NULL) {
_E("failed to allocate memory");
object_path[0] = '/';
- for (i = 0 ; interface_name[i] ; i++) {
-
- if (interface_name[i] == '.') {
- object_path[i+1] = '/';
- } else {
- object_path[i+1] = interface_name[i];
- }
+ for (i = 0; interface_name[i]; i++) {
+ if (interface_name[i] == '.')
+ object_path[i + 1] = '/';
+ else
+ object_path[i + 1] = interface_name[i];
}
return object_path;
char *key = NULL;
int ret = 1;
- if (check_tbl == NULL) {
+ if (check_tbl == NULL)
check_tbl = g_hash_table_new(g_str_hash, g_str_equal);
- }
event_id = (char *)g_hash_table_lookup(check_tbl, event_name);
-
if (event_id == NULL) {
if (__eventsystem_check_user_send_validation(event_name) < 0) {
_E("invalid user-event name");
static int __check_interface_validation_user(char *interface_name)
{
- int ret = 1;
int len = strlen(EVENT_SYSTEM_PREFIX);
- if (strncmp(interface_name, EVENT_SYSTEM_PREFIX, len) != 0) {
- ret = 0;
- }
+ if (strncmp(interface_name, EVENT_SYSTEM_PREFIX, len) != 0)
+ return 0;
- return ret;
+ return 1;
}
static int __check_eventname_validation_user(char *event_name)
{
- int ret = 1;
int len = strlen(USER_EVENT_NAME_PREFIX);
- if (strncmp(event_name, USER_EVENT_NAME_PREFIX, len) != 0) {
- ret = 0;
- }
+ if (strncmp(event_name, USER_EVENT_NAME_PREFIX, len) != 0)
+ return 0;
- return ret;
+ return 1;
}
static int __check_eventname_validation_system(char *event_name)
{
- int ret = 1;
int len = strlen(SYS_EVENT_NAME_PREFIX);
- if (strncmp(event_name, SYS_EVENT_NAME_PREFIX, len) != 0) {
- ret = 0;
- }
+ if (strncmp(event_name, SYS_EVENT_NAME_PREFIX, len) != 0)
+ return 0;
- return ret;
+ return 1;
}
static int __get_gdbus_shared_connection(GDBusConnection **connection, GBusType bus_type,
{
GError *error = NULL;
guint owner_id = 0;
+ gchar *guid = NULL;
+ char own_name[128] = {0, };
+ GDBusConnection *conn_system = NULL;
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
*connection = g_bus_get_sync(bus_type, NULL, &error);
if (*connection == NULL) {
if (((bus_type == G_BUS_TYPE_SYSTEM && !s_info.owner_id) ||
(bus_type == G_BUS_TYPE_SESSION && !s_info.owner_id_session))) {
- gchar *guid = NULL;
- char own_name[128] = {0, };
-
guid = g_dbus_generate_guid();
if (guid == NULL) {
_E("failed to get guid");
if (bus_type == G_BUS_TYPE_SESSION && event_type == ES_TYPE_USER) {
/* set same name on system-bus */
- GDBusConnection *conn_system = NULL;
-
error = NULL;
conn_system = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (conn_system == NULL) {
cb_list = g_list_find_custom(system_event_list, &em,
(GCompareFunc)__event_compare_name_cb);
- if (cb_list == NULL) {
+ if (cb_list == NULL)
return;
- }
g_variant_get(parameters, "(us)", &len, &raw);
em.event_name = ((eventmap_s *)cb_list->data)->event_name;
em.ep_cb = ((eventmap_s *)cb_list->data)->ep_cb;
- if (em.ep_cb) {
+ if (em.ep_cb)
em.ep_cb(em.event_name, buf, user_data);
- }
bundle_free_encoded_rawdata(&raw);
bundle_free(buf);
g_variant_get(parameters, "(us)", &len, &raw);
em.es_cb = ((eventmap_s *)cb_list->data)->es_cb;
- if (em.es_cb) {
+ if (em.es_cb)
em.es_cb(em.event_name, raw, len, user_data);
- }
bundle_free_encoded_rawdata(&raw);
}
_D("sender_name(%s), interface_name(%s)", sender_name, interface_name);
- if (filter_tbl == NULL) {
+ if (filter_tbl == NULL)
filter_tbl = g_hash_table_new(g_str_hash, g_str_equal);
- }
sender_id = (char *)g_hash_table_lookup(filter_tbl, interface_name);
-
if (sender_id == NULL) {
sender_pid = __eventsystem_get_sender_pid(connection, sender_name);
if (sender_pid <= 0) {
out_2:
FREE_AND_NULL(interface_name);
out_1:
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
return ret;
}
retvm_if(!reg_id, ES_R_EINVAL, "Invalid argument : reg_id");
retvm_if(!callback, ES_R_EINVAL, "Invalid argument : callback");
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
ret = __eventsystem_register_event_internal(event_name, &em, user_data);
-
if (ret == ES_R_OK && em) {
em->ep_cb = callback;
system_event_list = g_list_append(system_event_list, em);
retvm_if(reg_id == 0, ES_R_EINVAL, "Invalid argument : reg_id");
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
em.reg_id = reg_id;
cb_list = g_list_find_custom(system_event_list, &em,
{
GList *tmp_list = NULL;
int ret = 0;
+ char *dest_name;
if (dest_list) {
tmp_list = g_list_first(dest_list);
while (tmp_list != NULL) {
- char *dest_name = (char *)tmp_list->data;
+ dest_name = (char *)tmp_list->data;
if (dest_name && dest_name[0] != '\0') {
_D("dest_name(%s)", dest_name);
evti->destination_name = dest_name;
int eventsystem_send_user_event(const char *event_name, bundle *data, bool is_trusted)
{
int ret = 0;
+ eventinfo_s *evti = NULL;
/* check validation */
retvm_if(!event_name, ES_R_EINVAL, "Invalid argument : event_name is NULL");
return ES_R_EINVAL;
}
- eventinfo_s *evti = NULL;
evti = calloc(1, sizeof(eventinfo_s));
if (!evti) {
_E("memory alloc failed");
ret = ES_R_ERROR;
}
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
+
FREE_AND_NULL(evti->object_path);
out_4:
FREE_AND_NULL(evti->member_name);
int eventsystem_send_system_event(const char *event_name, bundle *data)
{
int ret = 0;
+ eventinfo_s *evti = NULL;
+ GDBusConnection *conn = NULL;
pthread_mutex_lock(&send_sync_lock);
_D("event_name(%s)", event_name);
- eventinfo_s *evti = NULL;
evti = calloc(1, sizeof(eventinfo_s));
if (!evti) {
_E("memory alloc failed");
evti->destination_name = NULL;
evti->is_user_event = false;
- GDBusConnection *conn = NULL;
if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) == ES_R_OK) {
ret = __eventsystem_send_event(conn, evti, data);
} else {
ret = ES_R_ERROR;
}
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
+
FREE_AND_NULL(evti->object_path);
out_4:
FREE_AND_NULL(evti->member_name);
_D("event_name(%s)", event_name);
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) < 0) {
_E("getting gdbus-connetion error");
out_2:
g_variant_unref(value);
out_1:
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
return ret;
}
GVariant *value = NULL;
gint result = 0;
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) < 0) {
_E("getting gdbus-connetion error");
_D("result(%d)", result);
- if (result == 1) {
+ if (result == 1)
ret = ES_R_OK;
- }
out_2:
g_variant_unref(value);
out_1:
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
return ret;
}
GVariant *value = NULL;
gint result = 0;
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) < 0) {
_E("getting gdbus-connetion error");
_D("result(%d)", result);
- if (result == 1) {
+ if (result == 1)
ret = ES_R_OK;
- }
out_2:
g_variant_unref(value);
out_1:
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
return ret;
}
GVariant *value = NULL;
gint result = 0;
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) < 0) {
_E("getting gdbus-connetion error");
_D("result(%d)", result);
- if (result == 1) {
+ if (result == 1)
ret = ES_R_OK;
- }
out_2:
g_variant_unref(value);
out_1:
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
return ret;
}
GVariant *value = NULL;
gint result = 0;
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) < 0) {
_E("getting gdbus-connetion error");
_D("result(%d)", result);
- if (result == 1) {
+ if (result == 1)
ret = ES_R_OK;
- }
out_2:
g_variant_unref(value);
out_1:
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
return ret;
}
char *dest_name = NULL;
gint result = 0;
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) < 0) {
_E("getting gdbus-connetion error");
out_2:
g_variant_unref(value);
out_1:
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
return ret;
}
GError *error = NULL;
GDBusProxy *proxy = NULL;
GVariant *param = NULL;
+ GVariant *value = NULL;
gint result = 0;
bundle_raw *raw = NULL;
int len = 0;
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
if (__get_gdbus_shared_connection(&conn, G_BUS_TYPE_SYSTEM, ES_TYPE_SYSTEM) < 0) {
_E("getting gdbus-connetion error");
}
param = g_variant_new("(s)", event_name);
- GVariant *value = g_dbus_proxy_call_sync(proxy, "GetEarlierData", param,
+ value = g_dbus_proxy_call_sync(proxy, "GetEarlierData", param,
G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (error != NULL) {
_E("proxy call sync error(%s)", error->message);
out_2:
g_variant_unref(value);
out_1:
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
return ret;
}
int ret = 0;
GDBusConnection *conn = NULL;
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
if (__check_eventname_validation_system((char *)event_name)) {
if (__eventsystem_check_privilege_validation(event_name) != ES_R_OK) {
FREE_AND_NULL(interface_name);
FREE_AND_NULL(object_path);
FREE_AND_NULL(member_name);
- if (conn) {
+ if (conn)
g_object_unref(conn);
- }
return ret;
}
retvm_if(reg_id == 0, ES_R_EINVAL, "Invalid argument : reg_id");
- if (!_initialized) {
+ if (!_initialized)
__initialize();
- }
em.reg_id = reg_id;
cb_list = g_list_find_custom(system_event_list, &em,
int eventsystem_application_finalize(void)
{
- gpointer key, value;
+ gpointer key;
+ gpointer value;
+ GHashTableIter iter;
+ char *key_item;
+ char *val_item;
_D("release all resouces");
- if (system_event_list) {
+ if (system_event_list)
g_list_free(system_event_list);
- }
if (check_tbl) {
- GHashTableIter iter;
-
g_hash_table_iter_init(&iter, check_tbl);
while (g_hash_table_iter_next(&iter, &key, &value)) {
- char *val_item = (char *)value;
- if (val_item) {
+ val_item = (char *)value;
+ if (val_item)
free(val_item);
- } else {
+ else
_E("check_tbl, val_item is NULL");
- }
g_hash_table_iter_remove(&iter);
}
g_hash_table_unref(check_tbl);
}
if (filter_tbl) {
- GHashTableIter iter;
-
g_hash_table_iter_init(&iter, filter_tbl);
while (g_hash_table_iter_next(&iter, &key, &value)) {
- char *key_item = (char *)key;
- if (key_item) {
+ key_item = (char *)key;
+ if (key_item)
free(key_item);
- } else {
+ else
_E("filter_tbl, key_item is NULL");
- }
- char *val_item = (char *)value;
- if (val_item) {
+
+ val_item = (char *)value;
+ if (val_item)
free(val_item);
- } else {
+ else
_E("filter_tbl, val_item is NULL");
- }
+
g_hash_table_iter_remove(&iter);
}
g_hash_table_unref(filter_tbl);