Coding rule check
[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 bool input_smartreply_init(app_control_h app_control)
70 {
71         return true;
72 }
73
74 void input_smartreply_deinit(void)
75 {
76         return;
77 }
78
79 bool input_smartreply_get_reply(void)
80 {
81         return true;
82 }
83
84 bool input_smartreply_get_reply_async(void)
85 {
86         return true;
87 }
88
89 int input_smartreply_get_reply_num(void)
90 {
91         if (g_input_smartreply_data == NULL) {
92                 PRINTFUNC(DLOG_ERROR, "InputSmartreplyData uninitialized");
93                 return 0;
94         }
95
96         if (g_input_smartreply_data->enabled == 0) {
97                 PRINTFUNC(DLOG_WARN, "Smartreply is disabled");
98                 return 0;
99         }
100
101         return g_input_smartreply_data->candidate_list_len;
102 }
103
104 char *input_smartreply_get_nth_item(int index)
105 {
106     char *message = NULL;
107
108         return message;
109 }
110
111 bool input_smartreply_send_feedback(const char *str)
112 {
113         return true;
114 }
115
116
117
118 void input_smartreply_set_notify(input_smartreply_changed callback,
119                         void *user_data)
120 {
121         if (callback == NULL) {
122                 PRINTFUNC(DLOG_ERROR, "empty callback function");
123                 return;
124         }
125
126         if (g_input_smartreply_data == NULL) {
127                 PRINTFUNC(DLOG_WARN, "InputSmartreplyData uninitialized");
128                 return;
129         }
130
131         g_input_smartreply_data->callback = callback;
132         g_input_smartreply_data->user_data = user_data;
133 }
134
135
136 void input_smartreply_unset_notify(void)
137 {
138         if (g_input_smartreply_data == NULL) {
139                 PRINTFUNC(DLOG_WARN, "InputSmartreplyData uninitialized");
140                 return;
141         }
142
143         g_input_smartreply_data->callback = NULL;
144         g_input_smartreply_data->user_data = NULL;
145 }
146
147 bool input_smartreply_is_enabled(void)
148 {
149         if (g_input_smartreply_data == NULL) {
150                 PRINTFUNC(DLOG_WARN, "InputSmartreplyData uninitialized");
151                 return false;
152         }
153
154         if (g_input_smartreply_data->enabled)
155                 return true;
156
157         return false;
158 }