4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #define UG_MODULE_API __attribute__ ((visibility("default")))
23 #include <efl_extension.h>
24 #include <setting-cfg.h>
26 #include "setting-appmgr-pkginfo.h"
27 #include "setting-appmgr-pkginfo-utils.h"
28 #include "setting-appmgr-runinfo.h"
29 #include "setting-appmgr-utils.h"
30 #include "setting-appmgr-main.h"
31 #include "setting-appmgr.h"
33 static void appmgrUg_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
35 SettingAppMgrUG *ad = data;
39 if (ad->runinfo_view->is_create)
40 setting_view_update(ad->runinfo_view, ad);
41 if (ad->pkginfo_view->is_create)
42 setting_view_update(ad->pkginfo_view, ad);
43 if (ad->main_view->is_create)
44 setting_view_update(ad->main_view, ad);
47 static void _app_mgr_item_del(void *data, Evas_Object *obj)
50 setting_retm_if(data == NULL, "Data parameter is NULL");
51 Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *) data;
59 _main_gl_del_cb(void *data, Evas_Object *obj EINA_UNUSED)
61 retv_if(data == NULL, NULL);
62 /*appmgr_listinfo *info = data; */
63 /*info->item = NULL; */
66 static inline void appmgrUg_init_itcs(SettingAppMgrUG *ad)
68 setting_create_Gendial_itc(SETTING_GENLIST_GROUP_INDEX_STYLE, &(ad->itc_grp_title));
69 setting_create_Gendial_itc("multiline_sub", &(ad->itc_multiline));
70 setting_create_Gendial_itc(SETTING_GENLIST_ICON_1LINE_STYLE, &(ad->itc_1txt_1ic_2));
71 setting_create_Gendial_itc(SETTING_GENLIST_ICON_1LINE_STYLE, &(ad->itc_1txt));
72 setting_create_Gendial_itc("multiline_sub.main", &(ad->itc_multiline_2txt));
74 ad->itc_sep.item_style = "dialogue/separator.transparent.2";
75 ad->itc_sep.func.text_get = NULL;
76 ad->itc_sep.func.content_get = NULL;
77 ad->itc_sep.func.state_get = NULL;
78 ad->itc_sep.func.del = NULL;
81 ad->itc_main.item_style = SETTING_GENLIST_2LINE_STYLE;
82 ad->itc_main.func.text_get = appmgrUg_main_gl_label_get;
83 ad->itc_main.func.content_get = appmgrUg_main_gl_icon_get;
84 ad->itc_main.func.state_get = NULL;
85 ad->itc_main.func.del = _main_gl_del_cb;
87 ad->itc_main.item_style = SETTING_GENLIST_2LINE_STYLE;
88 ad->itc_main.func.text_get = appmgrUg_main_gl_label_new_get;
89 ad->itc_main.func.content_get = appmgrUg_main_gl_icon_new_get;
90 ad->itc_main.func.state_get = NULL;
91 ad->itc_main.func.del = _main_gl_del_cb;
94 ad->itc_1ic.item_style = "1icon";
95 ad->itc_1ic.func.text_get = NULL;
96 ad->itc_1ic.func.content_get = appmgrUg_run_gl_stop_btn;
97 ad->itc_1ic.func.state_get = NULL;
98 ad->itc_1ic.func.del = NULL;
100 #if OLD_GENLIST_STYLE
101 ad->itc_info_title.item_style = SETTING_GENLIST_2LINE_STYLE;
102 ad->itc_info_title.func.text_get = appmgrUg_info_title_gl_label_get;
103 ad->itc_info_title.func.content_get = appmgrUg_info_title_gl_icon_get;
104 ad->itc_info_title.func.state_get = NULL;
105 ad->itc_info_title.func.del = NULL;
107 ad->itc_info_title.item_style = SETTING_GENLIST_2LINE_STYLE;
108 ad->itc_info_title.func.text_get = appmgrUg_info_title_gl_label_get;
109 ad->itc_info_title.func.content_get = appmgrUg_info_title_gl_icon_get;
110 ad->itc_info_title.func.state_get = NULL;
111 ad->itc_info_title.func.del = NULL;
114 ad->itc_2button1.item_style = "1icon";
115 ad->itc_2button1.func.text_get = NULL;
116 ad->itc_2button1.func.content_get = appmgrUg_info_2button1_gl_icon_get;
117 ad->itc_2button1.func.state_get = NULL;
118 ad->itc_2button1.func.del = NULL;
120 ad->itc_2button2.item_style = "1icon";
121 ad->itc_2button2.func.text_get = NULL;
122 ad->itc_2button2.func.content_get = appmgrUg_info_2button2_gl_icon_get;
123 ad->itc_2button2.func.state_get = NULL;
124 ad->itc_2button2.func.del = NULL;
126 setting_create_Gendial_itc("1icon", &(ad->itc_1button));
127 ad->itc_1button.func.text_get = NULL;
128 ad->itc_1button.func.content_get = appmgrUg_info_1button_gl_icon_get;
129 ad->itc_1button.func.del = NULL;
131 setting_create_Gendial_itc(SETTING_GENLIST_2LINE_STYLE, &(ad->itc_2txt_2));
132 ad->itc_2txt_2.func.text_get = appmgrUg_pkg_size_gl_label_get;
135 static void appmgrUg_navi_back(void *data, Evas_Object *obj, void *event_info)
138 SettingAppMgrUG *ad = data;
140 ret_if(data == NULL);
141 retm_if(ad->pkg_request, "pkg_request(%d)", ad->pkg_request);
143 elm_naviframe_item_pop(obj);
146 static inline Evas_Object *appmgrUg_create_navi(Evas_Object *parent,
151 retv_if(NULL == parent, NULL);
153 navi = elm_naviframe_add(parent);
154 elm_naviframe_prev_btn_auto_pushed_set(navi, EINA_FALSE);
156 eext_object_event_callback_add(navi, EEXT_CALLBACK_BACK, appmgrUg_navi_back, ad);
157 eext_object_event_callback_add(navi, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, ad);
159 evas_object_show(navi);
163 static int appmgrUg_get_tabtype(char *keyword)
165 retv_if(NULL == keyword, APPMGRUG_TAB_DOWNLOAD);
167 if (0 == safeStrCmp(keyword, MGRAPP_STR_DOWNLOADS))
168 return APPMGRUG_TAB_DOWNLOAD;
169 else if (0 == safeStrCmp(keyword, MGRAPP_STR_RUNNING))
170 return APPMGRUG_TAB_RUNNING;
171 else if (0 == safeStrCmp(keyword, MGRAPP_STR_ALL))
172 return APPMGRUG_TAB_ALL;
174 return APPMGRUG_TAB_DOWNLOAD;
177 static void *appmgrUg_on_create(ui_gadget_h ug, enum ug_mode mode,
178 app_control_h service, void *priv)
182 char *viewtype = NULL;
183 SettingAppMgrUG *ad = priv;
184 char *search_keyword = NULL;
186 retvm_if(NULL == ug || NULL == ad, NULL, "ug=%p, priv=%p is Invalid", ug, ad);
188 bindtextdomain(SETTING_PACKAGE, SETTING_LOCALEDIR);
189 textdomain(SETTING_PACKAGE);
192 ad->win = ug_get_window();
193 ad->lo_parent = ug_get_parent_layout(ug);
194 if (NULL == ad->lo_parent) {
195 SETTING_TRACE_ERROR("ug_get_parent_layout(ug) Fail");
199 appmgrUg_main_init(ad);
200 appmgrUg_pkginfo_init(ad);
201 appmgrUg_appinfo_init(ad);
203 appmgrUg_init_itcs(ad);
205 /*elm_theme_extension_add(NULL, SETTING_THEME_EDJ_NAME); */
207 ad->lo_main = setting_create_win_layout(ad->win);
208 ad->navi = appmgrUg_create_navi(ad->lo_main, ad);
209 if (NULL == ad->navi) {
210 SETTING_TRACE_ERROR("calloc() Fail");
213 elm_object_part_content_set(ad->lo_main, "elm.swallow.content", ad->navi);
215 app_control_get_extra_data(service, "viewtype", &viewtype);
216 app_control_get_extra_data(service, "keyword", &search_keyword);
218 if (0 == safeStrCmp(viewtype, "application-info")) {
219 /*register view table */
220 setting_view_node_table_register(&setting_view_appmgr_pkginfo, NULL);
222 SETTING_TRACE("viewtype : %s", viewtype);
224 app_control_get_extra_data(service, "pkgname", &pkgid);
225 SETTING_TRACE("pkgname : %s", pkgid);
226 ad->sel_pkgid = pkgid;
228 ad->sel_data_size = -1;
229 ad->support_taskmanager = TRUE;
230 ad->sel_is_disabled = FALSE;
232 ad->sel_label = NULL;
233 setting_view_create(ad->pkginfo_view, ad);
235 /*register view table */
236 setting_view_node_table_register(&setting_view_appmgr_main, NULL);
237 setting_view_node_table_register(&setting_view_appmgr_pkginfo, &setting_view_appmgr_main);
239 ad->tabtype = appmgrUg_get_tabtype(search_keyword);
240 setting_view_create(ad->main_view, ad);
244 evas_object_event_callback_add(ad->lo_parent, EVAS_CALLBACK_RESIZE, appmgrUg_resize,
249 static void appmgrUg_on_destroy(ui_gadget_h ug, app_control_h service, void *priv)
251 SettingAppMgrUG *ad = priv;
253 retm_if(NULL == ug || NULL == ad, "ug=%p, priv=%p is Invalid", ug, ad);
255 evas_object_event_callback_del(ad->lo_parent, EVAS_CALLBACK_RESIZE, appmgrUg_resize);
257 if (ad->runinfo_view->is_create)
258 setting_view_destroy(ad->runinfo_view, ad);
259 if (ad->pkginfo_view->is_create)
260 setting_view_destroy(ad->pkginfo_view, ad);
261 if (ad->main_view->is_create)
262 setting_view_destroy(ad->main_view, ad);
265 evas_object_del(ad->lo_main);
270 static void appmgrUg_on_pause(ui_gadget_h ug, app_control_h service, void *priv)
272 SettingAppMgrUG *ad = priv;
274 retm_if(NULL == ug || NULL == ad, "ug=%p, priv=%p is Invalid", ug, ad);
276 if (ad->runinfo_view->is_create)
277 setting_view_update(ad->runinfo_view, ad);
280 static void appmgrUg_on_resume(ui_gadget_h ug, app_control_h service, void *priv)
282 SettingAppMgrUG *ad = priv;
284 retm_if(NULL == ug || NULL == ad, "ug=%p, priv=%p is Invalid", ug, ad);
286 if (ad->pkginfo_view->is_create)
287 setting_view_update(ad->pkginfo_view, ad);
288 if (ad->main_view->is_create)
289 setting_view_update(ad->main_view, ad);
291 evas_object_show(ad->lo_main);
294 static void appmgrUg_on_event(ui_gadget_h ug, enum ug_event event,
295 app_control_h service, void *priv)
297 retm_if(NULL == ug || NULL == priv, "ug=%p, priv=%p is Invalid", ug, priv);
300 case UG_EVENT_LOW_MEMORY:
301 case UG_EVENT_LOW_BATTERY:
302 case UG_EVENT_LANG_CHANGE:
303 case UG_EVENT_ROTATE_PORTRAIT:
304 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
305 case UG_EVENT_ROTATE_LANDSCAPE:
306 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
307 case UG_EVENT_REGION_CHANGE:
313 static void appmgrUg_on_key_event(ui_gadget_h ug, enum ug_key_event event,
314 app_control_h service, void *priv)
320 case UG_KEY_EVENT_END:
328 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
332 retv_if(NULL == ops, -1);
334 ad = calloc(1, sizeof(SettingAppMgrUG));
336 SETTING_TRACE_ERROR("calloc() Fail");
340 ops->create = appmgrUg_on_create;
342 ops->pause = appmgrUg_on_pause;
343 ops->resume = appmgrUg_on_resume;
344 ops->destroy = appmgrUg_on_destroy;
346 ops->event = appmgrUg_on_event;
347 ops->key_event = appmgrUg_on_key_event;
349 ops->opt = UG_OPT_INDICATOR_ENABLE;
355 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
362 UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv,
366 Setting_Cfg_Node_T *node;
367 Eina_List **pplist = priv;
368 char ug_args[APPMGRUG_MAX_STR_LEN];
369 const Setting_Cfg_Node_T search_configs[] = {
370 {MGRAPP_STR_DOWNLOADS, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
371 {MGRAPP_STR_RUNNING, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
372 {MGRAPP_STR_ALL, NULL, NULL, 0, Cfg_Item_unResetable, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
375 retv_if(NULL == priv, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
376 retv_if(NULL == applocale, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
378 *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
380 size = sizeof(search_configs) / sizeof(Setting_Cfg_Node_T);
382 for (i = 0; i < size; i++) {
383 sprintf(ug_args, "keyword:%s", search_configs[i].key_name);
384 node = setting_plugin_search_item_subindex_add(
385 search_configs[i].key_name,
388 search_configs[i].item_type,
389 search_configs[i].data, "Application Manager");
391 *pplist = eina_list_append(*pplist, node);