Merge branch 'tizen_3.0' into tizen 09/115209/1 accepted/tizen/common/20170217.161459 accepted/tizen/unified/20170309.034308 accepted/tizen/wearable/20170217.094332 submit/tizen/20170217.071740 submit/tizen_unified/20170308.100410
authorsungwook79.park <sungwook79.park@samsung.com>
Fri, 17 Feb 2017 02:10:24 +0000 (11:10 +0900)
committersungwook79.park <sungwook79.park@samsung.com>
Fri, 17 Feb 2017 02:10:24 +0000 (11:10 +0900)
Change-Id: I2a09227205756fcc6568b0bc0f2416ff069b5e79

inc/w-input-template.h [new file with mode: 0755]
packaging/org.tizen.inputdelegator.spec
src/CMakeLists.txt
src/w-input-emoticon.cpp
src/w-input-selector.cpp
src/w-input-stt-tos.cpp
src/w-input-stt-voice.cpp
src/w-input-template.cpp [new file with mode: 0755]

diff --git a/inc/w-input-template.h b/inc/w-input-template.h
new file mode 100755 (executable)
index 0000000..f270cee
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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
index b43066f..ddef11b 100755 (executable)
@@ -1,3 +1,12 @@
+# For the backward compatibility, this is to be built for
+# wearable profile or 4.0 unified building environment.
+# This cannot be built for non-wearable in conventional 3.0 build environment.
+# Note that it is not a good idea to limit building with ExcludeArch because there are new architectures being tested.
+# Use ExclusiveArch istead.
+%if "%{?profile}" == "mobile" || "%{?profile}" == "tv" || "%{?profile}" == "ivi" || "%{?profile}" == "common"
+ExclusiveArch:  none
+%endif
+
 Name: org.tizen.inputdelegator
 Summary: Input Delegator Application
 Version: 0.1.170216
@@ -20,6 +29,8 @@ BuildRequires: gettext
 
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-appfw-app-control)
+BuildRequires: pkgconfig(capi-appfw-preference)
 BuildRequires: pkgconfig(capi-media-wav-player)
 BuildRequires: pkgconfig(capi-system-device)
 BuildRequires: pkgconfig(eina)
@@ -37,22 +48,6 @@ BuildRequires: pkgconfig(capi-media-audio-io)
 BuildRequires:  pkgconfig(bundle)
 %endif
 
-%if "%{?profile}" == "mobile"
-ExcludeArch: %{arm} aarch64 %ix86 x86_64
-%endif
-
-%if "%{?profile}" == "tv"
-ExcludeArch: %{arm} aarch64 %ix86 x86_64
-%endif
-
-%if "%{?profile}" == "common"
-ExcludeArch: %{arm} aarch64 %ix86 x86_64
-%endif
-
-%if "%{?profile}" == "ivi"
-ExcludeArch: %{arm} aarch64 %ix86 x86_64
-%endif
-
 %define _appdir                /usr/apps
 %define _app_destdir   %{_appdir}/%{name}
 
index 74963d3..bba7bdc 100755 (executable)
@@ -1,6 +1,8 @@
 
 PKG_CHECK_MODULES(DLOG REQUIRED dlog)
 PKG_CHECK_MODULES(CAPI_APPFW_APPLICATION REQUIRED capi-appfw-application)
+PKG_CHECK_MODULES(CAPI_APPFW_APP-CONTROL REQUIRED capi-appfw-app-control)
+PKG_CHECK_MODULES(CAPI_APPFW_PREFERENCE REQUIRED capi-appfw-preference)
 PKG_CHECK_MODULES(CAPI_MEDIA_WAV_PLAYER REQUIRED capi-media-wav-player)
 PKG_CHECK_MODULES(CAPI_SYSTEM_DEVICE REQUIRED capi-system-device)
 PKG_CHECK_MODULES(EINA REQUIRED eina)
@@ -24,6 +26,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
                ${CMAKE_SOURCE_DIR}/inc
                ${DLOG_INCLUDE_DIRS}
                ${CAPI_APPFW_APPLICATION_INCLUDE_DIRS}
