+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef _W_INPUT_SMARTREPLY_H_
-#define _W_INPUT_SMARTREPLY_H_
-
-#include <app_control.h>
-#include <stdbool.h>
-
-typedef void (*input_smartreply_changed)(void *user_data);
-
-
-bool input_smartreply_init(app_control_h app_control);
-
-void input_smartreply_deinit(void);
-
-const char *input_smartreply_get_lang(void);
-
-bool input_smartreply_get_reply(void);
-
-bool input_smartreply_get_reply_async(void);
-
-int input_smartreply_get_reply_num(void);
-
-char *input_smartreply_get_nth_item(int index);
-
-bool input_smartreply_send_feedback(const char *str);
-
-void input_smartreply_set_notify(input_smartreply_changed callback,
- void *user_data);
-
-void input_smartreply_unset_notify(void);
-
-bool input_smartreply_is_enabled(void);
-
-#endif
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __W_INPUT_TEMPLATE_H_
-#define __W_INPUT_TEMPLATE_H_
-
-#include <vector>
-#include <string>
-
-#include <app_control.h>
-
-struct TemplateData {
- std::string text;
- bool use_gettext;
-};
-
-typedef void (*input_template_changed) (void *user_data);
-
-
-void input_template_init(app_control_h app_control);
-
-void input_template_deinit(void);
-
-const std::vector<TemplateData> input_template_get_list(void);
-
-void input_template_set_notify(input_template_changed callback,
- void *user_data);
-
-void input_template_unset_notify(void);
-
-bool input_template_is_user_template(void);
-
-#endif
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(sqlite3)
-#BuildRequires: pkgconfig(smartreply)
%if %{enable_log_manager}
PKG_CHECK_MODULES(VCONF REQUIRED vconf)
PKG_CHECK_MODULES(DB_UTIL_PKG REQUIRED db-util)
PKG_CHECK_MODULES(SQLITE3_PKG REQUIRED sqlite3)
-#PKG_CHECK_MODULES(SMARTREPLY REQUIRED smartreply)
#PKG_CHECK_MODULES(GRAPHICS_EXTENSION REQUIRED graphics-extension)
#PKG_CHECK_MODULES(WNOTI_SERVICE REQUIRED wnoti-service2)
#PKG_CHECK_MODULES(SAP_CLIENT_STUB_API REQUIRED sap-client-stub-api)
${DB_UTIL_PKG_INCLUDE_DIRS}
${SQLITE3_PKG_INCLUDE_DIRS}
${DATA_CONTROL_INCLUDE_DIRS}
- ${SMARTREPLY_INCLUDE_DIRS}
${WNOTI_SERVICE_INCLUDE_DIRS}
${SAP_CLIENT_STUB_API_INCLUDE_DIRS})
${DB_UTIL_PKG_LIBRARY_DIRS}
${SQLITE3_PKG_LIBRARY_DIRS}
${VCONF_LIBRARY_DIRS}
- ${SMARTREPLY_LIBRARY_DIRS}
${WNOTI_SERVICE_LIBRARY_DIRS}
${SAP_CLIENT_STUB_API_LIBRARY_DIRS}
)
${DB_UTIL_PKG_LIBRARIES}
${SQLITE3_PKG_LIBRARIES}
${VCONF_LIBRARIES}
-# ${SMARTREPLY_LIBRARIES}
)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
#include "Debug.h"
#include "w-input-selector.h"
-#include "w-input-smartreply.h"
#define EMOTICON_CNT 27
const Eina_Unicode unicode_event[2] = { emoticon_info[i].code, 0 };
char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
- input_smartreply_send_feedback(utf_8);
reply_to_sender_by_callback((const char*)utf_8, "emoticon");
PRINTFUNC(SECURE_DEBUG, "[%d]%s", i, utf_8);
#include "w-input-keyboard.h"
#include "w-input-selector.h"
-#include "w-input-smartreply.h"
extern InputKeyboardData g_input_keyboard_data;
extern App_Data* app_data;
int ret;
ret = app_control_get_extra_data(reply,
"template_feedback", &feedback);
-
- if (ret == APP_CONTROL_ERROR_NONE) {
- if (feedback) {
- input_smartreply_send_feedback(feedback);
- }
- }
}
reply_to_sender_by_callback(feedback, "keyboard");
free(feedback);
const char *getText = elm_entry_entry_get(entry);
LOGD("button key clicked!! : getText = %s", getText);
- if (getText)
- input_smartreply_send_feedback(getText);
-
char *app_id = NULL;
app_control_get_caller(app_data->source_app_control, &app_id);
if (app_id != NULL)
//#include "ui_extension.h"
#include "w-input-selector.h"
-#include "w-input-template.h"
-#include "w-input-smartreply.h"
#include "w-input-keyboard.h"
#include "w-input-stt-ise.h"
#include "w-input-emoticon.h"
static Elm_Object_Item *it_empty;
static Elm_Object_Item *it_title;
static Elm_Object_Item *it_plus;
-static int g_smartreply_current_number = 0; /* currently loaded smartreply number */
-static unsigned int g_template_current_number = 0; /* currnetly loaded template number */
Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
Evas_Object* _create_genlist(Evas_Object* parent);
void _create_genlist_items(void* user_data, bool is_type_reply);
-void _update_genlist_items(void *user_data);
-void _update_smartreply_items(void *user_data);
-void _update_template_items(void *user_data);
static void _popup_close_cb(void *data, Evas_Object *obj, void *event_info);
static void _popup_back_cb(void *data, Evas_Object *obj, void *event_info);
}
}
-static void _input_smartreply_notify_cb(void *user_data)
-{
- ecore_main_loop_iterate();
- _update_genlist_items((void *)app_data);
-}
-
-static void _input_template_notify_cb(void *user_data)
-{
- _update_genlist_items((void *)app_data);
-}
-
-
static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info)
{
App_Data* ad = (App_Data*)data;
}
-static void __ise_smartreply_gl_sel(void *data, Evas_Object *obj, void *event_info)
-{
- App_Data* app_data = (App_Data*) data;
- Elm_Object_Item *item = (Elm_Object_Item *) event_info;
-
- if (item) {
- elm_genlist_item_selected_set(item, EINA_FALSE);
-
- int index = (unsigned int) elm_object_item_data_get(item);
-
- char *reply = input_smartreply_get_nth_item(index);
- if (reply) {
- input_smartreply_send_feedback(reply);
- reply_to_sender_by_callback(reply, "smartreply");
- free(reply);
- elm_exit();
- }
- }
-}
-
-static void __ise_template_add_gl_sel(void *data, Evas_Object *obj, void *event_info)
-{
- App_Data* app_data = (App_Data*) data;
- Elm_Object_Item *item = (Elm_Object_Item *) event_info;
-
- if (item) {
- elm_genlist_item_selected_set(item, EINA_FALSE);
-
- if(is_sap_connection() == EINA_TRUE){
- // Show toast popup
- show_popup_toast(gettext("WDS_IME_TPOP_ADD_TEMPLATE_ON_YOUR_PHONE_ABB"), true);
-
- // send message to Host
- app_control_h appctrl;
- app_control_create(&appctrl);
- app_control_set_app_id(appctrl, "com.samsung.w-manager-service");
- app_control_add_extra_data(appctrl, "type", "gm_setting");
- app_control_add_extra_data(appctrl, "data/setting_menu", "texttemplate_setting");
- app_control_send_launch_request(appctrl, NULL, NULL);
- app_control_destroy(appctrl);
- } else {
- app_control_h app_control;
- app_control_create(&app_control);
- app_control_set_app_id(app_control, "com.samsung.bt-connection-popup");
- app_control_add_extra_data(app_control, "msg", "perform");
- app_control_send_launch_request(app_control, __bt_connection_result_cb, NULL);
- app_control_destroy(app_control);
- }
- }
-}
-
-static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
-{
- App_Data* app_data = (App_Data*) data;
- Elm_Object_Item *item = (Elm_Object_Item *) event_info;
- int index = 0;
-
- if (item) {
- elm_genlist_item_selected_set(item, EINA_FALSE);
-
- index = (unsigned int) elm_object_item_data_get(item);
- const std::vector<TemplateData> template_list = input_template_get_list();
-
- //@ToDo : should call reply function when any template string is selected and confirmed.
- // Here reply string will be template_list[index].text.c_str();
- if( index < template_list.size()) {
- reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
- elm_exit();
- }
- }
-}
-
static Evas_Object * __ise_gl_3button_content_get(void *data, Evas_Object *obj, const char *part)
{
if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
return NULL;
}
-static char * __ise_smartreply_gl_text_get(void *data, Evas_Object *obj, const char *part)
-{
- if(!strcmp(part, "elm.text")) {
- int index;
- char *reply = NULL;
-
- index = (int)data;
- if (index < 0)
- return NULL;
-
- reply = input_smartreply_get_nth_item(index);
- if (reply == NULL)
- return NULL;
-
- /* Set hightlight color on first 3 smartreply items */
- if (index < 3) {
- char *colored = _genlist_text_set_theme_color(reply, "AT0113");
-
- if (colored == NULL) {
- return reply;
- } else {
- free(reply);
- return colored;
- }
- }
-
- return reply;
- }
- return NULL;
-}
-
-static char * __ise_template_gl_text_get(void *data, Evas_Object *obj, const char *part)
-{
- if(!strcmp(part, "elm.text")) {
- unsigned int index = (unsigned int)data;
- const std::vector<TemplateData> template_list = input_template_get_list();
-
- if(index < template_list.size()) {
- if(template_list[index].use_gettext) {
- return strdup(gettext(template_list[index].text.c_str()));
- } else {
- Eina_Strbuf *buf = NULL;
- const char *str = NULL;
- char *markup = NULL;
-
- buf = eina_strbuf_new();
- if(buf) {
- eina_strbuf_append(buf, template_list[index].text.c_str());
- eina_strbuf_replace_all(buf, "\n", "");
- eina_strbuf_replace_all(buf, "\r", "");
-
- str = eina_strbuf_string_get(buf);
-
- if (str) {
- markup = elm_entry_utf8_to_markup(str);
- }
- eina_strbuf_free(buf);
- }
-
- return markup;
- }
- }
- }
- return NULL;
-}
-
-static char * __ise_addtemplate_gl_text_get(void *data, Evas_Object *obj, const char *part)
-{
- if(!strcmp(part, "elm.text")) {
- return(strdup(gettext("WDS_IME_MBODY_ADD_TEMPLATE_ABB")));
- }
- return NULL;
-}
-
-static Evas_Object * __ise_gl_1button_content_get(void *data, Evas_Object *obj, const char *part)
-{
- if (!strcmp(part, "elm.icon")) {
- Evas_Object* btn = elm_button_add(obj);
- evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
- Evas_Object* ic = elm_image_add(btn);
- elm_image_resizable_set(ic, EINA_TRUE, EINA_TRUE);
- string path = get_resource_path();
- elm_object_style_set(btn, "ime_button_template");
- string path_ic = path + "/images/w_list_add_ic.png";
- elm_image_file_set(ic, path_ic.c_str(), NULL);
- elm_object_content_set(btn, ic);
- evas_object_layer_set(btn, 32000);
-
- return btn;
- }
- return NULL;
-}
static void __ise_gl_lang_changed(void *data, Evas_Object *obj, void *event_info)
{
}
elm_genlist_clear(app_data->genlist);
- g_smartreply_current_number = 0; /* reset previous smartreply size to 0 */
Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
itc0->item_style = "title";
elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
}
- if (input_smartreply_is_enabled() == false) {
- _update_template_items(app_data);
- if(g_template_current_number > 0) {
- Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
- eext_circle_object_genlist_scroller_policy_set(circle_genlist,
- ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
- }
- } else {
- // dummy title for bottom
- Elm_Object_Item *dummy;
-
- dummy = elm_genlist_item_append(app_data->genlist, itc0,
- NULL, NULL,
- ELM_GENLIST_ITEM_NONE,
- NULL, NULL);
-
- elm_genlist_item_select_mode_set(dummy, ELM_OBJECT_SELECT_MODE_NONE);
- }
-
Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
elm_genlist_item_class_free(itc1);
}
-void _update_genlist_items(void *user_data)
-{
- int len = 0;
-
- if (input_smartreply_is_enabled())
- len = input_smartreply_get_reply_num();
-
- if (g_smartreply_current_number != len)
- _update_smartreply_items(user_data);
-
- _update_template_items(user_data);
-
- g_smartreply_current_number = len;
-
- if (g_smartreply_current_number > 0 || g_template_current_number > 0) {
- Evas_Object *circle_genlist = (Evas_Object *) evas_object_data_get(app_data->genlist, "circle");
- eext_circle_object_genlist_scroller_policy_set(circle_genlist,
- ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
- }
-}
-
-void _update_smartreply_items(void *user_data)
-{
- App_Data* app_data;
-
- Elm_Object_Item *first;
- Elm_Object_Item *menu;
- Elm_Object_Item *pos;
-
- int len = 0;
- int i = 0;
-
- app_data = (App_Data *)user_data;
-
- if (app_data == NULL) {
- PRINTFUNC(DLOG_ERROR, "Can not get app_data");
- return;
- }
-
- if (app_data->genlist == NULL) {
- /* smartreply will update when genlist is exist only */
- PRINTFUNC(DLOG_ERROR, "Can not get getlist");
- return;
- }
-
- if (input_smartreply_is_enabled())
- len = input_smartreply_get_reply_num();
-
- if (g_smartreply_current_number == len)
- return;
-
- first = elm_genlist_first_item_get(app_data->genlist);
- menu = elm_genlist_item_next_get(first);
-
- /* Remove current smartreply list */
- pos = elm_genlist_item_next_get(menu);
- for (i = 0; i < g_smartreply_current_number; i++) {
- Elm_Object_Item *next;
-
- if (pos == NULL)
- break;
-
- next = elm_genlist_item_next_get(pos);
- elm_object_item_del(pos);
- pos = next;
- }
-
- /* Append newly added smartreply list */
- if (len > 0) {
- Elm_Genlist_Item_Class *itc;
-
- itc = elm_genlist_item_class_new();
-
- itc->item_style = "1text";
- itc->func.text_get = __ise_smartreply_gl_text_get;
- itc->func.content_get = NULL;
- itc->func.state_get = NULL;
- itc->func.del = NULL;
-
- pos = menu;
- for (i = 0; i < len; i++) {
- pos = elm_genlist_item_insert_after(app_data->genlist,
- itc,
- (void *)i,
- NULL,
- pos,
- ELM_GENLIST_ITEM_NONE,
- __ise_smartreply_gl_sel,
- app_data);
- }
-
- if (menu)
- elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
-
- elm_genlist_item_class_free(itc);
- }
-
- g_smartreply_current_number = len;
-}
-
-
-void _update_template_items(void *user_data)
-{
- App_Data* app_data;
-
- Elm_Object_Item *first;
- Elm_Object_Item *menu;
- Elm_Object_Item *pos;
- Elm_Object_Item *template_pos;
-
- unsigned int template_len = 0;
- unsigned int i = 0;
-
- app_data = (App_Data *)user_data;
-
- if (app_data == NULL) {
- PRINTFUNC(DLOG_ERROR, "Can not get app_data");
- return;
- }
-
- if (app_data->genlist == NULL) {
- /* smartreply will update when genlist is exist only */
- PRINTFUNC(DLOG_ERROR, "Can not get getlist");
- return;
- }
-
- if (app_data->app_type == APP_TYPE_REPLY) {
- menu = elm_genlist_first_item_get(app_data->genlist);
- } else {
- first = elm_genlist_first_item_get(app_data->genlist);
- menu = elm_genlist_item_next_get(first);
- }
-
- pos = menu;
- /* move to smartreply next if it need */
- if (input_smartreply_is_enabled()) {
- int smartreply_len = 0;
-
- smartreply_len = input_smartreply_get_reply_num();
- if (smartreply_len > 0) {
- int j = 0;
-
- for (j = 0; j < smartreply_len; j++) {
- if (pos == NULL)
- break;
-
- pos = elm_genlist_item_next_get(pos);
- }
- }
- }
-
- /* Remove Current template list */
- template_pos = elm_genlist_item_next_get(pos);
- for (i = 0 ; i < g_template_current_number; i++) {
- Elm_Object_Item *next;
-
- if (template_pos == NULL) {
- PRINTFUNC(DLOG_ERROR, "Template mismatched, iter : %d, current num: %d",
- i, g_template_current_number);
- break;
- }
-
- next = elm_genlist_item_next_get(template_pos);
- elm_object_item_del(template_pos);
- template_pos = next;
- }
-
- /* Remove Add or dummpy button */
- if(template_pos) {
- Elm_Object_Item *next;
-
- next = elm_genlist_item_next_get(template_pos);
- elm_object_item_del(template_pos);
- template_pos = next;
- }
-
- /* Append New Template list */
- const std::vector<TemplateData> template_list = input_template_get_list();
- template_len = 0;
-
- if (template_list.size() > 0) {
- Elm_Genlist_Item_Class *itc;
-
- itc = elm_genlist_item_class_new();
-
- itc->item_style = "1text";
- itc->func.text_get = __ise_template_gl_text_get;
- itc->func.content_get = NULL;
- itc->func.state_get = NULL;
- itc->func.del = NULL;
-
- for (i = 0; i < template_list.size(); i++) {
- bool matched = false;
-
- if(!template_list[i].use_gettext) {
- int smartreply_len = 0;
- int j = 0;
-
- smartreply_len = input_smartreply_get_reply_num();
- for (j = 0; j < smartreply_len; j++) {
- char *reply = NULL;
-
- reply = input_smartreply_get_nth_item(j);
- if (reply) {
- if (!strcmp(reply, template_list[i].text.c_str())) {
- matched = true;
- free(reply);
- break;
- }
- free(reply);
- }
- }
- }
-
- if (matched == false) {
- pos = elm_genlist_item_insert_after(app_data->genlist,
- itc,
- (void *)i,
- NULL,
- pos,
- ELM_GENLIST_ITEM_NONE,
- __ise_template_gl_sel,
- app_data);
- template_len++;
- }
- }
-
- elm_genlist_item_class_free(itc);
- }
-
-
- // template add button (+)
-/* if (!input_template_is_user_template()) {
- Elm_Genlist_Item_Class *itc;
-
- itc = elm_genlist_item_class_new();
-
- itc->item_style = "1text.1icon";
- itc->func.text_get = __ise_addtemplate_gl_text_get;;
- itc->func.content_get = __ise_gl_1button_content_get;
- itc->func.state_get = NULL;
- itc->func.del = NULL;
-
-
- pos = elm_genlist_item_insert_after(app_data->genlist,
- itc,
- NULL,
- NULL,
- pos,
- ELM_GENLIST_ITEM_NONE,
- __ise_template_add_gl_sel,
- app_data);
-
- elm_genlist_item_class_free(itc);
- }
-*/
- if (menu)
- elm_genlist_item_show(menu, ELM_GENLIST_ITEM_SCROLLTO_TOP);
-
- g_template_current_number = template_len;
-}
-
-
bool _app_create(void* user_data)
{
int width = 1000, height = 1000;
input_keyboard_init(service);
-// input_smartreply_init(service);
-// input_smartreply_set_notify(_input_smartreply_notify_cb, NULL);
-
-// if (input_smartreply_is_enabled())
-// input_smartreply_get_reply_async();
-
-
- input_template_init(service);
- input_template_set_notify(_input_template_notify_cb, NULL);
-
_create_genlist_items(app_data, is_type_reply);
ACTIVATE :
free(app_data->shared_res_path);
input_keyboard_deinit();
- input_smartreply_deinit();
-
- input_template_unset_notify();
- input_template_deinit();
}
static int init_i18n(const char *domain, const char *dir, char *lang_str)
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "Debug.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <locale.h>
-
-#include <dlog.h>
-#include <vconf.h>
-//#include <smartreply_service.h>
-
-#include "w-input-smartreply.h"
-
-#ifndef INPUT_SMARTREPLY_VCONF
-#define INPUT_SMARTREPLY_VCONF "db/wms/smart_reply"
-#endif
-
-
-typedef struct _InputSmartreplyData InputSmartreplyData;
-
-struct _InputSmartreplyData
-{
- char *caller_id;
- char *sender;
- char *message;
- char *lang;
-
- int enabled;
-
- input_smartreply_changed callback;
- void *user_data;
-
-// smartreply_reply_h *candidate_list;
- int candidate_list_len;
-};
-
-
-static void _input_smartreply_get_reply_callback(int handle, int error,
- int length);
-/* Disable smartreply on/off feature
-static void _input_smartreply_vconf_changed(keynode_t *key, void *data);
-*/
-
-
-static InputSmartreplyData *g_input_smartreply_data = NULL;
-
-static void _input_smartreply_get_reply_callback(int handle, int error,
- int length)
-{
-}
-
-
-
-bool input_smartreply_init(app_control_h app_control)
-{
- return true;
-}
-
-void input_smartreply_deinit(void)
-{
- return;
-}
-
-bool input_smartreply_get_reply(void)
-{
- return true;
-}
-
-bool input_smartreply_get_reply_async(void)
-{
- return true;
-}
-
-int input_smartreply_get_reply_num(void)
-{
- if (g_input_smartreply_data == NULL) {
- PRINTFUNC(DLOG_ERROR, "InputSmartreplyData uninitialized");
- return 0;
- }
-
- if (g_input_smartreply_data->enabled == 0) {
- PRINTFUNC(DLOG_WARN, "Smartreply is disabled");
- return 0;
- }
-
- return g_input_smartreply_data->candidate_list_len;
-}
-
-char *input_smartreply_get_nth_item(int index)
-{
- char *message = NULL;
-
- return message;
-}
-
-bool input_smartreply_send_feedback(const char *str)
-{
- return true;
-}
-
-
-
-void input_smartreply_set_notify(input_smartreply_changed callback,
- void *user_data)
-{
- if (callback == NULL) {
- PRINTFUNC(DLOG_ERROR, "empty callback function");
- return;
- }
-
- if (g_input_smartreply_data == NULL) {
- PRINTFUNC(DLOG_WARN, "InputSmartreplyData uninitialized");
- return;
- }
-
- g_input_smartreply_data->callback = callback;
- g_input_smartreply_data->user_data = user_data;
-}
-
-
-void input_smartreply_unset_notify(void)
-{
- if (g_input_smartreply_data == NULL) {
- PRINTFUNC(DLOG_WARN, "InputSmartreplyData uninitialized");
- return;
- }
-
- g_input_smartreply_data->callback = NULL;
- g_input_smartreply_data->user_data = NULL;
-}
-
-bool input_smartreply_is_enabled(void)
-{
- if (g_input_smartreply_data == NULL) {
- PRINTFUNC(DLOG_WARN, "InputSmartreplyData uninitialized");
- return false;
- }
-
- if (g_input_smartreply_data->enabled)
- return true;
-
- return false;
-}
#include "Debug.h"
#include "w-input-selector.h"
-#include "w-input-smartreply.h"
#include "w-input-stt-voice.h"
#include "w-input-stt-engine.h"
#include "w-input-stt-ise.h"
}
PRINTFUNC(DLOG_DEBUG, "result_text = %s", result_text.c_str());
- input_smartreply_send_feedback(result_text.c_str());
reply_to_sender_by_callback(result_text.c_str(), "voice");
destroy_voice();
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "Debug.h"
-
-#include <dlog.h>
-#include <db-util.h>
-#include <vconf.h>
-
-#include "w-input-template.h"
-
-
-#define INPUT_TEMPLATE_DB_VCONF "memory/wms/update_text_template_db"
-
-#define INPUT_TEMPLATE_DB_PATH "/opt/usr/dbspace/.WearableManagerService.db"
-#define INPUT_TEMPLATE_QUERY_LEN 1024
-
-struct InputTemplate {
- std::vector<TemplateData> template_list;
- bool notify;
- bool user_template;
- input_template_changed callback;
- void *user_data;
-};
-
-static struct InputTemplate g_input_template;
-
-
-static void _input_template_db_vconf_changed(keynode_t *key, void *data);
-
-static bool input_template_init_app_control_list(app_control_h app_control);
-static bool input_template_init_app_control(app_control_h app_control);
-static bool input_template_init_db_util(void);
-static bool input_template_init_default(void);
-
-
-static void _input_template_db_vconf_changed(keynode_t *key, void *data)
-{
- bool db_status = vconf_keynode_get_bool(key);
-
- PRINTFUNC(DLOG_DEBUG, "starts :: db_status = %d", db_status);
-
- if(db_status != 0)
- return;
-
- if (g_input_template.callback) {
- // Clear template list and reset to template_list from DB
- g_input_template.template_list.clear();
- input_template_init_db_util();
-
- g_input_template.callback(g_input_template.user_data);
- }
-}
-
-static bool input_template_init_app_control_list(app_control_h app_control)
-{
- int ret;
- int len;
-
- char **list = NULL;
-
- ret = app_control_get_extra_data_array(app_control,
- "template_list", &list, &len);
-
- if (ret != APP_CONTROL_ERROR_NONE)
- return false;
-
- if (list == NULL)
- return false;
-
- for (int i = 0; i < len; i++) {
- struct TemplateData data;
-
- if (*(list + i)) {
- // if use_gettext is true,
- // it's default template string that requires gettext.
- data.use_gettext = false;
- data.text = *(list + i);
-
- g_input_template.template_list.push_back(data);
-
- free(*(list + i));
- }
- }
-
- free(list);
-
- g_input_template.user_template = true;
-
- return true;
-}
-
-static bool input_template_init_app_control(app_control_h app_control)
-{
- bool ret;
-
- if (app_control == NULL)
- return false;
-
- ret = input_template_init_app_control_list(app_control);
- if (ret)
- return true;
-
- return false;
-}
-
-static bool input_template_init_db_util(void)
-{
- sqlite3 *g_tt_db = NULL;
- sqlite3_stmt *stmt = NULL;
-
- int ret = -1;
-
- char query[INPUT_TEMPLATE_QUERY_LEN + 1] = {0, };
-
- ret = db_util_open(INPUT_TEMPLATE_DB_PATH, &g_tt_db, 0);
-
- if (ret != SQLITE_OK) {
- PRINTFUNC(DLOG_ERROR, "db_util open failed");
- return false;
- }
-
- snprintf(query, INPUT_TEMPLATE_QUERY_LEN,
- "select sortId, itemId, checked, message from %s",
- "tmpl_msg_table");
-
- sqlite3_prepare_v2(g_tt_db, query, strlen(query), &stmt, NULL);
-
- if (ret != SQLITE_OK) {
- PRINTFUNC(DLOG_ERROR, "Can not get query");
- return false;
- }
-
- ret = sqlite3_step(stmt);
-
- while(ret == SQLITE_ROW) {
- struct TemplateData data;
- int text_mode;
-
- // if checked is 0,
- // it's default template string that requires gettext.
- text_mode = sqlite3_column_int(stmt, 2);
- if (text_mode)
- data.use_gettext = false;
- else
- data.use_gettext = true;
-
- data.text = (char *)sqlite3_column_text(stmt, 3);
- PRINTFUNC(DLOG_DEBUG, "db text %s", data.text.c_str());
- g_input_template.template_list.push_back(data);
-
- ret = sqlite3_step(stmt);
- }
-
- ret = sqlite3_finalize(stmt);
- if (ret != SQLITE_OK)
- PRINTFUNC(DLOG_ERROR, "Can not finalize sqlite");
-
- ret = db_util_close(g_tt_db);
- if (ret != SQLITE_OK)
- PRINTFUNC(DLOG_ERROR, "Can not close db_util");
-
- /* set vconf callback for DB update */
- ret = vconf_notify_key_changed(INPUT_TEMPLATE_DB_VCONF,
- _input_template_db_vconf_changed, NULL);
-
- if (ret < 0)
- PRINTFUNC(DLOG_ERROR, "Can not create vconf notify");
-
- g_input_template.user_template = false;
- return true;
-}
-
-static bool input_template_init_default(void)
-{
- struct TemplateData data;
-
- data.text = "IDS_WMGR_MBODY_HOWS_IT_GOING_Q_M_TEXT_TEMPLATE";
- data.use_gettext = true;
-
- g_input_template.template_list.push_back(data);
-
- data.text = "IDS_WMGR_MBODY_WHATS_UP_Q_M_TEXT_TEMPLATE";
- data.use_gettext = true;
-
- g_input_template.template_list.push_back(data);
-
- data.text = "IDS_WMGR_MBODY_ILL_TALK_TO_YOU_SOON_M_TEXT_TEMPLATE";
- data.use_gettext = true;
-
- g_input_template.template_list.push_back(data);
-
- data.text = "IDS_WMGR_MBODY_ILL_CALL_YOU_LATER_M_TEXT_TEMPLATE";
- data.use_gettext = true;
-
- g_input_template.template_list.push_back(data);
-
- data.text = "IDS_MSG_BODY_WHERE_ARE_YOU_Q_M_TEXT_TEMPLATE";
- data.use_gettext = true;
-
- g_input_template.template_list.push_back(data);
-
- data.text = "IDS_MSG_BODY_WHEN_CAN_WE_MEET_Q_M_TEXT_TEMPLATE";
- data.use_gettext = true;
-
- g_input_template.template_list.push_back(data);
-
- data.text = "WDS_WMGR_MBODY_CALL_ME_LATER";
- data.use_gettext = true;
-
- g_input_template.template_list.push_back(data);
- g_input_template.user_template = false;
-
- return true;
-}
-
-static void input_template_deinit_db_util(void)
-{
- vconf_ignore_key_changed(INPUT_TEMPLATE_DB_VCONF,
- _input_template_db_vconf_changed);
-}
-
-void input_template_init(app_control_h app_control)
-{
- input_template_unset_notify();
- g_input_template.template_list.clear();
- g_input_template.user_template = false;
-
- bool ret;
-
- ret = input_template_init_app_control(app_control);
- if (ret)
- return;
-
- ret = input_template_init_db_util();
- if (ret)
- return;
-
- input_template_init_default();
-}
-
-void input_template_deinit(void)
-{
- input_template_unset_notify();
- input_template_deinit_db_util();
-
- g_input_template.template_list.clear();
- g_input_template.user_template = false;
-}
-
-const std::vector<TemplateData> input_template_get_list(void)
-{
- return g_input_template.template_list;
-}
-
-void input_template_set_notify(input_template_changed callback,
- void *user_data)
-{
- if (callback == NULL) {
- PRINTFUNC(DLOG_ERROR, "empty callback function");
- return;
- }
-
- g_input_template.callback = callback;
- g_input_template.user_data = user_data;
-}
-
-void input_template_unset_notify(void)
-{
- g_input_template.callback = NULL;
- g_input_template.user_data = NULL;
-}
-
-bool input_template_is_user_template(void)
-{
- return (g_input_template.user_template);
-}