diff options
Diffstat (limited to 'lib/settings/ct-setting-main.cpp')
-rwxr-xr-x | lib/settings/ct-setting-main.cpp | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/lib/settings/ct-setting-main.cpp b/lib/settings/ct-setting-main.cpp new file mode 100755 index 0000000..1e013f3 --- /dev/null +++ b/lib/settings/ct-setting-main.cpp @@ -0,0 +1,155 @@ +/* + * Copyright 2012 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (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 <efl_assist.h> +#include "phone.h" +#include "phone-common.h" + +#include "ct-setting-view.h" +#include "ViewManager.h" + +static int create_setting_view(Evas_Object *parent, ct_setting_data *csetting_d) +{ + PH_TRACE; + Evas_Object *content; + Elm_Object_Item *navi_item; + + p_retvm_if(NULL == parent, FALSE, "parameter(parent) is NULL"); + + csetting_d->navi = elm_naviframe_add(parent); + p_retvm_if(NULL == csetting_d->navi, FALSE, "navi is NULL"); + ea_object_event_callback_add(csetting_d->navi, EA_CALLBACK_BACK, &Common::ViewManager::onBack, csetting_d->win); + ea_object_event_callback_add(csetting_d->navi, EA_CALLBACK_MORE, &Common::ViewManager::onMenu, NULL); + evas_object_show(csetting_d->navi); + + content = ct_setting_create_layout(csetting_d); + navi_item = elm_naviframe_item_push(csetting_d->navi, + S_(PH_SYS_BODY_CONTACTS), NULL, NULL, content, NULL); + elm_object_item_data_set(navi_item, csetting_d); + csetting_d->navi_item = navi_item; + + return TRUE; +} + +static void* settings_on_create(ui_gadget_h ug, enum ug_mode mode, + service_h service, void *priv) +{ + PH_TRACE; + Evas_Object *bg; + Evas_Object *parent; + Evas_Object *base; + int err = CONTACTS_ERROR_NONE; + ct_setting_data *csetting_d = (ct_setting_data *) priv; + + p_retvm_if(NULL == ug || NULL == priv, NULL, + "The parameter is invalid(ug=%p, priv=%p)", ug, priv); + + parent = (Evas_Object *) ug_get_parent_layout(ug); + p_retvm_if(NULL == parent, NULL, "ug_get_parent_layout() return NULL"); + csetting_d->ug = ug; + + bindtextdomain(PACKAGE, "/usr/ug/res/locale"); + + err = contacts_connect2(); + p_retvm_if(CONTACTS_ERROR_NONE != err, NULL, + "contacts_connect2() Failed(%d)", err); + + if (UG_MODE_FULLVIEW == mode) + base = phone_create_base_layout(parent, true); + else + { + err = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != err, + "contacts_disconnect2() Failed(%d)", err); + return NULL; + } + + bg = phone_create_bg(base); + if (NULL == bg) + { + ERR("phone_create_bg() return NULL"); + evas_object_del(base); + err = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != err, + "contacts_disconnect2() Failed(%d)", err); + return NULL; + } + + if (create_setting_view(base, csetting_d)) + elm_object_part_content_set(base, "elm.swallow.content", + csetting_d->navi); + else + { + evas_object_del(base); + base = NULL; + err = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != err, + "contacts_disconnect2() Failed(%d)", err); + } + + return base; +} + +static void settings_on_destroy(ui_gadget_h ug, service_h service, void *priv) +{ + PH_TRACE; + int err = CONTACTS_ERROR_NONE; + p_retm_if(NULL == ug, "The ug is NULL(ug = %p)", ug); + evas_object_del((Evas_Object *) ug_get_layout(ug)); + + err = contacts_disconnect2(); + p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", + err); +} + +extern "C" API int UG_MODULE_INIT(struct ug_module_ops *ops) +{ + PH_TRACE; + ct_setting_data *csetting_d; + + p_retvm_if(!ops, -1, "ops is NULL"); + + csetting_d = (ct_setting_data *) calloc(1, sizeof(ct_setting_data)); + p_retvm_if(NULL == csetting_d, -1, "calloc() return NULL"); + + ops->create = settings_on_create; + ops->start = NULL; + ops->pause = NULL; + ops->resume = NULL; + ops->destroy = settings_on_destroy; + ops->message = NULL; + ops->event = NULL; + ops->key_event = NULL; + ops->priv = csetting_d; + + return 0; +} + +extern "C" API void UG_MODULE_EXIT(struct ug_module_ops *ops) +{ + PH_TRACE; + if (!ops) + return; + + ops->priv = NULL; +} + +API int setting_plugin_reset(service_h service, void *priv) +{ + PH_TRACE; + return 0; +} |