+               ${CAPI_APPFW_APP-CONTROL_INCLUDE_DIRS}
+               ${CAPI_APPFW_PREFERENCE_INCLUDE_DIRS}
                ${CAPI_MEDIA_WAV_PLAYER_INCLUDE_DIRS}
                ${CAPI_SYSTEM_DEVICE_INCLUDE_DIRS}
                ${EINA_INCLUDE_DIRS}
@@ -44,6 +48,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
 
 LINK_DIRECTORIES(${DLOG_LIBRARY_DIRS}
                ${CAPI_APPFW_APPLICATION_LIBRARY_DIRS}
+               ${CAPI_APPFW_APP-CONTROL_LIBRARY_DIRS}
+               ${CAPI_APPFW_PREFERENCE_LIBRARY_DIRS}
                ${CAPI_MEDIA_WAV_PLAYER_LIBRARY_DIRS}
                ${CAPI_SYSTEM_DEVICE_LIBRARY_DIRS}
                ${EINA_LIBRARY_DIRS}
@@ -67,6 +73,8 @@ ADD_EXECUTABLE(${W_INPUT_SELECTOR}
 TARGET_LINK_LIBRARIES(${W_INPUT_SELECTOR}
                ${DLOG_LIBRARIES}
                ${CAPI_APPFW_APPLICATION_LIBRARIES}
+               ${CAPI_APPFW_APP-CONTROL_LIBRARIES}
+               ${CAPI_APPFW_PREFERENCE_LIBRARIES}
                ${CAPI_MEDIA_WAV_PLAYER_LIBRARIES}
                ${CAPI_SYSTEM_DEVICE_LIBRARIES}
                ${EINA_LIBRARIES}
index f0c64f2..42bd53b 100755 (executable)
@@ -18,6 +18,7 @@
 #include <Elementary.h>
 #include <string>
 #include <vector>
+#include <stdint.h>
 
 #include <vconf.h>
 #include <vconf-keys.h>
@@ -363,7 +364,7 @@ void set_recent_emoticons(vector <int> &emoticon_list, int val)
 
 static void _emoticon_item_clicked_cb(void *data, Evas_Object * obj, void *event_info)
 {
-    int index = (int)data;
+    int index = (uintptr_t)data;
 
     PRINTFUNC(DLOG_DEBUG, "index = %d", index);
 
@@ -402,7 +403,7 @@ Evas_Object* get_emoticon_button(Evas_Object* parent, int index){
 
      evas_object_layer_set(btn, 32000);
 
-     evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void *)index);
+     evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void *)(uintptr_t)index);
 
      return btn;
 }
@@ -421,13 +422,13 @@ Evas_Object* get_recent_emoticon_button(Evas_Object* parent, int index){
      char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
      elm_object_part_text_set(btn, "elm.text", utf_8);
 
-     evas_object_data_set(btn, "index", (void*) recent_emoji_list.at(index));
+     evas_object_data_set(btn, "index", (void*)(uintptr_t) recent_emoji_list.at(index));
 
      if (utf_8)
          free(utf_8);
 
      evas_object_layer_set(btn, 32000);
-     evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void*) recent_emoji_list.at(index));
+     evas_object_smart_callback_add(btn, "clicked", _emoticon_item_clicked_cb, (void*)(uintptr_t) recent_emoji_list.at(index));
 
      return btn;
 }
