diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 01:37:52 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 01:37:52 +0900 |
commit | 568c09651ccbdc576bc7662af3d9328728370262 (patch) | |
tree | 6edbe93ecee55afe6b0cb401f600d11f2212180c /lib/ph-front/ph-front-main.c | |
parent | b9b4104f70d3f35414260d964f4c7c0221d21446 (diff) | |
download | phone-contacts-568c09651ccbdc576bc7662af3d9328728370262.tar.gz phone-contacts-568c09651ccbdc576bc7662af3d9328728370262.tar.bz2 phone-contacts-568c09651ccbdc576bc7662af3d9328728370262.zip |
Tizen 2.1 base
Diffstat (limited to 'lib/ph-front/ph-front-main.c')
-rwxr-xr-x | lib/ph-front/ph-front-main.c | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/lib/ph-front/ph-front-main.c b/lib/ph-front/ph-front-main.c new file mode 100755 index 0000000..62242d0 --- /dev/null +++ b/lib/ph-front/ph-front-main.c @@ -0,0 +1,193 @@ +/* +* 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-common.h" +#include "phone-ug.h" +#include "ph-front.h" +#include "ph-front-view.h" +#include <bundle.h> + +// for removing build warning //////////////////////////////////// +int service_export_as_bundle(service_h service, bundle **data); +//////////////////////////////////////////////////////// + +void *phoneui_on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) +{ + PH_FN_CALL; + contacts_error_e err = CONTACTS_ERROR_NONE; + Evas_Object *bg; + Evas_Object *parent; + Evas_Object *layout; + ph_phoneui_data *phoneui_d; + const char* val = NULL; + bundle *bd; + + if (!ug || !priv) + return NULL; + + bindtextdomain(PACKAGE, LOCALEDIR); + + service_export_as_bundle(service, &bd); + + phoneui_d = priv; + if (bd) { + val = bundle_get_val(bd, PH_UG_BUNDLE_TYPE); + if (val) phoneui_d->ug_request = atoi(val); + PH_DBG("type = %d", phoneui_d->ug_request); + bundle_free(bd); + } + p_retvm_if(PH_UG_REQUEST_LAUNCH_VOICECALL != phoneui_d->ug_request, NULL, "Invalid ug request (%d)", phoneui_d->ug_request); + + phoneui_d->view_visible[PH_VIEW_DIALER] = true; + phoneui_d->view_visible[PH_VIEW_LOG] = true; + phoneui_d->view_visible[PH_VIEW_CONTACT] = false; + phoneui_d->view_visible[PH_VIEW_FAVORITE] = false; + + err = contacts_connect2(); + p_retvm_if(CONTACTS_ERROR_NONE != err, NULL, "contacts_connect2() Failed(%d)", err); + + parent = ug_get_parent_layout(ug); + if (!parent) + return NULL; + + phoneui_d = priv; + phoneui_d->win = ug_get_window(); + elm_win_conformant_set(phoneui_d->win, EINA_TRUE); + phoneui_d->select_tab = PH_VIEW_NONE; + phoneui_d->ug = ug; + + layout = ph_front_create_toolbar(phoneui_d); + + bg = phone_create_bg(layout); + if (NULL == bg) { + PH_DBG("phone_create_bg() return NULL"); + err = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err); + return NULL; + } + + return layout; +} + +void phoneui_on_start(ui_gadget_h ug, service_h service, void *priv) +{ + PH_FN_CALL; + ph_phoneui_data *phoneui_d = priv; + + elm_toolbar_select_mode_set(phoneui_d->tabbar, ELM_OBJECT_SELECT_MODE_ALWAYS); + + phoneui_d->timer = ecore_timer_add(3.0, phone_front_view_load_timer, phoneui_d); + PH_FN_END; +} + +void phoneui_on_pause(ui_gadget_h ug, service_h service, void *priv) +{ +} + +void phoneui_on_resume(ui_gadget_h ug, service_h service, void *priv) +{ +} + +void phoneui_on_destroy(ui_gadget_h ug, service_h service, void *priv) +{ + PH_FN_CALL; + contacts_error_e err = CONTACTS_ERROR_NONE; + p_retm_if(NULL == priv, "The parameter is invalid(priv=%p)", priv); + p_retm_if(NULL == ug, "The parameter is invalid(ug=%p)", ug); + ph_phoneui_data *phoneui_d = priv; + if (!ug) + return; + + free(phoneui_d->ug_data); + + if (phoneui_d && phoneui_d->ug == NULL) { + PH_DBG("view destroy already called, so clist_d free here"); + free(phoneui_d); + } + else { + phoneui_d->ug = NULL; + evas_object_del(ug_get_layout(ug)); + } + err = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err); + PH_FN_END; +} + +void phoneui_on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv) +{ +} + +void phoneui_on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv) +{ + ph_phoneui_data *phoneui_d = priv; + switch (event) { + case UG_EVENT_REGION_CHANGE: + phone_front_view_region_changed(phoneui_d); + 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_front_view_language_changed(phoneui_d); + break; + default: + break; + } +} + +void phoneui_on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h data, void *priv) +{ +} + +API int UG_MODULE_INIT(struct ug_module_ops *ops) +{ + ph_phoneui_data *phoneui_d; + + if (!ops) + return -1; + + phoneui_d = calloc(1, sizeof(ph_phoneui_data)); + if (!phoneui_d) + return -1; + + ops->create = phoneui_on_create; + ops->start = phoneui_on_start; + ops->pause = phoneui_on_pause; + ops->resume = phoneui_on_resume; + ops->destroy = phoneui_on_destroy; + ops->message = phoneui_on_message; + ops->event = phoneui_on_event; + ops->key_event = phoneui_on_key_event; + ops->priv = phoneui_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; +} + |