diff options
author | Kim Kibum <kb0929.kim@samsung.com> | 2012-04-09 12:12:16 +0900 |
---|---|---|
committer | Kim Kibum <kb0929.kim@samsung.com> | 2012-04-09 12:12:16 +0900 |
commit | 9702ab0622390dc37e7802f25e62524ac397acb4 (patch) | |
tree | a6e93c23ab04ee8b76138f7cb3ae45b7fe66aede /lib/common/ct-list-detail.c | |
parent | 66dd755e143f411119e62efba5e0f095861fe570 (diff) | |
download | contacts-9702ab0622390dc37e7802f25e62524ac397acb4.tar.gz contacts-9702ab0622390dc37e7802f25e62524ac397acb4.tar.bz2 contacts-9702ab0622390dc37e7802f25e62524ac397acb4.zip |
Tizen release 1.0
Diffstat (limited to 'lib/common/ct-list-detail.c')
-rwxr-xr-x | lib/common/ct-list-detail.c | 362 |
1 files changed, 362 insertions, 0 deletions
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); +} |