@@ -460,7 +461,7 @@ static void _emoticon_gl_content_unswallowed_cb(void *data, Evas_Object *obj, vo
 
 //      PRINTFUNC(DLOG_DEBUG,"%s - stype[%s]", __func__, itc->item_style);
     if (!strcmp(itc->item_style, "3button_flat")) {
-        int index = (int)elm_object_item_data_get(it);
+        int index = (uintptr_t)elm_object_item_data_get(it);
         //PRINTFUNC(DLOG_DEBUG,"it = %p", it);
         PRINTFUNC(DLOG_DEBUG, "index = %d %d %d", index, index+1, index+2);
 
@@ -474,7 +475,7 @@ static void _emoticon_gl_content_unswallowed_cb(void *data, Evas_Object *obj, vo
             emoticon_contents_pool[index+2].used = 0;
         }
     } else if (!strcmp(itc->item_style, "3button_flat_recent")) {
-        unsigned int index = (int)elm_object_item_data_get(it);
+        unsigned int index = (uintptr_t)elm_object_item_data_get(it);
         //PRINTFUNC(DLOG_DEBUG,"index = %d",index);
 
         if (index < recent_emoji_list.size()) {
@@ -492,7 +493,7 @@ static void _emoticon_gl_content_unswallowed_cb(void *data, Evas_Object *obj, vo
 static Evas_Object * __emoticon_gl_recent_content_get(void *data, Evas_Object *obj, const char *part)
 {
     if (is_content_reuse_on) {
-        unsigned int index = (unsigned int)data;
+        unsigned int index = (uintptr_t)data;
         int new_index = 0;
 
     //PRINTFUNC(DLOG_DEBUG,"%s %d", part, index);
@@ -518,7 +519,7 @@ static Evas_Object * __emoticon_gl_recent_content_get(void *data, Evas_Object *o
             return btn;
         }
     } else {
-        unsigned int index = (unsigned int)data;
+        unsigned int index = (uintptr_t)data;
         int new_index = 0;
 
     //    PRINTFUNC(DLOG_DEBUG,"%s %d", part, index);
@@ -548,7 +549,7 @@ static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object
     //PRINTFUNC(DLOG_DEBUG,"%s", __func__);
 
     if (is_content_reuse_on) {
-        int index = (int)data;
+        int index = (uintptr_t)data;
         int new_index = 0;
 
         if (!strcmp(part, "elm.icon.1") || (!strcmp(part, "elm.icon.2")) || (!strcmp(part, "elm.icon.3"))) {
@@ -575,7 +576,7 @@ static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object
             const Eina_Unicode unicode_event[2] = { (Eina_Unicode)emoticon_info[new_index].code, 0 };
             char* utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
             elm_object_part_text_set(btn, "elm.text", utf_8);
-            evas_object_data_set(btn, "index", (void*)new_index);
+            evas_object_data_set(btn, "index", (void*)(uintptr_t)new_index);
 
             if (utf_8)
                 free(utf_8);
@@ -588,7 +589,7 @@ static Evas_Object * __emoticon_gl_emoticon_content_get(void *data, Evas_Object
             return btn;
         }
     } else {
-        int index = (int)data;
+        int index = (uintptr_t)data;
         int new_index = 0;
 
         if (!strcmp(part, "elm.icon.1") ||  (!strcmp(part, "elm.icon.2")) ||  (!strcmp(part, "elm.icon.3"))) {
@@ -722,7 +723,7 @@ static Eina_Bool _lazy_loader_cb_for_items(void *data)
     int i;
     for (i = loading_done_for_item; i < loading_top; i++ ) {
         if (i%3 == 0)
-            elm_genlist_item_append(gl, itc_emoticon, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i);
+            elm_genlist_item_append(gl, itc_emoticon, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i);
     }
 
     loading_done_for_item = loading_top;
@@ -739,7 +740,7 @@ void _create_reusable_contents(Evas_Object *gl){
 
     for (i = 0; i < INITAL_ITEM_UNIT; i++ ) {
         if (i%3 == 0)
-            elm_genlist_item_append(gl, itc_emoticon, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i);
+            elm_genlist_item_append(gl, itc_emoticon, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i);
     }
 
     lazy_loading_timer_for_items = ecore_timer_add(0.1, _lazy_loader_cb_for_items, (void *)gl);
@@ -842,7 +843,7 @@ void _update_emoticon_items(void *data)
 
         for (i=0;i < recent_emoji_list.size();i=i+3)
         {
-            it = elm_genlist_item_append(gl, itc_recent, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i);
+            it = elm_genlist_item_append(gl, itc_recent, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i);
         }
     }
 
@@ -857,7 +858,7 @@ void _update_emoticon_items(void *data)
     } else {
         // Emoticons
         for (i=0;i< EMOTICON_CNT;i=i+3) {
-            it = elm_genlist_item_append(gl, itc_emoticon, (void*)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)i);
+            it = elm_genlist_item_append(gl, itc_emoticon, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, (void *)(uintptr_t)i);
             it_last = it;
         }
         elm_genlist_item_class_free(itc_emoticon);
index f5a426e..d7b14b5 100755 (executable)
@@ -23,8 +23,8 @@
 #include <vconf.h>
 #include <vconf-keys.h>
 
-//#include "ui_extension.h"
 #include "w-input-selector.h"
+#include "w-input-template.h"
 #include "w-input-keyboard.h"
 #include "w-input-stt-ise.h"
 #include "w-input-emoticon.h"
@@ -43,6 +43,8 @@ InputTypeData g_input_type_data;
 static Elm_Object_Item *it_empty;
 static Elm_Object_Item *it_title;
 
+static unsigned int g_template_item_size = 0;          /* Current Template item size */
+
 Evas_Coord last_step; // 0 ~ 9 for gesture, 10~11 for rotary
 
 void _init_app_data(App_Data* app_data);
@@ -50,25 +52,24 @@ static void _app_language_changed(app_event_info_h event_info, void *user_data);
 
 Evas_Object* _create_genlist(Evas_Object* parent);
 void _create_genlist_items(void* user_data);
+void _create_header_items(void *user_data);
+void _update_genlist_items(void *user_data);
+unsigned int _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_type_deinit(void);
 
-
-
 void _init_app_data(App_Data* app_data)
 {
-    app_data->win_main = NULL;
-    app_data->layout_main = NULL;
-    app_data->conform = NULL;
-    app_data->naviframe = NULL;
-    app_data->genlist = NULL;
+       app_data->win_main = NULL;
+       app_data->layout_main = NULL;
+       app_data->conform = NULL;
+       app_data->naviframe = NULL;
+       app_data->genlist = NULL;
 
-    app_data->res_path = NULL;
+       app_data->res_path = NULL;
 }
 
-
-
 Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
 {
        Evas_Object* window;
@@ -89,7 +90,6 @@ Evas_Object* load_edj(Evas_Object* parent, const char* file, const char* group)
 
                evas_object_size_hint_weight_set(window, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        }
-
        return window;
 }
 
@@ -108,9 +108,9 @@ void init_customizing_theme(void)
 
 static Eina_Bool back_cb(void *data, Elm_Object_Item *it)
 {
-    reply_to_sender_by_callback_for_back();
-    elm_exit();
-    return EINA_FALSE;
+       reply_to_sender_by_callback_for_back();
+       elm_exit();
+       return EINA_FALSE;
 }
 
 static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
@@ -138,6 +138,11 @@ static void _stt_clicked_cb(void *data, Evas_Object * obj, void *event_info)
        }
 }
 
+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;
@@ -147,7 +152,7 @@ static void _emoticon_clicked_cb(void *data, Evas_Object * obj, void *event_info
        if(!ad)
                return;
 
-    ise_show_emoticon_list(ad);
+       ise_show_emoticon_list(ad);
 }
 
 static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info)
@@ -162,6 +167,58 @@ static void _keyboard_clicked_cb(void *data, Evas_Object * obj, void *event_info
        input_keyboard_launch(ad->win_main, data);
 }
 
+static void __ise_template_gl_sel(void *data, Evas_Object *obj, void *event_info)
+{
+       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();
+
+               if (index < (int)template_list.size()) {
+                       reply_to_sender_by_callback(gettext(template_list[index].text.c_str()), "template");
+                       elm_exit();
+               }
+       }
+}
+
+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 Evas_Object * __ise_gl_2button_content_get(void *data, Evas_Object *obj, const char *part)
 {
        char *first_input_type = *(g_input_type_data.input_type_array + 0);
@@ -556,8 +613,6 @@ _main_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
 
 void _create_genlist_items(void* user_data)
 {
-       LOGD("[psw] _create_genlist_items");
-
        App_Data* app_data = (App_Data*) user_data;
 
        if(NULL == app_data->genlist) {
@@ -604,6 +659,8 @@ void _create_genlist_items(void* user_data)
 
        elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
 
+       g_template_item_size = _update_template_items(app_data);
+
        Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
        elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
 
@@ -613,6 +670,118 @@ void _create_genlist_items(void* user_data)
        elm_genlist_item_class_free(itc1);
 }
 
+void _create_header_items(void *user_data)
+{
+       Elm_Genlist_Item_Class * itc0 = elm_genlist_item_class_new();
+       itc0->item_style = "title";
+       itc0->func.text_get = NULL;
+       itc0->func.content_get = NULL;
+       itc0->func.state_get = NULL;
+       itc0->func.del = NULL;
+
+       Elm_Genlist_Item_Class * itc1 = elm_genlist_item_class_new();
+       if (g_input_type_data.input_type_array_len == 2) {
+               itc1->item_style = "2button_flat";
+               itc1->func.text_get = NULL;
+               itc1->func.content_get = __ise_gl_2button_content_get;
+               itc1->func.state_get = NULL;
+               itc1->func.del = NULL;
+       } else {
+               itc1->item_style = "3button_flat";
+               itc1->func.text_get = NULL;
+               itc1->func.content_get = __ise_gl_3button_content_get;
+               itc1->func.state_get = NULL;
+               itc1->func.del = NULL;
+       }
+
+       // dummy title for empty space
+       it_empty = elm_genlist_item_append(app_data->genlist, itc0,
+                               NULL, NULL,
+                               ELM_GENLIST_ITEM_NONE,
+                               NULL, NULL);
+
+       // 3 Buttons
+       it_title = elm_genlist_item_append(app_data->genlist, itc1,
+                                                       NULL, NULL,
+                                                       ELM_GENLIST_ITEM_NONE,
+                                                       NULL, NULL);
+
+       elm_genlist_item_select_mode_set(it_title, ELM_OBJECT_SELECT_MODE_NONE);
+
+       elm_genlist_item_class_free(itc0);
+       elm_genlist_item_class_free(itc1);
+}
+
+void _update_genlist_items(void *user_data)
+{
+       elm_genlist_clear(app_data->genlist);
+
+       _create_header_items(user_data);
+
+       g_template_item_size = _update_template_items(user_data);
+
+       /* Update genlist item position */
+       Elm_Object_Item *item = elm_genlist_item_next_get(it_title);
+       elm_genlist_item_show(item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
+}
+
+unsigned int _update_template_items(void *user_data)
+{
+       App_Data* app_data;
+
+       Elm_Object_Item *first;
+
+       unsigned int i = 0;
+       unsigned int item_size = 0;
+
+       app_data = (App_Data *)user_data;
+
+       if (app_data == NULL) {
+               PRINTFUNC(DLOG_ERROR, "Can not get app_data");
+               return item_size;
+       }
+
+       if (app_data->genlist == NULL) {
+               /* smartreply will update when genlist is exist only */
+               PRINTFUNC(DLOG_ERROR, "Can not get getlist");
+               return item_size;
+       }
+
+       first = elm_genlist_first_item_get(app_data->genlist);
+       if (first == NULL)
+               return 0;
+       elm_genlist_item_next_get(first);
+
+       /* Append New Template list */
+       const std::vector<TemplateData> template_list = input_template_get_list();
+
+       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++) {
+                       elm_genlist_item_append(app_data->genlist,
+                                       itc,
+                                       (void *)i,
+                                       NULL,
+                                       ELM_GENLIST_ITEM_NONE,
+                                       __ise_template_gl_sel,
+                                       app_data);
+                       item_size++;
+               }
+               elm_genlist_item_class_free(itc);
+       }
+
+       return item_size;
+}
+
 bool _app_create(void* user_data)
 {
        int width = 1000, height = 1000;
@@ -727,6 +896,9 @@ void _app_service(app_control_h service, void* user_data)
 
        input_keyboard_init(service);
 
+       input_template_init(service);
+       input_template_set_notify(_input_template_notify_cb,  NULL);
+
        _create_genlist_items(app_data);
 
 ACTIVATE :
@@ -764,6 +936,10 @@ void _app_terminate(void* user_data)
                free(app_data->shared_res_path);
 
        input_keyboard_deinit();
+
+       input_template_unset_notify();
+       input_template_deinit();
+
        input_type_deinit();
 }
 
index 2084348..8f0a283 100755 (executable)
@@ -21,6 +21,7 @@
 #include <app.h>
 #include <string>
 #include <efl_extension.h>
+#include <stdint.h>
 
 
 #include <stt.h>
@@ -375,7 +376,7 @@ static void _language_changed_cb(void *_data, Evas_Object *_obj, void *_event_in
     if (!_obj) return ;
     if (!_data) return ;
 
-    int index = (int)_data;
+    int index = (uintptr_t)_data;
     std::string terms = "";
 
     char body_str[40000];
index 56514f7..7305ddb 100755 (executable)
@@ -25,6 +25,7 @@
 #include <string>
 #include <efl_extension.h>
 #include <feedback.h>
+#include <stdint.h>
 
 #include "Debug.h"
 #include "w-input-selector.h"
@@ -40,7 +41,7 @@ using namespace std;
 #define GRP_PORTRAIT "mic_control"
 
 #define item_append(obj, style, index, cb, udata) \
-               elm_genlist_item_append(obj, &(style), (void *)index, NULL, ELM_GENLIST_ITEM_NONE, cb, udata)
+               elm_genlist_item_append(obj, &(style), (void *)(uintptr_t)index, NULL, ELM_GENLIST_ITEM_NONE, cb, udata)
 
 #define VIRTUAL_TEXT_AREA_FONT_STYLE \
                "DEFAULT='font=Tizen:style=Regular  font_size=32 color=#FFFFFF color_class=AT013 text_class=tizen wrap=mixed align=center' \
@@ -906,11 +907,11 @@ char *__get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
 
        if(!strcmp(part, "elm.text"))
        {
-               if((int)data == 0) {
+               if((uintptr_t)data == 0) {
                        return strdup(_("IDS_VC_BODY_AUTOMATIC"));
                } else {
                        char *s = NULL;
-                       s = (char *)disp_lang_array[(int)data];
+                       s = (char *)disp_lang_array[(uintptr_t)data];
 
                        if(s) {
                                char *p = strchr(s, '(');
@@ -925,7 +926,7 @@ char *__get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
                }
                return strdup(text);
        } else if (!strcmp(part, "elm.text.1")) {
-               if ((int)data == 0) {
+               if ((uintptr_t)data == 0) {
                        char* value = NULL;
                        value = vconf_get_str(VCONFKEY_LANGSET);
                        if (NULL == value) {
@@ -945,7 +946,7 @@ char *__get_genlist_item_label(void *data, Evas_Object *obj, const char *part)
 
                } else {
                        char *s = NULL;
-                       s = (char *)disp_lang_array[(int)data];
+                       s = (char *)disp_lang_array[(uintptr_t)data];
 
                        if(s) {
                                char *p = strchr(s, '(');
@@ -1103,7 +1104,7 @@ static void language_set_genlist_radio_cb(void *data, Evas_Object *obj, void *ev
        Elm_Object_Item * item = (Elm_Object_Item *) event_info;
        if (item) {
                elm_genlist_item_selected_set(item, 0);
-               index = (int)elm_object_item_data_get(item);
+               index = (uintptr_t)elm_object_item_data_get(item);
                elm_genlist_item_update(item);
        }
        set_language_value(index);
diff --git a/src/w-input-template.cpp b/src/w-input-template.cpp
new file mode 100755 (executable)
index 0000000..afe2410
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+ * 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);
+}