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