#define DEVICE_CALLBACK_KEY_INPUT_SIZE (DEVICE_CALLBACK_KEY_INPUT_MAX - DEVICE_CALLBACK_KEY_INPUT_MIN)
static GList *device_cb_list[DEVICE_CALLBACK_MAX];
-static GList *device_key_cb_list;
+static GList *deviced_internal_event_list;
static int flash_sigid;
-static int key_sigid;
+static int event_sigid;
//LCOV_EXCL_START Not called Callback
static void battery_capacity_cb(keynode_t *key, void *data)
//LCOV_EXCL_STOP
//LCOV_EXCL_START Target specific callback
-static void key_input_cb(GDBusConnection *conn,
+static void deviced_internal_event_cb(GDBusConnection *conn,
const gchar *sender,
const gchar *object,
const gchar *interface,
int type = 0;
g_variant_get(parameters, "(i)", &type);
- if (type < DEVICE_CALLBACK_KEY_INPUT_MIN || type >= DEVICE_CALLBACK_KEY_INPUT_MAX)
- return;
- SYS_G_LIST_FOREACH_SAFE(device_key_cb_list, elem, elem_next, cb_info) {
+ SYS_G_LIST_FOREACH_SAFE(deviced_internal_event_list, elem, elem_next, cb_info) {
if (cb_info->type == type)
cb_info->cb(type, NULL, cb_info->data);
}
if (flash_sigid)
return -EEXIST;
return register_signal(DEVICED_BUS_NAME,
- DEVICED_PATH_LED,
- DEVICED_INTERFACE_LED,
- SIGNAL_FLASH_STATE, flash_state_cb, &flash_sigid);
+ DEVICED_PATH_LED,
+ DEVICED_INTERFACE_LED,
+ SIGNAL_FLASH_STATE, flash_state_cb, &flash_sigid);
default:
- if (type >= DEVICE_CALLBACK_KEY_INPUT_MIN && type < DEVICE_CALLBACK_KEY_INPUT_MAX) {
- if (key_sigid)
- return -EEXIST;
- return register_signal(DEVICED_BUS_NAME,
- DEVICED_PATH_INPUT,
- DEVICED_INTERFACE_INPUT,
- "Key", key_input_cb, &key_sigid);
- }
+ if (event_sigid)
+ return -EEXIST;
+ return register_signal(DEVICED_BUS_NAME,
+ "/Org/Tizen/System/DeviceD/Event",
+ "org.tizen.system.deviced.Event",
+ "Id", deviced_internal_event_cb, &event_sigid);
break;
}
return -ENOENT;
return unregister_signal(&flash_sigid);
default:
- if (type >= DEVICE_CALLBACK_KEY_INPUT_MIN && type < DEVICE_CALLBACK_KEY_INPUT_MAX) {
- if (!key_sigid)
- return -ENOENT;
- return unregister_signal(&key_sigid);
- }
+ if (!event_sigid)
+ return -ENOENT;
+ return unregister_signal(&event_sigid);
break;
}
int ret_request, n;
int type = (int) enumtype;
- if ((type < 0 || type >= DEVICE_CALLBACK_MAX)
- && (type < DEVICE_CALLBACK_KEY_INPUT_MIN || type >= DEVICE_CALLBACK_KEY_INPUT_MAX))
- return DEVICE_ERROR_INVALID_PARAMETER;
-
- if (!cb)
+ if (type < 0 || !cb)
return DEVICE_ERROR_INVALID_PARAMETER;
if (device_callback_check_feature_supported(type) != 0)
if (type >= 0 && type < DEVICE_CALLBACK_MAX)
cb_list = &device_cb_list[type];
- else if (type >= DEVICE_CALLBACK_KEY_INPUT_MIN && type < DEVICE_CALLBACK_KEY_INPUT_MAX)
- cb_list = &device_key_cb_list;
else
- return DEVICE_ERROR_INVALID_PARAMETER;
+ cb_list = &deviced_internal_event_list;
/* check if it is the first request */
n = SYS_G_LIST_LENGTH(*cb_list);
/* check for the same request */
SYS_G_LIST_FOREACH_SAFE(*cb_list, elem, elem_next, cb_info) {
- if (cb_info->cb == cb)
+ if (cb_info->type == type && cb_info->cb == cb)
return DEVICE_ERROR_ALREADY_IN_PROGRESS;
}
int ret_request, n;
int type = (int) enumtype;
- if ((type < 0 || type >= DEVICE_CALLBACK_MAX)
- && (type < DEVICE_CALLBACK_KEY_INPUT_MIN || type >= DEVICE_CALLBACK_KEY_INPUT_MAX))
- return DEVICE_ERROR_INVALID_PARAMETER;
-
- if (!cb)
+ if (type < 0 || !cb)
return DEVICE_ERROR_INVALID_PARAMETER;
if (device_callback_check_feature_supported(type) != 0)
if (type >= 0 && type < DEVICE_CALLBACK_MAX)
cb_list = &device_cb_list[type];
- else if (type >= DEVICE_CALLBACK_KEY_INPUT_MIN && type < DEVICE_CALLBACK_KEY_INPUT_MAX)
- cb_list = &device_key_cb_list;
else
- return DEVICE_ERROR_INVALID_PARAMETER;
+ cb_list = &deviced_internal_event_list;
/* search for the same element with callback */
SYS_G_LIST_FOREACH_SAFE(*cb_list, elem, elem_next, cb_info) {
- if (cb_info->cb == cb)
+ if (cb_info->type == type && cb_info->cb == cb)
break;
}