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>
26 #include "rpm-frontend.h"
27 #include "rpm-installer-util.h"
28 #include "rpm-homeview.h"
29 #include "rpm-installer.h"
31 #define DESKTOP_W 720.0
33 extern struct appdata ad;
35 extern ri_frontend_data front_data;
36 Evas_Object *popup_global;
38 static void __ri_response_cb1(void *data, Evas_Object *obj, void *event);
39 static void __ri_response_cb2(void *data, Evas_Object *obj, void *event);
40 static void __ri_win_del(void *data, Evas_Object *obj, void *event);
41 static Eina_Bool __ri_perform_downgrade(void *data);
43 void _ri_information_popup(Evas_Smart_Cb func, const char *output,
48 evas_object_show(ad.win_main);
49 Evas_Object *popup = NULL;
50 popup = elm_popup_add(ad.win_main);
53 elm_object_part_text_set(popup, dgettext("sys_string",
54 "IDS_COM_BODY_INFORMATION"), NULL);
55 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
57 elm_object_text_set(popup, output);
58 Evas_Object *button = NULL;
59 button = elm_button_add(popup);
60 elm_object_text_set(button, dgettext("sys_string", "IDS_COM_SK_OK"));
61 elm_object_part_content_set(popup, "button1", button);
62 evas_object_smart_callback_add(button, "clicked", func, user_param);
63 evas_object_show(popup);
66 void _ri_package_downgrade_popup(Evas_Smart_Cb func1,
68 const char *output, void *user_param)
72 evas_object_show(ad.win_main);
73 Evas_Object *popup = NULL;
74 popup = elm_popup_add(ad.win_main);
77 elm_object_part_text_set(popup, dgettext("sys_string",
78 "IDS_COM_BODY_INFORMATION"), NULL);
79 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
81 elm_object_text_set(popup, output);
82 Evas_Object *button1 = NULL;
83 Evas_Object *button2 = NULL;
84 button1 = elm_button_add(popup);
85 elm_object_text_set(button1, dgettext("sys_string", "IDS_COM_SK_YES"));
86 elm_object_part_content_set(popup, "button1", button1);
87 evas_object_smart_callback_add(button1, "clicked", func1, user_param);
89 button2 = elm_button_add(popup);
90 elm_object_text_set(button2, dgettext("sys_string", "IDS_COM_SK_NO"));
91 elm_object_part_content_set(popup, "button2", button2);
92 evas_object_smart_callback_add(button2, "clicked", func2, user_param);
94 evas_object_show(popup);
97 static void __ri_win_del(void *data, Evas_Object *obj, void *event)
102 static Eina_Bool __ri_perform_downgrade(void *data)
105 ret = _rpm_installer_package_install(front_data.args->pkgid,
109 _ri_error_no_to_string(ret, &errstr);
110 _ri_broadcast_status_notification(front_data.args->pkgid,
112 _ri_stat_cb(front_data.args->pkgid, "error", errstr);
113 _ri_broadcast_status_notification(front_data.args->pkgid,
115 _ri_stat_cb(front_data.args->pkgid, "end", "fail");
117 "install failed with err(%d) (%s)\n", ret, errstr);
119 _d_msg(DEBUG_INFO, "install success\n");
120 _ri_broadcast_status_notification(front_data.args->pkgid,
122 _ri_stat_cb(front_data.args->pkgid, "end", "ok");
124 _ri_set_backend_state_info(REQUEST_COMPLETED);
125 _ri_set_backend_state(1);
129 static void __ri_response_cb1(void *data, Evas_Object *obj, void *event)
131 printf("\nresponse callback=%d\n", (int)event);
134 ecore_idler_add(__ri_perform_downgrade, NULL);
135 _d_msg(DEBUG_INFO, "doUpgrade is %d\n", do_upgrade);
136 evas_object_del(obj);
137 evas_object_del(popup_global);
140 static void __ri_response_cb2(void *data, Evas_Object *obj, void *event)
142 printf("\nresponse callback=%d\n", (int)event);
145 ecore_idler_add(__ri_perform_downgrade, NULL);
146 evas_object_del(obj);
147 evas_object_del(popup_global);
148 _d_msg(DEBUG_INFO, "doUpgrade is %d\n", do_upgrade);
152 Eina_Bool _ri_init_appdata(struct appdata *user_data)
154 unsigned char *prop_data = NULL;
161 user_data->win_main = elm_win_add(NULL, PACKAGE, ELM_WIN_DIALOG_BASIC);
162 if (!user_data->win_main)
165 elm_win_title_set(user_data->win_main, PACKAGE);
166 elm_win_alpha_set(user_data->win_main, EINA_TRUE);
167 elm_win_borderless_set(user_data->win_main, EINA_TRUE);
168 elm_win_raise(user_data->win_main);
169 ecore_x_window_geometry_get(ecore_x_window_root_get
170 (ecore_x_window_focus_get()), &x, &y, &w,
173 ecore_x_window_prop_property_get(ecore_x_window_root_get
174 (ecore_x_window_focus_get()),
175 ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE,
176 ECORE_X_ATOM_CARDINAL, 32,
178 if (ret && prop_data)
179 memcpy(&rotation, prop_data, sizeof(int));
182 evas_object_resize(user_data->win_main, w, h);
183 evas_object_move(user_data->win_main, x, y);
184 /*evas_object_show(user_data->win_main);
185 evas_object_smart_callback_add(user_data->win_main, "delete,request",
187 elm_win_indicator_state_set(user_data->win_main, EINA_TRUE);*/
190 elm_config_scale_set(s);
191 user_data->evas = evas_object_evas_get(user_data->win_main);
192 if (!user_data->evas)
198 Eina_Bool _ri_init_home_view(struct appdata *user_data)
204 void _ri_destroy_home_view(struct appdata *user_data)
210 evas_object_del(user_data->main_view);
213 int _ri_frontend_launch_main_view(struct appdata *data)
216 if (!_ri_init_appdata(data)) {
219 if (!_ri_init_home_view(data)) {
225 void _ri_frontend_update_progress_info(struct appdata *data, char *progressinfo)
227 elm_object_text_set(data->scrollbar_label, progressinfo);
228 _ri_information_popup(__ri_win_del, progressinfo, data);
231 void _ri_package_downgrade_information(const char *message)
233 _ri_package_downgrade_popup(__ri_response_cb1, __ri_response_cb2, message, &ad);