Fix bug not to change keyboard mode
[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 #include <vconf.h>
27 #include "main.h"
28
29 static bool app_create (void *user_data)
30 {
31     LOGD ("app create");
32     return true;
33 }
34
35 static void app_control (app_control_h app_control, void *user_data)
36 {
37     LOGD ("%s", __func__);
38
39     LOGD ("isf_extra_hwkbd_module start");
40
41     /* Toggle input mode */
42     int val = 1;
43     if (vconf_get_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, &val) != 0)
44         LOGW ("Failed to get vconf key");
45
46     if (vconf_set_bool (VCONFKEY_ISF_HW_KEYBOARD_INPUT_DETECTED, !val) != 0)
47         LOGW ("Failed to set vconf key");
48     else
49         LOGD ("Succeeded to set vconf key");
50
51     service_app_exit ();
52 }
53
54 static void app_terminate (void *user_data)
55 {
56     LOGD ("app terminated");
57 }
58
59 EXPORT_API int main (int argc, char *argv [])
60 {
61     service_app_lifecycle_callback_s event_callback = {0, };
62
63     event_callback.create = app_create;
64     event_callback.terminate = app_terminate;
65     event_callback.app_control = app_control;
66
67     LOGD ("start org.tizen.isf-kbd-mode-changer");
68
69     return service_app_main (argc, argv, &event_callback, NULL);
70 }