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.
26 #include <Elementary.h>
27 #include <appcore-efl.h>
29 #include <glib-object.h>
31 #include "rpm-frontend.h"
32 #include "rpm-homeview.h"
33 #include "rpm-installer-util.h"
34 #include "rpm-installer.h"
35 #include <pkgmgr_installer.h>
37 static void __ri_start_processing(void *user_data);
38 static Eina_Bool __ri_elm_exit_cb(void *data);
42 extern char scrolllabel[256];
43 extern ri_frontend_data front_data;
44 pkgmgr_installer *pi = NULL;
46 /**< Called before main loop */
47 int app_create(void *user_data)
51 struct appdata *data = (struct appdata *)user_data;
52 ri_frontend_cmdline_arg *fdata = front_data.args;
53 /*In case of downgrade, popup should be shown even if quiet mode*/
54 ret = _ri_frontend_launch_main_view(data);
58 /**< Called after main loop */
59 int app_terminate(void *user_data)
61 struct appdata *data = (struct appdata *)user_data;
62 ri_frontend_cmdline_arg *fdata = front_data.args;
63 if (fdata->quiet == 0) {
64 _ri_destroy_home_view(data);
69 /**< Called when every window goes back */
70 int app_pause(void *user_data)
75 /**< Called when any window comes on top */
76 int app_resume(void *user_data)
81 /**< Called at the first idler*/
82 int app_reset(bundle *b, void *user_data)
87 /**< Called at rotate device*/
88 int app_rotation(enum appcore_rm mode, void *user_data)
90 if (user_data == NULL) {
91 _d_msg(DEBUG_ERR, "arg supplied is NULL \n");
94 struct appdata *data = (struct appdata *)user_data;
97 case APPCORE_RM_LANDSCAPE_NORMAL:
101 case APPCORE_RM_LANDSCAPE_REVERSE:
105 case APPCORE_RM_PORTRAIT_REVERSE:
109 case APPCORE_RM_UNKNOWN:
110 case APPCORE_RM_PORTRAIT_NORMAL:
115 elm_win_rotation_with_resize_set(data->win_main, angle);
119 Eina_Bool show_popup_cb(void *data)
121 /*Avoid log printing as it is an idler function*/
124 const char message[256] = {'\0'};
125 state = _ri_get_backend_state_info();
127 case REQUEST_ACCEPTED:
129 case GOT_PACKAGE_INFO_SUCCESSFULLY:
131 case REQUEST_PENDING:
132 strncpy(message, _("Continue Downgrade?"), 255);
133 _ri_package_downgrade_information(message);
134 /*request is not completed yet. We just got confirmation
135 from user whether to downgrade or not*/
136 _ri_set_backend_state_info(REQUEST_ACCEPTED);
138 case REQUEST_COMPLETED:
140 if (front_data.args->quiet == 0) {
141 _ri_frontend_update_progress_info(&ad, scrolllabel);
151 static void __ri_start_processing(void *user_data)
154 if (user_data == NULL) {
155 _d_msg(DEBUG_ERR, "arg supplied is NULL \n");
158 ri_frontend_data *data = (ri_frontend_data *) user_data;
160 ret = _ri_cmdline_process(data);
162 _ri_cmdline_destroy(data);
166 int main(int argc, char *argv[])
169 ri_frontend_cmdline_arg *data = NULL;
170 struct appcore_ops ops;
171 ops.create = app_create;
172 ops.terminate = app_terminate;
173 ops.pause = app_pause;
174 ops.resume = app_resume;
175 ops.reset = app_reset;
178 appcore_set_i18n(PACKAGE, LOCALE_PATH);
179 _d_msg_init("rpm-installer");
180 data = (ri_frontend_cmdline_arg *) calloc(1,
182 (ri_frontend_cmdline_arg));
184 _d_msg(DEBUG_ERR, "Not Enough Memory\n");
185 ret = RPM_INSTALLER_ERR_NOT_ENOUGH_MEMORY;
191 data->req_cmd = INVALID_CMD;
192 data->move_type = -1;
194 /* We need to use pkgmgr_installer_receive request()
195 to parse the arguments */
197 _ri_parse_cmdline(argc, argv, data)) != RPM_INSTALLER_SUCCESS) {
198 _d_msg(DEBUG_ERR, "_ri_parse_cmdline failed \n");
202 front_data.args = data;
203 front_data.security_cookie = NULL;
204 front_data.error = NULL;
206 __ri_start_processing(&front_data);
208 /*The installer has finished the installation/uninstallation.
209 Now, if it was a non quiet operation we need to show the popup. */
210 ecore_idler_add(show_popup_cb, NULL);
212 _d_msg(DEBUG_RESULT, "About to run EFL Main Loop");
213 appcore_efl_main(PACKAGE, &argc, &argv, &ops);
214 _d_msg(DEBUG_RESULT, "%d\n", ret_val);
218 pkgmgr_installer_free(pi);
239 _d_msg(DEBUG_RESULT, "%d\n", ret);