summaryrefslogtreecommitdiff
path: root/lib/details/ct-detail-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/details/ct-detail-view.c')
-rwxr-xr-xlib/details/ct-detail-view.c1003
1 files changed, 1003 insertions, 0 deletions
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;
+}
+