upload tizen 2.0 beta code
[profile/ivi/isf.git] / ism / extras / efl_immodule / isf_imf_module.cpp
1 /*
2  * ISF(Input Service Framework)
3  *
4  * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
5  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6  *
7  * Contact: Jihoon Kim <jihoon48.kim@samsung.com>, Haifeng Deng <haifeng.deng@samsung.com>
8  *
9  * This library is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Lesser General Public License as published by the
11  * Free Software Foundation; either version 2.1 of the License, or (at your option)
12  * any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
15  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, write to the Free Software Foundation, Inc., 51
21  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24
25 #include <stdio.h>
26 #include "isf_imf_context.h"
27 #include "isf_imf_control_ui.h"
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif /* __cplusplus */
33
34     static const Ecore_IMF_Context_Info isf_imf_info = {
35         "isf",                                  /* ID */
36         "Input Service Framework for Ecore",    /* Description */
37         "*",                                    /* Default locales */
38         NULL,                                   /* Canvas type */
39         0                                       /* Canvas required */
40     };
41
42     static Ecore_IMF_Context_Class isf_imf_class = {
43         isf_imf_context_add,                    /* add */
44         isf_imf_context_del,                    /* del */
45         isf_imf_context_client_window_set,      /* client_window_set */
46         isf_imf_context_client_canvas_set,      /* client_canvas_set */
47         isf_imf_context_input_panel_show,       /* show */
48         isf_imf_context_input_panel_hide,       /* hide */
49         isf_imf_context_preedit_string_get,     /* get_preedit_string */
50         isf_imf_context_focus_in,               /* focus_in */
51         isf_imf_context_focus_out,              /* focus_out */
52         isf_imf_context_reset,                  /* reset */
53         isf_imf_context_cursor_position_set,    /* cursor_position_set */
54         isf_imf_context_use_preedit_set,        /* use_preedit_set */
55         isf_imf_context_input_mode_set,         /* input_mode_set */
56         isf_imf_context_filter_event,           /* filter_event */
57         isf_imf_context_preedit_string_with_attributes_get,
58         isf_imf_context_prediction_allow_set,
59         isf_imf_context_autocapital_type_set,
60         isf_imf_context_control_panel_show,
61         isf_imf_context_control_panel_hide,
62         isf_imf_context_input_panel_layout_set,
63         isf_imf_context_input_panel_layout_get,
64         isf_imf_context_input_panel_language_set,
65         isf_imf_context_input_panel_language_get,
66         isf_imf_context_cursor_location_set,
67         isf_imf_context_imdata_set,
68         isf_imf_context_imdata_get,
69         isf_imf_context_input_panel_return_key_type_set,
70         isf_imf_context_input_panel_return_key_disabled_set,
71         isf_imf_context_input_panel_caps_lock_mode_set,
72         isf_imf_context_input_panel_geometry_get,
73         isf_imf_context_input_panel_state_get,
74         isf_imf_context_input_panel_event_callback_add,
75         isf_imf_context_input_panel_event_callback_del,
76         isf_imf_context_input_panel_language_locale_get,
77         isf_imf_context_candidate_window_geometry_get
78     };
79
80     static Ecore_IMF_Context *imf_module_create (void);
81     static Ecore_IMF_Context *imf_module_exit (void);
82
83     static Eina_Bool imf_module_init (void) {
84         ecore_imf_module_register (&isf_imf_info, imf_module_create, imf_module_exit);
85         register_key_handler ();
86         return EINA_TRUE;
87     }
88
89     static void imf_module_shutdown (void) {
90         unregister_key_handler ();
91         isf_imf_context_shutdown ();
92     }
93
94     static Ecore_IMF_Context *imf_module_create (void) {
95         Ecore_IMF_Context  *ctx = NULL;
96         EcoreIMFContextISF *ctxd = NULL;
97
98         ctxd = isf_imf_context_new ();
99         if (!ctxd) {
100             printf ("isf_imf_context_new () failed!!!\n");
101             return NULL;
102         }
103
104         ctx = ecore_imf_context_new (&isf_imf_class);
105         if (!ctx) {
106             delete ctxd;
107             return NULL;
108         }
109
110         ecore_imf_context_data_set (ctx, ctxd);
111
112         return ctx;
113     }
114
115     static Ecore_IMF_Context *imf_module_exit (void) {
116         return NULL;
117     }
118
119     EINA_MODULE_INIT(imf_module_init);
120     EINA_MODULE_SHUTDOWN(imf_module_shutdown);
121
122 #ifdef __cplusplus
123 }
124 #endif /* __cplusplus */
125
126 /*
127 vi:ts=4:expandtab:nowrap
128 */