#include <ttrace.h>
#endif
-#ifdef HAVE_CYNARA
-#include <cynara-session.h>
-#include <cynara-client.h>
-#include <cynara-creds-socket.h>
-#include <sys/smack.h>
-#endif
-
#include <linux/uinput.h>
#ifdef ENABLE_TTRACE
#define TRACE_INPUT_DEVICE_END()
#endif
-#define DMERR(msg, ARG...) ERR("[%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
-#define DMWRN(msg, ARG...) WRN("[%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
-#define DMINF(msg, ARG...) INF("[%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
-#define DMDBG(msg, ARG...) DBG("[%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
-
#define INPUT_GENERATOR_DEVICE "Input Generator"
#define DETENT_DEVICE_NAME "tizen_detent"
#define INPUTGEN_MAX_BTN 16
-typedef struct _E_Devicemgr_Input_Device_Mgr_Data E_Devicemgr_Input_Device_Mgr_Data;
-typedef struct _E_Devicemgr_Input_Device_User_Data E_Devicemgr_Input_Device_User_Data;
typedef struct _E_Devicemgr_Coords E_Devicemgr_Coords;
typedef struct _E_Devicemgr_Inputgen_Touch_Axis E_Devicemgr_Inputgen_Touch_Axis;
typedef struct _E_Devicemgr_Inputgen_Client_Data E_Devicemgr_Inputgen_Client_Data;
typedef struct _E_Devicemgr_Inputgen_Device_Data E_Devicemgr_Inputgen_Device_Data;
typedef struct _E_Devicemgr_Inputgen_Resource_Data E_Devicemgr_Inputgen_Resource_Data;
-struct _E_Devicemgr_Input_Device_Mgr_Data
-{
- struct wl_resource *resource;
- Eina_Bool is_first_resource : 1;
- Eina_List *user_data_list;
-};
-
-struct _E_Devicemgr_Input_Device_User_Data
-{
- E_Devicemgr_Input_Device *dev;
- struct wl_resource *dev_res;
- struct wl_resource *dev_mgr_res;
- struct wl_resource *seat_res;
- E_Devicemgr_Input_Device_Mgr_Data *mgr_data;
-};
-
struct _E_Devicemgr_Coords
{
int x, y;
E_Devicemgr_Conf_Edd *conf;
};
-struct _E_Devicemgr_Wl_Data
-{
- struct wl_global *global;
- Eina_List *mgr_data_list;
-
-#ifdef HAVE_CYNARA
- cynara *p_cynara;
- Eina_Bool cynara_initialized;
-#endif
-};
-
typedef Eina_Bool (*E_Devicemgr_Intercept_Hook_Cb) (void *data, int point, void *event);
typedef struct _E_Devicemgr_Intercept_Hook E_Devicemgr_Intercept_Hook;
EINTERN void e_devicemgr_conf_init(E_Devicemgr_Config_Data *dconfig);
EINTERN void e_devicemgr_conf_fini(E_Devicemgr_Config_Data *dconfig);
-EINTERN Eina_Bool e_devicemgr_wl_init(void);
-EINTERN void e_devicemgr_wl_shutdown(void);
-
-EINTERN void e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev);
-EINTERN void e_devicemgr_wl_device_del(E_Devicemgr_Input_Device *dev);
-EINTERN void e_devicemgr_wl_device_update(E_Devicemgr_Input_Device *dev);
-
-EINTERN void e_devicemgr_wl_block_send_expired(struct wl_resource *resource);
-EINTERN void e_devicemgr_wl_detent_send_event(int detent);
-EINTERN void e_devicemgr_wl_touch_max_count_send(int slot, struct wl_resource *res, struct wl_resource *seat_res);
-EINTERN void e_devicemgr_wl_generator_with_sync_send_event(struct wl_resource *resource, int error);
-
EINTERN int e_devicemgr_block_add(struct wl_client *client, struct wl_resource *resource, uint32_t clas, uint32_t duration);
EINTERN int e_devicemgr_block_remove(struct wl_client *client);
+#include "e_devicemgr_wl_intern.h"
#include "e_devicemgr_intern.h"
#include "e_input_intern.h"
#include "e_comp_wl_intern.h"
#include "e_privilege_intern.h"
#include "e_security.h"
+#include "e_input_log.h"
#include <tizen-extension-server-protocol.h>
+#ifdef HAVE_CYNARA
+#include <cynara-session.h>
+#include <cynara-client.h>
+#include <cynara-creds-socket.h>
+#include <sys/smack.h>
+#endif
#ifdef HAVE_CYNARA
#define E_DEVMGR_CYNARA_ERROR_CHECK_GOTO(func_name, ret, label) \
} \
} \
while (0)
+#endif
+
+typedef struct _E_Tizen_Devicemgr_Mgr_Data E_Tizen_Devicemgr_Mgr_Data;
+typedef struct _E_Tizen_Devicemgr_User_Data E_Tizen_Devicemgr_User_Data;
+
+struct _E_Tizen_Devicemgr
+{
+ struct wl_global *global;
+ Eina_List *mgr_data_list;
+
+#ifdef HAVE_CYNARA
+ cynara *p_cynara;
+ Eina_Bool cynara_initialized;
+#endif
+};
+
+struct _E_Tizen_Devicemgr_Mgr_Data
+{
+ struct wl_resource *resource;
+ Eina_Bool is_first_resource : 1;
+ Eina_List *user_data_list;
+};
+
+struct _E_Tizen_Devicemgr_User_Data
+{
+ E_Devicemgr_Input_Device *dev;
+ struct wl_resource *dev_res;
+ struct wl_resource *dev_mgr_res;
+ struct wl_resource *seat_res;
+ E_Tizen_Devicemgr_Mgr_Data *mgr_data;
+};
+static E_Tizen_Devicemgr *g_tizen_devicemgr = NULL;
+
+#ifdef HAVE_CYNARA
static void
_e_devicemgr_util_cynara_log(const char *func_name, int err)
{
Eina_Bool res = EINA_FALSE;
/* If initialization of cynara has been failed, let's not to do further permission checks. */
- if (e_devicemgr->wl_data->p_cynara == NULL && e_devicemgr->wl_data->cynara_initialized) return EINA_TRUE;
+ if (g_tizen_devicemgr->p_cynara == NULL && g_tizen_devicemgr->cynara_initialized) return EINA_TRUE;
if (socket_fd < 0) return EINA_FALSE;
ret = cynara_creds_socket_get_user(socket_fd, USER_METHOD_UID, &uid);
};
static void
-_e_devicemgr_wl_device_data_destroy(E_Devicemgr_Input_Device_User_Data *device_user_data)
+_e_devicemgr_wl_device_data_destroy(E_Tizen_Devicemgr_User_Data *device_user_data)
{
if (!device_user_data) return;
static void
_e_devicemgr_wl_device_cb_unbind(struct wl_resource *resource)
{
- E_Devicemgr_Input_Device_User_Data *device_user_data;
+ E_Tizen_Devicemgr_User_Data *device_user_data;
DMDBG("Unbind tizen_input_device: %u (client: %p)", wl_resource_get_id(resource), wl_resource_get_client(resource));
if (!(device_user_data = wl_resource_get_user_data(resource))) return;
Eina_List *l, *ll;
uint32_t serial;
struct wl_client *wc;
- E_Devicemgr_Input_Device_User_Data *device_user_data;
+ E_Tizen_Devicemgr_User_Data *device_user_data;
struct wl_array axes;
- E_Devicemgr_Input_Device_Mgr_Data *mgr_data;
+ E_Tizen_Devicemgr_Mgr_Data *mgr_data;
E_Comp_Wl_Seat *seat_data;
/* TODO: find the seat corresponding to event */
wc = wl_resource_get_client(seat_res);
- EINA_LIST_FOREACH(e_devicemgr->wl_data->mgr_data_list, ll, mgr_data)
+ EINA_LIST_FOREACH(g_tizen_devicemgr->mgr_data_list, ll, mgr_data)
{
dev_mgr_res = mgr_data->resource;
if (wl_resource_get_client(dev_mgr_res) != wc) continue;
break;
}
- device_user_data = E_NEW(E_Devicemgr_Input_Device_User_Data, 1);
+ device_user_data = E_NEW(E_Tizen_Devicemgr_User_Data, 1);
if (!device_user_data)
{
DMERR("Failed to allocate memory for input device user data\n");
{
struct wl_resource *res;
uint32_t serial;
- E_Devicemgr_Input_Device_User_Data *device_user_data;
+ E_Tizen_Devicemgr_User_Data *device_user_data;
serial = wl_display_next_serial(e_comp_wl->wl.disp);
Eina_List *l, *ll;
uint32_t serial;
struct wl_client *wc;
- E_Devicemgr_Input_Device_Mgr_Data *mgr_data;
+ E_Tizen_Devicemgr_Mgr_Data *mgr_data;
serial = wl_display_next_serial(e_comp_wl->wl.disp);
{
wc = wl_resource_get_client(seat_resource);
- EINA_LIST_FOREACH(e_devicemgr->wl_data->mgr_data_list, ll, mgr_data)
+ EINA_LIST_FOREACH(g_tizen_devicemgr->mgr_data_list, ll, mgr_data)
{
dev_mgr_resource = mgr_data->resource;
if (wl_resource_get_client(dev_mgr_resource) != wc) continue;
static void
_e_devicemgr_wl_cb_unbind(struct wl_resource *resource)
{
- E_Devicemgr_Input_Device_Mgr_Data *mgr_data;
- E_Devicemgr_Input_Device_User_Data *device_user_data;
+ E_Tizen_Devicemgr_Mgr_Data *mgr_data;
+ E_Tizen_Devicemgr_User_Data *device_user_data;
if(!e_comp_wl) return;
device_user_data->mgr_data = NULL;
_e_devicemgr_wl_device_data_destroy(device_user_data);
}
- e_devicemgr->wl_data->mgr_data_list = eina_list_remove(e_devicemgr->wl_data->mgr_data_list, mgr_data);
+ g_tizen_devicemgr->mgr_data_list = eina_list_remove(g_tizen_devicemgr->mgr_data_list, mgr_data);
E_FREE(mgr_data);
}
uint32_t serial;
E_Devicemgr_Input_Device *dev;
struct wl_array axes;
- E_Devicemgr_Input_Device_User_Data *device_user_data;
- E_Devicemgr_Input_Device_Mgr_Data *mgr_data, *tmp_data;
+ E_Tizen_Devicemgr_User_Data *device_user_data;
+ E_Tizen_Devicemgr_Mgr_Data *mgr_data, *tmp_data;
- mgr_data = E_NEW(E_Devicemgr_Input_Device_Mgr_Data, 1);
+ mgr_data = E_NEW(E_Tizen_Devicemgr_Mgr_Data, 1);
if (!mgr_data)
{
DMERR("Failed to allocate memory for input device mgr data\n");
}
mgr_data->is_first_resource = 1;
- EINA_LIST_FOREACH(e_devicemgr->wl_data->mgr_data_list, l, tmp_data)
+ EINA_LIST_FOREACH(g_tizen_devicemgr->mgr_data_list, l, tmp_data)
{
if (wl_resource_get_client(tmp_data->resource) != client) continue;
DMDBG("tizen_input_device_manager (res: %d) is already bound to client (%p)",
mgr_data->resource = res;
mgr_data->user_data_list = NULL;
- e_devicemgr->wl_data->mgr_data_list = eina_list_append(e_devicemgr->wl_data->mgr_data_list, mgr_data);
+ g_tizen_devicemgr->mgr_data_list = eina_list_append(g_tizen_devicemgr->mgr_data_list, mgr_data);
wl_resource_set_implementation(res, &_e_devicemgr_wl_implementation, mgr_data,
_e_devicemgr_wl_cb_unbind);
g_rec_mutex_unlock(&e_devicemgr->device_list_mutex);
return;
}
- device_user_data = E_NEW(E_Devicemgr_Input_Device_User_Data, 1);
+ device_user_data = E_NEW(E_Tizen_Devicemgr_User_Data, 1);
if (!device_user_data)
{
DMERR("Failed to allocate memory for input device user data\n");
}
}
-Eina_Bool
-e_devicemgr_wl_init(void)
+E_Tizen_Devicemgr *
+e_devicemgr_wl_init(struct wl_display *display)
{
- if (!e_comp_wl) return EINA_FALSE;
- if (!e_comp_wl->wl.disp) return EINA_FALSE;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(display, NULL);
- if (e_devicemgr->wl_data) return EINA_TRUE;
+ if (g_tizen_devicemgr) return g_tizen_devicemgr;
- e_devicemgr->wl_data = E_NEW(E_Devicemgr_Wl_Data, 1);
- EINA_SAFETY_ON_NULL_RETURN_VAL(e_devicemgr->wl_data, EINA_FALSE);
+ g_tizen_devicemgr = E_NEW(E_Tizen_Devicemgr, 1);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(g_tizen_devicemgr, NULL);
/* try to add tizen_input_device_manager to wayland globals */
- e_devicemgr->wl_data->global = wl_global_create(e_comp_wl->wl.disp,
- &tizen_input_device_manager_interface, 6,
- NULL, _e_devicemgr_wl_cb_bind);
- if (!e_devicemgr->wl_data->global)
+ g_tizen_devicemgr->global = wl_global_create(display,
+ &tizen_input_device_manager_interface, 6,
+ NULL, _e_devicemgr_wl_cb_bind);
+ if (!g_tizen_devicemgr->global)
{
DMERR("Could not add tizen_input_device_manager to wayland globals");
- return EINA_FALSE;
+ return NULL;
}
- e_devicemgr->wl_data->mgr_data_list = NULL;
+ g_tizen_devicemgr->mgr_data_list = NULL;
/* initialization of cynara for checking privilege */
#ifdef HAVE_CYNARA
int ret;
- ret = cynara_initialize(&e_devicemgr->wl_data->p_cynara, NULL);
+ ret = cynara_initialize(&g_tizen_devicemgr->p_cynara, NULL);
if (EINA_UNLIKELY(CYNARA_API_SUCCESS != ret))
{
_e_devicemgr_util_cynara_log("cynara_initialize", ret);
- e_devicemgr->wl_data->p_cynara = NULL;
+ g_tizen_devicemgr->p_cynara = NULL;
}
- e_devicemgr->wl_data->cynara_initialized = EINA_TRUE;
+ g_tizen_devicemgr->cynara_initialized = EINA_TRUE;
#endif
- return EINA_TRUE;
+ return g_tizen_devicemgr;
}
void
e_devicemgr_wl_shutdown(void)
{
- if (!e_devicemgr->wl_data) return;
- /* destroy the global seat resource */
- if (e_devicemgr->wl_data->global)
- wl_global_destroy(e_devicemgr->wl_data->global);
- e_devicemgr->wl_data->global = NULL;
- eina_list_free(e_devicemgr->wl_data->mgr_data_list);
+ if (!g_tizen_devicemgr) return;
/* deinitialization of cynara if it has been initialized */
#ifdef HAVE_CYNARA
- if (e_devicemgr->wl_data->p_cynara) cynara_finish(e_devicemgr->wl_data->p_cynara);
- e_devicemgr->wl_data->cynara_initialized = EINA_FALSE;
+ if (g_tizen_devicemgr->p_cynara)
+ cynara_finish(g_tizen_devicemgr->p_cynara);
#endif
- E_FREE(e_devicemgr->wl_data);
+ eina_list_free(g_tizen_devicemgr->mgr_data_list);
+
+ /* destroy the global seat resource */
+ wl_global_destroy(g_tizen_devicemgr->global);
+
+ E_FREE(g_tizen_devicemgr);
}