Add initial code for inputdelegator
[platform/core/uifw/inputdelegator.git] / src / w-input-smartreply.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "Debug.h"
18
19 #include <stdlib.h>
20 #include <string.h>
21 #include <locale.h>
22
23 #include <dlog.h>
24 #include <vconf.h>
25 //#include <smartreply_service.h>
26
27 #include "w-input-smartreply.h"
28
29 #ifndef INPUT_SMARTREPLY_VCONF
30 #define INPUT_SMARTREPLY_VCONF "db/wms/smart_reply"
31 #endif
32
33
34 typedef struct _InputSmartreplyData InputSmartreplyData;
35
36 struct _InputSmartreplyData
37 {
38         char *caller_id;
39         char *sender;
40         char *message;
41         char *lang;
42
43         int enabled;
44
45         input_smartreply_changed callback;
46         void *user_data;
47
48 //      smartreply_reply_h *candidate_list;
49         int candidate_list_len;
50 };
51
52
53 static void _input_smartreply_get_reply_callback(int handle, int error,
54                                                 int length);
55 /* Disable smartreply on/off feature
56 static void _input_smartreply_vconf_changed(keynode_t *key, void *data);
57 */
58
59
60 static InputSmartreplyData *g_input_smartreply_data = NULL;
61
62 static void _input_smartreply_get_reply_callback(int handle, int error,
63                                                 int length)
64 {
65
66 }
67
68
69
70 bool input_smartreply_init(app_control_h app_control)
71 {
72         return true;
73 }
74
75 void input_smartreply_deinit(void)
76 {
77         return;
78 }
79
80 bool input_smartreply_get_reply(void)
81 {
82         return true;
83 }
84
85 bool input_smartreply_get_reply_async(void)
86 {
87         return true;
88 }
89
90 int input_smartreply_get_reply_num(void)
91 {
92         if (g_input_smartreply_data == NULL) {
93                 PRINTFUNC(DLOG_ERROR, "InputSmartreplyData uninitialized");
94                 return 0;
95         }
96
97         if (g_input_smartreply_data->enabled == 0) {
98                 PRINTFUNC(DLOG_WARN, "Smartreply is disabled");
99                 return 0;
100         }
101
102         return g_input_smartreply_data->candidate_list_len;
103 }
104
105 char *input_smartreply_get_nth_item(int index)
106 {
107     char *message = NULL;
108
109         return message;
110 }
111
112 bool input_smartreply_send_feedback(const char *str)
113 {
114         return true;
115 }
116
117
118
119 void input_smartreply_set_notify(input_smartreply_changed callback,
120                         void *user_data)
121 {
122         if (callback == NULL) {
123                 PRINTFUNC(DLOG_ERROR, "empty callback function");
124                 return;
125         }
126
127         if (g_input_smartreply_data == NULL) {
128                 PRINTFUNC(DLOG_WARN, "InputSmartreplyData uninitialized");
129                 return;
130         }
131
132         g_input_smartreply_data->callback = callback;
133         g_input_smartreply_data->user_data = user_data;
134 }
135
136
137 void input_smartreply_unset_notify(void)
138 {
139         if (g_input_smartreply_data == NULL) {
140                 PRINTFUNC(DLOG_WARN, "InputSmartreplyData uninitialized");
141                 return;
142         }
143
144         g_input_smartreply_data->callback = NULL;
145         g_input_smartreply_data->user_data = NULL;
146 }
147
148 bool input_smartreply_is_enabled(void)
149 {
150         if (g_input_smartreply_data == NULL) {
151                 PRINTFUNC(DLOG_WARN, "InputSmartreplyData uninitialized");
152                 return false;
153         }
154
155         if (g_input_smartreply_data->enabled)
156                 return true;
157
158         return false;
159 }