summaryrefslogtreecommitdiff
path: root/lib/settings/ct-setting-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/settings/ct-setting-main.c')
-rwxr-xr-xlib/settings/ct-setting-main.c157
1 files changed, 157 insertions, 0 deletions
diff --git a/lib/settings/ct-setting-main.c b/lib/settings/ct-setting-main.c
new file mode 100755
index 0000000..00ddce9
--- /dev/null
+++ b/lib/settings/ct-setting-main.c
@@ -0,0 +1,157 @@
+/*
+* 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 "ct-setting-view.h"
+
+static int create_setting_view(Evas_Object *parent, ct_setting_data *csetting_d)
+{
+ Evas_Object *l_btn;
+ 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);
+ evas_object_show(csetting_d->navi);
+ p_retvm_if(NULL == csetting_d->navi, FALSE, "navi is NULL");
+
+ 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);
+ csetting_d->navi_item_main = navi_item;
+
+ l_btn = elm_button_add(csetting_d->navi);
+ p_retvm_if(NULL == l_btn, -1, "elm_button_add() return NULL");
+
+ elm_object_item_part_content_set(navi_item, "prev_btn", l_btn);
+ elm_object_style_set(l_btn, "naviframe/back_btn/default");
+ evas_object_smart_callback_add(l_btn, "clicked", phone_ug_destroy_me_cb, csetting_d->ug);
+
+ return TRUE;
+}
+
+static void* settings_on_create(ui_gadget_h ug, enum ug_mode mode,
+ service_h service, void *priv)
+{
+ Evas_Object *bg;
+ Evas_Object *parent;
+ Evas_Object *base;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ ct_setting_data *csetting_d = priv;
+
+ p_retvm_if(NULL == ug || NULL == priv, NULL,
+ "The parameter is invalid(ug=%p, priv=%p)", ug, priv);
+
+ parent = 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_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv)
+{
+ if (!ug)
+ return;
+
+ switch (event) {
+ case UG_KEY_EVENT_END:
+ ug_destroy_me(ug);
+ break;
+ default:
+ break;
+ }
+}
+
+static void settings_on_destroy(ui_gadget_h ug, service_h service, void *priv)
+{
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ p_retm_if(NULL == ug, "The ug is NULL(ug = %p)", ug);
+ evas_object_del(ug_get_layout(ug));
+
+ err = contacts_disconnect2();
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)", err);
+}
+
+API int UG_MODULE_INIT(struct ug_module_ops *ops)
+{
+ ct_setting_data *csetting_d;
+
+ p_retvm_if(!ops, -1, "ops is NULL");
+
+ csetting_d = 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 = settings_on_key_event;
+ ops->priv = csetting_d ;
+
+ return 0;
+}
+
+API void UG_MODULE_EXIT(struct ug_module_ops *ops)
+{
+ if (!ops)
+ return;
+
+ ops->priv = NULL;
+}
+
+API int setting_plugin_reset(service_h service, void *priv)
+{
+ return 0;
+}