Merge "packaging: spec cleanup" into tizen
[apps/core/preloaded/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 extern int service_to_bundle(service_h service, bundle **data);
25
26 static int setting_plugin_main_create(void *cb);
27 static int setting_plugin_main_destroy(void *cb);
28 static int setting_plugin_main_update(void *cb);
29 static int setting_plugin_main_cleanup(void *cb);
30
31 setting_view setting_view_plugin_main = {
32         .create = setting_plugin_main_create,
33         .destroy = setting_plugin_main_destroy,
34         .update = setting_plugin_main_update,
35         .cleanup = setting_plugin_main_cleanup,
36 };
37
38
39
40
41 static void setting_plugin_main_click_softkey_back_cb(void *data, Evas_Object *obj, void *event_info);
42
43
44 /* ***************************************************
45  *
46  *basic func
47  *
48  ***************************************************/
49 static int setting_plugin_main_create(void *cb)
50 {
51         SETTING_TRACE_BEGIN;
52         /* error check */
53         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
54
55         SettingPluginUG *ad = (SettingPluginUG *) cb;
56
57         Evas_Object *scroller = NULL;
58
59         /* add basic layout */
60         char setBtnStr[MAX_DISPLAY_NAME_LEN_ON_UI];
61         snprintf(setBtnStr, sizeof(setBtnStr), "%s",
62                  (char *)dgettext("sys_string", "IDS_COM_BODY_BACK"));
63
64         /////////////////////////////////////////////////////////////////////////////////////////////////
65 #if 1
66         // there's no argument, use pappid
67         if (ad->pkgname == NULL) {
68                 SETTING_TRACE("pkgname is NULL, it's error, assign it");
69                 goto errorhandle;
70         }
71
72         char plugin_path[1024];
73         snprintf(plugin_path, 1024, "/opt/apps/%s/setting/setting.xml", ad->pkgname);
74         SETTING_TRACE(" >> SELECTED plugin name : %s \n", plugin_path);
75
76
77         PluginNode* plugin_node = setting_plugin_create(ad->navi_bar, ad->win_get);
78         plugin_node->win_main_layout = ad->win_main_layout;
79
80         plugin_node->ug = ad->ug;
81
82         setting_drawer_list_init();
83         setting_dbus_handler_init( plugin_node );
84
85         plugin_node->plugin_path = strdup(plugin_path);
86         int ret = setting_plugin_load(plugin_node, (const char *)plugin_node->plugin_path);
87         if (ret < 0)
88                 goto errorhandle;
89
90         ad->ly_main = plugin_node->ly_main;
91
92         ad->plugin_node = plugin_node; // the selected plugin name
93 #endif
94
95         setting_view_plugin_main.is_create = 1;
96         return SETTING_RETURN_SUCCESS;
97 errorhandle:
98                 // resource free
99                 return SETTING_RETURN_FAIL;
100 }
101
102 static int setting_plugin_main_destroy(void *cb)
103 {
104         SETTING_TRACE_BEGIN;
105         /* error check */
106         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
107         SettingPluginUG *ad = (SettingPluginUG *) cb;
108
109
110         setting_dbus_handler_fini();
111         setting_drawer_list_fini();
112
113 //      setting_plugin_destroy(ad->plugin_node );
114
115         //if (ad->ly_main != NULL) {
116         //      evas_object_del(ad->ly_main);
117                 setting_view_plugin_main.is_create = 0;
118         //}
119
120         return SETTING_RETURN_SUCCESS;
121 }
122
123 static int setting_plugin_main_update(void *cb)
124 {
125         SETTING_TRACE_BEGIN;
126         /* error check */
127         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
128
129         SettingPluginUG *ad = (SettingPluginUG *) cb;
130
131         if (ad->ly_main != NULL) {
132                 evas_object_show(ad->ly_main);
133         }
134
135         return SETTING_RETURN_SUCCESS;
136 }
137
138 static int setting_plugin_main_cleanup(void *cb)
139 {
140         SETTING_TRACE_BEGIN;
141         return SETTING_RETURN_SUCCESS;
142 }
143
144 /* ***************************************************
145  *
146  *general func
147  *
148  ***************************************************/
149
150 static void setting_plugin_main_click_softkey_back_cb(void *data, Evas_Object *obj, void *event_info)
151 {
152         SETTING_TRACE_BEGIN;
153         /* error check */
154         setting_retm_if(data == NULL,
155                         "[Setting > Plugin] Data parameter is NULL");
156
157         SettingPluginUG *ad = (SettingPluginUG *) data;
158
159         /* Send destroy request */
160         ug_destroy_me(ad->ug);
161         SETTING_TRACE_END;
162 }
163