Add a pid in logs
[platform/core/uifw/e-mod-tizen-keyrouter.git] / src / e_mod_main_wl.h
1 #ifndef E_MOD_MAIN_H
2 #define E_MOD_MAIN_H
3
4 #include <e.h>
5 #include <tizen-extension-server-protocol.h>
6 #ifdef ENABLE_CYNARA
7 #include <cynara-session.h>
8 #include <cynara-client.h>
9 #include <cynara-creds-socket.h>
10 #endif
11
12 #ifdef TRACE_INPUT_BEGIN
13 #undef TRACE_INPUT_BEGIN
14 #endif
15 #ifdef TRACE_INPUT_END
16 #undef TRACE_INPUT_END
17 #endif
18
19 #ifdef ENABLE_TTRACE
20 #include <ttrace.h>
21
22 #define TRACE_INPUT_BEGIN(NAME) traceBegin(TTRACE_TAG_INPUT, "INPUT:KRT:"#NAME)
23 #define TRACE_INPUT_END() traceEnd(TTRACE_TAG_INPUT)
24 #else
25 #define TRACE_INPUT_BEGIN(NAME)
26 #define TRACE_INPUT_END()
27 #endif
28
29 /* Temporary value of maximum number of HWKeys */
30
31 #define CHECK_ERR(val) if (TIZEN_KEYROUTER_ERROR_NONE != val) return;
32 #define CHECK_ERR_VAL(val) if (TIZEN_KEYROUTER_ERROR_NONE != val) return val;
33 #define CHECK_NULL(val) if (!val) return;
34 #define CHECK_NULL_VAL(val) if (!val) return val;
35
36 #define KLERR(msg, ARG...) ERR("[tizen_keyrouter][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
37 #define KLWRN(msg, ARG...) WRN("[tizen_keyrouter][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
38 #define KLINF(msg, ARG...) INF("[tizen_keyrouter][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
39 #define KLDBG(msg, ARG...) DBG("[tizen_keyrouter][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG)
40
41 typedef struct _E_Keyrouter E_Keyrouter;
42 typedef struct _E_Keyrouter* E_KeyrouterPtr;
43 typedef struct _E_Keyrouter_Key_List_Node E_Keyrouter_Key_List_Node;
44 typedef struct _E_Keyrouter_Key_List_Node* E_Keyrouter_Key_List_NodePtr;
45 typedef struct _E_Keyrouter_Tizen_HWKey E_Keyrouter_Tizen_HWKey;
46 typedef struct _E_Keyrouter_Grabbed_Key E_Keyrouter_Grabbed_Key;
47 typedef struct _E_Keyrouter_Grab_Request E_Keyrouter_Grab_Request;
48 typedef struct _E_Keyrouter_Grab_Result E_Keyrouter_Grab_Result;
49 typedef struct _E_Keyrouter_Registered_Window_Info E_Keyrouter_Registered_Window_Info;
50
51 typedef struct _E_Keyrouter_Conf_Edd E_Keyrouter_Conf_Edd;
52 typedef struct _E_Keyrouter_Config_Data E_Keyrouter_Config_Data;
53
54 #define TIZEN_KEYROUTER_MODE_PRESSED        TIZEN_KEYROUTER_MODE_REGISTERED+1
55
56 extern E_KeyrouterPtr krt;
57
58 struct _E_Keyrouter_Conf_Edd
59 {
60    int num_keycode;
61    int max_keycode;
62    Eina_List *KeyList;
63 };
64
65 struct _E_Keyrouter_Config_Data
66 {
67    E_Module *module;
68    E_Config_DD *conf_edd;
69    E_Config_DD *conf_hwkeys_edd;
70    E_Keyrouter_Conf_Edd *conf;
71 };
72
73 struct _E_Keyrouter_Registered_Window_Info
74 {
75    struct wl_resource *surface;
76    Eina_List *keys;
77 };
78
79 struct _E_Keyrouter_Key_List_Node
80 {
81    struct wl_resource *surface;
82    struct wl_client *wc;
83 };
84
85 struct _E_Keyrouter_Tizen_HWKey
86 {
87    char *name;
88    int keycode;
89    int no_privcheck;
90 };
91
92 struct _E_Keyrouter_Grabbed_Key
93 {
94    int keycode;
95    char* keyname;
96    Eina_Bool no_privcheck;
97
98    Eina_List *excl_ptr;
99    Eina_List *or_excl_ptr;
100    Eina_List *top_ptr;
101    Eina_List *shared_ptr;
102    Eina_List *press_ptr;
103    E_Keyrouter_Key_List_Node *registered_ptr;
104 };
105
106 struct _E_Keyrouter
107 {
108    struct wl_global *global;
109    Ecore_Event_Filter *ef_handler;
110    Eina_List *handlers;
111
112    E_Keyrouter_Config_Data *conf;
113
114    E_Keyrouter_Grabbed_Key *HardKeys;
115    Eina_List *grab_surface_list;
116    Eina_List *grab_client_list;
117
118    Eina_List *registered_window_list;
119
120    Eina_Bool isWindowStackChanged;
121    int numTizenHWKeys;
122    int max_tizen_hwkeys;
123 #ifdef ENABLE_CYNARA
124    cynara *p_cynara;
125 #endif
126 };
127
128 struct _E_Keyrouter_Grab_Request {
129    int key;
130    int mode;
131 };
132
133 struct _E_Keyrouter_Grab_Result {
134    E_Keyrouter_Grab_Request request_data;
135    int err;
136 };
137
138
139 /* E Module */
140 E_API extern E_Module_Api e_modapi;
141 E_API void *e_modapi_init(E_Module *m);
142 E_API int   e_modapi_shutdown(E_Module *m);
143 E_API int   e_modapi_save(E_Module *m);
144
145 int e_keyrouter_set_keygrab_in_list(struct wl_resource *surface, struct wl_client *client, uint32_t key, uint32_t mode);
146 int e_keyrouter_prepend_to_keylist(struct wl_resource *surface, struct wl_client *wc, uint32_t key, uint32_t mode);
147 void e_keyrouter_find_and_remove_client_from_list(struct wl_resource *surface, struct wl_client *wc, uint32_t key, uint32_t mode);
148 void e_keyrouter_remove_client_from_list(struct wl_resource *surface, struct wl_client *wc);
149 int e_keyrouter_find_key_in_list(struct wl_resource *surface, struct wl_client *wc, uint32_t key);
150
151 int e_keyrouter_add_client_destroy_listener(struct wl_client *client);
152 int e_keyrouter_add_surface_destroy_listener(struct wl_resource *surface);
153
154 Eina_Bool e_keyrouter_process_key_event(void *event, int type);
155
156 int e_keyrouter_set_keyregister(struct wl_client *client, struct wl_resource *surface, uint32_t key);
157 int e_keyrouter_unset_keyregister(struct wl_resource *surface, struct wl_client *client, uint32_t key);
158 Eina_Bool e_keyrouter_is_registered_window(struct wl_resource *surface);
159 void e_keyrouter_clear_registered_window(void);
160
161 struct wl_resource *e_keyrouter_util_get_surface_from_eclient(E_Client *client);
162 int e_keyrouter_util_get_pid(struct wl_client *client, struct wl_resource *surface);
163
164 void e_keyrouter_conf_init(E_Keyrouter_Config_Data *kconfig);
165 void e_keyrouter_conf_deinit(E_Keyrouter_Config_Data *kconfig);
166
167 #endif