added setting-plugin-efl UG
[apps/home/settings.git] / setting-plugin / src / setting-plugin-main.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 #include <setting-plugin-main.h>
22 #include <Ecore_X.h>
23
24 static int setting_plugin_main_create(void *cb);
25 static int setting_plugin_main_destroy(void *cb);
26 static int setting_plugin_main_update(void *cb);
27 static int setting_plugin_main_cleanup(void *cb);
28
29 setting_view setting_view_plugin_main = {
30         .create = setting_plugin_main_create,
31         .destroy = setting_plugin_main_destroy,
32         .update = setting_plugin_main_update,
33         .cleanup = setting_plugin_main_cleanup,
34 };
35
36
37 static void setting_plugin_main_click_softkey_back_cb(void *data, Evas_Object *obj, void *event_info);
38
39
40 /* ***************************************************
41  *
42  *basic func
43  *
44  ***************************************************/
45 static int setting_plugin_main_create(void *cb)
46 {
47         SETTING_TRACE_BEGIN;
48         /* error check */
49         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
50
51         SettingPluginUG *ad = (SettingPluginUG *) cb;
52
53         Evas_Object *scroller = NULL;
54
55         /* add basic layout */
56         char setBtnStr[MAX_DISPLAY_NAME_LEN_ON_UI];
57         snprintf(setBtnStr, sizeof(setBtnStr), "%s",
58                  (char *)dgettext("sys_string", "IDS_COM_BODY_BACK"));
59
60         /////////////////////////////////////////////////////////////////////////////////////////////////
61 #if 1
62         //char* plugin_path = "/opt/apps/UBKFwQidax.AppSetting4/setting/setting.xml";
63         if (ad->pkgname == NULL)
64                 goto errorhandle;
65
66         char plugin_path[1024];
67         snprintf(plugin_path, 1024, "/opt/apps/%s/setting/setting.xml", ad->pkgname);
68         SETTING_TRACE(" >> SELECTED plugin name : %s \n", plugin_path);
69
70         PluginNode* plugin_node = setting_plugin_create(ad->navi_bar, ad->win_get);
71         plugin_node->win_main_layout = ad->win_main_layout;
72
73         plugin_node->ug = ad->ug;
74
75         setting_drawer_list_init();
76         setting_dbus_handler_init( plugin_node );
77
78         plugin_node->plugin_path = strdup(plugin_path);
79         int ret = setting_plugin_load(plugin_node, (const char *)plugin_node->plugin_path);
80         if (ret < 0)
81                 goto errorhandle;
82
83         ad->ly_main = plugin_node->ly_main;
84
85         ad->plugin_node = plugin_node; // the selected plugin name
86 #endif
87
88         setting_view_plugin_main.is_create = 1;
89         return SETTING_RETURN_SUCCESS;
90 errorhandle:
91                 // resource free
92                 return SETTING_RETURN_FAIL;
93 }
94
95 static int setting_plugin_main_destroy(void *cb)
96 {
97         SETTING_TRACE_BEGIN;
98         /* error check */
99         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
100         SettingPluginUG *ad = (SettingPluginUG *) cb;
101
102
103         setting_dbus_handler_fini();
104         setting_drawer_list_fini();
105
106 //      setting_plugin_destroy(ad->plugin_node );
107
108         //if (ad->ly_main != NULL) {
109         //      evas_object_del(ad->ly_main);
110                 setting_view_plugin_main.is_create = 0;
111         //}
112
113         return SETTING_RETURN_SUCCESS;
114 }
115
116 static int setting_plugin_main_update(void *cb)
117 {
118         SETTING_TRACE_BEGIN;
119         /* error check */
120         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
121
122         SettingPluginUG *ad = (SettingPluginUG *) cb;
123
124         if (ad->ly_main != NULL) {
125                 evas_object_show(ad->ly_main);
126         }
127
128         return SETTING_RETURN_SUCCESS;
129 }
130
131 static int setting_plugin_main_cleanup(void *cb)
132 {
133         SETTING_TRACE_BEGIN;
134         return SETTING_RETURN_SUCCESS;
135 }
136
137 /* ***************************************************
138  *
139  *general func
140  *
141  ***************************************************/
142
143 static void setting_plugin_main_click_softkey_back_cb(void *data, Evas_Object *obj, void *event_info)
144 {
145         SETTING_TRACE_BEGIN;
146         /* error check */
147         setting_retm_if(data == NULL,
148                         "[Setting > Plugin] Data parameter is NULL");
149
150         SettingPluginUG *ad = (SettingPluginUG *) data;
151
152         /* Send destroy request */
153         ug_destroy_me(ad->ug);
154         SETTING_TRACE_END;
155
156 }
157