4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 #include <appcore-efl.h>
30 #include <Ecore_Wayland.h>
33 #include "rpm-frontend.h"
34 #include "rpm-installer-util.h"
35 #include "rpm-homeview.h"
36 #include "rpm-installer.h"
38 #define DESKTOP_W 720.0
40 extern struct appdata ad;
42 extern ri_frontend_data front_data;
43 Evas_Object *popup_global;
45 static void __ri_response_cb1(void *data, Evas_Object *obj, void *event);
46 static void __ri_response_cb2(void *data, Evas_Object *obj, void *event);
47 static void __ri_win_del(void *data, Evas_Object *obj, void *event);
48 static Eina_Bool __ri_perform_downgrade(void *data);
50 void _ri_information_popup(Evas_Smart_Cb func, const char *output,
55 evas_object_show(ad.win_main);
56 Evas_Object *popup = NULL;
57 popup = elm_popup_add(ad.win_main);
60 elm_object_part_text_set(popup, dgettext("sys_string",
61 "IDS_COM_BODY_INFORMATION"), NULL);
62 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
64 elm_object_text_set(popup, output);
65 Evas_Object *button = NULL;
66 button = elm_button_add(popup);
67 elm_object_text_set(button, dgettext("sys_string", "IDS_COM_SK_OK"));
68 elm_object_part_content_set(popup, "button1", button);
69 evas_object_smart_callback_add(button, "clicked", func, user_param);
70 evas_object_show(popup);
73 void _ri_package_downgrade_popup(Evas_Smart_Cb func1,
75 const char *output, void *user_param)
79 evas_object_show(ad.win_main);
80 Evas_Object *popup = NULL;
81 popup = elm_popup_add(ad.win_main);
84 elm_object_part_text_set(popup, dgettext("sys_string",
85 "IDS_COM_BODY_INFORMATION"), NULL);
86 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
88 elm_object_text_set(popup, output);
89 Evas_Object *button1 = NULL;
90 Evas_Object *button2 = NULL;
91 button1 = elm_button_add(popup);
92 elm_object_text_set(button1, dgettext("sys_string", "IDS_COM_SK_YES"));
93 elm_object_part_content_set(popup, "button1", button1);
94 evas_object_smart_callback_add(button1, "clicked", func1, user_param);
96 button2 = elm_button_add(popup);
97 elm_object_text_set(button2, dgettext("sys_string", "IDS_COM_SK_NO"));
98 elm_object_part_content_set(popup, "button2", button2);
99 evas_object_smart_callback_add(button2, "clicked", func2, user_param);
100 popup_global = popup;
101 evas_object_show(popup);
104 static void __ri_win_del(void *data, Evas_Object *obj, void *event)
109 static Eina_Bool __ri_perform_downgrade(void *data)
112 ret = _rpm_installer_package_install(front_data.args->pkgid,
116 _ri_error_no_to_string(ret, &errstr);
117 _ri_broadcast_status_notification(front_data.args->pkgid,
119 _ri_stat_cb(front_data.args->pkgid, "error", errstr);
120 _ri_broadcast_status_notification(front_data.args->pkgid,
122 _ri_stat_cb(front_data.args->pkgid, "end", "fail");
124 "install failed with err(%d) (%s)\n", ret, errstr);
126 _d_msg(DEBUG_INFO, "install success\n");
127 _ri_broadcast_status_notification(front_data.args->pkgid,
129 _ri_stat_cb(front_data.args->pkgid, "end", "ok");
131 _ri_set_backend_state_info(REQUEST_COMPLETED);
132 _ri_set_backend_state(1);
136 static void __ri_response_cb1(void *data, Evas_Object *obj, void *event)
138 printf("\nresponse callback=%d\n", (int)event);
141 ecore_idler_add(__ri_perform_downgrade, NULL);
142 _d_msg(DEBUG_INFO, "doUpgrade is %d\n", do_upgrade);
143 evas_object_del(obj);
144 evas_object_del(popup_global);
147 static void __ri_response_cb2(void *data, Evas_Object *obj, void *event)
149 printf("\nresponse callback=%d\n", (int)event);
152 ecore_idler_add(__ri_perform_downgrade, NULL);
153 evas_object_del(obj);
154 evas_object_del(popup_global);
155 _d_msg(DEBUG_INFO, "doUpgrade is %d\n", do_upgrade);
159 Eina_Bool _ri_init_appdata(struct appdata *user_data)
161 unsigned char *prop_data = NULL;
169 user_data->win_main = elm_win_add(NULL, PACKAGE, ELM_WIN_DIALOG_BASIC);
170 if (!user_data->win_main)
173 elm_win_title_set(user_data->win_main, PACKAGE);
174 elm_win_alpha_set(user_data->win_main, EINA_TRUE);
175 elm_win_borderless_set(user_data->win_main, EINA_TRUE);
176 elm_win_raise(user_data->win_main);
178 ecore_x_window_geometry_get(ecore_x_window_root_get
179 (ecore_x_window_focus_get()), &x, &y, &w,
181 ret = ecore_x_window_prop_property_get(ecore_x_window_root_get
182 (ecore_x_window_focus_get()),
183 ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
184 ECORE_X_ATOM_CARDINAL, 32,
186 #else /* HAVE_WAYLAND */ /* TO_DO_WAYLAND */
187 _d_msg(DEBUG_INFO, "Operation not supported in a pure Wayland\
188 environment. To do: replace the X11 dependant functions with\
189 Wayland compatible ones.\n");
191 if (ret && prop_data)
192 memcpy(&rotation, prop_data, sizeof(int));
195 evas_object_resize(user_data->win_main, w, h);
196 evas_object_move(user_data->win_main, x, y);
197 /*evas_object_show(user_data->win_main);
198 evas_object_smart_callback_add(user_data->win_main, "delete,request",
200 elm_win_indicator_state_set(user_data->win_main, EINA_TRUE);*/
203 elm_config_scale_set(s);
204 user_data->evas = evas_object_evas_get(user_data->win_main);
205 if (!user_data->evas)
211 Eina_Bool _ri_init_home_view(struct appdata *user_data)
217 void _ri_destroy_home_view(struct appdata *user_data)
223 evas_object_del(user_data->main_view);
226 int _ri_frontend_launch_main_view(struct appdata *data)
229 if (!_ri_init_appdata(data)) {
232 if (!_ri_init_home_view(data)) {
238 void _ri_frontend_update_progress_info(struct appdata *data, char *progressinfo)
240 elm_object_text_set(data->scrollbar_label, progressinfo);
241 _ri_information_popup(__ri_win_del, progressinfo, data);
244 void _ri_package_downgrade_information(const char *message)
246 _ri_package_downgrade_popup(__ri_response_cb1, __ri_response_cb2, message, &ad);