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"
34 static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv)
38 struct ug_data *ugd = NULL;
40 int ret = SERVICE_ERROR_NONE;
42 retv_if(priv == NULL, NULL);
44 bindtextdomain(PACKAGE, LOCALEDIR);
49 ugd->win_main = ug_get_parent_layout(ug);
50 retv_if(ugd->win_main == NULL, NULL);
52 ugd->bg = mgr_app_widget_create_bg(ugd->win_main);
54 MGR_APP_DEBUG_ERR("ugd->bg is null");
55 MGR_APP_MEM_FREE(ugd->win_main);
59 ugd->layout_main = mgr_app_widget_create_main_layout(ugd->win_main);
60 if (!ugd->layout_main) {
61 MGR_APP_DEBUG_ERR("ugd->layout_main is null");
62 MGR_APP_MEM_FREE(ugd->win_main);
63 MGR_APP_MEM_FREE(ugd->bg);
68 elm_object_part_content_set(ugd->layout_main, "elm.swallow.bg", ugd->bg);
70 ugd->navi_bar = mgr_app_view_create_base_navigation(ugd->layout_main);
72 MGR_APP_DEBUG_ERR("ugd->navi_bar is null");
73 MGR_APP_MEM_FREE(ugd->win_main);
74 MGR_APP_MEM_FREE(ugd->bg);
75 MGR_APP_MEM_FREE(ugd->layout_main);
80 /* package manager listener */
82 pkgmgr_client_free(ugd->pc_listen);
83 ugd->pc_listen = NULL;
85 ugd->pc_listen = pkgmgr_client_new(PC_LISTENING);
86 if (!ugd->pc_listen) {
87 MGR_APP_DEBUG_ERR("pc_listen is null");
88 MGR_APP_MEM_FREE(ugd->win_main);
89 MGR_APP_MEM_FREE(ugd->bg);
90 MGR_APP_MEM_FREE(ugd->layout_main);
96 ugd->uninstall = EINA_FALSE;
98 ret = service_get_extra_data(service, STR_VIEWTYPE, &arg);
100 case SERVICE_ERROR_NONE:
101 MGR_APP_DEBUG("SERVICE_ERROR_NONE. arg: %s", arg);
103 case SERVICE_ERROR_INVALID_PARAMETER:
104 MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_PARAMETER");
106 case SERVICE_ERROR_KEY_NOT_FOUND:
107 MGR_APP_DEBUG_ERR("SERVICE_ERROR_KEY_NOT_FOUND");
109 case SERVICE_ERROR_OUT_OF_MEMORY:
110 MGR_APP_DEBUG_ERR("SERVICE_ERROR_OUT_OF_MEMORY");
112 case SERVICE_ERROR_INVALID_DATA_TYPE:
113 MGR_APP_DEBUG_ERR("SERVICE_ERROR_INVALID_DATA_TYPE");
116 MGR_APP_DEBUG_ERR("ret value has an error.");
120 if (arg && !strncmp(arg, STR_MANAGE_APPLICATIONS, strlen(STR_MANAGE_APPLICATIONS))) {
121 mgrapp_view_list_create((void*)ugd);
123 MGR_APP_DEBUG_ERR("argument has an error.");
127 return ugd->layout_main;
130 static void on_start(ui_gadget_h ug, service_h service, void *priv)
136 static void on_pause(ui_gadget_h ug, service_h service, void *priv)
140 mgr_app_doubletap_sensor_disable();
145 static void on_resume(ui_gadget_h ug, service_h service, void *priv)
149 struct ug_data *ugd = NULL;
150 view_type_t target_view = VIEW_TYPE_NONE;
152 target_view = mgrapp_get_view_type();
153 if (VIEW_TYPE_APP_INFO == target_view) {
154 ret_if(priv == NULL);
156 mgrapp_view_info_update((void*)ugd);
159 mgr_app_doubletap_sensor_enable();
164 static void on_destroy(ui_gadget_h ug, service_h service, void *priv)
168 ret_if(priv == NULL);
170 struct ug_data *ugd = priv;
172 mgr_app_doubletap_sensor_destroy();
174 if (ugd->pc_listen) {
175 pkgmgr_client_free(ugd->pc_listen);
176 ugd->pc_listen = NULL;
179 if (ugd->layout_main) {
180 evas_object_del(ugd->layout_main);
181 ugd->layout_main = NULL;
187 static void on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv)
193 static void on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv)
197 case UG_EVENT_LOW_MEMORY:
199 case UG_EVENT_LOW_BATTERY:
201 case UG_EVENT_LANG_CHANGE:
203 case UG_EVENT_ROTATE_PORTRAIT:
205 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
207 case UG_EVENT_ROTATE_LANDSCAPE:
209 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
217 static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv)
222 case UG_KEY_EVENT_END:
231 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
234 struct ug_data *ugd = NULL;
236 retv_if(ops == NULL, -1);
238 MGR_APP_MEM_MALLOC(ugd, (1), struct ug_data);
240 ops->create = on_create;
241 ops->start = on_start;
242 ops->pause = on_pause;
243 ops->resume = on_resume;
244 ops->destroy = on_destroy;
245 ops->message = on_message;
246 ops->event = on_event;
247 ops->key_event = on_key_event;
249 ops->opt = UG_OPT_INDICATOR_ENABLE;
255 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
258 struct ug_data *ugd = NULL;
263 MGR_APP_MEM_FREE(ugd);
268 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
271 /* nothing to do for Setting>Reset */