diff options
Diffstat (limited to 'lib/log/ph-log-main.c')
-rwxr-xr-x | lib/log/ph-log-main.c | 300 |
1 files changed, 300 insertions, 0 deletions
diff --git a/lib/log/ph-log-main.c b/lib/log/ph-log-main.c new file mode 100755 index 0000000..c600354 --- /dev/null +++ b/lib/log/ph-log-main.c @@ -0,0 +1,300 @@ +/* +* Copyright 2012 Samsung Electronics Co., Ltd +* +* Licensed under the Flora License, Version 1.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://floralicense.org/license/ +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +#include <ui-gadget-module.h> + +#include "phone.h" +#include "phone-log.h" +#include "ph-log-utils.h" +#include "ph-log-main-view.h" +#include "ph-log-check-view.h" +#include "ph-log-detail-view.h" +#include <bundle.h> + +// for removing build warning //////////////////////////////////// +int service_export_as_bundle(service_h service, bundle **data); +//////////////////////////////////////////////////////// + +static bool log_create_ug_view(int request, ph_log_data *log_d, Evas_Object *base) +{ + PH_FN_CALL; + int ret; + p_retvm_if(NULL == log_d, false, "Parameter is null"); + + if (NULL == log_d->navi) { + log_d->navi = elm_naviframe_add(base); + p_retvm_if(NULL == log_d->navi, false, "elm_naviframe_add is failed"); + elm_object_part_content_set(base, "elm.swallow.content", log_d->navi); + evas_object_show(log_d->navi); + } + + if (PH_UG_REQUEST_LOG_SELECT == request) + log_d->view_type = LOG_VIEW_TYPE_UG_NUMBER_SELECT; + else if (PH_UG_REQUEST_LOG_CHECK == request) + log_d->view_type = LOG_VIEW_TYPE_UG_NUMBER_CHECK; + else + log_d->view_type = LOG_VIEW_TYPE_UG_LAUNCH_CALL; + + ret = ph_log_create_content(log_d); + if (ret < 0) { + ERR("Fail to ph_log_create_content"); + return false; + } + log_d->navi_item = elm_naviframe_item_push(log_d->navi, T_(PH_GET_TEXT_BASE_OP, PHTEXT_SELECT_LOGS), + NULL, NULL, log_d->box, NULL); + + if (LOG_VIEW_TYPE_UG_NUMBER_CHECK == log_d->view_type) + phone_log_check_mode_start(log_d); + else + phone_log_set_navi(log_d->navi); + + return true; +} + +static void *log_on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) +{ + PH_FN_CALL; + int ret; + Evas_Object *bg; + Evas_Object *parent; + Evas_Object *base; + ph_log_data *log_d; + int request = PH_UG_REQUEST_LOG_CHECK; + char* val = NULL; + + if (!ug || !priv) + return NULL; + + bindtextdomain(PACKAGE, LOCALEDIR); + + parent = ug_get_parent_layout(ug); + if (!parent) + return NULL; + + ret = contacts_connect2(); + p_retvm_if(CONTACTS_ERROR_NONE != ret, NULL, "contacts_connect2() Failed(%d)", ret); + + if (SERVICE_ERROR_NONE == service_get_extra_data (service, "type", &val)) { + if (val) + request = atoi(val); + PH_DBG("log request : %d", request); + free(val); + } + + if (mode==UG_MODE_FULLVIEW) + base = phone_create_base_layout(parent, true); + else + base = phone_create_base_layout(parent, false); + + log_d = priv; + log_d->win = ug_get_window(); + log_d->ug = ug; + + bg = phone_create_bg(base); + if (NULL == bg) { + PH_DBG("phone_create_bg() return NULL"); + evas_object_del(base); + ret = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != ret, "contacts_disconnect2() Failed(%d)", ret); + return NULL; + } + + phone_detail_log_init_time_format(); + phone_detail_log_generate_date_format(log_d->formatter); + + if (!log_create_ug_view(request, log_d, base)) { + phone_detail_log_delete_date_format(log_d->formatter); + evas_object_del(base); + ret = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != ret, "contacts_disconnect2() Failed(%d)", ret); + return NULL; + } + + return base; +} + +static void log_on_start(ui_gadget_h ug, service_h service, void *priv) +{ +} + +static void log_on_pause(ui_gadget_h ug, service_h service, void *priv) +{ + PH_FN_CALL; + ph_log_data *log_d = priv; + log_d->is_background = true; + +} + +static void log_on_resume(ui_gadget_h ug, service_h service, void *priv) +{ + PH_FN_CALL; + ph_log_data *log_d = priv; + + log_d->is_background = false; + if (log_d->update_timer) { + ecore_timer_del(log_d->update_timer); + log_d->update_timer = NULL; + ph_log_data_changed_cb(log_d); + } +} + +static void log_on_destroy(ui_gadget_h ug, service_h service, void *priv) +{ + PH_FN_CALL; + + if (!ug) + return; + + evas_object_del(ug_get_layout(ug)); + contacts_disconnect2(); + PH_FN_END; +} + +static void log_on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv) +{ +} + +static void log_on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv) +{ + ph_log_data *log_d = priv; + + switch (event) { + case UG_EVENT_REGION_CHANGE: + if (log_d->navi) + phone_log_views_update(log_d->navi); + break; + case UG_EVENT_ROTATE_PORTRAIT: + case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN: + case UG_EVENT_ROTATE_LANDSCAPE: + case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN: + break; + case UG_EVENT_LANG_CHANGE: + phone_log_view_language_changed(log_d->navi); + break; + default: + break; + } +} + +static void log_on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv) +{ + PH_FN_CALL; + if (!ug) + return; + + switch (event) { + case UG_KEY_EVENT_END: + ug_destroy_me(ug); + break; + default: + break; + } +} + +API int UG_MODULE_INIT(struct ug_module_ops *ops) +{ + ph_log_data *log_d; + + if (!ops) + return -1; + + log_d = calloc(1, sizeof(ph_log_data)); + p_retvm_if(NULL == log_d, -1, "calloc is failed"); + + ops->create = log_on_create; + ops->start = log_on_start; + ops->pause = log_on_pause; + ops->resume = log_on_resume; + ops->destroy = log_on_destroy; + ops->message = log_on_message; + ops->event = log_on_event; + ops->key_event = log_on_key_event; + ops->priv = log_d; + ops->opt = UG_OPT_INDICATOR_ENABLE; + + return 0; +} + +API void UG_MODULE_EXIT(struct ug_module_ops *ops) +{ + PH_FN_CALL; + + if (!ops) + return; + + ops->priv = NULL; + PH_FN_END; +} + +API Evas_Object* phone_create_log_view(ph_view_info *view_info) +{ + PH_FN_CALL; + int ret; + ph_log_data * log_d = calloc(1, sizeof(ph_log_data)); + p_retvm_if(NULL == log_d, NULL, "Fail to calloc ph_log_data"); + memset(log_d, 0x00, sizeof(ph_log_data)); + + log_d->ug = view_info->ug; + log_d->win = view_info->win; + log_d->navi = view_info->navi; + log_d->navi_item = elm_naviframe_bottom_item_get(log_d->navi); + log_d->is_background = true; + + if(!log_d->ug) + { + log_d->view_type = LOG_VIEW_TYPE_NORMAL; + log_d->viewby_type = VIEWBY_ALL_LOG; + } + else + { + switch(view_info->ug_request) + { + case PH_UG_REQUEST_SELECT: + case PH_UG_REQUEST_SELECT_NUMBER: + log_d->view_type = LOG_VIEW_TYPE_UG_NUMBER_SELECT; + break; + case PH_UG_REQUEST_SELECT_EMAIL: + log_d->view_type = LOG_VIEW_TYPE_UG_EMAIL_SELECT; + break; + case PH_UG_REQUEST_CHECK: + case PH_UG_REQUEST_CHECK_FOR_NUMBER: + log_d->view_type = LOG_VIEW_TYPE_UG_NUMBER_CHECK; + break; + case PH_UG_REQUEST_CHECK_FOR_EMAIL: + log_d->view_type = LOG_VIEW_TYPE_UG_EMAIL_CHECK; + break; + case PH_UG_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL: + log_d->view_type = LOG_VIEW_TYPE_UG_NUMBER_OR_EMAIL_CHECK; + break; + default: + log_d->view_type = LOG_VIEW_TYPE_UG_LAUNCH_CALL; + break; + } + } + + phone_detail_log_init_time_format(); + phone_detail_log_generate_date_format(log_d->formatter); + + ret = ph_log_create_content(log_d); + if (ret < 0) { + free(log_d); + return NULL; + } + + return log_d->layout; +} + |