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.
28 #include <Elementary.h>
29 #include <appcore-efl.h>
31 #include <glib-object.h>
32 /*#include <utilX.h>*/
35 #include "frontendhomeview.h"
36 #include "native_installer_util.h"
37 #include "nativeinstaller.h"
38 #include<pkgmgr_installer.h>
40 static void __start_processing(void *user_data);
42 int greturn_main_value = -1;
44 extern struct frontenddata frontdata;
45 extern char scrolllabel[256];
46 pkgmgr_installer *pi = NULL;
47 extern int do_upgrade;
49 /**< Called before main loop */
50 int app_create(void *user_data)
53 struct appdata *data = (struct appdata *)user_data;
54 struct frontendcmdlinearg *pardata = frontdata.cmdlineargs;
56 if (pardata->quiteoptions == 0) {
58 ret = _frontend_launch_main_view(data);
65 /**< Called after main loop */
66 int app_terminate(void *user_data)
68 struct appdata *data = (struct appdata *)user_data;
69 struct frontendcmdlinearg *pardata = frontdata.cmdlineargs;
70 if (pardata->quiteoptions == 0) {
72 _destroy_home_view(data);
77 /**< Called when every window goes back */
78 int app_pause(void *user_data)
80 /*printf("called app_pause\n"); */
84 /**< Called when any window comes on top */
85 int app_resume(void *user_data)
87 /*printf("called app_resume\n"); */
91 /**< Called at the first idler*/
92 int app_reset(bundle *b, void *user_data)
94 /*printf("called app_reset\n"); */
98 /**< Called at rotate device*/
99 int app_rotation(enum appcore_rm mode, void *user_data)
101 struct appdata *data = (struct appdata *)user_data;
104 case APPCORE_RM_LANDSCAPE_NORMAL:
108 case APPCORE_RM_LANDSCAPE_REVERSE:
112 case APPCORE_RM_PORTRAIT_REVERSE:
116 case APPCORE_RM_UNKNOWN:
117 case APPCORE_RM_PORTRAIT_NORMAL:
122 elm_win_rotation_with_resize_set(data->win_main, angle);
126 Eina_Bool show_popup_cb(void *data)
129 const char message[256] = {'\0'};
130 strncpy(message, _("Continue Downgrade?"), 255);
131 state = _get_backend_state_info();
133 case REQUEST_ACCEPTED:
135 case GOT_PACKAGE_INFO_SUCCESSFULLY:
137 case DPKG_REQUEST_PENDING:
138 _package_downgrade_information(message);
139 _set_backend_state_info(REQUEST_ACCEPTED);
141 case DPKG_REQUEST_COMPLETED:
143 if (frontdata.cmdlineargs->quiteoptions == 0) {
144 _frontend_update_progress_info(&ad, scrolllabel);
155 static void __start_processing(void *user_data)
158 struct frontenddata *data = (struct frontenddata *)user_data;
160 ret = _cmdline_process(data);
161 greturn_main_value = ret;
162 _cmdline_destroy(data);
166 int main(int argc, char *argv[])
169 struct frontendcmdlinearg *pardata = NULL;
170 struct appcore_ops ops;
171 Ecore_Idler *popup_handle = NULL;
172 ops.create = app_create;
173 ops.terminate = app_terminate;
174 ops.pause = app_pause;
175 ops.resume = app_resume;
176 ops.reset = app_reset;
180 appcore_set_i18n(PACKAGE, LOCALE_PATH);
181 _d_msg_init("frontend");
182 d_msg_frontend(DEBUG_RESULT, "Frontend version: %s\n",
183 NATIVE_INSTALLER_VERSION);
184 pardata = (struct frontendcmdlinearg *)calloc(1,
185 sizeof(struct frontendcmdlinearg));
186 if (pardata == NULL) {
187 d_msg_frontend(DEBUG_ERR, "not enough memory\n");
188 ret = NATIVEINSTALLER_ERR_NOT_ENOUGH_MEMORY;
191 pardata->pkeyid = NULL;
192 pardata->ppkgname = NULL;
193 pardata->quiteoptions = 0;
194 pardata->reqcommand = INVALID_CMD;
196 /* We need to use pkgmgr_installer_receive request()
197 to parse the arguments */
199 _parse_cmdline(argc, argv, pardata)) != NATIVEINSTALLER_SUCCESS) {
200 d_msg_frontend(DEBUG_ERR, "_parse_cmdline failed \n");
204 frontdata.cmdlineargs = pardata;
205 frontdata.gptr_security_cookie = NULL;
206 frontdata.perror_string = NULL;
207 __start_processing(&frontdata);
209 /*The installer has finished the installation/uninstallation.
210 Now, if it was a non quite operation we need to show the popup. */
211 popup_handle = ecore_idler_add(show_popup_cb, NULL);
213 d_msg_frontend(DEBUG_RESULT, "about to run efl main loop");
214 appcore_efl_main(PACKAGE, &argc, &argv, &ops);
215 d_msg_frontend(DEBUG_RESULT, "%d\n", greturn_main_value);
219 pkgmgr_installer_free(pi);
223 return greturn_main_value;
227 if (pardata->ppkgname) {
228 free(pardata->ppkgname);
229 pardata->ppkgname = NULL;
231 if (pardata->pkeyid) {
232 free(pardata->pkeyid);
233 pardata->pkeyid = NULL;
238 d_msg_frontend(DEBUG_RESULT, "%d\n", ret);