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.
19 #define UG_MODULE_API __attribute__ ((visibility("default")))
22 #include "mgr-app-uigadget.h"
23 #include "mgr-app-common-debug.h"
24 #include "mgr-app-common-error.h"
25 #include "mgr-app-common-util.h"
26 #include "mgr-app-view-main.h"
27 #include "mgr-app-view-common.h"
28 #include "mgr-app-widget.h"
30 #define STR_VIEWTYPE "viewtype"
31 #define STR_MANAGE_APPLICATIONS "manage-applications"
33 #define EDC_FILE EDJDIR"/ug-setting-manage-applications-efl/ug-setting-manage-applications-efl.edj"
35 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
39 struct ug_data *ugd = NULL;
41 int ret = SERVICE_ERROR_NONE;
43 retv_if(priv == NULL, NULL);
45 bindtextdomain(PACKAGE, LOCALEDIR);
50 ugd->win_main = ug_get_parent_layout(ug);
51 retv_if(ugd->win_main == NULL, NULL);
53 ugd->bg = mgr_app_widget_create_bg(ugd->win_main);
55 MGR_APP_DEBUG_ERR("ugd->bg is null");
56 MGR_APP_MEM_FREE(ugd->win_main);
60 ugd->layout_main = mgr_app_widget_create_main_layout(ugd->win_main);
61 if (!ugd->layout_main) {
62 MGR_APP_DEBUG_ERR("ugd->layout_main is null");
63 MGR_APP_MEM_FREE(ugd->win_main);
64 MGR_APP_MEM_FREE(ugd->bg);
69 elm_object_part_content_set(ugd->layout_main, "elm.swallow.bg", ugd->bg);
71 ugd->navi_bar = mgr_app_view_create_base_navigation(ugd->layout_main);
73 MGR_APP_DEBUG_ERR("ugd->navi_bar is null");
74 MGR_APP_MEM_FREE(ugd->win_main);
75 MGR_APP_MEM_FREE(ugd->bg);
76 MGR_APP_MEM_FREE(ugd->layout_main);
81 /* package manager listener */
83 pkgmgr_client_free(ugd->pc_listen);
84 ugd->pc_listen = NULL;
86 ugd->pc_listen = pkgmgr_client_new(PC_LISTENING);
87 if (!ugd->pc_listen) {
88 MGR_APP_DEBUG_ERR("pc_listen is null");
89 MGR_APP_MEM_FREE(ugd->win_main);
90 MGR_APP_MEM_FREE(ugd->bg);
91 MGR_APP_MEM_FREE(ugd->layout_main);
97 ugd->uninstall = EINA_FALSE;
99 ret = service_get_extra_data(service, STR_VIEWTYPE, &arg);
101 case SERVICE_ERROR_NONE:
102 MGR_APP_DEBUG("SERVICE_ERROR_NONE. arg: %s", arg);
104 case SERVICE_ERROR_INVALID_PARAMETER:
105 MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_PARAMETER");
107 case SERVICE_ERROR_KEY_NOT_FOUND:
108 MGR_APP_DEBUG_ERR("SERVICE_ERROR_KEY_NOT_FOUND");
110 case SERVICE_ERROR_OUT_OF_MEMORY:
111 MGR_APP_DEBUG_ERR("SERVICE_ERROR_OUT_OF_MEMORY");
113 case SERVICE_ERROR_INVALID_DATA_TYPE:
114 MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_DATA_TYPE");
117 MGR_APP_DEBUG_ERR("ret value has an error.");
121 elm_theme_extension_add(NULL, EDC_FILE);
123 if (arg && !strncmp(arg, STR_MANAGE_APPLICATIONS, strlen(STR_MANAGE_APPLICATIONS))) {
124 mgrapp_view_list_create((void*)ugd);
126 MGR_APP_DEBUG_ERR("argument has an error.");
130 return ugd->layout_main;
133 static void on_start(ui_gadget_h ug, service_h service, void *priv)
139 static void on_pause(ui_gadget_h ug, service_h service, void *priv)
143 mgr_app_doubletap_sensor_disable();
148 static void on_resume(ui_gadget_h ug, service_h service, void *priv)
152 struct ug_data *ugd = NULL;
153 view_type_t target_view = VIEW_TYPE_NONE;
155 target_view = mgrapp_get_view_type();
156 if (VIEW_TYPE_APP_INFO == target_view) {
157 ret_if(priv == NULL);
159 mgrapp_view_info_update((void*)ugd);
162 mgr_app_doubletap_sensor_enable();
167 static void on_destroy(ui_gadget_h ug, service_h service, void *priv)
171 ret_if(priv == NULL);
173 struct ug_data *ugd = priv;
175 mgr_app_doubletap_sensor_destroy();
177 if (ugd->pc_listen) {
178 pkgmgr_client_free(ugd->pc_listen);
179 ugd->pc_listen = NULL;
182 if (ugd->layout_main) {
183 evas_object_del(ugd->layout_main);
184 ugd->layout_main = NULL;
190 static void on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv)
196 static void on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv)
200 case UG_EVENT_LOW_MEMORY:
202 case UG_EVENT_LOW_BATTERY:
204 case UG_EVENT_LANG_CHANGE:
206 case UG_EVENT_ROTATE_PORTRAIT:
208 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
210 case UG_EVENT_ROTATE_LANDSCAPE:
212 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
220 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv)
225 case UG_KEY_EVENT_END:
234 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
237 struct ug_data *ugd = NULL;
239 retv_if(ops == NULL, -1);
241 MGR_APP_MEM_MALLOC(ugd, (1), struct ug_data);
243 ops->create = on_create;
244 ops->start = on_start;
245 ops->pause = on_pause;
246 ops->resume = on_resume;
247 ops->destroy = on_destroy;
248 ops->message = on_message;
249 ops->event = on_event;
250 ops->key_event = on_key_event;
252 ops->opt = UG_OPT_INDICATOR_ENABLE;
258 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
261 struct ug_data *ugd = NULL;
266 MGR_APP_MEM_FREE(ugd);
271 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
274 /* nothing to do for Setting>Reset */