/* * 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://www.tizenopensource.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 #include #include #include #include #include "phone.h" #include "ct-front.h" #if !defined(C_PACKAGE) # define C_PACKAGE "contacts" #endif struct contact_data { Evas_Object *win; ct_front_data *cfront_d; /* add more variables here */ }; static void ctapp_win_del(void *data, Evas_Object *obj, void *event) { elm_exit(); } static Evas_Object* ctapp_create_win(const char *name) { Evas_Object *eo; int w, h; elm_config_preferred_engine_set("opengl_x11");//temporary code due to S1-6700 eo = elm_win_add(NULL, name, ELM_WIN_BASIC); if (eo) { elm_win_title_set(eo, name); elm_win_borderless_set(eo, EINA_TRUE); evas_object_smart_callback_add(eo, "delete,request", ctapp_win_del, NULL); ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); evas_object_resize(eo, w, h); elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW); } return eo; } static void ctapp_region_changed(void *data) { PH_FN_CALL; struct contact_data *ad = data; ct_front_data *cfront_d = ad->cfront_d; ctui_front_view_region_changed(cfront_d); ug_send_event(UG_EVENT_REGION_CHANGE); return; } static void device_orientation(app_device_orientation_e orientation, void *data) { PH_FN_CALL; struct contact_data *ad = data; ct_front_data *cfront_d = ad->cfront_d; p_retm_if(cfront_d == NULL || cfront_d->win == NULL, "Paramter is NULL"); cfront_d->rotate = orientation; ctui_front_view_rotate(cfront_d, orientation); return; } static int ctapp_open(void *data) { PH_FN_CALL; struct contact_data *ad = data; ct_front_data *cfront_d = ad->cfront_d; if (EINA_FALSE == evas_object_visible_get(cfront_d->win)){ evas_object_show(cfront_d->win); if(CT_VIEW_NONE == cfront_d->select_tab) ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT, -1, NULL); } return 0; } static bool ctapp_create(void *data) { PH_FN_CALL; int ret; struct contact_data *ad = data; Evas_Object *win; /* create window */ win = ctapp_create_win(C_PACKAGE); p_retvm_if(NULL == win, false, "phapp_create_win() Failed"); ad->win = win; bindtextdomain(PACKAGE, LOCALEDIR); ret = contacts_svc_connect(); if (CTS_SUCCESS != ret) { Evas_Object *popup; ERR("contacts_svc_connect() Failed(%d)", ret); evas_object_show(win); popup = elm_popup_add(win); evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(popup); elm_object_text_set(popup, T_(PH_GET_TEXT_BASIC, PHTEXT_INITIALIZING)); elm_popup_timeout_set(popup, 1.5); evas_object_smart_callback_add(popup, "timeout", ctapp_win_del, NULL); return true; } UG_INIT_EFL(ad->win, UG_OPT_INDICATOR_ENABLE); ad->cfront_d = ctui_front_view_create(ad->win); ad->cfront_d->rotate = app_get_device_orientation(); elm_win_rotation_with_resize_set(ad->cfront_d->win, ad->cfront_d->rotate); appcore_set_open_cb(ctapp_open, data); return true; } static void ctapp_terminate(void *data) { PH_FN_CALL; struct contact_data *ad = data; if (NULL != ad->win) evas_object_del(ad->win); ug_destroy_all(); contacts_svc_disconnect(); return; } static void ctapp_pause(void *data) { PH_FN_CALL; struct contact_data *ad = data; ctui_front_view_pause(ad->cfront_d); ug_pause(); return; } static void ctapp_resume(void *data) { PH_FN_CALL; struct contact_data *ad = data; ct_front_data *cfront_d = ad->cfront_d; if (CT_VIEW_NONE == cfront_d->select_tab) ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT, -1, NULL); else ctui_front_view_resume(ad->cfront_d); ug_resume(); return; } static void ctapp_service(service_h service, void *data) { PH_FN_CALL; struct contact_data *ad = data; ct_front_data *cfront_d; int ret; char* val = NULL; p_retm_if(NULL == ad || NULL == ad->cfront_d, "data is null"); cfront_d = ad->cfront_d; ret = service_get_extra_data(service, "launch_type", &val); p_warn_if(SERVICE_ERROR_NONE != ret, "service_get_extra_data is failed(%d)", ret); if (val && *val) { if (0 == strcmp(val, "favorite")) ctui_front_view_reset(cfront_d, CT_VIEW_FAVORITE, -1, NULL); else if (0 == strcmp(val, "new")) ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT, CT_FRONT_CONTACT_NEW, NULL); free(val); return; } ret = service_get_extra_data(service, "search_name", &val); p_warn_if(SERVICE_ERROR_NONE != ret, "service_get_extra_data is failed(%d)", ret); if (val && *val) { ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT, CT_FRONT_CONTACT_SEARCH, service); free(val); return; } ret = service_get_extra_data(service, "tab", &val); p_warn_if(SERVICE_ERROR_NONE != ret, "service_get_extra_data is failed(%d)", ret); if (val && *val) { if (!strcmp(val, "contacts")) { ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT, -1, NULL); free(val); return; } } elm_win_lower(cfront_d->win); return; } API int main(int argc, char *argv[]) { struct contact_data ad = {0}; app_event_callback_s event_callback = {0,}; event_callback.create = ctapp_create; event_callback.terminate = ctapp_terminate; event_callback.pause = ctapp_pause; event_callback.resume = ctapp_resume; event_callback.service = ctapp_service; event_callback.low_memory = NULL; event_callback.low_battery = NULL; event_callback.device_orientation = device_orientation; event_callback.language_changed = NULL; event_callback.region_format_changed = ctapp_region_changed; return app_efl_main(&argc, &argv, &event_callback, &ad); }