summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/CMakeLists.txt34
-rwxr-xr-xlib/common/ct-common.c287
-rwxr-xr-xlib/common/ct-detail-setting.c138
-rwxr-xr-xlib/common/ct-group-edit-view.c832
-rwxr-xr-xlib/common/ct-list-detail.c362
-rwxr-xr-xlib/common/ct-list-setting.c90
-rwxr-xr-xlib/common/ct-text.c255
-rwxr-xr-xlib/details/CMakeLists.txt22
-rwxr-xr-xlib/details/ct-detail-main.c613
-rwxr-xr-xlib/details/ct-detail-utils.c570
-rwxr-xr-xlib/details/ct-detail-utils.h44
-rwxr-xr-xlib/details/ct-detail-view.c1003
-rwxr-xr-xlib/details/ct-detail-view.h32
-rwxr-xr-xlib/details/ct-group-assign-view.c335
-rwxr-xr-xlib/details/ct-group-assign-view.h32
-rwxr-xr-xlib/details/ct-input-num-email.c891
-rwxr-xr-xlib/details/ct-input-num-email.h32
-rwxr-xr-xlib/details/ct-input-utils.c784
-rwxr-xr-xlib/details/ct-input-utils.h56
-rwxr-xr-xlib/details/ct-input-view.c1639
-rwxr-xr-xlib/details/ct-input-view.h32
-rwxr-xr-xlib/include/ct-common.h482
-rwxr-xr-xlib/include/ct-detail.h39
-rwxr-xr-xlib/include/ct-list.h73
-rwxr-xr-xlib/include/ct-path.h61
-rwxr-xr-xlib/list/CMakeLists.txt15
-rwxr-xr-xlib/list/ct-list-contact-view.c1155
-rwxr-xr-xlib/list/ct-list-contact-view.h40
-rwxr-xr-xlib/list/ct-list-edit-view.c881
-rwxr-xr-xlib/list/ct-list-edit-view.h39
-rwxr-xr-xlib/list/ct-list-group-view.c472
-rwxr-xr-xlib/list/ct-list-group-view.h29
-rwxr-xr-xlib/list/ct-list-main.c302
-rwxr-xr-xlib/list/ct-list-utils.c309
-rwxr-xr-xlib/list/ct-list-utils.h73
-rwxr-xr-xlib/list/ct-list-view-ug.c342
-rw-r--r--lib/list/ct-list-view-ug.h34
-rwxr-xr-xlib/settings/CMakeLists.txt14
-rwxr-xr-xlib/settings/ct-setting-main.c182
-rwxr-xr-xlib/settings/ct-setting-view.c1117
-rwxr-xr-xlib/settings/ct-setting-view.h31
41 files changed, 13773 insertions, 0 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
new file mode 100755
index 0000000..f42aa61
--- /dev/null
+++ b/lib/CMakeLists.txt
@@ -0,0 +1,34 @@
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+SET(UG_TARGET ug-contacts-efl)
+SET(COMMON_LIB contacts-common)
+SET(CT_DETAILS ug-contacts-details-efl)
+SET(CT_LIST ug-contacts-list-efl)
+SET(CT_SETTING ug-contacts-settings-efl)
+SET(UGLIBDIR "/opt/ug/lib")
+
+FILE(GLOB COMMON_SRCS common/*.c)
+
+INCLUDE(FindPkgConfig)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC")
+
+ADD_LIBRARY(${COMMON_LIB} STATIC ${COMMON_SRCS})
+SET_TARGET_PROPERTIES(${COMMON_LIB} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
+TARGET_LINK_LIBRARIES(${COMMON_LIB} ${pkgs_LDFLAGS})
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/contacts.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/images
+ ${EDC_SRC_DIR}/contacts.edc ${CMAKE_BINARY_DIR}/contacts.edj
+ DEPENDS ${EDC_SRC_DIR}/contacts.edc ${EDC_SRC_DIR}/list.edc ${EDC_SRC_DIR}/progress.edc ${EDC_SRC_DIR}/layout_effect.edc ${EDC_SRC_DIR}/gl_title.edc
+ )
+
+ADD_CUSTOM_TARGET(contacts_edj_build DEPENDS ${CMAKE_BINARY_DIR}/contacts.edj)
+
+#INSTALL(TARGETS ${COMMON_LIB} DESTINATION /usr/lib)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/contacts.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/contacts-ug.h DESTINATION /usr/include)
+
+ADD_SUBDIRECTORY(details)
+ADD_SUBDIRECTORY(list)
+ADD_SUBDIRECTORY(settings)
diff --git a/lib/common/ct-common.c b/lib/common/ct-common.c
new file mode 100755
index 0000000..8959bbf
--- /dev/null
+++ b/lib/common/ct-common.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <ui-gadget-module.h>
+#include "contacts.h"
+#include "ct-common.h"
+
+#ifdef CT_TIMECHECK
+double ct_set_start_time(void)
+{
+ struct timeval tv;
+ double curtime;
+
+ gettimeofday(&tv, NULL);
+ curtime = tv.tv_sec * 1000 + (double)tv.tv_usec/1000;
+ return curtime;
+}
+
+double ct_exec_time(double start)
+{
+ double end = ct_set_start_time();
+ return (end - start - ct_correction);
+}
+
+int ct_init_time(void)
+{
+ double temp_t;
+ temp_t = ct_set_start_time();
+ ct_correction = ct_exec_time(temp_t);
+
+ return 0;
+}
+#endif
+
+void ctui_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, void *priv)
+{
+ Evas_Object *base;
+
+ if (!ug)
+ return;
+
+ base = ug_get_layout(ug);
+ if (!base)
+ return;
+
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(ug_get_window(), base);
+ evas_object_show(base);
+}
+
+void ctui_ug_destroy_cb(struct ui_gadget *ug, void *priv)
+{
+ c_retm_if(NULL == ug, "ug is NULL");
+
+ ug_destroy(ug);
+}
+
+Evas_Object* ctui_create_base_layout(Evas_Object *parent,
+ bool is_fullview)
+{
+ Evas_Object *base;
+
+ base = elm_layout_add(parent);
+ c_retvm_if(NULL == base, NULL, "elm_layout_add() Failed");
+
+ if (is_fullview)
+ elm_layout_theme_set(base, "layout", "application", "default");
+ else
+ elm_layout_theme_set(base, "layout", "application", "noindicator");
+
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ return base;
+}
+
+void ctui_ug_destroy_me_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ /* evas_object_smart_callback_del() func will be deleted */
+ evas_object_smart_callback_del(obj, "clicked", ctui_ug_destroy_me_cb);
+ ug_destroy_me(data);
+}
+
+static void popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ evas_object_del(obj);
+}
+
+Evas_Object * ctui_create_popup(Evas_Object *parent, const char *desc, double timeout)
+{
+ Evas_Object *notify;
+ notify = elm_popup_add(parent);
+ evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_smart_callback_add(notify, "block,clicked", popup_block_clicked_cb, NULL);
+ elm_popup_timeout_set(notify, timeout);
+ elm_object_text_set(notify, desc);
+ evas_object_show(notify);
+ return notify;
+}
+
+
+Evas_Object* ctui_set_bg(Evas_Object *parent)
+{
+ Evas_Object *bg;
+
+ bg = elm_bg_add(parent);
+ c_retvm_if(NULL == bg, NULL, "elm_bg_add() return NULL");
+
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(parent, "elm.swallow.bg", bg);
+
+ evas_object_show(bg);
+
+ return bg;
+}
+
+Evas_Object *ctui_create_notify(Evas_Object *parent)
+{
+ Evas_Object *info_layout;
+ Evas_Object *notify;
+
+ notify = elm_notify_add(parent);
+ elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
+
+ evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(notify, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ info_layout = elm_layout_add(parent);
+ elm_layout_theme_set(info_layout, "standard", "selectioninfo", "vertical/bottom_64");
+ elm_object_content_set(notify, info_layout);
+ evas_object_layer_set(notify, EVAS_LAYER_MAX);
+
+ evas_object_data_set(parent, "notify", notify);
+
+ return notify;
+}
+
+Evas_Object* ctui_show_notify(Evas_Object *parent, const char *msg, double timeout)
+{
+ Evas_Object *content;
+ Evas_Object *notify;
+
+ notify = evas_object_data_get(parent, "notify");
+ if (NULL == notify)
+ notify = ctui_create_notify(parent);
+
+ elm_notify_timeout_set(notify, timeout);
+
+ content = elm_object_content_get(notify);
+ c_retvm_if(NULL == content, NULL, "elm_object_content_get() return NULL");
+
+ edje_object_part_text_set(_EDJ(content), "elm.text", msg);
+ evas_object_show(notify);
+
+ return notify;
+}
+
+void ctui_hide_notify(Evas_Object *parent)
+{
+ Evas_Object *notify;
+
+ notify = evas_object_data_get(parent, "notify");
+ if (notify && evas_object_visible_get(notify))
+ evas_object_hide(notify);
+}
+
+Evas_Object* ctui_create_nocontents(Evas_Object *parent, const char* label)
+{
+ Evas_Object *layout;
+
+ layout = elm_layout_add(parent);
+ c_retvm_if(NULL == layout, NULL, "elm_layout_add() return NULL");
+
+ elm_layout_theme_set(layout, "layout", "nocontents", "full");
+ elm_object_part_text_set(layout, "elm.text", label);
+
+ return layout;
+}
+
+Evas_Object* ctui_create_popup_button(Evas_Object *popup, int index, const char* label, Evas_Smart_Cb cb, void *cb_data)
+{
+ Evas_Object *btn;
+ char part[CT_TEXT_SHORT_LEN];
+
+ btn = elm_button_add(popup);
+ elm_object_text_set(btn, label);
+ snprintf(part, sizeof(part), "button%d", index);
+
+ elm_object_part_content_set(popup, part, btn);
+ evas_object_smart_callback_add(btn, "clicked", cb, cb_data);
+
+ return btn;
+}
+
+static void editfield_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!elm_entry_is_empty(obj))
+ elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm");
+
+ if (elm_object_focus_get(data)) {
+ if (elm_entry_is_empty(obj))
+ elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
+ else
+ elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
+ }
+}
+static void editfield_focused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!elm_entry_is_empty(obj))
+ elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
+ elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm");
+}
+
+static void editfield_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (elm_entry_is_empty(obj))
+ elm_object_signal_emit(data, "elm,state,guidetext,show", "elm");
+ elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
+}
+
+static void editfield_eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ elm_entry_entry_set(data, "");
+}
+
+Evas_Object* ctui_create_editfield(Evas_Object *parent, const char *title, const char *guide, bool multiline)
+{
+ Evas_Object *layout, *entry;
+
+ layout = elm_layout_add(parent);
+ if (title && *title) {
+ elm_layout_theme_set(layout, "layout", "editfield", "title");
+ elm_object_part_text_set(layout, "elm.text", title);
+ }
+ else
+ elm_layout_theme_set(layout, "layout", "editfield", "default");
+
+ if (guide && *guide)
+ elm_object_part_text_set(layout, "elm.guidetext", guide);
+
+ entry = elm_entry_add(parent);
+ if (!multiline) {
+ elm_entry_scrollable_set(entry, EINA_TRUE);
+ elm_entry_single_line_set(entry, EINA_TRUE);
+ ctui_entry_limit_size_set(entry);
+ }
+ elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
+ evas_object_smart_callback_add(entry, "changed", editfield_changed_cb, layout);
+ evas_object_smart_callback_add(entry, "focused", editfield_focused_cb, layout);
+ evas_object_smart_callback_add(entry, "unfocused", editfield_unfocused_cb, layout);
+ elm_object_part_content_set(layout, "elm.swallow.content", entry);
+
+ elm_object_signal_callback_add(layout, "elm,eraser,clicked", "elm", editfield_eraser_clicked_cb, entry);
+ return layout;
+}
+
+void ct_toolbar_disalbed_item_append(Evas_Object *toolbar, int cnt)
+{
+ int i;
+ Elm_Object_Item *item;
+ for(i=0;i<cnt;i++) {
+ item = elm_toolbar_item_append(toolbar, NULL, NULL, NULL, NULL);
+ elm_object_item_disabled_set(item, EINA_TRUE);
+ }
+}
+
diff --git a/lib/common/ct-detail-setting.c b/lib/common/ct-detail-setting.c
new file mode 100755
index 0000000..abcc612
--- /dev/null
+++ b/lib/common/ct-detail-setting.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include "contacts.h"
+#include "ct-common.h"
+
+static void detail_setting_gl_addrbook_del(void *data, Evas_Object *obj)
+{
+ ct_ab_popup_data *info = data;
+ c_retm_if(NULL == info, "data is NULL");
+ free(info->name);
+ free(info);
+}
+
+static char* detail_setting_gl_addrbook_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ ct_ab_popup_data *ab_popup_data = data;
+ c_retvm_if(NULL == ab_popup_data, NULL, "parameter(ab_popup_data) is NULL");
+
+ if (0 == strcmp(part, "elm.text") || 0 == strcmp(part, "elm.text.1"))
+ return SAFE_STRDUP(ab_popup_data->name);
+ else if(0 == strcmp(part, "elm.text.2"))
+ return SAFE_STRDUP(T_(CT_GET_TEXT_ACC_TYPE, ab_popup_data->type));
+
+ return NULL;
+}
+
+enum ADDRBOOK_ITC_TYPE {
+ ADDRBOOK_ITC,
+ ADDRBOOK_ITC_NAME,
+ ADDRBOOK_ITC_MAX,
+};
+
+static Elm_Genlist_Item_Class addrbook_itcs[ADDRBOOK_ITC_MAX] = {
+ {
+ .item_style = "1text",
+ .func.text_get = detail_setting_gl_addrbook_label_get,
+ .func.del = detail_setting_gl_addrbook_del
+ },
+ {
+ .item_style = "2text.2",
+ .func.text_get = detail_setting_gl_addrbook_label_get,
+ .func.del = detail_setting_gl_addrbook_del
+ },
+};
+
+Evas_Object* ctui_addrbook_popup(Evas_Object *parent, Evas_Smart_Cb gl_sel_cb,
+ void *data, int mode_filter, Evas_Smart_Cb response_cb, void *response_cb_data)
+{
+ int ret;
+ CTSiter *iter;
+ Evas_Object *genlist;
+ Evas_Object *popup;
+ ct_ab_popup_data *ab_popup_data;
+
+ popup = elm_popup_add(parent);
+ elm_object_style_set(popup, "liststyle");
+ ctui_create_popup_button(popup, 1, S_(CT_SYS_POP_CLOSE), response_cb, response_cb_data);
+ evas_object_show(popup);
+
+ genlist = elm_genlist_add(popup);
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_data_set(genlist, "data", data);
+
+ ab_popup_data = calloc(1, sizeof(ct_ab_popup_data));
+ c_retvm_if(NULL == ab_popup_data, NULL, "calloc() return NULL");
+ ab_popup_data->id = 0;
+ ab_popup_data->name = strdup(S_(CT_SYS_BODY_PHONE));
+
+ elm_genlist_item_append(genlist, &addrbook_itcs[ADDRBOOK_ITC], ab_popup_data, NULL, ELM_GENLIST_ITEM_NONE, gl_sel_cb, ab_popup_data);
+
+ ret = contacts_svc_get_list(CTS_LIST_ALL_ADDRESSBOOK, &iter);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_get_list() Failed(%d)", ret);
+
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue *ab;
+
+ ab_popup_data = calloc(1, sizeof(ct_ab_popup_data));
+ if (NULL == ab_popup_data) {
+ ERR("calloc() return NULL");
+ continue;
+ }
+
+ ab = contacts_svc_iter_get_info(iter);
+ if (CTS_ADDRESSBOOK_MODE_READONLY == mode_filter &&
+ contacts_svc_value_get_int(ab, CTS_LIST_ADDRESSBOOK_MODE_INT) == mode_filter) {
+ free(ab_popup_data);
+ ret = contacts_svc_value_free(ab);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_free() Failed(%d)", ret);
+ continue;
+ }
+
+ ab_popup_data->id = contacts_svc_value_get_int(ab, CTS_LIST_ADDRESSBOOK_ID_INT);
+ ab_popup_data->name = contacts_svc_value_steal_str(ab, CTS_LIST_ADDRESSBOOK_NAME_STR);
+ ab_popup_data->type = contacts_svc_value_get_int(ab, CTS_LIST_ADDRESSBOOK_ACC_TYPE_INT);
+ ab_popup_data->mode = contacts_svc_value_get_int(ab, CTS_LIST_ADDRESSBOOK_MODE_INT);
+
+ if (CTS_ADDRESSBOOK_TYPE_INTERNAL != ab_popup_data->type)
+ elm_genlist_item_append(genlist, &addrbook_itcs[ADDRBOOK_ITC_NAME], ab_popup_data, NULL,
+ ELM_GENLIST_ITEM_NONE, gl_sel_cb, ab_popup_data);
+ else
+ elm_genlist_item_append(genlist, &addrbook_itcs[ADDRBOOK_ITC], ab_popup_data, NULL,
+ ELM_GENLIST_ITEM_NONE, gl_sel_cb, ab_popup_data);
+
+ ret = contacts_svc_value_free(ab);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_free() Failed(%d)", ret);
+ }
+ contacts_svc_iter_remove(iter);
+
+ elm_object_content_set(popup, genlist);
+ evas_object_show(genlist);
+
+ return popup;
+}
+
diff --git a/lib/common/ct-group-edit-view.c b/lib/common/ct-group-edit-view.c
new file mode 100755
index 0000000..e297a08
--- /dev/null
+++ b/lib/common/ct-group-edit-view.c
@@ -0,0 +1,832 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include "contacts.h"
+#include "ct-list.h"
+
+enum GEDIT_ITC_TYPE{
+ GEDIT_ITC_ADDRBOOK,
+ GEDIT_ITC_GROUP,
+ GEDIT_ITC_GROUP_CREATE,
+ GEDIT_ITC_BTN,
+ GEDIT_ITC_SEPARATOR,
+};
+
+static Elm_Genlist_Item_Class gedit_itcs[] = {
+ {.item_style="dialogue/title"},
+ {.item_style="dialogue/1text.2icon.2"},
+ {.item_style="dialogue/1text"},
+ {.item_style="dialogue/bg/1icon"},
+ {.item_style="dialogue/separator/10"},
+};
+
+static void gedit_popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_group_edit_data *gedit_d = data;
+
+ evas_object_del(gedit_d->popup);
+ gedit_d->popup = NULL;
+}
+
+static void gedit_gl_del(void *data, Evas_Object *obj)
+{
+ ct_group_list *info = data;
+ c_retm_if(NULL == data, "data is NULL");
+
+ free(info->name);
+ free(info);
+}
+
+enum
+{
+ DELETE_GROUP_ONLY,
+ DELETE_GROUP_WITH_MEMBER,
+};
+
+static void gedit_notify_update(ct_group_edit_data *cgedit_d)
+{
+ Evas_Object *notify;
+ if (0 < cgedit_d->count) {
+ char buf[CT_TEXT_SHORT_LEN];
+ snprintf(buf, sizeof(buf), "%s (%d)", S_(CT_SYS_POP_SELECTED), cgedit_d->count);
+ notify = ctui_show_notify(cgedit_d->navi, buf, 0.0);
+ }
+ else {
+ notify = evas_object_data_get(cgedit_d->navi, "notify");
+ if (notify)
+ evas_object_hide(notify);
+ }
+}
+
+
+static void gedit_navi_item_update(ct_group_edit_data *cgedit_d)
+{
+ if (0 < cgedit_d->count)
+ elm_object_item_disabled_set(cgedit_d->btn_op, EINA_FALSE);
+ else
+ elm_object_item_disabled_set(cgedit_d->btn_op, EINA_TRUE);
+}
+
+
+static void gedit_navi_item_clear(Elm_Object_Item *item)
+{
+ Evas_Object *btn;
+
+ btn = elm_object_item_part_content_get(item, "title_left_btn");
+ if (btn)
+ evas_object_del(btn);
+
+ btn = elm_object_item_part_content_get(item, "title_right_btn");
+ if (btn)
+ evas_object_del(btn);
+}
+
+static void gedit_gl_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *genlist;
+ ct_group_edit_data *cgedit_d;
+ ct_group_list *info = data;
+
+ elm_genlist_item_selected_set(event_info, EINA_FALSE);
+
+ c_retm_if(NULL == data, "data is NULL");
+
+ genlist = elm_object_item_widget_get(info->item);
+ cgedit_d = evas_object_data_get(genlist, "cgedit_d");
+
+ if (EINA_FALSE == elm_genlist_decorate_mode_get(genlist)
+ || EINA_TRUE == elm_genlist_item_flip_get(info->item))
+ return;
+
+ info->selected = !info->selected;
+ elm_genlist_item_update(info->item);
+
+ if (EINA_TRUE == info->selected)
+ cgedit_d->count++;
+ else
+ cgedit_d->count--;
+
+ gedit_navi_item_update(cgedit_d);
+ gedit_notify_update(cgedit_d);
+}
+
+static void gedit_group_delete(int op_code, Evas_Object *genlist)
+{
+ int ret;
+ bool completed = true;
+ Elm_Object_Item *item;
+ GSList *deleted = NULL;
+ ct_group_edit_data *cgedit_d = evas_object_data_get(genlist, "cgedit_d");
+
+ gedit_popup_hide_cb(cgedit_d, NULL, NULL);
+
+ ret = contacts_svc_begin_trans();
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_begin_trans() Failed(%d)", ret);
+
+ item = elm_genlist_first_item_get(genlist);
+ while (item) {
+ ct_group_list *info = elm_object_item_data_get(item);
+ if (info && info->selected) {
+ if (DELETE_GROUP_WITH_MEMBER == op_code) {
+ ret = contacts_svc_delete_group_with_members(info->id_grp);
+ if (CTS_SUCCESS != ret) {
+ ERR("Error : contacts_svc_delete_group_with_members() Failed(%d)", ret);
+ completed = false;
+ break;
+ }
+ }
+ else {
+ ret = contacts_svc_delete_group(info->id_grp);
+ if (CTS_SUCCESS != ret) {
+ ERR("Error : contacts_svc_delete_group() Failed(%d)", ret);
+ completed = false;
+ break;
+ }
+ }
+ deleted = g_slist_append (deleted, item);
+ }
+ item = elm_genlist_item_next_get(item);
+ }
+
+ if (completed) {
+ GSList *l;
+ ret = contacts_svc_end_trans(true);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+ for (l=deleted; l; l=l->next) {
+ elm_object_item_del(l->data);
+ cgedit_d->count--;
+ }
+ if (deleted)
+ g_slist_free(deleted);
+
+ ctui_show_notify(cgedit_d->navi, S_(CT_SYS_POP_DELETED), 2.0);
+ elm_naviframe_item_pop(cgedit_d->navi);
+ }
+ else {
+ ret = contacts_svc_end_trans(false);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+ ctui_show_notify(cgedit_d->navi, S_(CT_SYS_POP_FAILED), 2.0);
+ }
+}
+
+static void gedit_group_delete_only(void *data, Evas_Object *obj, void *event_info)
+{
+ gedit_group_delete(DELETE_GROUP_ONLY, data);
+}
+
+static void gedit_group_delete_with_member(void *data, Evas_Object *obj, void *event_info)
+{
+ gedit_group_delete(DELETE_GROUP_WITH_MEMBER, data);
+}
+
+static void gedit_group_delete_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *popup;
+ Evas_Object *list;
+ Evas_Object *genlist = data;
+ ct_group_edit_data *cgedit_d = evas_object_data_get(genlist, "cgedit_d");
+
+ popup = elm_popup_add(cgedit_d->navi);
+ elm_object_style_set(popup, "min_liststyle");
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ ctui_create_popup_button(popup, 1, S_(CT_SYS_POP_CLOSE), gedit_popup_hide_cb, cgedit_d);
+
+ list = elm_list_add(popup);
+ elm_list_item_append(list, T_(CT_GET_TEXT_BASIC, CTTEXT_REMOVE_GROUP_ONLY),
+ NULL, NULL, gedit_group_delete_only, data);
+ elm_list_item_append(list, T_(CT_GET_TEXT_BASIC, CTTEXT_REMOVE_GROUP_WITH_MEMBER),
+ NULL, NULL, gedit_group_delete_with_member, data);
+ elm_list_mode_set(list, ELM_LIST_EXPAND);
+ elm_object_content_set(popup, list);
+
+ cgedit_d->popup = popup;
+ evas_object_show(popup);
+}
+
+
+static void gedit_navi_item_disabled_set(Elm_Object_Item *item, Eina_Bool disabled)
+{
+ Evas_Object *btn;
+ btn = elm_object_item_part_content_get(item, "title_left_btn");
+ c_retm_if(NULL == btn, "elm_object_item_part_content_get() return NULL");
+ elm_object_focus_set(btn, EINA_FALSE);
+ elm_object_disabled_set(btn, disabled);
+}
+
+
+static void gedit_entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ char *text;
+ Evas_Object *genlist;
+ ct_group_list *info = data;
+ ct_group_edit_data *cgedit_d;
+
+ genlist = elm_object_item_widget_get(info->item);
+ cgedit_d = evas_object_data_get(genlist, "cgedit_d");
+
+ c_ret_if(cgedit_d->name_old);
+
+ text = ctui_entry_markup_to_utf8(elm_entry_entry_get(obj));
+ c_retm_if(NULL == text, "ctui_entry_markup_to_utf8() return NULL");
+
+ if (*text && strcmp(info->name, text))
+ gedit_navi_item_disabled_set(cgedit_d->navi_it, EINA_FALSE);
+ else
+ gedit_navi_item_disabled_set(cgedit_d->navi_it, EINA_TRUE);
+
+ free(text);
+}
+
+
+static void gedit_back_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_group_edit_data *cgedit_d = data;
+ ctui_hide_notify(cgedit_d->navi);
+ elm_naviframe_item_pop(cgedit_d->navi);
+}
+
+void ctui_gedit_navi_create_btn(ct_group_edit_data *cgedit_d)
+{
+ Eina_Bool disable;
+ Evas_Object *cbar;
+ Evas_Object *l_btn;
+
+ disable = (0 < cgedit_d->count) ? EINA_FALSE: EINA_TRUE;
+
+ cbar = elm_toolbar_add(cgedit_d->navi);
+ c_retm_if(NULL == cbar, "elm_toolbar_add() return NULL");
+ elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
+
+ cgedit_d->btn_op = elm_toolbar_item_append(cbar, cgedit_d->ctr_btn_info.icon_path, NULL,
+ cgedit_d->ctr_btn_info.cb, cgedit_d->ctr_btn_info.user_data);
+
+ ct_toolbar_disalbed_item_append(cbar, 3);
+
+ elm_object_item_disabled_set(cgedit_d->btn_op, disable);
+ elm_object_item_part_content_set(cgedit_d->navi_it, "controlbar", cbar);
+
+ l_btn = ctui_naviframe_btn(cgedit_d->navi, S_(CT_SYS_SK_CANCEL));
+ evas_object_smart_callback_add(l_btn, "clicked", gedit_back_btn_cb, cgedit_d);
+ elm_object_item_part_content_set(cgedit_d->navi_it, "prev_btn", l_btn);
+}
+
+static void gedit_redraw_genlist(ct_group_edit_data *cgedit_d)
+{
+ Evas_Object *genlist = cgedit_d->genlist;
+ Elm_Object_Item *item;
+
+ gedit_navi_item_clear(cgedit_d->navi_it);
+ ctui_gedit_navi_create_btn(cgedit_d);
+
+ item = elm_genlist_first_item_get(genlist);
+ while (item) {
+ elm_object_item_disabled_set(item, EINA_FALSE);
+ item = elm_genlist_item_next_get(item);
+ }
+ cgedit_d->is_rename = false;
+}
+
+static int gedit_group_create(int id_ab, const char *grp_name, ct_group_edit_data *cgedit_d)
+{
+ int ret = CTS_ERR_FAIL;
+
+ if (*grp_name) {
+ CTSvalue *group;
+ group = contacts_svc_value_new(CTS_VALUE_GROUP);
+ contacts_svc_value_set_str(group, CTS_GROUP_VAL_NAME_STR, grp_name);
+ ret = contacts_svc_insert_group(id_ab, group);
+ contacts_svc_value_free(group);
+ }
+
+ return ret;
+}
+
+static int gedit_group_rename(int grp_id, const char *grp_name, ct_group_edit_data *cgedit_d)
+{
+ int ret;
+ int ret_trans;
+ CTSvalue *group;
+ bool success = true;
+
+ ret = contacts_svc_begin_trans();
+ if (ret < CTS_SUCCESS)
+ return ret;
+
+ if (*grp_name) {
+ ret = contacts_svc_get_group(grp_id, &group);
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_get_group(%d) Failed", ret);
+ success = false;
+ }
+ else {
+ ret = contacts_svc_value_set_str(group, CTS_GROUP_VAL_NAME_STR, grp_name);
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_value_set_str() Failed(%d)", ret);
+ success = false;
+ }
+ else {
+ ret = contacts_svc_update_group(group);
+ if (ret < CTS_SUCCESS)
+ success = false;
+ }
+ contacts_svc_value_free(group);
+ }
+ if (cgedit_d->popup)
+ evas_object_smart_callback_add(cgedit_d->popup, "timeout", gedit_popup_hide_cb, cgedit_d);
+ }
+
+ if (success)
+ ret_trans = contacts_svc_end_trans(true);
+ else
+ ret_trans = contacts_svc_end_trans(false);
+ c_warn_if(ret_trans < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret_trans);
+
+ return ret;
+}
+
+static void gedit_err_entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_group_edit_data *cgedit_d = data;
+ evas_object_smart_callback_del(obj, "focused", gedit_err_entry_focused_cb);
+ ctui_entry_entry_set(obj, cgedit_d->name_old);
+ elm_entry_cursor_end_set(obj);
+ free(cgedit_d->name_old);
+ cgedit_d->name_old = NULL;
+}
+
+static void gedit_entry_set_err_message(Evas_Object *entry, const char *err_msg, ct_group_edit_data *cgedit_d) {
+ char msg[256];
+ snprintf(msg, sizeof(msg), "<color=#FF0000>%s</>", err_msg);
+ elm_entry_entry_set(entry, msg);
+ evas_object_smart_callback_add(entry, "focused", gedit_err_entry_focused_cb, cgedit_d);
+}
+
+static void gedit_save_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_group_list *info;
+ Evas_Object *genlist;
+ Evas_Object *entry;
+ char *text;
+ ct_group_edit_data *cgedit_d;
+
+ info = elm_object_item_data_get(data);
+ genlist = elm_object_item_widget_get(data);
+ entry = evas_object_data_get(genlist, "entry");
+
+ text = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ c_retm_if(NULL == text, "ctui_entry_markup_to_utf8() return NULL");
+
+ cgedit_d = evas_object_data_get(genlist, "cgedit_d");
+
+ if (info->id_grp)
+ ret = gedit_group_rename(info->id_grp, text, cgedit_d);
+ else {
+ ret = gedit_group_create(info->id_ab, text, cgedit_d);
+ if (CTS_SUCCESS < ret)
+ info->id_grp = ret;
+ }
+
+ if (ret < CTS_SUCCESS) {
+ const char *err_msg;
+ cgedit_d->name_old = text;
+
+ switch (ret) {
+ case CTS_ERR_DB_LOCK:
+ err_msg = T_(CT_GET_TEXT_ERR, CTTEXT_ERR_DB_LOCKED);
+ break;
+ case CTS_ERR_NO_SPACE:
+ err_msg = S_(CT_SYS_POP_NOT_ENOUGH_MEMORY);
+ break;
+ case CTS_ERR_ALREADY_EXIST:
+ err_msg = T_(CT_GET_TEXT_ERR, CTTEXT_ALREADY_EXIST);
+ break;
+ default:
+ err_msg = S_(CT_SYS_POP_FAILED);
+ break;
+ }
+
+ gedit_entry_set_err_message(entry, err_msg, cgedit_d);
+ gedit_navi_item_disabled_set(cgedit_d->navi_it, EINA_TRUE);
+ return;
+ }
+ evas_object_data_del(genlist, "entry");
+ free(text);
+
+ elm_naviframe_item_pop(cgedit_d->navi);
+}
+
+static void gedit_cancel_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_group_list *info = elm_object_item_data_get(data);
+ Evas_Object *genlist = elm_object_item_widget_get(data);
+ ct_group_edit_data *cgedit_d = evas_object_data_get(genlist, "cgedit_d");
+
+ elm_genlist_item_flip_set(data, EINA_FALSE);
+
+ if (!info->id_grp)
+ elm_object_item_del(data);
+
+ if (cgedit_d->name_old) {
+ free(cgedit_d->name_old);
+ cgedit_d->name_old = NULL;
+ }
+ gedit_redraw_genlist(cgedit_d);
+}
+
+static void gedit_enter_name_mode(Elm_Object_Item *item, ct_group_edit_data *cgedit_d)
+{
+ Elm_Object_Item *tmp_item;
+ Evas_Object *r_btn;
+ Evas_Object *l_btn;
+
+ elm_object_item_part_content_set(cgedit_d->navi_it, "controlbar", NULL);
+ elm_object_item_part_content_set(cgedit_d->navi_it, "prev_btn", NULL);
+ ctui_hide_notify(cgedit_d->navi);
+
+ r_btn = ctui_naviframe_btn(cgedit_d->navi, S_(CT_SYS_SK_CANCEL));
+ evas_object_smart_callback_add(r_btn, "clicked", gedit_cancel_btn_cb, item);
+ evas_object_show(r_btn);
+ elm_object_item_part_content_set(cgedit_d->navi_it, "title_right_btn", r_btn);
+
+ l_btn = ctui_naviframe_btn(cgedit_d->navi, S_(CT_SYS_SK_SAVE));
+ evas_object_smart_callback_add(l_btn, "clicked", gedit_save_btn_cb, item);
+ evas_object_show(l_btn);
+ elm_object_item_part_content_set(cgedit_d->navi_it, "title_left_btn", l_btn);
+
+ tmp_item = elm_genlist_first_item_get(cgedit_d->genlist);
+ while (tmp_item) {
+ elm_object_item_disabled_set(tmp_item, EINA_TRUE);
+ tmp_item = elm_genlist_item_next_get(tmp_item);
+ }
+ /** Defence code for genlist bug */
+ elm_object_item_disabled_set(item, EINA_FALSE);
+
+ cgedit_d->is_rename = true;
+}
+
+static void gedit_group_create_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_group_list *info = data;
+ ct_group_list *new_info;
+ ct_group_edit_data *cgedit_d;
+ Evas_Object *genlist;
+ Elm_Object_Item *item_separator;
+
+ genlist = elm_object_item_widget_get(info->item);
+ cgedit_d = evas_object_data_get(genlist, "cgedit_d");
+ if (!cgedit_d || cgedit_d->is_rename) return;
+
+ elm_genlist_item_selected_set(info->item, EINA_FALSE);
+
+ item_separator = elm_genlist_item_prev_get(info->item);
+
+ new_info = calloc(1, sizeof(ct_group_list));
+ new_info->id_ab = info->id_ab;
+ new_info->id_grp = 0;
+ new_info->name = strdup("");
+ new_info->item = elm_genlist_item_insert_before(cgedit_d->genlist, &gedit_itcs[GEDIT_ITC_GROUP_CREATE], new_info,
+ elm_genlist_item_parent_get(info->item), item_separator,
+ ELM_GENLIST_ITEM_NONE, gedit_gl_sel, new_info);
+
+ elm_genlist_item_flip_set(new_info->item, EINA_TRUE);
+ gedit_enter_name_mode(new_info->item, cgedit_d);
+}
+
+static char* gedit_gl_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ ct_group_list *info = data;
+ c_retvm_if(NULL == data, NULL, "The parameter(data) is NULL");
+
+ if (!strcmp(part, "elm.text") && info->name)
+ return strndup(info->name, CT_TEXT_MAX_LEN);
+ return NULL;
+}
+
+static void gedit_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *genlist;
+ ct_group_list *info = data;
+ ct_group_edit_data *cgedit_d;
+ c_retm_if(NULL == data, "data is NULL");
+
+ genlist = elm_object_item_widget_get(info->item);
+ cgedit_d = evas_object_data_get(genlist, "cgedit_d");
+
+ if (EINA_TRUE == info->selected)
+ cgedit_d->count++;
+ else
+ cgedit_d->count--;
+
+ if (!cgedit_d->is_rename) {
+ gedit_navi_item_update(cgedit_d);
+ gedit_notify_update(cgedit_d);
+ }
+}
+
+static void gedit_group_rename_btn_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ ct_group_list *info = data;
+ Evas_Object *genlist = elm_object_item_widget_get(info->item);
+ ct_group_edit_data *cgedit_d = evas_object_data_get(genlist, "cgedit_d");
+ if (!cgedit_d || cgedit_d->is_rename) return;
+ if (info->item) {
+ elm_genlist_item_flip_set(info->item, EINA_TRUE);
+ gedit_enter_name_mode(info->item, cgedit_d);
+ }
+}
+
+static Evas_Object* gedit_gl_icon_get(void *data, Evas_Object *obj, const char *part)
+{
+ ct_group_list *info = data;
+ c_retvm_if(NULL== data, NULL, "The parameter(data) is NULL");
+
+ if (!strcmp(part, "elm.icon")) {
+ Evas_Object *btn;
+ btn = ctui_create_btn(obj, T_(CT_GET_TEXT_BASE_OP, CTTEXT_NEW_GROUP));
+ evas_object_smart_callback_add(btn, "clicked", gedit_group_create_btn_cb, info);
+ return btn;
+ }
+ else if (elm_genlist_decorate_mode_get(obj) && 0 <= info->id_grp) {
+ if (0 == strcmp(part, "elm.icon.1")) {
+ Evas_Object *check = elm_check_add(obj);
+ elm_check_state_pointer_set(check, &info->selected);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ evas_object_smart_callback_add(check, "changed", gedit_check_changed_cb, info);
+ return check;
+ }
+ else if (0 == strcmp(part, "elm.icon.2")) {
+ Evas_Object *btn = elm_button_add(obj);
+ evas_object_propagate_events_set(btn, EINA_FALSE);
+ elm_object_style_set(btn, "rename");
+ evas_object_smart_callback_add(btn, "clicked", gedit_group_rename_btn_cb, info);
+ return btn;
+ }
+ else if (0 == strcmp(part, "elm.flip.content")) {
+ static Elm_Entry_Filter_Limit_Size limit_filter_data;
+ Evas_Object *edit_field;
+ Evas_Object *entry;
+
+ edit_field = ctui_create_editfield(obj, NULL, NULL, false);
+ evas_object_propagate_events_set(edit_field, EINA_FALSE);
+
+ entry = elm_object_part_content_get(edit_field, "elm.swallow.content");
+ elm_object_signal_emit(edit_field, "elm,state,guidetext,hide", "elm");
+ ctui_entry_entry_set(entry, info->name);
+ evas_object_data_set(obj,"entry", entry);
+
+ limit_filter_data.max_char_count = 0;
+ limit_filter_data.max_byte_count = 20;
+ elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
+ evas_object_smart_callback_add(entry, "changed", gedit_entry_changed_cb, info);
+
+ evas_object_show(entry);
+ elm_object_focus_set(entry, EINA_TRUE);
+
+ return edit_field;
+ }
+ }
+ return NULL;
+}
+
+static void gedit_fill_genlist_with_addrbook(ct_group_edit_data *cgedit_d,
+ Elm_Object_Item *parent, int id_ab)
+{
+ int ret;
+ CTSiter *iter;
+ ct_group_list *info;
+ Elm_Object_Item *item;
+
+ ret = contacts_svc_get_list_with_int(CTS_LIST_GROUPS_OF_ADDRESSBOOK_ID, id_ab, &iter);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_get_list_with_int() Failed(%d)", ret);
+
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue *value;
+ int grp_id;
+
+ value = contacts_svc_iter_get_info(iter);
+ grp_id = contacts_svc_value_get_int(value, CTS_LIST_GROUP_ID_INT);
+
+ if (grp_id != cgedit_d->grp_id) {
+ info = calloc(1, sizeof(ct_group_list));
+ info->id_ab = id_ab;
+ info->id_grp = grp_id;
+ info->name = contacts_svc_value_steal_str(value, CTS_LIST_GROUP_NAME_STR);
+ info->item = elm_genlist_item_append(cgedit_d->genlist, &gedit_itcs[GEDIT_ITC_GROUP], info, NULL,
+ ELM_GENLIST_ITEM_NONE, gedit_gl_sel, info);
+ }
+ contacts_svc_value_free(value);
+ }
+ contacts_svc_iter_remove(iter);
+ item = elm_genlist_item_append(cgedit_d->genlist, &gedit_itcs[GEDIT_ITC_SEPARATOR], NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ // "Create group" button
+ info = calloc(1, sizeof(ct_group_list));
+ info->id_ab = id_ab;
+ info->id_grp = -1;
+ info->item = elm_genlist_item_append(cgedit_d->genlist, &gedit_itcs[GEDIT_ITC_BTN], info, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+ item = elm_genlist_item_append(cgedit_d->genlist, &gedit_itcs[GEDIT_ITC_SEPARATOR], NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+}
+
+static void gedit_fill_genlist_with_all_addrbook(ct_group_edit_data *cgedit_d)
+{
+ int ret;
+ CTSiter *iter;
+ ct_group_list *info;
+ Evas_Object *genlist = cgedit_d->genlist;
+
+ // phone group
+ info = calloc(1, sizeof(ct_group_list));
+ info->id_ab = 0;
+ info->name = strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE));
+ info->item = elm_genlist_item_append(genlist, &gedit_itcs[GEDIT_ITC_ADDRBOOK], info, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ gedit_fill_genlist_with_addrbook(cgedit_d, info->item, info->id_ab);
+
+ ret = contacts_svc_get_list(CTS_LIST_ALL_ADDRESSBOOK, &iter);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_get_list() Failed(%d)", ret);
+
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ int mode;
+ CTSvalue *ab;
+ ct_group_list *info;
+
+ info = calloc(1, sizeof(ct_group_list));
+ if (NULL == info) {
+ ERR("calloc() return NULL");
+ continue;
+ }
+
+ ab = contacts_svc_iter_get_info(iter);
+ mode = contacts_svc_value_get_int(ab, CTS_LIST_ADDRESSBOOK_MODE_INT);
+ if (CTS_ADDRESSBOOK_MODE_READONLY == mode) {
+ free(info);
+ ret = contacts_svc_value_free(ab);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_free() Failed(%d)", ret);
+ continue;
+ }
+
+ info->id_ab = contacts_svc_value_get_int(ab, CTS_LIST_ADDRESSBOOK_ID_INT);
+ info->name = contacts_svc_value_steal_str(ab, CTS_LIST_ADDRESSBOOK_NAME_STR);
+ info->item = elm_genlist_item_append(cgedit_d->genlist, &gedit_itcs[GEDIT_ITC_ADDRBOOK], info, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ gedit_fill_genlist_with_addrbook(cgedit_d, info->item, info->id_ab);
+
+ ret = contacts_svc_value_free(ab);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_free() Failed(%d)", ret);
+ }
+ contacts_svc_iter_remove(iter);
+}
+
+static void gedit_group_changed(void *data)
+{
+ ct_group_edit_data *cgedit_d = data;
+
+ elm_genlist_clear(cgedit_d->genlist);
+ cgedit_d->count = 0;
+ if (elm_genlist_decorate_mode_get(cgedit_d->genlist) == EINA_FALSE)
+ elm_genlist_decorate_mode_set(cgedit_d->genlist, EINA_TRUE);
+
+ ctui_genlist_append_separator_20px(cgedit_d->genlist);
+
+ if (-1 == cgedit_d->base_ab || cgedit_d->is_move_copy_view)
+ gedit_fill_genlist_with_all_addrbook(cgedit_d);
+ else
+ gedit_fill_genlist_with_addrbook(cgedit_d, NULL, cgedit_d->base_ab);
+
+ if (cgedit_d->is_rename)
+ gedit_redraw_genlist(cgedit_d);
+ else
+ gedit_navi_item_update(cgedit_d);
+}
+
+static void gedit_view_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_group_edit_data *cgedit_d = data;
+
+ ret = contacts_svc_unsubscribe_change_with_data(CTS_SUBSCRIBE_GROUP_CHANGE, gedit_group_changed, cgedit_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_unsubscribe_change_with_data() Failed(%d)", ret);
+
+ free(cgedit_d->name_old);
+ free(cgedit_d);
+}
+
+static void gedit_genlist_style_set(void)
+{
+ gedit_itcs[GEDIT_ITC_ADDRBOOK].func.text_get = gedit_gl_label_get;
+ gedit_itcs[GEDIT_ITC_ADDRBOOK].func.del = gedit_gl_del;
+
+ gedit_itcs[GEDIT_ITC_GROUP].func.text_get = gedit_gl_label_get;
+ gedit_itcs[GEDIT_ITC_GROUP].func.content_get = gedit_gl_icon_get;
+ gedit_itcs[GEDIT_ITC_GROUP].func.del = gedit_gl_del;
+
+ gedit_itcs[GEDIT_ITC_GROUP_CREATE].func.content_get = gedit_gl_icon_get;
+ gedit_itcs[GEDIT_ITC_GROUP_CREATE].func.del = gedit_gl_del;
+
+ gedit_itcs[GEDIT_ITC_BTN].func.content_get = gedit_gl_icon_get;
+ gedit_itcs[GEDIT_ITC_BTN].func.del = gedit_gl_del;
+}
+
+Evas_Object * ctui_gedit_create_view(ct_group_edit_data *cgedit_d)
+{
+ Evas_Object *conform, *base, *bg;
+ int ret;
+
+ base = ctui_create_base_layout(cgedit_d->navi, false);
+ bg = ctui_set_bg(base);
+ if (NULL == bg) {
+ ERR("ctui_set_bg() return NULL");
+ evas_object_del(base);
+ return NULL;
+ }
+ elm_object_style_set(bg, "group_list");
+
+ elm_win_conformant_set(cgedit_d->win, EINA_TRUE);
+ conform = elm_conformant_add(base);
+ elm_object_style_set(conform, "internal_layout");
+ evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(conform);
+
+ cgedit_d->genlist = elm_genlist_add(base);
+ elm_genlist_decorate_mode_set(cgedit_d->genlist, EINA_TRUE);
+ elm_genlist_select_mode_set(cgedit_d->genlist, ELM_OBJECT_SELECT_MODE_NONE);
+ gedit_genlist_style_set();
+ evas_object_size_hint_weight_set(cgedit_d->genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(cgedit_d->genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(cgedit_d->genlist);
+ evas_object_data_set(cgedit_d->genlist, "cgedit_d", cgedit_d);
+ elm_object_content_set(conform, cgedit_d->genlist);
+ elm_object_part_content_set(base, "elm.swallow.content", conform);
+
+ ctui_genlist_append_separator_20px(cgedit_d->genlist);
+
+ if (-1 == cgedit_d->base_ab || cgedit_d->is_move_copy_view)
+ gedit_fill_genlist_with_all_addrbook(cgedit_d);
+ else
+ gedit_fill_genlist_with_addrbook(cgedit_d, NULL, cgedit_d->base_ab);
+
+ evas_object_event_callback_add(base, EVAS_CALLBACK_DEL,
+ gedit_view_delete_cb, (void*)cgedit_d);
+
+ ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE, gedit_group_changed, cgedit_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_subscribe_change() Failed(%d)", ret);
+
+ return base;
+}
+
+void ctui_gedit_push_view(Evas_Object *win, Evas_Object *navi, int id_ab)
+{
+ ct_group_edit_data *cgedit_d;
+ Evas_Object *layout;
+
+ cgedit_d = calloc(1, sizeof(ct_group_edit_data));
+ c_retm_if(NULL == cgedit_d, "calloc() return NULL");
+
+ cgedit_d->win = win;
+ cgedit_d->navi = navi;
+ cgedit_d->base_ab = id_ab;
+ cgedit_d->count = 0;
+ cgedit_d->is_move_copy_view = false;
+
+ layout = ctui_gedit_create_view(cgedit_d);
+
+ cgedit_d->ctr_btn_info.cb = gedit_group_delete_btn_cb;
+ cgedit_d->ctr_btn_info.icon_path= CTUI_IMG_ICON_DELETE;
+ cgedit_d->ctr_btn_info.user_data = cgedit_d->genlist;
+
+ cgedit_d->navi_it = elm_naviframe_item_push(cgedit_d->navi,
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_SELECT_GROUP), NULL, NULL, layout, NULL);
+
+ ctui_gedit_navi_create_btn(cgedit_d);
+}
+
diff --git a/lib/common/ct-list-detail.c b/lib/common/ct-list-detail.c
new file mode 100755
index 0000000..7ca2f31
--- /dev/null
+++ b/lib/common/ct-list-detail.c
@@ -0,0 +1,362 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <aul.h>
+#include <ui-gadget-module.h>
+
+#include "contacts.h"
+#include "ct-common.h"
+
+inline void ctui_ld_to_dd(ct_list_data *clist_d, ct_detail_data *cdetail_d)
+{
+ cdetail_d->win = clist_d->win;
+ cdetail_d->navi = clist_d->navi;
+ cdetail_d->base_grp = clist_d->base_grp;
+ cdetail_d->base_ab = clist_d->base_ab;
+ cdetail_d->ug = clist_d->ug;
+ cdetail_d->prev_navi_item = clist_d->navi_item;
+ cdetail_d->clist_d = clist_d;
+}
+
+#define CT_UG_BUNDLE_RESULT_ID "id"
+
+void ctui_ug_return_id(struct ui_gadget *ug, int ct_id, int num_id, int email_id)
+{
+ bundle *bd;
+ char buf[16];
+
+ bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_create() Failed");
+
+ if (ct_id) {
+ snprintf(buf, sizeof(buf), "%d", ct_id);
+ bundle_add(bd, CT_UG_BUNDLE_RESULT_ID, buf);
+ bundle_add(bd, CT_UG_BUNDLE_RESULT_CONTACT_ID, buf);
+ }
+
+ if (num_id) {
+ snprintf(buf, sizeof(buf), "%d", num_id);
+ bundle_del(bd, CT_UG_BUNDLE_RESULT_ID);
+ bundle_add(bd, CT_UG_BUNDLE_RESULT_ID, buf);
+ bundle_add(bd, CT_UG_BUNDLE_RESULT_NUMBER_ID, buf);
+ }
+
+ if (email_id) {
+ snprintf(buf, sizeof(buf), "%d", email_id);
+ bundle_del(bd, CT_UG_BUNDLE_RESULT_ID);
+ bundle_add(bd, CT_UG_BUNDLE_RESULT_ID, buf);
+ bundle_add(bd, CT_UG_BUNDLE_RESULT_EMAIL_ID, buf);
+ }
+
+ ug_send_result(ug, bd);
+
+ bundle_free(bd);
+}
+
+int ctui_get_display_name(CTSvalue *name, char *dest, int dest_len)
+{
+ const char *first, *last, *display;
+
+ display = contacts_svc_value_get_str(name, CTS_NAME_VAL_DISPLAY_STR);
+
+ if (display)
+ snprintf(dest, dest_len, "%s", display);
+ else {
+ first = contacts_svc_value_get_str(name, CTS_NAME_VAL_FIRST_STR);
+ last = contacts_svc_value_get_str(name, CTS_NAME_VAL_LAST_STR);
+
+ if (CTS_ORDER_NAME_FIRSTLAST == contacts_svc_get_order(CTS_ORDER_OF_DISPLAY))
+ snprintf(dest, dest_len, "%s%s%s", SAFE_STR(first), STR_BLANK(first, last));
+ else
+ snprintf(dest, dest_len, "%s%s%s", SAFE_STR(last), STR_BLANK(last, first));
+ }
+ return 0;
+}
+
+void ctui_get_number_type_str(int cts_num_type, char *dest, int dest_len)
+{
+ const char* type_str;
+ if (cts_num_type & CTS_NUM_TYPE_CUSTOM) {
+ char *custom;
+ custom = contacts_svc_get_custom_type(CTS_TYPE_CLASS_NUM, cts_num_type);
+ if (NULL == custom)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_OTHER);
+ else {
+ snprintf(dest, dest_len, "%s", custom);
+ free(custom);
+ return;
+ }
+ }
+ else if (cts_num_type & CTS_NUM_TYPE_CELL)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_MOBILE);
+ else if (cts_num_type & CTS_NUM_TYPE_VOICE) {
+ if (cts_num_type & CTS_NUM_TYPE_HOME)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_HOME);
+ else if (cts_num_type & CTS_NUM_TYPE_WORK)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_WORK);
+ else
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_TELEPHONE);
+ }
+ else if (cts_num_type & CTS_NUM_TYPE_FAX) {
+ if (cts_num_type & CTS_NUM_TYPE_HOME)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_FAX);
+ else if (cts_num_type & CTS_NUM_TYPE_WORK)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_FAX);
+ else
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_FAX);
+ }
+ else if (cts_num_type & CTS_NUM_TYPE_PAGER)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_PAGER);
+ else if (cts_num_type & CTS_NUM_TYPE_CAR)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_CAR);
+ else if (cts_num_type & CTS_NUM_TYPE_ASSISTANT)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_ASSISTANT);
+ else {
+ if (cts_num_type == CTS_NUM_TYPE_HOME)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_HOME);
+ else if (cts_num_type == CTS_NUM_TYPE_WORK)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_WORK);
+ else
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_OTHER);
+ }
+
+ snprintf(dest, dest_len, "%s", type_str);
+}
+
+const char* ctui_get_default_contact_img(int view_type)
+{
+ switch (view_type) {
+ case CT_VIEW_DETAIL:
+ return CTUI_IMG_DEFAULT_PHOTO_90_90;
+
+ case CT_VIEW_INPUT:
+ return CTUI_IMG_PHOTO_EDIT;
+
+ case CT_VIEW_ETC:
+ default:
+ return CTUI_IMG_DEFAULT_PHOTO_70_70;
+ }
+}
+
+Evas_Object* ctui_create_btn(Evas_Object *parent, const char *label)
+{
+ Evas_Object *btn;
+
+ btn = elm_button_add(parent);
+ c_retvm_if(NULL == btn, NULL, "elm_button_add() return NULL");
+
+ elm_object_style_set(btn, "style2");
+ elm_object_text_set(btn, label);
+ evas_object_show(btn);
+
+ return btn;
+}
+
+inline void ctui_voice_call(const int id, const char* number)
+{
+ char idx[10];
+ bundle *bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_create() Failed");
+
+ bundle_add(bd, "launch-type", "MO");// "MO" : normal call, "EMERGENCY" : emergency call
+ bundle_add(bd, "number", number);
+
+ snprintf(idx, sizeof(idx), "%d", id);
+ bundle_add(bd, "ctindex", idx);
+
+ aul_launch_app(VOICE_CALL_UI_PKG, bd);
+ bundle_free(bd);
+}
+
+Evas_Object* ctui_new_confirm_popup(Evas_Object *win, const char* description)
+{
+ Evas_Object* notify = elm_popup_add(win);
+ evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_text_set(notify, description);
+ evas_object_show(notify);
+ return notify;
+}
+
+void ctui_msg_ug(struct ui_gadget *parent, const char *number, const int idx, const char *attach)
+{
+ struct ug_cbs cbs = {0};
+ struct ui_gadget* ug;
+
+ bundle* bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_craete() return NULL");
+
+ if (number && idx) {
+ char temp[CT_TEXT_SHORT_LEN];
+ snprintf(temp, sizeof(temp), "%s/%d", number, idx);
+ bundle_add(bd, "number/index", temp);
+ }
+ else if (number) {
+ bundle_add(bd, "TO", number);
+ }
+
+ if (attach) {
+ bundle_add(bd, "ATTACHFILE", attach);
+ bundle_add(bd, "SUBJECT", "Contacts name card");
+ }
+
+ cbs.layout_cb = ctui_ug_layout_cb;
+ cbs.result_cb = NULL;
+ cbs.destroy_cb = ctui_ug_destroy_cb;
+
+ ug = ug_create(parent, MSG_COMPOSER_UG, UG_MODE_FULLVIEW, bd, &cbs);
+ c_warn_if(NULL == ug, "ug_create() Failed");
+
+ bundle_free(bd);
+}
+
+Evas_Object* ctui_naviframe_btn(Evas_Object *parent, const char *label)
+{
+ Evas_Object *btn;
+
+ btn = elm_button_add(parent);
+ elm_object_style_set(btn, "naviframe/title/default");
+ elm_object_text_set(btn, label);
+ evas_object_show(btn);
+
+ return btn;
+}
+
+void ctui_cbar_item_clear(Evas_Object *cbar)
+{
+ Elm_Object_Item *c_item, *n_item;
+ c_retm_if(NULL == cbar, "parameter(toolbar) is NULL");
+
+ c_item = elm_toolbar_first_item_get(cbar);
+ while (c_item) {
+ n_item = elm_toolbar_item_next_get(c_item);
+ elm_object_item_del(c_item);
+ c_item = n_item;
+ }
+ evas_object_data_del(cbar, "done_item");
+ evas_object_data_del(cbar, "delete_item");
+ evas_object_data_del(cbar, "move_item");
+ evas_object_data_del(cbar, "copy_item");
+}
+
+void ctui_entry_limit_size_set(Evas_Object *entry)
+{
+ const int EDITFIELD_MAX_CHAR = 700;
+ static Elm_Entry_Filter_Limit_Size filter;
+ c_retm_if(NULL == entry, "parameter(entry) is NULL");
+
+ filter.max_char_count = EDITFIELD_MAX_CHAR;
+ elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &filter);
+}
+
+
+
+void ctui_genlist_append_separator_10px(Evas_Object *genlist)
+{
+ static Elm_Genlist_Item_Class itc = { .item_style="dialogue/separator/10" };
+
+ Elm_Object_Item *item;
+ item = elm_genlist_item_append(genlist, &itc, NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+}
+
+void ctui_genlist_append_separator_20px(Evas_Object *genlist)
+{
+ static Elm_Genlist_Item_Class itc = { .item_style="dialogue/separator/20" };
+
+ Elm_Object_Item *item;
+ item = elm_genlist_item_append(genlist, &itc, NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+}
+
+
+void ctui_cbar_btn_disabled_set(Evas_Object *cbar, Eina_Bool disabled)
+{
+ Elm_Object_Item *done_item, *delete_item, *move_item, *copy_item;
+
+ c_retm_if(NULL == cbar, "parameter(cbar) is NULL");
+
+ done_item = evas_object_data_get(cbar, "done_item");
+ delete_item = evas_object_data_get(cbar, "delete_item");
+ move_item = evas_object_data_get(cbar, "move_item");
+ copy_item = evas_object_data_get(cbar, "copy_item");
+
+ if(done_item)
+ elm_object_item_disabled_set(done_item, disabled);
+ if(delete_item)
+ elm_object_item_disabled_set(delete_item, disabled);
+ if(move_item)
+ elm_object_item_disabled_set(move_item, disabled);
+ if(copy_item)
+ elm_object_item_disabled_set(copy_item, disabled);
+}
+
+char* ctui_entry_markup_to_utf8(const char *s)
+{
+ int i;
+ char *ret;
+
+ ret = elm_entry_markup_to_utf8(s);
+ c_retvm_if(NULL == ret, NULL, "elm_entry_markup_to_utf8() return NULL");
+
+ for (i = 0; i < strlen(ret); i++)
+ if (' ' != ret[i]) return ret;
+
+ ret[0] = '\0';
+ return ret;
+}
+
+void ctui_entry_entry_set(Evas_Object *entry, const char *s)
+{
+ char *s_markup;
+ if(NULL == s || '\0' == s[0])
+ return;
+
+ s_markup = elm_entry_utf8_to_markup(s);
+ elm_entry_entry_set(entry, s_markup);
+ free(s_markup);
+}
+
+void ctui_back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *win = data;
+ elm_win_lower(win);
+}
+
+void ctui_list_detail_genlist_append_separator_line_20px(Evas_Object *genlist)
+{
+ static Elm_Genlist_Item_Class itc = { .item_style="dialogue/separator/21/with_line" };
+
+ Elm_Object_Item *item;
+ item = elm_genlist_item_append(genlist, &itc, NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+}
+
+void ctui_list_ug_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ug_destroy_me(data);
+}
diff --git a/lib/common/ct-list-setting.c b/lib/common/ct-list-setting.c
new file mode 100755
index 0000000..2399a06
--- /dev/null
+++ b/lib/common/ct-list-setting.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include "contacts.h"
+#include "ct-common.h"
+
+Evas_Object* ctui_progressbar_popup(Evas_Object *parent, ct_progress_info *p_info)
+{
+ Evas_Object *popup;
+ Evas_Object *layout;
+ Evas_Object *title;
+ Evas_Object *progressbar;
+
+ popup = elm_popup_add(parent);
+ c_retvm_if(NULL == popup, NULL, "elm_popup_add() return NULL");
+
+ layout = elm_layout_add(popup);
+ c_retvm_if(NULL == layout, NULL, "elm_layout_add() return NULL");
+ elm_layout_file_set(layout, CONTACTS_EDJ, "popup_center_text_progressview");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ p_info->layout = layout;
+
+ title = elm_label_add(layout);
+ c_retvm_if(NULL == title, NULL, "elm_label_add() return NULL");
+ elm_object_style_set(title, "popup_description/default");
+ elm_label_line_wrap_set(title, EINA_TRUE);
+ evas_object_size_hint_weight_set(title, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(title, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(title);
+ p_info->label = title;
+
+ progressbar = elm_progressbar_add(layout);
+ c_retvm_if(NULL == progressbar, NULL, "elm_progressbar_add() return NULL");
+ p_info->progressbar= progressbar;
+
+ elm_object_part_content_set(layout, "elm.swallow.content", title);
+ elm_object_part_content_set(layout, "elm.swallow.end", progressbar);
+
+ if (0 < p_info->cnt_checked_total) {
+ elm_object_style_set(progressbar, "list_progress");
+ elm_progressbar_value_set(progressbar, 0.0);
+ }
+ else {
+ elm_object_style_set(progressbar, "pending_list");
+ elm_progressbar_pulse_set(progressbar, EINA_TRUE);
+ }
+
+ evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(progressbar);
+ elm_object_content_set(popup, layout);
+
+ evas_object_show(popup);
+ return popup;
+}
+
+void ctui_progress_popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object **popup;
+ bool *is_alive = data;
+ *is_alive = false;
+
+ popup = evas_object_data_get(obj, "p_popup");
+ c_retm_if(NULL == popup, "evas_object_data_get() return NULL");
+ evas_object_del(*popup);
+ *popup = NULL;
+}
+
+
diff --git a/lib/common/ct-text.c b/lib/common/ct-text.c
new file mode 100755
index 0000000..1d0d647
--- /dev/null
+++ b/lib/common/ct-text.c
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <appcore-efl.h>
+
+#include "contacts.h"
+#include "ct-common.h"
+
+static const char *number_type_str[] = {
+ N_("IDS_PB_BODY_MOBILE"),/*Mobile*/
+ N_("IDS_PB_BODY_TELEPHONE"),/*Telephone*/
+ N_("IDS_PB_BODY_FAX"),/*Fax*/
+ N_("IDS_PB_BODY_OTHER"),/*Other*/
+ N_("IDS_PB_BODY_HOME"),/*Home*/
+ N_("IDS_PB_BODY_WORK"),/*Work*/
+ N_("IDS_PB_BODY_CAR_TELEPHONE"),/*Car*/
+ N_("IDS_PB_BODY_PAGER"),/*Pager*/
+ N_("IDS_PB_BODY_ASSISTANT_S_NUMBER"),/*Assistant*/
+};
+
+static const char *postal_type_str[] = {
+ N_("IDS_PB_BODY_HOME"),/*Home*/
+ N_("IDS_PB_BODY_WORK"),/*Work*/
+ N_("IDS_PB_BODY_OTHER")/*Other*/
+};
+
+static const char *basic_str[] = {
+ N_("IDS_PB_BODY_ALL_CONTACTS"),/*All Contacts*/
+ N_("IDS_PB_BODY_NOT_ASSIGNED"),/*Not Assigned*/
+ N_("IDS_PB_BODY_SERVICE_NUMBER"),/*Service Number*/
+ N_("IDS_PB_BODY_PHONE"),/*Phone*/
+ N_("IDS_PB_BODY_GROUPS"),/*Groups*/
+ N_("IDS_PB_BODY_DEFAULT"),/*Default*/
+ N_("IDS_PB_BODY_RINGTONE"),/*Ringtone*/
+ N_("IDS_PB_BODY_WEBSITE"),/*Website*/
+ N_("IDS_PB_BODY_IM"),/*Instant Messenger*/
+ N_("IDS_PB_BODY_EMAIL"),/*Email*/
+ N_("IDS_PB_BODY_NUMBER"),/*Number*/
+ N_("IDS_PB_BODY_NOTE"),/*Note*/
+ N_("IDS_PB_BODY_POSTAL_ADDRESS"),/*Postal Address*/
+ N_("IDS_PB_HEADER_DETAILS"),/*Details*/
+ N_("IDS_PB_BODY_COMPANY"),/*Company*/
+ N_("IDS_PB_BODY_BIRTHDAY"),/*Birthday*/
+ N_("IDS_PB_SK1_ADD_TO_HOME_SCREEN"),/*Added to Home*/
+ N_("IDS_PB_BODY_ORDER_OF_DISPLAY_NAME"),/* Order display name */
+ N_("IDS_PB_BODY_OWN_NUMBER"),/* Own number */
+ N_("IDS_PB_BODY_FIRST_NAME"),
+ N_("IDS_PB_BODY_LAST_NAME"),
+ N_("IDS_PB_BODY_MIDDLE_NAME"),
+ N_("IDS_PB_BODY_SUFFIX"),
+ N_("IDS_PB_BODY_NICKNAME"),
+ N_("IDS_PB_BODY_GROUP_ONLY"),
+ N_("IDS_PB_POP_GROUP_AND_GROUP_MEMBERS"),
+ N_("IDS_PB_BODY_EXPORT_CONTACTS"),
+ N_("IDS_PB_SK_IMPORT_CONTACTS"),
+ N_("IDS_PB_HEADER_SELECT_CONTACTS"),
+ N_("IDS_PB_BODY_POSTAL_CODE"),
+ N_("IDS_PB_BODY_COUNTRY"),
+ N_("IDS_PB_BODY_PROVINCE"),
+ N_("IDS_PB_BODY_CITY"),
+ N_("IDS_PB_BODY_STREET"),
+ N_("IDS_KA_BODY_SAVED_IN"),
+ N_("IDS_PB_POP_COPIED"),
+ N_("IDS_PB_BODY_BACKUP"),
+ N_("IDS_PB_POP_DELETING_CONTACTS_ING"),
+ N_("IDS_PB_BODY_MOVING_ING"),
+ N_("IDS_PB_BODY_COPYING_ING"),
+ N_("IDS_PB_POP_IMPORTING_SIM_CONTACTS_ING"),
+ N_("IDS_PB_POP_IMPORTING_CONTACTS_FROM_VCARD_ING"),
+ N_("IDS_PB_POP_EXPORTING_CONTACTS_TO_PS_ING"),
+ N_("IDS_COM_BODY_IMPORTED_ABB"),
+ N_("IDS_COM_BODY_NA"),
+ N_("IDS_COM_BODY_NO_SIM"),
+};
+
+static const char *err_str[] = {
+ N_("IDS_PB_BODY_NO_NAME"),
+ N_("IDS_PB_POP_INVALID_EMAIL_ADDRESS"),
+ N_("IDS_PB_POP_COMPLETE_AT_LEAST_ONE_FIELD_AS_WELL_AS_NAME"),
+ N_("IDS_IM_BODY_FAILED_TO_ACCESS_DATABASE"),
+ N_("IDS_PB_POP_ALREADY_ADDED"),
+ N_("IDS_PB_POP_GROUP_ALREADY_IN_USE"),
+ N_("IDS_PB_BODY_NO_GROUP"),
+ N_("IDS_PB_POP_NO_NUMBER"),
+ N_("IDS_PB_POP_NO_EMAIL_ADDRESSES"),
+ N_("IDS_PB_BODY_NO_CONTACTS"),
+ N_("IDS_PB_POP_SIM_MEMORY_EMPTY"),
+ N_("IDS_PB_POP_MAXIMUM_NUMBER_OF_ENTRIES_EXCEEDED"),
+ N_("IDS_PB_POP_INITIALISING_TRY_LATER_ING"),
+ N_("IDS_SEARCH_BODY_DATA_DOES_NOT_EXIST"),
+};
+
+static const char *base_op_str[] = {
+ N_("IDS_PB_BODY_MARK_AS_DEFAULT_NUMBER"),/*Set Default Number*/
+ N_("IDS_PB_BODY_IMAGE"),/*Image*/
+ N_("IDS_PB_BODY_TAKE_A_PHOTO"),/*Take a photo*/
+ N_("IDS_PB_OPT_REMOVE_PHOTO_ABB"),/*Delete photo*/
+ N_("IDS_PB_SK1_ADD_TO_HOME_SCREEN"),/*Add to Home*/
+ N_("IDS_PB_BODY_SAVE_CONTACT_TO"),/*Save contact to*/
+ N_("IDS_PB_BODY_IMPORT_SIM_CONTACTS"), /* Import SIM contacts */
+ N_("IDS_PB_BODY_FIRST_NAME_LAST_NAME"),/* order display - First, Last */
+ N_("IDS_PB_BODY_LAST_NAME_FIRST_NAME"),/* order display - Last, First */
+ N_("IDS_PB_HEADER_SEND_NAMECARD"),
+ N_("IDS_PB_POP_THIS_CONTACT_WILL_BE_DELETED"),
+ N_("IDS_PB_OPT_NEW_GROUP"),
+ N_("IDS_PB_HEADER_SELECT_GROUP"),
+ N_("IDS_PB_BODY_EXPORT_CONTACTS"),
+ N_("IDS_PB_BODY_IMPORT_FROM_SD_CARD"),
+};
+
+static const char *event_type_str[] = {
+ N_("IDS_PB_BODY_BIRTHDAY"),/*CTS_EVENT_TYPE_BIRTH*/
+ N_("IDS_PB_BODY_ANNIVERSARY")/*CTS_EVENT_TYPE_ANNIVERSARY*/
+};
+
+static const char *im_type_str[] = {
+ N_("IDS_PB_HEADER_UNKNOWN"),/*CTS_IM_TYPE_NONE*/
+ N_("IDS_PB_BODY_GOOGLE"),/*CTS_IM_TYPE_GOOGLE*/
+ N_("IDS_PB_BODY_MSN"),/*CTS_IM_TYPE_WLM*/
+ N_("IDS_PB_BODY_YAHOO"),/*CTS_IM_TYPE_YAHOO*/
+ N_("IDS_PB_BODY_FACEBOOK"),/*CTS_IM_TYPE_FACEBOOK*/
+ N_("IDS_PB_BODY_IMPSCOMMUNITY_ICQ"),/*CTS_IM_TYPE_ICQ*/
+ N_("IDS_PB_BODY_IMPSCOMMUNITY_AIM"),/*CTS_IM_TYPE_AIM*/
+ N_("IDS_PB_OPT_QQ")/*CTS_IM_TYPE_QQ*/
+};
+
+static const char* acc_type_str[] = {
+ N_("IDS_PB_BODY_PHONE"),/*CTS_ADDRESSBOOK_TYPE_INTERNAL*/
+ N_("IDS_PB_BODY_EXCHANGE"),/*CTS_ADDRESSBOOK_TYPE_EXCHANGE*/
+ N_("IDS_PB_BODY_GOOGLE"),/*CTS_ADDRESSBOOK_TYPE_GOOGLE*/
+ N_("IDS_PB_BODY_YAHOO"),/*CTS_ADDRESSBOOK_TYPE_YAHOO*/
+ N_("IDS_PB_BODY_FACEBOOK"),/*CTS_ADDRESSBOOK_TYPE_GOOGLE*/
+ N_("IDS_PB_HEADER_UNKNOWN"),/*CTS_ADDRESSBOOK_TYPE_OTHER*/
+};
+
+static const char *month_str[] = {
+ "IDS_COM_BODY_NONE",
+ "IDS_COM_BODY_JAN",
+ "IDS_COM_BODY_FEB",
+ "IDS_COM_BODY_MAR",
+ "IDS_COM_BODY_APR",
+ "IDS_COM_BODY_MAY",
+ "IDS_COM_BODY_JUN",
+ "IDS_COM_BODY_JUL",
+ "IDS_COM_BODY_AUG",
+ "IDS_COM_BODY_SEP",
+ "IDS_COM_BODY_OCT",
+ "IDS_COM_BODY_NOV",
+ "IDS_COM_BODY_DEC"
+};
+
+const char* ctui_get_text(int op, int type)
+{
+ const char **table;
+
+ switch (op) {
+ case CT_GET_TEXT_BASIC:
+ table = basic_str;
+ break;
+ case CT_GET_TEXT_ERR:
+ table = err_str;
+ break;
+ case CT_GET_TEXT_BASE_OP:
+ table = base_op_str;
+ break;
+ case CT_GET_TEXT_NUM_TYPE:
+ table = number_type_str;
+ break;
+ case CT_GET_TEXT_POSTAL_TYPE:
+ case CT_GET_TEXT_EMAIL_TYPE:
+ table = postal_type_str;
+ type--;
+ if (-1 == type) type = 2;
+ break;
+ case CT_GET_TEXT_EVENT_TYPE:
+ table = event_type_str;
+ break;
+ case CT_GET_TEXT_IM_TYPE:
+ table = im_type_str;
+ break;
+ case CT_GET_TEXT_MONTH:
+ if (sizeof(month_str) / sizeof(month_str[0]) <= type)
+ return NULL;
+ else
+ return dgettext("sys_string", month_str[type]);
+ case CT_GET_TEXT_ACC_TYPE:
+ if (5 < type) type = 5;
+ table = acc_type_str;
+ break;
+ default:
+ return NULL;
+ }
+
+ return dgettext(PACKAGE, table[type]);
+}
+
+static const char *sys_str[] = {
+ "IDS_COM_SK_OK",
+ "IDS_COM_SK_SAVE",
+ "IDS_COM_SK_EDIT",
+ "IDS_COM_SK_DONE",
+ "IDS_COM_SK_DELETE",
+ "IDS_COM_SK_CANCEL",
+ "IDS_COM_BODY_CREATE",
+ "IDS_COM_BODY_MOVE",
+ "IDS_COM_BODY_COPY",
+ "IDS_COM_BODY_CALL",
+ "IDS_COM_BODY_MESSAGE",
+ "IDS_COM_BODY_VIDEO_CALL",
+ "IDS_COM_BODY_UNKNOWN",
+ "IDS_COM_BODY_PHONE",
+ "IDS_COM_BODY_SELECT_ALL",
+ "IDS_COM_BODY_SEARCH",
+ "IDS_COM_BODY_BLUETOOTH",
+ "IDS_COM_BODY_EMAIL",
+ "IDS_COM_BODY_CONTACTS",
+ "IDS_COM_POP_SELECTED",
+ "IDS_COM_POP_SUCCESS",
+ "IDS_COM_POP_FAILED",
+ "IDS_COM_POP_CLOSE",
+ "IDS_COM_POP_ERROR",
+ "IDS_COM_POP_DELETED",
+ "IDS_COM_POP_REMOVED",
+ "IDS_COM_POP_MOVED",
+ "IDS_COM_POP_ADDED",
+ "IDS_COM_POP_NOT_ENOUGH_MEMORY",
+ "IDS_COM_POP_FILE_NOT_FOUND",
+};
+
+inline const char* ctui_get_system_string(int type)
+{
+ return dgettext("sys_string", sys_str[type]);
+}
diff --git a/lib/details/CMakeLists.txt b/lib/details/CMakeLists.txt
new file mode 100755
index 0000000..008f92f
--- /dev/null
+++ b/lib/details/CMakeLists.txt
@@ -0,0 +1,22 @@
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
+
+SET(TARGET ${CT_DETAILS})
+
+FILE(GLOB SRCS *.c)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(details_pkgs REQUIRED icu-i18n)
+
+FOREACH(flag ${details_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+ADD_LIBRARY(${TARGET} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
+TARGET_LINK_LIBRARIES(${TARGET} ${COMMON_LIB} ${ug_pkgs_LDFLAGS} ${details_pkgs_LDFLAGS})
+
+ADD_DEPENDENCIES(${TARGET} contacts_edj_build)
+
+INSTALL(TARGETS ${TARGET} DESTINATION ${UGLIBDIR})
diff --git a/lib/details/ct-detail-main.c b/lib/details/ct-detail-main.c
new file mode 100755
index 0000000..561b373
--- /dev/null
+++ b/lib/details/ct-detail-main.c
@@ -0,0 +1,613 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <ui-gadget-module.h>
+
+#include "contacts.h"
+#include "ct-detail.h"
+#include "ct-detail-utils.h"
+#include "ct-detail-view.h"
+#include "ct-input-view.h"
+#include "ct-input-utils.h"
+
+static void detail_delete_contact(ct_detail_data *cdetail_d)
+{
+ int id;
+ int ret;
+ const char *msg;
+
+ id = cdetail_d->contact_id;
+ ret = contacts_svc_delete_contact(id);
+
+ if (CTS_SUCCESS == ret)
+ msg = S_(CT_SYS_POP_DELETED);
+ else
+ msg = S_(CT_SYS_POP_FAILED);
+
+ ctui_show_notify(cdetail_d->navi, msg, 2.0);
+}
+
+static void detail_delete_contact_ug(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *notify;
+ ct_detail_data *cdetail_d = data;
+ detail_delete_contact(cdetail_d);
+ notify = evas_object_data_get(cdetail_d->navi, "notify");
+ if (notify)
+ evas_object_smart_callback_add(notify, "timeout", ctui_ug_destroy_me_cb, cdetail_d->ug);
+ evas_object_del(cdetail_d->popup);
+}
+
+static void detail_delete_contact_lib(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_detail_data *cdetail_d = data;
+ detail_delete_contact(cdetail_d);
+ elm_naviframe_item_pop(cdetail_d->navi);
+ evas_object_del(cdetail_d->popup);
+}
+
+static void detail_delete_contact_cv(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_detail_data *cdetail_d = data;
+ detail_delete_contact(cdetail_d);
+ evas_object_del(cdetail_d->popup);
+}
+
+static void detail_delete_cb_cv(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *notify;
+ ct_detail_data *cdetail_d = data;
+
+ // focus problem on emulator
+ evas_object_focus_set(cdetail_d->genlist, EINA_TRUE);
+
+ notify = ctui_new_confirm_popup(cdetail_d->navi, T_(CT_GET_TEXT_BASE_OP, CTTEXT_CONFIRM_DELETE_CONTACT));
+ cdetail_d->popup = notify;
+ ctui_create_popup_button(notify, 1, S_(CT_SYS_SK_OK), detail_delete_contact_cv, cdetail_d);
+ ctui_create_popup_button(notify, 2, S_(CT_SYS_SK_CANCEL), ct_detail_popup_hide_cb, cdetail_d);
+}
+
+static void detail_delete_cb_lib(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *notify;
+ ct_detail_data *cdetail_d = data;
+
+ // focus problem on emulator
+ evas_object_focus_set(cdetail_d->genlist, EINA_TRUE);
+
+ notify = ctui_new_confirm_popup(cdetail_d->navi, T_(CT_GET_TEXT_BASE_OP, CTTEXT_CONFIRM_DELETE_CONTACT));
+ cdetail_d->popup = notify;
+ ctui_create_popup_button(notify, 1, S_(CT_SYS_SK_OK), detail_delete_contact_lib, cdetail_d);
+ ctui_create_popup_button(notify, 2, S_(CT_SYS_SK_CANCEL), ct_detail_popup_hide_cb, cdetail_d);
+}
+
+static void detail_delete_cb_ug(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *notify;
+ ct_detail_data *cdetail_d = data;
+
+ // focus problem on emulator
+ evas_object_focus_set(cdetail_d->genlist, EINA_TRUE);
+
+ notify = ctui_new_confirm_popup(cdetail_d->navi, T_(CT_GET_TEXT_BASE_OP, CTTEXT_CONFIRM_DELETE_CONTACT));
+ cdetail_d->popup = notify;
+ ctui_create_popup_button(notify, 1, S_(CT_SYS_SK_OK), detail_delete_contact_ug, cdetail_d);
+ ctui_create_popup_button(notify, 2, S_(CT_SYS_SK_CANCEL), ct_detail_popup_hide_cb, cdetail_d);
+}
+
+
+static int create_ug_detail_view(int request, ct_detail_data *cdetail_d)
+{
+ c_retvm_if(NULL == cdetail_d->base, FALSE, "base is NULL");
+
+ cdetail_d->navi = elm_naviframe_add(cdetail_d->base);
+ c_retvm_if (NULL == cdetail_d->navi, FALSE, "elm_naviframe_add() return NULL");
+ elm_naviframe_prev_btn_auto_pushed_set(cdetail_d->navi, EINA_FALSE);
+ evas_object_show(cdetail_d->navi);
+
+ if (CT_UG_REQUEST_DETAIL == request) {
+ Evas_Object *content;
+ Evas_Object *cbar;
+ Evas_Object *back_btn;
+ Elm_Object_Item *tmp;
+
+ cbar = elm_toolbar_add(cdetail_d->navi);
+ c_retvm_if(NULL == cbar, FALSE, "elm_toolbar_add() return NULL");
+ elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
+
+ content = ct_detail_create_content(cdetail_d);
+ if (NULL == content)
+ return FALSE;
+
+ back_btn = elm_button_add(cdetail_d->navi);
+ c_retvm_if(NULL == back_btn, FALSE, "elm_button_add() return NULL");
+
+ elm_object_style_set(back_btn, "naviframe/back_btn/default");
+ evas_object_smart_callback_add(back_btn, "clicked", ctui_ug_destroy_me_cb, cdetail_d->ug);
+
+ cdetail_d->navi_item = elm_naviframe_item_push(cdetail_d->navi,
+ T_(CT_GET_TEXT_BASIC, CTTEXT_DETAILS), back_btn, NULL, content, NULL);
+
+ elm_toolbar_item_append(cbar, CTUI_IMG_ICON_DELETE, NULL,
+ detail_delete_cb_ug, cdetail_d);
+
+ ct_toolbar_disalbed_item_append(cbar, 1);
+
+ tmp = elm_toolbar_item_append(cbar, CTUI_IMG_ICON_DETAIL_EDIT, NULL,
+ ct_input_push_navi_content, cdetail_d);
+
+ ct_toolbar_disalbed_item_append(cbar, 1);
+
+ if (CTS_ADDRESSBOOK_MODE_READONLY == cdetail_d->base_ab_mode)
+ elm_object_item_disabled_set(tmp, EINA_TRUE);
+
+ elm_object_item_part_content_set(cdetail_d->navi_item, "controlbar", cbar);
+ }
+ else
+ ct_input_push_navi_content(cdetail_d, NULL, NULL);
+
+ return TRUE;
+}
+
+static void *detail_on_create(struct ui_gadget *ug, enum ug_mode mode,
+ bundle *data, void *priv)
+{
+ int ret, request;
+ Evas_Object *bg;
+ Evas_Object *parent;
+ ct_detail_data *cdetail_d = priv;
+
+ c_retvm_if(NULL == ug || NULL == priv, NULL,
+ "The parameter is invalid(ug=%p, priv=%p)", ug, priv);
+
+ cdetail_d->win = ug_get_window();
+ parent = ug_get_parent_layout(ug);
+ c_retvm_if(NULL == parent, NULL, "ug_get_parent_layout() return NULL");
+ cdetail_d->ug = ug;
+
+ bindtextdomain(PACKAGE, "/opt/ug/res/locale");
+
+ ret = contacts_svc_connect();
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_connect() Failed(%d)", ret);
+
+ if (UG_MODE_FULLVIEW == mode)
+ cdetail_d->base = ctui_create_base_layout(parent, true);
+ else
+ cdetail_d->base = ctui_create_base_layout(parent, false);
+
+ request = ct_detail_parse_bundle(data, cdetail_d);
+ if (-2 == request) {
+ Evas_Object *popup;
+ popup = elm_popup_add(cdetail_d->base);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_text_set(popup, T_(CT_GET_TEXT_ERR, CTTEXT_DATA_NOT_EXIST));
+ elm_popup_timeout_set(popup, 1.5);
+ evas_object_show(popup);
+ cdetail_d->ug = ug;
+ evas_object_smart_callback_add(popup, "timeout", ctui_list_ug_hide_cb, cdetail_d->ug);
+ return cdetail_d->base;
+ }
+ c_retvm_if(request < 0, NULL, "ct_detail_parse_bundle() Failed(%d)", request);
+
+ bg = ctui_set_bg(cdetail_d->base);
+ if (NULL == bg) {
+ ERR("ctui_set_bg() return NULL");
+ evas_object_del(cdetail_d->base);
+ cdetail_d->base = NULL;
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+ return NULL;
+ }
+ elm_object_style_set(bg, "group_list");
+
+ if (create_ug_detail_view(request, cdetail_d)) {
+ elm_object_part_content_set(cdetail_d->base, "elm.swallow.content", cdetail_d->navi);
+ }
+ else {
+ evas_object_del(cdetail_d->base);
+ cdetail_d->base = NULL;
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+ }
+
+ return cdetail_d->base;
+}
+
+static void detail_on_destroy(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ int ret;
+ ct_detail_data *cdetail_d = priv;
+ c_retm_if(NULL == ug, "The parameter is invalid(ug=%p)", ug);
+
+ evas_object_del(ug_get_layout(ug));
+ if (!cdetail_d->navi)
+ free(cdetail_d);
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+}
+
+static void detail_on_key_event(struct ui_gadget *ug, enum ug_key_event event, bundle *data, void *priv)
+{
+ CT_FN_CALL;
+ ct_detail_data *cdetail_d = priv;
+
+ if (!ug)
+ return;
+
+ switch (event) {
+ case UG_KEY_EVENT_END:
+ if (cdetail_d->popup) {
+ evas_object_del(cdetail_d->popup);
+ cdetail_d->popup = NULL;
+ }
+ else {
+ if (elm_naviframe_top_item_get(cdetail_d->navi)
+ == cdetail_d->navi_item) {
+ ug_destroy_me(ug);
+ }
+ else
+ elm_naviframe_item_pop(cdetail_d->navi);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void detail_on_message(struct ui_gadget *ug, bundle *msg, bundle *data, void *priv)
+{
+ const char* val = NULL;
+ ct_detail_data *cdetail_d = priv;
+
+ if (UG_MODE_FRAMEVIEW == ug_get_mode(ug)) {
+ if (msg) {
+ val = bundle_get_val(msg, "key_event");
+ if (val && CTUG_MSG_KEY_END == atoi(val)) {
+ if (cdetail_d->popup) {
+ evas_object_del(cdetail_d->popup);
+ cdetail_d->popup = NULL;
+ }
+ else {
+ if (elm_naviframe_top_item_get(cdetail_d->navi)
+ == cdetail_d->navi_item) {
+ ug_destroy_me(ug);
+ }
+ else
+ elm_naviframe_item_pop(cdetail_d->navi);
+ }
+ }
+ }
+ }
+}
+
+static void detail_on_pause(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ ct_detail_data *cdetail_d = priv;
+ cdetail_d->order_display = contacts_svc_get_order(CTS_ORDER_OF_DISPLAY);
+}
+
+static void detail_on_resume(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ ct_detail_data *cdetail_d = priv;
+ if (cdetail_d->order_display != contacts_svc_get_order(CTS_ORDER_OF_DISPLAY))
+ ctui_detail_genlist_update(cdetail_d);
+}
+
+API int UG_MODULE_INIT(struct ug_module_ops *ops)
+{
+ ct_detail_data *cdetail_d;
+
+ c_retvm_if(!ops, -1, "ops is NULL");
+
+ cdetail_d = calloc(1, sizeof(ct_detail_data));
+ c_retvm_if(!cdetail_d, -1, "UG data is NULL, Not enough memory");
+
+ ops->create = detail_on_create;
+ ops->start = NULL;
+ ops->pause = detail_on_pause;
+ ops->resume = detail_on_resume;
+ ops->destroy = detail_on_destroy;
+ ops->message = detail_on_message;
+ ops->key_event = detail_on_key_event;
+ ops->priv = cdetail_d;
+ ops->opt = UG_OPT_INDICATOR_ENABLE;
+
+ return 0;
+}
+
+API void UG_MODULE_EXIT(struct ug_module_ops *ops)
+{
+ c_retm_if(!ops, "ops is NULL");
+
+ ops->priv = NULL;
+}
+
+static void detail_back_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *nf = (Evas_Object *)data;
+ elm_naviframe_item_pop(nf);
+}
+
+API int ctui_create_detail_view(ct_list_data *clist_d, int id)
+{
+ CT_FN_CALL;
+ CT_START_TIME_CHECK;
+ ct_detail_data *cdetail_d;
+ Evas_Object *content;
+ Evas_Object *cbar;
+ Evas_Object *bg;
+ Evas_Object *back_btn;
+ Elm_Object_Item *tmp;
+
+ cdetail_d = calloc(1, sizeof(ct_detail_data));
+ c_retvm_if(!cdetail_d, -1, "cdetail_d is NULL, Not enough memory");
+
+ ctui_ld_to_dd(clist_d, cdetail_d);
+ cdetail_d->contact_id = id;
+
+ cdetail_d->base = ctui_create_base_layout(clist_d->navi, false);
+ bg = ctui_set_bg(cdetail_d->base);
+ if (NULL == bg) {
+ ERR("ctui_set_bg() return NULL");
+ evas_object_del(cdetail_d->base);
+ free(cdetail_d);
+ return -1;
+ }
+ elm_object_style_set(bg, "group_list");
+
+ content = ct_detail_create_content(cdetail_d);
+ if (NULL == content) {
+ ERR("ct_detail_create_content() Failed");
+ evas_object_del(cdetail_d->base);
+ free(cdetail_d);
+ return -1;
+ }
+ elm_object_part_content_set(cdetail_d->base, "elm.swallow.content", content);
+
+ back_btn = elm_button_add(cdetail_d->navi);
+ c_retvm_if(NULL == back_btn, -1, "elm_button_add() return NULL");
+
+ elm_object_style_set(back_btn, "naviframe/back_btn/default");
+ evas_object_smart_callback_add(back_btn, "clicked", detail_back_btn_cb, cdetail_d->navi);
+
+ cdetail_d->navi_item = elm_naviframe_item_push(cdetail_d->navi,
+ T_(CT_GET_TEXT_BASIC, CTTEXT_DETAILS), back_btn, NULL, cdetail_d->base, NULL);
+
+ cbar = elm_toolbar_add(cdetail_d->navi);
+ if (NULL == cbar) {
+ ERR("elm_toolbar_add() return NULL");
+ free(cdetail_d);
+ evas_object_del(cdetail_d->base);
+ return -1;
+ }
+ elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
+
+ elm_toolbar_item_append(cbar, CTUI_IMG_ICON_DELETE, NULL,
+ detail_delete_cb_lib, cdetail_d);
+
+ ct_toolbar_disalbed_item_append(cbar, 1);
+
+ tmp = elm_toolbar_item_append(cbar, CTUI_IMG_ICON_DETAIL_EDIT, NULL,
+ ct_input_push_navi_content, cdetail_d);
+
+ if (CTS_ADDRESSBOOK_MODE_READONLY == cdetail_d->base_ab_mode)
+ elm_object_item_disabled_set(tmp, EINA_TRUE);
+
+ ct_toolbar_disalbed_item_append(cbar, 1);
+
+ elm_object_item_part_content_set(cdetail_d->navi_item, "controlbar", cbar);
+
+ CT_END_TIME_CHECK();
+ return 0;
+}
+
+API int ctui_create_input_view(ct_detail_data *cdetail_d)
+{
+ CT_FN_CALL;
+ CT_START_TIME_CHECK;
+
+ c_retvm_if(!cdetail_d, -1, "cdetail_d is NULL");
+
+ ct_input_push_navi_content(cdetail_d, NULL, NULL);
+
+ CT_END_TIME_CHECK("ct_input_push_navi_content");
+ return 0;
+}
+
+API int ctui_contacts_viewer(Evas_Object *win, int ct_id, const char *vcard_stream)
+{
+ int ret;
+ ct_detail_data *cdetail_d;
+ Evas_Object *bg;
+ Evas_Object *content;
+ Evas_Object *cbar;
+ Evas_Object *back_btn;
+
+ cdetail_d = calloc(1, sizeof(ct_detail_data));
+ c_retvm_if(!cdetail_d, -1, "cdetail_d is NULL, Not enough memory");
+
+ cdetail_d->win = win;
+ cdetail_d->base = ctui_create_base_layout(win, true);
+ cdetail_d->navi = elm_naviframe_add(cdetail_d->base);
+ evas_object_show(cdetail_d->navi);
+ elm_naviframe_prev_btn_auto_pushed_set(cdetail_d->navi, EINA_FALSE);
+
+ bg = ctui_set_bg(cdetail_d->base);
+ if (NULL == bg) {
+ ERR("ctui_set_bg() return NULL");
+ evas_object_del(cdetail_d->base);
+ free(cdetail_d);
+ return -1;
+ }
+ elm_object_style_set(bg, "group_list");
+
+ if (ct_id) {
+ cdetail_d->is_shortcut = true;
+ cdetail_d->contact_id = ct_id;
+ ret = contacts_svc_get_contact(ct_id, &(cdetail_d->contact));
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_get_contact() Failed(%d)", ret);
+ evas_object_del(cdetail_d->base);
+ free(cdetail_d);
+ return -1;
+ }
+ }
+ else {
+ cdetail_d->vcard = (char *)vcard_stream;
+ ret = contacts_svc_get_contact_from_vcard(vcard_stream, &(cdetail_d->contact));
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_get_contact_from_vcard() Failed(%d)", ret);
+ evas_object_del(cdetail_d->base);
+ free(cdetail_d);
+ return -1;
+ }
+ }
+
+ content = ct_detail_create_content(cdetail_d);
+ if (NULL == content) {
+ ERR("ct_detail_create_content() Failed");
+ evas_object_del(cdetail_d->base);
+ ret = contacts_svc_struct_free(cdetail_d->contact);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_struct_free() Failed(%d)", ret);
+ free(cdetail_d);
+ return -1;
+ }
+
+ cbar = elm_toolbar_add(cdetail_d->navi);
+ if (NULL == cbar) {
+ ERR("elm_toolbar_add() return NULL");
+ evas_object_del(cdetail_d->base);
+ ret = contacts_svc_struct_free(cdetail_d->contact);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_struct_free() Failed(%d)", ret);
+ free(cdetail_d);
+ return -1;
+ }
+
+ elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
+
+ if (ct_id) {
+ Elm_Object_Item *item_edit;
+
+ item_edit = elm_toolbar_item_append(cbar, CTUI_IMG_ICON_DETAIL_EDIT, NULL,
+ ct_input_push_navi_content, cdetail_d);
+ if (CTS_ADDRESSBOOK_MODE_READONLY == cdetail_d->base_ab_mode)
+ elm_object_item_disabled_set(item_edit, EINA_TRUE);
+ ct_toolbar_disalbed_item_append(cbar, 1);
+
+ elm_toolbar_item_append(cbar, CTUI_IMG_ICON_DELETE, NULL,
+ detail_delete_cb_cv, cdetail_d);
+ ct_toolbar_disalbed_item_append(cbar, 1);
+ }
+ else {
+ elm_toolbar_item_append(cbar, CTUI_IMG_ICON_ADD_TO_CONTACTS, NULL,
+ ct_input_push_navi_content, cdetail_d);
+ ct_toolbar_disalbed_item_append(cbar, 1);
+ }
+
+ back_btn = elm_button_add(cdetail_d->navi);
+ c_retvm_if(NULL == back_btn, -1, "elm_button_add() return NULL");
+
+ elm_object_style_set(back_btn, "naviframe/back_btn/default");
+ evas_object_smart_callback_add(back_btn, "clicked", ctui_back_btn_clicked_cb, cdetail_d->win);
+
+ cdetail_d->navi_item = elm_naviframe_item_push(cdetail_d->navi,
+ T_(CT_GET_TEXT_BASIC, CTTEXT_DETAILS), back_btn, NULL, content, NULL);
+ elm_object_item_part_content_set(cdetail_d->navi_item, "controlbar", cbar);
+
+ elm_object_part_content_set(cdetail_d->base, "elm.swallow.content", cdetail_d->navi);
+ evas_object_size_hint_weight_set(cdetail_d->base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, cdetail_d->base);
+ evas_object_show(cdetail_d->base);
+
+ return 0;
+
+}
+
+API int ctui_detail_create_view_without_del(Evas_Object *win, Evas_Object *navi, struct ui_gadget *ug, int id)
+{
+ CT_FN_CALL;
+ CT_START_TIME_CHECK;
+ ct_detail_data *cdetail_d;
+ Evas_Object *content, *bg;
+ Evas_Object *cbar;
+ Evas_Object *back_btn;
+
+ cdetail_d = calloc(1, sizeof(ct_detail_data));
+ c_retvm_if(!cdetail_d, -1, "cdetail_d is NULL, Not enough memory");
+
+ cdetail_d->win = win;
+ cdetail_d->navi = navi;
+ cdetail_d->ug = ug;
+ cdetail_d->prev_navi_item = elm_naviframe_top_item_get(navi);
+ cdetail_d->contact_id = id;
+
+ cdetail_d->base = ctui_create_base_layout(cdetail_d->navi, false);
+ bg = ctui_set_bg(cdetail_d->base);
+ if (NULL == bg) {
+ ERR("ctui_set_bg() return NULL");
+ evas_object_del(cdetail_d->base);
+ free(cdetail_d);
+ return -1;
+ }
+ elm_object_style_set(bg, "group_list");
+
+ content = ct_detail_create_content(cdetail_d);
+ if (NULL == content) {
+ ERR("ct_detail_create_content() Failed");
+ free(cdetail_d);
+ evas_object_del(cdetail_d->base);
+ return -1;
+ }
+ elm_object_part_content_set(cdetail_d->base, "elm.swallow.content", content);
+
+ cbar = elm_toolbar_add(cdetail_d->navi);
+ c_retvm_if(NULL == cbar, -1, "elm_toolbar_add() return NULL");
+
+ elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
+ if (!ug) {
+ Elm_Object_Item *item_edit;
+
+ item_edit = elm_toolbar_item_append(cbar, CTUI_IMG_ICON_DETAIL_EDIT, NULL,
+ ct_input_push_navi_content, cdetail_d);
+ if (CTS_ADDRESSBOOK_MODE_READONLY == cdetail_d->base_ab_mode)
+ elm_object_item_disabled_set(item_edit, EINA_TRUE);
+
+ ct_toolbar_disalbed_item_append(cbar, 3);
+ }
+
+ back_btn = elm_button_add(cdetail_d->navi);
+ c_retvm_if(NULL == back_btn, -1, "elm_button_add() return NULL");
+
+ elm_object_style_set(back_btn, "naviframe/back_btn/default");
+ evas_object_smart_callback_add(back_btn, "clicked", detail_back_btn_cb, cdetail_d->navi);
+
+ cdetail_d->navi_item = elm_naviframe_item_push(cdetail_d->navi,
+ T_(CT_GET_TEXT_BASIC, CTTEXT_DETAILS), back_btn, NULL, cdetail_d->base, NULL);
+ elm_object_item_part_content_set(cdetail_d->navi_item, "controlbar", cbar);
+
+ CT_END_TIME_CHECK();
+ return 0;
+}
+
diff --git a/lib/details/ct-detail-utils.c b/lib/details/ct-detail-utils.c
new file mode 100755
index 0000000..fb3f85a
--- /dev/null
+++ b/lib/details/ct-detail-utils.c
@@ -0,0 +1,570 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <fcntl.h>
+#include <vconf.h>
+#include <Ecore_X.h>
+#include <ui-gadget-module.h>
+
+#include "contacts.h"
+#include "ct-detail.h"
+#include "ct-detail-view.h"
+#include "ct-detail-utils.h"
+
+int ct_detail_parse_bundle(bundle *bd, ct_detail_data* cdetail_d)
+{
+ int type = CT_UG_REQUEST_DETAIL;
+ const char* val = NULL;
+
+ if (bd) {
+ val = bundle_get_val(bd, CT_UG_BUNDLE_TYPE);
+ if (val) type = atoi(val);
+ CT_DBG("type = %d", type);
+
+ switch (type) {
+ case CT_UG_REQUEST_DETAIL:
+ case CT_UG_REQUEST_EDIT:
+ val = bundle_get_val(bd, CT_UG_BUNDLE_ID);
+ if (val) cdetail_d->contact_id = atoi(val);
+ break;
+ case CT_UG_REQUEST_ADD:
+ val = bundle_get_val(bd, CT_UG_BUNDLE_VCARD);
+ if (val) contacts_svc_get_contact_from_vcard(val, &(cdetail_d->contact));
+ break;
+ case CT_UG_REQUEST_ADD_WITH_NUM:
+ val = bundle_get_val(bd, CT_UG_BUNDLE_NUM);
+ if (val) {
+ if (NULL == cdetail_d->contact)
+ cdetail_d->contact = contacts_svc_struct_new(CTS_STRUCT_CONTACT);
+ GSList *nums = NULL;
+ CTSvalue *num = contacts_svc_value_new(CTS_VALUE_NUMBER);
+ contacts_svc_value_set_int(num, CTS_NUM_VAL_TYPE_INT, CTS_NUM_TYPE_CELL);
+ contacts_svc_value_set_str(num, CTS_NUM_VAL_NUMBER_STR, val);
+ nums = g_slist_append(nums, num);
+ contacts_svc_struct_store_list(cdetail_d->contact, CTS_CF_NUMBER_LIST, nums);
+ g_slist_free(nums);
+ }
+ break;
+ case CT_UG_REQUEST_ADD_WITH_EMAIL:
+ val = bundle_get_val(bd, CT_UG_BUNDLE_EMAIL);
+ if (val) {
+ if (NULL == cdetail_d->contact)
+ cdetail_d->contact = contacts_svc_struct_new(CTS_STRUCT_CONTACT);
+ GSList *emails = NULL;
+ CTSvalue *email = contacts_svc_value_new(CTS_VALUE_EMAIL);
+ contacts_svc_value_set_int(email, CTS_EMAIL_VAL_TYPE_INT, CTS_EMAIL_TYPE_HOME);
+ contacts_svc_value_set_str(email, CTS_EMAIL_VAL_ADDR_STR, val);
+ emails = g_slist_append(emails, email);
+ contacts_svc_struct_store_list(cdetail_d->contact, CTS_CF_EMAIL_LIST, emails);
+ g_slist_free(emails);
+ }
+ break;
+ case CT_UG_REQUEST_ADD_WITH_WEB:
+ val = bundle_get_val(bd, CT_UG_BUNDLE_WEB);
+ if (val) {
+ if (NULL == cdetail_d->contact)
+ cdetail_d->contact = contacts_svc_struct_new(CTS_STRUCT_CONTACT);
+ GSList *webs = NULL;
+ CTSvalue *web = contacts_svc_value_new(CTS_VALUE_WEB);
+ contacts_svc_value_set_int(web, CTS_WEB_VAL_TYPE_INT, CTS_WEB_TYPE_HOME);
+ contacts_svc_value_set_str(web, CTS_WEB_VAL_ADDR_STR, val);
+ webs = g_slist_append(webs, web);
+ contacts_svc_struct_store_list(cdetail_d->contact, CTS_CF_WEB_ADDR_LIST, webs);
+ g_slist_free(webs);
+ }
+ break;
+ }
+ }
+ // FIXME : improve performance
+ if (cdetail_d->contact_id) {
+ int ret;
+ CTSstruct *contact;
+ ret = contacts_svc_get_contact(cdetail_d->contact_id, &contact);
+ c_retvm_if(ret != CTS_SUCCESS, -2, "contact id is not valid");
+ contacts_svc_struct_free(contact);
+ }
+ return type;
+}
+
+static inline bool detail_is_usable_char(char c)
+{
+ switch (c) {
+ case '\\':
+ case '/':
+ case ':':
+ case '*':
+ case '?':
+ case '\"':
+ case '<':
+ case '>':
+ case '|':
+ case ';':
+ return false;
+ default:
+ return true;
+ }
+}
+
+static inline bool detail_is_blank_str(char *display)
+{
+ int i;
+ for (i = 0 ; i < strlen(display); i++)
+ if (' ' != display[i]) return false;
+ return true;
+}
+
+static void detail_get_vcard_filepath(ct_detail_data *cdetail_d, char* path_buf, int buf_size)
+{
+ int ret;
+ char display[CT_TEXT_MAX_LEN];
+ char temp[CT_TEXT_MAX_LEN];
+ CTSvalue *name;
+
+ temp[0] = '\0';
+ ret = contacts_svc_struct_get_value(cdetail_d->contact, CTS_CF_NAME_VALUE, &name);
+ if (CTS_SUCCESS == ret)
+ ctui_get_display_name(name, temp, sizeof(temp));
+
+ display[0] = '\0';
+ if (*temp) {
+ int i;
+ int idx = 0;
+ for (i = 0 ; i < strlen(temp); i++) {
+ if (detail_is_usable_char(temp[i]))
+ display[idx++] = temp[i];
+ }
+ display[idx] = '\0';
+ }
+
+ if ('\0' == display[0] || detail_is_blank_str(display)) {
+ snprintf(display, sizeof(display), "%s", T_(CT_GET_TEXT_ERR, CTTEXT_NONAME));
+ }
+ snprintf(path_buf, buf_size, "%s/%s.vcf", UGDATAIDR, display);
+}
+
+static int detail_make_vcard(ct_detail_data *cdetail_d, char *path_buf, int buf_size)
+{
+ int ret, fd;
+ char* vcard;
+
+ detail_get_vcard_filepath(cdetail_d, path_buf, buf_size);
+ c_retvm_if(NULL == path_buf, FALSE, "detail_get_vcard_filepath() return NULL");
+
+ ret = contacts_svc_get_vcard_from_contact(cdetail_d->contact, &vcard);
+ c_retvm_if(NULL == vcard, FALSE,
+ "contacts_svc_get_vcard_from_contact() Failed(%d)", ret);
+
+ fd = open(path_buf, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ if (fd < 0) {
+ ERR("Open(%s) Failed", path_buf);
+ free(vcard);
+ return FALSE;
+ }
+
+ write(fd, vcard, strlen(vcard));
+ close(fd);
+
+ free(vcard);
+ return TRUE;
+}
+
+void ct_detail_delete_namecards(ct_detail_data *cdetail_d)
+{
+ int ret;
+ int fd;
+ char file_path[FILENAME_MAX];
+
+ detail_get_vcard_filepath(cdetail_d, file_path, sizeof(file_path));
+
+ fd = open(file_path, O_RDONLY);
+ if (fd < 0) return;
+
+ close(fd);
+
+ ret = unlink(file_path);
+ c_warn_if(ret < 0, "unlink(%s) failed(%d)", file_path, ret);
+}
+
+void ct_detail_email_ug(struct ui_gadget *parent, const char *to, const char *attach)
+{
+ struct ug_cbs cbs = {0};
+ struct ui_gadget* ug;
+
+ bundle* bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_craete() return NULL");
+
+ bundle_add(bd, "RUN_TYPE", "5");
+
+ if (to)
+ bundle_add(bd, "TO", to);
+
+ if (attach) {
+ bundle_add(bd, "ATTACHMENT", attach);
+ bundle_add(bd, "SUBJECT", "Contacts name card");
+ }
+
+ cbs.layout_cb = ctui_ug_layout_cb;
+ cbs.result_cb = NULL;
+ cbs.destroy_cb = ctui_ug_destroy_cb;
+
+ ug = ug_create(parent, EMAIL_COMPOSER_UG, UG_MODE_FULLVIEW, bd, &cbs);
+ c_warn_if(NULL == ug, "ug_create() Failed");
+
+ bundle_free(bd);
+}
+
+void ct_detail_send_via_msg(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ char file_path[FILENAME_MAX];
+ ct_detail_data *cdetail_d = data;
+
+ ret = detail_make_vcard(cdetail_d, file_path, sizeof(file_path));
+ c_retm_if(TRUE != ret, "detail_make_vcard() Failed");
+
+ ctui_msg_ug(cdetail_d->ug, NULL, 0, file_path);
+ ct_detail_popup_hide_cb(cdetail_d, NULL, NULL);
+}
+
+void ct_detail_send_via_email(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ char file_path[FILENAME_MAX];
+ ct_detail_data *cdetail_d = data;
+
+ ret = detail_make_vcard(cdetail_d, file_path, sizeof(file_path));
+ c_retm_if(TRUE != ret, "detail_make_vcard() Failed");
+
+ ct_detail_email_ug(cdetail_d->ug, NULL, file_path);
+ ct_detail_popup_hide_cb(cdetail_d, NULL, NULL);
+}
+
+void ct_detail_send_via_bluetooth(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ bundle* bd;
+ struct ui_gadget* ug;
+ ct_detail_data *cdetail_d = data;
+ char file_path[FILENAME_MAX];
+ struct ug_cbs cbs = {0};
+
+ ret = detail_make_vcard(cdetail_d, file_path, sizeof(file_path));
+ c_retm_if(TRUE != ret, "detail_make_vcard() Failed");
+
+ bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_create() return NULL");
+
+ bundle_add(bd, "launch-type", "send");
+ bundle_add(bd, "filecount", "1");
+ bundle_add(bd, "files", file_path);
+
+ cbs.layout_cb = ctui_ug_layout_cb;
+ cbs.result_cb = NULL;
+ cbs.destroy_cb = ctui_ug_destroy_cb;
+ ug = ug_create(cdetail_d->ug, BLUETOOTH_UG, UG_MODE_FULLVIEW, bd, &cbs);
+
+ bundle_free(bd);
+ ct_detail_popup_hide_cb(cdetail_d, NULL, NULL);
+}
+
+void ct_detail_get_nicknames(CTSvalue *value, char *dest, int dest_len)
+{
+ int ret;
+ char temp[dest_len];
+ const char* nickname = NULL;
+
+ c_retm_if(NULL == dest, "dest is NULL");
+
+ nickname = contacts_svc_value_get_str(value, CTS_NICKNAME_VAL_NAME_STR);
+ if (NULL == nickname) return;
+
+ if (*dest) {
+ ret = snprintf(temp, dest_len, "%s, %s", dest, nickname);
+ if (0 < ret)
+ memcpy(dest, temp, ret+1);
+ }
+ else {
+ snprintf(dest, dest_len, "%s", nickname);
+ }
+}
+
+int ct_detail_get_extra_name(CTSvalue *name, char *dest, int dest_len)
+{
+ int ret;
+ const char *middle, *title, *suffix;
+ char temp[dest_len];
+
+ middle = contacts_svc_value_get_str(name, CTS_NAME_VAL_ADDITION_STR);
+ title = contacts_svc_value_get_str(name, CTS_NAME_VAL_PREFIX_STR);
+ suffix = contacts_svc_value_get_str(name, CTS_NAME_VAL_SUFFIX_STR);
+
+ c_retvm_if(NULL == dest, -1, "dest is NULL");
+
+ if (middle)
+ snprintf(dest, dest_len, "%s", middle);
+
+ if (title) {
+ if (*dest) {
+ ret = snprintf(temp, dest_len, "%s, %s", dest, title);
+ if (0 < ret)
+ memcpy(dest, temp, ret+1);
+ }
+ else {
+ snprintf(dest, dest_len, "%s", title);
+ }
+ }
+
+ if (suffix) {
+ if (*dest) {
+ ret = snprintf(temp, dest_len, "%s, %s", dest, suffix);
+ if (0 < ret)
+ memcpy(dest, temp, ret+1);
+ }
+ else {
+ snprintf(dest, dest_len, "%s", suffix);
+ }
+ }
+
+ return 0;
+}
+
+void ct_detail_popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_detail_data *cdetail_d = data;
+ evas_object_del(cdetail_d->popup);
+ cdetail_d->popup = NULL;
+}
+
+void ct_detail_get_group_names(GSList *list, char *dest, int dest_len)
+{
+ int ret;
+ const char *group;
+ char temp[CT_TEXT_MAX_LEN];
+ GSList *cursor;
+
+ dest[0] = '\0';
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (contacts_svc_value_get_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL))
+ continue;
+
+ group = contacts_svc_value_get_str(cursor->data, CTS_GROUPREL_VAL_NAME_STR);
+ if (group && *group) {
+ if (*dest) {
+ ret = snprintf(temp, CT_TEXT_MAX_LEN, "%s, %s", dest, group);
+ if (ret < dest_len) {
+ memcpy(dest, temp, ret + 1);
+ }
+ else {
+ memcpy(dest, temp, dest_len);
+ dest[dest_len - 1] = '\0';
+ }
+ }
+ else {
+ snprintf(dest, CT_TEXT_MAX_LEN, "%s", group);
+ }
+ continue;
+ }
+ }
+
+ if ('\0' == *dest)
+ snprintf(dest, dest_len, "%s", T_(CT_GET_TEXT_BASIC, CTTEXT_NOT_ASSIGNED));
+
+}
+
+static void detail_refresh_view(ct_detail_data *cdetail_d)
+{
+ int ret;
+
+ contacts_svc_struct_free(cdetail_d->contact);
+ cdetail_d->contact = NULL;
+
+ if (cdetail_d->contact_id) {
+ contacts_svc_begin_trans();
+ cdetail_d->view_creat_ver = contacts_svc_end_trans(true);
+ ret = contacts_svc_get_contact(cdetail_d->contact_id, &(cdetail_d->contact));
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_get_contact() Failed(%d)", ret);
+ elm_naviframe_item_pop(cdetail_d->navi);
+ }
+ }
+ else {
+ ret = contacts_svc_get_contact_from_vcard(cdetail_d->vcard, &(cdetail_d->contact));
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_get_contact_from_vcard() Failed(%d)", ret);
+ elm_exit();
+ }
+ }
+
+ ctui_detail_genlist_update(cdetail_d);
+}
+
+void ct_detail_contacts_changed(void *user_data)
+{
+ int id_ab, type, ret;
+ bool changed = false;
+ CTSiter *iter;
+ CTSvalue *value;
+ ct_detail_data *cdetail_d = user_data;
+
+ contacts_svc_struct_get_value(cdetail_d->contact, CTS_CF_BASE_INFO_VALUE, &value);
+ id_ab = contacts_svc_value_get_int(value, CTS_BASE_VAL_ADDRESSBOOK_ID_INT);
+
+ ret = contacts_svc_get_updated_contacts(id_ab, cdetail_d->view_creat_ver, &iter);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_get_updated_contacts() Failed(%d)", ret);
+
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ value = contacts_svc_iter_get_info(iter);
+ if (contacts_svc_value_get_int(value, CTS_LIST_CHANGE_ID_INT) == cdetail_d->contact_id) {
+ changed = true;
+ type = contacts_svc_value_get_int(value, CTS_LIST_CHANGE_TYPE_INT);
+ contacts_svc_value_free(value);
+ break;
+ }
+ contacts_svc_value_free(value);
+ }
+ contacts_svc_iter_remove(iter);
+ c_ret_if(!changed);
+
+ if (CTS_OPERATION_DELETED == type) {
+ if (cdetail_d->is_shortcut)
+ elm_exit();
+ else if (NULL == cdetail_d->clist_d && cdetail_d->ug)
+ ug_destroy_me(cdetail_d->ug);
+ else
+ elm_naviframe_item_pop_to(cdetail_d->prev_navi_item);
+ }
+ else {
+ detail_refresh_view(cdetail_d);
+ }
+}
+
+static inline void detail_append_str_with_linebreak(const char *src, char *dest, int dest_len)
+{
+ char temp[CT_TEXT_MAX_LEN];
+ if (src && '\0' != src[0]) {
+ if ('\0' == dest[0])
+ snprintf(dest, dest_len, "%s", src);
+ else {
+ snprintf(temp, sizeof(temp), "%s\n%s", src, dest);
+ snprintf(dest, dest_len, "%s", temp);
+ }
+ }
+}
+
+int ct_detail_get_full_addr(CTSvalue *postal, char *buf, int buf_len)
+{
+ const char *code, *region, *locality, *street, *extended, *country;
+ char temp[CT_TEXT_MAX_LEN];
+ code = contacts_svc_value_get_str(postal, CTS_POSTAL_VAL_POSTALCODE_STR);
+ region = contacts_svc_value_get_str(postal, CTS_POSTAL_VAL_REGION_STR);
+ locality = contacts_svc_value_get_str(postal, CTS_POSTAL_VAL_LOCALITY_STR);
+ street = contacts_svc_value_get_str(postal, CTS_POSTAL_VAL_STREET_STR);
+ extended = contacts_svc_value_get_str(postal, CTS_POSTAL_VAL_EXTENDED_STR);
+ country = contacts_svc_value_get_str(postal, CTS_POSTAL_VAL_COUNTRY_STR);
+
+ if (extended && *extended)
+ snprintf(temp, sizeof(temp), "%s%s%s", SAFE_STR(street), STR_BLANK(street, extended));
+ else
+ snprintf(temp, sizeof(temp), "%s", SAFE_STR(street));
+
+ detail_append_str_with_linebreak(temp, buf, buf_len);
+ detail_append_str_with_linebreak(locality, buf, buf_len);
+ detail_append_str_with_linebreak(region, buf, buf_len);
+ detail_append_str_with_linebreak(country, buf, buf_len);
+ detail_append_str_with_linebreak(code, buf, buf_len);
+
+ return 0;
+}
+
+int ct_detail_get_ct_number_type(int cts_num_type)
+{
+ if (cts_num_type & CTS_NUM_TYPE_CUSTOM)
+ return CTTEXT_TYPE_OTHER;
+ else if (cts_num_type & CTS_NUM_TYPE_CELL)
+ return CTTEXT_TYPE_MOBILE;
+ else if (cts_num_type & CTS_NUM_TYPE_VOICE) {
+ if (cts_num_type & CTS_NUM_TYPE_HOME)
+ return CTTEXT_TYPE_HOME;
+ else if (cts_num_type & CTS_NUM_TYPE_WORK)
+ return CTTEXT_TYPE_WORK;
+ else
+ return CTTEXT_TYPE_TELEPHONE;
+ }
+ else if (cts_num_type & CTS_NUM_TYPE_FAX) {
+ if (cts_num_type & CTS_NUM_TYPE_HOME)
+ return CTTEXT_TYPE_FAX;
+ else if (cts_num_type & CTS_NUM_TYPE_WORK)
+ return CTTEXT_TYPE_FAX;
+ else
+ return CTTEXT_TYPE_FAX;
+ }
+ else if (cts_num_type & CTS_NUM_TYPE_PAGER)
+ return CTTEXT_TYPE_PAGER;
+ else if (cts_num_type & CTS_NUM_TYPE_CAR)
+ return CTTEXT_TYPE_CAR;
+ else if (cts_num_type & CTS_NUM_TYPE_ASSISTANT)
+ return CTTEXT_TYPE_ASSISTANT;
+ else
+ return CTTEXT_TYPE_OTHER;
+
+}
+
+bool ct_detail_set_favorite(CTSstruct *contact, int contact_id, bool is_set)
+{
+ int ret;
+ CTSvalue *base;
+
+ if (is_set)
+ ret = contacts_svc_set_favorite(CTS_FAVOR_CONTACT, contact_id);
+ else
+ ret = contacts_svc_unset_favorite(CTS_FAVOR_CONTACT, contact_id);
+ c_retvm_if(CTS_SUCCESS != ret, false, "contacts_svc_set(unset)_favorite() failed(%d)", ret);
+
+ ret = contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &base);
+ c_retvm_if(CTS_SUCCESS != ret, false, "contacts_svc_struct_get_value() failed(%d)", ret);
+ ret = contacts_svc_value_set_bool(base, CTS_BASE_VAL_FAVORITE_BOOL, is_set);
+ c_retvm_if(CTS_SUCCESS != ret, false, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ return true;
+}
+
+void ct_detail_genlist_append_separator_line_10px(Evas_Object *genlist)
+{
+ static Elm_Genlist_Item_Class itc = { .item_style="dialogue/separator/11/with_line" };
+
+ Elm_Object_Item *item;
+ item = elm_genlist_item_append(genlist, &itc, NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+}
+
+void ct_detail_mouseup(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Up *ev = event_info;
+ ct_detail_data *cdetail_d = data;
+ cdetail_d->touch_x = ev->canvas.x;
+ cdetail_d->touch_y = ev->canvas.y;
+}
+
diff --git a/lib/details/ct-detail-utils.h b/lib/details/ct-detail-utils.h
new file mode 100755
index 0000000..8b01087
--- /dev/null
+++ b/lib/details/ct-detail-utils.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_DETAIL_UTILS_H__
+#define __CONTACTS_DETAIL_UTILS_H__
+void ct_detail_send_via_msg(void *data, Evas_Object *obj, void *event_info);
+void ct_detail_email_ug(struct ui_gadget *parent, const char *to, const char *attach);
+void ct_detail_send_via_email(void *data, Evas_Object *obj, void *event_info);
+void ct_detail_send_via_bluetooth(void *data, Evas_Object *obj, void *event_info);
+void ct_detail_get_group_names(GSList *list, char *dest, int dest_len);
+void ct_detail_delete_namecards(ct_detail_data *cdetail_d);
+int ct_detail_parse_bundle(bundle *bd, ct_detail_data* cdetail_d);
+void ct_detail_popup_hide_cb(void *data, Evas_Object *obj, void *event_info);
+void ct_detail_get_nicknames(CTSvalue *value, char *dest, int dest_len);
+int ct_detail_get_extra_name(CTSvalue *name, char *dest, int dest_len);
+int ct_detail_get_full_addr(CTSvalue *postal, char *buf, int buf_len);
+void ct_detail_contacts_changed(void *user_data);
+bool ct_detail_set_favorite(CTSstruct *contact, int contact_id, bool is_set);
+void ct_detail_genlist_append_separator_line_10px(Evas_Object *genlist);
+void ct_detail_mouseup(void *data, Evas *evas, Evas_Object *obj, void *event_info);
+
+#endif //__CONTACTS_DETAIL_UTILS_H__
diff --git a/lib/details/ct-detail-view.c b/lib/details/ct-detail-view.c
new file mode 100755
index 0000000..1827914
--- /dev/null
+++ b/lib/details/ct-detail-view.c
@@ -0,0 +1,1003 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <aul.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <unicode/udatpg.h>
+#include <unicode/udat.h>
+#include <unicode/ucal.h>
+#include <unicode/ustring.h>
+#include "contacts.h"
+#include "ct-detail.h"
+#include "ct-detail-utils.h"
+#include "ct-detail-view.h"
+
+enum DETAIL_ITC_TYPE {
+ DETAIL_ITC_2TEXT_MULTILINE = 0,
+ DETAIL_ITC_NOTE = DETAIL_ITC_2TEXT_MULTILINE,
+ DETAIL_ITC_COMPANY = DETAIL_ITC_2TEXT_MULTILINE,
+ DETAIL_ITC_BASEINFO = 1,
+ DETAIL_ITC_NUM_UTIL_BTN = 2,
+ DETAIL_ITC_UTIL_BTN = 3,
+ DETAIL_ITC_ADDRBOOK = 4,
+ DETAIL_ITC_TYPED_DATA = 5,
+ DETAIL_ITC_NUMBER = DETAIL_ITC_TYPED_DATA,
+ DETAIL_ITC_EMAIL = DETAIL_ITC_TYPED_DATA,
+ DETAIL_ITC_TITLE_BIG_TEXT = 6,
+ DETAIL_ITC_MESSENGER = DETAIL_ITC_TITLE_BIG_TEXT,
+ DETAIL_ITC_BIRTH = DETAIL_ITC_TITLE_BIG_TEXT,
+ DETAIL_ITC_WEBSITE = DETAIL_ITC_TITLE_BIG_TEXT,
+ DETAIL_ITC_NUMBER_DEF = 7,
+ DETAIL_ITC_ADDRESS = 8,
+ DETAIL_ITC_MAX = 9,
+};
+
+static Elm_Genlist_Item_Class detail_itcs[] = {
+ {.item_style="multiline/dialogue/2text"},
+ {.item_style="dialogue/bg/3text.2icon"},
+ {.item_style="dialogue/bg/2icon"},
+ {.item_style="dialogue/bg/2icon"},
+ {.item_style="dialogue/title"},
+ {.item_style="dialogue.1title.1text"},
+ {.item_style="dialogue/2text.2"},
+ {.item_style="dialogue/1title.1text.1icon"},
+ {.item_style="dialogue/1title.1text.2"},
+};
+
+static char* detail_gl_2text_multiline_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ int type;
+ CTSvalue *value = data;
+ c_retvm_if(NULL == value, NULL, "parameter(CTSvalue) is NULL");
+
+ type = contacts_svc_value_get_type(value);
+ c_retvm_if(CTS_VALUE_COMPANY != type && CTS_VALUE_CONTACT_BASE_INFO != type, NULL, "Invalid type(%d)", type);
+
+ if (0 == strcmp(part, "elm.text.2")) {
+ if (CTS_VALUE_COMPANY == type)
+ return SAFE_STRDUP(contacts_svc_value_get_str(value, CTS_COMPANY_VAL_NAME_STR));
+ else
+ return elm_entry_utf8_to_markup(contacts_svc_value_get_str(value, CTS_BASE_VAL_NOTE_STR));
+ }
+ else if (0 == strcmp(part, "elm.text.1")) {
+ if (CTS_VALUE_COMPANY == type)
+ return strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_COMPANY));
+ else
+ return strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_NOTE));
+ }
+ return NULL;
+}
+
+static char *detail_gl_address_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ int type;
+ int val_type;
+ char buf[CT_TEXT_MAX_LEN];
+ const char *ret_str;
+ CTSvalue *value = data;
+
+ c_retvm_if(NULL == value, NULL, "parameter(CTSvalue) is NULL");
+
+ type = contacts_svc_value_get_type(value);
+ c_retvm_if(CTS_ERR_ARG_NULL == type, NULL,
+ "contacts_svc_value_get_type() return CTS_ERR_ARG_NULL");
+
+ ret_str = NULL;
+ if (0 == strcmp(part, "elm.title")) {
+ val_type = contacts_svc_value_get_int(value, CTS_POSTAL_VAL_TYPE_INT);
+ return strdup(T_(CT_GET_TEXT_POSTAL_TYPE, val_type));
+ }
+ else if (0 == strcmp(part, "elm.text")) {
+ buf[0] = '\0';
+ ct_detail_get_full_addr(value, buf, sizeof(buf));
+ return elm_entry_utf8_to_markup(buf);
+ }
+ return NULL;
+}
+
+static char* detail_get_datetime_str(int year, int mon, int day)
+{
+ char *locale;
+ char *ret_str;
+ char formatted_str[CT_TEXT_SHORT_LEN];
+ int32_t pattern_capacity;
+ int32_t formattedCapacity;
+ UCalendar *cal;
+ UChar *tzId;
+ UChar pattern[CT_TEXT_SHORT_LEN];
+ UChar formatted[CT_TEXT_SHORT_LEN];
+ UChar customSkeleton[CT_TEXT_SHORT_LEN];
+ UDate date;
+ UDateFormat *formatter = NULL;
+ UDateTimePatternGenerator generator;
+ UErrorCode status = U_ZERO_ERROR;
+
+ u_uastrncpy(customSkeleton, UDAT_YEAR_MONTH_DAY, strlen(UDAT_YEAR_MONTH_DAY));
+
+ locale = vconf_get_str(VCONFKEY_REGIONFORMAT);
+ c_retvm_if(NULL == locale, NULL, "vconf_get_str() return NULL");
+
+ generator = udatpg_open(locale, &status);
+ c_retvm_if(U_FAILURE(status), NULL, "udatpg_open() Failed()");
+
+ pattern_capacity = (int32_t) (sizeof(pattern) / sizeof((pattern)[0]));
+ udatpg_getBestPattern(generator, customSkeleton, 6, pattern, pattern_capacity, &status);
+ c_retvm_if(U_FAILURE(status), NULL, "udatpg_getBestPattern() Failed()");
+
+ formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, locale, NULL, -1, pattern, -1, &status);
+ c_retvm_if(U_FAILURE(status), NULL, "udat_open() Failed()");
+
+ formattedCapacity = (int32_t) (sizeof(formatted) / sizeof((formatted)[0]));
+
+ tzId = (UChar*)malloc(sizeof(UChar) * (strlen("PST")+1) );
+ c_retvm_if(NULL == tzId, NULL, "malloc() return NULL");
+ u_uastrcpy(tzId, "PST");
+ cal = ucal_open(tzId, u_strlen(tzId), NULL, UCAL_TRADITIONAL, &status);
+ free(tzId);
+
+ ucal_setDate(cal, year, mon, day, &status);
+ c_retvm_if(U_FAILURE(status), NULL, "ucal_setDate() Failed()");
+ date = ucal_getMillis(cal, &status);
+
+ udat_format(formatter, date, formatted, formattedCapacity, NULL, &status);
+ c_retvm_if(U_FAILURE(status), NULL, "udat_format() Failed()");
+
+ u_austrcpy(formatted_str, formatted);
+ udat_close(formatter);
+ ret_str = g_strdup(formatted_str);
+
+ return ret_str;
+}
+
+static char* detail_gl_title_big_text_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ int type;
+ const char *ret_str;
+ CTSvalue *value = data;
+
+ c_retvm_if(NULL == value, NULL, "parameter(CTSvalue) is NULL");
+
+ type = contacts_svc_value_get_type(value);
+ c_retvm_if(CTS_ERR_ARG_NULL == type, NULL,
+ "contacts_svc_value_get_type() return CTS_ERR_ARG_NULL");
+
+ ret_str = NULL;
+ if (0 == strcmp(part, "elm.text.1")) {
+ int date, day, mon, year;
+
+ switch (type) {
+ case CTS_VALUE_EVENT:
+ date = contacts_svc_value_get_int(value, CTS_EVENT_VAL_DATE_INT);
+
+ day = date%100;
+ mon = (date%10000)/100;
+ year = date/10000;
+
+ c_retvm_if(mon < 1 || 12 < mon || day < 1 || 31 < day, NULL, "Invalid date(mon=%d,day=%d)",mon,day);
+ return detail_get_datetime_str(year, mon - 1, day - 1);
+
+ case CTS_VALUE_MESSENGER:
+ ret_str = contacts_svc_value_get_str(value, CTS_MESSENGER_VAL_IM_ID_STR);
+ break;
+
+ case CTS_VALUE_WEB:
+ ret_str = contacts_svc_value_get_str(value, CTS_WEB_VAL_ADDR_STR);
+ break;
+
+ default:
+ ERR("unknown type(%d)", type);
+ ret_str = NULL;
+ break;
+
+ }
+ }
+ else if (0 == strcmp(part, "elm.text.2")) {
+ int val_type;
+
+ switch (type) {
+ case CTS_VALUE_EVENT:
+ val_type = contacts_svc_value_get_int(value, CTS_EVENT_VAL_TYPE_INT);
+ ret_str = T_(CT_GET_TEXT_EVENT_TYPE, val_type);
+ break;
+
+ case CTS_VALUE_MESSENGER:
+ val_type = contacts_svc_value_get_int(value, CTS_MESSENGER_VAL_TYPE_INT);
+ ret_str = T_(CT_GET_TEXT_IM_TYPE, val_type);
+ break;
+
+ case CTS_VALUE_WEB:
+ ret_str = T_(CT_GET_TEXT_BASIC, CTTEXT_WEBSITE);
+ break;
+
+ default:
+ ERR("unknown type(%d)", type);
+ ret_str = NULL;
+ break;
+
+ }
+ }
+ return SAFE_STRDUP(ret_str);
+}
+
+static Evas_Object *detail_gl_number_default_icon_get(void *data, Evas_Object *obj, const char *part)
+{
+ Evas_Object *ret_obj;
+
+ ret_obj = NULL;
+ if (0 == strcmp(part, "elm.icon")) {
+ Evas_Object *ico;
+
+ ico = elm_icon_add(obj);
+ c_retvm_if(NULL == ico, NULL, "elm_icon_add() return NULL");
+
+ elm_icon_file_set(ico, CTUI_IMG_CHECK, NULL);
+ evas_object_size_hint_aspect_set(ico, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+
+ ret_obj = ico;
+ }
+ return ret_obj;
+}
+
+static char *detail_gl_typed_data_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ int type;
+ int val_type;
+ char buf[CT_TEXT_MAX_LEN];
+ const char *ret_str;
+ CTSvalue *value = data;
+ c_retvm_if(NULL == value, NULL, "parameter(CTSvalue) is NULL");
+
+ type = contacts_svc_value_get_type(value);
+ c_retvm_if(CTS_ERR_ARG_NULL == type, NULL,
+ "contacts_svc_value_get_type() return CTS_ERR_ARG_NULL");
+
+ ret_str = NULL;
+ if (0 == strcmp(part, "elm.title")) {
+ int num_type_int;
+ switch (type) {
+ case CTS_VALUE_NUMBER:
+ num_type_int = contacts_svc_value_get_int(value, CTS_NUM_VAL_TYPE_INT);
+ ctui_get_number_type_str(num_type_int, buf, sizeof(buf));
+ ret_str = buf;
+ break;
+
+ case CTS_VALUE_EMAIL:
+ val_type = contacts_svc_value_get_int(value, CTS_EMAIL_VAL_TYPE_INT);
+ ret_str = T_(CT_GET_TEXT_EMAIL_TYPE, val_type);
+ break;
+
+ default:
+ ERR("unknown type(%d)", type);
+ ret_str = NULL;
+ break;
+
+ }
+ }
+ else if (0 == strcmp(part, "elm.text")) {
+ switch (type) {
+ case CTS_VALUE_NUMBER:
+ ret_str = contacts_svc_value_get_str(value, CTS_NUM_VAL_NUMBER_STR);
+ break;
+ case CTS_VALUE_EMAIL:
+ ret_str = contacts_svc_value_get_str(value, CTS_EMAIL_VAL_ADDR_STR);
+ break;
+
+ default:
+ ERR("unknown type(%d)", type);
+ ret_str = NULL;
+ break;
+ }
+ }
+
+ return SAFE_STRDUP(ret_str);
+}
+
+static void detail_msg_ug_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_detail_data *cdetail_d;
+
+ cdetail_d = evas_object_data_get(obj, "cdetail_d");
+ c_retm_if(NULL == cdetail_d, "evas_object_data_get() return NULL");
+
+ if (cdetail_d->popup)
+ ct_detail_popup_hide_cb(cdetail_d, NULL, NULL);
+ ctui_msg_ug(cdetail_d->ug, data, cdetail_d->contact_id, NULL);
+}
+
+static void detail_voice_call_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_detail_data *cdetail_d;
+
+ cdetail_d = evas_object_data_get(obj, "cdetail_d");
+ c_retm_if(NULL == cdetail_d, "evas_object_data_get() return NULL");
+
+ if (cdetail_d->popup)
+ ct_detail_popup_hide_cb(cdetail_d, NULL, NULL);
+
+ ctui_voice_call(cdetail_d->contact_id, data);
+}
+
+static void detail_number_cb(CTSvalue *value, ct_detail_data *cdetail_d)
+{
+ const char *num;
+
+ if (cdetail_d->popup) ct_detail_popup_hide_cb(cdetail_d, NULL, NULL);
+
+ num = contacts_svc_value_get_str(value, CTS_NUM_VAL_NUMBER_STR);
+ if (num && *num) {
+ Elm_Object_Item *item;
+ cdetail_d->popup = elm_ctxpopup_add(cdetail_d->win);
+ c_retm_if(NULL == cdetail_d->popup, "elm_ctxpopup_add() return NULL");
+
+ evas_object_smart_callback_add(cdetail_d->popup, "dismissed", ct_detail_popup_hide_cb, cdetail_d);
+ evas_object_data_set(cdetail_d->popup, "cdetail_d", cdetail_d);
+
+ elm_ctxpopup_item_append(cdetail_d->popup, S_(CT_SYS_BODY_CALL), NULL,
+ detail_voice_call_cb, num);
+ item = elm_ctxpopup_item_append(cdetail_d->popup, S_(CT_SYS_BODY_MESSAGE), NULL,
+ detail_msg_ug_cb, num);
+ elm_object_item_disabled_set(item, EINA_TRUE);
+
+ evas_object_move(cdetail_d->popup, cdetail_d->touch_x, cdetail_d->touch_y);
+ evas_object_show(cdetail_d->popup);
+ }
+}
+
+static void detail_favorite_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ bool set;
+ Eina_Bool checked;
+ const char* result_msg;
+ ct_detail_data *cdetail_d = data;
+ Elm_Object_Item *item_baseinfo;
+
+ c_retm_if(NULL == cdetail_d, "evas_object_data_get() return NULL");
+
+ checked = elm_check_state_get(obj);
+ set = ct_detail_set_favorite(cdetail_d->contact, cdetail_d->contact_id, checked);
+
+ if (checked && set)
+ result_msg = S_(CT_SYS_POP_ADDED);
+ else if (!checked && set)
+ result_msg = S_(CT_SYS_POP_REMOVED);
+ else
+ result_msg = S_(CT_SYS_POP_FAILED);
+
+ ctui_show_notify(cdetail_d->navi, result_msg, 2.0);
+
+ item_baseinfo = evas_object_data_get(cdetail_d->genlist, "base_info");
+ c_retm_if(NULL == item_baseinfo, "evas_object_data_get() return NULL");
+
+ elm_genlist_item_update(item_baseinfo);
+}
+
+static Evas_Object *detail_gl_base_info_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ int ret;
+ Evas_Object *ret_obj;
+ CTSvalue *base_info;
+ ct_detail_data *cdetail_d = data;
+
+ ret = contacts_svc_struct_get_value(cdetail_d->contact, CTS_CF_BASE_INFO_VALUE, &base_info);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_struct_get_value() Failed(%d)", ret);
+ ret_obj = NULL;
+
+ if (0 == strcmp(part, "elm.icon.1")) {
+ const char *value_data;
+ Evas_Object *img;
+
+ value_data = contacts_svc_value_get_str(base_info, CTS_BASE_VAL_IMG_PATH_STR);
+ if (NULL == value_data)
+ value_data = ctui_get_default_contact_img(CT_VIEW_DETAIL);
+ img = elm_image_add(obj);
+ c_retvm_if(NULL == img, NULL, "elm_image_add() return NULL");
+
+ elm_image_prescale_set(img, CT_DETAIL_IMAGE_SIZE);
+ evas_object_size_hint_aspect_set(img, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
+ elm_image_file_set(img, value_data, NULL);
+
+ ret_obj = img;
+ }
+ else if (0 == strcmp(part, "elm.icon.2")) {
+ Evas_Object *check;
+
+ check = elm_check_add(obj);
+ c_retvm_if(NULL == check, NULL, "elm_icon_add() return NULL");
+
+ evas_object_smart_callback_add(check, "changed", detail_favorite_cb, cdetail_d);
+ elm_object_style_set(check, "favorite/extended");
+
+ if (!contacts_svc_value_get_bool(base_info, CTS_BASE_VAL_FAVORITE_BOOL))
+ elm_check_state_set(check, EINA_FALSE);
+ else
+ elm_check_state_set(check, EINA_TRUE);
+
+ ret_obj = check;
+ }
+ return ret_obj;
+}
+
+
+
+static char *detail_gl_base_info_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ int ret;
+ char display[CT_TEXT_MAX_LEN];
+ const char *ret_str;
+ CTSvalue *name;
+ GSList *list = NULL;
+ ct_detail_data *cdetail_d = data;
+
+ c_retvm_if(NULL == cdetail_d, NULL, "parameter(cdetail_d) is NULL");
+
+ name = NULL;
+ ret_str = NULL;
+ if (0 == strcmp(part, "elm.text.1")) {
+ display[0] = '\0';
+
+ ret = contacts_svc_struct_get_value(cdetail_d->contact, CTS_CF_NAME_VALUE, &name);
+ if (CTS_SUCCESS == ret) {
+ ctui_get_display_name(name, display, sizeof(display));
+ ret_str = display;
+ }
+ else {
+ ret_str = NULL;
+ }
+ }
+ else if (0 == strcmp(part, "elm.text.2")) {
+ display[0] = '\0';
+ ret = contacts_svc_struct_get_value(cdetail_d->contact, CTS_CF_NAME_VALUE, &name);
+ if (CTS_SUCCESS == ret) {
+ ct_detail_get_extra_name(name, display, sizeof(display));
+
+ contacts_svc_struct_get_list(cdetail_d->contact, CTS_CF_NICKNAME_LIST, &list);
+ if (list)
+ ct_detail_get_nicknames(list->data, display, sizeof(display));
+ }
+ ret_str = display;
+ }
+ else if (0 == strcmp(part, "elm.text.3")) {
+ contacts_svc_struct_get_list(cdetail_d->contact, CTS_CF_GROUPREL_LIST, &list);
+ ct_detail_get_group_names(list, display, sizeof(display));
+ ret_str = display;
+ }
+
+ return SAFE_STRDUP(ret_str);
+}
+
+static void detail_gl_email_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ const char *email;
+ ct_detail_data *cdetail_d;
+ CTSvalue *value = data;
+ Elm_Object_Item *item = event_info;
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+
+ c_retm_if(NULL == value, "parameter(CTSstruct) is NULL");
+
+ cdetail_d = (ct_detail_data *)evas_object_data_get(obj, "cdetail_d");
+ c_retm_if(NULL == cdetail_d, "evas_object_data_get() return NULL");
+
+ email = contacts_svc_value_get_str(value, CTS_EMAIL_VAL_ADDR_STR);
+ ct_detail_email_ug(cdetail_d->ug, email, NULL);
+}
+
+static void detail_gl_messenger_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ CTSvalue *value;
+ Elm_Object_Item *item = event_info;
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+
+ value = data;
+ c_retm_if(NULL == value, "parameter(CTSstruct) is NULL");
+
+ ERR("detail_gl_messenger_sel() not implemented");
+}
+
+static char* detail_gl_ab_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ ct_detail_data *cdetail_d = data;
+ const char *ret_str;
+ char display[CT_TEXT_MAX_LEN];
+
+ ret_str = NULL;
+ if (0 == strcmp(part, "elm.text")) {
+ display[0] = '\0';
+ if (cdetail_d->base_ab_name)
+ snprintf(display, sizeof(display), "%s %s", T_(CT_GET_TEXT_BASIC, CTTEXT_SAVED_IN), cdetail_d->base_ab_name);
+ ret_str = display;
+ }
+ return SAFE_STRDUP(ret_str);
+}
+
+
+static void detail_gl_number_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ CTSvalue *value;
+ ct_detail_data *cdetail_d;
+ Elm_Object_Item *item = event_info;
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+
+ value = data;
+ c_retm_if(NULL == value, "parameter(CTSstruct) is NULL");
+
+ cdetail_d = (ct_detail_data *)evas_object_data_get(obj, "cdetail_d");
+ c_retm_if(NULL == cdetail_d, "evas_object_data_get() return NULL");
+
+ detail_number_cb(value, cdetail_d);
+}
+
+static Evas_Object *detail_gl_number_util_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ const char *label;
+ const char *number;
+ CTSvalue *value;
+ ct_detail_data *cdetail_d;
+ Evas_Object *btn;
+ Evas_Smart_Cb clicked_fn;
+
+ if (0 == strcmp(part, "elm.icon.1")) {
+ label = S_(CT_SYS_BODY_CALL);
+ clicked_fn = detail_voice_call_cb;
+ }
+ else if (0 == strcmp(part, "elm.icon.2")) {
+ label = S_(CT_SYS_BODY_MESSAGE);
+ clicked_fn = detail_msg_ug_cb;
+ }
+ else {
+ return NULL;
+ }
+
+ value = data;
+ c_retvm_if(NULL == value, NULL, "CTSvalue is NULL");
+
+ cdetail_d = evas_object_data_get(obj, "cdetail_d");
+ c_retvm_if(NULL == cdetail_d, NULL, "evas_object_data_get() return NULL");
+
+ number = contacts_svc_value_get_str(value, CTS_NUM_VAL_NUMBER_STR);
+
+ btn = ctui_create_btn(obj, label);
+ c_retvm_if(NULL == btn, NULL, "ctui_create_btn() return NULL");
+
+ if (0 == strcmp(part, "elm.icon.2"))
+ elm_object_disabled_set(btn, EINA_TRUE);
+
+ evas_object_data_set(btn, "cdetail_d", cdetail_d);
+ evas_object_smart_callback_add(btn, "clicked", clicked_fn, number);
+
+ return btn;
+}
+
+static void detail_send_name_card_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item;
+ ct_detail_data *cdetail_d = data;
+
+ c_retm_if(NULL == cdetail_d, "evas_object_data_get() return NULL");
+
+ if (cdetail_d->popup)
+ ct_detail_popup_hide_cb(cdetail_d, NULL, NULL);
+
+ cdetail_d->popup = elm_ctxpopup_add(cdetail_d->win);
+ c_retm_if(NULL == cdetail_d->popup, "elm_ctxpopup_add() return NULL");
+
+ evas_object_smart_callback_add(cdetail_d->popup, "dismissed", ct_detail_popup_hide_cb, cdetail_d);
+ item = elm_ctxpopup_item_append(cdetail_d->popup, S_(CT_SYS_BODY_MESSAGE), NULL,
+ ct_detail_send_via_msg, cdetail_d);
+ elm_object_item_disabled_set(item, EINA_TRUE);
+ item = elm_ctxpopup_item_append(cdetail_d->popup, S_(CT_SYS_BODY_EMAIL), NULL,
+ ct_detail_send_via_email, cdetail_d);
+ elm_object_item_disabled_set(item, EINA_TRUE);
+ item = elm_ctxpopup_item_append(cdetail_d->popup, S_(CT_SYS_BODY_BLUETOOTH), NULL,
+ ct_detail_send_via_bluetooth, cdetail_d);
+ elm_object_item_disabled_set(item, EINA_TRUE);
+
+ evas_object_move(cdetail_d->popup, cdetail_d->touch_x, cdetail_d->touch_y);
+ evas_object_show(cdetail_d->popup);
+}
+
+static Evas_Object *detail_gl_util_btn_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ Evas_Object *ret_obj;
+ ct_detail_data *cdetail_d = data;
+ c_retvm_if(NULL == cdetail_d, NULL, "parameter(ct_detail_data) is NULL");
+
+ ret_obj = NULL;
+ if (0 == strcmp(part, "elm.icon.2")) {
+ Evas_Object *btn;
+ btn = ctui_create_btn(obj, T_(CT_GET_TEXT_BASE_OP, CTTEXT_SEND_NAME_CARD));
+ c_retvm_if(NULL == btn, NULL, "ctui_create_btn() return NULL");
+
+ evas_object_data_set(btn, "cdetail_d", cdetail_d);
+
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, ct_detail_mouseup, cdetail_d);
+ evas_object_smart_callback_add(btn, "clicked", detail_send_name_card_cb, cdetail_d);
+
+ ret_obj = btn;
+ }
+ return ret_obj;
+}
+
+static void detail_gl_website_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ const char *website;
+ CTSvalue *value = data;
+ Elm_Object_Item *item = event_info;
+
+ c_retm_if(NULL == value, "parameter(value) is NULL");
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ website = contacts_svc_value_get_str(value, CTS_WEB_VAL_ADDR_STR);
+ if (website && *website) {
+ bundle *bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_craete() return NULL");
+
+ bundle_add(bd, "url", website);
+ aul_launch_app(BROWSER_UI_PKG, bd);
+ bundle_free(bd);
+ }
+}
+
+static void detail_group_changed (void *data)
+{
+ int ret;
+ GSList *list, *cursor;
+ Elm_Object_Item *item;
+ ct_detail_data *cdetail_d = data;
+
+ c_ret_if(cdetail_d->has_input);
+
+ list = NULL;
+ contacts_svc_struct_get_list(cdetail_d->contact, CTS_CF_GROUPREL_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ CTSvalue *group_value;
+ int grp_id;
+
+ if (contacts_svc_value_get_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL))
+ continue;
+
+ grp_id = contacts_svc_value_get_int(cursor->data, CTS_GROUPREL_VAL_ID_INT);
+
+ ret = contacts_svc_get_group(grp_id, &group_value);
+ if (CTS_ERR_DB_RECORD_NOT_FOUND == ret) { // group deleted
+ contacts_svc_value_set_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL, true);
+ }
+ else if (CTS_SUCCESS == ret) { // group renamed
+ const char *new_name = contacts_svc_value_get_str(group_value, CTS_GROUP_VAL_NAME_STR);
+ const char *old_name = contacts_svc_value_get_str(cursor->data, CTS_GROUPREL_VAL_NAME_STR);
+ if (0 != strcmp(new_name, old_name)) {
+ int position;
+ CTSvalue *group;
+ contacts_svc_value_set_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL, true);
+ position = g_slist_index(list, cursor->data);
+
+ group = contacts_svc_value_new(CTS_VALUE_GROUP_RELATION);
+ contacts_svc_value_set_int(group, CTS_GROUPREL_VAL_ID_INT, grp_id);
+ contacts_svc_value_set_str(group, CTS_GROUPREL_VAL_NAME_STR, new_name);
+ list = g_slist_insert(list, group, position+1);
+ }
+ contacts_svc_value_free(group_value);
+ }
+ }
+ contacts_svc_struct_store_list(cdetail_d->contact, CTS_CF_GROUPREL_LIST, list);
+ item = evas_object_data_get(cdetail_d->genlist, "base_info");
+ elm_genlist_item_update(item);
+}
+
+static void detail_view_delete_cb(void *data, Evas *e, Evas_Object *obj,
+ void *event_info)
+{
+ int ret;
+ ct_detail_data *cdetail_d = data;
+
+ if (cdetail_d->popup)
+ evas_object_del(cdetail_d->popup);
+
+ ct_detail_delete_namecards(cdetail_d);
+
+ contacts_svc_struct_free(cdetail_d->contact);
+ cdetail_d->contact = NULL;
+
+ ret = contacts_svc_unsubscribe_change_with_data(CTS_SUBSCRIBE_CONTACT_CHANGE,
+ ct_detail_contacts_changed, cdetail_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_unsubscribe_change_with_data() Failed(%d)", ret);
+ ret = contacts_svc_unsubscribe_change_with_data(CTS_SUBSCRIBE_GROUP_CHANGE,
+ detail_group_changed, cdetail_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_unsubscribe_change_with_data() Failed(%d)", ret);
+
+ free(cdetail_d->vcard);
+ cdetail_d->vcard = NULL;
+ free(cdetail_d->base_ab_name);
+ cdetail_d->base_ab_name = NULL;
+
+ evas_object_data_del(cdetail_d->navi, "cdetail_d");
+
+ if (cdetail_d->has_input)
+ cdetail_d->has_detail = false;
+ else
+ free(cdetail_d);
+}
+
+static inline void detail_create_itcs()
+{
+ detail_itcs[DETAIL_ITC_TYPED_DATA].func.text_get = detail_gl_typed_data_label_get;
+
+ detail_itcs[DETAIL_ITC_NUMBER_DEF].func.text_get = detail_gl_typed_data_label_get;
+ detail_itcs[DETAIL_ITC_NUMBER_DEF].func.content_get = detail_gl_number_default_icon_get;
+
+ detail_itcs[DETAIL_ITC_TITLE_BIG_TEXT].func.text_get = detail_gl_title_big_text_label_get;
+
+ detail_itcs[DETAIL_ITC_ADDRESS].func.text_get = detail_gl_address_label_get;
+
+ detail_itcs[DETAIL_ITC_2TEXT_MULTILINE].func.text_get = detail_gl_2text_multiline_label_get;
+
+ detail_itcs[DETAIL_ITC_BASEINFO].func.text_get = detail_gl_base_info_label_get;
+ detail_itcs[DETAIL_ITC_BASEINFO].func.content_get = detail_gl_base_info_icon_get;
+
+ detail_itcs[DETAIL_ITC_NUM_UTIL_BTN].func.content_get = detail_gl_number_util_icon_get;
+
+ detail_itcs[DETAIL_ITC_UTIL_BTN].func.content_get = detail_gl_util_btn_icon_get;
+
+ detail_itcs[DETAIL_ITC_ADDRBOOK].func.text_get = detail_gl_ab_label_get;
+}
+
+static CTSvalue* detail_default_number(GSList *list)
+{
+ GSList *cursor;
+ CTSvalue* ret_val;
+
+ c_retvm_if(NULL == list, NULL, "parameter(GSList) is NULL");
+
+ ret_val = list->data;
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (contacts_svc_value_get_bool(cursor->data, CTS_NUM_VAL_DEFAULT_BOOL))
+ ret_val = cursor->data;
+ }
+
+ return ret_val;
+}
+
+static void detail_fill_list(Evas_Object *genlist, Elm_Genlist_Item_Class *itc, GSList *list, Evas_Smart_Cb func)
+{
+ GSList *cursor;
+ Elm_Object_Item *item;
+
+ if (list)
+ ctui_list_detail_genlist_append_separator_line_20px(genlist);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ item = elm_genlist_item_append(genlist, itc, cursor->data, NULL,
+ ELM_GENLIST_ITEM_NONE, func, cursor->data);
+ if (NULL == func)
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+}
+
+static void detail_fill_number_list(Evas_Object *genlist, GSList *list)
+{
+ GSList *cursor;
+
+ if (g_slist_length(list) < 2)
+ return;
+
+ ctui_list_detail_genlist_append_separator_line_20px(genlist);
+ for (cursor=list;cursor;cursor=cursor->next) {
+ bool def = contacts_svc_value_get_bool(cursor->data, CTS_NUM_VAL_DEFAULT_BOOL);
+ if (def) continue;
+
+ elm_genlist_item_append(genlist, &detail_itcs[DETAIL_ITC_NUMBER], cursor->data, NULL,
+ ELM_GENLIST_ITEM_NONE, detail_gl_number_sel, cursor->data);
+ }
+}
+
+API Evas_Object* ctui_detail_genlist_update(ct_detail_data *cdetail_d)
+{
+ CT_FN_CALL;
+ int ret;
+ GSList *list;
+ Evas_Object *genlist;
+ const char *value_data;
+ CTSvalue *baseinfo = NULL;
+ CTSvalue *company;
+ CTSvalue *value;
+ CTSstruct *contact = cdetail_d->contact;
+ Elm_Object_Item *item;
+
+ // Create genlist
+ if (NULL == cdetail_d->genlist) {
+ genlist = elm_genlist_add(cdetail_d->navi);
+ cdetail_d->genlist = genlist;
+ evas_object_event_callback_add(genlist, EVAS_CALLBACK_MOUSE_UP, ct_detail_mouseup, cdetail_d);
+ evas_object_data_set(genlist, "cdetail_d", cdetail_d);
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+ }
+ else {
+ genlist = cdetail_d->genlist;
+ elm_genlist_clear(genlist);
+ }
+
+ // base info
+ item = elm_genlist_item_append(genlist, &detail_itcs[DETAIL_ITC_BASEINFO], cdetail_d, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ evas_object_data_set(genlist, "base_info", item);
+
+ contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &baseinfo);
+
+ // number list
+ list = NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_NUMBER_LIST, &list);
+ value = detail_default_number(list);
+ if (value) {
+ ct_detail_genlist_append_separator_line_10px(genlist);
+ elm_genlist_item_append(genlist, &detail_itcs[DETAIL_ITC_NUMBER_DEF], value, NULL,
+ ELM_GENLIST_ITEM_NONE, detail_gl_number_sel, value);
+ ctui_genlist_append_separator_10px(genlist);
+ elm_genlist_item_append(genlist, &detail_itcs[DETAIL_ITC_NUM_UTIL_BTN], value, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ }
+ detail_fill_number_list(genlist, list);
+
+ // email list
+ list=NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_EMAIL_LIST, &list);
+ detail_fill_list(genlist, &detail_itcs[DETAIL_ITC_EMAIL], list, detail_gl_email_sel);
+
+ // messenger list
+ list=NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_MESSENGER_LIST, &list);
+ detail_fill_list(genlist, &detail_itcs[DETAIL_ITC_MESSENGER], list, detail_gl_messenger_sel);
+
+ // POSTAL list
+ list=NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_POSTAL_ADDR_LIST, &list);
+ detail_fill_list(genlist, &detail_itcs[DETAIL_ITC_ADDRESS], list, NULL);
+
+ // Addressbook
+ if (baseinfo && -1 != cdetail_d->base_ab) {
+ Elm_Object_Item *item;
+ ret = contacts_svc_value_get_int(baseinfo, CTS_BASE_VAL_ADDRESSBOOK_ID_INT);
+ item = elm_genlist_item_append(genlist, &detail_itcs[DETAIL_ITC_ADDRBOOK], cdetail_d, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ }
+
+ // Company
+ ret = contacts_svc_struct_get_value(contact, CTS_CF_COMPANY_VALUE, &company);
+ if (CTS_SUCCESS == ret) {
+ value_data = contacts_svc_value_get_str(company, CTS_COMPANY_VAL_NAME_STR);
+ if (value_data && *value_data) {
+ Elm_Object_Item *item;
+ item = elm_genlist_item_append(genlist, &detail_itcs[DETAIL_ITC_COMPANY], company, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+ }
+
+ // event list
+ list=NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_EVENT_LIST, &list);
+ detail_fill_list(genlist, &detail_itcs[DETAIL_ITC_BIRTH], list, NULL);
+
+ // website
+ list=NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_WEB_ADDR_LIST, &list);
+ detail_fill_list(genlist, &detail_itcs[DETAIL_ITC_WEBSITE], list, detail_gl_website_sel);
+
+ // note
+ if (baseinfo) {
+ value_data = contacts_svc_value_get_str(baseinfo, CTS_BASE_VAL_NOTE_STR);
+ if (value_data && *value_data) {
+ Elm_Object_Item *item;
+ item = elm_genlist_item_append(genlist, &detail_itcs[DETAIL_ITC_NOTE], baseinfo, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+ }
+
+ if (cdetail_d->contact_id) {
+ // util button (set as favorite, send name card)
+ ctui_genlist_append_separator_20px(genlist);
+ elm_genlist_item_append(genlist, &detail_itcs[DETAIL_ITC_UTIL_BTN], cdetail_d, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ }
+ return genlist;
+}
+
+
+Evas_Object* ct_detail_create_content(ct_detail_data *cdetail_d)
+{
+ Evas_Object *genlist;
+ cdetail_d->vcard = SAFE_STRDUP(cdetail_d->vcard);
+
+ if (cdetail_d->contact_id) {
+ int ret;
+ CTSvalue *value;
+
+ contacts_svc_begin_trans();
+ cdetail_d->view_creat_ver = contacts_svc_end_trans(true);
+
+ ret = contacts_svc_get_contact(cdetail_d->contact_id, &(cdetail_d->contact));
+ c_retvm_if(ret<CTS_SUCCESS, NULL, "contacts_svc_get_contact() Failed(%d)", ret);
+
+ ret = contacts_svc_struct_get_value(cdetail_d->contact, CTS_CF_BASE_INFO_VALUE, &value);
+ free(cdetail_d->base_ab_name);
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_struct_get_value() Failed(%d)", ret);
+ cdetail_d->base_ab = -1;
+ cdetail_d->base_ab_mode = CTS_ADDRESSBOOK_MODE_READONLY;
+ cdetail_d->base_ab_name = NULL;
+ }
+ else {
+ CTSvalue *ab_value;
+ int type;
+ char temp[CT_TEXT_SHORT_LEN];
+
+ cdetail_d->base_ab = contacts_svc_value_get_int(value, CTS_BASE_VAL_ADDRESSBOOK_ID_INT);
+ if (cdetail_d->base_ab) {
+ ret = contacts_svc_get_addressbook(cdetail_d->base_ab, &ab_value);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_get_addressbook() Failed(%d)", ret);
+ cdetail_d->base_ab_mode = contacts_svc_value_get_int(ab_value, CTS_ADDRESSBOOK_VAL_MODE_INT);
+ type = contacts_svc_value_get_int(ab_value, CTS_ADDRESSBOOK_VAL_ACC_TYPE_INT);
+ snprintf(temp, sizeof(temp), "%s (%s)",
+ contacts_svc_value_get_str(ab_value, CTS_ADDRESSBOOK_VAL_NAME_STR), T_(CT_GET_TEXT_ACC_TYPE, type));
+
+ cdetail_d->base_ab_name = strdup(temp);
+ ret = contacts_svc_value_free(ab_value);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_free() Failed(%d)", ret);
+ }
+ else {
+ cdetail_d->base_ab_mode = CTS_ADDRESSBOOK_MODE_NONE;
+ cdetail_d->base_ab_name = strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE));
+ }
+ }
+
+ ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE,
+ ct_detail_contacts_changed, cdetail_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_subscribe_change() Failed(%d)", ret);
+ ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE,
+ detail_group_changed, cdetail_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_subscribe_change() Failed(%d)", ret);
+ }
+
+ detail_create_itcs();
+ genlist = ctui_detail_genlist_update(cdetail_d);
+
+ evas_object_data_set(cdetail_d->navi, "cdetail_d", cdetail_d);
+ evas_object_event_callback_add(genlist, EVAS_CALLBACK_DEL, detail_view_delete_cb, cdetail_d);
+ cdetail_d->has_detail = true;
+
+ return genlist;
+}
+
diff --git a/lib/details/ct-detail-view.h b/lib/details/ct-detail-view.h
new file mode 100755
index 0000000..9ddad34
--- /dev/null
+++ b/lib/details/ct-detail-view.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_DETAIL_VIEW_H__
+#define __CONTACTS_DETAIL_VIEW_H__
+
+Evas_Object* ct_detail_create_content(ct_detail_data *cdetail_d);
+
+#endif //__CONTACTS_DETAIL_VIEW_H__
+
diff --git a/lib/details/ct-group-assign-view.c b/lib/details/ct-group-assign-view.c
new file mode 100755
index 0000000..fc7e14d
--- /dev/null
+++ b/lib/details/ct-group-assign-view.c
@@ -0,0 +1,335 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include "contacts.h"
+#include "ct-list.h"
+#include "ct-input-utils.h"
+#include "ct-detail-utils.h"
+#include "ct-group-assign-view.h"
+
+static Elm_Genlist_Item_Class grp_itc;
+
+typedef struct {
+ int grp_id;
+ char *name;
+ bool selected;
+}ct_assign_list;
+
+static void grp_assign_gl_del(void *data, Evas_Object *obj)
+{
+ ct_assign_list *info = data;
+ c_retm_if(NULL == data, "data is NULL");
+
+ free(info->name);
+ free(info);
+}
+
+static char* grp_assign_gl_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ ct_assign_list *info = data;
+ c_retvm_if(NULL == data, NULL, "The parameter(data) is NULL");
+
+ if (!strcmp(part, "elm.text") && info->name)
+ return strdup(info->name);
+ return NULL;
+}
+
+static void grp_assign_check_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_assign_list *info = data;
+ c_retm_if(NULL == data, "The parameter(data) is NULL");
+
+ if (EINA_TRUE == elm_check_state_get(obj))
+ info->selected = true;
+ else
+ info->selected = false;
+}
+
+static Evas_Object* grp_assign_gl_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ ct_assign_list *gl = data;
+ c_retvm_if(NULL == data, NULL, "The parameter(data) is NULL");
+
+ if (!strcmp(part, "elm.icon")) {
+ Evas_Object *btn = elm_check_add(obj);
+ elm_check_state_set(btn, gl->selected);
+ evas_object_propagate_events_set(btn, EINA_FALSE);
+ evas_object_smart_callback_add(btn, "changed", grp_assign_check_btn_cb, data);
+ return btn;
+ }
+ return NULL;
+}
+
+static void grp_assign_done_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ bool completed = true;
+ Elm_Object_Item *item;
+ GSList *list, *cursor, *newlist;
+ char display[CT_TEXT_MAX_LEN];
+ ct_assign_group_data *cgassign_d = data;
+
+ if (NULL == cgassign_d->genlist) {
+ elm_naviframe_item_pop(cgassign_d->cinput_d->cdetail_d->navi);
+ return;
+ }
+
+ display[0]= '\0';
+ list = NULL;
+ contacts_svc_struct_get_list(cgassign_d->cinput_d->contact, CTS_CF_GROUPREL_LIST, &list);
+
+ item = elm_genlist_first_item_get(cgassign_d->genlist);
+ newlist = NULL;
+ while (item) {
+ int id = -1;
+ bool exist = false;
+ CTSvalue *group = NULL;
+
+ ct_assign_list *info = elm_object_item_data_get(item);
+ item = elm_genlist_item_next_get(item);
+ if (NULL == info) {
+ ERR("info is NULL");
+ continue;
+ }
+
+ for (cursor = list;cursor;cursor=cursor->next) {
+ id = contacts_svc_value_get_int(cursor->data, CTS_GROUPREL_VAL_ID_INT);
+ if (info->grp_id == id) {
+ exist = true;
+ contacts_svc_value_set_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL, !info->selected);
+ }
+ }
+
+ if (!exist && info->selected) {
+ group = contacts_svc_value_new(CTS_VALUE_GROUP_RELATION);
+ if (NULL == group) {
+ completed = false;
+ break;
+ }
+ contacts_svc_value_set_int(group, CTS_GROUPREL_VAL_ID_INT, info->grp_id);
+ newlist = g_slist_append(newlist, group);
+ }
+ }
+
+ if (completed) {
+ contacts_svc_struct_store_list(cgassign_d->cinput_d->contact, CTS_CF_GROUPREL_LIST, newlist);
+ if (cgassign_d->cinput_d->ly_group)
+ ct_input_update_group(cgassign_d->cinput_d->contact, cgassign_d->cinput_d->ly_group);
+ }
+ else {
+ cgassign_d->cinput_d->cdetail_d->popup = ctui_create_popup(cgassign_d->cinput_d->cdetail_d->navi, S_(CT_SYS_POP_FAILED), 1.5);
+ evas_object_smart_callback_add(cgassign_d->cinput_d->cdetail_d->popup, "timeout",
+ ct_detail_popup_hide_cb, cgassign_d->cinput_d->cdetail_d);
+ }
+
+ g_slist_free(newlist);
+ elm_naviframe_item_pop(cgassign_d->cinput_d->cdetail_d->navi);
+}
+
+static inline void grp_assign_back_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item;
+ GSList *list, *cursor;
+ ct_assign_group_data *cgassign_d = data;
+
+
+ if (NULL == cgassign_d->genlist) {
+ list = NULL;
+ contacts_svc_struct_get_list(cgassign_d->cinput_d->contact, CTS_CF_GROUPREL_LIST, &list);
+ for (cursor = list;cursor;cursor=cursor->next)
+ contacts_svc_value_set_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL, true);
+
+ if (cgassign_d->cinput_d->ly_group)
+ ct_input_update_group(cgassign_d->cinput_d->contact, cgassign_d->cinput_d->ly_group);
+ elm_naviframe_item_pop(cgassign_d->cinput_d->cdetail_d->navi);
+ return;
+ }
+
+ list = NULL;
+ contacts_svc_struct_get_list(cgassign_d->cinput_d->contact, CTS_CF_GROUPREL_LIST, &list);
+ for (cursor = list;cursor;cursor=cursor->next) {
+ bool exist = false;
+ item = elm_genlist_first_item_get(cgassign_d->genlist);
+ while (item) {
+ ct_assign_list *info = elm_object_item_data_get(item);
+ item = elm_genlist_item_next_get(item);
+ if (NULL == info) {
+ ERR("info is NULL");
+ continue;
+ }
+
+ int id = contacts_svc_value_get_int(cursor->data, CTS_GROUPREL_VAL_ID_INT) ;
+ if (info->grp_id == id) {
+ exist = true;
+ break;
+ }
+ }
+ if (!exist)
+ contacts_svc_value_set_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL, true);
+ }
+ contacts_svc_struct_store_list(cgassign_d->cinput_d->contact, CTS_CF_GROUPREL_LIST, list);
+
+
+ if (cgassign_d->cinput_d->ly_group)
+ ct_input_update_group(cgassign_d->cinput_d->contact, cgassign_d->cinput_d->ly_group);
+ elm_naviframe_item_pop(cgassign_d->cinput_d->cdetail_d->navi);
+}
+
+static void grp_assign_gl_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_assign_list *info = data;
+ Elm_Object_Item *item = event_info;
+ c_retm_if(NULL == data, "data is NULL");
+
+ info->selected = !info->selected;
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ elm_genlist_item_update(item);
+}
+
+static void grp_assign_fill_genlist(ct_assign_group_data *cgassign_d, CTSiter *iter)
+{
+ GSList *list;
+ ct_assign_list *gl;
+ Elm_Object_Item *item;
+
+ grp_itc.item_style = "1text.1icon.2";
+ grp_itc.func.text_get = grp_assign_gl_label_get;
+ grp_itc.func.content_get = grp_assign_gl_icon_get;
+ grp_itc.func.state_get = NULL;
+ grp_itc.func.del = grp_assign_gl_del;
+
+ list = NULL;
+ contacts_svc_struct_get_list(cgassign_d->cinput_d->contact, CTS_CF_GROUPREL_LIST, &list);
+
+ do {
+ GSList *cursor;
+ CTSvalue *info = contacts_svc_iter_get_info(iter);
+ gl = calloc(1, sizeof(ct_assign_list));
+ gl->grp_id = contacts_svc_value_get_int(info, CTS_GROUPREL_VAL_ID_INT);
+ gl->name = contacts_svc_value_steal_str(info, CTS_GROUPREL_VAL_NAME_STR);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (gl->grp_id == contacts_svc_value_get_int(cursor->data, CTS_GROUPREL_VAL_ID_INT)
+ && !contacts_svc_value_get_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL)) {
+ gl->selected = true;
+ break;
+ }
+ }
+ item = elm_genlist_item_append(cgassign_d->genlist, &grp_itc, gl, NULL,
+ ELM_GENLIST_ITEM_NONE, grp_assign_gl_sel, gl);
+ contacts_svc_value_free(info);
+ }while(CTS_SUCCESS == contacts_svc_iter_next(iter));
+}
+
+static void grp_assign_fill_layout(void *data)
+{
+ int ret;
+ CTSiter *iter;
+ ct_assign_group_data *cgassign_d = data;
+
+ ret = contacts_svc_get_list_with_int(CTS_LIST_GROUPS_OF_ADDRESSBOOK_ID,
+ cgassign_d->cinput_d->cdetail_d->base_ab, &iter);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_get_list_with_int() is Failed(%d)", ret);
+
+ if (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ if (NULL == cgassign_d->genlist) {
+ cgassign_d->genlist = elm_genlist_add(cgassign_d->navi_content);
+ grp_assign_fill_genlist(cgassign_d, iter);
+ elm_object_part_content_set(cgassign_d->navi_content, "elm.swallow.content", cgassign_d->genlist);
+ }
+ else {
+ elm_genlist_clear(cgassign_d->genlist);
+ grp_assign_fill_genlist(cgassign_d, iter);
+ }
+ }
+ else {
+ Evas_Object *noc;
+ noc = ctui_create_nocontents(cgassign_d->navi_content, T_(CT_GET_TEXT_ERR, CTTEXT_NO_GROUP));
+ elm_object_part_content_set(cgassign_d->navi_content, "elm.swallow.content", noc);
+ cgassign_d->genlist = NULL;
+ }
+ contacts_svc_iter_remove(iter);
+}
+
+static void grp_assign_view_delete_cb(void *data, Evas *e, Evas_Object *obj,
+ void *event_info)
+{
+ int ret;
+ ct_assign_group_data *cgassign_d = data;
+ ret = contacts_svc_unsubscribe_change_with_data(CTS_SUBSCRIBE_GROUP_CHANGE,
+ grp_assign_fill_layout, cgassign_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_unsubscribe_change_with_data() Failed(%d)", ret);
+
+ free(cgassign_d);
+}
+
+static void grp_assign_create_layout(ct_assign_group_data *cgassign_d)
+{
+ Evas_Object *l_btn;
+ Evas_Object *layout;
+ Evas_Object *cbar;
+ Elm_Object_Item *navi_item;
+
+ layout = ctui_create_base_layout(cgassign_d->cinput_d->cdetail_d->navi, false);
+ cgassign_d->navi_content = layout;
+
+ grp_assign_fill_layout(cgassign_d);
+
+ l_btn = ctui_naviframe_btn(cgassign_d->cinput_d->cdetail_d->navi, S_(CT_SYS_SK_CANCEL));
+ evas_object_smart_callback_add(l_btn, "clicked", grp_assign_back_cb, cgassign_d);
+
+ navi_item = elm_naviframe_item_push(cgassign_d->cinput_d->cdetail_d->navi,
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_SELECT_GROUP), l_btn, NULL, layout, NULL);
+
+ cbar = elm_toolbar_add(cgassign_d->cinput_d->cdetail_d->navi);
+ c_retm_if(NULL == cbar, "elm_toolbar_add() return NULL");
+ elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
+
+ elm_toolbar_item_append(cbar, CTUI_IMG_ICON_DONE, NULL,
+ grp_assign_done_cb, cgassign_d);
+
+ ct_toolbar_disalbed_item_append(cbar, 3);
+
+ elm_object_item_part_content_set(navi_item , "controlbar", cbar);
+
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL,
+ grp_assign_view_delete_cb, cgassign_d);
+}
+
+void ct_grp_assign_create_view(ct_input_data *cinput_d)
+{
+ int ret;
+ ct_assign_group_data *cgassign_d;
+
+ cgassign_d = calloc(1, sizeof(ct_assign_group_data));
+ cgassign_d->cinput_d = cinput_d;
+ grp_assign_create_layout(cgassign_d);
+
+ ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE,
+ grp_assign_fill_layout, cgassign_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_subscribe_change() Failed(%d)", ret);
+}
+
diff --git a/lib/details/ct-group-assign-view.h b/lib/details/ct-group-assign-view.h
new file mode 100755
index 0000000..bec1fae
--- /dev/null
+++ b/lib/details/ct-group-assign-view.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_ASSIGN_GROUP_VIEW_H__
+#define __CONTACTS_ASSIGN_GROUP_VIEW_H__
+
+//void ct_assign_grp_create_view_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
+void ct_grp_assign_create_view(ct_input_data *cinput_d);
+
+#endif //__CONTACTS_ASSIGN_GROUP_VIEW_H__
diff --git a/lib/details/ct-input-num-email.c b/lib/details/ct-input-num-email.c
new file mode 100755
index 0000000..718201e
--- /dev/null
+++ b/lib/details/ct-input-num-email.c
@@ -0,0 +1,891 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include "contacts.h"
+#include "ct-detail.h"
+#include "ct-detail-utils.h"
+#include "ct-input-utils.h"
+#include "ct-input-view.h"
+#include "ct-input-num-email.h"
+
+static Evas_Object* input_fill_layout_number(ct_input_data *cinput_d, CTSvalue *value);
+static Evas_Object* input_fill_layout_email(ct_input_data *cinput_d, CTSvalue *value);
+
+static inline CTSvalue *input_new_number(CTSstruct *contact)
+{
+ int ret;
+ int type;
+ GSList *list;
+ CTSvalue *value;
+
+ value = contacts_svc_value_new(CTS_VALUE_NUMBER);
+ c_retvm_if(NULL == value, NULL, "contacts_svc_value_new() return NULL");
+
+ type = ct_input_get_number_type(ct_input_next_number_type(contact));
+ contacts_svc_value_set_int(value, CTS_NUM_VAL_TYPE_INT, type);
+
+ list = NULL;
+ list = g_slist_append(list, value);
+ ret = contacts_svc_struct_store_list(contact, CTS_CF_NUMBER_LIST, list);
+ g_slist_free(list);
+ c_retvm_if(ret < CTS_SUCCESS, NULL, "contacts_svc_struct_store_list() failed(%d)", ret);
+
+ ret = contacts_svc_value_set_bool(value, CTS_NUM_VAL_DELETE_BOOL, true);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ return value;
+}
+
+static inline CTSvalue* input_new_email(CTSstruct *contact)
+{
+ int ret;
+ int type;
+ GSList *list;
+ CTSvalue *value;
+
+ value = contacts_svc_value_new(CTS_VALUE_EMAIL);
+ c_retvm_if(NULL == value, NULL, "contacts_svc_value_new() return NULL");
+
+ type = ct_input_next_email_type(contact);
+ contacts_svc_value_set_int(value, CTS_EMAIL_VAL_TYPE_INT, type);
+
+ list = NULL;
+ list = g_slist_append(list, value);
+ ret = contacts_svc_struct_store_list(contact, CTS_CF_EMAIL_LIST, list);
+ g_slist_free(list);
+ c_retvm_if(ret < CTS_SUCCESS, NULL, "contacts_svc_struct_store_list() failed(%d)", ret);
+
+ ret = contacts_svc_value_set_bool(value, CTS_EMAIL_VAL_DELETE_BOOL, true);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ return value;
+
+}
+
+static void input_email_del(ct_input_data *cinput_d, ct_input_typed_data *typed_data)
+{
+ int ret;
+ int idx;
+ Eina_List *list;
+
+ c_retm_if(NULL == cinput_d, "parameter(cinput_d) is NULL");
+ c_retm_if(NULL == typed_data, "parameter(typed_data) is NULL");
+
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_EMAIL_VAL_DELETE_BOOL, true);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ if (typed_data->ly_main == cinput_d->ly_email_first) {
+ idx = ct_input_box_idx_get(cinput_d->box, typed_data->ly_main);
+ list = elm_box_children_get(cinput_d->box);
+ cinput_d->ly_email_first = eina_list_nth(list, idx + 1);
+ }
+
+ elm_box_unpack(cinput_d->box, typed_data->ly_main);
+ evas_object_del(typed_data->ly_main);
+
+}
+
+static void input_email_del_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_input_typed_data *typed_data;
+
+ typed_data = evas_object_data_get(obj, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ input_email_del(data, typed_data);
+}
+
+static void input_number_default_reset(ct_input_data *cinput_d)
+{
+ int cnt = 0;
+ int idx;
+ int ret;
+ Evas_Object *ly;
+ Eina_List *list;
+ ct_input_typed_data *typed_data;
+
+ idx = ct_input_box_idx_get(cinput_d->box, cinput_d->ly_number_first);
+ list = elm_box_children_get(cinput_d->box);
+ ly = cinput_d->ly_number_first;
+
+ cinput_d->ly_number_default = NULL;
+
+ while (ly != cinput_d->ly_number_last) {
+ typed_data = evas_object_data_get(ly, "typed_data");
+
+ if (NULL == typed_data) {
+ ERR("elm_object_item_data_get return NULL");
+ ly = eina_list_nth(list, ++cnt);
+ continue;
+ }
+
+ if (!contacts_svc_value_get_bool(typed_data->value, CTS_NUM_VAL_DELETE_BOOL)) {
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_NUM_VAL_DEFAULT_BOOL, true);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() Failed(%d)", ret);
+
+ cinput_d->ly_number_default = typed_data->ly_main;
+ edje_object_signal_emit(_EDJ(typed_data->ly_content), "elm,state,contact,default_number,enabled", "elm");
+ return;
+ }
+ ly = eina_list_nth(list, ++cnt);
+ }
+}
+
+static void input_set_default_num_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_input_data *cinput_d;
+ ct_input_typed_data *typed_data = data;
+
+ cinput_d = evas_object_data_get(obj, "cinput_d");
+ c_retm_if(NULL == cinput_d, "evas_object_data_get() return NULL");
+
+ evas_object_del(obj);
+ cinput_d->cdetail_d->popup = NULL;
+
+ if (cinput_d->ly_number_default) {
+ ct_input_typed_data *typed_data_temp;
+ typed_data_temp = evas_object_data_get(cinput_d->ly_number_default, "typed_data");
+ c_retm_if(NULL == typed_data_temp, "evas_object_data_get() return NULL");
+
+ ret = contacts_svc_value_set_bool(typed_data_temp->value, CTS_NUM_VAL_DEFAULT_BOOL, false);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ edje_object_signal_emit(_EDJ(typed_data_temp->ly_content), "elm,state,contact,default_number,disabled", "elm");
+ }
+
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_NUM_VAL_DEFAULT_BOOL, true);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ cinput_d->ly_number_default = typed_data->ly_main;
+ edje_object_signal_emit(_EDJ(typed_data->ly_content), "elm,state,contact,default_number,enabled", "elm");
+}
+
+
+
+static void input_set_default_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ unsigned int idx;
+ int num_type;
+ const char *num;
+ char buf[CT_TEXT_SHORT_LEN];
+ char number_type[CT_TEXT_SHORT_LEN/2];
+ Eina_List *list, *cursor;
+ Evas_Object *ly_main;
+ Evas_Object *popup;
+ ct_input_data *cinput_d = data;
+ ct_input_typed_data *typed_data;
+
+ c_retm_if(NULL == cinput_d, "parameter(cinput_d) is NULL");
+
+ popup = elm_ctxpopup_add(cinput_d->cdetail_d->win);
+ c_retm_if(NULL == popup, "elm_ctxpopup_add() return NULL");
+
+ evas_object_smart_callback_add(popup, "dismissed", ct_detail_popup_hide_cb, cinput_d->cdetail_d);
+ evas_object_data_set(popup, "cinput_d", cinput_d);
+
+ idx = ct_input_box_idx_get(cinput_d->box, cinput_d->ly_number_first);
+ list = eina_list_nth_list(elm_box_children_get(cinput_d->box), idx);
+
+ EINA_LIST_FOREACH(list, cursor, ly_main) {
+ if (NULL == ly_main) continue;
+
+ if (ly_main == cinput_d->ly_number_last)
+ break;
+
+ typed_data = evas_object_data_get(ly_main, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ if (contacts_svc_value_get_bool(typed_data->value, CTS_NUM_VAL_DELETE_BOOL))
+ continue;
+
+ if (contacts_svc_value_get_bool(typed_data->value, CTS_NUM_VAL_DEFAULT_BOOL))
+ continue;
+
+ num_type = contacts_svc_value_get_int(typed_data->value, CTS_NUM_VAL_TYPE_INT);
+ num = contacts_svc_value_get_str(typed_data->value, CTS_NUM_VAL_NUMBER_STR);
+
+ ctui_get_number_type_str(num_type, number_type, sizeof(number_type));
+ snprintf(buf, sizeof(buf), "%s %s", number_type, num);
+ elm_ctxpopup_item_append(popup, buf, NULL, input_set_default_num_cb, typed_data);
+ }
+
+ if (cinput_d->cdetail_d->popup)
+ ct_detail_popup_hide_cb(cinput_d->cdetail_d, NULL, NULL);
+
+ cinput_d->cdetail_d->popup = popup;
+ evas_object_move(popup, cinput_d->cdetail_d->touch_x, cinput_d->cdetail_d->touch_y);
+ evas_object_show(popup);
+}
+
+
+static Evas_Object* input_fill_layout_set_default(ct_input_data *cinput_d)
+{
+ Evas_Object *btn;
+ Evas_Object *ly_content, *ly_main;
+ Evas_Object *box = cinput_d->box;
+
+ ly_content = ct_input_create_dg_layout(box, "bg/1icon");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+
+ ly_main = ct_input_create_dg_layout(box, "edit/contact.3");
+ c_retvm_if(NULL == ly_main, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_main, "elm,state,decorate,enabled", "elm");
+ elm_object_part_content_set(ly_main, "elm.swallow.decorate.content", ly_content);
+
+ btn = ctui_create_btn(ly_content, T_(CT_GET_TEXT_BASE_OP, CTTEXT_SET_DEFAULT_NUM));
+ c_retvm_if(NULL == btn, NULL, "ctui_create_btn() return NULL");
+
+ evas_object_smart_callback_add(btn, "clicked", input_set_default_cb, cinput_d);
+ c_retvm_if(NULL == btn, NULL, "elm_button_add() return NULL");
+ elm_object_part_content_set(ly_content, "elm.icon", btn);
+
+ return ly_main;
+}
+
+static void input_number_set_default_button_reset(ct_input_data *cinput_d)
+{
+ c_retm_if(NULL == cinput_d, "parameter(cinput_d) is NULL");
+
+ if (cinput_d->cnt_num < 2 && cinput_d->ly_number_set_default) {
+ elm_box_unpack(cinput_d->box, cinput_d->ly_number_set_default_separator);
+ evas_object_del(cinput_d->ly_number_set_default_separator);
+
+ elm_box_unpack(cinput_d->box, cinput_d->ly_number_set_default);
+ evas_object_del(cinput_d->ly_number_set_default);
+ cinput_d->ly_number_set_default = NULL;
+ }
+ else if (NULL == cinput_d->ly_number_set_default && 1 < cinput_d->cnt_num) {
+ /* 'Mark as default number' button */
+ cinput_d->ly_number_set_default_separator = ct_input_fill_layout_separator(cinput_d, "separator/hd16");
+ c_retm_if(NULL == cinput_d->ly_number_set_default_separator, "ct_input_fill_layout_separator() return NULL");
+ elm_box_pack_after(cinput_d->box, cinput_d->ly_number_set_default_separator, cinput_d->ly_number_last);
+
+ cinput_d->ly_number_set_default = input_fill_layout_set_default(cinput_d);
+ c_retm_if(NULL == cinput_d->ly_number_set_default, "input_fill_layout_set_default() return NULL");
+ elm_box_pack_after(cinput_d->box, cinput_d->ly_number_set_default, cinput_d->ly_number_set_default_separator);
+ }
+}
+
+
+static void input_number_del(ct_input_data *cinput_d, ct_input_typed_data *typed_data)
+{
+ int ret;
+ int idx;
+ Eina_List *list;
+ c_retm_if(NULL == cinput_d, "parameter(cinput_d) is NULL");
+ c_retm_if(NULL == typed_data, "parameter(typed_data) is NULL");
+
+ if (!contacts_svc_value_get_bool(typed_data->value, CTS_NUM_VAL_DELETE_BOOL)) {
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_NUM_VAL_DELETE_BOOL, true);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ cinput_d->cnt_num--;
+ input_number_set_default_button_reset(cinput_d);
+ }
+
+ if (typed_data->ly_main == cinput_d->ly_number_first) {
+ idx = ct_input_box_idx_get(cinput_d->box, typed_data->ly_main);
+ list = elm_box_children_get(cinput_d->box);
+ cinput_d->ly_number_first = eina_list_nth(list, idx + 1);
+ }
+
+ if (typed_data->ly_main == cinput_d->ly_number_default)
+ input_number_default_reset(cinput_d);
+
+ elm_box_unpack(cinput_d->box, typed_data->ly_main);
+ evas_object_del(typed_data->ly_main);
+}
+
+static void input_number_del_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_input_typed_data *typed_data;
+
+ typed_data = evas_object_data_get(obj, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ input_number_del(data, typed_data);
+}
+
+
+static Evas_Object* input_add_new_email(ct_input_data *cinput_d)
+{
+ CTSvalue *value;
+ Evas_Object *layout;
+
+ value = input_new_email(cinput_d->contact);
+ c_retvm_if(NULL == value, NULL, "input_new_email() return NULL");
+
+ layout = input_fill_layout_email(cinput_d, value);
+ c_retvm_if(NULL == layout, NULL, "input_fill_layout_email() return NULL");
+
+ if (NULL == cinput_d->ly_email_first)
+ cinput_d->ly_email_first = layout;
+ cinput_d->ly_email_last = layout;
+
+ return layout;
+}
+
+static void input_number_type_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int type = (int)data;
+ char buf[CT_TEXT_SHORT_LEN];
+ ct_input_typed_data *typed_data;
+ Evas_Object *ly_type;
+
+ typed_data = evas_object_data_get(obj, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ contacts_svc_value_set_int(typed_data->value, CTS_NUM_VAL_TYPE_INT, ct_input_get_number_type(type));
+ ctui_get_number_type_str(ct_input_get_number_type(type), buf, sizeof(buf));
+
+ ly_type = elm_object_part_content_get(typed_data->ly_content, "elm.flip.content.title");
+ c_retm_if(NULL == ly_type, "elm_object_part_content_get() return NULL");
+
+ elm_object_part_text_set(ly_type, "title.text", buf);
+ evas_object_del(obj);
+}
+
+static void input_email_type_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int type = (int)data;
+ ct_input_typed_data *typed_data;
+ Evas_Object *ly_type;
+
+ typed_data = evas_object_data_get(obj, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ contacts_svc_value_set_int(typed_data->value, CTS_EMAIL_VAL_TYPE_INT, type);
+
+ ly_type = elm_object_part_content_get(typed_data->ly_content, "elm.flip.content.title");
+ c_retm_if(NULL == ly_type, "elm_object_part_content_get() return NULL");
+
+ elm_object_part_text_set(ly_type, "title.text", T_(CT_GET_TEXT_EMAIL_TYPE, type));
+ evas_object_del(obj);
+}
+
+static void input_data_type_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ int i;
+ int type;
+ int type_int;
+ int x, y, w, h;
+ Evas_Object *popup;
+ ct_input_data *cinput_d;
+ ct_input_typed_data *typed_data = data;
+ Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event_info;
+
+ if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ return;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ if (ev->output.y < y || y + h < ev->output.y)
+ return;
+
+ c_retm_if(NULL == typed_data, "parameter(typed_data) is NULL");
+
+ cinput_d = evas_object_data_get(obj, "cinput_d");
+ c_retm_if(NULL == cinput_d, "evas_object_data_get() return NULL");
+
+ ct_detail_mouseup(cinput_d->cdetail_d, NULL, NULL, event_info);
+
+ popup = elm_ctxpopup_add(cinput_d->cdetail_d->navi);
+ c_retm_if(NULL == popup, "elm_ctxpopup_add() return NULL");
+ cinput_d->cdetail_d->popup = popup;
+
+ evas_object_smart_callback_add(popup, "dismissed", ct_detail_popup_hide_cb, cinput_d->cdetail_d);
+ evas_object_data_set(popup, "typed_data", typed_data);
+
+ type = contacts_svc_value_get_type(typed_data->value);
+ switch (type) {
+ case CTS_VALUE_NUMBER:
+ type_int = contacts_svc_value_get_int(typed_data->value, CTS_NUM_VAL_TYPE_INT);
+ for (i=CTTEXT_TYPE_MOBILE;i<=CTTEXT_TYPE_OTHER;i++) {
+ if (type_int == ct_input_get_number_type(i)) continue;
+ elm_ctxpopup_item_append(popup, T_(CT_GET_TEXT_NUM_TYPE, i), NULL,
+ input_number_type_changed_cb, (void *)i);
+ }
+ break;
+
+ case CTS_VALUE_EMAIL:
+ type_int = contacts_svc_value_get_int(typed_data->value, CTS_EMAIL_VAL_TYPE_INT);
+ for (i=CTS_EMAIL_TYPE_HOME;i<=CTS_EMAIL_TYPE_WORK;i++) {
+ if (type_int == i) continue;
+ elm_ctxpopup_item_append(popup, T_(CT_GET_TEXT_EMAIL_TYPE, i), NULL,
+ input_email_type_changed_cb, (void *)i);
+ }
+ if (type_int != CTS_EMAIL_TYPE_NONE) {
+ elm_ctxpopup_item_append(popup, T_(CT_GET_TEXT_EMAIL_TYPE, CTS_EMAIL_TYPE_NONE), NULL,
+ input_email_type_changed_cb, (void *)CTS_EMAIL_TYPE_NONE);
+ }
+ break;
+
+ default:
+ ERR("Unknown type");
+ return;
+ }
+
+ evas_object_move(popup, cinput_d->cdetail_d->touch_x, cinput_d->cdetail_d->touch_y);
+ evas_object_show(popup);
+}
+
+static Evas_Object* input_add_new_number(ct_input_data *cinput_d)
+{
+ CTSvalue *value;
+ Evas_Object *layout;
+
+ value = input_new_number(cinput_d->contact);
+ c_retvm_if(NULL == value, NULL, "input_new_number() return NULL");
+
+ layout = input_fill_layout_number(cinput_d, value);
+ c_retvm_if(NULL == layout, NULL, "input_fill_layout_number() return NULL");
+
+ if (NULL == cinput_d->ly_number_first)
+ cinput_d->ly_number_first = layout;
+ cinput_d->ly_number_last = layout;
+
+ input_number_set_default_button_reset(cinput_d);
+
+ return layout;
+}
+
+static void input_number_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_input_data *cinput_d = data;
+ Evas_Object *btn_minus;
+ ct_input_typed_data *typed_data;
+
+ evas_object_smart_callback_del(obj, "changed", input_number_changed_cb);
+ c_retm_if(NULL == cinput_d, "parameter(ct_input_data) is NULL");
+
+ typed_data = evas_object_data_get(obj, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_NUM_VAL_DELETE_BOOL, false);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+ cinput_d->cnt_num++;
+
+ if (typed_data->ly_main == cinput_d->ly_number_last) {
+ btn_minus = elm_button_add(typed_data->ly_main);
+ c_retm_if(NULL == btn_minus, "elm_button_add() return NULL");
+
+ elm_object_style_set(btn_minus, "icon_minus");
+ evas_object_data_set(btn_minus, "typed_data", typed_data);
+ elm_object_part_content_set(typed_data->ly_main, "elm.edit.icon", btn_minus);
+ evas_object_smart_callback_add(btn_minus, "clicked", input_number_del_clicked_cb, cinput_d);
+
+ c_retm_if(NULL == input_add_new_number(cinput_d), "input_add_new_number() return NULL");
+ return;
+ }
+
+ input_number_set_default_button_reset(cinput_d);
+}
+
+
+static void input_email_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_input_data *cinput_d = data;
+ Evas_Object *btn_minus;
+ ct_input_typed_data *typed_data;
+
+ evas_object_smart_callback_del(obj, "changed", input_email_changed_cb);
+ c_retm_if(NULL == cinput_d, "parameter(ct_input_data) is NULL");
+
+ typed_data = evas_object_data_get(obj, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_EMAIL_VAL_DELETE_BOOL, false);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ if (typed_data->ly_main == cinput_d->ly_email_last) {
+ btn_minus = elm_button_add(typed_data->ly_main);
+ c_retm_if(NULL == btn_minus, "elm_button_add() return NULL");
+
+ elm_object_style_set(btn_minus, "icon_minus");
+ evas_object_data_set(btn_minus, "typed_data", typed_data);
+ elm_object_part_content_set(typed_data->ly_main, "elm.edit.icon", btn_minus);
+ evas_object_smart_callback_add(btn_minus, "clicked", input_email_del_clicked_cb, cinput_d);
+
+ c_retm_if(NULL == input_add_new_email(cinput_d), "input_add_new_email() return NULL");
+ }
+}
+
+static void input_number_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ char *input;
+ Evas_Object *entry = obj;
+ ct_input_data *cinput_d = data;
+ ct_input_typed_data *typed_data;
+
+ typed_data = evas_object_data_get(entry, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ input = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ c_retm_if(NULL == input, "ctui_entry_markup_to_utf8() return NULL");
+
+ if (*input) {
+ ret = contacts_svc_value_set_str(typed_data->value, CTS_NUM_VAL_NUMBER_STR, input);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+
+ if (NULL == cinput_d->ly_number_default) {
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_NUM_VAL_DELETE_BOOL, false);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() Failed(%d)", ret);
+
+ cinput_d->ly_number_default = typed_data->ly_main;
+ edje_object_signal_emit(_EDJ(typed_data->ly_content), "elm,state,contact,default_number,enabled", "elm");
+ }
+ }
+ else if (!contacts_svc_value_get_bool(typed_data->value, CTS_NUM_VAL_DELETE_BOOL)) {
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_NUM_VAL_DELETE_BOOL, true);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() Failed(%d)", ret);
+ cinput_d->cnt_num--;
+
+ if (typed_data->ly_main == cinput_d->ly_number_default) {
+ edje_object_signal_emit(_EDJ(typed_data->ly_content), "elm,state,contact,default_number,disabled", "elm");
+ input_number_default_reset(cinput_d);
+ }
+
+ if (cinput_d->ly_number_set_default)
+ input_number_set_default_button_reset(cinput_d);
+
+ if (typed_data->data)
+ evas_object_smart_callback_add(typed_data->data, "changed", input_number_changed_cb, cinput_d);
+ }
+
+ free(input);
+}
+
+static void input_email_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ char *input;
+ Evas_Object *entry = obj;
+ ct_input_data *cinput_d = data;
+ ct_input_typed_data *typed_data;
+
+ typed_data = evas_object_data_get(entry, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ input = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ c_retm_if(NULL == input, "ctui_entry_markup_to_utf8() return NULL");
+
+ if (*input) {
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_EMAIL_VAL_DELETE_BOOL, false);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ ret = contacts_svc_value_set_str(typed_data->value, CTS_EMAIL_VAL_ADDR_STR, input);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+ }
+ else if (!contacts_svc_value_get_bool(typed_data->value, CTS_EMAIL_VAL_DELETE_BOOL)) {
+ ret = contacts_svc_value_set_bool(typed_data->value, CTS_EMAIL_VAL_DELETE_BOOL, true);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ if (typed_data->data)
+ evas_object_smart_callback_add(typed_data->data, "changed", input_email_changed_cb, cinput_d);
+ }
+
+ free(input);
+}
+
+
+static Evas_Object *input_number_get_edit_rename(ct_input_data *cinput_d,
+ ct_input_typed_data *typed_data)
+{
+ const char *val_str;
+ Evas_Object *entry;
+ Evas_Object *editfield;
+ Evas_Object *ly_content = typed_data->ly_content;
+
+ editfield = ct_input_add_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_NUMBER),
+ input_number_unfocused_cb, cinput_d);
+ c_retvm_if(NULL == editfield, NULL, "ct_input_add_editfield() return NULL");
+
+ entry = elm_object_part_content_get(editfield, "elm.swallow.content");
+ typed_data->data = entry;
+
+ evas_object_data_set(entry, "typed_data", typed_data);
+ elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_PHONENUMBER);
+ val_str = contacts_svc_value_get_str(typed_data->value, CTS_NUM_VAL_NUMBER_STR);
+
+ if (val_str && *val_str) {
+ ctui_entry_entry_set(entry, val_str);
+ }
+ else
+ evas_object_smart_callback_add(entry, "changed", input_number_changed_cb, cinput_d);
+
+ return editfield;
+
+}
+
+
+static Evas_Object *input_email_get_edit_rename(ct_input_data *cinput_d,
+ ct_input_typed_data *typed_data)
+{
+ const char *val_str;
+ Evas_Object *entry;
+ Evas_Object *editfield;
+ Evas_Object *ly_content = typed_data->ly_content;
+
+ editfield = ct_input_add_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_EMAIL),
+ input_email_unfocused_cb, cinput_d);
+ c_retvm_if(NULL == editfield, NULL, "ct_input_add_editfield() return NULL");
+
+ entry = elm_object_part_content_get(editfield, "elm.swallow.content");
+ typed_data->data = entry;
+
+ evas_object_data_set(entry, "typed_data", typed_data);
+ elm_entry_input_panel_layout_set(entry, ELM_INPUT_PANEL_LAYOUT_EMAIL);
+ val_str = contacts_svc_value_get_str(typed_data->value, CTS_EMAIL_VAL_ADDR_STR);
+
+ if (val_str && *val_str) {
+ ctui_entry_entry_set(entry, val_str);
+ }
+ else
+ evas_object_smart_callback_add(entry, "changed", input_email_changed_cb, cinput_d);
+ return editfield;
+
+}
+
+static Evas_Object* input_fill_layout_number(ct_input_data *cinput_d, CTSvalue *value)
+{
+ const char *val_str;
+ int type_int;
+ char buf[CT_TEXT_SHORT_LEN];
+ Evas_Object *ly_content, *ly_main, *ly_type;
+ Evas_Object *ef;
+ Evas_Object *btn_minus;
+ Evas_Object *ico_check;
+ Evas_Object *box = cinput_d->box;
+ ct_input_typed_data *typed_data;
+
+ ly_content = ct_input_create_dg_layout(box, "1title.1text.1icon.2");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_content, "elm,state,flip,enabled", "elm");
+
+ ly_main = ct_input_create_dg_layout(box, "edit/contact");
+ c_retvm_if(NULL == ly_main, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_main, "elm,state,decorate,enabled", "elm");
+ elm_object_part_content_set(ly_main, "elm.swallow.decorate.content", ly_content);
+
+ if (contacts_svc_value_get_bool(value, CTS_NUM_VAL_DEFAULT_BOOL)) {
+ edje_object_signal_emit(_EDJ(ly_content), "elm,state,contact,default_number,enabled", "elm");
+ cinput_d->ly_number_default = ly_main;
+ }
+
+ type_int = contacts_svc_value_get_int(value, CTS_NUM_VAL_TYPE_INT);
+ ctui_get_number_type_str(type_int, buf, sizeof(buf));
+
+ ly_type = elm_layout_add(ly_content);
+ if (NULL == ly_type) {
+ ERR("elm_layout_add() return NULL");
+ evas_object_del(ly_main);
+ return NULL;
+ }
+ elm_layout_file_set(ly_type, CONTACTS_EDJ, "gl_title");
+ elm_object_part_text_set(ly_type, "title.text", buf);
+
+ evas_object_data_set(ly_type, "cinput_d", cinput_d);
+ elm_object_part_content_set(ly_content, "elm.flip.content.title", ly_type);
+
+ ico_check = elm_icon_add(ly_content);
+ if (NULL == ico_check) {
+ ERR("elm_icon_add() return NULL");
+ evas_object_del(ly_main);
+ return NULL;
+ }
+ elm_icon_file_set(ico_check, CTUI_IMG_CHECK, NULL);
+ evas_object_size_hint_aspect_set(ico_check, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ elm_object_part_content_set(ly_content, "elm.icon", ico_check);
+
+ typed_data = calloc(1, sizeof(ct_input_typed_data));
+ c_retvm_if(NULL == typed_data, NULL, "calloc() return NULL");
+ typed_data->value = value;
+ typed_data->ly_main = ly_main;
+ typed_data->ly_content = ly_content;
+ evas_object_data_set(ly_main, "typed_data", typed_data);
+
+ val_str = contacts_svc_value_get_str(value, CTS_NUM_VAL_NUMBER_STR);
+ if (val_str && *val_str) {
+ btn_minus = elm_button_add(ly_main);
+ if (NULL == btn_minus) {
+ ERR("elm_button_add() return NULL");
+ evas_object_del(ly_main);
+ free(typed_data);
+ return NULL;
+ }
+ elm_object_style_set(btn_minus, "icon_minus");
+ evas_object_data_set(btn_minus, "typed_data", typed_data);
+ elm_object_part_content_set(ly_main, "elm.edit.icon", btn_minus);
+ evas_object_smart_callback_add(btn_minus, "clicked", input_number_del_clicked_cb, cinput_d);
+ }
+
+ ef = input_number_get_edit_rename(cinput_d, typed_data);
+ if (NULL == ef) {
+ ERR("input_number_get_edit_rename() return NULL");
+ evas_object_del(ly_main);
+ free(typed_data);
+ return NULL;
+ }
+ elm_object_part_content_set(ly_content, "elm.flip.content", ef);
+
+ evas_object_event_callback_add(ly_type, EVAS_CALLBACK_MOUSE_UP, input_data_type_mouse_up_cb, typed_data);
+ evas_object_event_callback_add(ly_main, EVAS_CALLBACK_DEL, ct_input_typed_layout_del_cb, typed_data);
+
+ if (cinput_d->ly_number_last)
+ elm_box_pack_after(box, ly_main, cinput_d->ly_number_last);
+ else
+ elm_box_pack_end(box, ly_main);
+
+ return ly_main;
+}
+
+
+void ct_input_fill_layout_numbers(ct_input_data *cinput_d)
+{
+ GSList *list, *cursor;
+ Evas_Object *ly;
+ CTSstruct *contact = cinput_d->contact;
+
+ ly = NULL;
+ list = NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_NUMBER_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (NULL == cursor->data) continue;
+ ly = input_fill_layout_number(cinput_d, cursor->data);
+ c_retm_if(NULL == ly, "input_fill_layout_number() return NULL");
+
+ cinput_d->cnt_num++;
+ if (NULL == cinput_d->ly_number_first)
+ cinput_d->ly_number_first = ly;
+ }
+ if (NULL != ly)
+ cinput_d->ly_number_last = ly;
+ c_retm_if(NULL == input_add_new_number(cinput_d), "input_add_new_number() return NULL");
+}
+
+static Evas_Object* input_fill_layout_email(ct_input_data *cinput_d, CTSvalue *value)
+{
+ const char *val_str;
+ int type_int;
+ Evas_Object *ly_content, *ly_main, *ly_type;
+ Evas_Object *ef;
+ Evas_Object *btn_minus;
+ Evas_Object *box = cinput_d->box;
+ ct_input_typed_data *typed_data;
+
+ ly_content = ct_input_create_dg_layout(box, "1title.1text.1icon.2");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_content, "elm,state,flip,enabled", "elm");
+
+ ly_main = ct_input_create_dg_layout(box, "edit/contact");
+ c_retvm_if(NULL == ly_main, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_main, "elm,state,decorate,enabled", "elm");
+ elm_object_part_content_set(ly_main, "elm.swallow.decorate.content", ly_content);
+
+ type_int = contacts_svc_value_get_int(value, CTS_EMAIL_VAL_TYPE_INT);
+ ly_type = elm_layout_add(ly_content);
+ if (NULL == ly_type) {
+ ERR("elm_layout_add() return NULL");
+ evas_object_del(ly_main);
+ return NULL;
+ }
+ elm_layout_file_set(ly_type, CONTACTS_EDJ, "gl_title");
+ elm_object_part_text_set(ly_type, "title.text", T_(CT_GET_TEXT_EMAIL_TYPE, type_int));
+ evas_object_data_set(ly_type, "cinput_d", cinput_d);
+ elm_object_part_content_set(ly_content, "elm.flip.content.title", ly_type);
+
+ typed_data = calloc(1, sizeof(ct_input_typed_data));
+ c_retvm_if(NULL == typed_data, NULL, "calloc() return NULL");
+ typed_data->value = value;
+ typed_data->ly_main = ly_main;
+ typed_data->ly_content = ly_content;
+ evas_object_data_set(ly_main, "typed_data", typed_data);
+
+ val_str = contacts_svc_value_get_str(value, CTS_EMAIL_VAL_ADDR_STR);
+ if (val_str && *val_str) {
+ btn_minus = elm_button_add(ly_main);
+ if (NULL == btn_minus) {
+ ERR("elm_button_add() return NULL");
+ evas_object_del(ly_main);
+ free(typed_data);
+ return NULL;
+ }
+ elm_object_style_set(btn_minus, "icon_minus");
+ evas_object_data_set(btn_minus, "typed_data", typed_data);
+ elm_object_part_content_set(ly_main, "elm.edit.icon", btn_minus);
+ evas_object_smart_callback_add(btn_minus, "clicked", input_email_del_clicked_cb, cinput_d);
+ }
+
+ ef = input_email_get_edit_rename(cinput_d, typed_data);
+ if (NULL == ef) {
+ ERR("input_email_get_edit_rename() return NULL");
+ evas_object_del(ly_main);
+ free(typed_data);
+ return NULL;
+ }
+ elm_object_part_content_set(ly_content, "elm.flip.content", ef);
+
+ evas_object_event_callback_add(ly_main, EVAS_CALLBACK_DEL, ct_input_typed_layout_del_cb, typed_data);
+ evas_object_event_callback_add(ly_type, EVAS_CALLBACK_MOUSE_UP, input_data_type_mouse_up_cb, typed_data);
+
+ if (cinput_d->ly_email_last)
+ elm_box_pack_after(box, ly_main, cinput_d->ly_email_last);
+ else
+ elm_box_pack_end(box, ly_main);
+
+ return ly_main;
+}
+
+int ct_input_fill_layout_emails(ct_input_data *cinput_d)
+{
+ int cnt = 0;
+ GSList *list, *cursor;
+ Evas_Object *ly;
+ CTSstruct *contact = cinput_d->contact;
+
+ ly = NULL;
+ list = NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_EMAIL_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (NULL == cursor->data) continue;
+ ly = input_fill_layout_email(cinput_d, cursor->data);
+ c_retvm_if(NULL == ly, cnt, "input_fill_layout_email() return NULL");
+
+ if (NULL == cinput_d->ly_email_first)
+ cinput_d->ly_email_first = ly;
+
+ cnt++;
+ }
+ if (NULL != ly)
+ cinput_d->ly_email_last = ly;
+ c_retvm_if(NULL == input_add_new_email(cinput_d), cnt, "input_add_new_email() return NULL");
+ return cnt;
+}
+
diff --git a/lib/details/ct-input-num-email.h b/lib/details/ct-input-num-email.h
new file mode 100755
index 0000000..15e07d2
--- /dev/null
+++ b/lib/details/ct-input-num-email.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_INPUT_VIEW_EXT_H__
+#define __CONTACTS_INPUT_VIEW_EXT_H__
+
+void ct_input_fill_layout_numbers(ct_input_data *cinput_d);
+int ct_input_fill_layout_emails(ct_input_data *cinput_d);
+
+#endif //__CONTACTS_INPUT_VIEW_EXT_H__
diff --git a/lib/details/ct-input-utils.c b/lib/details/ct-input-utils.c
new file mode 100755
index 0000000..9625f26
--- /dev/null
+++ b/lib/details/ct-input-utils.c
@@ -0,0 +1,784 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <regex.h>
+#include <errno.h>
+#include <aul.h>
+#include <appsvc.h>
+#include <ui-gadget-module.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "contacts.h"
+#include "ct-list.h"
+#include "ct-detail.h"
+#include "ct-detail-utils.h"
+#include "ct-input-utils.h"
+#include "ct-input-view.h"
+
+#define CT_INPUT_BASE_ADDRBOOK "db/app/contacts/base_addressbook"
+
+int ct_input_get_base_ab(void)
+{
+ int ret, base_ab;
+
+ ret = vconf_get_int(CT_INPUT_BASE_ADDRBOOK, &base_ab);
+ c_retvm_if(ret<0, 0, "vconf_get_int() Failed(%d)", ret);
+
+ return base_ab;
+}
+
+static void input_change_photo(ct_input_data *cinput_d, const char *normal,
+ const char *full)
+{
+ int ret;
+ CTSvalue* base_info = NULL;
+
+ base_info = ct_detail_get_baseinfo_value(cinput_d->contact);
+
+ ret = contacts_svc_value_set_str(base_info, CTS_BASE_VAL_IMG_PATH_STR, normal);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+
+ ret = contacts_svc_value_set_str(base_info, CTS_BASE_VAL_FULL_IMG_PATH_STR, full);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+
+ ct_input_update_image(cinput_d);
+}
+
+static void input_src_ug_destroy(struct ui_gadget *ug, void *priv)
+{
+ ct_input_data *cinput_d = priv;
+ c_retm_if(NULL == ug, "ug is NULL");
+
+ if (NULL == cinput_d->crop_ug) {
+ ug_destroy(ug);
+ cinput_d->src_ug = NULL;
+ }
+}
+
+static void input_gallery_result(struct ui_gadget *ug, bundle *result, void *data)
+{
+ const char *val;
+ ct_input_data *cinput_d = data;
+
+ c_retm_if(NULL == ug || NULL == data, "ug or data is NULL");
+
+ if (result) {
+ val = bundle_get_val(result, "path");
+ c_retm_if(!val, "return value is NULL.\n");
+
+ input_change_photo(cinput_d, val, val);
+ }
+
+ if (cinput_d->src_ug) {
+ ug_destroy(cinput_d->src_ug);
+ cinput_d->src_ug = NULL;
+ }
+}
+
+void ct_input_gallery(void *data, Evas_Object *obj, void *event_info)
+{
+ struct ug_cbs cbs = {0};
+ ct_input_data *cinput_d = data;
+
+ bundle *bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_create() Failed");
+
+ bundle_add(bd, "launch-type", "select-one");
+ bundle_add(bd, "file-type", "image");
+
+ cbs.result_cb = input_gallery_result;
+ cbs.destroy_cb = input_src_ug_destroy;
+ cbs.layout_cb = ctui_ug_layout_cb;
+ cbs.priv = cinput_d;
+
+ cinput_d->src_ug = ug_create(cinput_d->cdetail_d->ug, GALLERY_UG, UG_MODE_FULLVIEW, bd, &cbs);
+ c_warn_if(NULL == cinput_d->src_ug, "ug_create() Failed");
+
+ bundle_free(bd);
+ evas_object_del(cinput_d->cdetail_d->popup);
+ cinput_d->cdetail_d->popup = NULL;
+}
+
+static void input_camera_result(bundle* bd, int request_code, int reserved, void* user_data)
+{
+ const char *normal, *full;
+ ct_input_data *cinput_d = user_data;
+
+ c_retm_if(bundle_get_val(bd, "camera_end"), "camera is closed abnormally");
+
+ normal = bundle_get_val(bd, "crop_image_path");
+ c_retm_if(!normal, "return value is NULL.\n");
+
+ full = bundle_get_val(bd, "image_path");
+
+ input_change_photo(cinput_d, normal, full);
+}
+
+void ct_input_camera(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_input_data *cinput_d = data;
+
+ bundle* bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_create() Failed");
+
+ appsvc_set_operation(bd, APPSVC_OPERATION_CREATE_CONTENT);
+ appsvc_set_mime(bd, "image/jpg");
+ appsvc_set_pkgname(bd, CAMERA_PKG);
+ appsvc_add_data(bd, "CALLER", "contacts");
+ appsvc_run_service(bd, 0, input_camera_result, data);
+ bundle_free(bd);
+
+ evas_object_del(cinput_d->cdetail_d->popup);
+ cinput_d->cdetail_d->popup = NULL;
+}
+
+static inline struct ui_gadget* input_myfile_ug(struct ug_cbs cbs,
+ bundle *bd, ct_input_data *cinput_d)
+{
+ struct ui_gadget* ug;
+
+ cbs.layout_cb = ctui_ug_layout_cb;
+ cbs.priv = cinput_d;
+
+ ug = ug_create(cinput_d->cdetail_d->ug, MYFILES_UG, UG_MODE_FULLVIEW, bd, &cbs);
+ c_warn_if(NULL == ug, "ug_create() Failed");
+
+ return ug;
+}
+
+#define ACCOUNT_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+[.])*[a-z0-9!#$%&'*+/=?^_`{|}~-]+"
+#define DOMAIN_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+[.])+[a-z0-9!#$%&'*+/=?^_`{|}~-]+"
+#define EMAIL_RGEX ACCOUNT_RGEX"@"DOMAIN_RGEX
+
+int ct_input_valid_email(CTSstruct *contact)
+{
+ int result = TRUE;
+ GSList *list;
+ GSList *cursor;
+
+ list = NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_EMAIL_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ bool is_del;
+ const char *email = NULL;
+
+ is_del = contacts_svc_value_get_bool(cursor->data, CTS_EMAIL_VAL_DELETE_BOOL);
+ if (is_del) continue;
+
+ email = contacts_svc_value_get_str(cursor->data, CTS_EMAIL_VAL_ADDR_STR);
+ if (email && *email) {
+ int len = strlen(email) + 1;
+ regex_t compiled;
+ regmatch_t str[len];
+
+ if (regcomp(&compiled, EMAIL_RGEX, REG_ICASE | REG_EXTENDED))
+ result = FALSE;
+ if (regexec(&compiled, email, len, str, 0) == REG_NOMATCH)
+ result = FALSE;
+
+ regfree(&compiled);
+ }
+ if (!result)
+ break;
+ }
+ return result;
+}
+
+static int input_is_name_empty(CTSstruct *contact)
+{
+ int ret;
+ CTSvalue *name_val;
+ const char *name = NULL;
+
+ ret = contacts_svc_struct_get_value(contact, CTS_CF_NAME_VALUE, &name_val);
+
+ c_retv_if(CTS_ERR_NO_DATA == ret, TRUE);
+ c_retvm_if(CTS_SUCCESS != ret, TRUE, "contacts_svc_struct_get_value() Failed(%d)", ret);
+
+ name = contacts_svc_value_get_str(name_val, CTS_NAME_VAL_FIRST_STR);
+ if (NULL == name || '\0' == *name) {
+ name = contacts_svc_value_get_str(name_val, CTS_NAME_VAL_LAST_STR);
+ if (NULL == name || '\0' == *name)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static int input_is_num_empty(CTSstruct *contact)
+{
+ GSList *list = NULL;
+ GSList *cursor;
+
+ contacts_svc_struct_get_list(contact, CTS_CF_NUMBER_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ bool is_del;
+ const char *number = NULL;
+
+ is_del = contacts_svc_value_get_bool(cursor->data, CTS_NUM_VAL_DELETE_BOOL);
+ if (is_del) continue;
+
+ number = contacts_svc_value_get_str(cursor->data, CTS_NUM_VAL_NUMBER_STR);
+ if (number && *number)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static int input_is_email_empty(CTSstruct *contact)
+{
+ GSList *list = NULL;
+ GSList *cursor;
+
+ contacts_svc_struct_get_list(contact, CTS_CF_EMAIL_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ bool is_del;
+ const char *email = NULL;
+
+ is_del = contacts_svc_value_get_bool(cursor->data, CTS_EMAIL_VAL_DELETE_BOOL);
+ if (is_del) continue;
+
+ email = contacts_svc_value_get_str(cursor->data, CTS_EMAIL_VAL_ADDR_STR);
+ if (email && *email)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void input_btn_popup(ct_detail_data *cdetail_d, const char *desc)
+{
+ Evas_Object *notify;
+
+ notify = elm_popup_add(cdetail_d->navi);
+ evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_text_set(notify, desc);
+
+ ctui_create_popup_button(notify, 1, S_(CT_SYS_SK_OK), ct_detail_popup_hide_cb, cdetail_d);
+
+ cdetail_d->popup = notify;
+ evas_object_show(notify);
+}
+
+void ct_input_save_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_detail_data *cdetail_d;
+ ct_input_data *cinput_d = data;
+
+ elm_object_focus_set(obj, EINA_FALSE);
+
+ c_retm_if(NULL == cinput_d, "cinput_d is NULL");
+
+ cdetail_d = cinput_d->cdetail_d;
+
+ if (TRUE != (ret = ct_input_valid_email(cinput_d->contact))) {
+ input_btn_popup(cdetail_d, T_(CT_GET_TEXT_ERR, CTTEXT_INVALID_EMAIL));
+ return;
+ }
+
+ if (input_is_name_empty(cinput_d->contact)
+ && input_is_num_empty(cinput_d->contact)
+ && input_is_email_empty(cinput_d->contact)) {
+ input_btn_popup(cdetail_d, T_(CT_GET_TEXT_ERR, CTTEXT_SAVE_FAIL));
+ return;
+ }
+
+
+
+ if (cdetail_d->contact_id) {
+ ret = contacts_svc_update_contact(cinput_d->contact);
+ if (ret < CTS_SUCCESS) {
+ switch (ret) {
+ case CTS_ERR_DB_LOCK:
+ ERR("contacts_svc_update_contact() Failed(%d)", ret);
+ cdetail_d->popup = ctui_create_popup(cdetail_d->navi, T_(CT_GET_TEXT_ERR, CTTEXT_ERR_DB_LOCKED), 1.5);
+ break;
+ case CTS_ERR_NO_SPACE:
+ ERR("contacts_svc_update_contact() Failed(%d)", ret);
+ cdetail_d->popup = ctui_create_popup(cdetail_d->navi, S_(CT_SYS_POP_NOT_ENOUGH_MEMORY), 1.5);
+ break;
+ default:
+ ERR("contacts_svc_update_contact() Failed(%d)", ret);
+ cdetail_d->popup = ctui_create_popup(cdetail_d->navi, S_(CT_SYS_POP_FAILED), 1.5);
+ break;
+ }
+ evas_object_smart_callback_add(cdetail_d->popup, "timeout", ct_detail_popup_hide_cb, cdetail_d);
+ return;
+ }
+ else {
+ cinput_d->saved = true;
+ }
+ }
+ else {
+ ret = contacts_svc_insert_contact(cdetail_d->base_ab, cinput_d->contact);
+ if (ret < CTS_SUCCESS) {
+ switch (ret) {
+ case CTS_ERR_DB_LOCK:
+ ERR("contacts_svc_insert_contact() Failed(%d)", ret);
+ cdetail_d->popup = ctui_create_popup(cdetail_d->navi, T_(CT_GET_TEXT_ERR, CTTEXT_ERR_DB_LOCKED), 1.5);
+ break;
+ case CTS_ERR_NO_SPACE:
+ ERR("contacts_svc_update_contact() Failed(%d)", ret);
+ cdetail_d->popup = ctui_create_popup(cdetail_d->navi, S_(CT_SYS_POP_NOT_ENOUGH_MEMORY), 1.5);
+ break;
+ default:
+ ERR("contacts_svc_insert_contact() Failed(%d)", ret);
+ cdetail_d->popup = ctui_create_popup(cdetail_d->navi, S_(CT_SYS_POP_FAILED), 1.5);
+ break;
+ }
+ evas_object_smart_callback_add(cdetail_d->popup, "timeout", ct_detail_popup_hide_cb, cdetail_d);
+ return;
+ }
+ else {
+ cdetail_d->contact_id = ret;
+ }
+ vconf_set_int(CT_INPUT_BASE_ADDRBOOK, cdetail_d->base_ab);
+ if (NULL == cdetail_d->clist_d && cdetail_d->ug)
+ ctui_ug_return_id(cdetail_d->ug, ret, 0, 0);
+ }
+
+ /* evas_object_smart_callback_del() func will be deleted */
+ evas_object_smart_callback_del(obj, "clicked", ct_input_save_cb);
+
+ if (cdetail_d->clist_d && CT_UG_REQUEST_UPDATE_WITH_NUM <= cdetail_d->clist_d->ug_request &&
+ cdetail_d->clist_d->ug_request <= CT_UG_REQUEST_SAVE_RINGTONE) {
+ ug_destroy_me(cdetail_d->ug);
+ }
+ else if (cdetail_d->ug && !cdetail_d->has_detail && NULL == cdetail_d->clist_d)
+ ug_destroy_me(cdetail_d->ug);
+ else if (cdetail_d->vcard)
+ elm_exit();
+ else
+ elm_naviframe_item_pop(cdetail_d->navi);
+}
+
+CTSvalue* ct_input_get_birth(CTSstruct *contact)
+{
+ GSList *list=NULL, *cursor;
+ contacts_svc_struct_get_list(contact, CTS_CF_EVENT_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ int type = contacts_svc_value_get_int(cursor->data, CTS_EVENT_VAL_TYPE_INT);
+ if (CTS_EVENT_TYPE_BIRTH == type)
+ return cursor->data;
+ }
+ return NULL;
+}
+
+CTSvalue* ct_input_get_baseinfo_value(CTSstruct* contact)
+{
+ int ret;
+ CTSvalue *baseinfo;
+
+ baseinfo = NULL;
+ ret = contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &baseinfo);
+ c_retvm_if(CTS_SUCCESS != ret && CTS_ERR_NO_DATA != ret, NULL, "contacts_svc_struct_get_value() failed(%d)", ret);
+
+ if (NULL == baseinfo) {
+ baseinfo = contacts_svc_value_new(CTS_VALUE_CONTACT_BASE_INFO);
+ ret = contacts_svc_struct_store_value(contact, CTS_CF_BASE_INFO_VALUE, baseinfo);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_struct_store_value() failed(%d)", ret);
+ }
+
+ return baseinfo;
+}
+
+CTSvalue* ct_input_get_nickname(CTSstruct *contact)
+{
+ GSList *list=NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_NICKNAME_LIST, &list);
+
+ if (NULL == list) return NULL;
+ return list->data;
+}
+
+CTSvalue* ct_input_get_website_value(CTSstruct* contact)
+{
+ GSList *list = NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_WEB_ADDR_LIST, &list);
+ if (0 < g_slist_length(list))
+ return list->data;
+ return NULL;
+}
+
+int ct_input_get_number_type(int ct_num_type)
+{
+ int ret_type;
+
+ switch (ct_num_type) {
+ case CTTEXT_TYPE_MOBILE:
+ ret_type = CTS_NUM_TYPE_CELL;
+ break;
+ case CTTEXT_TYPE_TELEPHONE:
+ ret_type = CTS_NUM_TYPE_VOICE;
+ break;
+ case CTTEXT_TYPE_FAX:
+ ret_type = CTS_NUM_TYPE_FAX;
+ break;
+ case CTTEXT_TYPE_ASSISTANT:
+ ret_type = CTS_NUM_TYPE_ASSISTANT;
+ break;
+ case CTTEXT_TYPE_CAR:
+ ret_type = CTS_NUM_TYPE_CAR;
+ break;
+ case CTTEXT_TYPE_HOME:
+ ret_type = CTS_NUM_TYPE_HOME;
+ break;
+ case CTTEXT_TYPE_PAGER:
+ ret_type = CTS_NUM_TYPE_PAGER;
+ break;
+ case CTTEXT_TYPE_WORK:
+ ret_type = CTS_NUM_TYPE_WORK;
+ break;
+ case CTTEXT_TYPE_OTHER:
+ default:
+ ret_type = CTS_NUM_TYPE_NONE;
+ break;
+ }
+
+ return ret_type;
+}
+
+static void input_img_del_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ CTSvalue *value;
+ ct_input_data *cinput_d = data;
+
+ c_retm_if(NULL == cinput_d, "parameter(cinput_d) is NULL");
+
+ value = ct_detail_get_baseinfo_value(cinput_d->contact);
+
+ ret = contacts_svc_value_set_str(value, CTS_BASE_VAL_IMG_PATH_STR, NULL);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+
+ ret = contacts_svc_value_set_str(value, CTS_BASE_VAL_FULL_IMG_PATH_STR, NULL);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+
+ ct_input_update_image(cinput_d);
+
+ evas_object_del(cinput_d->cdetail_d->popup);
+ cinput_d->cdetail_d->popup = NULL;
+}
+
+void ct_input_contact_image_change_popup(ct_input_data *cinput_d, bool has_photo)
+{
+ Evas_Object *popup;
+ Elm_Object_Item *item;
+ int battery_status = -1;
+
+ c_retm_if(NULL == cinput_d, "parameter(cinput_d) is NULL");
+
+ popup = elm_ctxpopup_add(cinput_d->cdetail_d->navi);
+ c_retm_if(NULL == popup, "elm_ctxpopup_add() return NULL");
+
+ evas_object_smart_callback_add(popup, "dismissed", ct_detail_popup_hide_cb, cinput_d->cdetail_d);
+ evas_object_data_set(popup, "cinput_d", cinput_d);
+
+ if (has_photo) {
+ elm_ctxpopup_item_append(popup, T_(CT_GET_TEXT_BASE_OP, CTTEXT_DELETE_PHOTO), NULL,
+ input_img_del_cb, cinput_d);
+ }
+
+ elm_ctxpopup_item_append(popup, T_(CT_GET_TEXT_BASE_OP, CTTEXT_IMAGE), NULL,
+ ct_input_gallery, cinput_d);
+
+ vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &battery_status);
+ if (VCONFKEY_SYSMAN_BAT_POWER_OFF != battery_status) {
+ item = elm_ctxpopup_item_append(popup, T_(CT_GET_TEXT_BASE_OP, CTTEXT_TAKE_A_PHOTO), NULL,
+ ct_input_camera, cinput_d);
+ elm_object_item_disabled_set(item, EINA_TRUE);
+ }
+
+ cinput_d->cdetail_d->popup = popup;
+ evas_object_move(popup, cinput_d->cdetail_d->touch_x, cinput_d->cdetail_d->touch_y);
+ evas_object_show(popup);
+}
+
+void ct_input_entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if (elm_object_focus_get(obj)) return;
+ evas_object_smart_callback_call(obj, "unfocused", NULL);
+}
+
+Evas_Object* ct_input_add_editfield(Evas_Object *parent, const char* guide_txt,
+ Evas_Smart_Cb unfocused_cb, void *unfocused_cb_data)
+{
+ Evas_Object *editfield;
+ Evas_Object *entry;
+
+ editfield = ctui_create_editfield(parent, NULL, guide_txt, false);
+ c_retvm_if(NULL == editfield, NULL, "ctui_create_editfield() return NULL");
+
+ entry = elm_object_part_content_get(editfield, "elm.swallow.content");
+ evas_object_smart_callback_add(entry, "changed", ct_input_entry_changed_cb, editfield);
+
+ if (unfocused_cb)
+ evas_object_smart_callback_add(entry, "unfocused", unfocused_cb, unfocused_cb_data);
+
+ return editfield;
+}
+
+static int input_get_ct_number_type(int cts_num_type)
+{
+ if (cts_num_type & CTS_NUM_TYPE_CUSTOM)
+ return CTTEXT_TYPE_OTHER;
+ else if (cts_num_type & CTS_NUM_TYPE_CELL)
+ return CTTEXT_TYPE_MOBILE;
+ else if (cts_num_type & CTS_NUM_TYPE_VOICE) {
+ if (cts_num_type & CTS_NUM_TYPE_HOME)
+ return CTTEXT_TYPE_HOME;
+ else if (cts_num_type & CTS_NUM_TYPE_WORK)
+ return CTTEXT_TYPE_WORK;
+ else
+ return CTTEXT_TYPE_TELEPHONE;
+ }
+ else if (cts_num_type & CTS_NUM_TYPE_FAX) {
+ if (cts_num_type & CTS_NUM_TYPE_HOME)
+ return CTTEXT_TYPE_FAX;
+ else if (cts_num_type & CTS_NUM_TYPE_WORK)
+ return CTTEXT_TYPE_FAX;
+ else
+ return CTTEXT_TYPE_FAX;
+ }
+ else if (cts_num_type & CTS_NUM_TYPE_PAGER)
+ return CTTEXT_TYPE_PAGER;
+ else if (cts_num_type & CTS_NUM_TYPE_CAR)
+ return CTTEXT_TYPE_CAR;
+ else if (cts_num_type & CTS_NUM_TYPE_ASSISTANT)
+ return CTTEXT_TYPE_ASSISTANT;
+ else
+ return CTTEXT_TYPE_OTHER;
+
+}
+
+int ct_input_next_number_type(CTSstruct *contact)
+{
+ int i;
+ int used = 0;
+ GSList *list = NULL, *cursor;
+ contacts_svc_struct_get_list(contact, CTS_CF_NUMBER_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (!contacts_svc_value_get_bool(cursor->data, CTS_NUM_VAL_DELETE_BOOL)) {
+ int cts_type;
+ cts_type = contacts_svc_value_get_int(cursor->data, CTS_NUM_VAL_TYPE_INT);
+ used |= 1<<input_get_ct_number_type(cts_type);
+ }
+ }
+
+ for (i=CTTEXT_TYPE_MOBILE;i<=CTTEXT_TYPE_OTHER;i++)
+ if (!(used & 1<<i))
+ return i;
+
+ return CTTEXT_TYPE_OTHER;
+}
+
+int ct_input_next_email_type(CTSstruct *contact)
+{
+ int i;
+ GSList *list = NULL, *cursor;
+ contacts_svc_struct_get_list(contact, CTS_CF_EMAIL_LIST, &list);
+
+ for (i=CTS_EMAIL_TYPE_HOME;i<=CTS_EMAIL_TYPE_WORK;i++) {
+ for (cursor=list;cursor;cursor=cursor->next)
+ if (i == contacts_svc_value_get_int(cursor->data, CTS_EMAIL_VAL_TYPE_INT)
+ && !contacts_svc_value_get_bool(cursor->data, CTS_EMAIL_VAL_DELETE_BOOL))
+ break;
+
+ if (NULL == cursor)
+ break;
+ }
+ if (CTS_EMAIL_TYPE_WORK < i)
+ return CTS_EMAIL_TYPE_NONE;
+ else
+ return i;
+}
+
+int ct_input_next_addr_type(CTSstruct *contact)
+{
+ int i;
+ int type = CTS_ADDR_TYPE_NONE;
+ GSList *list = NULL, *cursor;
+ contacts_svc_struct_get_list(contact, CTS_CF_POSTAL_ADDR_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (contacts_svc_value_get_bool(cursor->data, CTS_POSTAL_VAL_DELETE_BOOL))
+ continue;
+
+ type |= contacts_svc_value_get_int(cursor->data, CTS_POSTAL_VAL_TYPE_INT);
+ }
+
+ for (i=CTS_ADDR_TYPE_HOME;i<=CTS_ADDR_TYPE_WORK;i++) {
+ if (!(type & i))
+ return i;
+ }
+
+ return CTS_ADDR_TYPE_NONE;
+}
+
+void ct_input_get_group_names(GSList *list, char *dest, int dest_len)
+{
+ int ret;
+ int grp_id;
+ const char *group;
+ char temp[CT_TEXT_MAX_LEN];
+ CTSvalue *group_value;
+ GSList *cursor;
+
+ dest[0] = '\0';
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (contacts_svc_value_get_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL))
+ continue;
+
+ grp_id = contacts_svc_value_get_int(cursor->data, CTS_GROUPREL_VAL_ID_INT);
+ ret = contacts_svc_get_group(grp_id, &group_value);
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_get_group() failed");
+ break;
+ }
+
+ group = contacts_svc_value_get_str(group_value, CTS_GROUP_VAL_NAME_STR);
+ if (*group) {
+ if (*dest) {
+ ret = snprintf(temp, CT_TEXT_MAX_LEN, "%s, %s", dest, group);
+ if (ret < dest_len) {
+ memcpy(dest, temp, ret + 1);
+ }
+ else {
+ memcpy(dest, temp, dest_len);
+ dest[dest_len - 1] = '\0';
+ }
+ }
+ else {
+ snprintf(dest, CT_TEXT_MAX_LEN, "%s", group);
+ }
+ }
+ contacts_svc_value_free(group_value);
+ }
+ if ('\0' == *dest)
+ snprintf(dest, dest_len, "%s", T_(CT_GET_TEXT_BASIC, CTTEXT_NOT_ASSIGNED));
+}
+
+Evas_Object* ct_input_create_dg_layout(Evas_Object *parent, const char *theme)
+{
+ Evas_Object *layout = elm_layout_add(parent);
+ c_retvm_if(NULL == layout, NULL, "elm_layout_add() return NULL");
+
+ elm_layout_theme_set(layout, "layout", "dialogue", theme);
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
+
+ evas_object_show(layout);
+ return layout;
+}
+
+void ct_input_typed_layout_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ ct_input_typed_data *typed_data = data;
+ free(typed_data);
+}
+
+CTSvalue* ct_input_get_event(CTSstruct *contact, int event_type)
+{
+ GSList *list=NULL, *cursor;
+
+ contacts_svc_struct_get_list(contact, CTS_CF_EVENT_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ int type = contacts_svc_value_get_int(cursor->data, CTS_EVENT_VAL_TYPE_INT);
+ if (event_type == type)
+ return cursor->data;
+ }
+ return NULL;
+}
+
+CTSvalue* ct_detail_get_baseinfo_value(CTSstruct* contact)
+{
+ int ret;
+ CTSvalue *baseinfo;
+
+ baseinfo = NULL;
+ ret = contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &baseinfo);
+ c_retvm_if(CTS_SUCCESS != ret && CTS_ERR_NO_DATA != ret, NULL, "contacts_svc_struct_get_value() failed(%d)", ret);
+
+ if (NULL == baseinfo) {
+ baseinfo = contacts_svc_value_new(CTS_VALUE_CONTACT_BASE_INFO);
+ ret = contacts_svc_struct_store_value(contact, CTS_CF_BASE_INFO_VALUE, baseinfo);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_struct_store_value() failed(%d)", ret);
+ }
+
+ return baseinfo;
+}
+
+unsigned int ct_input_box_idx_get(Evas_Object *box, Evas_Object *obj)
+{
+ int count = 0;
+ Eina_List *list, *cursor;
+ Evas_Object *data;
+ list = elm_box_children_get(box);
+
+ EINA_LIST_FOREACH(list, cursor, data) {
+ if (data == obj)
+ break;
+ count++;
+ }
+ return count;
+}
+
+void ct_input_update_group(CTSstruct *contact, Evas_Object *layout)
+{
+ GSList *list;
+ char display[CT_TEXT_SHORT_LEN];
+
+ list = NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_GROUPREL_LIST, &list);
+
+ ct_input_get_group_names(list, display, sizeof(display));
+
+ elm_object_part_text_set(layout, "elm.text.2", display);
+}
+
+
+Evas_Object* ct_input_fill_layout_separator(ct_input_data *cinput_d, const char *theme)
+{
+ Evas_Object *box = cinput_d->box;
+ Evas_Object *layout;
+
+ /*Create a separator layout*/
+ layout = elm_layout_add(box);
+ c_retvm_if(NULL == layout, NULL, "elm_layout_add() return NULL");
+
+ elm_layout_theme_set(layout, "layout", "dialogue", theme);
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
+ evas_object_show(layout);
+
+ return layout;
+}
diff --git a/lib/details/ct-input-utils.h b/lib/details/ct-input-utils.h
new file mode 100755
index 0000000..641b25a
--- /dev/null
+++ b/lib/details/ct-input-utils.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_INPUT_UTILS_H__
+#define __CONTACTS_INPUT_UTILS_H__
+
+CTSvalue* ct_input_get_birth(CTSstruct *contact);
+int ct_input_get_base_ab(void);
+void ct_input_camera(void *data, Evas_Object *obj, void *event_info);
+void ct_input_gallery(void *data, Evas_Object *obj, void *event_info);
+void ct_input_save_cb(void *data, Evas_Object *obj, void *event_info);
+void ct_input_set_default_num(ct_input_data *cinput_d, CTSvalue *val);
+CTSvalue* ct_input_get_baseinfo_value(CTSstruct* contact);
+CTSvalue* ct_input_get_nickname(CTSstruct *contact);
+CTSvalue* ct_input_get_website_value(CTSstruct* contact);
+int ct_input_get_number_type(int ct_num_type);
+void ct_input_contact_image_change_popup(ct_input_data *cinput_d, bool has_photo);
+void ct_input_entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
+Evas_Object* ct_input_add_editfield(Evas_Object *parent, const char* guide_txt,
+ Evas_Smart_Cb unfocused_cb, void *unfocused_cb_data);
+void ct_input_gl_del(void *data, Evas_Object *obj);
+int ct_input_next_number_type(CTSstruct *contact);
+int ct_input_next_email_type(CTSstruct *contact);
+int ct_input_next_addr_type(CTSstruct *contact);
+void ct_input_get_group_names(GSList *list, char *dest, int dest_len);
+Evas_Object* ct_input_create_dg_layout(Evas_Object *parent, const char *theme);
+void ct_input_typed_layout_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
+CTSvalue* ct_input_get_event(CTSstruct *contact, int event_type);
+CTSvalue* ct_detail_get_baseinfo_value(CTSstruct* contact);
+unsigned int ct_input_box_idx_get(Evas_Object *box, Evas_Object *obj);
+void ct_input_update_group(CTSstruct *contact, Evas_Object *layout);
+Evas_Object* ct_input_fill_layout_separator(ct_input_data *cinput_d, const char *theme);
+
+#endif //__CONTACTS_INPUT_UTILS_H__
diff --git a/lib/details/ct-input-view.c b/lib/details/ct-input-view.c
new file mode 100755
index 0000000..6ec5c28
--- /dev/null
+++ b/lib/details/ct-input-view.c
@@ -0,0 +1,1639 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <errno.h>
+#include "contacts.h"
+#include "ct-detail.h"
+#include "ct-detail-utils.h"
+#include "ct-detail-view.h"
+#include "ct-input-utils.h"
+#include "ct-input-view.h"
+#include "ct-input-num-email.h"
+#include "ct-group-assign-view.h"
+
+static void input_update_address(ct_input_data *cinput_d);
+static Evas_Object* input_add_new_address(ct_input_data *cinput_d);
+static void input_update_event(Evas_Object *layout, CTSvalue *value);
+
+enum INPUT_ITEMS {
+ INPUT_BASEINFO = 0,
+ INPUT_NUMBER,
+ INPUT_EMAIL,
+ INPUT_MESSENGER,
+ INPUT_ADDRESS,
+ INPUT_GROUP,
+ INPUT_ADDRBOOK,
+ INPUT_BIRTHDAY,
+ INPUT_WEBSITE,
+ INPUT_NOTE,
+ INPUT_ITEMS_MAX,
+};
+
+static void input_layout_mouse_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *layout = (Evas_Object *) data;
+ elm_object_signal_emit(layout, "elm,state,unselected", "elm");
+}
+
+static void input_layout_mouse_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Move *ev = (Evas_Event_Mouse_Move *)event_info;
+ Evas_Object *layout = (Evas_Object *) data;
+ if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ elm_object_signal_emit(layout, "elm,state,unselected", "elm");
+}
+
+static void input_layout_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *layout = (Evas_Object *) data;
+ elm_object_signal_emit(layout, "elm,state,selected", "elm");
+}
+
+static void input_layout_selectable_set(Evas_Object *layout)
+{
+ c_retm_if(NULL == layout, "parameter(layout) is NULL");
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_UP, input_layout_mouse_up_cb, layout);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_DOWN, input_layout_mouse_down_cb, layout);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_MOVE, input_layout_mouse_move_cb, layout);
+}
+
+
+static inline CTSvalue* input_new_address(CTSstruct *contact)
+{
+ int ret;
+ int type;
+ GSList *list;
+ CTSvalue *value;
+
+ value = contacts_svc_value_new(CTS_VALUE_POSTAL);
+ c_retvm_if(NULL == value, NULL, "contacts_svc_value_new() return NULL");
+
+ type = ct_input_next_addr_type(contact);
+ contacts_svc_value_set_int(value, CTS_POSTAL_VAL_TYPE_INT, type);
+
+ list = NULL;
+ list = g_slist_append(list, value);
+
+ ret = contacts_svc_struct_store_list(contact, CTS_CF_POSTAL_ADDR_LIST, list);
+ g_slist_free(list);
+ c_retvm_if(ret < CTS_SUCCESS, NULL, "contacts_svc_struct_store_list() failed(%d)", ret);
+
+ return value;
+}
+
+
+static inline CTSvalue* input_new_name(CTSstruct *contact)
+{
+ int ret;
+ CTSvalue *name;
+
+ name = contacts_svc_value_new(CTS_VALUE_NAME);
+ ret = contacts_svc_struct_store_value(contact, CTS_CF_NAME_VALUE, name);
+ c_retvm_if(ret < CTS_SUCCESS, NULL, "contacts_svc_struct_store_value() failed(%d)", ret);
+
+ return name;
+}
+
+
+static inline CTSvalue* input_new_nickname(CTSstruct *contact)
+{
+ int ret;
+ GSList *list;
+ CTSvalue *value;
+
+ value = contacts_svc_value_new(CTS_VALUE_NICKNAME);
+
+ list = NULL;
+ list = g_slist_append(list, value);
+ ret = contacts_svc_struct_store_list(contact, CTS_CF_NICKNAME_LIST, list);
+
+ g_slist_free(list);
+ c_retvm_if(ret < CTS_SUCCESS, NULL, "contacts_svc_struct_store_list() failed(%d)", ret);
+
+ return value;
+}
+
+static inline CTSvalue* input_new_web(CTSstruct *contact)
+{
+ int ret;
+ GSList *list;
+ CTSvalue *value;
+
+ value = contacts_svc_value_new(CTS_VALUE_WEB);
+ list = NULL;
+ list = g_slist_append(list, value);
+
+ ret = contacts_svc_struct_store_list(contact, CTS_CF_WEB_ADDR_LIST, list);
+ g_slist_free(list);
+ c_retvm_if(ret < CTS_SUCCESS, NULL, "contacts_svc_struct_store_list() failed(%d)", ret);
+
+ ret = contacts_svc_value_set_bool(value, CTS_EVENT_VAL_DELETE_BOOL, true);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_value_set_bool() failed(%d)", ret);
+ return value;
+}
+
+static void input_contacts_changed(void *user_data)
+{
+ int id_ab, type, ret;
+ bool changed = false;
+ CTSiter *iter;
+ CTSvalue *value;
+ ct_input_data *cinput_d = user_data;
+ ct_detail_data *cdetail_d = cinput_d->cdetail_d;
+
+ c_retm_if(NULL == cdetail_d, "ct_detail_data is NULL");
+ c_retm_if(NULL == cinput_d->contact, "Contact is NULL");
+
+ if (cinput_d->saved)
+ return;
+
+ contacts_svc_struct_get_value(cinput_d->contact, CTS_CF_BASE_INFO_VALUE, &value);
+ id_ab = contacts_svc_value_get_int(value, CTS_BASE_VAL_ADDRESSBOOK_ID_INT);
+
+ ret = contacts_svc_get_updated_contacts(id_ab, cinput_d->view_create_ver, &iter);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_get_updated_contacts() Failed(%d)", ret);
+
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ value = contacts_svc_iter_get_info(iter);
+ if (contacts_svc_value_get_int(value, CTS_LIST_CHANGE_ID_INT) == cdetail_d->contact_id) {
+ changed = true;
+ type = contacts_svc_value_get_int(value, CTS_LIST_CHANGE_TYPE_INT);
+ contacts_svc_value_free(value);
+ break;
+ }
+ contacts_svc_value_free(value);
+ }
+ contacts_svc_iter_remove(iter);
+ c_ret_if(!changed);
+ if (CTS_OPERATION_UPDATED == type || (CTS_OPERATION_DELETED == type && !cdetail_d->has_detail))
+ elm_naviframe_item_pop(cdetail_d->navi);
+}
+
+
+static void input_view_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_input_data *cinput_d = data;
+ ct_detail_data *cdetail_d = cinput_d->cdetail_d;
+
+ if (cdetail_d->contact_id) {
+ ret = contacts_svc_unsubscribe_change_with_data(CTS_SUBSCRIBE_CONTACT_CHANGE,
+ input_contacts_changed, cinput_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_unsubscribe_change_with_data() Failed(%d)", ret);
+ }
+
+ contacts_svc_struct_free(cinput_d->contact);
+
+ if (cdetail_d->has_detail) {
+ cdetail_d->has_input = false;
+ }
+ else {
+ if (cdetail_d && cdetail_d->popup)
+ evas_object_del(cdetail_d->popup);
+
+ free(cdetail_d->base_ab_name);
+ contacts_svc_struct_free(cdetail_d->contact);
+ free(cdetail_d);
+ }
+
+ if (cinput_d->crop_ug)
+ ug_destroy(cinput_d->crop_ug);
+
+ if (cinput_d->src_ug)
+ ug_destroy(cinput_d->src_ug);
+
+ free(cinput_d);
+}
+
+
+static void input_baseinfo_value_set(CTSvalue *value, Evas_Object *entry, int field)
+{
+ int ret;
+ char *input;
+
+ input = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ c_retm_if(NULL == input, "ctui_entry_markup_to_utf8() return NULL");
+
+ ret = contacts_svc_value_set_str(value, field, input);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+ free(input);
+}
+
+static void input_company_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ CTSvalue *value;
+ ct_input_data *cinput_d = data;
+
+ ret = contacts_svc_struct_get_value(cinput_d->contact, CTS_CF_COMPANY_VALUE, &value);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_struct_get_value() Failed(%d)", ret);
+
+ input_baseinfo_value_set(value, obj, CTS_COMPANY_VAL_NAME_STR);
+}
+
+static void input_nick_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ CTSvalue *value;
+ ct_input_data *cinput_d = data;
+
+ value = ct_input_get_nickname(cinput_d->contact);
+ c_retm_if(NULL == value, "ct_input_get_nickname() return NULL");
+
+ input_baseinfo_value_set(value, obj, CTS_NICKNAME_VAL_NAME_STR);
+}
+static void input_middle_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ CTSvalue *value;
+ ct_input_data *cinput_d = data;
+
+ ret = contacts_svc_struct_get_value(cinput_d->contact, CTS_CF_NAME_VALUE, &value);
+ if (CTS_ERR_NO_DATA == ret) {
+ value = input_new_name(cinput_d->contact);
+ }
+ else if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_struct_get_value() failed(%d)", ret);
+ return;
+ }
+
+ input_baseinfo_value_set(value, obj, CTS_NAME_VAL_ADDITION_STR);
+}
+
+static void input_suffix_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ CTSvalue *value;
+ ct_input_data *cinput_d = data;
+
+ ret = contacts_svc_struct_get_value(cinput_d->contact, CTS_CF_NAME_VALUE, &value);
+ if (CTS_ERR_NO_DATA == ret) {
+ value = input_new_name(cinput_d->contact);
+ }
+ else if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_struct_get_value() failed(%d)", ret);
+ return;
+ }
+
+ input_baseinfo_value_set(value, obj, CTS_NAME_VAL_SUFFIX_STR);
+}
+
+static void input_website_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ char *input;
+ Evas_Object *entry = obj;
+ CTSvalue *value = data;
+
+ c_retm_if(NULL == value, "parameter(value) is NULL");
+
+ input = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ c_retm_if(NULL == input, "ctui_entry_markup_to_utf8() return NULL");
+
+ if (*input) {
+ ret = contacts_svc_value_set_str(value, CTS_WEB_VAL_ADDR_STR, input);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+
+ ret = contacts_svc_value_set_bool(value, CTS_WEB_VAL_DELETE_BOOL, false);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+ }
+ else {
+ ret = contacts_svc_value_set_bool(value, CTS_WEB_VAL_DELETE_BOOL, true);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() failed(%d)", ret);
+ }
+
+ free(input);
+
+}
+
+static void input_note_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ char *input;
+ Evas_Object *entry = obj;
+ CTSvalue *value = data;
+
+ input = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ c_retm_if(NULL == input, "ctui_entry_markup_to_utf8() return NULL");
+
+ ret = contacts_svc_value_set_str(value, CTS_BASE_VAL_NOTE_STR, input);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+ free(input);
+}
+
+static inline const char* input_get_contact_image_path(CTSstruct *contact)
+{
+ CTSvalue *base_info;
+ const char *img_path;
+
+ contacts_svc_struct_get_value(contact, CTS_CF_BASE_INFO_VALUE, &base_info);
+ img_path = contacts_svc_value_get_str(base_info, CTS_BASE_VAL_IMG_PATH_STR);
+
+ return img_path;
+}
+
+static void input_img_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ const char *value_data;
+
+ ct_input_data *cinput_d = data;
+ c_retm_if(NULL == cinput_d, "parameter(ct_input_data) is NULL");
+
+ value_data = input_get_contact_image_path(cinput_d->contact);
+
+ if (NULL == value_data)
+ ct_input_contact_image_change_popup(cinput_d, false);
+ else
+ ct_input_contact_image_change_popup(cinput_d, true);
+}
+
+void ct_input_update_image(ct_input_data *cinput_d)
+{
+ Evas_Object *layout;
+ Evas_Object *ico;
+ Evas_Object *btn;
+ const char *img_path;
+ static int idx_ico;
+
+ layout = elm_object_part_content_get(cinput_d->ly_baseinfo, "elm.swallow.decorate.content");
+ c_retm_if(NULL == layout, "elm_object_part_content_get() return NULL");
+
+ btn = elm_object_part_content_get(layout, "elm.icon");
+ if (NULL == btn) {
+ btn = elm_button_add(layout);
+ c_retm_if(NULL == btn, "elm_button_add() return NULL");
+ elm_object_part_content_set(layout, "elm.icon", btn);
+ evas_object_smart_callback_add(btn, "clicked", input_img_clicked_cb, cinput_d);
+ evas_object_size_hint_aspect_set(btn, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
+ }
+
+ ico = elm_object_part_content_get(btn, "icon");
+ if (!ico) {
+ ico = elm_icon_add(btn);
+ elm_icon_prescale_set(ico, CT_DETAIL_IMAGE_SIZE);
+ elm_object_part_content_set(btn, "icon", ico);
+ }
+
+ img_path = input_get_contact_image_path(cinput_d->contact);
+ if (NULL == img_path)
+ img_path = ctui_get_default_contact_img(CT_VIEW_INPUT);
+
+ if (idx_ico++%2)
+ elm_icon_file_set(ico, img_path, NULL);
+ else
+ elm_icon_file_set(ico, img_path, "/");
+}
+
+static void input_name_unfocused_cb(Evas_Object *entry, int field, ct_input_data *cinput_d)
+{
+ int ret;
+ char *name;
+ CTSvalue *value;
+
+ c_retm_if(NULL == cinput_d, "parameter(cinput_d) is NULL");
+
+ ret = contacts_svc_struct_get_value(cinput_d->contact, CTS_CF_NAME_VALUE, &value);
+ if (CTS_ERR_NO_DATA == ret) {
+ value = input_new_name(cinput_d->contact);
+ }
+ else if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_struct_get_value() failed(%d)", ret);
+ return;
+ }
+
+ name = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ c_retm_if(NULL == name, "ctui_entry_markup_to_utf8() return NULL");
+
+ ret = contacts_svc_value_set_str(value, CTS_NAME_VAL_DISPLAY_STR, NULL);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+
+ ret = contacts_svc_value_set_str(value, field, name);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() failed(%d)", ret);
+
+ free(name);
+
+}
+
+static void input_firstname_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ input_name_unfocused_cb(obj, CTS_NAME_VAL_FIRST_STR, data);
+}
+
+static void input_lastname_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ input_name_unfocused_cb(obj, CTS_NAME_VAL_LAST_STR, data);
+}
+
+static inline Evas_Object* input_editfield_entry_set(Evas_Object *ef, const char *text)
+{
+ Evas_Object *en = elm_object_part_content_get(ef, "elm.swallow.content");
+ c_retvm_if(NULL == en, NULL, "elm_object_part_content_get() return NULL");
+
+ if (text && *text) {
+ elm_entry_entry_set(en, text);
+ }
+ return en;
+}
+
+static Evas_Object* input_fill_layout_baseinfo_expand(ct_input_data *cinput_d, const char* guide_text,
+ Evas_Smart_Cb unfocused_cb, int type_struct, int type_value)
+{
+ int ret;
+ const char *display;
+ CTSvalue *value;
+ Evas_Object *ly_main, *ly_content;
+ Evas_Object *ef;
+ Evas_Object *box = cinput_d->box;
+
+ ly_content = ct_input_create_dg_layout(box, "bg/1text");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_content, "elm,state,flip,enabled", "elm");
+
+ ef = ct_input_add_editfield(ly_content, guide_text, unfocused_cb, cinput_d);
+ c_retvm_if(NULL == ef, NULL, "ct_input_add_editfield() return NULL");
+ elm_object_part_content_set(ly_content, "elm.flip.content", ef);
+
+ if (-1 == type_struct) {
+ value = ct_input_get_nickname(cinput_d->contact);
+ c_warn_if(NULL == value, "ct_input_get_nickname() return NULL");
+ }
+ else {
+ ret = contacts_svc_struct_get_value(cinput_d->contact, type_struct, &value);
+ c_warn_if(CTS_SUCCESS != ret && CTS_ERR_NO_DATA != ret, "contacts_svc_struct_get_value() Failed(%d)", ret);
+ }
+
+ display = contacts_svc_value_get_str(value, type_value);
+ input_editfield_entry_set(ef, display);
+
+ ly_main = ct_input_create_dg_layout(box, "edit/contact.5");
+ elm_object_signal_emit(ly_main, "elm,state,decorate,enabled", "elm");
+ c_retvm_if(NULL == ly_main, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_part_content_set(ly_main, "elm.swallow.decorate.content", ly_content);
+
+ return ly_main;
+}
+
+
+static void input_expand_baseinfo(ct_input_data *cinput_d)
+{
+ Evas_Object *ly;
+
+ ly = input_fill_layout_baseinfo_expand(cinput_d, T_(CT_GET_TEXT_BASIC, CTTEXT_MIDDLE),
+ input_middle_unfocused_cb, CTS_CF_NAME_VALUE, CTS_NAME_VAL_ADDITION_STR);
+ c_retm_if(NULL == ly, "input_fill_layout_baseinfo_expand() return NULL");
+ elm_box_pack_after(cinput_d->box, ly, cinput_d->ly_baseinfo);
+ cinput_d->ly_baseinfo_middle = ly;
+
+ ly = input_fill_layout_baseinfo_expand(cinput_d, T_(CT_GET_TEXT_BASIC, CTTEXT_SUFFIX),
+ input_suffix_unfocused_cb, CTS_CF_NAME_VALUE, CTS_NAME_VAL_SUFFIX_STR);
+ c_retm_if(NULL == ly, "input_fill_layout_baseinfo_expand() return NULL");
+ elm_box_pack_after(cinput_d->box, ly, cinput_d->ly_baseinfo_middle);
+ cinput_d->ly_baseinfo_suffix = ly;
+
+ ly = input_fill_layout_baseinfo_expand(cinput_d, T_(CT_GET_TEXT_BASIC, CTTEXT_NICKNAME),
+ input_nick_unfocused_cb, -1, CTS_NICKNAME_VAL_NAME_STR);
+ c_retm_if(NULL == ly, "input_fill_layout_baseinfo_expand() return NULL");
+ elm_box_pack_after(cinput_d->box, ly, cinput_d->ly_baseinfo_suffix);
+ cinput_d->ly_baseinfo_nick = ly;
+
+ ly = input_fill_layout_baseinfo_expand(cinput_d, T_(CT_GET_TEXT_BASIC, CTTEXT_COMPANY),
+ input_company_unfocused_cb, CTS_CF_COMPANY_VALUE, CTS_COMPANY_VAL_NAME_STR);
+ c_retm_if(NULL == ly, "input_fill_layout_baseinfo_expand() return NULL");
+ elm_box_pack_after(cinput_d->box, ly, cinput_d->ly_baseinfo_nick);
+ cinput_d->ly_baseinfo_company = ly;
+}
+
+
+static inline void input_close_baseinfo(ct_input_data *cinput_d)
+{
+ c_retm_if(NULL == cinput_d, "parameter(cinput_d) is NULL");
+
+ elm_box_unpack(cinput_d->box, cinput_d->ly_baseinfo_middle);
+ elm_box_unpack(cinput_d->box, cinput_d->ly_baseinfo_suffix);
+ elm_box_unpack(cinput_d->box, cinput_d->ly_baseinfo_nick);
+ elm_box_unpack(cinput_d->box, cinput_d->ly_baseinfo_company);
+
+ evas_object_del(cinput_d->ly_baseinfo_middle);
+ evas_object_del(cinput_d->ly_baseinfo_suffix);
+ evas_object_del(cinput_d->ly_baseinfo_nick);
+ evas_object_del(cinput_d->ly_baseinfo_company);
+
+ cinput_d->ly_baseinfo_middle = NULL;
+ cinput_d->ly_baseinfo_suffix = NULL;
+ cinput_d->ly_baseinfo_nick = NULL;
+ cinput_d->ly_baseinfo_company = NULL;
+}
+
+static void input_baseinfo_expand_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *icon;
+ ct_input_data *cinput_d = data;
+ icon = elm_object_part_content_get(obj, "icon");
+
+ if (cinput_d->ly_baseinfo_middle) {
+ input_close_baseinfo(cinput_d);
+ elm_object_style_set(obj, "icon_expand_opened");
+ }
+ else {
+ input_expand_baseinfo(cinput_d);
+ elm_object_style_set(obj, "icon_expand_closed");
+ }
+}
+
+static void input_addr_editfield_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ int field;
+ char *display;
+ Evas_Object *entry = obj;
+ CTSvalue *value = data;
+
+ field = (int)evas_object_data_get(obj, "field");
+
+ display = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ c_retm_if(NULL == display, "ctui_entry_markup_to_utf8() return NULL");
+
+ ret = contacts_svc_value_set_str(value, field, display);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() Failed(%d)", ret);
+
+ if (*display) {
+ ret = contacts_svc_value_set_bool(value, CTS_POSTAL_VAL_DELETE_BOOL, false);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() Failed(%d)", ret);
+ }
+
+ if (CTS_POSTAL_VAL_STREET_STR == field) {
+ ret = contacts_svc_value_set_str(value, CTS_POSTAL_VAL_EXTENDED_STR, NULL);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_str() Failed(%d)", ret);
+ }
+
+ free(display);
+}
+
+static void input_addr_type_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int type = (int)data;
+ Evas_Object *ly_type;
+ ct_input_typed_data *typed_data;
+
+ typed_data = evas_object_data_get(obj, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+
+ contacts_svc_value_set_int(typed_data->value, CTS_POSTAL_VAL_TYPE_INT, type);
+
+ ly_type = elm_object_part_content_get(typed_data->ly_content, "elm.flip.content.title");
+ c_retm_if(NULL == ly_type, "elm_object_part_content_get() return NULL");
+
+ elm_object_part_text_set(ly_type, "title.text", T_(CT_GET_TEXT_POSTAL_TYPE, type));
+ evas_object_del(obj);
+}
+
+
+static void input_addr_type_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ int i;
+ int type;
+ int x, y, w, h;
+ Evas_Object *popup;
+ ct_input_data *cinput_d;
+ ct_input_typed_data *typed_data = data;
+ Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event_info;
+
+ if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ return;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ if (ev->output.y < y || y + h < ev->output.y)
+ return;
+
+ c_retm_if(NULL == typed_data, "parameter(typed_data) is NULL");
+
+ cinput_d = evas_object_data_get(obj, "cinput_d");
+ c_retm_if(NULL == cinput_d, "evas_object_data_get() return NULL");
+
+ ct_detail_mouseup(cinput_d->cdetail_d, NULL, NULL, event_info);
+
+ popup = elm_ctxpopup_add(cinput_d->cdetail_d->win);
+ c_retm_if(NULL == popup, "elm_ctxpopup_add() return NULL");
+ cinput_d->cdetail_d->popup = popup;
+
+ evas_object_smart_callback_add(popup, "dismissed", ct_detail_popup_hide_cb, cinput_d->cdetail_d);
+ type = contacts_svc_value_get_int(typed_data->value, CTS_POSTAL_VAL_TYPE_INT);
+ evas_object_data_set(popup, "typed_data", typed_data);
+
+ for (i=CTS_ADDR_TYPE_HOME;i<=CTS_ADDR_TYPE_WORK;i++)
+ {
+ if (type == i) continue;
+ elm_ctxpopup_item_append(popup, T_(CT_GET_TEXT_POSTAL_TYPE, i), NULL,
+ input_addr_type_changed_cb, (void *)i);
+ }
+ if (type != CTS_ADDR_TYPE_NONE) {
+ elm_ctxpopup_item_append(popup, T_(CT_GET_TEXT_POSTAL_TYPE, CTS_ADDR_TYPE_NONE), NULL,
+ input_addr_type_changed_cb, (void *)CTS_ADDR_TYPE_NONE);
+ }
+ evas_object_move(popup, cinput_d->cdetail_d->touch_x, cinput_d->cdetail_d->touch_y);
+ evas_object_show(popup);
+}
+
+static Eina_Bool input_fill_layout(void *data);
+static void input_render_flush_post_cb(void *data, Evas *e, void *even_info)
+{
+ ecore_idler_add(input_fill_layout, data);
+ evas_event_callback_del(e, EVAS_CALLBACK_RENDER_FLUSH_POST, input_render_flush_post_cb);
+}
+
+static Evas_Object* input_fill_layout_baseinfo(ct_input_data *cinput_d)
+{
+ int ret;
+ const char *name;
+ CTSvalue *value;
+ Evas_Object *ly_main, *ly_content;
+ Evas_Object *ef_first, *ef_last;
+ Evas_Object *bt_expand;
+ Evas_Object *box = cinput_d->box;
+
+ ly_content = ct_input_create_dg_layout(box, "bg/2text.1icon.3");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_content, "elm,state,flip,enabled", "elm");
+
+ ly_main = ct_input_create_dg_layout(box, "edit/contact.4");
+ c_retvm_if(NULL == ly_main, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_main, "elm,state,decorate,enabled", "elm");
+ elm_object_part_content_set(ly_main, "elm.swallow.decorate.content", ly_content);
+ cinput_d->ly_baseinfo = ly_main;
+
+ /* first name */
+ ef_first = ct_input_add_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_FIRSTNAME),
+ input_firstname_unfocused_cb, cinput_d);
+ c_retvm_if(NULL == ef_first, NULL, "ct_input_add_editfield() return NULL");
+ elm_object_part_content_set(ly_content, "elm.flip.content.1", ef_first);
+
+ /* last name */
+ ef_last = ct_input_add_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_LASTNAME),
+ input_lastname_unfocused_cb, cinput_d);
+ c_retvm_if(NULL == ef_last, NULL, "ct_input_add_editfield() return NULL");
+ elm_object_part_content_set(ly_content, "elm.flip.content.2", ef_last);
+ ret = contacts_svc_struct_get_value(cinput_d->contact, CTS_CF_NAME_VALUE, &value);
+
+ if (CTS_SUCCESS == ret) {
+ name = contacts_svc_value_get_str(value, CTS_NAME_VAL_FIRST_STR);
+ input_editfield_entry_set(ef_first, name);
+
+ name = contacts_svc_value_get_str(value, CTS_NAME_VAL_LAST_STR);
+ input_editfield_entry_set(ef_last, name);
+ }
+
+ /* photo */
+ ct_input_update_image(cinput_d);
+
+ bt_expand = elm_button_add(ly_main);
+ c_retvm_if(NULL == bt_expand, NULL, "elm_button_add() return NULL");
+ elm_object_part_content_set(ly_main, "elm.edit.icon", bt_expand);
+
+ elm_object_style_set(bt_expand, "icon_expand_opened");
+ evas_object_smart_callback_add(bt_expand, "clicked", input_baseinfo_expand_clicked_cb, cinput_d);
+
+ return ly_main;
+}
+
+static Evas_Object* input_fill_layout_title(ct_input_data *cinput_d, const char *title)
+{
+ Evas_Object *box = cinput_d->box;
+ Evas_Object *layout;
+
+ /*Create a separator layout*/
+ layout = ct_input_create_dg_layout(box, "title");
+ c_retvm_if(NULL == layout, NULL, "ct_input_create_dg_layout() return NULL");
+
+ elm_object_part_text_set(layout, "elm.text", title);
+ evas_object_show(layout);
+ return layout;
+}
+
+static Evas_Object* input_fill_layout_messenger(ct_input_data *cinput_d, CTSvalue *value)
+{
+ const char *str_type;
+ const char *str_im_id;
+ Evas_Object *box = cinput_d->box;
+ Evas_Object *ly_content;
+
+ ly_content = ct_input_create_dg_layout(box, "dialogue/2text.2");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_content, "elm,state,rename,enabled", "elm");
+ input_layout_selectable_set(ly_content);
+
+ str_im_id = contacts_svc_value_get_str(value, CTS_MESSENGER_VAL_IM_ID_STR);
+ elm_object_part_text_set(ly_content, "elm.text.1", str_im_id);
+
+ str_type = T_(CT_GET_TEXT_IM_TYPE, contacts_svc_value_get_int(value, CTS_MESSENGER_VAL_TYPE_INT));
+ elm_object_part_text_set(ly_content, "elm.text.2", str_type);
+
+ // TODO: add mouse clicked event handler
+
+ return ly_content;
+}
+
+static int input_fill_layout_messengers(ct_input_data *cinput_d)
+{
+ int ret;
+ int cnt = 0;
+ GSList *list, *cursor;
+ Evas_Object *layout;
+ CTSstruct *contact = cinput_d->contact;
+
+ list = NULL;
+ layout = NULL;
+ ret = contacts_svc_struct_get_list(contact, CTS_CF_MESSENGER_LIST, &list);
+ if (CTS_SUCCESS == ret) {
+ layout = input_fill_layout_title(cinput_d, T_(CT_GET_TEXT_BASIC ,CTTEXT_INSTANT_MESSENGER));
+ c_retvm_if(NULL == layout, cnt, "input_fill_layout_title() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (NULL == cursor->data) continue;
+ layout = input_fill_layout_messenger(cinput_d, cursor->data);
+ c_retvm_if(NULL == layout, cnt, "input_fill_layout_messenger() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ cnt++;
+ }
+ }
+
+ return cnt;
+}
+
+static Evas_Object* input_fill_layout_address(ct_input_data *cinput_d, CTSvalue *value)
+{
+ int type_int;
+ const char *display;
+ Evas_Object *ly_main, *ly_content, *ly_type;
+ Evas_Object *ef, *en;
+ Evas_Object *btn;
+ Evas_Object *box = cinput_d->box;
+ ct_input_typed_data *typed_data;
+
+ ly_content = ct_input_create_dg_layout(box, "1title.5text");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_content, "elm,state,flip,enabled", "elm");
+
+ ly_main = ct_input_create_dg_layout(box, "edit/contact.5");
+ c_retvm_if(NULL == ly_main, NULL, "ct_input_create_dg_layout() return NULL");
+ elm_object_signal_emit(ly_main, "elm,state,decorate,enabled", "elm");
+ elm_object_part_content_set(ly_main, "elm.swallow.decorate.content", ly_content);
+
+ /* postal code */
+ ef = ct_input_add_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_POSTAL_CODE),
+ input_addr_editfield_unfocused_cb, value);
+ c_retvm_if(NULL == ef, NULL, "ct_input_add_editfield() return NULL");
+ elm_object_part_content_set(ly_content, "elm.flip.content.1", ef);
+
+ display = contacts_svc_value_get_str(value, CTS_POSTAL_VAL_POSTALCODE_STR);
+ en = input_editfield_entry_set(ef, display);
+ elm_entry_input_panel_layout_set(en, ELM_INPUT_PANEL_LAYOUT_NUMBER);
+ evas_object_data_set(en, "field", (void *)CTS_POSTAL_VAL_POSTALCODE_STR);
+
+ /* country */
+ ef = ct_input_add_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_COUNTRY),
+ input_addr_editfield_unfocused_cb, value);
+ c_retvm_if(NULL == ef, NULL, "ct_input_add_editfield() return NULL");
+ elm_object_part_content_set(ly_content, "elm.flip.content.2", ef);
+
+ display = contacts_svc_value_get_str(value, CTS_POSTAL_VAL_COUNTRY_STR);
+ en = input_editfield_entry_set(ef, display);
+ evas_object_data_set(en, "field", (void *)CTS_POSTAL_VAL_COUNTRY_STR);
+
+ /* province */
+ ef = ct_input_add_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_PROVINCE),
+ input_addr_editfield_unfocused_cb, value);
+ c_retvm_if(NULL == ef, NULL, "ct_input_add_editfield() return NULL");
+ elm_object_part_content_set(ly_content, "elm.flip.content.3", ef);
+
+ display = contacts_svc_value_get_str(value, CTS_POSTAL_VAL_REGION_STR);
+ en = input_editfield_entry_set(ef, display);
+ evas_object_data_set(en, "field", (void *)CTS_POSTAL_VAL_REGION_STR);
+
+ /* city */
+ ef = ct_input_add_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_CITY),
+ input_addr_editfield_unfocused_cb, value);
+ c_retvm_if(NULL == ef, NULL, "ct_input_add_editfield() return NULL");
+ elm_object_part_content_set(ly_content, "elm.flip.content.4", ef);
+
+ display = contacts_svc_value_get_str(value, CTS_POSTAL_VAL_LOCALITY_STR);
+ en = input_editfield_entry_set(ef, display);
+ evas_object_data_set(en, "field", (void *)CTS_POSTAL_VAL_LOCALITY_STR);
+
+ /* street */
+ ef = ct_input_add_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_STREET),
+ input_addr_editfield_unfocused_cb, value);
+ c_retvm_if(NULL == ef, NULL, "ct_input_add_editfield() return NULL");
+ elm_object_part_content_set(ly_content, "elm.flip.content.5", ef);
+
+ display = contacts_svc_value_get_str(value, CTS_POSTAL_VAL_STREET_STR);
+ en = input_editfield_entry_set(ef, display);
+ evas_object_data_set(en, "field", (void *)CTS_POSTAL_VAL_STREET_STR);
+
+ /* type */
+ type_int = contacts_svc_value_get_int(value, CTS_POSTAL_VAL_TYPE_INT);
+
+ ly_type = elm_layout_add(ly_content);
+ if (NULL == ly_type) {
+ ERR("elm_layout_add() return NULL");
+ evas_object_del(ly_main);
+ return NULL;
+ }
+ elm_layout_file_set(ly_type, CONTACTS_EDJ, "gl_title");
+ elm_object_part_text_set(ly_type, "title.text", T_(CT_GET_TEXT_POSTAL_TYPE, type_int));
+
+ evas_object_data_set(ly_type, "cinput_d", cinput_d);
+ elm_object_part_content_set(ly_content, "elm.flip.content.title", ly_type);
+
+ /* edit button */
+ btn = elm_button_add(ly_main);
+ if (NULL == btn) {
+ ERR("elm_button_add() return NULL");
+ evas_object_del(ly_main);
+ return NULL;
+ }
+ elm_object_part_content_set(ly_main, "elm.edit.icon", btn);
+ evas_object_data_set(btn, "cinput_d", cinput_d);
+
+ typed_data = calloc(1, sizeof(ct_input_typed_data));
+ c_retvm_if(NULL == typed_data, NULL, "calloc() return NULL");
+ typed_data->ly_main = ly_main;
+ typed_data->ly_content = ly_content;
+ typed_data->value = value;
+ evas_object_data_set(ly_main, "typed_data", typed_data);
+
+ evas_object_event_callback_add(ly_type, EVAS_CALLBACK_MOUSE_UP, input_addr_type_mouse_up_cb, typed_data);
+ evas_object_event_callback_add(ly_main, EVAS_CALLBACK_DEL, ct_input_typed_layout_del_cb, typed_data);
+ return ly_main;
+}
+
+static Evas_Object* input_add_new_address(ct_input_data *cinput_d)
+{
+ CTSvalue *value;
+ Evas_Object *layout;
+
+ value = input_new_address(cinput_d->contact);
+ c_retvm_if(NULL == value, NULL, "input_new_address() return NULL");
+
+ layout = input_fill_layout_address(cinput_d, value);
+ c_retvm_if(NULL == layout, NULL, "input_fill_layout_address() return NULL");
+
+ if (cinput_d->ly_addr_last)
+ elm_box_pack_after(cinput_d->box, layout, cinput_d->ly_addr_last);
+ else
+ elm_box_pack_end(cinput_d->box, layout);
+
+ return layout;
+}
+
+static void input_addr_del_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int idx;
+ Evas_Object *layout;
+ ct_input_data *cinput_d;
+ ct_input_typed_data *typed_data = data;
+ c_retm_if(NULL == typed_data, "parameter(typed_data) is NULL");
+
+ cinput_d = evas_object_data_get(obj, "cinput_d");
+ c_retm_if(NULL == cinput_d, "evas_object_data_get() return NULL");
+
+ if (typed_data->ly_main == cinput_d->ly_addr_first) {
+ idx = ct_input_box_idx_get(cinput_d->box, cinput_d->ly_addr_first);
+ layout = eina_list_nth(elm_box_children_get(cinput_d->box), idx + 1);
+ cinput_d->ly_addr_first = layout;
+ }
+
+ contacts_svc_value_set_bool(typed_data->value, CTS_POSTAL_VAL_DELETE_BOOL, true);
+ elm_box_unpack(cinput_d->box, typed_data->ly_main);
+ evas_object_del(typed_data->ly_main);
+ input_update_address(cinput_d);
+}
+
+static void input_addr_add_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *layout;
+ ct_input_data *cinput_d = data;
+ c_retm_if(NULL == cinput_d, "parameter(cinput_d) is NULL");
+
+ layout = input_add_new_address(data);
+ c_retm_if(NULL == layout, "input_add_new_address() return");
+ if (NULL == cinput_d->ly_addr_first)
+ cinput_d->ly_addr_first = layout;
+ cinput_d->ly_addr_last = layout;
+ input_update_address(data);
+}
+
+
+static void input_update_address(ct_input_data *cinput_d)
+{
+ int idx;
+ Eina_List *list, *cursor;
+ Evas_Object *btn;
+ Evas_Object *layout;
+ ct_input_typed_data *typed_data;
+
+ idx = ct_input_box_idx_get(cinput_d->box, cinput_d->ly_addr_first);
+ list = eina_list_nth_list(elm_box_children_get(cinput_d->box), idx);
+ EINA_LIST_FOREACH(list, cursor, layout) {
+ if (NULL == layout) continue;
+
+ btn = elm_object_part_content_get(layout, "elm.edit.icon");
+ c_retm_if(NULL == btn, "elm_object_part_content_get() return NULL");
+
+ evas_object_smart_callback_del(btn, "clicked", input_addr_add_clicked_cb);
+ evas_object_smart_callback_del(btn, "clicked", input_addr_del_clicked_cb);
+
+ if (layout == cinput_d->ly_addr_last) {
+ elm_object_style_set(btn, "icon_plus");
+ evas_object_smart_callback_add(btn, "clicked", input_addr_add_clicked_cb, cinput_d);
+ break;
+ }
+ else {
+ typed_data = evas_object_data_get(layout, "typed_data");
+ c_retm_if(NULL == typed_data, "evas_object_data_get() return NULL");
+ elm_object_style_set(btn, "icon_minus");
+ evas_object_smart_callback_add(btn, "clicked", input_addr_del_clicked_cb, typed_data);
+ }
+ }
+}
+
+
+static Evas_Object* input_fill_layout_addresses(ct_input_data *cinput_d)
+{
+ GSList *list, *cursor;
+ CTSstruct *contact = cinput_d->contact;
+ Evas_Object *layout;
+
+ list = NULL;
+ layout = NULL;
+
+ contacts_svc_struct_get_list(contact, CTS_CF_POSTAL_ADDR_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next) {
+ if (NULL == cursor->data) continue;
+ layout = input_fill_layout_address(cinput_d, cursor->data);
+ c_retvm_if(NULL == layout, NULL, "input_fill_layout_address() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+ if (NULL == cinput_d->ly_addr_first)
+ cinput_d->ly_addr_first = layout;
+ cinput_d->ly_addr_last = layout;
+ }
+
+ if (NULL == cinput_d->ly_addr_last) {
+ layout = input_add_new_address(cinput_d);
+ c_retvm_if(NULL == layout, NULL, "input_add_new_address() return");
+ if (NULL == cinput_d->ly_addr_first)
+ cinput_d->ly_addr_first = layout;
+ cinput_d->ly_addr_last = layout;
+ }
+
+ input_update_address(cinput_d);
+
+ return layout;
+}
+
+static void input_group_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ int x, y, w, h;
+ Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event_info;
+ ct_input_data *cinput_d = data;
+
+ if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ return;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ if (ev->output.y < y || y + h < ev->output.y)
+ return;
+ elm_object_focus_set(cinput_d->cdetail_d->navi, EINA_FALSE);
+
+ ct_detail_mouseup(cinput_d->cdetail_d, e, obj, event_info);
+ ct_grp_assign_create_view(data);
+}
+
+static Evas_Object* input_fill_layout_group(ct_input_data *cinput_d)
+{
+ char display[CT_TEXT_SHORT_LEN];
+ GSList *list;
+ Evas_Object *box = cinput_d->box;
+ Evas_Object *ly_content;
+
+ ly_content = ct_input_create_dg_layout(box, "2text.3");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+
+ cinput_d->ly_group = ly_content;
+ input_layout_selectable_set(ly_content);
+ evas_object_event_callback_add(ly_content, EVAS_CALLBACK_MOUSE_UP, input_group_mouse_up_cb, cinput_d);
+
+ elm_object_part_text_set(ly_content, "elm.text.1", T_(CT_GET_TEXT_BASIC, CTTEXT_GROUP));
+
+ list = NULL;
+ contacts_svc_struct_get_list(cinput_d->contact, CTS_CF_GROUPREL_LIST, &list);
+ ct_input_get_group_names(list, display, sizeof(display));
+ elm_object_part_text_set(ly_content, "elm.text.2", display);
+
+ return ly_content;
+}
+
+static void input_del_group_info(ct_input_data *cinput_d)
+{
+ GSList *cursor;
+ GSList *list;
+
+ list = NULL;
+ contacts_svc_struct_get_list(cinput_d->contact, CTS_CF_GROUPREL_LIST, &list);
+
+ for (cursor=list;cursor;cursor=cursor->next)
+ contacts_svc_value_set_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL, TRUE);
+
+ if (cinput_d->ly_group)
+ ct_input_update_group(cinput_d->contact, cinput_d->ly_group);
+}
+
+static void input_addrbook_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ char temp[CT_TEXT_SHORT_LEN];
+ ct_input_data *cinput_d;
+ ct_ab_popup_data *ab_popup_data = data;
+
+ cinput_d = evas_object_data_get(obj, "data");
+ c_retm_if(NULL == data, "evas_object_data_get() return NULL");
+
+ if (cinput_d->cdetail_d->base_ab != ab_popup_data->id)
+ input_del_group_info(cinput_d);
+ cinput_d->cdetail_d->base_ab = ab_popup_data->id;
+ cinput_d->cdetail_d->base_ab_mode = ab_popup_data->mode;
+
+ if (ab_popup_data->id)
+ snprintf(temp, sizeof(temp), "%s(%s)", T_(CT_GET_TEXT_ACC_TYPE, ab_popup_data->type), ab_popup_data->name);
+ else
+ snprintf(temp, sizeof(temp), "%s", T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE));
+
+ free(cinput_d->cdetail_d->base_ab_name);
+ cinput_d->cdetail_d->base_ab_name = strdup(temp);
+
+ if (cinput_d->ly_addrbook)
+ elm_object_part_text_set(cinput_d->ly_addrbook, "elm.text.2", cinput_d->cdetail_d->base_ab_name);
+
+ ct_detail_popup_hide_cb(cinput_d->cdetail_d, NULL, NULL);
+}
+
+static void input_addrbook_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ int x, y, w, h;
+ Evas_Object *popup;
+ ct_input_data *cinput_d = data;
+ Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event_info;
+
+ if (ev && ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ return;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ if (ev->output.y < y || y + h < ev->output.y)
+ return;
+ elm_object_focus_set(cinput_d->cdetail_d->navi, EINA_FALSE);
+ ct_detail_mouseup(cinput_d->cdetail_d, e, obj, event_info);
+
+ popup = ctui_addrbook_popup(cinput_d->cdetail_d->win, input_addrbook_item_sel_cb, cinput_d,
+ CTS_ADDRESSBOOK_MODE_READONLY, ct_detail_popup_hide_cb, cinput_d->cdetail_d);
+ c_retm_if(NULL == popup, "ctui_addrbook_popup() return NULL");
+ elm_object_part_text_set(popup, "title,text", T_(CT_GET_TEXT_BASE_OP, CTTEXT_SAVE_CONTACT_TO));
+
+ cinput_d->cdetail_d->popup = popup;
+}
+
+
+static Evas_Object* input_fill_layout_addrbook(ct_input_data *cinput_d)
+{
+ const char *display;
+ Evas_Object *box = cinput_d->box;
+ Evas_Object *ly_content;
+
+ ly_content = ct_input_create_dg_layout(box, "2text.3");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+
+ cinput_d->ly_addrbook = ly_content;
+ input_layout_selectable_set(ly_content);
+ evas_object_event_callback_add(ly_content, EVAS_CALLBACK_MOUSE_UP, input_addrbook_mouse_up_cb, cinput_d);
+
+ elm_object_part_text_set(ly_content, "elm.text.1", T_(CT_GET_TEXT_BASE_OP, CTTEXT_SAVE_CONTACT_TO));
+
+ if (0 == cinput_d->cdetail_d->base_ab)
+ display = S_(CT_SYS_BODY_PHONE);
+ else if (cinput_d->cdetail_d->base_ab_name)
+ display = cinput_d->cdetail_d->base_ab_name;
+ else
+ display = S_(CT_SYS_BODY_UNKNOWN);
+
+ elm_object_part_text_set(ly_content, "elm.text.2", display);
+ return ly_content;
+}
+
+static inline CTSvalue* input_new_event(CTSstruct *contact, int event_type)
+{
+ int ret;
+ GSList *list;
+ CTSvalue *value;
+
+ value = contacts_svc_value_new(CTS_VALUE_EVENT);
+
+ ret = contacts_svc_value_set_int(value, CTS_EVENT_VAL_TYPE_INT, event_type);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_value_set_int() failed(%d)", ret);
+
+ list = NULL;
+ list = g_slist_append(list, value);
+ ret = contacts_svc_struct_store_list(contact, CTS_CF_EVENT_LIST, list);
+ g_slist_free(list);
+ c_retvm_if(ret < CTS_SUCCESS, NULL, "contacts_svc_struct_store_list() failed(%d)", ret);
+
+ ret = contacts_svc_value_set_bool(value, CTS_EVENT_VAL_DELETE_BOOL, true);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_value_set_bool() failed(%d)", ret);
+
+ return value;
+}
+
+
+static void input_event_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int year;
+ int month;
+ int day;
+ int ret;
+ CTSvalue *value = data;
+ ct_input_data *cinput_d;
+ struct tm currtime;
+
+ c_retm_if(NULL == value, "parameter(value) is NULL");
+
+ cinput_d = evas_object_data_get(obj, "cinput_d");
+ c_retm_if(NULL == cinput_d, "evas_object_data_get() return NULL");
+
+ elm_datetime_value_get(obj, &currtime);
+
+ year = currtime.tm_year + 1900;
+ month = currtime.tm_mon + 1;
+ day = currtime.tm_mday;
+
+ ret = contacts_svc_value_set_int(value, CTS_EVENT_VAL_DATE_INT,
+ year * 10000 + month * 100 + day);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_value_set_int() Failed(%d)", ret);
+
+ if (contacts_svc_value_get_bool(value, CTS_EVENT_VAL_DELETE_BOOL)) {
+ int event_type;
+ Evas_Object *layout;
+
+ ret = contacts_svc_value_set_bool(value, CTS_EVENT_VAL_DELETE_BOOL, false);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_set_bool() Failed(%d)", ret);
+
+ event_type = contacts_svc_value_get_int(value, CTS_EVENT_VAL_TYPE_INT);
+ if (CTS_EVENT_TYPE_BIRTH == event_type) {
+ layout = cinput_d->ly_birthday;
+ input_update_event(layout, value);
+ }
+ }
+}
+
+static void input_update_event(Evas_Object *layout, CTSvalue *value)
+{
+ time_t timer;
+ struct tm *stime;
+ Evas_Object *btn;
+ Evas_Object *datetime;
+ bool deleted = false;
+
+ datetime = elm_object_part_content_get(layout, "elm.icon.1");
+ c_retm_if(NULL == datetime, "elm_object_part_content_get() return NULL");
+
+ deleted = contacts_svc_value_get_bool(value, CTS_EVENT_VAL_DELETE_BOOL);
+
+ if (deleted) {
+ timer = time(NULL);
+ stime = localtime(&timer);
+ c_retm_if(NULL == stime, "localtime() Failed(%d)", errno);
+
+ evas_object_smart_callback_del(datetime, "changed", input_event_changed_cb);
+ elm_datetime_value_set(datetime, stime);
+ evas_object_smart_callback_add(datetime, "changed", input_event_changed_cb, value);
+ }
+
+ btn = elm_object_part_content_get(layout, "elm.icon.2");
+ c_retm_if(NULL == btn, "elm_object_part_content_get() return NULL");
+
+ if (deleted) {
+ elm_object_focus_set(btn, EINA_FALSE);
+ elm_object_disabled_set(btn, EINA_TRUE);
+ }
+ else
+ elm_object_disabled_set(btn, EINA_FALSE);
+}
+
+static void input_event_cancel_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int event_type;
+ ct_input_data *cinput_d;
+ CTSvalue *value = data;
+ Evas_Object *layout;
+
+ cinput_d = evas_object_data_get(obj, "cinput_d");
+ c_retm_if(NULL == cinput_d, "evas_object_data_get() return NULL");
+
+ contacts_svc_value_set_bool(value, CTS_EVENT_VAL_DELETE_BOOL, true);
+
+ event_type = contacts_svc_value_get_int(value, CTS_EVENT_VAL_TYPE_INT);
+ if (CTS_EVENT_TYPE_BIRTH == event_type) {
+ layout = cinput_d->ly_birthday;
+ input_update_event(layout, value);
+ }
+}
+
+
+static Evas_Object* input_fill_layout_birthday(ct_input_data *cinput_d)
+{
+ int event_date;
+ CTSvalue *value;
+ Evas_Object *ly_content;
+ Evas_Object *btn;
+ Evas_Object *datetime;
+
+ ly_content = ct_input_create_dg_layout(cinput_d->box, "1text.2icon");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+
+ /* datetime */
+ datetime = elm_datetime_add(ly_content);
+ c_retvm_if(NULL == datetime, NULL, "elm_datetime_add() return NULL");
+
+ elm_datetime_field_visible_set(datetime, ELM_DATETIME_HOUR, EINA_FALSE);
+ elm_datetime_field_visible_set(datetime, ELM_DATETIME_MINUTE, EINA_FALSE);
+ elm_datetime_field_visible_set(datetime, ELM_DATETIME_AMPM, EINA_FALSE);
+
+ elm_object_part_content_set(ly_content, "elm.icon.1", datetime);
+ evas_object_data_set(datetime, "cinput_d", cinput_d);
+
+ value = ct_input_get_event(cinput_d->contact, CTS_EVENT_TYPE_BIRTH);
+ if (NULL == value)
+ value = input_new_event(cinput_d->contact, CTS_EVENT_TYPE_BIRTH);
+
+ if (contacts_svc_value_get_bool(value, CTS_EVENT_VAL_DELETE_BOOL)) {
+ time_t timer;
+ struct tm *stime = NULL;
+ timer = time(NULL);
+ stime = localtime(&timer);
+ c_retvm_if(NULL == stime, NULL, "localtime() Failed(%d)", errno);
+ elm_datetime_value_set(datetime, stime);
+ }
+ else {
+ struct tm stime;
+ event_date = contacts_svc_value_get_int(value, CTS_EVENT_VAL_DATE_INT);
+ stime.tm_year = event_date/10000 - 1900;
+ stime.tm_mon = (event_date%10000)/100 - 1;
+ stime.tm_mday = event_date%100;
+ elm_datetime_value_set(datetime, &stime);
+ }
+ evas_object_smart_callback_add(datetime, "changed", input_event_changed_cb, value);
+
+ /* reset button */
+ btn = elm_button_add(ly_content);
+ c_retvm_if(NULL == btn, NULL, "elm_button_add() return NULL");
+ elm_object_part_content_set(ly_content, "elm.icon.2", btn);
+ evas_object_propagate_events_set(btn, EINA_FALSE);
+ evas_object_data_set(btn, "cinput_d", cinput_d);
+
+ elm_object_style_set(btn, "cancel");
+ evas_object_smart_callback_add(btn, "clicked", input_event_cancel_clicked_cb, value);
+
+ if (contacts_svc_value_get_bool(value, CTS_EVENT_VAL_DELETE_BOOL))
+ elm_object_disabled_set(btn, EINA_TRUE);
+ else
+ elm_object_disabled_set(btn, EINA_FALSE);
+
+ evas_object_show(ly_content);
+ return ly_content;
+}
+
+static Evas_Object* input_fill_layout_website(ct_input_data *cinput_d)
+{
+ CTSvalue *value;
+ char *val_str;
+ Evas_Object *box = cinput_d->box;
+ Evas_Object *ly_content;
+ Evas_Object *ef, *en;
+
+ ly_content = ct_input_create_dg_layout(box, "1icon");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+
+ value = ct_input_get_website_value(cinput_d->contact);
+ if (NULL == value)
+ value = input_new_web(cinput_d->contact);
+
+ // TODO: Fixme
+ ef = ctui_create_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_WEBSITE), NULL, false);
+ c_retvm_if(NULL == ef, NULL, "ctui_create_editfield() return NULL");
+
+ elm_object_part_content_set(ly_content, "elm.icon", ef);
+
+ val_str = elm_entry_utf8_to_markup(contacts_svc_value_get_str(value, CTS_WEB_VAL_ADDR_STR));
+ en = input_editfield_entry_set(ef, val_str);
+ free(val_str);
+
+ evas_object_smart_callback_add(en, "unfocused", input_website_unfocused_cb, value);
+ evas_object_smart_callback_add(en, "changed", ct_input_entry_changed_cb, ef);
+
+ return ly_content;
+}
+
+static Evas_Object* input_fill_layout_note(ct_input_data *cinput_d)
+{
+ CTSvalue *value;
+ char *val_str;
+ Evas_Object *box = cinput_d->box;
+ Evas_Object *ly_content;
+ Evas_Object *ef, *en;
+
+ ly_content = ct_input_create_dg_layout(box, "1icon");
+ c_retvm_if(NULL == ly_content, NULL, "ct_input_create_dg_layout() return NULL");
+
+ value = ct_detail_get_baseinfo_value(cinput_d->contact);
+
+ ef = ctui_create_editfield(ly_content, T_(CT_GET_TEXT_BASIC, CTTEXT_NOTE), NULL, true);
+ c_retvm_if(NULL == ef, NULL, "ctui_create_editfield() return NULL");
+
+ en = elm_object_part_content_get(ef, "elm.swallow.content");
+ evas_object_smart_callback_add(en, "unfocused", input_note_unfocused_cb, value);
+ evas_object_smart_callback_add(en, "changed", ct_input_entry_changed_cb, ef);
+ elm_object_part_content_set(ly_content, "elm.icon", ef);
+ elm_entry_input_panel_layout_set(en, ELM_INPUT_PANEL_LAYOUT_NORMAL);
+
+ val_str = elm_entry_utf8_to_markup(contacts_svc_value_get_str(value, CTS_BASE_VAL_NOTE_STR));
+ input_editfield_entry_set(ef, val_str);
+ free(val_str);
+
+ return ly_content;
+}
+
+static Eina_Bool input_fill_layout(void *data)
+{
+ const int ITEMS_MAX_CNT = 9;
+ int i;
+ int cnt, cnt_append = 0;
+ Evas_Object *layout;
+ ct_input_data *cinput_d = data;
+
+ for (i = cinput_d->idx_append; i < INPUT_ITEMS_MAX; i++) {
+ switch(i) {
+ case INPUT_BASEINFO:
+ /* base info */
+ layout = input_fill_layout_baseinfo(cinput_d);
+ c_retvm_if(NULL == layout, EINA_FALSE, "ct_input_fill_layout_separator() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ /* separator */
+ layout = ct_input_fill_layout_separator(cinput_d, "separator/hd33/with_line");
+ c_retvm_if(NULL == layout, EINA_FALSE, "ct_input_fill_layout_separator() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ cnt_append += 2;
+ break;
+
+ case INPUT_NUMBER:
+ /* number */
+ ct_input_fill_layout_numbers(cinput_d);
+
+ /* separator */
+ layout = ct_input_fill_layout_separator(cinput_d, "separator/hd33/with_line");
+ c_retvm_if(NULL == layout, EINA_FALSE, "ct_input_fill_layout_separator() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ cnt_append += cinput_d->cnt_num + 1;
+ break;
+
+ case INPUT_EMAIL:
+ /* email */
+ cnt = 0;
+ cnt = ct_input_fill_layout_emails(cinput_d);
+ cnt_append += cnt + 1;
+ break;
+
+ case INPUT_MESSENGER:
+ /* messenger */
+ cnt = input_fill_layout_messengers(cinput_d);
+
+ /* separator */
+ layout = ct_input_fill_layout_separator(cinput_d, "separator/hd33/with_line");
+ c_retvm_if(NULL == layout, EINA_FALSE, "ct_input_fill_layout_separator() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ cnt_append += cnt;
+ break;
+
+ case INPUT_ADDRESS:
+ /* address */
+ input_fill_layout_addresses(cinput_d);
+
+ /* separator */
+ layout = ct_input_fill_layout_separator(cinput_d, "separator/hd33/with_line");
+ c_retvm_if(NULL == layout, EINA_FALSE, "ct_input_fill_layout_separator() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ cnt_append += cinput_d->cnt_addr * 5;
+ break;
+
+ case INPUT_GROUP:
+ /* group */
+ layout = input_fill_layout_group(cinput_d);
+ c_retvm_if(NULL == layout, EINA_FALSE, "input_fill_layout_group() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ cnt_append += 1;
+ break;
+
+ case INPUT_ADDRBOOK:
+ /* address book */
+ if (0 == cinput_d->contact_id) {
+ if (cinput_d->cdetail_d->base_ab < 0) {
+ cinput_d->cdetail_d->base_ab = ct_input_get_base_ab();
+ cinput_d->cdetail_d->base_ab_mode = CTS_ADDRESSBOOK_MODE_NONE;
+ }
+ layout = input_fill_layout_addrbook(cinput_d);
+ c_retvm_if(NULL == layout, EINA_FALSE, "input_fill_layout_addrbook() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+ cnt_append += 1;
+ }
+ break;
+
+ case INPUT_BIRTHDAY:
+ /* Birthday */
+ layout = input_fill_layout_title(cinput_d, T_(CT_GET_TEXT_EVENT_TYPE, CTS_EVENT_TYPE_BIRTH));
+ c_retvm_if(NULL == layout, EINA_FALSE, "input_fill_layout_title() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ layout = input_fill_layout_birthday(cinput_d);
+ c_retvm_if(NULL == layout, EINA_FALSE, "input_fill_layout_birthday() return NULL");
+ cinput_d->ly_birthday = layout;
+
+ elm_box_pack_end(cinput_d->box, layout);
+ cnt_append += 1;
+ break;
+
+ case INPUT_WEBSITE:
+ /* website */
+ layout = input_fill_layout_website(cinput_d);
+ c_retvm_if(NULL == layout, EINA_FALSE,"input_fill_layout_website() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ cnt_append += 1;
+ break;
+
+ case INPUT_NOTE:
+ layout = input_fill_layout_note(cinput_d);
+ c_retvm_if(NULL == layout, EINA_FALSE,"input_fill_layout_note() return NULL");
+ elm_box_pack_end(cinput_d->box, layout);
+
+ cnt_append += 1;
+ break;
+
+ default:
+ ERR("Unknown item(%d)", i);
+ return EINA_FALSE;
+ }
+
+ if (0 == cinput_d->idx_append && ITEMS_MAX_CNT <= cnt_append) {
+ cinput_d->idx_append = i + 1;
+ evas_event_callback_add(evas_object_evas_get(cinput_d->box),
+ EVAS_CALLBACK_RENDER_FLUSH_POST, input_render_flush_post_cb, cinput_d);
+ break;
+ }
+ }
+ return EINA_FALSE;
+}
+
+static Evas_Object* input_create_layout(ct_input_data *cinput_d)
+{
+ Evas_Object *box;
+ Evas_Object *scroller;
+ Evas_Object *conform;
+ ct_detail_data *cdetail_d = cinput_d->cdetail_d;
+
+ elm_win_conformant_set(cdetail_d->win, EINA_TRUE);
+ conform = elm_conformant_add(cdetail_d->navi);
+ c_retvm_if(NULL == conform, NULL, "elm_conformant_add() return NULL");
+
+ elm_object_style_set(conform, "internal_layout");
+ evas_object_show(conform);
+
+ scroller = elm_scroller_add(cdetail_d->navi);
+ c_retvm_if(NULL == scroller, NULL, "elm_scroller_add() return NULL");
+ elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
+ elm_scroller_policy_set(scroller,ELM_SCROLLER_POLICY_OFF,ELM_SCROLLER_POLICY_ON);
+ evas_object_show(scroller);
+ elm_object_content_set(conform, scroller);
+ cinput_d->scroller = scroller;
+
+ box = elm_box_add(scroller);
+ c_retvm_if(NULL == box, NULL, "elm_box_add() return NULL");
+ evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
+ evas_object_event_callback_add(box, EVAS_CALLBACK_MOUSE_UP, ct_detail_mouseup, cinput_d->cdetail_d);
+ elm_object_content_set(scroller, box);
+ evas_object_show(box);
+ cinput_d->box = box;
+
+ cdetail_d->has_input = true;
+ if (!cinput_d->contact) {
+ cinput_d->contact = contacts_svc_struct_new(CTS_STRUCT_CONTACT);
+ if (cdetail_d->base_grp) {
+ GSList *grp_rels = NULL;
+ CTSvalue *grp_info = contacts_svc_value_new(CTS_VALUE_GROUP_RELATION);
+ contacts_svc_value_set_int(grp_info, CTS_GROUPREL_VAL_ID_INT, cdetail_d->base_grp);
+ grp_rels = g_slist_append(grp_rels, grp_info);
+ contacts_svc_struct_store_list(cinput_d->contact, CTS_CF_GROUPREL_LIST, grp_rels);
+ g_slist_free(grp_rels);
+ }
+ }
+
+ input_fill_layout(cinput_d);
+ evas_object_event_callback_add(conform, EVAS_CALLBACK_DEL, input_view_delete_cb, cinput_d);
+ return conform;
+}
+
+static void input_cancel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_input_data *cinput_d = data;
+ ct_detail_data *cdetail_d = cinput_d->cdetail_d;
+
+ /* evas_object_smart_callback_del() func will be deleted */
+ evas_object_smart_callback_del(obj, "clicked", input_cancel_cb);
+
+ elm_naviframe_item_pop(cdetail_d->navi);
+}
+
+void ct_input_push_navi_content(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ Evas_Object *l_btn;
+ Evas_Object *r_btn;
+ Evas_Object *content;
+ Elm_Object_Item *navi_item;
+ const char *navi_title;
+ ct_input_data *cinput_d;
+ ct_detail_data *cdetail_d = data;
+
+ cinput_d = calloc(1, sizeof(ct_input_data));
+ c_retm_if(NULL == cinput_d, "calloc() return NULL");
+ cinput_d->cdetail_d = cdetail_d;
+ cinput_d->contact = contacts_svc_struct_duplicate(cdetail_d->contact);
+ cinput_d->pre_item = elm_naviframe_top_item_get(cdetail_d->navi);
+
+ if (cdetail_d->has_detail) {
+ ct_detail_delete_namecards(cdetail_d);
+ }
+
+ content = input_create_layout(cinput_d);
+ c_retm_if(NULL == content, "input_create_layout() Failed");
+
+ if (cdetail_d->contact_id) {
+ navi_title = S_(CT_SYS_SK_EDIT);
+
+ contacts_svc_begin_trans();
+ cinput_d->view_create_ver = contacts_svc_end_trans(true);
+ ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE,
+ input_contacts_changed, cinput_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_subscribe_change() Failed(%d)", ret);
+ }
+ else
+ navi_title = S_(CT_SYS_BODY_CREATE);
+
+ navi_item = elm_naviframe_item_push(cdetail_d->navi,
+ navi_title, NULL, NULL, content, NULL);
+
+ r_btn = ctui_naviframe_btn(cdetail_d->navi, S_(CT_SYS_SK_CANCEL));
+ if (cdetail_d->ug && NULL == cinput_d->pre_item)
+ evas_object_smart_callback_add(r_btn, "clicked", ctui_ug_destroy_me_cb, cdetail_d->ug);
+ else
+ evas_object_smart_callback_add(r_btn, "clicked", input_cancel_cb, cinput_d);
+ elm_object_item_part_content_set(navi_item, "title_right_btn", r_btn);
+
+ l_btn = ctui_naviframe_btn(cdetail_d->navi, S_(CT_SYS_SK_SAVE));
+ evas_object_smart_callback_add(l_btn, "clicked", ct_input_save_cb, cinput_d);
+ elm_object_item_part_content_set(navi_item, "title_left_btn", l_btn);
+}
diff --git a/lib/details/ct-input-view.h b/lib/details/ct-input-view.h
new file mode 100755
index 0000000..60f7f90
--- /dev/null
+++ b/lib/details/ct-input-view.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_INPUT_VIEW_H__
+#define __CONTACTS_INPUT_VIEW_H__
+
+void ct_input_push_navi_content(void *data, Evas_Object *obj, void *event_info);
+void ct_input_update_image(ct_input_data *cinput_d);
+
+#endif //__CONTACTS_INPUT_VIEW_H__
diff --git a/lib/include/ct-common.h b/lib/include/ct-common.h
new file mode 100755
index 0000000..1305b1c
--- /dev/null
+++ b/lib/include/ct-common.h
@@ -0,0 +1,482 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+
+#ifndef __CONTACTS_COMMON_H__
+#define __CONTACTS_COMMON_H__
+
+#include <time.h>
+#include <libintl.h>
+#include <ui-gadget.h>
+#include <contacts-svc.h>
+
+#include "contacts-ug.h"
+#include "ct-path.h"
+
+#define CT_TIMECHECK
+#ifdef CT_TIMECHECK
+double ct_correction, ct_startT;
+double ct_set_start_time(void);
+double ct_exec_time(double start);
+int ct_init_time(void);
+#define CT_TIME_CHECK \
+ DBG("time = %f ms\n", ct_set_start_time());
+#define CT_START_TIME_CHECK \
+ ct_init_time();\
+ct_startT = ct_set_start_time();
+#define CT_END_TIME_CHECK(fmt, arg...) \
+ DBG(fmt" time = %f ms\n", ##arg, ct_exec_time(ct_startT));
+#else //CT_TIMECHECK
+#define CT_START_TIME_CHECK
+#define CT_END_TIME_CHECK(arg)
+#endif //CT_TIMECHECK
+
+#if !defined(LOCALEDIR)
+# define LOCALEDIR "/opt/ug/res/locale"
+#endif
+
+#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+
+typedef void* PTHREAD_FN;
+
+typedef struct {
+ int position;
+ int skipped_count;
+ char index[4];
+ char prev_index[4];
+ Elm_Object_Item *item;
+} ct_list_index_data;
+
+typedef struct {
+ int cnt;
+ int cnt_loop;
+ int cnt_checked_total;
+ int result;
+ bool alive;
+ bool completed;
+ pthread_t thread;
+ Ecore_Timer *timer;
+ Evas_Object *progressbar;
+ Evas_Object *layout;
+ Evas_Object *label;
+} ct_progress_info;
+
+typedef struct {
+ void *user_data;
+ Evas_Smart_Cb cb;
+ char *icon_path;
+} ctr_btn_info;
+
+typedef struct {
+ Evas_Object *win;
+ Evas_Object *navi;
+ Evas_Object *popup;
+ Evas_Object *genlist;
+
+ Elm_Object_Item *navi_it;
+ Elm_Object_Item *btn_op;
+
+ int count;
+ int grp_id;
+ int base_ab;
+ char *name_old;
+ bool is_rename;
+ bool is_move_copy_view;
+
+ ctr_btn_info ctr_btn_info;
+} ct_group_edit_data;
+
+typedef struct {
+ Evas_Object *win;
+ Evas_Object *box;
+ Evas_Object *cbar;
+ Evas_Object *navi;
+ Evas_Object *content;
+ Elm_Object_Item *navi_item;
+ Evas_Object *layout;
+ Evas_Object *popup;
+ int ug_request;
+ char *title;
+ const char *ug_data;
+ struct ui_gadget *ug;
+ Elm_Theme *th;
+
+ bool is_background;
+
+ cts_order_type order_sorting;
+ cts_order_type order_display;
+
+ Evas_Object *fast_index;
+ Evas_Object *genlist;
+ int list_op;
+ int base_ab;
+ int base_ab_mode;
+ int base_grp;
+ int readed_n;
+ Eina_List *list;
+ Eina_List *list_sdn;
+ Ecore_Idler *list_idler;
+ Ecore_Timer *update_timer;
+ ct_list_index_data *list_skipped_index;
+
+ Evas_Object *searchbar;
+ char *search_str;
+ char *search_normalize;
+
+ Evas_Object *select_all_checkbox;
+ int list_mode;
+ int edit_op;
+ int cnt_total;
+ int cnt_checked;
+ int cnt_list;
+ int cnt_max;
+ int selected_contact;
+ Eina_Bool select_all_checked;
+
+ ct_progress_info *p_info;
+ ct_group_edit_data *cgedit_d;
+}ct_list_data;
+
+typedef struct {
+ Evas_Object *win;
+ Evas_Object *navi;
+ Evas_Object *base;
+ Evas_Object *genlist;
+ GSList *expand_ab;
+ ct_list_data *clist_d;
+} ct_group_data;
+
+typedef struct {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *navi;
+ Elm_Object_Item *navi_item;
+ Elm_Object_Item *prev_navi_item;
+ Evas_Object *popup;
+ Evas_Object *genlist;
+
+ cts_order_type order_display;
+
+ bool is_shortcut;
+ bool has_detail;
+ bool has_input;
+ int touch_x;
+ int touch_y;
+ int base_grp;
+ int base_ab;
+ int base_ab_mode;
+ char *base_ab_name;
+ int contact_id;
+ char* vcard;
+ struct ui_gadget *ug;
+ int view_creat_ver;
+ CTSstruct *contact;
+ ct_list_data *clist_d;
+}ct_detail_data;
+
+typedef struct {
+ Evas_Object *box;
+ Evas_Object *scroller;
+ Elm_Object_Item *pre_item;
+
+ Evas_Object *ly_baseinfo;
+ Evas_Object *ly_baseinfo_middle;
+ Evas_Object *ly_baseinfo_suffix;
+ Evas_Object *ly_baseinfo_nick;
+ Evas_Object *ly_baseinfo_company;
+ Evas_Object *ly_number_first;
+ Evas_Object *ly_number_last;
+ Evas_Object *ly_number_default;
+ Evas_Object *ly_number_set_default;
+ Evas_Object *ly_number_set_default_separator;
+ Evas_Object *ly_email_first;
+ Evas_Object *ly_email_last;
+ Evas_Object *ly_addr_first;
+ Evas_Object *ly_addr_last;
+ Evas_Object *ly_group;
+ Evas_Object *ly_addrbook;
+ Evas_Object *ly_birthday;
+
+ bool saved;
+ int view_create_ver;
+ int cnt_addr;
+ int cnt_num;
+ int idx_append;
+
+ int contact_id;
+ CTSstruct *contact;
+ ct_detail_data *cdetail_d;
+
+ struct ui_gadget *src_ug;
+ struct ui_gadget *crop_ug;
+}ct_input_data;
+
+typedef struct {
+ Evas_Object *ly_main;
+ Evas_Object *ly_content;
+ CTSvalue *value;
+ Evas_Object *data;
+}ct_input_typed_data;
+
+
+typedef struct {
+ Evas_Object *navi_content;
+ Evas_Object *genlist;
+
+ ct_input_data *cinput_d;
+}ct_assign_group_data;
+
+typedef struct {
+ Evas_Object *navi;
+ Evas_Object *popup;
+ Evas_Object *notify;
+ Evas_Object *radio_grp;
+
+ Evas_Object *genlist;
+ Evas_Object *select_all_check;
+ Eina_Bool select_all_checked;
+
+ int id_ab;
+ int mode;
+ char *path;
+ char *name_ab;
+ struct ui_gadget *ug;
+ Eina_List *list_id_ab;
+
+ ct_progress_info *p_info;
+}ct_setting_data;
+
+typedef struct {
+ int id;
+ int type;
+ int mode;
+ char *name;
+ Eina_Bool checked;
+ Elm_Object_Item *item;
+} ct_ab_popup_data;
+
+// for removing build warning ////////////////////////////////////
+char* contacts_svc_value_steal_str(CTSvalue* value, int field);
+////////////////////////////////////////////////////////
+
+
+enum {
+ CT_VIEW_DETAIL,
+ CT_VIEW_INPUT,
+ CT_VIEW_ETC,
+};
+const char* ctui_get_default_contact_img(int view_type);
+int ctui_get_display_name(CTSvalue *name, char *dest, int dest_len);
+void ctui_get_number_type_str(int cts_num_type, char *dest, int dest_len);
+Evas_Object* ctui_create_base_layout(Evas_Object *parent, bool is_fullview);
+Evas_Object* ctui_create_popup(Evas_Object *parent, const char *desc, double timeout);
+
+Evas_Object* ctui_progressbar_popup(Evas_Object *parent, ct_progress_info *p_info);
+void ctui_progress_popup_hide_cb(void *data, Evas_Object *obj, void *event_info);
+void ctui_ld_to_dd(ct_list_data *clist_d, ct_detail_data *cdetail_d);
+void ctui_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, void *priv);
+void ctui_ug_destroy_cb(struct ui_gadget *ug, void *priv);
+void ctui_ug_destroy_me_cb(void *data, Evas_Object *obj, void *event_info);
+void ctui_ug_return_id(struct ui_gadget *ug, int ct_id, int num_id, int email_id);
+
+enum {
+ CTUG_MSG_INVALID = 0,
+ CTUG_MSG_KEY_END = 1,
+};
+void ctui_msg_ug(struct ui_gadget *parent, const char *number, const int idx, const char *attach);
+void ctui_voice_call(const int id, const char* number);
+Evas_Object* ctui_new_confirm_popup(Evas_Object *win, const char* description);
+Evas_Object* ctui_naviframe_btn(Evas_Object *parent, const char *label);
+Evas_Object* ctui_addrbook_popup(Evas_Object *parent, Evas_Smart_Cb gl_sel_cb,
+ void *data, int mode_filter, Evas_Smart_Cb response_cb, void *response_cb_data);
+void ctui_cbar_item_clear(Evas_Object *toolbar);
+void ctui_entry_limit_size_set(Evas_Object *entry);
+Evas_Object* ctui_create_btn(Evas_Object *parent, const char *label);
+void ctui_genlist_append_separator_10px(Evas_Object *genlist);
+void ctui_genlist_append_separator_20px(Evas_Object *genlist);
+void ctui_cbar_btn_disabled_set(Evas_Object *cbar, Eina_Bool disabled);
+char* ctui_entry_markup_to_utf8(const char *s);
+void ctui_entry_entry_set(Evas_Object *entry, const char *s);
+Evas_Object* ctui_create_notify(Evas_Object *parent);
+Evas_Object* ctui_show_notify(Evas_Object *parent, const char *msg, double timeout);
+void ctui_hide_notify(Evas_Object *parent);
+Evas_Object* ctui_set_bg(Evas_Object *parent);
+void ctui_back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info);
+void ctui_list_detail_genlist_append_separator_line_20px(Evas_Object *genlist);
+Evas_Object* ctui_create_nocontents(Evas_Object *parent, const char* label);
+Evas_Object* ctui_create_popup_button(Evas_Object *popup, int index, const char* label, Evas_Smart_Cb cb, void *cb_data);
+Evas_Object* ctui_create_editfield(Evas_Object *parent, const char *title, const char *guide, bool multiline);
+void ct_toolbar_disalbed_item_append(Evas_Object *toolbar, int cnt);
+void ctui_list_ug_hide_cb(void *data, Evas_Object *obj, void *event_info);
+
+enum {
+ CTTEXT_TYPE_MOBILE,
+ CTTEXT_TYPE_TELEPHONE,
+ CTTEXT_TYPE_FAX,
+ CTTEXT_TYPE_OTHER,
+ CTTEXT_TYPE_HOME,
+ CTTEXT_TYPE_WORK,
+ CTTEXT_TYPE_CAR,
+ CTTEXT_TYPE_PAGER,
+ CTTEXT_TYPE_ASSISTANT,
+}; //CT_GET_TEXT_NUM_TYPE
+
+enum {
+ CTTEXT_ALL_CONTACTS,
+ CTTEXT_NOT_ASSIGNED,
+ CTTEXT_SDN,
+ CTTEXT_PHONE,
+ CTTEXT_GROUP,
+ CTTEXT_DEFAULT,
+ CTTEXT_RINGTONE,
+ CTTEXT_WEBSITE,
+ CTTEXT_INSTANT_MESSENGER,
+ CTTEXT_EMAIL,
+ CTTEXT_NUMBER,
+ CTTEXT_NOTE,
+ CTTEXT_POSTAL_ADDRESS,
+ CTTEXT_DETAILS,
+ CTTEXT_COMPANY,
+ CTTEXT_BIRTHDAY,
+ CTTEXT_ADDED_TO_HOME,
+ CTTEXT_ORDER_DISPLAY_NAME,
+ CTTEXT_OWN_NUMBER,
+ CTTEXT_FIRSTNAME,
+ CTTEXT_LASTNAME,
+ CTTEXT_MIDDLE,
+ CTTEXT_SUFFIX,
+ CTTEXT_NICKNAME,
+ CTTEXT_REMOVE_GROUP_ONLY,
+ CTTEXT_REMOVE_GROUP_WITH_MEMBER,
+ CTTEXT_SELECT_EXPORT_ADDRBOOK,
+ CTTEXT_IMPORT_CONTACT_TO,
+ CTTEXT_SELECT_CONTACTS,
+ CTTEXT_POSTAL_CODE,
+ CTTEXT_COUNTRY,
+ CTTEXT_PROVINCE,
+ CTTEXT_CITY,
+ CTTEXT_STREET,
+ CTTEXT_SAVED_IN,
+ CTTEXT_COPIED,
+ CTTEXT_EXPORTED,
+ CTTEXT_DELETING_CONTACTS,
+ CTTEXT_MOVING_CONTACTS,
+ CTTEXT_COPYING_CONTACTS,
+ CTTEXT_IMPORTING_SIM_CONTACTS,
+ CTTEXT_IMPORTING_SD_CONTACTS,
+ CTTEXT_BACKUP_CONTACTS_TO,
+ CTTEXT_IMPORTED,
+ CTTEXT_NA,
+ CTTEXT_NO_SIM,
+}; //CT_GET_TEXT_BASIC
+
+enum {
+ CTTEXT_NONAME,
+ CTTEXT_INVALID_EMAIL,
+ CTTEXT_SAVE_FAIL,
+ CTTEXT_ERR_DB_LOCKED,
+ CTTEXT_ADD_FAIL_EXIST,
+ CTTEXT_ALREADY_EXIST,
+ CTTEXT_NO_GROUP,
+ CTTEXT_NO_NUMBER,
+ CTTEXT_NO_EMAIL,
+ CTTEXT_NO_CONTACTS,
+ CTTEXT_IMPORT_SIM_NO_DATA,
+ CTTEXT_EXCEED_LIMIT,
+ CTTEXT_INITIALISING_TRY_LATER_ING,
+ CTTEXT_DATA_NOT_EXIST,
+};//CT_GET_TEXT_ERR
+
+enum {
+ CTTEXT_SET_DEFAULT_NUM,
+ CTTEXT_IMAGE,
+ CTTEXT_TAKE_A_PHOTO,
+ CTTEXT_DELETE_PHOTO,
+ CTTEXT_ADD_TO_HOME,
+ CTTEXT_SAVE_CONTACT_TO,
+ CTTEXT_IMPORT_SIM_CONTACTS,
+ CTTEXT_FIRSTLAST,
+ CTTEXT_LASTFIRST,
+ CTTEXT_SEND_NAME_CARD,
+ CTTEXT_CONFIRM_DELETE_CONTACT,
+ CTTEXT_NEW_GROUP,
+ CTTEXT_SELECT_GROUP,
+ CTTEXT_EXPORT_CONTACTS,
+ CTTEXT_IMPORT_CONTACTS,
+}; //CT_GET_TEXT_BASE_OP
+
+enum {
+ CT_GET_TEXT_BASIC,
+ CT_GET_TEXT_ERR,
+ CT_GET_TEXT_BASE_OP,
+ CT_GET_TEXT_NUM_TYPE,
+ CT_GET_TEXT_EMAIL_TYPE,
+ CT_GET_TEXT_POSTAL_TYPE,
+ CT_GET_TEXT_EVENT_TYPE,
+ CT_GET_TEXT_IM_TYPE,
+ CT_GET_TEXT_MONTH,
+ CT_GET_TEXT_ACC_TYPE,
+};
+const char* ctui_get_text(int op, int type);
+#define T_(op, type) ctui_get_text(op, type)
+
+enum {
+ CT_SYS_SK_OK,
+ CT_SYS_SK_SAVE,
+ CT_SYS_SK_EDIT,
+ CT_SYS_SK_DONE,
+ CT_SYS_SK_DELETE,
+ CT_SYS_SK_CANCEL,
+ CT_SYS_BODY_CREATE,
+ CT_SYS_BODY_MOVE,
+ CT_SYS_BODY_COPY,
+ CT_SYS_BODY_CALL,
+ CT_SYS_BODY_MESSAGE,
+ CT_SYS_BODY_VIDEO_CALL,
+ CT_SYS_BODY_UNKNOWN,
+ CT_SYS_BODY_PHONE,
+ CT_SYS_BODY_SELECT_ALL,
+ CT_SYS_BODY_SEARCH,
+ CT_SYS_BODY_BLUETOOTH,
+ CT_SYS_BODY_EMAIL,
+ CT_SYS_BODY_CONTACTS,
+ CT_SYS_POP_SELECTED,
+ CT_SYS_POP_SUCCESS,
+ CT_SYS_POP_FAILED,
+ CT_SYS_POP_CLOSE,
+ CT_SYS_POP_ERROR,
+ CT_SYS_POP_DELETED,
+ CT_SYS_POP_REMOVED,
+ CT_SYS_POP_MOVED,
+ CT_SYS_POP_ADDED,
+ CT_SYS_POP_NOT_ENOUGH_MEMORY,
+ CT_SYS_POP_FILE_NOT_FOUND,
+};
+
+const char* ctui_get_system_string(int type);
+#define S_(text) ctui_get_system_string(text)
+
+#endif //__CONTACTS_COMMON_H__
+
diff --git a/lib/include/ct-detail.h b/lib/include/ct-detail.h
new file mode 100755
index 0000000..60d40aa
--- /dev/null
+++ b/lib/include/ct-detail.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_DETAIL_H__
+#define __CONTACTS_DETAIL_H__
+
+#include "ct-common.h"
+
+#define CT_DETAIL_DEFAULT_NUM_COLOR 213, 129, 31, 255
+#define CT_DETAIL_IMAGE_SIZE 128
+
+int ctui_create_detail_view(ct_list_data *clist_d, int id);
+int ctui_create_input_view(ct_detail_data *cdetail_d);
+int ctui_contacts_viewer(Evas_Object *win, int ct_id, const char *vcard_stream);
+Evas_Object* ctui_detail_genlist_update(ct_detail_data *cdetail_d);
+
+#endif //__CONTACTS_DETAIL_H__
diff --git a/lib/include/ct-list.h b/lib/include/ct-list.h
new file mode 100755
index 0000000..9567e76
--- /dev/null
+++ b/lib/include/ct-list.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_LIST_H__
+#define __CONTACTS_LIST_H__
+
+#include "ct-common.h"
+
+#define CT_LIST_MAX_SEARCH_STR 1024
+#define CT_LIST_ICON_SIZE 70
+
+typedef struct {
+ Elm_Object_Item *item;
+ bool img_loaded;
+ bool number_loaded;
+ Eina_Bool checked;
+ char *img_path;
+ char *number;
+ char *display;
+ char *normalize;
+ int id;
+ int id_ret;
+ int id_ab;
+ int mode_ab;
+}ct_contact_list;
+
+typedef struct {
+ int id_ab;
+ int id_grp;
+ int count;
+ int mode;
+ char *name;
+ Eina_Bool selected;
+ Elm_Object_Item *item;
+}ct_group_list;
+
+typedef struct {
+ char *name;
+ char *number;
+}ct_sdn_list;
+
+Evas_Object* ctui_create_list_view(Evas_Object *win);
+void ctui_gedit_push_view(Evas_Object *win, Evas_Object *navi, int id_ab);
+Evas_Object * ctui_gedit_create_view(ct_group_edit_data *cgedit_d);
+void ctui_gedit_navi_toolbar_create_btn(ct_group_edit_data *cgedit_d);
+Eina_Bool ctui_list_genlist_update(void *data);
+void ctui_list_create_group_view(void *data, Evas_Object *obj, void *event_info);
+void ctui_list_new_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info);
+void ctui_gedit_navi_create_btn(ct_group_edit_data *cgedit_d);
+
+#endif //__CONTACTS_LIST_H__
diff --git a/lib/include/ct-path.h b/lib/include/ct-path.h
new file mode 100755
index 0000000..e24be2e
--- /dev/null
+++ b/lib/include/ct-path.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_PATH_H__
+#define __CONTACTS_PATH_H__
+
+#if !defined(IMGDIR)
+# define IMGDIR "/opt/ug/res/images/ug-"PACKAGE
+#endif
+
+#if !defined(EDJDIR)
+# define EDJDIR "/opt/ug/res/edje/ug-"PACKAGE
+#endif
+
+#if !defined(UGDATAIDR)
+# define UGDATAIDR "/opt/data/ug-contacts"
+#endif
+
+#define CONTACTS_EDJ EDJDIR"/contacts.edj"
+
+#define CTUI_IMG_CHECK IMGDIR"/00_check_checking.png"
+#define CTUI_IMG_DEFAULT_PHOTO_70_70 IMGDIR"/caller_ID_default_70x70.png"
+#define CTUI_IMG_DEFAULT_PHOTO_90_90 IMGDIR"/caller_ID_default_90x90.png"
+#define CTUI_IMG_PHOTO_EDIT IMGDIR"/caller_ID_edit.png"
+#define CTUI_IMG_MENU_DELETE IMGDIR"/menu_delete.png"
+#define CTUI_IMG_PHONE IMGDIR"/phone.png"
+
+#define CTUI_IMG_ICON_EDIT IMGDIR"/01_controlbar_icon_edit.png"
+#define CTUI_IMG_ICON_GROUPS IMGDIR"/01_controllbar_icon_groups.png"
+#define CTUI_IMG_ICON_CREATE IMGDIR"/01_controlbar_icon_create.png"
+#define CTUI_IMG_ICON_DELETE IMGDIR"/01_controlbar_icon_delete.png"
+#define CTUI_IMG_ICON_DONE IMGDIR"/01_controlbar_icon_save.png"
+#define CTUI_IMG_ICON_ADD_TO_CONTACTS IMGDIR"/01_controllbar_icon_add_to_contact.png"
+#define CTUI_IMG_ICON_COPY IMGDIR"/01_controlbar_icon_copy.png"
+#define CTUI_IMG_ICON_MOVE IMGDIR"/01_controlbar_icon_move.png"
+#define CTUI_IMG_ICON_DETAIL_EDIT IMGDIR"/01_controlbar_icon_compose.png"
+
+#endif //__CONTACTS_PATH_H__
+
diff --git a/lib/list/CMakeLists.txt b/lib/list/CMakeLists.txt
new file mode 100755
index 0000000..6aa7157
--- /dev/null
+++ b/lib/list/CMakeLists.txt
@@ -0,0 +1,15 @@
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
+
+SET(TARGET ${CT_LIST})
+
+FILE(GLOB SRCS *.c)
+
+ADD_LIBRARY(${TARGET} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES VERSION ${VERSION})
+
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
+TARGET_LINK_LIBRARIES(${TARGET} ${COMMON_LIB} ${ug_pkgs_LDFLAGS} ug-contacts-details-efl)
+
+ADD_DEPENDENCIES(${TARGET} contacts_edj_build contacts_theme_build)
+INSTALL(TARGETS ${TARGET} DESTINATION ${UGLIBDIR})
diff --git a/lib/list/ct-list-contact-view.c b/lib/list/ct-list-contact-view.c
new file mode 100755
index 0000000..b2d1dac
--- /dev/null
+++ b/lib/list/ct-list-contact-view.c
@@ -0,0 +1,1155 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <pthread.h>
+#include <ui-gadget-module.h>
+
+#include "contacts.h"
+#include "ct-detail.h"
+#include "ct-list.h"
+#include "ct-list-utils.h"
+#include "ct-list-view-ug.h"
+#include "ct-list-edit-view.h"
+#include "ct-list-group-view.h"
+#include "ct-list-contact-view.h"
+
+static Elm_Genlist_Item_Class contact_itc, contact_itc_del, contact_itc_sdn;
+static char pre_search_str[CT_LIST_MAX_SEARCH_STR];
+
+#define CT_LIST_FAST_INDEX_LEN 4
+#define SKIPPED_INDEX_LEN 5
+
+// for removing build warning ///////////////////////////////////////
+int contacts_svc_normalize_str(const char *src, char *dest, const int dest_len);
+int contacts_svc_normalized_strstr(const char *str, const char *search_str, int *len);
+///////////////////////////////////////////////////////////////////
+
+#if 0
+static char* list_get_highlight_text(ct_list_data *clist_d, const char *src)
+{
+ char *search;
+ int src_len = strlen(src);
+ char display[src_len + 15]; // 15 - strlen("<highlight></>") + 1
+
+ if (NULL == l_data->search_str)
+ return strdup(src);
+
+ search = strcasestr(src, l_data->search_str);
+ if (search)
+ {
+ int len1 = search - src;
+ int len2 = strlen(l_data->search_str);
+ int len3 = strlen(src) - len2 - len1;
+
+ memcpy(display, src, len1);
+ display[len1] = 0;
+ strcat(display, "<highlight>");
+ memcpy(display + len1 + 11, src + len1, len2);
+ display[len1 + len2 + 11] = 0;
+ strcat(display, "</>");
+ memcpy(display + len1 + len2 + 14, src + len1 + len2, len3);
+ display[src_len + 14] = '\0';
+ return strdup(display);
+ }
+ return strdup(src);
+}
+#endif
+
+static int list_handle_noname(int op, int sub_op, ct_contact_list *item)
+{
+ int ret;
+ CTSvalue *value = NULL;
+ char normalized_str[CT_TEXT_MAX_LEN];
+
+ ret = contacts_svc_get_contact_value(op, item->id, &value);
+ if (CTS_SUCCESS == ret) {
+ free(item->display);
+ free(item->normalize);
+ item->display = contacts_svc_value_steal_str(value, sub_op);
+
+ ret = contacts_svc_normalize_str(item->display, normalized_str, sizeof(normalized_str));
+ if (CTS_SUCCESS <= ret)
+ item->normalize = strdup(normalized_str);
+ else
+ item->normalize = NULL;
+
+ contacts_svc_value_free(value);
+ return TRUE;
+ }
+ else {
+ CT_DBG("op(%d) is NO DATA", op);
+ return FALSE;
+ }
+}
+
+static char* list_gl_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ ct_contact_list *item = data;
+ c_retvm_if(NULL == item, NULL, "The parameter(data) is NULL");
+
+ c_retvm_if(0 != strcmp(part, "elm.text") && 0 != strcmp(part, "elm.slide.text.1"),
+ NULL, "unknown part(%s)", part);
+ if ('\0' == item->display[0]) {
+ int ret;
+
+ ret = list_handle_noname(CTS_GET_COMPANY_VALUE, CTS_COMPANY_VAL_NAME_STR, item);
+ if (TRUE != ret) {
+ ret = list_handle_noname(CTS_GET_DEFAULT_NUMBER_VALUE, CTS_NUM_VAL_NUMBER_STR, item);
+ if (TRUE != ret)
+ list_handle_noname(CTS_GET_DEFAULT_EMAIL_VALUE, CTS_EMAIL_VAL_ADDR_STR, item);
+ }
+ }
+
+ if (item->display && *item->display) {
+ ct_list_data *clist_d = evas_object_data_get(obj, "clist_d");
+ c_retvm_if(NULL == clist_d, strdup(item->display),
+ "evas_object_data_get() return NULL");
+#if 0
+ if (0 == strcmp(part, "elm.slide.text.1"))
+ return strdup(item->display);
+ else
+ return list_get_highlight_text(clist_d, item->display);
+#endif
+ return strdup(item->display);
+ }
+ else
+ return strdup(T_(CT_GET_TEXT_ERR, CTTEXT_NONAME));
+}
+
+static void list_fast_level_up(void *data, Evas_Object *obj, void *event_info)
+{
+ int count = 0;
+ int skipped_count = 0;
+ int level = elm_index_item_level_get(obj);// get the level we are at (presumably 1)
+ const Elm_Object_Item *item;
+ const Elm_Object_Item *index_item;
+ const Elm_Object_Item *skipped_item = NULL;
+ ct_contact_list *item_data;
+ char first_index1[CT_LIST_FAST_INDEX_LEN];
+ char first_index2[CT_LIST_FAST_INDEX_LEN];
+ char second_index1[CT_LIST_FAST_INDEX_LEN];
+ char second_index2[CT_LIST_FAST_INDEX_LEN];
+ char prev_index[CT_LIST_FAST_INDEX_LEN];
+ char skipped_index[CT_LIST_FAST_INDEX_LEN];
+
+ prev_index[0] = '\0';
+ skipped_index[0] = '\0';
+
+ if (1 != level)
+ return;
+
+ // get the item selected at the previous level (0)
+ index_item = elm_index_selected_item_get(obj, level - 1);
+ elm_index_item_clear(obj); // clear the new level
+
+ item = elm_object_item_data_get(index_item);
+ c_retm_if(NULL == item, "elm_object_item_data_get(%p) returns NULL", index_item);
+
+ item_data = elm_object_item_data_get(item);
+ c_retm_if(NULL == item_data, "elm_object_item_data_get(%p) returns NULL", item);
+
+ ct_list_get_fast_index(item_data->display, level-1, first_index1, sizeof(first_index1));
+ ct_list_get_fast_index(item_data->display, level, second_index1, sizeof(second_index1));
+ elm_index_item_append(obj, second_index1, NULL, item);
+ count++;
+ item = elm_genlist_item_next_get(item);
+
+ while (item) {
+ item_data = elm_object_item_data_get(item);
+ if (NULL == item_data) {
+ item = elm_genlist_item_next_get(item);
+ continue;
+ }
+ ct_list_get_fast_index(item_data->display, level-1, first_index2, sizeof(first_index2));
+ ct_list_get_fast_index(item_data->display, level, second_index2, sizeof(second_index2));
+
+ if (0 != strcmp(first_index1, first_index2))
+ break;
+ if (0 != strcmp(second_index1, second_index2)) {
+ if ((CT_LIST_FAST_INDEX_LEN < count)) {
+ if (!strcmp(skipped_index, second_index2)) {
+ elm_index_item_append(obj, second_index2, NULL, skipped_item);
+ count -= skipped_count;
+ }
+ else {
+ elm_index_item_append(obj, second_index2, NULL, item);
+ count = 0;
+ }
+ skipped_index[0] = '\0';
+ skipped_item = NULL;
+ skipped_count = 0;
+ memcpy(second_index1, second_index2, sizeof(second_index2));
+ }
+ else {
+ if (strcmp(skipped_index, second_index2)) {
+ snprintf(skipped_index, sizeof(skipped_index), "%s", second_index2);
+ skipped_item = item;
+ skipped_count = count;
+ }
+ }
+ }
+ count++;
+ item = elm_genlist_item_next_get(item);
+ }
+
+ elm_index_level_go(obj, level); // go for the new level
+}
+
+static void list_fast_level_down(void *data, Evas_Object *obj, void *event_info)
+{
+ return;
+}
+static void list_fast_delayed_changed(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ // called on a change but delayed in case multiple changes happen in a
+ // short timespan
+ elm_genlist_item_bring_in(event_info, ELM_GENLIST_ITEM_SCROLLTO_TOP);
+}
+
+static void list_fast_changed(void *data, Evas_Object *obj, void *event_info)
+{
+ // this is calld on every change, no matter how often
+ return;
+}
+
+static void list_fast_selected(void *data, Evas_Object *obj, void *event_info)
+{
+ // called on final select
+ elm_genlist_item_bring_in(elm_object_item_data_get(event_info), ELM_GENLIST_ITEM_SCROLLTO_TOP);
+}
+
+static inline void list_append_item(ct_list_data *clist_d,
+ ct_contact_list *item_data)
+{
+ Elm_Object_Item *item;
+ ct_list_index_data *skipped_index = clist_d->list_skipped_index;
+ char cur_index[CT_LIST_FAST_INDEX_LEN];
+
+ item = elm_genlist_item_append(clist_d->genlist, &contact_itc, item_data, NULL,
+ ELM_GENLIST_ITEM_NONE, ct_list_ug_gl_sel, clist_d);
+ item_data->item = item;
+
+ clist_d->cnt_total++;
+ if (item_data->checked) clist_d->cnt_checked++;
+ ct_list_get_fast_index(item_data->display, 0, cur_index, CT_LIST_FAST_INDEX_LEN);
+
+ // add index for fast scroll
+ if (strcmp(skipped_index->prev_index, cur_index)) {
+ if (SKIPPED_INDEX_LEN < skipped_index->position || '\0' == skipped_index->prev_index[0]) {
+ snprintf(skipped_index->prev_index, sizeof(skipped_index->prev_index),
+ "%s", cur_index);
+ if (0 == strcmp(skipped_index->index, cur_index)) {
+ elm_index_item_append(clist_d->fast_index, skipped_index->prev_index, NULL,
+ skipped_index->item);
+ skipped_index->position -= skipped_index->skipped_count;
+ }
+ else {
+ elm_index_item_append(clist_d->fast_index, skipped_index->prev_index, NULL, item);
+ skipped_index->position = 0;
+ }
+ skipped_index->index[0] = '\0';
+ skipped_index->item = NULL;
+ skipped_index->skipped_count = 0;
+ }
+ else {
+ if (strcmp(skipped_index->index, cur_index)) {
+ snprintf(skipped_index->index, sizeof(skipped_index->index), "%s", cur_index);
+ skipped_index->item = item;
+ skipped_index->skipped_count = skipped_index->position;
+ }
+ }
+ }
+ skipped_index->position++;
+}
+
+#define N 20
+
+static Eina_Bool list_append_part(void *user_data)
+{
+ int i=0;
+ Eina_List *cursor;
+ ct_contact_list *item_data;
+ ct_list_data *clist_d = user_data;
+
+ cursor = eina_list_nth_list(clist_d->list, clist_d->readed_n);
+ EINA_LIST_FOREACH(cursor, cursor, item_data) {
+ if (i++ == N) break;
+ list_append_item(clist_d, item_data);
+ }
+ if (N < i) {
+ clist_d->readed_n += N;
+ return ECORE_CALLBACK_RENEW;
+ }
+ else {
+ clist_d->list_idler = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+}
+
+static void list_append_all(ct_list_data *clist_d)
+{
+ int i = 0;
+ Eina_List *cursor;
+ ct_contact_list *item_data;
+
+ if (clist_d->list_idler) {
+ ecore_idler_del(clist_d->list_idler);
+ clist_d->list_idler = NULL;
+ }
+
+ memset(clist_d->list_skipped_index, 0x0, sizeof(ct_list_index_data));
+ EINA_LIST_FOREACH(clist_d->list, cursor, item_data) {
+ if (i++ == N) break;
+ list_append_item(clist_d, item_data);
+ }
+ if (N < i) {
+ clist_d->readed_n = N;
+ clist_d->list_idler = ecore_idler_add(list_append_part, clist_d);
+ }
+}
+
+#undef N
+
+static Evas_Object* list_create_navi_content_genlist(Evas_Object* parent)
+{
+ Evas_Object *genlist = elm_genlist_add(parent);
+
+ elm_genlist_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF,
+ ELM_SCROLLER_POLICY_OFF);
+ elm_genlist_block_count_set(genlist, 20);
+ elm_genlist_homogeneous_set(genlist, EINA_TRUE);
+
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ return genlist;
+}
+
+#define N_S 10
+
+static Eina_Bool list_searched_list_append_part(void *user_data)
+{
+ int ret, i=0;
+ int readed = 0;
+ Eina_List *cursor;
+ ct_contact_list *item_data;
+ ct_list_data *clist_d = user_data;
+ int len;
+
+ cursor = eina_list_nth_list(clist_d->list, clist_d->readed_n);
+ EINA_LIST_FOREACH(cursor, cursor, item_data) {
+
+ if (NULL == item_data) continue;
+ ret = contacts_svc_normalized_strstr(item_data->normalize, clist_d->search_normalize, &len);
+ if (0 <= ret) {
+ if (i++ == N_S) break;
+#if 0 /* TODO : remove test code : for verification contacts_svc_normalized_strstr */
+ char middle[CT_TEXT_MAX_LEN] = {0};
+ char first[CT_TEXT_MAX_LEN] = {0};
+ snprintf(first, sizeof(first), "%s", item_data->display);
+ snprintf(middle, len+1, "%s", item_data->display + ret);
+ first[ret] = '\0';
+ CT_DBG("%s -> %s, %s, %s", item_data->display, first, middle, item_data->display + ret + len);
+#endif
+ list_append_item(clist_d, item_data);
+ }
+ readed++;
+ }
+ if (N_S < i) {
+ clist_d->readed_n += readed;
+ return ECORE_CALLBACK_RENEW;
+ }
+ else {
+ clist_d->list_idler = NULL;
+ free(clist_d->search_normalize);
+ clist_d->search_normalize = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+}
+
+static void list_handle_search(ct_list_data *clist_d)
+{
+ int ret, i=0;
+ int readed = 0;
+ int len;
+ Eina_List *cursor;
+ ct_contact_list *item_data;
+ char normalized_str[CT_TEXT_MAX_LEN] = {0};
+
+ ret = contacts_svc_normalize_str(clist_d->search_str, normalized_str, CT_TEXT_MAX_LEN);
+ c_retm_if(ret < CTS_SUCCESS, "contacts_svc_normalize_str() Failed(%d)", ret);
+
+ elm_genlist_clear(clist_d->genlist);
+ elm_index_item_clear(clist_d->fast_index);
+ clist_d->cnt_total = 0;
+ clist_d->cnt_checked = 0;
+
+ if (clist_d->list_idler) {
+ ecore_idler_del(clist_d->list_idler);
+ clist_d->list_idler = NULL;
+ }
+
+ memset(clist_d->list_skipped_index, 0x0, sizeof(ct_list_index_data));
+ EINA_LIST_FOREACH(clist_d->list, cursor, item_data) {
+ if (NULL == item_data) continue;
+ ret = contacts_svc_normalized_strstr(item_data->normalize, normalized_str, &len);
+ if (0 <= ret) {
+ if (i++ == N_S) break;
+#if 0 /* TODO : remove test code : for verification contacts_svc_normalized_strstr */
+ char middle[CT_TEXT_MAX_LEN] = {0};
+ char first[CT_TEXT_MAX_LEN] = {0};
+ snprintf(first, sizeof(first), "%s", item_data->display);
+ snprintf(middle, len+1, "%s", item_data->display + ret);
+ first[ret] = '\0';
+ CT_DBG("%s -> %s, %s, %s", item_data->display, first, middle, item_data->display + ret + len);
+#endif
+ list_append_item(clist_d, item_data);
+ }
+ readed++;
+ }
+ if (N_S < i) {
+ clist_d->readed_n = readed;
+ free(clist_d->search_normalize);
+ clist_d->search_normalize = strdup(normalized_str);
+ clist_d->list_idler = ecore_idler_add(list_searched_list_append_part, clist_d);
+ }
+
+}
+
+#undef N_S
+
+static inline void list_refresh_genlist(ct_list_data *clist_d)
+{
+ elm_genlist_clear(clist_d->genlist);
+ elm_index_item_clear(clist_d->fast_index);
+ clist_d->cnt_total = 0;
+ clist_d->cnt_checked = 0;
+ list_append_all(clist_d);
+}
+
+static void list_searchbar_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ elm_object_focus_set(data, EINA_TRUE);
+}
+
+static void list_searchbar_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ CT_FN_CALL;
+ Evas_Object *en;
+ Evas_Object *sb = data;
+ ct_list_data *clist_d;
+ char *search_str;
+
+ clist_d = evas_object_data_get(sb, "clist_d");
+ c_retm_if(NULL == sb, "evas_object_data_get() return NULL");
+
+ en = elm_object_part_content_get(sb, "elm.swallow.content");
+ c_retm_if(NULL == en, "elm_object_part_content_get() return NULL");
+
+ if (!elm_entry_is_empty(en))
+ elm_object_signal_emit(sb, "elm,state,guidetext,hide", "elm");
+
+
+ if (elm_object_focus_get(sb)) {
+ if (elm_entry_is_empty(en))
+ elm_object_signal_emit(sb, "elm,state,eraser,hide", "elm");
+ else
+ elm_object_signal_emit(sb, "elm,state,eraser,show", "elm");
+ }
+
+ search_str = ctui_entry_markup_to_utf8(elm_entry_entry_get(en));
+ c_retm_if(NULL == search_str, "ctui_entry_markup_to_utf8() return NULL");
+ CT_DBG("search string is %s", search_str);
+
+ free(clist_d->search_str);
+ clist_d->search_str = search_str;
+
+ if (search_str && strcmp(pre_search_str, search_str)) {
+ if (*search_str)
+ list_handle_search(clist_d);
+ else
+ list_refresh_genlist(clist_d);
+ }
+ snprintf(pre_search_str, sizeof(pre_search_str), "%s", search_str);
+
+ if (elm_genlist_decorate_mode_get(clist_d->genlist))
+ ct_list_edit_update_selection_info(clist_d);
+}
+
+static void list_searchbar_focused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm");
+ elm_object_signal_emit(data, "cancel,in", "");
+
+ if (!elm_entry_is_empty(obj))
+ elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
+}
+
+static void list_searchbar_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *cancel_btn;
+ elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
+
+ if (elm_entry_is_empty(obj)) {
+ elm_object_signal_emit(data, "elm,state,guidetext,show", "elm");
+ cancel_btn = elm_object_part_content_get(data, "button_cancel");
+ evas_object_hide(cancel_btn);
+ elm_object_signal_emit(data, "cancel,out", "");
+ }
+}
+
+static void list_searchbar_cancel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *sb = data;
+ Evas_Object *en;
+ ct_list_data *clist_d;
+ const char *text;
+
+ c_retm_if(NULL == sb, "parameter(sb) is NULL");
+
+ clist_d = evas_object_data_get(sb, "clist_d");
+ c_retm_if(NULL == sb, "evas_object_data_get() return NULL");
+
+ en = elm_object_part_content_get(sb, "elm.swallow.content");
+ c_retm_if(NULL == en, "elm_object_part_content_get() return NULL");
+
+ text = elm_entry_entry_get(en);
+ if (text && *text)
+ elm_entry_entry_set(en, NULL);
+ elm_object_focus_set(en, EINA_FALSE);
+
+ list_refresh_genlist(clist_d);
+
+ // problem of set focus automatically on searchbar when resumed app
+ elm_object_focus_set(clist_d->genlist, EINA_TRUE);
+}
+
+static void list_searchbar_eraser_cb(void *data, Evas_Object *obj, const char *emission,
+ const char *source)
+{
+ elm_entry_entry_set(data, "");
+}
+
+static Evas_Object* list_create_searchbar(Evas_Object* parent, ct_list_data *clist_d)
+{
+ Evas_Object *sb;
+ Evas_Object *en;
+ Evas_Object *cancel_btn;
+
+ sb = elm_layout_add(parent);
+ c_retvm_if(NULL == sb, NULL, "elm_layout_add() return NULL");
+ evas_object_data_set(sb, "clist_d", clist_d);
+
+ elm_layout_theme_set(sb, "layout", "searchbar", "cancel_button");
+
+ en = elm_entry_add(sb);
+ elm_entry_scrollable_set(en, EINA_TRUE);
+ elm_entry_single_line_set(en, EINA_TRUE);
+ elm_object_part_content_set(sb, "elm.swallow.content", en);
+ elm_object_part_text_set(sb, "elm.guidetext", S_(CT_SYS_BODY_SEARCH));
+
+ ctui_entry_limit_size_set(en);
+ elm_entry_input_panel_layout_set(en, ELM_INPUT_PANEL_LAYOUT_NORMAL);
+
+ cancel_btn = elm_button_add(sb);
+ elm_object_part_content_set(sb, "button_cancel", cancel_btn);
+ elm_object_style_set(cancel_btn, "searchbar/default");
+ elm_object_text_set(cancel_btn, "Cancel");
+
+ evas_object_smart_callback_add(en, "focused", list_searchbar_focused_cb, sb);
+ evas_object_smart_callback_add(en, "unfocused", list_searchbar_unfocused_cb, sb);
+ evas_object_smart_callback_add(en, "changed", list_searchbar_changed_cb, sb);
+ evas_object_smart_callback_add(en, "preedit,changed", list_searchbar_changed_cb, sb);
+ elm_object_signal_callback_add(sb, "elm,bg,clicked", "elm", list_searchbar_clicked_cb, en);
+ elm_object_signal_callback_add(sb, "elm,eraser,clicked", "elm", list_searchbar_eraser_cb, en);
+ evas_object_smart_callback_add(cancel_btn, "clicked", list_searchbar_cancel_cb, sb);
+
+ return sb;
+}
+
+static void list_gl_sdn_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = event_info;
+ ct_sdn_list *info = elm_object_item_data_get(item);
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ ctui_voice_call(0, info->number);
+}
+
+static Evas_Object* list_fill_sdn_view(Evas_Object *parent, ct_list_data *clist_d)
+{
+ int ret;
+ CTSiter *iter;
+ CTSvalue *info;
+ Evas_Object *genlist;
+
+ genlist = elm_genlist_add(parent);
+ c_retvm_if(NULL == genlist, NULL, "elm_genlist_add() return NULL");
+
+ ret = contacts_svc_get_list(CTS_LIST_ALL_SDN, &iter);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_get_list...() Failed(%d)", ret);
+
+ clist_d->cnt_list = 0;
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ ct_sdn_list *data;
+ info = contacts_svc_iter_get_info(iter);
+ data = calloc(1, sizeof(ct_sdn_list));
+ if (NULL == data) {
+ ERR("calloc() return NULL");
+ break;
+ }
+ data->name = contacts_svc_value_steal_str(info, CTS_LIST_SDN_NAME_STR);
+ data->number = contacts_svc_value_steal_str(info, CTS_LIST_SDN_NUMBER_STR);
+ clist_d->cnt_list++;
+ contacts_svc_value_free(info);
+ elm_genlist_item_append(genlist, &contact_itc_sdn, data, NULL, ELM_GENLIST_ITEM_NONE, list_gl_sdn_sel, NULL);
+ }
+ contacts_svc_iter_remove(iter);
+ return genlist;
+}
+
+
+static Evas_Object* list_create_contact_list(Evas_Object *parent, ct_list_data *clist_d)
+{
+ Evas_Object *layout, *fast_index, *searchbar, *genlist, *conform;
+
+ elm_win_conformant_set(clist_d->win, EINA_TRUE);
+
+ conform = elm_conformant_add(parent);
+ c_retvm_if(NULL == conform, NULL, "elm_conformant_add() return NULL");
+
+ elm_object_style_set(conform, "internal_layout");
+ evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(conform);
+
+ layout = elm_layout_add(conform);
+ elm_layout_file_set(layout, CONTACTS_EDJ, "genlist");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ clist_d->layout = layout;
+
+ searchbar = list_create_searchbar(layout, clist_d);
+ elm_object_part_content_set(layout, "searchbar", searchbar);
+ evas_object_show(searchbar);
+ clist_d->searchbar = searchbar;
+
+ clist_d->box = elm_box_add(layout);
+ evas_object_size_hint_weight_set(clist_d->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(clist_d->box);
+ elm_object_part_content_set(layout, "content", clist_d->box);
+
+ // Create genlist
+ genlist = list_create_navi_content_genlist(clist_d->box);
+ evas_object_show(genlist);
+ clist_d->genlist = genlist;
+
+ elm_box_pack_end(clist_d->box, genlist);
+ evas_object_data_set(genlist, "clist_d", clist_d);
+
+ // Create fast scroll
+ fast_index = elm_index_add(layout);
+ elm_object_part_content_set(layout, "fastscroll", fast_index);
+ evas_object_show(fast_index);
+ clist_d->fast_index = fast_index;
+ evas_object_smart_callback_add(fast_index, "level,up", list_fast_level_up, NULL);
+ evas_object_smart_callback_add(fast_index, "level,down", list_fast_level_down, NULL);
+ evas_object_smart_callback_add(fast_index, "delay,changed", list_fast_delayed_changed,
+ fast_index);
+ evas_object_smart_callback_add(fast_index, "changed", list_fast_changed, NULL);
+ evas_object_smart_callback_add(fast_index, "selected", list_fast_selected, NULL);
+ elm_index_level_go(fast_index, 0);
+
+ // Genlist item append
+ pre_search_str[0] = '\0';
+ if (NULL == clist_d->list_skipped_index)
+ clist_d->list_skipped_index = calloc(1, sizeof(ct_list_index_data));
+
+ list_append_all(clist_d);
+
+ evas_object_show(layout);
+
+ elm_object_content_set(conform, layout);
+ return conform;
+}
+
+API void ctui_list_new_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_list_data *clist_d = data;
+ ct_detail_data *cdetail_d;
+
+ switch (clist_d->ug_request)
+ {
+ case CT_UG_REQUEST_UPDATE_WITH_NUM:
+ case CT_UG_REQUEST_UPDATE_WITH_EMAIL:
+ case CT_UG_REQUEST_UPDATE_WITH_WEB:
+ case CT_UG_REQUEST_SAVE_IMG:
+ ct_list_update_with_data(clist_d, 0);
+ case CT_UG_REQUEST_SAVE_RINGTONE:
+ break;
+
+ default:
+ cdetail_d = calloc(1, sizeof(ct_detail_data));
+ c_retm_if(!cdetail_d, "cdetail_d is NULL, Not enough memory");
+
+ ctui_ld_to_dd(clist_d, cdetail_d);
+
+ if (0 < cdetail_d->base_ab) {
+ int ret, type;
+ CTSvalue *ab_value;
+ char temp[CT_TEXT_SHORT_LEN];
+
+ ret = contacts_svc_get_addressbook(cdetail_d->base_ab, &ab_value);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_get_addressbook() Failed(%d)", ret);
+ cdetail_d->base_ab_mode = contacts_svc_value_get_int(ab_value, CTS_ADDRESSBOOK_VAL_MODE_INT);
+ type = contacts_svc_value_get_int(ab_value, CTS_ADDRESSBOOK_VAL_ACC_TYPE_INT);
+ snprintf(temp, sizeof(temp), "%s(%s)", T_(CT_GET_TEXT_ACC_TYPE, type),
+ contacts_svc_value_get_str(ab_value, CTS_ADDRESSBOOK_VAL_NAME_STR));
+ cdetail_d->base_ab_name = strdup(temp);
+ ret = contacts_svc_value_free(ab_value);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_free() Failed(%d)", ret);
+ }
+ else if (0 == cdetail_d->base_ab) {
+ cdetail_d->base_ab_mode = CTS_ADDRESSBOOK_MODE_NONE;
+ cdetail_d->base_ab_name = strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE));
+ }
+ ctui_create_input_view(cdetail_d);
+ break;
+ }
+}
+
+static inline void list_clean_ecore_task(ct_list_data *clist_d)
+{
+ if (clist_d->list_idler) {
+ ecore_idler_del(clist_d->list_idler);
+ clist_d->list_idler = NULL;
+ }
+}
+
+static inline void list_clear_pdata(ct_list_data *clist_d)
+{
+ CT_FN_CALL;
+ int ret;
+ c_ret_if(NULL == clist_d);
+ c_ret_if(NULL == clist_d->p_info);
+
+ clist_d->p_info->alive = false;
+ pthread_join(clist_d->p_info->thread, NULL);
+
+ ret = contacts_svc_end_trans(false);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+ ecore_timer_del(clist_d->p_info->timer);
+
+ free(clist_d->p_info);
+ clist_d->p_info = NULL;
+}
+
+static void list_lazy_update(void *data)
+{
+ ct_list_data *clist_d = data;
+ if (clist_d->update_timer) {
+ ecore_timer_del(clist_d->update_timer);
+ clist_d->update_timer = NULL;
+ }
+
+ CT_DBG("is_background = %d", clist_d->is_background);
+ if (clist_d->is_background)
+ clist_d->update_timer = ecore_timer_add(3.0, ctui_list_genlist_update, clist_d);
+ else
+ ctui_list_genlist_update(clist_d);
+}
+
+static void list_group_changed_cb(void *data)
+{
+ int ret;
+ ct_list_data *clist_d = data;
+ CTSvalue *group;
+
+ c_ret_if(CT_GET_LIST_CONTACTS_OF_GROUP_ID != clist_d->list_op);
+ ret = contacts_svc_get_group(clist_d->base_grp, &group);
+ if (CTS_SUCCESS != ret) {
+ clist_d->list_op = CT_GET_LIST_ALL_CONTACTS;
+ clist_d->base_grp = 0;
+ FREEandSTRDUP(clist_d->title, T_(CT_GET_TEXT_BASIC, CTTEXT_ALL_CONTACTS));
+ list_lazy_update(clist_d);
+ }
+}
+
+static void list_view_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_list_data *clist_d = data;
+
+ list_clear_pdata(clist_d);
+ list_clean_ecore_task(clist_d);
+
+ ret = contacts_svc_unsubscribe_change_with_data(CTS_SUBSCRIBE_CONTACT_CHANGE,
+ list_lazy_update, clist_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_unsubscribe_change_with_data() Failed(%d)", ret);
+
+ ret = contacts_svc_unsubscribe_change_with_data(CTS_SUBSCRIBE_GROUP_CHANGE,
+ list_group_changed_cb, clist_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_unsubscribe_change_with_data() Failed(%d)", ret);
+
+ ct_list_free_contacts(clist_d->list);
+
+ if (clist_d->update_timer)
+ ecore_timer_del(clist_d->update_timer);
+
+ free(clist_d->search_str);
+ free(clist_d->search_normalize);
+ free(clist_d->list_skipped_index);
+ free(clist_d->title);
+ free(clist_d);
+}
+
+static void list_fill_contact_view(Evas_Object *parent, ct_list_data *clist_d)
+{
+ Evas_Object *content = NULL;
+
+ if (clist_d->list) {
+ if (NULL == clist_d->genlist) {
+ content = list_create_contact_list(parent, clist_d);
+ if (CT_LIST_MODE_EDIT == clist_d->list_mode)
+ elm_genlist_decorate_mode_set(clist_d->genlist, EINA_TRUE);
+
+ elm_object_part_content_set(parent, "elm.swallow.content", content);
+ }
+ else {
+ if (clist_d->search_str && *clist_d->search_str)
+ list_handle_search(clist_d);
+ else
+ list_refresh_genlist(clist_d);
+ }
+ }
+ else {
+ Evas_Object *content;
+ list_clean_ecore_task(clist_d);
+ content = ctui_create_nocontents(parent, T_(CT_GET_TEXT_ERR, CTTEXT_NO_CONTACTS));
+
+ elm_object_part_content_set(parent, "elm.swallow.content", content);
+ clist_d->genlist = NULL;
+
+ free(clist_d->search_str);
+ clist_d->search_str = NULL;
+ clist_d->searchbar = NULL;
+ clist_d->cnt_total = 0;
+ }
+}
+
+void ct_list_searchbar_update(ct_list_data *clist_d)
+{
+ if (CT_GET_LIST_SDN == clist_d->list_op) {
+ if (clist_d->searchbar) {
+ elm_object_part_content_unset(clist_d->layout, "searchbar");
+ evas_object_del(clist_d->searchbar);
+ clist_d->searchbar = NULL;
+ }
+ }
+ else if (clist_d->searchbar) {
+ Evas_Object *en;
+
+ free(clist_d->search_str);
+ clist_d->search_str = NULL;
+ pre_search_str[0] = '\0';
+ en = elm_object_part_content_get(clist_d->searchbar, "elm.swallow.content");
+ elm_entry_entry_set(en, NULL);
+ }
+}
+
+static void list_edit_btn_update(ct_list_data *clist_d)
+{
+ Elm_Object_Item *edit_item;
+ Elm_Object_Item *new_item;
+
+ edit_item = evas_object_data_get(clist_d->cbar, "edit_item");
+ c_retm_if(NULL == edit_item, "evas_object_data_get() return NULL");
+
+ if (NULL == clist_d->list || CT_GET_LIST_SDN == clist_d->list_op)
+ elm_object_item_disabled_set(edit_item, EINA_TRUE);
+ else
+ elm_object_item_disabled_set(edit_item, EINA_FALSE);
+
+ new_item = evas_object_data_get(clist_d->cbar, "new_item");
+ c_retm_if(NULL == new_item, "evas_object_data_get() return NULL");
+
+ if (CTS_ADDRESSBOOK_MODE_READONLY == clist_d->base_ab_mode || CT_GET_LIST_SDN == clist_d->list_op)
+ elm_object_item_disabled_set(new_item, EINA_TRUE);
+ else
+ elm_object_item_disabled_set(new_item, EINA_FALSE);
+}
+
+static void list_make_cbar(ct_list_data *clist_d)
+{
+ if (clist_d->ug && !clist_d->ug_request) {
+ elm_toolbar_item_append(clist_d->cbar, CTUI_IMG_ICON_GROUPS, NULL, ctui_list_create_group_view, clist_d);
+ ct_toolbar_disalbed_item_append(clist_d->cbar, 3);
+ }
+ else {
+ Evas_Object *l_btn;
+ Elm_Object_Item *new_item;
+ Elm_Object_Item *done_item;
+ Elm_Object_Item *edit_item;
+
+ /* back button */
+ if (NULL == clist_d->ug || clist_d->ug_request < CT_UG_REQUEST_SELECT_CONTACT) {
+ l_btn = elm_button_add(clist_d->navi);
+ c_retm_if(NULL == l_btn, "elm_button_add() return NULL");
+
+ elm_object_style_set(l_btn, "naviframe/back_btn/default");
+ if (clist_d->ug_request)
+ evas_object_smart_callback_add(l_btn, "clicked", ctui_ug_destroy_me_cb, clist_d->ug);
+ else
+ evas_object_smart_callback_add(l_btn, "clicked", ctui_back_btn_clicked_cb, clist_d->win);
+ elm_object_item_part_content_set(clist_d->navi_item, "prev_btn", l_btn);
+ }
+
+ /* edit button */
+ if (!clist_d->ug_request) {
+ edit_item = elm_toolbar_item_append(clist_d->cbar, CTUI_IMG_ICON_EDIT, NULL, ct_list_edit_button_cb, clist_d);
+ evas_object_data_set(clist_d->cbar, "edit_item", edit_item);
+ list_edit_btn_update(clist_d);
+ }
+
+ /* group button */
+ elm_toolbar_item_append(clist_d->cbar, CTUI_IMG_ICON_GROUPS, NULL, ctui_list_create_group_view, clist_d);
+
+ if (l_btn && NULL == edit_item) {
+ ct_toolbar_disalbed_item_append(clist_d->cbar, 3);
+ }
+
+ /* create or done button */
+ if (CT_UG_REQUEST_CHECK == clist_d->ug_request ||
+ CT_UG_REQUEST_CHECK_FOR_NUMBER == clist_d->ug_request ||
+ CT_UG_REQUEST_CHECK_FOR_EMAIL == clist_d->ug_request) {
+ done_item = elm_toolbar_item_append(clist_d->cbar, CTUI_IMG_ICON_DONE, NULL, ct_list_edit_check_done, clist_d);
+ elm_object_item_disabled_set(done_item, EINA_TRUE);
+ evas_object_data_set(clist_d->cbar, "done_item", done_item);
+ }
+ else {
+ new_item = elm_toolbar_item_append(clist_d->cbar, CTUI_IMG_ICON_CREATE, NULL, ctui_list_new_btn_clicked_cb, clist_d);
+ if (CTS_ADDRESSBOOK_MODE_READONLY == clist_d->base_ab_mode)
+ elm_object_item_disabled_set(new_item, EINA_TRUE);
+ evas_object_data_set(clist_d->cbar, "new_item", new_item);
+ }
+
+ if (l_btn && NULL == edit_item) {
+ ct_toolbar_disalbed_item_append(clist_d->cbar, 3);
+ }
+
+ /* cancel button */
+ if (NULL == l_btn) {
+ l_btn = ctui_naviframe_btn(clist_d->navi, S_(CT_SYS_SK_CANCEL));
+ evas_object_smart_callback_add(l_btn, "clicked", ctui_ug_destroy_me_cb, clist_d->ug);
+ elm_object_item_part_content_set(clist_d->navi_item, "prev_btn", l_btn);
+ }
+ }
+}
+
+static Evas_Object* list_gl_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ ct_contact_list* ct_info = data;
+ ct_list_data *clist_d = evas_object_data_get(obj, "clist_d");
+
+ c_retvm_if(NULL == ct_info, NULL, "ct_info is NULL");
+
+ if (0 == strcmp(part, "elm.icon")) {
+ const char *path;
+ Evas_Object *icon;
+
+ if (!ct_info->img_loaded) {
+ contacts_svc_get_image(CTS_IMG_NORMAL, ct_info->id, &ct_info->img_path);
+ ct_info->img_loaded = true;
+ }
+
+ path = ct_info->img_path;
+ if (NULL == path) return NULL;
+
+ icon = elm_icon_add(obj);
+ if (icon) {
+ elm_icon_prescale_set(icon, CT_LIST_ICON_SIZE);
+ elm_icon_file_set(icon, path, NULL);
+ evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ evas_object_show(icon);
+ }
+ return icon;
+ }
+ else if (0 == strcmp(part, "elm.edit.icon.1")) {
+ Evas_Object *check;
+ check = ct_list_edit_add_check(obj, &ct_info->checked, clist_d);
+ c_retvm_if(NULL == check, NULL, "ct_list_edit_add_check() return NULL");
+ evas_object_data_set(check, "ct_info", ct_info);
+ return check;
+ }
+ return NULL;
+}
+
+static char* list_gl_sdn_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ ct_sdn_list *info = data;
+ c_retvm_if(NULL == data, NULL, "The parameter(data) is NULL");
+
+ if (0 == strcmp(part, "elm.text.1"))
+ return SAFE_STRDUP(info->name);
+ else if (0 == strcmp(part, "elm.text.2"))
+ return SAFE_STRDUP(info->number);
+ return NULL;
+}
+
+static void list_gl_sdn_del(void *data, Evas_Object *obj)
+{
+ ct_sdn_list *info = data;
+ c_retm_if(NULL == info, "parameter(info) is NULL");
+
+ free(info->name);
+ free(info->number);
+ free(info);
+}
+
+static void list_create_itcs(ct_list_data *clist_d)
+{
+ contact_itc.item_style = "1text.1icon.5";
+ contact_itc.decorate_item_style = "mode/slide3";
+ contact_itc.func.text_get = list_gl_label_get;
+ contact_itc.func.content_get = list_gl_icon_get;
+ contact_itc.decorate_all_item_style = "edit_default";
+
+ contact_itc_del.item_style = "1text.1icon.5";
+ contact_itc_del.decorate_item_style = "mode/slide";
+ contact_itc_del.func.text_get = list_gl_label_get;
+ contact_itc_del.func.content_get = list_gl_icon_get;
+ contact_itc_del.decorate_all_item_style = "edit_default";
+
+ contact_itc_sdn.item_style = "2text.2";
+ contact_itc_sdn.func.text_get = list_gl_sdn_label_get;
+ contact_itc_sdn.func.del = list_gl_sdn_del;
+}
+
+API void ct_list_navi_set(int mode, ct_list_data *clist_d)
+{
+ if (NULL == clist_d->cbar) {
+ clist_d->cbar = elm_toolbar_add(clist_d->navi);
+ c_retm_if(NULL == clist_d->cbar, "elm_toolbar_add() return NULL");
+ elm_toolbar_shrink_mode_set(clist_d->cbar, ELM_TOOLBAR_SHRINK_EXPAND);
+ elm_object_item_part_content_set(clist_d->navi_item, "controlbar", clist_d->cbar);
+ }
+ else {
+ evas_object_data_del(clist_d->cbar, "done_item");
+ evas_object_data_del(clist_d->cbar, "edit_item");
+ evas_object_data_del(clist_d->cbar, "new_item");
+ ctui_cbar_item_clear(clist_d->cbar);
+ }
+
+ switch (mode) {
+ case CT_LIST_MODE_DEFAULT:
+ list_make_cbar(clist_d);
+ break;
+ case CT_LIST_MODE_EDIT:
+ ct_list_edit_make_edit_cbar(clist_d);
+ break;
+ default:
+ return;
+ }
+}
+
+Evas_Object* ct_list_create_contact_view(ct_list_data *clist_d)
+{
+ int ret;
+ Evas_Object *layout;
+
+ layout = ctui_create_base_layout(clist_d->navi, false);
+
+ list_create_itcs(clist_d);
+ list_fill_contact_view(layout, clist_d);
+
+ ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE,
+ list_lazy_update, clist_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_subscribe_change() Failed(%d)", ret);
+
+ ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE,
+ list_group_changed_cb, clist_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_subscribe_change() Failed(%d)", ret);
+
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL,
+ list_view_delete_cb, clist_d);
+ return layout;
+}
+
+void ct_list_create_genlist_sdn(void *data)
+{
+ char buf[CT_TEXT_SHORT_LEN];
+ Evas_Object *content;
+ ct_list_data *clist_d = data;
+
+ c_retm_if(NULL == clist_d->navi_item, "navi_item is NULL");
+
+ ct_list_free_contacts(clist_d->list);
+ clist_d->list = NULL;
+
+ snprintf(buf, sizeof(buf), "%s (%d)", clist_d->title, clist_d->cnt_list);
+ elm_object_item_text_set(clist_d->navi_item, buf);
+
+ if (clist_d->genlist) {
+ evas_object_del(clist_d->genlist);
+ clist_d->genlist = NULL;
+ }
+ content = elm_object_item_content_get(clist_d->navi_item);
+ elm_object_part_content_set(content, "elm.swallow.content", list_fill_sdn_view(content, clist_d));
+
+ list_edit_btn_update(clist_d);
+}
+
+API Eina_Bool ctui_list_genlist_update(void *data)
+{
+ CT_FN_CALL;
+ char buf[CT_TEXT_SHORT_LEN];
+ Evas_Object *content;
+ ct_list_data *clist_d = data;
+
+ if (clist_d->update_timer) {
+ ecore_timer_del(clist_d->update_timer);
+ clist_d->update_timer = NULL;
+ }
+
+ if (clist_d->list_op == CT_GET_LIST_SDN)
+ return ECORE_CALLBACK_CANCEL;
+ c_retvm_if(NULL == clist_d->navi_item, ECORE_CALLBACK_CANCEL, "navi_item is NULL");
+
+ ct_list_free_contacts(clist_d->list);
+ clist_d->list = ct_list_get_contacts(clist_d);
+ clist_d->cnt_total = 0;
+
+ snprintf(buf, sizeof(buf), "%s (%d)", clist_d->title, clist_d->cnt_list);
+ elm_object_item_text_set(clist_d->navi_item, buf);
+
+ content = clist_d->content;
+ list_fill_contact_view(content, clist_d);
+ list_edit_btn_update(clist_d);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
diff --git a/lib/list/ct-list-contact-view.h b/lib/list/ct-list-contact-view.h
new file mode 100755
index 0000000..eb114d6
--- /dev/null
+++ b/lib/list/ct-list-contact-view.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_LIST_CONTACT_VIEW_H__
+#define __CONTACTS_LIST_CONTACT_VIEW_H__
+
+enum {
+ CT_LIST_VIEW_NORMAL,
+ CT_LIST_VIEW_EDIT,
+};
+
+void ct_list_create_genlist_sdn(void *data);
+Evas_Object* ct_list_create_contact_view(ct_list_data *clist_d);
+void ct_list_navi_set(int mode, ct_list_data *clist_d);
+void ct_list_searchbar_update(ct_list_data *clist_d);
+void ct_list_edit_select_all(ct_list_data *clist_d);
+
+#endif //__CONTACTS_LIST_CONTACT_VIEW_H__
diff --git a/lib/list/ct-list-edit-view.c b/lib/list/ct-list-edit-view.c
new file mode 100755
index 0000000..b37c6e8
--- /dev/null
+++ b/lib/list/ct-list-edit-view.c
@@ -0,0 +1,881 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <pthread.h>
+#include <ui-gadget-module.h>
+
+#include "contacts.h"
+#include "ct-list.h"
+#include "ct-list-utils.h"
+#include "ct-list-view-ug.h"
+#include "ct-list-contact-view.h"
+
+#define TIMER_DURATION 0.2
+
+static inline void list_edit_realized_items_checked_set(Evas_Object *genlist,
+ Eina_Bool checked)
+{
+ Elm_Object_Item *item;
+
+ item = elm_genlist_first_item_get(genlist);
+ while (item) {
+ ct_contact_list *info = elm_object_item_data_get(item);
+ item = elm_genlist_item_next_get(item);
+ if (NULL == info) {
+ ERR("elm_object_item_data_get() return NULL");
+ continue;
+ }
+ info->checked = checked;
+ }
+ elm_genlist_realized_items_update(genlist);
+}
+
+static inline void list_edit_all_items_checked_set(Eina_List *list,
+ Eina_Bool checked)
+{
+ Eina_List *l;
+ ct_contact_list *info;
+
+ EINA_LIST_FOREACH(list, l, info) {
+ if (NULL == info) {
+ ERR("elm_object_item_data_get() return NULL");
+ continue;
+ }
+ info->checked = checked;
+ }
+}
+
+void ct_list_edit_mode_end(ct_list_data *clist_d)
+{
+ Evas_Object *layout;
+ Evas_Object *en;
+ char buf[CT_TEXT_SHORT_LEN];
+
+ clist_d->list_mode = CT_LIST_VIEW_NORMAL;
+
+ if (clist_d->select_all_checkbox) {
+ layout = evas_object_data_get(clist_d->select_all_checkbox, "layout");
+ elm_box_unpack(clist_d->box, layout);
+ evas_object_del(layout);
+ clist_d->select_all_checkbox = NULL;
+ }
+
+ clist_d->cnt_checked = 0;
+ clist_d->select_all_checked = EINA_FALSE;
+ list_edit_all_items_checked_set(clist_d->list, EINA_FALSE);
+
+ elm_genlist_decorate_mode_set(clist_d->genlist, EINA_FALSE);
+ ct_list_navi_set(CT_LIST_MODE_DEFAULT, clist_d);
+
+ snprintf(buf, sizeof(buf), "%s (%d)", clist_d->title, clist_d->cnt_list);
+ elm_object_item_text_set(clist_d->navi_item, buf);
+
+ en = elm_object_part_content_get(clist_d->searchbar, "elm.swallow.content");
+ elm_entry_entry_set(en, NULL);
+}
+
+static void list_edit_cancel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_list_data *clist_d = data;
+ ctui_hide_notify(clist_d->navi);
+ ct_list_edit_mode_end(data);
+}
+
+static PTHREAD_FN list_edit_del_contacts(void *data)
+{
+ Elm_Object_Item *item;
+ ct_list_data *clist_d = data;
+ ct_progress_info *p_info = clist_d->p_info;
+
+ item = elm_genlist_first_item_get(clist_d->genlist);
+ while (item) {
+ ct_contact_list *info;
+
+ if (!p_info->alive) {
+ p_info->result = FALSE;
+ break;
+ }
+
+ info = elm_object_item_data_get(item);
+ if (info && info->checked) {
+ if (CTS_SUCCESS != contacts_svc_delete_contact(info->id)) {
+ p_info->result = FALSE;
+ p_info->completed = true;
+ break;
+
+ }
+ if (++p_info->cnt == p_info->cnt_checked_total)
+ break;
+ }
+
+ item = elm_genlist_item_next_get(item);
+ }
+
+ pthread_exit(NULL);
+}
+
+static void list_edit_process_end(void *data)
+{
+ ct_list_data *clist_d = data;
+ ct_progress_info *p_info = clist_d->p_info;
+
+ clist_d->p_info = NULL;
+
+ if (p_info->result)
+ ct_list_edit_mode_end(clist_d);
+
+ free(p_info);
+}
+
+static Eina_Bool list_edit_del_timer_cb(void *data)
+{
+ ct_list_data *clist_d = data;
+ ct_progress_info *p_info = clist_d->p_info;
+
+ c_retvm_if(NULL == p_info, ECORE_CALLBACK_CANCEL, "parameter(clist_d) is NULL");
+
+ if (!p_info->completed) {
+ char count[CT_TEXT_SHORT_LEN];
+ char percent[CT_TEXT_SHORT_LEN];
+ double value = (double)p_info->cnt / (double)p_info->cnt_checked_total;
+
+ if (!p_info->alive) {
+ p_info->result = FALSE;
+ p_info->completed = true;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ elm_progressbar_value_set(p_info->progressbar, value);
+ snprintf(percent, sizeof(percent), "%d%%", (int)(100.0 * (double)p_info->cnt/(double)p_info->cnt_checked_total));
+ snprintf(count, sizeof(count), "%d/%d", p_info->cnt, p_info->cnt_checked_total);
+ edje_object_part_text_set(elm_layout_edje_get(p_info->layout), "elm.text.subtext1", percent);
+ edje_object_part_text_set(elm_layout_edje_get(p_info->layout), "elm.text.subtext2", count);
+
+ if (p_info->cnt == p_info->cnt_checked_total)
+ p_info->completed = true;
+
+ return ECORE_CALLBACK_RENEW;
+ }
+ else {
+ int ret;
+ const char *message;
+
+ pthread_join(p_info->thread, NULL);
+
+ if (TRUE == p_info->result) {
+ message = S_(CT_SYS_POP_DELETED);
+ ret = contacts_svc_end_trans(true);
+ }
+ else {
+ message = S_(CT_SYS_POP_FAILED);
+ ret = contacts_svc_end_trans(false);
+ }
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+
+ evas_object_del(clist_d->popup);
+
+ list_edit_process_end(clist_d);
+ ctui_show_notify(clist_d->navi, message, 2.0);
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+}
+
+static void list_edit_del_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_list_data *clist_d = data;
+ ct_progress_info *p_info;
+ Evas_Object *btn;
+
+ p_info = calloc(1, sizeof(ct_progress_info));
+ c_retm_if(NULL == p_info, "calloc return NULL");
+
+ clist_d->p_info = p_info;
+ p_info->cnt_checked_total = clist_d->cnt_checked;
+ p_info->alive = true;
+ p_info->result = TRUE;
+
+ ret = contacts_svc_begin_trans();
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_begin_trans() Failed(%d)", ret);
+ free(p_info);
+ clist_d->p_info = NULL;
+ return;
+ }
+
+ ret = pthread_create(&p_info->thread, NULL, list_edit_del_contacts, clist_d);
+ if (0 != ret) {
+ ERR("Thread creation failed(%d)", ret);
+ free(p_info);
+ clist_d->p_info = NULL;
+
+ ret = contacts_svc_end_trans(false);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+
+ return;
+ }
+
+ p_info->timer = ecore_timer_add(TIMER_DURATION, list_edit_del_timer_cb, clist_d);
+ if (NULL == p_info->timer) {
+ ERR("ecore_timer_add() return NULL");
+
+ p_info->alive = false;
+ pthread_join(p_info->thread, NULL);
+
+ free(p_info);
+ clist_d->p_info = NULL;
+
+ ret = contacts_svc_end_trans(false);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+
+ return;
+ }
+
+ clist_d->popup = ctui_progressbar_popup(clist_d->win, p_info);
+ elm_object_text_set(p_info->label, T_(CT_GET_TEXT_BASIC, CTTEXT_DELETING_CONTACTS));
+ btn = ctui_create_popup_button(clist_d->popup, 1, S_(CT_SYS_SK_CANCEL), ctui_progress_popup_hide_cb, &p_info->alive);
+ evas_object_data_set(btn, "p_popup", &clist_d->popup);
+}
+
+enum {
+ CT_LIST_EDIT_MOVE = 1,
+ CT_LIST_EDIT_COPY = 2,
+};
+
+struct list_ginfo{
+ int id_grp;
+ int id_ab;
+};
+
+static int list_copy_and_add_contact(int index, struct list_ginfo *sel_grp_info)
+{
+ int cur_ab;
+ int ret;
+ int i = 0;
+ CTSstruct *new_contact = NULL;
+ GSList *list, *l;
+
+ c_retvm_if(NULL == sel_grp_info, -1, "parameter is null");
+ ret = contacts_svc_get_contact(index, &new_contact);
+ c_retvm_if(ret < CTS_SUCCESS, -1, "contacts_svc_get_contact is failed(%d)", ret);
+ list = NULL;
+ contacts_svc_struct_get_list(new_contact, CTS_CF_GROUPREL_LIST, &list);
+ for (l=list;l;l=l->next)
+ contacts_svc_value_set_bool(l->data, CTS_GROUPREL_VAL_DELETE_BOOL, true);
+
+ cur_ab = sel_grp_info[i].id_ab;
+ for (;sel_grp_info[i].id_ab == cur_ab && 0 < sel_grp_info[i].id_grp;i++) {
+ CTSvalue *group = contacts_svc_value_new(CTS_VALUE_GROUP_RELATION);
+ if (group) {
+ contacts_svc_value_set_int(group, CTS_GROUPREL_VAL_ID_INT, sel_grp_info[i].id_grp);
+ list = g_slist_append(list, group);
+ }
+ else {
+ ERR("contacts_svc_value_new is failed: CTS_VALUE_GROUP_RELATION");
+ contacts_svc_struct_free(new_contact);
+ return -1;
+ }
+ }
+ if (g_slist_length(list) != 0)
+ contacts_svc_struct_store_list(new_contact, CTS_CF_GROUPREL_LIST, list);
+
+ ret = contacts_svc_insert_contact(cur_ab , new_contact);
+ if (ret < CTS_SUCCESS){
+ ERR("contacts_svc_insert_contact is failed(%d)", ret);
+ contacts_svc_struct_free(new_contact);
+ return -1;
+ }
+ contacts_svc_struct_free(new_contact);
+
+ return i;
+}
+
+static int list_edit_move_copy_contact_to_group(int contact_id,
+ struct list_ginfo *sel_grp_info, int count, int cur_ab, int cur_grp, bool rm_cur_grp)
+{
+ CTSstruct *contact;
+ GSList *list, *cursor;
+ int i, ret, group_count;
+ bool changed = false;
+
+ contact = NULL;
+ ret = contacts_svc_get_contact(contact_id, &contact);
+ c_retvm_if(ret < CTS_SUCCESS, FALSE, "contacts_svc_get_contact failed (%d)", ret);
+
+ list = NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_GROUPREL_LIST, &list);
+
+ for (i=0;i < count;) {
+ bool exist = false;
+ int jump = 0;
+ if (sel_grp_info[i].id_ab != cur_ab){
+ jump = list_copy_and_add_contact(contact_id, &sel_grp_info[i]);
+ if (jump < 0) {
+ ERR("list_copy_and_add_contact failed(%d)", jump);
+ contacts_svc_struct_free(contact);
+ return FALSE;
+ }
+ i += jump;
+ continue;
+ }
+ for (cursor=list;cursor;cursor=cursor->next) {
+ int grp_id = contacts_svc_value_get_int(cursor->data, CTS_GROUPREL_VAL_ID_INT);
+ if (sel_grp_info[i].id_grp == grp_id){
+ exist = true;
+ break;
+ }
+ }
+
+ if (!exist) {
+ CTSvalue *group = contacts_svc_value_new(CTS_VALUE_GROUP_RELATION);
+ if (NULL == group) {
+ ERR("contacts_svc_value_new failed : CTS_VALUE_GROUP_RELATION");
+ contacts_svc_struct_free(contact);
+ return FALSE;
+ }
+ contacts_svc_value_set_int(group, CTS_GROUPREL_VAL_ID_INT, sel_grp_info[i].id_grp);
+ list = g_slist_append(list, group);
+ changed = true;
+ }
+ i++;
+ }
+
+ if (rm_cur_grp) {
+ if ( 0 < cur_grp){
+ for (cursor = list;cursor;cursor=cursor->next) {
+ int grp_id = contacts_svc_value_get_int(cursor->data, CTS_GROUPREL_VAL_ID_INT);
+ if (cur_grp == grp_id) {
+ contacts_svc_value_set_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL, true);
+ changed = true;
+ break;
+ }
+ }
+ }
+ group_count = 0;
+ for (cursor = list;cursor;cursor=cursor->next) {
+ if (!contacts_svc_value_get_bool(cursor->data, CTS_GROUPREL_VAL_DELETE_BOOL))
+ group_count++;
+ }
+ }
+
+ if (rm_cur_grp && 0 == group_count)
+ ret = contacts_svc_delete_contact(contact_id);
+ else if (changed){
+ contacts_svc_struct_store_list(contact, CTS_CF_GROUPREL_LIST, list);
+ ret = contacts_svc_update_contact(contact);
+ }
+ contacts_svc_struct_free(contact);
+ if (ret < CTS_SUCCESS)
+ return FALSE;
+ else
+ return TRUE;
+}
+
+static PTHREAD_FN list_edit_move_copy_contacts(void *data)
+{
+ int i;
+ int *result_list;
+ Elm_Object_Item *item;
+ ct_list_data *clist_d = data;
+ ct_group_edit_data *cgedit_d = clist_d->cgedit_d;
+ ct_progress_info *p_info = clist_d->p_info;
+ bool remove = false;
+ struct list_ginfo *sel_grp_info;
+
+ i = 0;
+ item = elm_genlist_first_item_get(clist_d->genlist);
+ result_list = calloc(clist_d->cnt_checked, sizeof(int));
+ while (item) {
+ ct_contact_list *contact = elm_object_item_data_get(item);
+ if (contact && contact->checked)
+ result_list[i++] = contact->id;
+ item = elm_genlist_item_next_get(item);
+ }
+
+ i = 0;
+ item = elm_genlist_first_item_get(cgedit_d->genlist);
+ sel_grp_info = calloc(cgedit_d->count, sizeof(struct list_ginfo));
+ while (item) {
+ ct_group_list *info = elm_object_item_data_get(item);
+ if (info && info->selected) {
+ sel_grp_info[i].id_grp = info->id_grp;
+ sel_grp_info[i++].id_ab = info->id_ab;
+ }
+ item = elm_genlist_item_next_get(item);
+ }
+
+ if (CT_LIST_EDIT_MOVE == clist_d->edit_op)
+ remove = true;
+ else remove = false;
+
+ for (i=0;i < clist_d->cnt_checked && p_info->cnt != p_info->cnt_checked_total;i++, p_info->cnt++){
+ int ret;
+
+ if (!p_info->alive){
+ p_info->result = FALSE;
+ break;
+ }
+ ret = list_edit_move_copy_contact_to_group(result_list[i], sel_grp_info,
+ cgedit_d->count, clist_d->base_ab, clist_d->base_grp, remove);
+ if (FALSE == ret){
+ p_info->result = FALSE;
+ p_info->completed = true;
+ break;
+ }
+ }
+
+ free(sel_grp_info);
+
+ pthread_exit(NULL);
+}
+
+static Eina_Bool list_edit_move_copy_timer_cb(void *data)
+{
+ ct_list_data *clist_d = data;
+ ct_progress_info *p_info = clist_d->p_info;
+
+ c_retvm_if(NULL == p_info, ECORE_CALLBACK_CANCEL, "parameter(ct_list_data) is NULL");
+
+ if (!p_info->completed) {
+ char count[CT_TEXT_SHORT_LEN];
+ char percent[CT_TEXT_SHORT_LEN];
+ double value = (double)p_info->cnt / (double)p_info->cnt_checked_total;
+
+ if (!p_info->alive) {
+ p_info->result = FALSE;
+ p_info->completed = true;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ elm_progressbar_value_set(p_info->progressbar, value);
+ snprintf(percent, sizeof(percent), "%d%%", (int)(100.0 * (double)p_info->cnt/(double)p_info->cnt_checked_total));
+ snprintf(count, sizeof(count), "%d/%d", p_info->cnt, p_info->cnt_checked_total);
+ edje_object_part_text_set(elm_layout_edje_get(p_info->layout), "elm.text.subtext1", percent);
+ edje_object_part_text_set(elm_layout_edje_get(p_info->layout), "elm.text.subtext2", count);
+
+ if (p_info->cnt == p_info->cnt_checked_total)
+ p_info->completed = true;
+
+ return ECORE_CALLBACK_RENEW;
+ }
+ else {
+ int ret;
+ const char *message;
+
+ pthread_join(p_info->thread, NULL);
+ clist_d->cgedit_d = NULL;
+ elm_naviframe_item_pop(clist_d->navi);
+
+ if (TRUE == p_info->result) {
+ if (CT_LIST_EDIT_MOVE == clist_d->edit_op)
+ message = S_(CT_SYS_POP_MOVED);
+ else
+ message = T_(CT_GET_TEXT_BASIC, CTTEXT_COPIED);
+ ret = contacts_svc_end_trans(true);
+ }
+ else {
+ message = S_(CT_SYS_POP_FAILED);
+ ret = contacts_svc_end_trans(false);
+ }
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+
+ evas_object_del(clist_d->popup);
+
+ list_edit_process_end(clist_d);
+ ctui_show_notify(clist_d->navi, message, 2.0);
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+}
+
+static void list_edit_move_copy_contacts_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_list_data *clist_d = data;
+ ct_progress_info *p_info;
+ Evas_Object *btn;
+
+ c_retm_if(clist_d->p_info, "thread is running");
+ p_info = calloc(1, sizeof(ct_progress_info));
+ c_retm_if(NULL == p_info, "calloc return NULL");
+
+ clist_d->p_info = p_info;
+ p_info->cnt_checked_total = clist_d->cnt_checked;
+ p_info->alive = true;
+ p_info->result = TRUE;
+
+ ret = contacts_svc_begin_trans();
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_begin_trans() Failed(%d)", ret);
+ free(p_info);
+ clist_d->p_info = NULL;
+ if (clist_d->cgedit_d)
+ elm_naviframe_item_pop(clist_d->cgedit_d->navi);
+ clist_d->cgedit_d = NULL;
+ return;
+ }
+
+ ret = pthread_create(&p_info->thread, NULL, list_edit_move_copy_contacts, clist_d);
+ if (0 != ret) {
+ ERR("Thread creation failed(%d)", ret);
+ free(p_info);
+ clist_d->p_info = NULL;
+ if (clist_d->cgedit_d)
+ elm_naviframe_item_pop(clist_d->cgedit_d->navi);
+ clist_d->cgedit_d = NULL;
+ ret = contacts_svc_end_trans(false);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+ return;
+ }
+
+ p_info->timer = ecore_timer_add(TIMER_DURATION, list_edit_move_copy_timer_cb, clist_d);
+ if (NULL == p_info->timer) {
+ ERR("ecore_timer_add() return NULL");
+ p_info->alive = false;
+ pthread_join(p_info->thread, NULL);
+ free(p_info);
+ clist_d->p_info = NULL;
+ ret = contacts_svc_end_trans(false);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+ return;
+ }
+
+ clist_d->popup = ctui_progressbar_popup(clist_d->win, p_info);
+ if (CT_LIST_EDIT_MOVE == clist_d->edit_op)
+ elm_object_text_set(p_info->label, T_(CT_GET_TEXT_BASIC, CTTEXT_MOVING_CONTACTS));
+ else
+ elm_object_text_set(p_info->label, T_(CT_GET_TEXT_BASIC, CTTEXT_COPYING_CONTACTS));
+
+ btn = ctui_create_popup_button(clist_d->popup, 1, S_(CT_SYS_SK_CANCEL), ctui_progress_popup_hide_cb, &p_info->alive);
+ evas_object_data_set(btn, "p_popup", &clist_d->popup);
+}
+
+static void list_edit_back_btn_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_group_edit_data *cgedit_d = data;
+ ctui_hide_notify(cgedit_d->navi);
+ elm_naviframe_item_pop(cgedit_d->navi);
+}
+
+static void list_edit_move_copy_cb(ct_list_data *clist_d)
+{
+ Evas_Object *l_btn;
+ Evas_Object *layout;
+ ct_group_edit_data *cgedit_d;
+ const char *title;
+
+ cgedit_d = calloc(1, sizeof(ct_group_edit_data));
+
+ cgedit_d->win = clist_d->win;
+ cgedit_d->navi = clist_d->navi;
+ cgedit_d->base_ab = clist_d->base_ab;
+ cgedit_d->is_move_copy_view = true;
+ cgedit_d->grp_id = clist_d->base_grp;
+ clist_d->cgedit_d = cgedit_d;
+
+ layout = ctui_gedit_create_view(cgedit_d);
+
+ if (CT_LIST_EDIT_MOVE == clist_d->edit_op) {
+ cgedit_d->ctr_btn_info.cb = list_edit_move_copy_contacts_btn_cb;
+ cgedit_d->ctr_btn_info.icon_path = CTUI_IMG_ICON_MOVE;
+ cgedit_d->ctr_btn_info.user_data = clist_d;
+ title = S_(CT_SYS_BODY_MOVE);
+ }
+ else {
+ cgedit_d->ctr_btn_info.cb = list_edit_move_copy_contacts_btn_cb;
+ cgedit_d->ctr_btn_info.icon_path = CTUI_IMG_ICON_COPY;
+ cgedit_d->ctr_btn_info.user_data = clist_d;
+ title = S_(CT_SYS_BODY_COPY);
+ }
+
+ l_btn = ctui_naviframe_btn(cgedit_d->navi, S_(CT_SYS_SK_CANCEL));
+ evas_object_smart_callback_add(l_btn, "clicked", list_edit_back_btn_cb, cgedit_d);
+
+ cgedit_d->navi_it = elm_naviframe_item_push(cgedit_d->navi, title, l_btn, NULL, layout, NULL);
+ ctui_gedit_navi_create_btn(cgedit_d);
+}
+
+static void list_edit_move_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_list_data *clist_d = data;
+ clist_d->edit_op = CT_LIST_EDIT_MOVE;
+ list_edit_move_copy_cb(clist_d);
+}
+
+static void list_edit_copy_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_list_data *clist_d = data;
+ clist_d->edit_op = CT_LIST_EDIT_COPY;
+ list_edit_move_copy_cb(clist_d);
+}
+
+
+void ct_list_edit_make_edit_cbar(ct_list_data *clist_d)
+{
+ Evas_Object *l_btn;
+ Elm_Object_Item *delete_item;
+ Elm_Object_Item *move_item;
+ Elm_Object_Item *copy_item;
+
+ if (0 < clist_d->list_op) {
+ copy_item = elm_toolbar_item_append(clist_d->cbar, CTUI_IMG_ICON_COPY, NULL, list_edit_copy_cb, clist_d);
+ evas_object_data_set(clist_d->cbar, "copy_item", copy_item);
+ move_item = elm_toolbar_item_append(clist_d->cbar, CTUI_IMG_ICON_MOVE, NULL, list_edit_move_cb, clist_d);
+ evas_object_data_set(clist_d->cbar, "move_item", move_item);
+ }
+ delete_item = elm_toolbar_item_append(clist_d->cbar, CTUI_IMG_ICON_DELETE, NULL, list_edit_del_cb, clist_d);
+ evas_object_data_set(clist_d->cbar, "delete_item", delete_item);
+ if (0 >= clist_d->list_op) {
+ ct_toolbar_disalbed_item_append(clist_d->cbar, 3);
+ }
+ l_btn = ctui_naviframe_btn(clist_d->navi, S_(CT_SYS_SK_CANCEL));
+ evas_object_smart_callback_add(l_btn, "clicked", list_edit_cancel_cb, clist_d);
+ elm_object_item_part_content_set(clist_d->navi_item, "prev_btn", l_btn);
+}
+
+static int list_edit_checked_cnt_get(Eina_List *list) {
+ int cnt = 0;
+ Eina_List *l;
+ ct_contact_list *contact;
+
+ EINA_LIST_FOREACH(list, l, contact) {
+ if (NULL == contact) continue;
+ if (contact->checked)
+ cnt++;
+ }
+ return cnt;
+}
+
+void ct_list_edit_update_selection_info(ct_list_data *clist_d)
+{
+ int checked_cnt = 0;
+ Evas_Object *notify;
+ char buf[CT_TEXT_SHORT_LEN];
+
+ if (clist_d->ug_request) {
+ checked_cnt = list_edit_checked_cnt_get(clist_d->list);
+ }
+ else {
+ if (0 != clist_d->cnt_total && clist_d->cnt_checked == clist_d->cnt_total)
+ elm_check_state_set(clist_d->select_all_checkbox, EINA_TRUE);
+ else if (0 == clist_d->cnt_total || clist_d->cnt_checked != clist_d->cnt_total)
+ elm_check_state_set(clist_d->select_all_checkbox, EINA_FALSE);
+ checked_cnt = clist_d->cnt_checked;
+ }
+
+ if (0 == checked_cnt) {
+ ctui_cbar_btn_disabled_set(clist_d->cbar, EINA_TRUE);
+ notify = evas_object_data_get(clist_d->navi, "notify");
+ if (notify)
+ evas_object_hide(notify);
+ return;
+ }
+ else {
+ ctui_cbar_btn_disabled_set(clist_d->cbar, EINA_FALSE);
+ }
+
+ snprintf(buf, sizeof(buf), "%s (%d)", S_(CT_SYS_POP_SELECTED), clist_d->cnt_checked);
+ ctui_show_notify(clist_d->navi, buf, 0.0);
+}
+
+void ct_list_edit_select_all(ct_list_data *clist_d)
+{
+ list_edit_realized_items_checked_set(clist_d->genlist, clist_d->select_all_checked);
+ elm_genlist_realized_items_update(clist_d->genlist);
+
+ if (clist_d->select_all_checked)
+ clist_d->cnt_checked = clist_d->cnt_total;
+ else
+ clist_d->cnt_checked = 0;
+
+ ct_list_edit_update_selection_info(clist_d);
+}
+
+void ct_list_item_checked_set(Elm_Object_Item *item, ct_list_data *clist_d)
+{
+ ct_contact_list *contact = elm_object_item_data_get(item);
+ c_retm_if(NULL == contact, "elm_object_item_data_get() returns NULL");
+
+ if (contact->checked) {
+ if (clist_d->cnt_max) {
+ if (clist_d->cnt_max <= clist_d->cnt_checked) {
+ ctui_create_popup(clist_d->win, T_(CT_GET_TEXT_ERR, CTTEXT_EXCEED_LIMIT), 2.0);
+ contact->checked = EINA_FALSE;
+ return;
+ }
+ }
+ clist_d->cnt_checked++;
+ }
+ else
+ clist_d->cnt_checked--;
+ elm_genlist_item_fields_update(item, "elm.edit.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT);
+}
+
+
+static void list_edit_item_check_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ Elm_Object_Item *item;
+ ct_contact_list *ct_info;
+ ct_list_data *clist_d = data;
+
+ ct_info = evas_object_data_get(obj, "ct_info");
+ c_retm_if(NULL == ct_info, "evas_object_data_get() return NULL");
+
+ item = ct_info->item;
+ c_retm_if(NULL == item, "ct_info->item is NULL");
+
+ ct_list_item_checked_set(ct_info->item, clist_d);
+ if (!ct_info->checked) {
+ ct_list_edit_update_selection_info(clist_d);
+ return;
+ }
+ if (CT_UG_REQUEST_CHECK_FOR_NUMBER == clist_d->ug_request)
+ ct_list_ug_handle_check_for_number(item, clist_d);
+ else if (CT_UG_REQUEST_CHECK_FOR_EMAIL == clist_d->ug_request)
+ ct_list_ug_handle_check_for_email(item, clist_d);
+ else
+ ct_list_edit_update_selection_info(clist_d);
+}
+
+Evas_Object* ct_list_edit_add_check(Evas_Object *parent, Eina_Bool *checked,
+ ct_list_data *clist_d)
+{
+ Evas_Object *check = elm_check_add(parent);
+ elm_check_state_pointer_set(check, checked);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ evas_object_smart_callback_add(check, "changed", list_edit_item_check_cb, clist_d);
+ return check;
+}
+
+static void list_select_all_check_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ ct_list_edit_select_all(data);
+}
+
+static void list_select_all_mouse_up_cb(void *data, Evas *e,
+ Evas_Object *obj, void *event_info)
+{
+ int x, y, w, h;
+ ct_list_data *clist_d = data;
+ Evas_Event_Mouse_Up *ev = event_info;
+
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ return;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ if (ev->output.y < y || y + h < ev->output.y)
+ return;
+
+ elm_check_state_set(clist_d->select_all_checkbox, !clist_d->select_all_checked);
+ ct_list_edit_select_all(clist_d);
+}
+
+void ct_list_edit_mode_start(ct_list_data *clist_d)
+{
+ Evas_Object *layout;
+ Evas_Object *check;
+ const char *title;
+
+ clist_d->list_mode = CT_LIST_VIEW_EDIT;
+
+ // Append 'Select All' layout
+ if (!clist_d->ug_request && (0 == clist_d->cnt_max || clist_d->cnt_total <= clist_d->cnt_max))
+ {
+ layout = elm_layout_add(clist_d->box);
+ elm_layout_theme_set(layout, "genlist", "item", "select_all/default");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_UP,
+ list_select_all_mouse_up_cb, clist_d);
+
+ check = clist_d->select_all_checkbox = elm_check_add(layout);
+ elm_check_state_pointer_set(check, &clist_d->select_all_checked);
+ evas_object_smart_callback_add(check, "changed", list_select_all_check_cb, clist_d);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ elm_object_part_content_set(layout, "elm.icon", check);
+ evas_object_data_set(clist_d->select_all_checkbox, "layout", layout);
+
+ elm_object_part_text_set(layout, "elm.text", S_(CT_SYS_BODY_SELECT_ALL));
+ elm_box_pack_start(clist_d->box, layout);
+ evas_object_show(layout);
+ }
+
+ elm_genlist_decorate_mode_set(clist_d->genlist, EINA_TRUE);
+ clist_d->select_all_checked = EINA_FALSE;
+
+ title = T_(CT_GET_TEXT_BASIC, CTTEXT_SELECT_CONTACTS);
+ elm_object_item_text_set(clist_d->navi_item, title);
+}
+
+void ct_list_edit_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_list_data *clist_d = data;
+
+ c_retm_if(NULL == clist_d->navi_item, "parameter(navi_item) is NULL");
+
+ ct_list_navi_set(CT_LIST_MODE_EDIT, clist_d);
+ if (!clist_d->ug_request)
+ ctui_cbar_btn_disabled_set(clist_d->cbar, EINA_TRUE);
+
+ ct_list_edit_mode_start(clist_d);
+}
+
+void ct_list_edit_check_done(void *data, Evas_Object *obj, void *event_info)
+{
+ int i = 0;
+ int cnt_checked;
+ int *result_list;
+ Eina_List *l;
+ ct_contact_list *contact;
+ ct_list_data *clist_d = data;
+ cnt_checked = list_edit_checked_cnt_get(clist_d->list);
+
+ result_list = calloc(cnt_checked, sizeof(int));
+ EINA_LIST_FOREACH(clist_d->list, l, contact) {
+ if (NULL == contact || !contact->checked) continue;
+
+ if (CT_UG_REQUEST_CHECK_FOR_NUMBER == clist_d->ug_request)
+ result_list[i++] = contact->id_ret;
+ else if (CT_UG_REQUEST_CHECK_FOR_EMAIL == clist_d->ug_request)
+ result_list[i++] = contact->id_ret;
+ else
+ result_list[i++] = contact->id;
+ }
+
+ if (CT_UG_REQUEST_CHECK_FOR_NUMBER == clist_d->ug_request)
+ ct_list_ug_return_ids(clist_d->ug, result_list, cnt_checked, CT_UG_BUNDLE_RESULT_NUMBER_ID_LIST);
+ else if (CT_UG_REQUEST_CHECK_FOR_EMAIL == clist_d->ug_request)
+ ct_list_ug_return_ids(clist_d->ug, result_list, cnt_checked, CT_UG_BUNDLE_RESULT_EMAIL_ID_LIST);
+ else
+ ct_list_ug_return_ids(clist_d->ug, result_list, cnt_checked, CT_UG_BUNDLE_RESULT_CONTACT_ID_LIST);
+
+ free(result_list);
+ ug_destroy_me(clist_d->ug);
+}
+
diff --git a/lib/list/ct-list-edit-view.h b/lib/list/ct-list-edit-view.h
new file mode 100755
index 0000000..26b5952
--- /dev/null
+++ b/lib/list/ct-list-edit-view.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_LIST_EDIT_VIEW_H__
+#define __CONTACTS_LIST_EDIT_VIEW_H__
+
+void ct_list_edit_mode_start(ct_list_data *clist_d);
+void ct_list_edit_mode_end(ct_list_data *clist_d);
+void ct_list_edit_button_cb(void *data, Evas_Object *obj, void *event_info);
+void ct_list_edit_make_edit_cbar(ct_list_data *clist_d);
+void ct_list_edit_check_done(void *data, Evas_Object *obj, void *event_info);
+void ct_list_edit_update_selection_info(ct_list_data *clist_d);
+Evas_Object* ct_list_edit_add_check(Evas_Object *parent, Eina_Bool *checked, ct_list_data *clist_d);
+void ct_list_item_checked_set(Elm_Object_Item *item, ct_list_data *clist_d);
+
+#endif //__CONTACTS_LIST_EDIT_VIEW_H__
+
diff --git a/lib/list/ct-list-group-view.c b/lib/list/ct-list-group-view.c
new file mode 100755
index 0000000..4c98926
--- /dev/null
+++ b/lib/list/ct-list-group-view.c
@@ -0,0 +1,472 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include "contacts.h"
+#include "ct-list.h"
+#include "ct-list-utils.h"
+#include "ct-list-edit-view.h"
+#include "ct-list-contact-view.h"
+#include "ct-list-group-view.h"
+
+static Elm_Genlist_Item_Class grp_itc_expandable, grp_itc, grp_itc2, grp_itc2_noshadow;
+
+static void group_gl_del(void *data, Evas_Object *obj)
+{
+ ct_group_list *info = data;
+ c_retm_if(NULL == info, "data is NULL");
+ free(info->name);
+ free(info);
+}
+
+static char* group_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ char merge_str[CT_TEXT_MAX_LEN];
+ ct_group_list *info = data;
+
+ c_retvm_if(NULL == data, NULL, "The parameter(data) is NULL");
+
+ snprintf(merge_str, sizeof(merge_str), "%s (%d)", info->name, info->count);
+
+ if ((!strcmp(part, "elm.text.1") || !strcmp(part, "elm.text")) && info->name)
+ return strdup(merge_str);
+
+ return strdup("");
+}
+
+enum {
+ ALL_CONTACT,
+ ALL_CONTACT_OF_ADDRBOOK,
+ ALL_CONTACT_OF_GROUP,
+ LIST_SDN,
+ NOT_ASSIGN_OF_ADDRBOOK
+};
+static void group_sel_common(int op, void *data, void *event_info)
+{
+ Elm_Object_Item *item = event_info;
+ ct_group_data *cgroup_d = data;
+ ct_list_data *clist_d = cgroup_d->clist_d;
+ ct_group_list *info = elm_object_item_data_get(item);
+ c_retm_if(NULL == info, "elm_object_item_data_get() return NULL");
+
+ clist_d->base_ab = info->id_ab;
+ clist_d->base_grp = info->id_grp;
+ clist_d->base_ab_mode = info->mode;
+
+ switch (op) {
+ case ALL_CONTACT:
+ clist_d->list_op = CT_GET_LIST_ALL_CONTACTS;
+ break;
+ case ALL_CONTACT_OF_ADDRBOOK:
+ clist_d->list_op = CT_GET_LIST_CONTACTS_OF_ADDRBOOK_ID;
+ break;
+ case ALL_CONTACT_OF_GROUP:
+ clist_d->list_op = CT_GET_LIST_CONTACTS_OF_GROUP_ID;
+ break;
+ case NOT_ASSIGN_OF_ADDRBOOK:
+ clist_d->list_op = CT_GET_LIST_NOT_ASSIGNED_OF_ADDRBOOK_ID;
+ break;
+ case LIST_SDN:
+ clist_d->list_op = CT_GET_LIST_SDN;
+ break;
+ default:
+ ERR("It is impossible to reach here");
+ break;
+ }
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ FREEandSTRDUP(clist_d->title, info->name);
+
+ edje_object_signal_emit(_EDJ(cgroup_d->base), "elm,state,hide", "");
+
+ ct_list_searchbar_update(clist_d);
+ if (CT_GET_LIST_SDN == clist_d->list_op)
+ ct_list_create_genlist_sdn(clist_d);
+ else
+ ctui_list_genlist_update(clist_d);
+}
+
+static void group_addrbook_sel_all_contacts(void *data, Evas_Object *obj, void *event_info)
+{
+ group_sel_common(ALL_CONTACT, data, event_info);
+}
+
+static void group_addrbook_sel_SDN(void *data, Evas_Object *obj, void *event_info)
+{
+ group_sel_common(LIST_SDN, data, event_info);
+}
+
+static void group_addrbook_sel_normal(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = event_info;
+
+ if (elm_genlist_item_expanded_get(item))
+ elm_genlist_item_expanded_set(item, EINA_FALSE);
+ else
+ elm_genlist_item_expanded_set(item, EINA_TRUE);
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+}
+
+static void group_sel_all_conatacts(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ group_sel_common(ALL_CONTACT_OF_ADDRBOOK, data, event_info);
+}
+
+static void group_sel_normal(void *data, Evas_Object *obj, void *event_info)
+{
+ group_sel_common(ALL_CONTACT_OF_GROUP, data, event_info);
+}
+
+static void group_sel_not_assigned(void *data, Evas_Object *obj, void *event_info)
+{
+ group_sel_common(NOT_ASSIGN_OF_ADDRBOOK, data, event_info);
+}
+
+static void group_addrbook_expand(void *data, Evas_Object *obj, void *event_info)
+{
+ CT_FN_CALL;
+ int ret;
+ Elm_Object_Item *it = event_info;
+ ct_group_data *cgroup_d = data;
+ ct_group_list *sub_item;
+ CTSiter *iter;
+
+ Evas_Object *gl = elm_object_item_widget_get(it);
+ ct_group_list *it_info = elm_object_item_data_get(it);
+ c_retm_if(NULL == it_info, "elm_object_item_data_get() returns NULL");
+
+ sub_item = calloc(1, sizeof(ct_group_list));
+ sub_item->id_ab = it_info->id_ab;
+ sub_item->mode = it_info->mode;
+ sub_item->count = contacts_svc_count_with_int(CTS_GET_COUNT_CONTACTS_IN_ADDRESSBOOK,
+ sub_item->id_ab);
+ sub_item->name = strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_ALL_CONTACTS));
+
+ elm_genlist_item_append(gl, &grp_itc2, sub_item, it, ELM_GENLIST_ITEM_NONE,
+ group_sel_all_conatacts, cgroup_d);
+
+ ret = contacts_svc_get_list_with_int(CTS_LIST_GROUPS_OF_ADDRESSBOOK_ID,
+ it_info->id_ab, &iter);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_get_list_with_int() Failed(%d)", ret);
+
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue *info = contacts_svc_iter_get_info(iter);
+ sub_item = calloc(1, sizeof(ct_group_list));
+ sub_item->id_ab = it_info->id_ab;
+ sub_item->mode = it_info->mode;
+ sub_item->id_grp = contacts_svc_value_get_int(info, CTS_GROUPREL_VAL_ID_INT);
+ sub_item->count = contacts_svc_count_with_int(CTS_GET_COUNT_CONTACTS_IN_GROUP,
+ sub_item->id_grp);
+ sub_item->name = contacts_svc_value_steal_str(info, CTS_GROUPREL_VAL_NAME_STR);
+
+ elm_genlist_item_append(gl, &grp_itc2_noshadow, sub_item, it,
+ ELM_GENLIST_ITEM_NONE, group_sel_normal, cgroup_d);
+ contacts_svc_value_free(info);
+ }
+ contacts_svc_iter_remove(iter);
+ ret = contacts_svc_count_with_int(CTS_GET_COUNT_NO_GROUP_CONTACTS_IN_ADDRESSBOOK,
+ it_info->id_ab);
+
+ if (ret) {
+ sub_item = calloc(1, sizeof(ct_group_list));
+ sub_item->id_ab = it_info->id_ab;
+ sub_item->count = ret;
+ sub_item->mode = it_info->mode;
+ sub_item->name = strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_NOT_ASSIGNED));
+
+ elm_genlist_item_append(gl, &grp_itc2_noshadow, sub_item, it,
+ ELM_GENLIST_ITEM_NONE, group_sel_not_assigned, cgroup_d);
+ }
+ cgroup_d->expand_ab = g_slist_append(cgroup_d->expand_ab, (gpointer)it_info->id_ab);
+}
+
+static void group_addrbook_contract(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = event_info;
+ ct_group_data *cgroup_d = data;
+
+ ct_group_list *info = elm_object_item_data_get(item);
+ c_retm_if(NULL == info, "elm_object_item_data_get() returns NULL");
+
+ cgroup_d->expand_ab = g_slist_remove_all(cgroup_d->expand_ab, (gpointer)info->id_ab);
+ elm_genlist_item_subitems_clear(item);
+}
+
+struct group_handle_list {
+ const char *name;
+ Elm_Genlist_Item_Type type;
+ Evas_Smart_Cb cb;
+};
+
+static void group_fill_genlist(ct_group_data *cgroup_d)
+{
+ int i;
+ int ret;
+ CTSiter *iter;
+ ct_group_list *item;
+ Evas_Object *genlist = cgroup_d->genlist;
+ Elm_Object_Item *gen_item;
+
+ ctui_list_detail_genlist_append_separator_line_20px(cgroup_d->genlist);
+
+ const struct group_handle_list basic[] = {
+ {T_(CT_GET_TEXT_BASIC, CTTEXT_ALL_CONTACTS), ELM_GENLIST_ITEM_NONE, group_addrbook_sel_all_contacts},
+ {T_(CT_GET_TEXT_BASIC, CTTEXT_SDN), ELM_GENLIST_ITEM_NONE, group_addrbook_sel_SDN},
+ {T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE), ELM_GENLIST_ITEM_TREE, group_addrbook_sel_normal}
+ };
+
+ for (i=0;i<ARRAY_SIZE(basic);i++) {
+ if (1 == i && 0 == contacts_svc_count(CTS_GET_COUNT_SDN))
+ continue;
+ item = calloc(1, sizeof(ct_group_list));
+ item->id_ab = i - ARRAY_SIZE(basic) + 1;
+ item->name = strdup(basic[i].name);
+ if (0 == i) {
+ item->count = contacts_svc_count(CTS_GET_ALL_CONTACT);
+ item->mode = CTS_ADDRESSBOOK_MODE_NONE;
+
+ gen_item = elm_genlist_item_append(genlist, &grp_itc, item, NULL, basic[i].type,
+ basic[i].cb, cgroup_d);
+ }
+ else if (1 == i) {
+ int count = contacts_svc_count(CTS_GET_COUNT_SDN);
+ if (count <= 0) continue;
+ if (CT_UG_REQUEST_CHECK == cgroup_d->clist_d->ug_request ||
+ CT_UG_REQUEST_CHECK_FOR_NUMBER == cgroup_d->clist_d->ug_request ||
+ CT_UG_REQUEST_CHECK_FOR_EMAIL == cgroup_d->clist_d->ug_request) continue;
+ item->count = count;
+ item->mode = CTS_ADDRESSBOOK_MODE_READONLY;
+ gen_item = elm_genlist_item_append(genlist, &grp_itc, item, NULL, basic[i].type,
+ basic[i].cb, cgroup_d);
+ }
+ else {
+ item->count = contacts_svc_count_with_int(CTS_GET_COUNT_CONTACTS_IN_ADDRESSBOOK,
+ item->id_ab);
+ item->mode = CTS_ADDRESSBOOK_MODE_NONE;
+
+ gen_item = elm_genlist_item_append(genlist, &grp_itc_expandable, item, NULL, basic[i].type,
+ basic[i].cb, cgroup_d);
+ }
+ if (2 == i && g_slist_find(cgroup_d->expand_ab, (gpointer)item->id_ab))
+ group_addrbook_sel_normal(NULL, NULL, gen_item);
+
+ }
+
+ ret = contacts_svc_get_list(CTS_LIST_ALL_ADDRESSBOOK, &iter);
+ c_retm_if(CTS_SUCCESS != ret, "contacts_svc_get_list() Failed(%d)", ret);
+
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue *info;
+
+ info = contacts_svc_iter_get_info(iter);
+ item = calloc(1, sizeof(ct_group_list));
+ item->id_ab = contacts_svc_value_get_int(info, CTS_LIST_ADDRESSBOOK_ID_INT);
+ item->name = contacts_svc_value_steal_str(info, CTS_LIST_ADDRESSBOOK_NAME_STR);
+ item->mode = contacts_svc_value_get_int(info, CTS_LIST_ADDRESSBOOK_MODE_INT);
+ item->count = contacts_svc_count_with_int(CTS_GET_COUNT_CONTACTS_IN_ADDRESSBOOK,
+ item->id_ab);
+
+ gen_item = elm_genlist_item_append(genlist, &grp_itc_expandable, item, NULL,
+ ELM_GENLIST_ITEM_TREE, group_addrbook_sel_normal, NULL);
+ if (g_slist_find(cgroup_d->expand_ab, (gpointer)item->id_ab))
+ group_addrbook_sel_normal(NULL, NULL, gen_item);
+ }
+ contacts_svc_iter_remove(iter);
+}
+
+static void group_changed(void *user_data)
+{
+ ct_group_data *cgroup_d = user_data;
+
+ elm_genlist_clear(cgroup_d->genlist);
+ group_fill_genlist(cgroup_d);
+}
+
+static void group_edit_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_group_data *cgroup_d = data;
+ ctui_gedit_push_view(cgroup_d->win, cgroup_d->navi, -1);
+}
+
+static void group_view_delete_cb(void *data, Evas *e, Evas_Object *obj,
+ void *event_info)
+{
+ int ret;
+ ct_group_data *cgroup_d = data;
+ c_retm_if(NULL == cgroup_d, "parameter(cgroup_d) is NULL");
+
+ ret = contacts_svc_unsubscribe_change_with_data(CTS_SUBSCRIBE_CONTACT_CHANGE, group_changed, cgroup_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_unsubscribe_change_with_data() Failed(%d)", ret);
+ ret = contacts_svc_unsubscribe_change_with_data(CTS_SUBSCRIBE_GROUP_CHANGE, group_changed, cgroup_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_unsubscribe_change_with_data() Failed(%d)", ret);
+
+ free(cgroup_d);
+}
+
+static void group_create_itcs()
+{
+ grp_itc_expandable.item_style = "dialogue/1text/expandable";
+ grp_itc_expandable.func.text_get = group_label_get;
+ grp_itc_expandable.func.content_get = NULL;
+ grp_itc_expandable.func.state_get = NULL;
+ grp_itc_expandable.func.del = group_gl_del;
+
+ grp_itc.item_style = "dialogue/1text";
+ grp_itc.func.text_get = group_label_get;
+ grp_itc.func.content_get = NULL;
+ grp_itc.func.state_get = NULL;
+ grp_itc.func.del = group_gl_del;
+
+ grp_itc2.item_style = "dialogue/1text/expandable2";
+ grp_itc2.func.text_get = group_label_get;
+ grp_itc2.func.content_get = NULL;
+ grp_itc2.func.state_get = NULL;
+ grp_itc2.func.del = group_gl_del;
+
+ grp_itc2_noshadow.item_style = "dialogue/1text/expandable2";
+ grp_itc2_noshadow.func.text_get = group_label_get;
+ grp_itc2_noshadow.func.content_get = NULL;
+ grp_itc2_noshadow.func.state_get = NULL;
+ grp_itc2_noshadow.func.del = group_gl_del;
+}
+
+static void group_layout_post_cb(void *data, Evas *e, void *even_info)
+{
+ Evas_Object *layout = data;
+ edje_object_signal_emit(_EDJ(layout), "elm,state,show", "");
+ evas_event_callback_del(e, EVAS_CALLBACK_RENDER_FLUSH_POST, group_layout_post_cb);
+}
+
+static void group_layout_hide_effect_finished(void *data, Evas_Object *obj, const char *emission, const char *source)
+{
+ ct_group_data *cgroup_d = data;
+ c_retm_if(NULL == cgroup_d, "parameter(cgroup_d) is NULL");
+
+ if (cgroup_d->base)
+ evas_object_del(cgroup_d->base);
+}
+
+static void group_back_clicked_cb(void *data, Evas_Object *obj, void *even_info)
+{
+ edje_object_signal_emit(_EDJ(data), "elm,state,hide", "");
+}
+
+API void ctui_list_create_group_view(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_list_data *clist_d = data;
+ ct_group_data *cgroup_d;
+ Elm_Object_Item *navi_item;
+ Evas_Object *cbar, *tmp_base, *bg, *back_btn;
+
+ c_retm_if(NULL == clist_d->win, "parameter(win) is NULL");
+
+ cgroup_d = calloc(1, sizeof(ct_group_data));
+ c_retm_if(NULL == cgroup_d, "calloc() return NULL");
+
+ cgroup_d->clist_d = clist_d;
+ cgroup_d->win = clist_d->win;
+
+ cgroup_d->base = elm_layout_add(cgroup_d->win);
+ if (NULL == cgroup_d->base) {
+ ERR("elm_layout_add() return NULL");
+ free(cgroup_d);
+ return;
+ }
+
+ evas_object_size_hint_weight_set(cgroup_d->base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(cgroup_d->win, cgroup_d->base);
+ elm_layout_file_set(cgroup_d->base, CONTACTS_EDJ, "layout_effect");
+
+ if (NULL == obj) /* called by livebox */
+ edje_object_signal_emit(_EDJ(cgroup_d->base), "elm,state,no_animation", "");
+ evas_object_show(cgroup_d->base);
+ evas_event_callback_add(evas_object_evas_get(cgroup_d->base), EVAS_CALLBACK_RENDER_FLUSH_POST,
+ group_layout_post_cb, cgroup_d->base);
+ edje_object_signal_callback_add(_EDJ(cgroup_d->base), "elm,action,hide,finished",
+ "", group_layout_hide_effect_finished, cgroup_d);
+
+ bg = ctui_set_bg(cgroup_d->base);
+ elm_object_style_set(bg, "group_list");
+
+ cgroup_d->navi = elm_naviframe_add(cgroup_d->base);
+ if (NULL == cgroup_d->navi) {
+ ERR("elm_naviframe_add() return NULL");
+ free(cgroup_d);
+ return;
+ }
+ elm_naviframe_prev_btn_auto_pushed_set(cgroup_d->navi, EINA_FALSE);
+ evas_object_show(cgroup_d->navi);
+
+ tmp_base = ctui_create_base_layout(cgroup_d->base, true);
+ elm_object_part_content_set(tmp_base, "elm.swallow.content", cgroup_d->navi);
+ elm_object_part_content_set(cgroup_d->base, "elm.swallow.content", tmp_base);
+
+ group_create_itcs();
+ cgroup_d->genlist = elm_genlist_add(cgroup_d->navi);
+ if (NULL == cgroup_d->genlist) {
+ ERR("elm_genlist_add() return NULL");
+ free(cgroup_d);
+ return;
+ }
+
+ evas_object_smart_callback_add(cgroup_d->genlist, "expanded",
+ group_addrbook_expand, cgroup_d);
+ evas_object_smart_callback_add(cgroup_d->genlist, "contracted",
+ group_addrbook_contract, cgroup_d);
+ group_fill_genlist(cgroup_d);
+
+ evas_object_show(cgroup_d->genlist);
+ evas_object_event_callback_add(cgroup_d->genlist, EVAS_CALLBACK_DEL, group_view_delete_cb, cgroup_d);
+
+ cbar = elm_toolbar_add(cgroup_d->navi);
+ if (NULL == cbar) {
+ ERR("elm_toolbar_add() return NULL");
+ free(cgroup_d);
+ return;
+ }
+ elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
+
+ back_btn = elm_button_add(cgroup_d->navi);
+ c_retm_if(NULL == back_btn, "elm_button_add() return NULL");
+
+ elm_object_style_set(back_btn, "naviframe/back_btn/default");
+ evas_object_smart_callback_add(back_btn, "clicked", group_back_clicked_cb, cgroup_d->base);
+
+ elm_toolbar_item_append(cbar, CTUI_IMG_ICON_EDIT, NULL,
+ group_edit_cb, cgroup_d);
+
+ ct_toolbar_disalbed_item_append(cbar, 3);
+
+ navi_item = elm_naviframe_item_push(cgroup_d->navi,
+ T_(CT_GET_TEXT_BASIC, CTTEXT_GROUP), back_btn, NULL, cgroup_d->genlist, NULL);
+ elm_object_item_part_content_set(navi_item, "controlbar", cbar);
+
+ ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, group_changed, cgroup_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_subscribe_change() Failed(%d)", ret);
+
+ ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE, group_changed, cgroup_d);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_subscribe_change() Failed(%d)", ret);
+}
diff --git a/lib/list/ct-list-group-view.h b/lib/list/ct-list-group-view.h
new file mode 100755
index 0000000..6574a12
--- /dev/null
+++ b/lib/list/ct-list-group-view.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_LIST_GROUP_VIEW_H__
+#define __CONTACTS_LIST_GROUP_VIEW_H__
+
+#endif //__CONTACTS_LIST_GROUP_VIEW_H__
diff --git a/lib/list/ct-list-main.c b/lib/list/ct-list-main.c
new file mode 100755
index 0000000..ffeb8dc
--- /dev/null
+++ b/lib/list/ct-list-main.c
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <ui-gadget-module.h>
+#include "contacts.h"
+#include "ct-list.h"
+#include "ct-detail.h"
+#include "ct-list-utils.h"
+#include "ct-list-view-ug.h"
+#include "ct-list-contact-view.h"
+#include "ct-list-group-view.h"
+#include "ct-list-edit-view.h"
+
+API void ctui_list_view_reset(ct_list_data *clist_d)
+{
+ Evas_Object *cbar;
+ evas_object_data_del(clist_d->cbar, "done_item");
+ evas_object_data_del(clist_d->cbar, "edit_item");
+ evas_object_data_del(clist_d->cbar, "new_item");
+
+ cbar = clist_d->cbar;
+ clist_d->cbar = elm_toolbar_add(clist_d->navi);
+
+ elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
+ if (EINA_TRUE == elm_genlist_decorate_mode_get(clist_d->genlist))
+ ct_list_edit_mode_end(clist_d);
+
+ if (CT_GET_LIST_ALL_CONTACTS != clist_d->list_op) {
+ clist_d->base_ab = 0;
+ clist_d->base_ab_mode = CTS_ADDRESSBOOK_MODE_NONE;
+ clist_d->base_grp = 0;
+ clist_d->list_op = CT_GET_LIST_ALL_CONTACTS;
+ ctui_list_genlist_update(clist_d);
+ }
+
+ if (elm_naviframe_top_item_get(clist_d->navi) != clist_d->navi_item)
+ elm_naviframe_item_pop_to(clist_d->navi_item);
+ evas_object_del(clist_d->cbar);
+ clist_d->cbar = cbar;
+}
+
+static int create_list_view(Evas_Object *base, ct_list_data *clist_d)
+{
+ char buf[CT_TEXT_SHORT_LEN];
+
+ c_retvm_if(NULL == base, FALSE, "base is NULL");
+
+ clist_d->navi = elm_naviframe_add(base);
+ c_retvm_if(NULL == clist_d->navi, FALSE, "navi is NULL");
+ elm_naviframe_prev_btn_auto_pushed_set(clist_d->navi, EINA_FALSE);
+ evas_object_show(clist_d->navi);
+
+ clist_d->list = ct_list_get_contacts(clist_d);
+ clist_d->content = ct_list_create_contact_view(clist_d);
+
+ FREEandSTRDUP(clist_d->title, T_(CT_GET_TEXT_BASIC, CTTEXT_ALL_CONTACTS));
+ snprintf(buf, sizeof(buf), "%s (%d)", clist_d->title, clist_d->cnt_list);
+ clist_d->navi_item = elm_naviframe_item_push(clist_d->navi, buf, NULL, NULL, clist_d->content, NULL);
+ ct_list_navi_set(CT_LIST_MODE_DEFAULT, clist_d);
+
+ if (CT_UG_REQUEST_CHECK == clist_d->ug_request ||
+ CT_UG_REQUEST_CHECK_FOR_NUMBER == clist_d->ug_request ||
+ CT_UG_REQUEST_CHECK_FOR_EMAIL == clist_d->ug_request)
+ ct_list_edit_mode_start(clist_d);
+
+ elm_object_part_content_set(base, "elm.swallow.content", clist_d->navi);
+
+ return TRUE;
+}
+
+static void *list_on_create(struct ui_gadget *ug, enum ug_mode mode,
+ bundle *data, void *priv)
+{
+ int ret;
+ Evas_Object *bg, *base;
+ Evas_Object *parent;
+ ct_list_data *clist_d = priv;
+
+ c_retvm_if(NULL == ug || NULL == priv, NULL,
+ "The parameter is invalid(ug=%p, priv=%p)", ug, priv);
+
+ ret = ct_list_parse_bundle(data, clist_d);
+ if (-2 == ret) {
+ clist_d->popup = ctui_create_popup(ug_get_parent_layout(ug), S_(CT_SYS_POP_FILE_NOT_FOUND), 1.5);
+ clist_d->ug = ug;
+ evas_object_smart_callback_add(clist_d->popup, "timeout", ctui_list_ug_hide_cb, clist_d->ug);
+ return clist_d->popup;
+ }
+ c_retvm_if(-1 == ret, NULL, "ct_list_parse_bundle() Failed");
+
+ clist_d->win = ug_get_window();
+ parent = ug_get_parent_layout(ug);
+ c_retvm_if(NULL == parent, NULL, "ug_get_parent_layout() return NULL");
+ clist_d->ug = ug;
+
+ bindtextdomain(PACKAGE, "/opt/ug/res/locale");
+
+ ret = contacts_svc_connect();
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_connect() Failed(%d)", ret);
+
+ if (UG_MODE_FULLVIEW == mode)
+ base = ctui_create_base_layout(parent, true);
+ else
+ base = ctui_create_base_layout(parent, false);
+
+ bg = ctui_set_bg(base);
+ if (NULL == bg) {
+ ERR("ctui_set_bg() return NULL");
+ evas_object_del(base);
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+ return NULL;
+ }
+
+ if (FALSE == create_list_view(base, clist_d)) {
+ evas_object_del(base);
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+ }
+
+ return base;
+}
+
+static void list_on_message(struct ui_gadget *ug, bundle *msg, bundle *data, void *priv)
+{
+ const char* val = NULL;
+ ct_list_data *clist_d = priv;
+
+ c_retm_if(NULL == msg, "msg is NULL");
+
+ val = bundle_get_val(msg, "reset");
+ if (val && atoi(val))
+ ctui_list_view_reset(clist_d);
+}
+
+static void list_on_pause(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ ct_list_data *clist_d = priv;
+ clist_d->order_sorting = contacts_svc_get_order(CTS_ORDER_OF_SORTING);
+ clist_d->order_display = contacts_svc_get_order(CTS_ORDER_OF_DISPLAY);
+
+ clist_d->is_background = true;
+}
+
+static void list_on_resume(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ ct_list_data *clist_d = priv;
+ ct_detail_data *cdetail_d;
+
+ if (clist_d->order_display != contacts_svc_get_order(CTS_ORDER_OF_DISPLAY)) {
+ ctui_list_genlist_update(clist_d);
+ cdetail_d = evas_object_data_get(clist_d->navi, "cdetail_d");
+ if (cdetail_d)
+ ctui_detail_genlist_update(cdetail_d);
+ }
+ else if (clist_d->order_sorting != contacts_svc_get_order(CTS_ORDER_OF_SORTING)) {
+ ctui_list_genlist_update(clist_d);
+ }
+
+ clist_d->is_background = false;
+ if (clist_d->update_timer) {
+ ecore_timer_del(clist_d->update_timer);
+ clist_d->update_timer = NULL;
+ ctui_list_genlist_update(clist_d);
+ }
+}
+
+static void list_on_destroy(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ int ret;
+ c_retm_if(NULL == ug, "The parameter is invalid(ug=%p)", ug);
+
+ evas_object_del(ug_get_layout(ug));
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+}
+
+API int UG_MODULE_INIT(struct ug_module_ops *ops)
+{
+ ct_list_data *clist_d;
+
+ c_retvm_if(!ops, -1, "ops is NULL");
+
+ clist_d = calloc(1, sizeof(ct_list_data));
+ c_retvm_if(!clist_d, -1, "UG data is NULL, Not enough memory");
+
+ ops->create = list_on_create;
+ ops->start = NULL;
+ ops->pause = list_on_pause;
+ ops->resume = list_on_resume;
+ ops->destroy = list_on_destroy;
+ ops->message = list_on_message;
+ ops->key_event = NULL;
+ ops->priv = clist_d;
+ ops->opt = UG_OPT_INDICATOR_ENABLE;
+
+ return 0;
+}
+
+API void UG_MODULE_EXIT(struct ug_module_ops *ops)
+{
+ c_retm_if(!ops, "ops is NULL");
+
+ ops->priv = NULL;
+}
+
+API Evas_Object* ctui_create_list_view(Evas_Object *win)
+{
+ ct_list_data *clist_d;
+ Evas_Object *bg, *base;
+
+ clist_d = calloc(1, sizeof(ct_list_data));
+ c_retvm_if(!clist_d, NULL, "clist_d is NULL, Not enough memory");
+
+ clist_d->win = win;
+ base = ctui_create_base_layout(win, true);
+
+ if (base) {
+ clist_d->list_op = CT_GET_LIST_ALL_CONTACTS;
+ create_list_view(base, clist_d);
+
+ bg = ctui_set_bg(base);
+ if (NULL == bg) {
+ ERR("ctui_set_bg() return NULL");
+ evas_object_del(base);
+ free(clist_d);
+ return NULL;
+ }
+
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, base);
+ evas_object_show(base);
+ evas_object_data_set(clist_d->navi, "clist_d", clist_d);
+
+ return clist_d->navi;
+ }
+ else {
+ free(clist_d);
+ return NULL;
+ }
+}
+API void ctui_change_background(Evas_Object *obj, bool is_background)
+{
+ ct_list_data *clist_d;
+ clist_d = evas_object_data_get(obj, "clist_d");
+ c_retm_if(NULL == clist_d, "evas_object_data_get() return NULL");
+
+ clist_d->is_background = is_background;
+
+ if (!clist_d->is_background && clist_d->update_timer) {
+ ecore_timer_del(clist_d->update_timer);
+ clist_d->update_timer = NULL;
+ ctui_list_genlist_update(clist_d);
+ }
+}
+API Evas_Object* ctui_create_phone_list_view(void *ug, Evas_Object *win,
+ Evas_Object *navi)
+{
+ ct_list_data *clist_d;
+
+ bindtextdomain(PACKAGE, "/opt/ug/res/locale");
+
+ clist_d = calloc(1, sizeof(ct_list_data));
+ c_retvm_if(!clist_d, NULL, "clist_d is NULL, Not enough memory");
+
+ clist_d->ug = ug;
+ clist_d->win = win;
+ clist_d->navi = navi;
+ clist_d->navi_item = elm_naviframe_bottom_item_get(navi);
+ clist_d->cbar = elm_object_item_part_content_get(clist_d->navi_item,
+ "controlbar");
+
+ clist_d->list_op = CT_GET_LIST_ALL_CONTACTS;
+
+ clist_d->list = ct_list_get_contacts(clist_d);
+ clist_d->content = ct_list_create_contact_view(clist_d);
+ evas_object_data_set(clist_d->navi, "clist_d", clist_d);
+
+ return clist_d->content;
+}
diff --git a/lib/list/ct-list-utils.c b/lib/list/ct-list-utils.c
new file mode 100755
index 0000000..1114fb9
--- /dev/null
+++ b/lib/list/ct-list-utils.c
@@ -0,0 +1,309 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <ui-gadget-module.h>
+#include "contacts.h"
+#include "ct-detail.h"
+#include "ct-list.h"
+#include "ct-list-contact-view.h"
+#include "ct-list-group-view.h"
+#include "ct-list-utils.h"
+
+int ct_list_parse_bundle(bundle *bd, ct_list_data* clist_d)
+{
+ const char* val = NULL;
+
+ if (bd) {
+ val = bundle_get_val(bd, CT_UG_BUNDLE_TYPE);
+ if (val) clist_d->ug_request = atoi(val);
+ CT_DBG("type = %d", clist_d->ug_request);
+
+ switch (clist_d->ug_request) {
+ case CT_UG_REQUEST_LIST:
+ case CT_UG_REQUEST_LIST_WITH_BACK:
+ case CT_UG_REQUEST_SELECT_CONTACT:
+ case CT_UG_REQUEST_SELECT_NUMBER:
+ case CT_UG_REQUEST_SELECT_EMAIL:
+ break;
+ case CT_UG_REQUEST_UPDATE_WITH_NUM:
+ clist_d->ug_data = bundle_get_val(bd, CT_UG_BUNDLE_NUM);
+ break;
+ case CT_UG_REQUEST_UPDATE_WITH_EMAIL:
+ clist_d->ug_data = bundle_get_val(bd, CT_UG_BUNDLE_EMAIL);
+ break;
+ case CT_UG_REQUEST_UPDATE_WITH_WEB:
+ clist_d->ug_data = bundle_get_val(bd, CT_UG_BUNDLE_WEB);
+ break;
+ case CT_UG_REQUEST_CHECK:
+ val = bundle_get_val(bd, CT_UG_BUNDLE_MAX);
+ if (val) clist_d->cnt_max = atoi(val);
+ break;
+ case CT_UG_REQUEST_CHECK_FOR_NUMBER:
+ clist_d->list_op = CT_GET_LIST_ALL_CONTACT_HAD_NUMBER;
+ val = bundle_get_val(bd, CT_UG_BUNDLE_MAX);
+ if (val) clist_d->cnt_max = atoi(val);
+ break;
+ case CT_UG_REQUEST_CHECK_FOR_EMAIL:
+ clist_d->list_op = CT_GET_LIST_ALL_CONTACT_HAD_EMAIL;
+ val = bundle_get_val(bd, CT_UG_BUNDLE_MAX);
+ if (val) clist_d->cnt_max = atoi(val);
+ break;
+ case CT_UG_REQUEST_SAVE_IMG:
+ clist_d->ug_data = bundle_get_val(bd, CT_UG_BUNDLE_PATH);
+ if (-1 == access(clist_d->ug_data, R_OK)) {
+ ERR("Invalid filepath(%s)", clist_d->ug_data);
+ return -2;
+ }
+ break;
+ default:
+ ERR("Invalid request(%d)", clist_d->ug_request);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+void ct_list_free_contacts(Eina_List* list)
+{
+ ct_contact_list *data;
+ Eina_List* l;
+
+ EINA_LIST_FOREACH(list, l, data) {
+ if (data) {
+ free(data->img_path);
+ free(data->display);
+ free(data->normalize);
+ free(data->number);
+ free(data);
+ }
+ }
+ eina_list_free(list);
+}
+
+char* ct_list_get_display_name(CTSvalue *list_info)
+{
+ const char *first, *last;
+ char *display, name[CT_TEXT_MAX_LEN];
+
+ display = contacts_svc_value_steal_str(list_info, CTS_LIST_CONTACT_DISPLAY_STR);
+ if (display) return display;
+
+ first = contacts_svc_value_get_str(list_info, CTS_LIST_CONTACT_FIRST_STR);
+ last = contacts_svc_value_get_str(list_info, CTS_LIST_CONTACT_LAST_STR);
+
+ if (CTS_ORDER_NAME_FIRSTLAST == contacts_svc_get_order(CTS_ORDER_OF_DISPLAY))
+ snprintf(name, sizeof(name), "%s%s%s", SAFE_STR(first), STR_BLANK(first, last));
+ else
+ snprintf(name, sizeof(name), "%s%s%s", SAFE_STR(last), STR_BLANK(last, first));
+
+ return strdup(name);
+}
+
+Eina_List* ct_list_get_contacts(ct_list_data *clist_d)
+{
+ CT_FN_CALL;
+ int ret;
+ CTSiter *iter;
+
+ Eina_List *result = NULL;
+
+ switch (clist_d->list_op) {
+ case CT_GET_LIST_ALL_CONTACTS:
+ ret = contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter);
+ break;
+ case CT_GET_LIST_CONTACTS_OF_ADDRBOOK_ID:
+ ret = contacts_svc_get_list_with_int(CTS_LIST_MEMBERS_OF_ADDRESSBOOK_ID,
+ clist_d->base_ab, &iter);
+ break;
+ case CT_GET_LIST_NOT_ASSIGNED_OF_ADDRBOOK_ID:
+ ret = contacts_svc_get_list_with_int(CTS_LIST_NO_GROUP_MEMBERS_OF_ADDRESSBOOK_ID,
+ clist_d->base_ab, &iter);
+ break;
+ case CT_GET_LIST_CONTACTS_OF_GROUP_ID:
+ ret = contacts_svc_get_list_with_int(CTS_LIST_MEMBERS_OF_GROUP_ID,
+ clist_d->base_grp, &iter);
+ break;
+ case CT_GET_LIST_ALL_CONTACT_HAD_NUMBER:
+ ret = contacts_svc_get_list(CTS_LIST_ALL_CONTACT_HAD_NUMBER, &iter);
+ break;
+ case CT_GET_LIST_ALL_CONTACT_HAD_EMAIL:
+ ret = contacts_svc_get_list(CTS_LIST_ALL_CONTACT_HAD_EMAIL, &iter);
+ break;
+ default:
+ ERR("Invalid op");
+ return NULL;
+ }
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_get_list...() Failed(%d)", ret);
+
+ clist_d->cnt_list = 0;
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ ct_contact_list *info;
+ CTSvalue *value;
+
+ value = contacts_svc_iter_get_info(iter);
+ info = calloc(1, sizeof(ct_contact_list));
+ if (NULL == info) {
+ ERR("calloc() return NULL");
+ break;
+ }
+ info->display = ct_list_get_display_name(value);
+ info->id = contacts_svc_value_get_int(value, CTS_LIST_CONTACT_ID_INT);
+ info->normalize = contacts_svc_value_steal_str(value, CTS_LIST_CONTACT_NORMALIZED_STR);
+ info->id_ab = contacts_svc_value_get_int(value, CTS_LIST_CONTACT_ADDRESSBOOK_ID_INT);
+ result = eina_list_append(result, info);
+ clist_d->cnt_list++;
+ contacts_svc_value_free(value);
+ }
+
+ contacts_svc_iter_remove(iter);
+
+ return result;
+}
+
+void ct_list_update_with_data(ct_list_data *clist_d, int id)
+{
+ int ret;
+ ct_detail_data *cdetail_d;
+ GSList *ct_list;
+ CTSvalue *ct_val;
+
+ cdetail_d = calloc(1, sizeof(ct_detail_data));
+ c_retm_if(!cdetail_d, "cdetail_d is NULL, Not enough memory");
+
+ ctui_ld_to_dd(clist_d, cdetail_d);
+ cdetail_d->contact_id = id;
+
+ if (id)
+ ret = contacts_svc_get_contact(id, &(cdetail_d->contact));
+ else
+ ret = -1;
+
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_get_contact() Failed(%d)", ret);
+ cdetail_d->contact = contacts_svc_struct_new(CTS_STRUCT_CONTACT);
+ }
+
+ switch (clist_d->ug_request) {
+ case CT_UG_REQUEST_UPDATE_WITH_NUM:
+ ct_list = NULL;
+ ct_val = contacts_svc_value_new(CTS_VALUE_NUMBER);
+ contacts_svc_value_set_str(ct_val, CTS_NUM_VAL_NUMBER_STR, clist_d->ug_data);
+ ct_list = g_slist_append(ct_list, ct_val);
+ contacts_svc_struct_store_list(cdetail_d->contact, CTS_CF_NUMBER_LIST, ct_list);
+ g_slist_free(ct_list);
+ break;
+ case CT_UG_REQUEST_UPDATE_WITH_EMAIL:
+ ct_list = NULL;
+ ct_val = contacts_svc_value_new(CTS_VALUE_EMAIL);
+ contacts_svc_value_set_str(ct_val, CTS_EMAIL_VAL_ADDR_STR, clist_d->ug_data);
+ ct_list = g_slist_append(ct_list, ct_val);
+ contacts_svc_struct_store_list(cdetail_d->contact, CTS_CF_EMAIL_LIST, ct_list);
+ g_slist_free(ct_list);
+ break;
+ case CT_UG_REQUEST_UPDATE_WITH_WEB:
+ ct_list = NULL;
+ ct_val = contacts_svc_value_new(CTS_VALUE_WEB);
+ contacts_svc_value_set_str(ct_val, CTS_WEB_VAL_ADDR_STR, clist_d->ug_data);
+ ct_list = g_slist_append(ct_list, ct_val);
+ contacts_svc_struct_store_list(cdetail_d->contact, CTS_CF_WEB_ADDR_LIST, ct_list);
+ g_slist_free(ct_list);
+ break;
+ default:
+ ERR("Invalid type(%d)", clist_d->ug_request);
+ break;
+ }
+
+ ctui_create_input_view(cdetail_d);
+}
+
+void ct_list_popup_hide(ct_list_data *clist_d)
+{
+ evas_object_del(clist_d->popup);
+ clist_d->popup = NULL;
+}
+
+void ct_list_ug_return_ids(struct ui_gadget *ug, int *result_list, int ct_len, const char *bd_key)
+{
+ gchar *encoded_str;
+ bundle *bd;
+
+ bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_create() Failed");
+
+ if (result_list) {
+ encoded_str = g_base64_encode((guchar *)result_list, ct_len*sizeof(int));
+ bundle_add(bd, bd_key, encoded_str);
+ g_free(encoded_str);
+ }
+
+ ug_send_result(ug, bd);
+
+ bundle_free(bd);
+}
+
+static inline int list_check_utf8(char c)
+{
+ if (c < 128)
+ return 1;
+ else if ((c & 0xe0) == 0xc0)
+ return 2;
+ else if ((c & 0xf0) == 0xe0)
+ return 3;
+ else if ((c & 0xf8) == 0xf0)
+ return 4;
+ else if ((c & 0xfc) == 0xf8)
+ return 5;
+ else if ((c & 0xfe) == 0xfc)
+ return 6;
+ else
+ return CTS_ERR_FAIL;
+}
+
+int ct_list_get_fast_index(char *display, int position, char *dest, int dest_size)
+{
+ int i;
+ int pos = 0;
+ int length;
+
+ c_retvm_if(NULL == display || '\0' == *display, 0, "parameter(display) is NULL");
+
+ dest[0] = '\0';
+ for (i=0;i<position;i++) {
+ length = list_check_utf8(display[pos]);
+ c_retvm_if(length < 0, -1, "Unknown character(Not UTF8)");
+ c_retvm_if(dest_size <= length, -1, "dest size is too short");
+ pos += length;
+ }
+ length = list_check_utf8(display[pos]);
+ c_retvm_if(length < 0, -1, "Unknown character(Not UTF8)");
+ c_retvm_if(dest_size <= length, -1, "dest size is too short");
+
+ if ('a' <= display[pos] && display[pos] <= 'z' )
+ snprintf(dest, length+1, "%c", toupper((int)display[pos]));
+ else
+ snprintf(dest, length+1, "%s", &(display[pos]));
+ return 0;
+}
+
diff --git a/lib/list/ct-list-utils.h b/lib/list/ct-list-utils.h
new file mode 100755
index 0000000..78de277
--- /dev/null
+++ b/lib/list/ct-list-utils.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_LIST_UTILS_H__
+#define __CONTACTS_LIST_UTILS_H__
+
+#define CT_LIST_FREQUENT_COUNT 5
+
+enum
+{
+ CT_LIST_UG_REQ_NONE = 0,
+ CT_LIST_UG_REQ_ALL_CONTACTS = 1,
+ CT_LIST_UG_REQ_GROUP_CONTACTS = 2,
+ CT_LIST_UG_REQ_ACCOUNT_CONTACTS = 3,
+ CT_LIST_UG_REQ_SET_CONTACT_IMAGE = 4,
+ CT_LIST_UG_REQ_SET_CONTACT_RINGTONE = 5,
+ CT_LIST_UG_REQ_GET_DEFAULT_NUMBER = 6,
+ CT_LIST_UG_REQ_GET_DEFAULT_EMAIL = 7,
+ CT_LIST_UG_REQ_GET_ONE_CONTACT = 8,
+ CT_LIST_UG_REQ_GET_VCARD = 9,
+ CT_LIST_UG_REQ_SEARCH_CONTACTS = 10,
+};
+
+
+enum {
+ CT_GET_LIST_ALL_CONTACTS = 0,
+ CT_GET_LIST_CONTACTS_OF_ADDRBOOK_ID = 1,
+ CT_GET_LIST_CONTACTS_OF_GROUP_ID = 2,
+ CT_GET_LIST_NOT_ASSIGNED_OF_ADDRBOOK_ID = 3,
+ CT_GET_LIST_SDN = 4,
+ CT_GET_LIST_ALL_CONTACT_HAD_NUMBER = 5,
+ CT_GET_LIST_ALL_CONTACT_HAD_EMAIL = 6,
+};
+
+enum {
+ CT_LIST_MODE_DEFAULT,
+ CT_LIST_MODE_EDIT,
+};
+
+Eina_List* ct_list_get_contacts(ct_list_data *clist_d);
+void ct_list_free_contacts(Eina_List* list);
+int ct_list_parse_bundle(bundle *bd, ct_list_data* clist_d);
+void ct_list_update_with_data(ct_list_data *clist_d, int id);
+void ct_list_popup_hide(ct_list_data *clist_d);
+void ct_list_ug_return_ids(struct ui_gadget *ug, int *ct_id_list, int ct_len, const char *bd_key);
+int ct_list_get_fast_index(char *display, int position, char *dest, int dest_size);
+
+#define CT_MAX_ADDRBOOK 200
+char* ct_list_get_display_name(CTSvalue *list_info);
+
+#endif //__CONTACTS_LIST_UTILS_H__
diff --git a/lib/list/ct-list-view-ug.c b/lib/list/ct-list-view-ug.c
new file mode 100755
index 0000000..81c3407
--- /dev/null
+++ b/lib/list/ct-list-view-ug.c
@@ -0,0 +1,342 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <ui-gadget-module.h>
+
+#include "contacts.h"
+#include "ct-list.h"
+#include "ct-detail.h"
+#include "ct-list-utils.h"
+#include "ct-list-edit-view.h"
+#include "ct-list-contact-view.h"
+
+static void list_ug_nums_popup_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_list_data *clist_d = evas_object_data_get(obj, "clist_d");
+ int contact_id = (int)evas_object_data_get(obj, "ct_id");
+
+ if (CT_UG_REQUEST_CHECK_FOR_NUMBER == clist_d->ug_request) {
+ Elm_Object_Item *item;
+ ct_contact_list *contact;
+
+ item = evas_object_data_get(obj, "item");
+ c_retm_if(NULL == item, "evas_object_data_get() return NULL");
+
+ contact = elm_object_item_data_get(item);
+ c_retm_if(NULL == contact, "elm_object_item_data_get() return NULL");
+
+ contact->id_ret = (int)data;
+ ct_list_edit_update_selection_info(clist_d);
+ ct_list_popup_hide(clist_d);
+ }
+ else {
+ ctui_ug_return_id(clist_d->ug, contact_id, (int)data, 0);
+ ug_destroy_me(clist_d->ug);
+ }
+}
+
+static void list_ug_emails_popup_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_list_data *clist_d = evas_object_data_get(obj, "clist_d");
+ int contact_id = (int)evas_object_data_get(obj, "ct_id");
+
+ if (CT_UG_REQUEST_CHECK_FOR_EMAIL == clist_d->ug_request) {
+ Elm_Object_Item *item;
+ ct_contact_list *contact;
+
+ item = evas_object_data_get(obj, "item");
+ c_retm_if(NULL == item, "evas_object_data_get() return NULL");
+
+ contact = elm_object_item_data_get(item);
+ c_retm_if(NULL == contact, "elm_object_item_data_get() return NULL");
+
+ contact->id_ret = (int)data;
+ ct_list_edit_update_selection_info(clist_d);
+ ct_list_popup_hide(clist_d);
+ }
+ else {
+ ctui_ug_return_id(clist_d->ug, contact_id, 0, (int)data);
+ ug_destroy_me(clist_d->ug);
+ }
+}
+
+static void list_ug_popup_cancel_cb(void *data,Evas_Object *obj, void *event_info)
+{
+ ct_list_data *clist_d;
+ Elm_Object_Item *item;
+ ct_contact_list *contact;
+
+
+
+ clist_d = evas_object_data_get(data, "clist_d");
+ c_retm_if(NULL == clist_d, "evas_object_data_get() return NULL");
+
+ evas_object_del(clist_d->popup);
+ clist_d->popup = NULL;
+
+ item = evas_object_data_get(data, "item");
+ c_retm_if(NULL == item, "evas_object_data_get() return NULL");
+
+ contact = elm_object_item_data_get(item);
+ c_retm_if(NULL == contact, "elm_object_item_data_get() return NULL");
+
+ contact->checked = EINA_FALSE;
+ clist_d->cnt_checked--;
+ elm_genlist_item_update(item);
+}
+
+
+static Evas_Object* list_ug_create_values_list(int type, ct_list_data *clist_d,
+ int contact_id, GSList *values)
+{
+ GSList *cursor;
+ Evas_Object *list;
+ Evas_Object *popup;
+
+ popup = elm_popup_add(clist_d->navi);
+ elm_object_style_set(popup, "min_liststyle");
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ list = elm_list_add(popup);
+ evas_object_data_set(list, "clist_d", clist_d);
+ evas_object_data_set(list, "ct_id", (void *)contact_id);
+ evas_object_size_hint_max_set(list, -1, 600 * elm_config_scale_get()); // TODO : should be revise
+
+ for (cursor=values;cursor;cursor=cursor->next) {
+ int id, val_type;
+ const char *value, *type_str;
+ char buf[CT_TEXT_MAX_LEN];
+ if (CTS_VALUE_EMAIL == type) {
+ id = contacts_svc_value_get_int(cursor->data, CTS_EMAIL_VAL_ID_INT);
+ val_type = contacts_svc_value_get_int(cursor->data, CTS_EMAIL_VAL_TYPE_INT);
+ type_str = T_(CT_GET_TEXT_EMAIL_TYPE, val_type);
+ value = contacts_svc_value_get_str(cursor->data, CTS_EMAIL_VAL_ADDR_STR);
+
+ snprintf(buf, sizeof(buf), "%s %s", type_str, value);
+ elm_list_item_append(list, buf, NULL, NULL, list_ug_emails_popup_sel, (void *)id);
+ }
+ else{
+ char num_type_str[CT_TEXT_SHORT_LEN];
+ id = contacts_svc_value_get_int(cursor->data, CTS_NUM_VAL_ID_INT);
+ val_type = contacts_svc_value_get_int(cursor->data, CTS_NUM_VAL_TYPE_INT);
+ ctui_get_number_type_str(val_type, num_type_str, sizeof(num_type_str));
+ value = contacts_svc_value_get_str(cursor->data, CTS_NUM_VAL_NUMBER_STR);
+
+ snprintf(buf, sizeof(buf), "%s %s", num_type_str, value);
+ elm_list_item_append(list, buf, NULL, NULL, list_ug_nums_popup_sel, (void *)id);
+ }
+ }
+
+ elm_list_mode_set(list, ELM_LIST_EXPAND);
+ elm_object_content_set(popup, list);
+
+ ctui_create_popup_button(popup, 1, S_(CT_SYS_POP_CLOSE), list_ug_popup_cancel_cb, list);
+
+ clist_d->popup = popup;
+ evas_object_show(popup);
+ return list;
+}
+
+
+static inline void list_ug_handle_select_number(ct_list_data *clist_d, int contact_id)
+{
+ GSList *list=NULL;
+ CTSstruct *contact = NULL;
+ int ret = contacts_svc_get_contact(contact_id, &contact);
+ c_retm_if(ret<CTS_SUCCESS, "contacts_svc_get_contact() Failed(%d)", ret);
+
+ contacts_svc_struct_get_list(contact, CTS_CF_NUMBER_LIST, &list);
+ if (list) {
+ if (1 == g_slist_length(list)) {
+ int num_id = contacts_svc_value_get_int(list->data, CTS_NUM_VAL_ID_INT);
+ ctui_ug_return_id(clist_d->ug, contact_id, num_id, 0);
+ ug_destroy_me(clist_d->ug);
+ }
+ else
+ list_ug_create_values_list(CTS_VALUE_NUMBER, clist_d, contact_id, list);
+ }
+ else {
+ ctui_create_popup(clist_d->navi, T_(CT_GET_TEXT_ERR, CTTEXT_NO_NUMBER), 1.5);
+ }
+ contacts_svc_struct_free(contact);
+}
+
+static inline void list_ug_handle_select_email(ct_list_data *clist_d, int contact_id)
+{
+ CTSstruct *contact = NULL;
+ int ret = contacts_svc_get_contact(contact_id, &contact);
+ c_retm_if(ret<CTS_SUCCESS, "contacts_svc_get_contact() Failed(%d)", ret);
+
+ GSList *emails=NULL;
+ contacts_svc_struct_get_list(contact, CTS_CF_EMAIL_LIST, &emails);
+ if (emails) {
+ if (1 == g_slist_length(emails)) {
+ int email_id = contacts_svc_value_get_int(emails->data, CTS_EMAIL_VAL_ID_INT);
+ ctui_ug_return_id(clist_d->ug, contact_id, 0, email_id);
+ ug_destroy_me(clist_d->ug);
+ }
+ else
+ list_ug_create_values_list(CTS_VALUE_EMAIL, clist_d, contact_id, emails);
+ }
+ else {
+ ctui_create_popup(clist_d->navi, T_(CT_GET_TEXT_ERR, CTTEXT_NO_EMAIL), 1.5);
+ }
+ contacts_svc_struct_free(contact);
+}
+
+void ct_list_ug_handle_check_for_number(Elm_Object_Item *item, ct_list_data *clist_d)
+{
+ int ret;
+ GSList *list=NULL;
+ ct_contact_list *ct_info;
+ CTSstruct* contact;
+ Evas_Object *list_nums;
+
+ ct_info = elm_object_item_data_get(item);
+ c_retm_if(NULL == ct_info, "elm_object_item_data_get() return NULL");
+
+ ret = contacts_svc_get_contact(ct_info->id, &contact);
+ c_retm_if(ret<CTS_SUCCESS, "contacts_svc_get_contact() Failed(%d)", ret);
+
+ contacts_svc_struct_get_list(contact, CTS_CF_NUMBER_LIST, &list);
+
+ if (NULL == list) {
+ ERR("contacts_svc_struct_get_list() return NULL");
+ contacts_svc_struct_free(contact);
+ return;
+ }
+
+ if (1 == g_slist_length(list)) {
+ ct_info->id_ret = contacts_svc_value_get_int(list->data, CTS_NUM_VAL_ID_INT);
+ ct_list_edit_update_selection_info(clist_d);
+ }
+ else {
+ list_nums = list_ug_create_values_list(CTS_VALUE_NUMBER, clist_d, ct_info->id, list);
+ c_retm_if(NULL == list_nums, "list_ug_create_values_list() return NULL");
+ evas_object_data_set(list_nums, "item", item);
+ }
+
+ contacts_svc_struct_free(contact);
+}
+
+void ct_list_ug_handle_check_for_email(Elm_Object_Item *item, ct_list_data *clist_d)
+{
+ int ret;
+ GSList *list=NULL;
+ CTSstruct *contact;
+ Evas_Object *list_emails;
+ ct_contact_list *ct_info;
+
+ ct_info = elm_object_item_data_get(item);
+ c_retm_if(NULL == ct_info, "elm_object_item_data_get() return NULL");
+
+ ret = contacts_svc_get_contact(ct_info->id, &contact);
+ c_retm_if(ret<CTS_SUCCESS, "contacts_svc_get_contact() Failed(%d)", ret);
+
+ contacts_svc_struct_get_list(contact, CTS_CF_EMAIL_LIST, &list);
+
+ if (NULL == list) {
+ ERR("contacts_svc_struct_get_list() return NULL");
+ contacts_svc_struct_free(contact);
+ return;
+ }
+
+ if (1 == g_slist_length(list)) {
+ ct_info->id_ret = contacts_svc_value_get_int(list->data, CTS_EMAIL_VAL_ID_INT);
+ ct_list_edit_update_selection_info(clist_d);
+ }
+ else {
+ list_emails = list_ug_create_values_list(CTS_VALUE_EMAIL, clist_d, ct_info->id, list);
+ c_retm_if(NULL == list_emails, "list_ug_create_values_list() return NULL");
+ evas_object_data_set(list_emails, "item", item);
+ }
+
+ contacts_svc_struct_free(contact);
+
+}
+
+void ct_list_ug_gl_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_list_data *clist_d = data;
+ ct_contact_list *contact;
+ Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+
+ if (CT_LIST_VIEW_EDIT == clist_d->list_mode) {
+ ct_contact_list *contact = elm_object_item_data_get(item);
+ c_retm_if(NULL == contact, "elm_object_item_data_get() returns NULL");
+
+ contact->checked = !contact->checked;
+ ct_list_item_checked_set(item, clist_d);
+ if (!contact->checked) {
+ ct_list_edit_update_selection_info(clist_d);
+ return;
+ }
+
+ if (CT_UG_REQUEST_CHECK_FOR_NUMBER == clist_d->ug_request)
+ ct_list_ug_handle_check_for_number(item, clist_d);
+ else if (CT_UG_REQUEST_CHECK_FOR_EMAIL == clist_d->ug_request)
+ ct_list_ug_handle_check_for_email(item, clist_d);
+ else
+ ct_list_edit_update_selection_info(clist_d);
+
+ return;
+ }
+
+ contact = elm_object_item_data_get(item);
+ c_retm_if(NULL == contact, "elm_object_item_data_get() returns NULL");
+
+ switch (clist_d->ug_request) {
+ case CT_UG_REQUEST_LIST:
+ case CT_UG_REQUEST_LIST_WITH_BACK:
+ ret = ctui_create_detail_view(clist_d, contact->id);
+ c_warn_if(ret < 0, "ctui_create_detail_view() Failed");
+ break;
+ case CT_UG_REQUEST_SELECT_CONTACT:
+ if (clist_d->ug) {
+ ctui_ug_return_id(clist_d->ug, contact->id, 0, 0);
+ ug_destroy_me(clist_d->ug);
+ clist_d->ug = NULL;
+ }
+ break;
+ case CT_UG_REQUEST_SELECT_NUMBER:
+ list_ug_handle_select_number(clist_d, contact->id);
+ break;
+ case CT_UG_REQUEST_SELECT_EMAIL:
+ list_ug_handle_select_email(clist_d, contact->id);
+ break;
+ case CT_UG_REQUEST_UPDATE_WITH_NUM:
+ case CT_UG_REQUEST_UPDATE_WITH_EMAIL:
+ case CT_UG_REQUEST_UPDATE_WITH_WEB:
+ ct_list_update_with_data(clist_d, contact->id);
+ break;
+ default:
+ ERR("Invalid ug_request(%d)", clist_d->ug_request);
+ break;
+ }
+}
+
diff --git a/lib/list/ct-list-view-ug.h b/lib/list/ct-list-view-ug.h
new file mode 100644
index 0000000..97f554a
--- /dev/null
+++ b/lib/list/ct-list-view-ug.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_LIST_VIEW_UG_H__
+#define __CONTACTS_LIST_VIEW_UG_H__
+
+void ct_list_ug_gl_sel(void *data, Evas_Object *obj, void *event_info);
+void ct_list_ug_handle_check_for_email(Elm_Object_Item *item, ct_list_data *clist_d);
+void ct_list_ug_handle_check_for_number(Elm_Object_Item *item, ct_list_data *clist_d);
+
+#endif //__CONTACTS_LIST_VIEW_UG_H__
+
diff --git a/lib/settings/CMakeLists.txt b/lib/settings/CMakeLists.txt
new file mode 100755
index 0000000..8c056ff
--- /dev/null
+++ b/lib/settings/CMakeLists.txt
@@ -0,0 +1,14 @@
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
+
+SET(TARGET ${CT_SETTING})
+
+FILE(GLOB SRCS *.c)
+
+ADD_LIBRARY(${TARGET} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
+TARGET_LINK_LIBRARIES(${TARGET} ${COMMON_LIB} ${ug_pkgs_LDFLAGS})
+
+ADD_DEPENDENCIES(${TARGET} contacts_edj_build)
+
+INSTALL(TARGETS ${TARGET} DESTINATION ${UGLIBDIR})
+
diff --git a/lib/settings/ct-setting-main.c b/lib/settings/ct-setting-main.c
new file mode 100755
index 0000000..a578cdc
--- /dev/null
+++ b/lib/settings/ct-setting-main.c
@@ -0,0 +1,182 @@
+
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+#include <ui-gadget-module.h>
+#include "contacts.h"
+#include "ct-common.h"
+#include "ct-setting-view.h"
+
+static int create_setting_view(Evas_Object *parent, ct_setting_data *csetting_d)
+{
+ Evas_Object *l_btn;
+ Evas_Object *content;
+ Elm_Object_Item *navi_item;
+
+ c_retvm_if(NULL == parent, FALSE, "parameter(parent) is NULL");
+
+ csetting_d->navi = elm_naviframe_add(parent);
+ evas_object_show(csetting_d->navi);
+ c_retvm_if(NULL == csetting_d->navi, FALSE, "navi is NULL");
+
+ content = ct_setting_create_layout(csetting_d);
+ navi_item = elm_naviframe_item_push(csetting_d->navi, S_(CT_SYS_BODY_CONTACTS), NULL, NULL, content, NULL);
+
+ l_btn = elm_button_add(csetting_d->navi);
+ c_retvm_if(NULL == l_btn, -1, "elm_button_add() return NULL");
+
+ elm_object_item_part_content_set(navi_item, "prev_btn", l_btn);
+ elm_object_style_set(l_btn, "naviframe/back_btn/default");
+ evas_object_smart_callback_add(l_btn, "clicked", ctui_ug_destroy_me_cb, csetting_d->ug);
+
+ return TRUE;
+}
+
+static void* settings_on_create(struct ui_gadget *ug, enum ug_mode mode,
+ bundle *data, void *priv)
+{
+ int ret;
+ Evas_Object *bg;
+ Evas_Object *parent;
+ Evas_Object *base;
+ ct_setting_data *csetting_d = priv;
+
+ c_retvm_if(NULL == ug || NULL == priv, NULL,
+ "The parameter is invalid(ug=%p, priv=%p)", ug, priv);
+
+ parent = ug_get_parent_layout(ug);
+ c_retvm_if(NULL == parent, NULL, "ug_get_parent_layout() return NULL");
+ csetting_d->ug = ug;
+
+ bindtextdomain(PACKAGE, "/opt/ug/res/locale");
+
+ ret = contacts_svc_connect();
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_connect() Failed(%d)", ret);
+
+ if (UG_MODE_FULLVIEW == mode)
+ base = ctui_create_base_layout(parent, true);
+ else {
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+ return NULL;
+ }
+
+ bg = ctui_set_bg(base);
+ if (NULL == bg) {
+ ERR("ctui_set_bg() return NULL");
+ evas_object_del(base);
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+ return NULL;
+ }
+
+ if (create_setting_view(base, csetting_d ))
+ elm_object_part_content_set(base, "elm.swallow.content", csetting_d->navi);
+ else {
+ evas_object_del(base);
+ base = NULL;
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+ }
+
+ return base;
+}
+
+static void settings_on_key_event(struct ui_gadget *ug, enum ug_key_event event, bundle *data, void *priv)
+{
+ if (!ug)
+ return;
+
+ switch (event) {
+ case UG_KEY_EVENT_END:
+ ug_destroy_me(ug);
+ break;
+ default:
+ break;
+ }
+}
+
+static void settings_on_destroy(struct ui_gadget *ug, bundle *data, void *priv)
+{
+ int ret;
+ ct_setting_data *csetting_d = priv;
+
+ c_retm_if(NULL == ug, "The ug is NULL(ug = %p)", ug);
+
+ if (csetting_d->p_info) {
+ csetting_d->p_info->alive = false;
+ pthread_join(csetting_d->p_info->thread, NULL);
+
+ ret = contacts_svc_end_trans(false);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+ ecore_timer_del(csetting_d->p_info->timer);
+ free(csetting_d->p_info);
+ csetting_d->p_info = NULL;
+ }
+ free(csetting_d->path);
+ free(csetting_d->name_ab);
+ eina_list_free(csetting_d->list_id_ab);
+ free(csetting_d);
+
+ evas_object_del(ug_get_layout(ug));
+
+ ret = contacts_svc_disconnect();
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_disconnect() Failed(%d)", ret);
+}
+
+API int UG_MODULE_INIT(struct ug_module_ops *ops)
+{
+ ct_setting_data *csetting_d ;
+
+ c_retvm_if(!ops, -1, "ops is NULL");
+
+ csetting_d = calloc(1, sizeof(ct_setting_data));
+ c_retvm_if(NULL == csetting_d , -1, "calloc() return NULL");
+
+ ops->create = settings_on_create;
+ ops->start = NULL;
+ ops->pause = NULL;
+ ops->resume = NULL;
+ ops->destroy = settings_on_destroy;
+ ops->message = NULL;
+ ops->event = NULL;
+ ops->key_event = settings_on_key_event;
+ ops->priv = csetting_d ;
+ ops->opt = UG_OPT_INDICATOR_PORTRAIT_ONLY;
+
+ return 0;
+}
+
+API void UG_MODULE_EXIT(struct ug_module_ops *ops)
+{
+ if (!ops)
+ return;
+
+ ops->priv = NULL;
+}
+
+API int setting_plugin_reset(bundle *data, void *priv)
+{
+ return 0;
+}
diff --git a/lib/settings/ct-setting-view.c b/lib/settings/ct-setting-view.c
new file mode 100755
index 0000000..0623aad
--- /dev/null
+++ b/lib/settings/ct-setting-view.c
@@ -0,0 +1,1117 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#include <fcntl.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <unistd.h>
+#include <pthread.h>
+#include "contacts.h"
+#include "ct-common.h"
+#include "ct-setting-view.h"
+
+enum SETTING_ITC_TYPE{
+ SETTING_ITC_MY_NUM = 0,
+ SETTING_ITC_TEXT = 1,
+ SETTING_ITC_IMPORT_SIM = SETTING_ITC_TEXT,
+ SETTING_ITC_IMPORT_NO_SIM = SETTING_ITC_TEXT,
+ SETTING_ITC_IMPORT = SETTING_ITC_TEXT,
+ SETTING_ITC_EXPORT = SETTING_ITC_TEXT,
+ SETTING_ITC_ORDER = 2,
+ SETTING_ITC_RADIO = 3,
+ SETTING_ITC_FIRSTLAST = SETTING_ITC_RADIO,
+ SETTING_ITC_LASTFIRST = SETTING_ITC_RADIO,
+ SETTING_ITC_ADDRBOOK = 4,
+ SETTING_ITC_ADDRBOOK_NAME = 5,
+ SETTING_ITC_MAX,
+};
+
+static Elm_Genlist_Item_Class setting_itcs[] = {
+ {.item_style="dialogue/2text.2"},
+ {.item_style="dialogue.1text"},
+ {.item_style="dialogue/2text.3/expandable"},
+ {.item_style="dialogue/1text.1icon/expandable2"},
+ {.item_style="1text.1icon.2"},
+ {.item_style="2text.1icon.4"},
+};
+
+enum
+{
+ SETTING_EXPORT_CONTACT,
+ SETTING_IMPORT_CONTACT
+};
+
+static void setting_popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_setting_data *csetting_d = data;
+ c_retm_if(NULL == csetting_d, "parameter(csetting_d) is NULL");
+
+ csetting_d->select_all_checked = EINA_FALSE;
+ evas_object_del(csetting_d->popup);
+ csetting_d->popup = NULL;
+}
+
+static void setting_addrbook_select_all_update(Evas_Object *genlist)
+{
+ Eina_Bool checked;
+ Eina_Bool select_all_checked;
+ Elm_Object_Item *item;
+ Evas_Object *select_all_check;
+ ct_ab_popup_data *ab_popup_data;
+
+ select_all_check = evas_object_data_get(genlist, "check");
+ c_retm_if(NULL == select_all_check, "evas_object_data_get() return NULL");
+
+ select_all_checked = elm_check_state_get(select_all_check);
+
+ checked = EINA_TRUE;
+ item = elm_genlist_first_item_get(genlist);
+ while (item) {
+ ab_popup_data = elm_object_item_data_get(item);
+ c_retm_if(NULL == ab_popup_data, "elm_object_item_data_get() return NULL");
+ if (EINA_FALSE == ab_popup_data->checked) {
+ checked = EINA_FALSE;
+ break;
+ }
+ item = elm_genlist_item_next_get(item);
+ }
+
+ if (select_all_checked != checked)
+ elm_check_state_set(select_all_check, checked);
+}
+
+static void setting_export_ab_list_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ CT_FN_CALL;
+
+ ct_ab_popup_data *ab_popup_data = data;
+ c_retm_if(NULL == ab_popup_data, "parameter(ab_popup_data) is NULL");
+ elm_genlist_item_selected_set(event_info, EINA_FALSE);
+
+ ab_popup_data->checked = !ab_popup_data->checked;
+ if (ab_popup_data->item)
+ elm_genlist_item_update(ab_popup_data->item);
+
+ setting_addrbook_select_all_update(obj);
+}
+
+void setting_select_all(ct_setting_data *csetting_d)
+{
+ Elm_Object_Item *item;
+ ct_ab_popup_data *ab_popup_data;
+
+ item = elm_genlist_first_item_get(csetting_d->genlist);
+ while (item) {
+ ab_popup_data = elm_object_item_data_get(item);
+ ab_popup_data->checked = csetting_d->select_all_checked;
+ item = elm_genlist_item_next_get(item);
+ }
+ elm_genlist_realized_items_update(csetting_d->genlist);
+}
+
+static void setting_select_all_mouse_up_cb(void *data, Evas *e,
+ Evas_Object *obj, void *event_info)
+{
+ CT_FN_CALL;
+ int x, y, w, h;
+ ct_setting_data *csetting_d = data;
+ Evas_Event_Mouse_Up *ev = event_info;
+
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ return;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ if (ev->output.y < y || y + h < ev->output.y)
+ return;
+
+ csetting_d->select_all_checked = !csetting_d->select_all_checked;
+ elm_check_state_set(csetting_d->select_all_check, csetting_d->select_all_checked);
+ setting_select_all(csetting_d);
+}
+
+static void setting_select_all_check_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ setting_select_all(data);
+}
+
+static void setting_process_end(ct_setting_data *csetting_d )
+{
+ ct_progress_info *p_info = csetting_d->p_info;
+
+ free(p_info);
+ csetting_d->p_info = NULL;
+}
+
+static void setting_order(int order_type)
+{
+ int ret;
+
+ /* set ORDER_OF_DISPLAY */
+ ret = contacts_svc_set_order(CTS_ORDER_OF_DISPLAY, order_type);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_set_order() Failed(%d)", ret);
+
+ ret = contacts_svc_set_order(CTS_ORDER_OF_SORTING, order_type);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_set_order() Failed(%d)", ret);
+}
+
+static void setting_order_ui(Evas_Object *genlist)
+{
+ int order;
+ ct_setting_data *csetting_d;
+ Elm_Object_Item *item_order;
+
+ c_retm_if(NULL == genlist, "parameter(genlist) is NULL");
+
+ csetting_d = evas_object_data_get(genlist, "csetting_d");
+ c_retm_if(NULL == csetting_d, "evas_object_data_get() return NULL");
+
+ order = contacts_svc_get_order(CTS_ORDER_OF_DISPLAY);
+ elm_radio_value_set(csetting_d->radio_grp, order);
+
+ item_order = evas_object_data_get(genlist, "order");
+ c_retm_if(NULL == item_order, "evas_object_data_get() return NULL");
+
+ elm_genlist_item_update(item_order);
+}
+
+static void setting_handle_order(void *data, Evas_Object *obj, void *event_info)
+{
+
+ Elm_Object_Item *it = event_info;
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+
+ setting_order((int)data);
+ setting_order_ui(obj);
+}
+
+static PTHREAD_FN setting_import_sim_contacts(void *data)
+{
+ ct_setting_data *csetting_d = data;
+ ct_progress_info *p_info = csetting_d->p_info;
+ p_info->result = contacts_svc_import_sim();
+ p_info->completed = true;
+ pthread_exit(NULL);
+}
+
+static Eina_Bool setting_import_sim_timer_cb(void *data)
+{
+ const char *message;
+ ct_setting_data *csetting_d = data;
+ ct_progress_info *p_info;
+
+ c_retvm_if(NULL == csetting_d , ECORE_CALLBACK_CANCEL, "parameter(ct_setting_data) is NULL");
+ p_info = csetting_d->p_info;
+ c_retv_if(!p_info->completed, ECORE_CALLBACK_RENEW);
+
+ pthread_join(p_info->thread, NULL);
+
+ if (CTS_SUCCESS == p_info->result)
+ message = T_(CT_GET_TEXT_BASIC, CTTEXT_IMPORTED);
+ else if (CTS_ERR_NO_DATA == p_info->result)
+ message = T_(CT_GET_TEXT_ERR, CTTEXT_IMPORT_SIM_NO_DATA);
+ else
+ message = S_(CT_SYS_POP_FAILED);
+
+ evas_object_del(csetting_d->popup);
+
+ free(p_info);
+ csetting_d->p_info = NULL;
+
+ ctui_show_notify(csetting_d->navi, message, 2.0);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+static void setting_import_sim_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int ret;
+ ct_progress_info *p_info;
+ ct_setting_data *csetting_d = data;
+ Elm_Object_Item *it = event_info;
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+
+ c_retm_if(csetting_d->p_info, "thread is running");
+ c_retm_if(NULL == data, "parameter(ct_setting_data) is NULL");
+
+ p_info = calloc(1, sizeof(ct_progress_info));
+ c_retm_if(NULL == p_info, "calloc() return NULL");
+ csetting_d->p_info = p_info;
+ p_info->alive = true;
+ p_info->result = TRUE;
+
+ ret = pthread_create(&p_info->thread, NULL, setting_import_sim_contacts, csetting_d );
+ if (0 != ret) {
+ ERR("Thread creation failed(%d)", ret);
+ free(p_info);
+ csetting_d->p_info = NULL;
+ return;
+ }
+
+ p_info->timer = ecore_timer_add(0.1, setting_import_sim_timer_cb, csetting_d );
+ if (NULL == p_info->timer) {
+ ERR("ecore_timer_ada() return NULL");
+ p_info->alive = false;
+ pthread_join(p_info->thread, NULL);
+ free(p_info);
+ csetting_d->p_info = NULL;
+ return;
+ }
+ csetting_d->popup = ctui_progressbar_popup(csetting_d->navi, p_info);
+ elm_object_text_set(p_info->label, T_(CT_GET_TEXT_BASIC, CTTEXT_IMPORTING_SIM_CONTACTS));
+}
+
+static inline Eina_List* setting_get_contact_list(Eina_List *list_ab)
+{
+ int ret;
+ CTSiter *iter;
+ Eina_List *result;
+ Eina_List *l;
+ int id_ab;
+ void *data;
+
+ result = NULL;
+ EINA_LIST_FOREACH(list_ab, l, data) {
+ id_ab = (int)data;
+ ret = contacts_svc_get_list_with_int(CTS_LIST_MEMBERS_OF_ADDRESSBOOK_ID, id_ab, &iter);
+ c_retvm_if(CTS_SUCCESS != ret, NULL, "contacts_svc_get_list...() Failed(%d)", ret);
+
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue *info = contacts_svc_iter_get_info(iter);
+ int id = contacts_svc_value_get_int(info, CTS_LIST_CONTACT_ID_INT);
+ result = eina_list_append(result, (void *)id);
+ contacts_svc_value_free(info);
+ }
+ contacts_svc_iter_remove(iter);
+ }
+ return result;
+
+}
+
+static inline void setting_progress_fail(ct_progress_info *p_info)
+{
+ p_info->completed = true;
+ p_info->result = FALSE;
+ pthread_exit(NULL);
+}
+
+static Eina_Bool setting_backup_import_timer_cb(void *data)
+{
+ ct_setting_data *csetting_d = data;
+ ct_progress_info *p_info;
+
+ c_retvm_if(NULL == csetting_d , ECORE_CALLBACK_CANCEL, "parameter(ct_setting_data) is NULL");
+ p_info = csetting_d->p_info;
+
+
+ if (!p_info->completed) {
+ char count[CT_TEXT_SHORT_LEN];
+ char percent[CT_TEXT_SHORT_LEN];
+ double value = (double)p_info->cnt / (double)p_info->cnt_checked_total;
+
+ if (!p_info->alive) {
+ p_info->result = FALSE;
+ p_info->completed = true;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ elm_progressbar_value_set(p_info->progressbar, value);
+ snprintf(percent, sizeof(percent), "%d%%", (int)(100.0 * (double)p_info->cnt/(double)p_info->cnt_checked_total));
+ snprintf(count, sizeof(count), "%d/%d", p_info->cnt, p_info->cnt_checked_total);
+ edje_object_part_text_set(elm_layout_edje_get(p_info->layout), "elm.text.subtext1", percent);
+ edje_object_part_text_set(elm_layout_edje_get(p_info->layout), "elm.text.subtext2", count);
+
+ if (p_info->cnt == p_info->cnt_checked_total)
+ p_info->completed = true;
+
+ return ECORE_CALLBACK_RENEW;
+ }
+ else {
+ int ret;
+ const char *message;
+
+ pthread_join(p_info->thread, NULL);
+
+ if (p_info->result) {
+ if (SETTING_IMPORT_CONTACT== csetting_d->mode)
+ message = T_(CT_GET_TEXT_BASIC, CTTEXT_IMPORTED);
+ else
+ message = T_(CT_GET_TEXT_BASIC, CTTEXT_EXPORTED);
+ ret = contacts_svc_end_trans(true);
+ }
+ else {
+ message = S_(CT_SYS_POP_FAILED);
+ ret = contacts_svc_end_trans(false);
+ }
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+
+ evas_object_del(csetting_d->popup);
+
+ setting_process_end(csetting_d );
+ ctui_show_notify(csetting_d->navi, message, 2.0);
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+}
+
+static PTHREAD_FN setting_export_contacts(void *data)
+{
+ int ret;
+ int fd;
+ int *id;
+ Eina_List *c_list;
+ Eina_List *cursor;
+ ct_setting_data *csetting_d = data;
+ ct_progress_info *p_info = csetting_d->p_info;
+
+ c_list = setting_get_contact_list(csetting_d->list_id_ab);
+
+ fd = open(csetting_d->path, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ if (fd < 0) {
+ ERR("open(%s) Failed", csetting_d->path);
+ setting_progress_fail(p_info);
+ }
+
+ EINA_LIST_FOREACH(c_list, cursor, id) {
+ char* vcard;
+ CTSstruct *contact;
+
+ if (!p_info->alive) {
+ p_info->result = FALSE;
+ p_info->completed = true;
+ break;
+ }
+
+ ret = contacts_svc_get_contact((int)id, &contact);
+ if (ret < CTS_SUCCESS) {
+ ERR("contacts_svc_get_contact() Failed(%d)", ret);
+ p_info->result = FALSE;
+ continue;
+ }
+
+ ret = contacts_svc_get_vcard_from_contact(contact, &vcard);
+ contacts_svc_struct_free(contact);
+ if (ret < CTS_SUCCESS) {
+ ERR("contacts_svc_struct_free() Failed(%d)", ret);
+ p_info->result = FALSE;
+ continue;
+ }
+
+ write(fd, vcard, strlen(vcard));
+ p_info->cnt++;
+ free(vcard);
+ }
+
+ eina_list_free(c_list);
+
+ ret = fsync(fd);
+ if (0 != ret)
+ ERR("fsync() failed(%d)", ret);
+
+ close(fd);
+ if (!p_info->result) {
+ ret = unlink(csetting_d->path);
+ if (0 != ret)
+ ERR("unlink(%s) failed(%d)", csetting_d->path, ret);
+ }
+
+ pthread_exit(NULL);
+}
+
+static void setting_get_filename(char *fullpath, char *dest, int size_dest)
+{
+ char* index;
+ index = strrchr(fullpath, '/');
+ snprintf(dest, size_dest, "%s", index + 1);
+}
+
+static void setting_export_myfile_ug_result(struct ui_gadget *ug, bundle *result, void *data)
+{
+ int ret;
+ Eina_List *c_list;
+ const char *val;
+ char path[CT_TEXT_MAX_LEN];
+ char title[CT_TEXT_MAX_LEN];
+ char filepath[CT_TEXT_SHORT_LEN];
+ ct_progress_info *p_info;
+ ct_setting_data *csetting_d = data;
+
+ c_retm_if(csetting_d->p_info, "thread is running");
+ c_retm_if(NULL == ug, "parameter(ug) is NULL");
+ ug_destroy(ug);
+
+ c_retm_if(NULL == data, "parameter(ct_setting_data) is NULL");
+ c_retm_if(NULL == result, "parameter(result) is NULL");
+
+ c_list = setting_get_contact_list(csetting_d->list_id_ab);
+ if (NULL == c_list) {
+ char err[CT_TEXT_SHORT_LEN];
+ ERR("setting_get_contact_list() return NULL");
+ snprintf(err, sizeof(err), "Fail (%s)", T_(CT_GET_TEXT_ERR, CTTEXT_NO_CONTACTS));
+ ctui_show_notify(csetting_d->navi, err, 2.0);
+ return;
+ }
+
+ val = bundle_get_val(result, "result");
+ c_retm_if(NULL == val, "bundle_get_val() return NULL");
+
+ p_info = calloc(1, sizeof(ct_progress_info));
+ c_retm_if(NULL == p_info, "calloc() return NULL");
+ csetting_d->p_info = p_info;
+
+ p_info->cnt_checked_total = eina_list_count(c_list);
+ if (-1 == p_info->cnt_checked_total) {
+ ERR("eina_list_count() return -1");
+ free(p_info);
+ csetting_d->p_info = NULL;
+ return;
+ }
+
+ free(csetting_d->path);
+ if (csetting_d->name_ab && *csetting_d->name_ab)
+ snprintf(path, sizeof(path), "%s/%s.vcf", (char *)val, csetting_d->name_ab);
+ else
+ snprintf(path, sizeof(path), "%s/contacts.vcf", (char *)val);
+ csetting_d->path = strdup(path);
+
+ p_info->alive = true;
+ p_info->result = TRUE;
+ setting_get_filename(csetting_d->path, filepath, sizeof(filepath));
+ snprintf(title, sizeof(title), "%s<br>%s", T_(CT_GET_TEXT_BASIC, CTTEXT_BACKUP_CONTACTS_TO), filepath);
+
+ ret = pthread_create(&p_info->thread, NULL, setting_export_contacts, csetting_d );
+ if (0 != ret) {
+ ERR("Thread creation failed(%d)", ret);
+ free(p_info);
+ csetting_d->p_info = NULL;
+ return;
+ }
+
+ p_info->timer = ecore_timer_add(0.1, setting_backup_import_timer_cb, csetting_d );
+ if (NULL == p_info->timer) {
+ ERR("ecore_timer_ada() return NULL");
+ p_info->alive = false;
+ pthread_join(p_info->thread, NULL);
+ free(p_info);
+ csetting_d->p_info = NULL;
+ return;
+ }
+
+ csetting_d->popup = ctui_progressbar_popup(csetting_d->navi, p_info);
+ elm_object_text_set(p_info->label, title);
+ ctui_create_popup_button(csetting_d->popup, 1, S_(CT_SYS_SK_CANCEL), setting_popup_hide_cb, NULL);
+}
+
+static void setting_export_contacts_myfile_ug(ct_setting_data *csetting_d)
+{
+ struct ui_gadget* ug;
+ struct ug_cbs cbs = {0};
+
+ bundle *bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_create() Failed");
+ bundle_add(bd, "path", "/opt/data/ug-contacts/");
+ bundle_add(bd, "select_type", "SINGLE_ALL");
+ //bundle_add(bd, "file_type", "FOLDER"); // fail
+ bundle_add(bd, "file_type", "*"); // no file
+
+ cbs.result_cb = setting_export_myfile_ug_result;
+ cbs.layout_cb = ctui_ug_layout_cb;
+ cbs.destroy_cb = ctui_ug_destroy_cb;
+ cbs.priv = csetting_d ;
+
+ ug = ug_create(csetting_d->ug, MYFILES_UG, UG_MODE_FULLVIEW, bd, &cbs);
+ c_warn_if(NULL == ug, "ug_create() Failed");
+
+ bundle_free(bd);
+}
+
+static int setting_import_contact(const char *vcard_stream, void *data)
+{
+ int ret;
+ CTSstruct *contact;
+ ct_setting_data *csetting_d = data;
+ ct_progress_info *p_info = csetting_d->p_info;
+
+ if (!p_info->alive) {
+ p_info->result = FALSE;
+ p_info->completed = true;
+ return CTS_ERR_FAIL;
+ }
+
+ p_info->cnt++;
+ ret = contacts_svc_get_contact_from_vcard(vcard_stream, &contact);
+ if (ret < CTS_SUCCESS) {
+ ERR("contacts_svc_get_contact_from_vcard() Failed(%d)", ret);
+ p_info->result = FALSE;
+ if (p_info->cnt == p_info->cnt_checked_total)
+ p_info->completed = true;
+ return ret;
+ }
+
+ ret = contacts_svc_insert_contact(csetting_d->id_ab, contact);
+ contacts_svc_struct_free(contact);
+ if (ret < CTS_SUCCESS) {
+ ERR("contacts_svc_insert_contact() Failed(%d)", ret);
+ p_info->result = FALSE;
+ }
+
+ if (p_info->cnt == p_info->cnt_checked_total)
+ p_info->completed = true;
+
+ return CTS_SUCCESS;
+}
+
+static PTHREAD_FN setting_import_contacts(void* data)
+{
+ ct_setting_data *csetting_d = data;
+ contacts_svc_vcard_foreach(csetting_d->path, setting_import_contact, csetting_d );
+ pthread_exit(NULL);
+}
+
+static void setting_import_myfile_ug_result(struct ui_gadget *ug, bundle *result, void *data)
+{
+ int ret;
+ const char *val;
+ ct_setting_data *csetting_d = data;
+ ct_progress_info *p_info;
+ char title[CT_TEXT_MAX_LEN];
+ char filepath[CT_TEXT_SHORT_LEN];
+
+ c_retm_if(NULL == ug, "parameter(ug) is NULL");
+ ug_destroy(ug);
+
+ c_retm_if(NULL == data, "parameter(ct_setting_data) is NULL");
+ c_retm_if(NULL == result, "parameter(result) is NULL");
+
+ val = bundle_get_val(result, "result");
+ c_retm_if(NULL == val, "bundle_get_val() return NULL");
+
+ free(csetting_d->path);
+ csetting_d->path = strdup((char *)val);
+ c_retm_if(NULL == csetting_d->path, "strdup() return NULL");
+
+ p_info = calloc(1, sizeof(ct_progress_info));
+ c_retm_if(NULL == p_info, "calloc() return NULL");
+ csetting_d->p_info = p_info;
+
+ p_info->cnt_checked_total = contacts_svc_vcard_count(csetting_d->path);
+ if (-1 == p_info->cnt_checked_total) {
+ ERR("contacts_svc_vcard_count() return -1");
+ free(p_info);
+ csetting_d->p_info = NULL;
+ return;
+ }
+
+ p_info->cnt = 0;
+ p_info->alive = true;
+ p_info->result = TRUE;
+ p_info->completed = false;
+ setting_get_filename(csetting_d->path, filepath, sizeof(filepath));
+ snprintf(title, sizeof(title), "%s<br>%s", T_(CT_GET_TEXT_BASIC, CTTEXT_IMPORTING_SD_CONTACTS), filepath);
+
+ ret = contacts_svc_begin_trans();
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_begin_trans() Failed(%d)", ret);
+ free(p_info);
+ return;
+ }
+
+ ret = pthread_create(&p_info->thread, NULL, setting_import_contacts, csetting_d );
+ if (0 != ret) {
+ ERR("Thread creation failed(%d)", ret);
+ free(p_info);
+ csetting_d->p_info = NULL;
+ ret = contacts_svc_end_trans(false);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+
+ return;
+ }
+
+ p_info->timer = ecore_timer_add(0.1, setting_backup_import_timer_cb, csetting_d );
+ if (NULL == p_info->timer) {
+ ERR("ecore_timer_ada() return NULL");
+
+ p_info->alive = false;
+ pthread_join(p_info->thread, NULL);
+
+ free(p_info);
+ csetting_d->p_info = NULL;
+
+ ret = contacts_svc_end_trans(false);
+ c_warn_if(ret < CTS_SUCCESS, "contacts_svc_end_trans() Failed(%d)", ret);
+
+ return;
+ }
+
+ csetting_d->popup = ctui_progressbar_popup(csetting_d->navi, p_info);
+ elm_object_text_set(p_info->label, title);
+ ctui_create_popup_button(csetting_d->popup, 1, S_(CT_SYS_SK_CANCEL), setting_popup_hide_cb, NULL);
+}
+
+static void setting_import_contacts_myfile_ug(ct_setting_data *csetting_d )
+{
+ struct ui_gadget* ug;
+ struct ug_cbs cbs = {0};
+
+ bundle *bd = bundle_create();
+ c_retm_if(NULL == bd, "bundle_create() Failed");
+ bundle_add(bd, "select_type", "SINGLE_FILE");
+ bundle_add(bd, "file_type", "vcf");
+
+ cbs.result_cb = setting_import_myfile_ug_result;
+ cbs.destroy_cb = ctui_ug_destroy_cb;
+ cbs.layout_cb = ctui_ug_layout_cb;
+ cbs.priv = csetting_d;
+
+ ug = ug_create(csetting_d->ug, MYFILES_UG, UG_MODE_FULLVIEW, bd, &cbs);
+ c_warn_if(NULL == ug, "ug_create() Failed");
+
+ bundle_free(bd);
+}
+
+static void setting_export_ab_popup_response(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *genlist;
+ Elm_Object_Item *item;
+ ct_setting_data *csetting_d = data;
+ ct_ab_popup_data *ab_popup_data;
+
+ eina_list_free(csetting_d->list_id_ab);
+ csetting_d->list_id_ab = NULL;
+
+ genlist = csetting_d->genlist;
+ item = elm_genlist_first_item_get(genlist);
+ while (item) {
+ ab_popup_data = elm_object_item_data_get(item);
+ if (ab_popup_data && EINA_TRUE == ab_popup_data->checked) {
+ csetting_d->list_id_ab = eina_list_append(csetting_d->list_id_ab, (void *)ab_popup_data->id);
+ free(csetting_d->name_ab);
+ csetting_d->name_ab = ab_popup_data->name;
+ ab_popup_data->name = NULL;
+ }
+ item = elm_genlist_item_next_get(item);
+ }
+ if (csetting_d->list_id_ab && 1 != eina_list_count(csetting_d->list_id_ab)) {
+ free(csetting_d->name_ab);
+ csetting_d->name_ab = NULL;
+ }
+ setting_export_contacts_myfile_ug(csetting_d);
+
+ csetting_d->select_all_checked = EINA_FALSE;
+ evas_object_del(csetting_d->popup);
+ csetting_d->popup = NULL;
+}
+
+static void setting_ab_popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_setting_data *csetting_d = data;
+ evas_object_del(csetting_d->popup);
+ csetting_d->popup = NULL;
+}
+
+static void setting_import_ab_list_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_ab_popup_data *info = data;
+ ct_setting_data *csetting_d ;
+
+ c_retm_if(NULL == info, "parameter(info) is NULL");
+
+ csetting_d = evas_object_data_get(obj, "data");
+ c_retm_if(NULL == csetting_d , "evas_object_data_get() return NULL");
+
+ csetting_d->id_ab = info->id;
+ csetting_d->name_ab = info->name;
+ info->name = NULL;
+
+ setting_popup_hide_cb(csetting_d, NULL, NULL);
+ setting_import_contacts_myfile_ug(csetting_d );
+}
+
+static Evas_Object* setting_create_export_addrbook_popup(Evas_Object *parent, ct_setting_data *csetting_d)
+{
+ int ret;
+ CTSiter *iter;
+ Evas_Object *box, *layout;
+ Evas_Object *check;
+ Evas_Object *genlist;
+ Evas_Object *popup;
+ Elm_Object_Item *item;
+ ct_ab_popup_data *ab_popup_data;
+
+ popup = elm_popup_add(parent);
+ c_retvm_if(NULL == popup, NULL, "elm_popup_add() return NULL");
+ elm_object_style_set(popup, "liststyle");
+ ctui_create_popup_button(popup, 1, S_(CT_SYS_SK_OK), setting_export_ab_popup_response, csetting_d);
+ ctui_create_popup_button(popup, 2, S_(CT_SYS_SK_CANCEL), setting_popup_hide_cb, csetting_d);
+ evas_object_show(popup);
+
+ box = elm_box_add(popup);
+ c_retvm_if(NULL == box, NULL, "elm_box_add() return NULL");
+ evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
+ evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ layout = elm_layout_add(box);
+ c_retvm_if(NULL == layout, NULL, "elm_layout_add() return NULL");
+ elm_layout_theme_set(layout, "genlist", "item", "select_all/default");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_UP, setting_select_all_mouse_up_cb, csetting_d);
+
+ check = elm_check_add(layout);
+ c_retvm_if(NULL == check, NULL, "elm_check_add() return NULL");
+ csetting_d->select_all_check = check;
+ elm_check_state_pointer_set(check, &csetting_d->select_all_checked);
+ evas_object_smart_callback_add(check, "changed", setting_select_all_check_cb, csetting_d);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ elm_object_part_content_set(layout, "elm.icon", check);
+
+ elm_object_part_text_set(layout, "elm.text", S_(CT_SYS_BODY_SELECT_ALL));
+ elm_box_pack_start(box, layout);
+ evas_object_show(layout);
+
+ genlist = elm_genlist_add(box);
+ c_retvm_if(NULL == genlist, NULL, "elm_genlist_add() return NULL");
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ csetting_d->genlist = genlist;
+ evas_object_data_set(genlist, "check", check);
+
+ ab_popup_data = calloc(1, sizeof(ct_ab_popup_data));
+ c_retvm_if(NULL == ab_popup_data, NULL, "calloc() return NULL");
+ ab_popup_data->id = 0;
+ ab_popup_data->name = strdup(S_(CT_SYS_BODY_PHONE));
+
+ item = elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_ADDRBOOK], ab_popup_data,
+ NULL, ELM_GENLIST_ITEM_NONE, setting_export_ab_list_sel, ab_popup_data);
+ ab_popup_data->item = item;
+
+ ret = contacts_svc_get_list(CTS_LIST_ALL_ADDRESSBOOK, &iter);
+ if (CTS_SUCCESS != ret) {
+ ERR("contacts_svc_get_list() Failed(%d)", ret);
+ evas_object_show(genlist);
+ elm_box_pack_end(box, genlist);
+ elm_object_content_set(popup, box);
+ return popup;
+ }
+
+ while (CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue *ab;
+
+ ab_popup_data = calloc(1, sizeof(ct_ab_popup_data));
+ if (NULL == ab_popup_data) {
+ ERR("calloc() return NULL");
+ continue;
+ }
+
+ ab = contacts_svc_iter_get_info(iter);
+ ab_popup_data->id = contacts_svc_value_get_int(ab, CTS_LIST_ADDRESSBOOK_ID_INT);
+ ab_popup_data->name = contacts_svc_value_steal_str(ab, CTS_LIST_ADDRESSBOOK_NAME_STR);
+ ab_popup_data->type = contacts_svc_value_get_int(ab, CTS_LIST_ADDRESSBOOK_ACC_TYPE_INT);
+ ab_popup_data->mode = contacts_svc_value_get_int(ab, CTS_LIST_ADDRESSBOOK_MODE_INT);
+
+ if (CTS_ADDRESSBOOK_TYPE_INTERNAL != ab_popup_data->type)
+ item = elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_ADDRBOOK], ab_popup_data, NULL,
+ ELM_GENLIST_ITEM_NONE, setting_export_ab_list_sel, ab_popup_data);
+ else
+ item = elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_ADDRBOOK_NAME], ab_popup_data, NULL,
+ ELM_GENLIST_ITEM_NONE, setting_export_ab_list_sel, ab_popup_data);
+
+ ab_popup_data->item = item;
+ ret = contacts_svc_value_free(ab);
+ c_warn_if(CTS_SUCCESS != ret, "contacts_svc_value_free() Failed(%d)", ret);
+ }
+ contacts_svc_iter_remove(iter);
+
+ evas_object_show(genlist);
+ elm_box_pack_end(box, genlist);
+ elm_object_content_set(popup, box);
+ return popup;
+}
+
+
+static void setting_export_contacts_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *popup;
+ ct_setting_data *csetting_d = data;
+ Elm_Object_Item *it = event_info;
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+
+ csetting_d->mode = SETTING_EXPORT_CONTACT;
+ popup = setting_create_export_addrbook_popup(csetting_d->navi, csetting_d);
+ c_retm_if(NULL == popup, "setting_addrbook_popup() return NULL");
+ csetting_d->popup = popup;
+
+ elm_object_part_text_set(popup, "title,text", T_(CT_GET_TEXT_BASIC, CTTEXT_SELECT_EXPORT_ADDRBOOK));
+}
+
+static void setting_import_contacts_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *popup;
+ ct_setting_data *csetting_d = data;
+ Elm_Object_Item *it = event_info;
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+
+ csetting_d->mode = SETTING_IMPORT_CONTACT;
+ popup = ctui_addrbook_popup(csetting_d->navi, setting_import_ab_list_sel, csetting_d, CTS_ADDRESSBOOK_MODE_READONLY, setting_ab_popup_hide_cb, csetting_d);
+ c_retm_if(NULL == popup, "setting_addrbook_popup() return NULL");
+ csetting_d->popup = popup;
+
+ elm_object_part_text_set(popup, "title,text", T_(CT_GET_TEXT_BASIC, CTTEXT_IMPORT_CONTACT_TO));
+}
+
+static void setting_order_item_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = event_info;
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+
+ if (EINA_TRUE == elm_genlist_item_expanded_get(item))
+ elm_genlist_item_expanded_set(item, EINA_FALSE);
+ else
+ elm_genlist_item_expanded_set(item, EINA_TRUE);
+}
+
+static void setting_mynum_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *it = event_info;
+ elm_genlist_item_selected_set(it, EINA_FALSE);
+}
+
+static void setting_gl_exp(void *data, Evas_Object *obj, void *event_info)
+{
+ int order;
+ Evas_Object *genlist = obj;
+ Elm_Object_Item *it = event_info;
+ ct_setting_data *csetting_d = data;
+
+ csetting_d->radio_grp = elm_radio_add(genlist);
+
+ elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_FIRSTLAST],
+ (void *)CTS_ORDER_NAME_FIRSTLAST, it, ELM_GENLIST_ITEM_NONE,
+ setting_handle_order, (void *)CTS_ORDER_NAME_FIRSTLAST);
+ elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_LASTFIRST],
+ (void *)CTS_ORDER_NAME_LASTFIRST, it, ELM_GENLIST_ITEM_NONE,
+ setting_handle_order, (void *)CTS_ORDER_NAME_LASTFIRST);
+
+ order = contacts_svc_get_order(CTS_ORDER_OF_DISPLAY);
+ elm_radio_value_set(csetting_d->radio_grp, order);
+}
+
+static void setting_gl_con(void *data, Evas_Object *obj, void *event_info)
+{
+ ct_setting_data *csetting_d = data;
+ Elm_Object_Item *item = event_info;
+ elm_genlist_item_subitems_clear(item);
+
+ c_retm_if(NULL == csetting_d, "parameter(csetting_d) is NUL");
+ if(csetting_d->radio_grp) {
+ evas_object_del(csetting_d->radio_grp);
+ csetting_d->radio_grp = NULL;
+ }
+}
+
+static char *setting_gl_text_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ if (0 == strcmp(part, "elm.text"))
+ return strdup(data);
+ return NULL;
+}
+
+static char *setting_gl_order_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ if (0 == strcmp(part, "elm.text.1"))
+ return strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_ORDER_DISPLAY_NAME));
+ else if (0 == strcmp(part, "elm.text.2")) {
+ if (CTS_ORDER_NAME_FIRSTLAST == contacts_svc_get_order(CTS_ORDER_OF_DISPLAY))
+ return strdup(T_(CT_GET_TEXT_BASE_OP, CTTEXT_FIRSTLAST));
+ else
+ return strdup(T_(CT_GET_TEXT_BASE_OP, CTTEXT_LASTFIRST));
+ }
+ return NULL;
+}
+
+static char *setting_gl_radio_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ int type = (int)data;
+ if (0 == strcmp(part, "elm.text")) {
+ if (CTS_ORDER_NAME_FIRSTLAST == type)
+ return strdup(T_(CT_GET_TEXT_BASE_OP, CTTEXT_FIRSTLAST));
+ else if (CTS_ORDER_NAME_LASTFIRST == type)
+ return strdup(T_(CT_GET_TEXT_BASE_OP, CTTEXT_LASTFIRST));
+ }
+ return NULL;
+}
+
+static char *setting_gl_my_num_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ if (0 == strcmp(part, "elm.text.2"))
+ return strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_OWN_NUMBER));
+ else if (0 == strcmp(part, "elm.text.1")) {
+ char *number = vconf_get_str(VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER);
+ if (number && *number)
+ return strdup(number);
+ else
+ return strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_NA));
+ }
+ return NULL;
+}
+
+static Evas_Object *setting_gl_radio_icon_get(void *data, Evas_Object *obj, const char *part)
+{
+ int type = (int)data;
+ ct_setting_data *csetting_d;
+
+ if (0 == strcmp(part, "elm.icon")) {
+ Evas_Object *radio;
+
+ csetting_d = evas_object_data_get(obj, "csetting_d");
+ c_retvm_if(NULL == csetting_d, NULL, "evas_object_data_get() return NULL");
+
+ radio = elm_radio_add(obj);
+ c_retvm_if(NULL == radio, NULL, "elm_radio_add() return NULL");
+
+ elm_radio_group_add(radio, csetting_d->radio_grp);
+ elm_radio_state_value_set(radio, type);
+
+ return radio;
+ }
+ return NULL;
+}
+
+static void setting_gl_addrbook_del(void *data, Evas_Object *obj)
+{
+ ct_ab_popup_data *info = data;
+ c_retm_if(NULL == info, "data is NULL");
+ free(info->name);
+ free(info);
+}
+
+
+static char* setting_gl_addrbook_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ ct_ab_popup_data *ab_popup_data = data;
+ c_retvm_if(NULL == ab_popup_data, NULL, "parameter(ab_popup_data) is NULL");
+
+ if (0 == strcmp(part, "elm.text") || 0 == strcmp(part, "elm.text.1"))
+ return SAFE_STRDUP(ab_popup_data->name);
+ else if (0 == strcmp(part, "elm.text.2"))
+ return SAFE_STRDUP(T_(CT_GET_TEXT_ACC_TYPE, ab_popup_data->type));
+
+ return NULL;
+}
+
+
+static void setting_addrbook_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ setting_addrbook_select_all_update(data);
+}
+
+static Evas_Object* setting_gl_addrbook_icon_get(void *data, Evas_Object *obj, const char *part)
+{
+ Evas_Object *ret_ico;
+ ct_ab_popup_data *ab_popup_data = data;
+ c_retvm_if(NULL == ab_popup_data, NULL, "parameter(ab_popup_data) is NULL");
+
+ ret_ico = NULL;
+ if (0 == strcmp(part, "elm.icon")) {
+ Evas_Object *check;
+ check = elm_check_add(obj);
+ elm_check_state_pointer_set(check, &ab_popup_data->checked);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ evas_object_smart_callback_add(check, "changed", setting_addrbook_check_changed_cb, obj);
+ ret_ico = check;
+ }
+
+ return ret_ico;
+}
+
+
+static inline void setting_create_itcs()
+{
+ setting_itcs[SETTING_ITC_TEXT].func.text_get = setting_gl_text_label_get;
+
+ setting_itcs[SETTING_ITC_ORDER].func.text_get = setting_gl_order_label_get;
+
+ setting_itcs[SETTING_ITC_RADIO].func.text_get = setting_gl_radio_label_get;
+ setting_itcs[SETTING_ITC_RADIO].func.content_get = setting_gl_radio_icon_get;
+
+ setting_itcs[SETTING_ITC_MY_NUM].func.text_get = setting_gl_my_num_label_get;
+
+ setting_itcs[SETTING_ITC_ADDRBOOK].func.text_get = setting_gl_addrbook_label_get;
+ setting_itcs[SETTING_ITC_ADDRBOOK].func.content_get = setting_gl_addrbook_icon_get;
+ setting_itcs[SETTING_ITC_ADDRBOOK].func.del = setting_gl_addrbook_del;
+
+ setting_itcs[SETTING_ITC_ADDRBOOK_NAME].func.text_get = setting_gl_addrbook_label_get;
+ setting_itcs[SETTING_ITC_ADDRBOOK_NAME].func.content_get = setting_gl_addrbook_icon_get;
+ setting_itcs[SETTING_ITC_ADDRBOOK_NAME].func.del = setting_gl_addrbook_del;
+}
+
+Evas_Object* ct_setting_create_layout(ct_setting_data *csetting_d)
+{
+ Evas_Object *genlist;
+ Elm_Object_Item *item;
+ Evas_Object *base;
+ int sim_state;
+
+ setting_create_itcs();
+ base = ctui_create_base_layout(csetting_d->navi, true);
+
+ genlist = elm_genlist_add(base);
+ elm_object_part_content_set(base, "elm.swallow.content", genlist);
+
+ evas_object_data_set(genlist, "csetting_d", csetting_d);
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SIM_PB_INIT, &sim_state);
+ if (sim_state)
+ elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_IMPORT_SIM],
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_IMPORT_SIM_CONTACTS), NULL, ELM_GENLIST_ITEM_NONE, setting_import_sim_cb, csetting_d);
+ else {
+ item = elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_IMPORT_NO_SIM],
+ T_(CT_GET_TEXT_BASIC, CTTEXT_NO_SIM), NULL, ELM_GENLIST_ITEM_NONE, setting_import_sim_cb, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+
+ elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_IMPORT],
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_IMPORT_CONTACTS), NULL, ELM_GENLIST_ITEM_NONE,
+ setting_import_contacts_cb, csetting_d);
+
+ elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_EXPORT],
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_EXPORT_CONTACTS), NULL, ELM_GENLIST_ITEM_NONE,
+ setting_export_contacts_cb, csetting_d );
+
+ item = elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_ORDER],
+ NULL, NULL, ELM_GENLIST_ITEM_TREE, setting_order_item_sel, NULL);
+ evas_object_data_set(genlist, "order", item);
+
+ item = elm_genlist_item_append(genlist, &setting_itcs[SETTING_ITC_MY_NUM],
+ NULL, NULL, ELM_GENLIST_ITEM_NONE, setting_mynum_cb, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ evas_object_smart_callback_add(genlist, "expanded", setting_gl_exp, csetting_d);
+ evas_object_smart_callback_add(genlist, "contracted", setting_gl_con, csetting_d);
+
+ return base;
+}
+
+
diff --git a/lib/settings/ct-setting-view.h b/lib/settings/ct-setting-view.h
new file mode 100755
index 0000000..671a010
--- /dev/null
+++ b/lib/settings/ct-setting-view.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * This file is part of ug-contacts-efl
+ *
+ * Written by Youngjae Shin <yj99.shin@samsung.com>
+ * Donghee Ye <donghee.ye@samsung.com>
+ * Sunggoo Kim <sung.goo.kim@samsung.com>
+ *
+ * PROPRIETARY/CONFIDENTIAL
+ *
+ * This software is the confidential and proprietary information of
+ * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered
+ * into with SAMSUNG ELECTRONICS.
+ * SAMSUNG make no representations or warranties about the suitability
+ * of the software, either express or implied, including but not limited
+ * to the implied warranties of merchantability, fitness for a particular
+ * purpose, or non-infringement. SAMSUNG shall not be liable for any
+ * damages suffered by licensee as a result of using, modifying or
+ * distributing this software or its derivatives.
+ *
+ */
+
+#ifndef __CONTACTS_SETTING_VIEW_H__
+#define __CONTACTS_SETTING_VIEW_H__
+
+Evas_Object* ct_setting_create_layout(ct_setting_data *csetting_d );
+
+#endif //__CONTACTS_DETAIL_VIEW_H__