f4342fea1e3a6078588ec3f5572133bd4627acea
[platform/core/uifw/isf.git] / ism / extras / kbd_mode_changer / main.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) 2012-2015 Samsung Electronics Co., Ltd.
6  *
7  * Contact: Wonkeun Oh <wonkeun.oh@samsung.com>, Jihoon Kim <jihoon48.kim@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 <tizen.h>
26 #ifdef HAVE_VCONF
27 #include <vconf.h>
28 #endif
29 #include "main.h"
30
31 static bool app_create (void *user_data)
32 {
33     LOGD ("app create");
34     return true;
35 }
36
37 static void app_control (app_control_h app_control, void *user_data)
38 {
39     LOGD ("%s", __func__);
40
41     LOGD ("isf_extra_hwkbd_module start");
42
43     /* Toggle input mode */
44 #ifdef HAVE_VCONF
45     int val = 1;
46     if (vconf_get_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, &val) != 0)
47         LOGW ("Failed to get vconf key");
48
49     if (vconf_set_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, !val) != 0)
50         LOGW ("Failed to set vconf key");
51     else
52         LOGD ("Succeeded to set vconf key");
53 #endif
54
55     service_app_exit ();
56 }
57
58 static void app_terminate (void *user_data)
59 {
60     LOGD ("app terminated");
61 }
62
63 EXPORT_API int main (int argc, char *argv [])
64 {
65     service_app_lifecycle_callback_s event_callback = {0, };
66
67     event_callback.create = app_create;
68     event_callback.terminate = app_terminate;
69     event_callback.app_control = app_control;
70
71     LOGD ("start org.tizen.isf-kbd-mode-changer");
72
73     return service_app_main (argc, argv, &event_callback, NULL);
74 }