2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <ui-gadget-module.h>
20 #include "phone-common.h"
22 #include "ct-setting-view.h"
24 static int create_setting_view(Evas_Object *parent, ct_setting_data *csetting_d)
28 Elm_Object_Item *navi_item;
30 p_retvm_if(NULL == parent, FALSE, "parameter(parent) is NULL");
32 csetting_d->navi = elm_naviframe_add(parent);
33 evas_object_show(csetting_d->navi);
34 p_retvm_if(NULL == csetting_d->navi, FALSE, "navi is NULL");
36 content = ct_setting_create_layout(csetting_d);
37 navi_item = elm_naviframe_item_push(csetting_d->navi, S_(PH_SYS_BODY_CONTACTS), NULL, NULL, content, NULL);
38 csetting_d->navi_item_main = navi_item;
40 l_btn = elm_button_add(csetting_d->navi);
41 p_retvm_if(NULL == l_btn, -1, "elm_button_add() return NULL");
43 elm_object_item_part_content_set(navi_item, "prev_btn", l_btn);
44 elm_object_style_set(l_btn, "naviframe/back_btn/default");
45 evas_object_smart_callback_add(l_btn, "clicked", phone_ug_destroy_me_cb, csetting_d->ug);
50 static void* settings_on_create(ui_gadget_h ug, enum ug_mode mode,
51 service_h service, void *priv)
56 contacts_error_e err = CONTACTS_ERROR_NONE;
57 ct_setting_data *csetting_d = priv;
59 p_retvm_if(NULL == ug || NULL == priv, NULL,
60 "The parameter is invalid(ug=%p, priv=%p)", ug, priv);
62 parent = ug_get_parent_layout(ug);
63 p_retvm_if(NULL == parent, NULL, "ug_get_parent_layout() return NULL");
66 bindtextdomain(PACKAGE, "/usr/ug/res/locale");
68 err = contacts_connect2();
69 p_retvm_if(CONTACTS_ERROR_NONE != err, NULL, "contacts_connect2() Failed(%d)", err);
71 if (UG_MODE_FULLVIEW == mode)
72 base = phone_create_base_layout(parent, true);
74 err = contacts_disconnect2();
75 p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err);
79 bg = phone_create_bg(base);
81 ERR("phone_create_bg() return NULL");
82 evas_object_del(base);
83 err = contacts_disconnect2();
84 p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err);
88 if (create_setting_view(base, csetting_d ))
89 elm_object_part_content_set(base, "elm.swallow.content", csetting_d->navi);
91 evas_object_del(base);
93 err = contacts_disconnect2();
94 p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err);
100 static void settings_on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv)
106 case UG_KEY_EVENT_END:
114 static void settings_on_destroy(ui_gadget_h ug, service_h service, void *priv)
116 contacts_error_e err = CONTACTS_ERROR_NONE;
117 p_retm_if(NULL == ug, "The ug is NULL(ug = %p)", ug);
118 evas_object_del(ug_get_layout(ug));
120 err = contacts_disconnect2();
121 p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err);
124 API int UG_MODULE_INIT(struct ug_module_ops *ops)
126 ct_setting_data *csetting_d;
128 p_retvm_if(!ops, -1, "ops is NULL");
130 csetting_d = calloc(1, sizeof(ct_setting_data));
131 p_retvm_if(NULL == csetting_d , -1, "calloc() return NULL");
133 ops->create = settings_on_create;
137 ops->destroy = settings_on_destroy;
140 ops->key_event = settings_on_key_event;
141 ops->priv = csetting_d ;
146 API void UG_MODULE_EXIT(struct ug_module_ops *ops)
154 API int setting_plugin_reset(service_h service, void *priv)