39b6aec481406bbbbacfe8a55fe73be9ff71a54c
[platform/core/uifw/isf.git] / ism / src / isf_remote_control.h
1 #ifndef _ISF_REMOTE_CONTROL_H_
2 #define _ISF_REMOTE_CONTROL_H_
3
4 /**
5  * @file isf_remote_control.h
6  * @brief This file contains remote control APIs for TV profile.
7  */
8
9 #include <Ecore_IMF.h>
10 #include <scim_visibility.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif /* __cplusplus */
15
16 /**
17  * @brief Enumeration for remote control function error.
18  *
19  * @since_tizen @if TV 3.0 @endif
20  */
21 typedef enum {
22     REMOTE_CONTROL_ERROR_NONE = 0, /**< Successful */
23     REMOTE_CONTROL_PERMISSION_DENIED, /**< Permission denied */
24     REMOTE_CONTROL_REPLY_TIMEOUT, /**< Reply timeout */
25     REMOTE_CONTROL_CONNECTION_LOST, /**< Connection to server lost */
26     REMOTE_CONTROL_INVALID_OPERATION, /**< Invalid operation */
27     REMOTE_CONTROL_INVALID_PARAMETER, /**< Invalid parameter */
28 } remote_control_error_e;
29
30 /**
31  * @brief Enumeration for key types.
32  *
33  * @since_tizen @if TV 3.0 @endif
34  *
35  * @see remote_control_send_key_event()
36  */
37 typedef enum {
38     REMOTE_CONTROL_KEY_ENTER = 0, /**< Enter key */
39     REMOTE_CONTROL_KEY_SPACE, /**< Space key */
40     REMOTE_CONTROL_KEY_BACKSPACE, /**< Backspace key */
41     REMOTE_CONTROL_KEY_ESC, /**< Escape key */
42     REMOTE_CONTROL_KEY_UP, /**< Up key */
43     REMOTE_CONTROL_KEY_DOWN, /**< Down key */
44     REMOTE_CONTROL_KEY_LEFT, /**< LEFT key */
45     REMOTE_CONTROL_KEY_RIGHT, /**< Right key */
46     REMOTE_CONTROL_KEY_PAGE_UP, /**< Page up key */
47     REMOTE_CONTROL_KEY_PAGE_DOWN, /**< Page down key */
48     REMOTE_CONTROL_KEY_SELECT, /**< Select key */
49     REMOTE_CONTROL_KEY_CANCEL, /**< Cancel key */
50 } remote_control_key_type_e;
51
52 /**
53  * @brief Enumeration for input resources.
54  *
55  * @since_tizen @if TV 3.0 @endif
56  *
57  * @see remote_control_input_resource_changed_cb()
58  */
59 typedef enum {
60     REMOTE_CONTROL_INPUT_RESOURCE_LOCAL, /**< Input event from TV IME, H/W keyboard */
61     REMOTE_CONTROL_INPUT_RESOURCE_REMOTE, /**< Input event from remote control API */
62 } remote_control_input_resource;
63
64 /**
65  * @brief The structure type to contain the attributes of text field.
66  *
67  * @since_tizen @if TV 3.0 @endif
68  *
69  * @see remote_control_entry_metadata_cb
70  */
71 typedef struct {
72     Ecore_IMF_Input_Hints hint; /**< The input hint information */
73     Ecore_IMF_Input_Panel_Layout layout; /**< The layout information */
74     int variation; /**< The layout variation information */
75     Ecore_IMF_Autocapital_Type autocapital_type; /**< The autocapital type information */
76     bool return_key_disabled; /**< The return key state information */
77     Ecore_IMF_Input_Panel_Return_Key_Type return_key_type; /**< The return key type information */
78 } remote_control_entry_metadata_s;
79
80 /**
81  * @brief A structure type to contain the attributes for socket and callback function.
82  *
83  * @since_tizen @if TV 3.0 @endif
84  *
85  * @see remote_control_connect()
86  */
87 typedef struct _remote_control_client remote_control_client;
88
89 /**
90  * @brief Creates a new remote control client.
91  *
92  * @details This function provides socket connection and register a fd_handler for the callback function.
93  *
94  * @since_tizen @if TV 3.0 @endif
95  *
96  * @privlevel platform
97  *
98  * @privilege %http://tizen.org/privilege/imemanager
99  *
100  * @return The remote control client on success, otherwise NULL
101  *
102  * @see remote_control_disconnect()
103  */
104 remote_control_client * remote_control_connect(void);
105
106 /**
107  * @brief Destroys a remote control client.
108  *
109  * @since_tizen @if TV 3.0 @endif
110  *
111  * @privlevel platform
112  *
113  * @privilege %http://tizen.org/privilege/imemanager
114  *
115  * @param[in] client The remote control client
116  *
117  * @return 0 on success, otherwise a negative error value
118  * @retval #REMOTE_CONTROL_ERROR_NONE No error
119  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
120  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
121  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
122  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
123  *
124  * @see remote_control_connect()
125  */
126 int remote_control_disconnect(remote_control_client *client);
127
128 /**
129  * @brief Called when an associated text field has focus.
130  *
131  * @since_tizen @if TV 3.0 @endif
132  *
133  * @privlevel platform
134  *
135  * @privilege %http://tizen.org/privilege/imemanager
136  *
137  * @param[in] user_data User data to be passed from the callback registration function
138  *
139  * @pre The callback can be registered using remote_control_focus_in_callback_set() function.
140  *
141  * @see remote_control_focus_in_callback_set()
142  * @see remote_control_focus_in_callback_unset()
143  */
144 typedef void (*remote_control_focus_in_cb)(void *user_data);
145
146 /**
147  * @brief Register a callback function to be called when an associated text field has focus.
148  *
149  * @since_tizen @if TV 3.0 @endif
150  *
151  * @privlevel platform
152  *
153  * @privilege %http://tizen.org/privilege/imemanager
154  *
155  * @param[in] client The remote control client
156  * @param[in] func focus_in event callback function
157  * @param[in] user_data User data to be passed to the callback function
158  *
159  * @return 0 on success, otherwise a negative error value
160  * @retval #REMOTE_CONTROL_ERROR_NONE No error
161  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
162  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
163  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
164  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
165  *
166  * @see remote_control_focus_in_cb()
167  * @see remote_control_focus_in_callback_unset()
168  */
169 int remote_control_focus_in_callback_set(remote_control_client *client, remote_control_focus_in_cb func, void *user_data);
170
171 /**
172  * @brief Remove a remote_control_focus_in_cb() callback function.
173  *
174  * @since_tizen @if TV 3.0 @endif
175  *
176  * @privlevel platform
177  *
178  * @privilege %http://tizen.org/privilege/imemanager
179  *
180  * @param[in] client The remote control client
181  *
182  * @return 0 on success, otherwise a negative error value
183  * @retval #REMOTE_CONTROL_ERROR_NONE No error
184  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
185  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
186  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
187  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
188  *
189  * @see remote_control_focus_in_cb()
190  * @see remote_control_focus_in_callback_set()
191  */
192 int remote_control_focus_in_callback_unset(remote_control_client *client);
193
194 /**
195  * @brief Called when an associated text field loses focus.
196  *
197  * @since_tizen @if TV 3.0 @endif
198  *
199  * @privlevel platform
200  *
201  * @privilege %http://tizen.org/privilege/imemanager
202  *
203  * @param[in] user_data User data to be passed from the callback registration function
204  *
205  * @pre The callback can be registered using remote_control_focus_out_callback_set() function.
206  *
207  * @see remote_control_focus_out_callback_set()
208  * @see remote_control_focus_out_callback_unset()
209  */
210 typedef void (*remote_control_focus_out_cb)(void *user_data);
211
212 /**
213  * @brief Register a callback function to be called when an associated text field loses focus.
214  *
215  * @since_tizen @if TV 3.0 @endif
216  *
217  * @privlevel platform
218  *
219  * @privilege %http://tizen.org/privilege/imemanager
220  *
221  * @param[in] client The remote control client
222  * @param[in] func focus_out event callback function
223  * @param[in] user_data User data to be passed to the callback function
224  *
225  * @return 0 on success, otherwise a negative error value
226  * @retval #REMOTE_CONTROL_ERROR_NONE No error
227  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
228  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
229  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
230  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
231  *
232  * @see remote_control_focus_out_cb()
233  * @see remote_control_focus_out_callback_unset()
234  */
235 int remote_control_focus_out_callback_set(remote_control_client *client, remote_control_focus_out_cb func , void *user_data);
236
237 /**
238  * @brief Remove a remote_control_focus_out_cb() callback function.
239  *
240  * @since_tizen @if TV 3.0 @endif
241  *
242  * @privlevel platform
243  *
244  * @privilege %http://tizen.org/privilege/imemanager
245  *
246  * @param[in] client The remote control client
247  *
248  * @return 0 on success, otherwise a negative error value
249  * @retval #REMOTE_CONTROL_ERROR_NONE No error
250  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
251  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
252  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
253  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
254  *
255  * @see remote_control_focus_out_cb()
256  * @see remote_control_focus_out_callback_set()
257  */
258 int remote_control_focus_out_callback_unset(remote_control_client *client);
259
260 /**
261  * @brief Called when an associated text field requests the input panel to set its attributes.
262  *
263  * @since_tizen @if TV 3.0 @endif
264  *
265  * @privlevel platform
266  *
267  * @privilege %http://tizen.org/privilege/imemanager
268  *
269  * @remarks remote_control_entry_metadata_cb() will be called after focus_in event and it can be called again when the associated text field's attributes are changed
270  *
271  * @param[in] user_data User data to be passed from the callback registration function
272  * @param[in] data The structure pointer of text field attributes
273  *
274  * @pre The callback can be registered using remote_control_entry_metadata_callback_set() function.
275  *
276  * @see remote_control_entry_metadata_callback_set()
277  * @see remote_control_entry_metadata_callback_unset()
278  */
279 typedef void (*remote_control_entry_metadata_cb)(void *user_data, remote_control_entry_metadata_s *data);
280
281 /**
282  * @brief Register a remote_control_entry_metadata_cb() callback function.
283  *
284  * @since_tizen @if TV 3.0 @endif
285  *
286  * @privlevel platform
287  *
288  * @privilege %http://tizen.org/privilege/imemanager
289  *
290  * @param[in] client The remote control client
291  * @param[in] func remote_control_entry_metadata_cb() callback function
292  * @param[in] user_data User data to be passed to the callback function
293  *
294  * @return 0 on success, otherwise a negative error value
295  * @retval #REMOTE_CONTROL_ERROR_NONE No error
296  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
297  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
298  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
299  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
300  *
301  * @see remote_control_entry_metadata_cb()
302  * @see remote_control_entry_metadata_callback_unset()
303  */
304 int remote_control_entry_metadata_callback_set(remote_control_client *client, remote_control_entry_metadata_cb func, void *user_data);
305
306 /**
307  * @brief Remove a remote_control_entry_metadata_cb() callback function.
308  *
309  * @since_tizen @if TV 3.0 @endif
310  *
311  * @privlevel platform
312  *
313  * @privilege %http://tizen.org/privilege/imemanager
314  *
315  * @param[in] client The remote control client
316  *
317  * @return 0 on success, otherwise a negative error value
318  * @retval #REMOTE_CONTROL_ERROR_NONE No error
319  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
320  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
321  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
322  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
323  *
324  * @see remote_control_entry_metadata_cb()
325  * @see remote_control_entry_metadata_callback_set()
326  */
327 int remote_control_entry_metadata_callback_unset(remote_control_client *client);
328
329 /**
330  * @brief Called when an associated text field responds to a request with the surrounding text.
331  *
332  * @since_tizen @if TV 3.0 @endif
333  *
334  * @privlevel platform
335  *
336  * @privilege %http://tizen.org/privilege/imemanager
337  *
338  * @remarks remote_control_text_updated_cb() will be called after remote_control_entry_metadata_cb() and it can be called again when the text or the cursor position in the associated text field is changed
339  *
340  * @param[in] user_data User data to be passed from the callback registration function
341  * @param[in] surrounding_text The UTF-8 string requested
342  * @param[in] cursor_pos The cursor position
343  *
344  * @pre The callback can be registered using remote_control_text_updated_callback_set() function.
345  *
346  * @see remote_control_text_updated_callback_set()
347  * @see remote_control_text_updated_callback_unset()
348  */
349 typedef void (*remote_control_text_updated_cb)(void *user_data, const char *surrounding_text, int cursor_pos);
350
351 /**
352  * @brief Register a remote_control_text_updated_cb() callback function.
353  *
354  * @since_tizen @if TV 3.0 @endif
355  *
356  * @privlevel platform
357  *
358  * @privilege %http://tizen.org/privilege/imemanager
359  *
360  * @param[in] client The remote control client
361  * @param[in] func remote_control_text_updated_cb() callback function
362  * @param[in] user_data User data to be passed to the callback function
363  *
364  * @return 0 on success, otherwise a negative error value
365  * @retval #REMOTE_CONTROL_ERROR_NONE No error
366  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
367  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
368  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
369  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
370  *
371  * @see remote_control_text_updated_cb()
372  * @see remote_control_text_updated_callback_unset()
373  */
374 int remote_control_text_updated_callback_set(remote_control_client *client, remote_control_text_updated_cb func, void *user_data);
375
376 /**
377  * @brief Remove a remote_control_text_updated_cb() callback function.
378  *
379  * @since_tizen @if TV 3.0 @endif
380  *
381  * @privlevel platform
382  *
383  * @privilege %http://tizen.org/privilege/imemanager
384  *
385  * @param[in] client The remote control client
386  *
387  * @return 0 on success, otherwise a negative error value
388  * @retval #REMOTE_CONTROL_ERROR_NONE No error
389  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
390  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
391  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
392  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
393  *
394  * @see remote_control_text_updated_cb()
395  * @see remote_control_text_updated_callback_set()
396  */
397 int remote_control_text_updated_callback_unset(remote_control_client *client);
398
399 /**
400  * @brief Called when the input resource is changed.
401  *
402  * @since_tizen @if TV 3.0 @endif
403  *
404  * @privlevel platform
405  *
406  * @privilege %http://tizen.org/privilege/imemanager
407  *
408  * @param[in] user_data User data to be passed from the callback registration function
409  * @param[in] resource local input event callback function
410  *
411  * @pre The callback can be registered using remote_control_input_resource_changed_callback_set() function.
412  *
413  * @see remote_control_local_input_callback_set()
414  * @see remote_control_local_input_callback_unset()
415  */
416 typedef void (*remote_control_input_resource_changed_cb)(void *user_data, remote_control_input_resource resource);
417
418 /**
419  * @brief Register a callback function to be called when the input resource is changed.
420  *
421  * @since_tizen @if TV 3.0 @endif
422  *
423  * @privlevel platform
424  *
425  * @privilege %http://tizen.org/privilege/imemanager
426  *
427  * @param[in] client The remote control client
428  * @param[in] func Input resource changed callback function
429  * @param[in] user_data User data to be passed to the callback function
430  *
431  * @return 0 on success, otherwise a negative error value
432  * @retval #REMOTE_CONTROL_ERROR_NONE No error
433  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
434  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
435  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
436  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
437  *
438  * @see remote_control_input_resource_changed_cb()
439  * @see remote_control_input_resource_changed_callback_unset()
440  */
441 int remote_control_input_resource_changed_callback_set(remote_control_client *client, remote_control_input_resource_changed_cb func , void *user_data);
442
443 /**
444  * @brief Remove a remote_control_input_resource_changed_cb() callback function.
445  *
446  * @since_tizen @if TV 3.0 @endif
447  *
448  * @privlevel platform
449  *
450  * @privilege %http://tizen.org/privilege/imemanager
451  *
452  * @param[in] client The remote control client
453  *
454  * @return 0 on success, otherwise a negative error value
455  * @retval #REMOTE_CONTROL_ERROR_NONE No error
456  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
457  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
458  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
459  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
460  *
461  * @see remote_control_input_resource_changed_cb()
462  * @see remote_control_input_resource_changed_callback_set()
463  */
464 int remote_control_input_resource_changed_callback_unset(remote_control_client *client);
465
466 /**
467  * @brief Sends the key event to the associated text field.
468  *
469  * @since_tizen @if TV 3.0 @endif
470  *
471  * @privlevel platform
472  *
473  * @privilege %http://tizen.org/privilege/imemanager
474  *
475  * @param[in] client The remote control client
476  * @param[in] key The remote_control_key_type_e information
477  *
478  * @return 0 on success, otherwise a negative error value
479  * @retval #REMOTE_CONTROL_ERROR_NONE No error
480  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
481  * @retval #REMOTE_CONTROL_INVALID_OPERATION Invalid operation
482  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
483  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
484  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
485  *
486  * @see remote_control_key_type_e
487  */
488 int remote_control_send_key_event(remote_control_client *client, remote_control_key_type_e key);
489
490 /**
491  * @brief Sends the text to the associated text field.
492  *
493  * @since_tizen @if TV 3.0 @endif
494  *
495  * @privlevel platform
496  *
497  * @privilege %http://tizen.org/privilege/imemanager
498  *
499  * @param[in] client The remote control client
500  * @param[in] text The UTF-8 string to be committed
501  *
502  * @return 0 on success, otherwise a negative error value
503  * @retval #REMOTE_CONTROL_ERROR_NONE No error
504  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
505  * @retval #REMOTE_CONTROL_INVALID_OPERATION Invalid operation
506  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
507  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
508  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
509  *
510  * @see remote_control_update_preedit_string()
511  */
512 int remote_control_send_commit_string(remote_control_client *client, const char *text);
513
514 /**
515  * @brief Updates a new preedit string to the associated text field.
516  *
517  * @since_tizen @if TV 3.0 @endif
518  *
519  * @privlevel platform
520  *
521  * @privilege %http://tizen.org/privilege/imemanager
522  *
523  * @param[in] client The remote control client
524  * @param[in] text The UTF-8 string to be updated in preedit
525  * @param[in] attrs An Eina_List of attributes
526  * @param[in] cursor_pos The cursor position; -1 means at the end of line
527  *
528  * @return 0 on success, otherwise a negative error value
529  * @retval #REMOTE_CONTROL_ERROR_NONE No error
530  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
531  * @retval #REMOTE_CONTROL_INVALID_OPERATION Invalid operation
532  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
533  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
534  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
535  *
536  * @see remote_control_send_commit_string()
537  */
538 int remote_control_update_preedit_string(remote_control_client *client, const char *text, Eina_List *attrs, int cursor_pos);
539
540 /**
541  * @brief Requests to delete surrounding text.
542  *
543  * @since_tizen @if TV 3.0 @endif
544  *
545  * @privlevel platform
546  *
547  * @privilege %http://tizen.org/privilege/imemanager
548  *
549  * @param[in] client The remote control client
550  * @param[in] offset The offset value from the cursor position
551  * @param[in] len The length of the text to delete
552  *
553  * @return 0 on success, otherwise a negative error value
554  * @retval #REMOTE_CONTROL_ERROR_NONE No error
555  * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function
556  * @retval #REMOTE_CONTROL_INVALID_OPERATION Invalid operation
557  * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter
558  * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Reply timeout
559  * @retval #REMOTE_CONTROL_CONNECTION_LOST Connection to server lost
560  */
561 int remote_control_delete_surrounding_text(remote_control_client *client, int offset, int len);
562
563 #ifdef __cplusplus
564 }
565 #endif /* __cplusplus */
566
567 #endif