X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fwidget_app.c;h=80d9cb82b9d1ddd2981a4374db52ef9e82f462bf;hb=refs%2Ftags%2Fsubmit%2Ftizen_3.0%2F20161104.073859;hp=f90e7ec2b9e1b7fd2bc5e90a1614f17c65e4c937;hpb=150f55cbec59b7f623b8381992b8db8a1e66ce87;p=platform%2Fcore%2Fappfw%2Fappcore-widget.git diff --git a/src/widget_app.c b/src/widget_app.c index f90e7ec..80d9cb8 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "widget_app.h" #include "widget-log.h" @@ -84,6 +85,7 @@ static void *app_user_data; static char *appid; static widget_class_h class_provider; static int exit_called; +static char *package_id; static void _widget_core_set_appcore_event_cb(void); static void _widget_core_unset_appcore_event_cb(void); @@ -170,6 +172,7 @@ static int __send_lifecycle_event(const char *class_id, const char *instance_id, int status) { bundle *b = bundle_create(); + char pkgid[256] = {0, }; int ret; if (b == NULL) { @@ -177,9 +180,17 @@ static int __send_lifecycle_event(const char *class_id, const char *instance_id, return -1; /* LCOV_EXCL_LINE */ } + if (package_id == NULL) { + ret = aul_app_get_pkgid_bypid(getpid(), pkgid, sizeof(pkgid)); + if (ret == 0) + package_id = strdup(pkgid); + } + bundle_add_str(b, AUL_K_WIDGET_ID, class_id); bundle_add_str(b, AUL_K_WIDGET_INSTANCE_ID, instance_id); bundle_add_byte(b, AUL_K_WIDGET_STATUS, &status, sizeof(int)); + if (package_id) + bundle_add_str(b, AUL_K_PKGID, package_id); _D("send lifecycle %s(%d)", instance_id, status); ret = aul_app_com_send("widget.status", b); @@ -441,10 +452,10 @@ static int __instance_destroy(widget_class_h handle, const char *id, int event = WIDGET_INSTANCE_EVENT_TERMINATE; bundle *content_info; - if (!wc) { - _E("could not find widget obj: %s", id); /* LCOV_EXCL_LINE */ - return WIDGET_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_LINE */ + _E("could not find widget obj: %s, clear amd info", id); /* LCOV_EXCL_LINE */ + aul_widget_instance_del(handle->classid, id); /* LCOV_EXCL_LINE */ + return WIDGET_ERROR_NONE; /* LCOV_EXCL_LINE */ } wc->state = WC_TERMINATED; @@ -458,13 +469,12 @@ static int __instance_destroy(widget_class_h handle, const char *id, if (reason == WIDGET_APP_DESTROY_TYPE_PERMANENT) { event = WIDGET_INSTANCE_EVENT_DESTROY; + aul_widget_instance_del(handle->classid, id); } else { ret = __send_update_status(handle->classid, id, WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info); } - aul_widget_instance_del(handle->classid, id); - if (content_info) bundle_free(content_info); @@ -614,6 +624,7 @@ static void __pause_all(int send_update) __instance_pause(cxt->provider, cxt->id, send_update); break; } + LOGD("pause %s", cxt->id); iter = g_list_next(iter); } } @@ -646,16 +657,15 @@ static void __destroy_all(int reason, int send_update) GList *iter = g_list_first(contexts); __pause_all(send_update); - while (iter != NULL) { widget_context_s *cxt = (widget_context_s *)iter->data; - + iter = g_list_next(iter); switch (cxt->state) { case WC_PAUSED: + LOGD("destroy %s", cxt->state, cxt->id); __instance_destroy(cxt->provider, cxt->id, reason, send_update); break; } - iter = g_list_next(iter); } } @@ -750,6 +760,30 @@ static void __add_climsg() ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE, __configure_cb, NULL); } +static void __get_content(bundle *b) +{ + char *instance_id = NULL; + widget_context_s *cxt = NULL; + + bundle_get_str(b, AUL_K_WIDGET_INSTANCE_ID, &instance_id); + if (!instance_id) + return; + + cxt = __find_context_by_id(instance_id); + if (!cxt) { + _E("can not find instance id:%s", instance_id); + return; + } + + if (cxt->content) { + bundle_add_str(b, AUL_K_WIDGET_CONTENT_INFO, cxt->content); + _D("content info of %s found", cxt->id); + } else { + bundle_add_str(b, AUL_K_WIDGET_CONTENT_INFO, ""); + _D("empty content info added"); + } +} + static int __aul_handler(aul_type type, bundle *b, void *data) { char *caller = NULL; @@ -776,6 +810,9 @@ static int __aul_handler(aul_type type, bundle *b, void *data) case AUL_TERMINATE: widget_app_exit(); break; + case AUL_WIDGET_CONTENT: + __get_content(b); + break; default: break; } @@ -831,10 +868,8 @@ static int __before_loop(int argc, char **argv) { int r; bundle *kb = NULL; - char *wayland_display = NULL; - char *xdg_runtime_dir = NULL; char *name; - char *viewer_endpoint; + char *viewer_endpoint = NULL; #if !(GLIB_CHECK_VERSION(2, 36, 0)) g_type_init(); @@ -842,8 +877,6 @@ static int __before_loop(int argc, char **argv) kb = bundle_import_from_argv(argc, argv); if (kb) { - bundle_get_str(kb, AUL_K_WAYLAND_WORKING_DIR, &xdg_runtime_dir); - bundle_get_str(kb, AUL_K_WAYLAND_DISPLAY, &wayland_display); bundle_get_str(kb, WIDGET_K_ENDPOINT, &viewer_endpoint); if (viewer_endpoint) { _E("viewer endpoint :%s", viewer_endpoint); @@ -852,22 +885,14 @@ static int __before_loop(int argc, char **argv) _E("endpoint is missing"); } - if (xdg_runtime_dir) - setenv("XDG_RUNTIME_DIR", xdg_runtime_dir, 1); - - _D("xdg_runtime_dir:%s", xdg_runtime_dir); - - if (wayland_display) - setenv("WAYLAND_DISPLAY", wayland_display, 1); - - _D("wayland_display:%s", wayland_display); - bundle_free(kb); kb = NULL; } else { _E("failed to get launch argv"); /* LCOV_EXCL_LINE */ } + aul_rsm_provider_init(); + elm_init(argc, argv); r = aul_launch_init(__aul_handler, NULL); @@ -938,9 +963,17 @@ static void __after_loop() if (app_ops->terminate) app_ops->terminate(app_user_data); + aul_rsm_provider_fini(); + _widget_app_free_viewer_endpoint(); _widget_core_unset_appcore_event_cb(); __free_handler_list(); + + if (package_id) { + free(package_id); + package_id = NULL; + } + elm_shutdown(); } @@ -1113,7 +1146,6 @@ EXPORT_API int widget_app_main(int argc, char **argv, __FUNCTION__, "widget_app_create_cb() callback must be " "registered"); - app_ops = callback; app_user_data = user_data; r = __before_loop(argc, argv); @@ -1320,6 +1352,7 @@ EXPORT_API int widget_app_get_elm_win(widget_context_h context, widget_context_s *cxt = (widget_context_s *)context; Evas_Object *ret_win; Ecore_Wl_Window *wl_win; + struct wl_surface *surface; if (!_is_widget_feature_enabled()) { _E("not supported"); /* LCOV_EXCL_LINE */ @@ -1333,17 +1366,25 @@ EXPORT_API int widget_app_get_elm_win(widget_context_h context, ret_win = elm_win_add(NULL, cxt->id, ELM_WIN_BASIC); if (ret_win == NULL) { _E("failed to create window"); /* LCOV_EXCL_LINE */ - return WIDGET_ERROR_FAULT; /* LCOV_EXCL_LINE */ + goto fault; /* LCOV_EXCL_LINE */ } wl_win = elm_win_wl_window_get(ret_win); if (wl_win == NULL) { _E("failed to get wayland window"); /* LCOV_EXCL_LINE */ - evas_object_del(ret_win); /* LCOV_EXCL_LINE */ - return WIDGET_ERROR_FAULT; /* LCOV_EXCL_LINE */ + goto fault; } + surface = ecore_wl_window_surface_get(wl_win); + if (surface == NULL) { + _E("failed to get surface"); /* LCOV_EXCL_LINE */ + goto fault; /* LCOV_EXCL_LINE */ + } + + aul_rsm_provider_remote_enable(cxt->id, surface); + ecore_wl_window_class_name_set(wl_win, cxt->id); + elm_win_aux_hint_add(ret_win, "wm.policy.win.user.geometry", "1"); *win = ret_win; cxt->win = ret_win; @@ -1352,6 +1393,13 @@ EXPORT_API int widget_app_get_elm_win(widget_context_h context, _D("window created: %d", cxt->win_id); return WIDGET_ERROR_NONE; + +fault: + if (ret_win) /* LCOV_EXCL_LINE */ + evas_object_del(ret_win); /* LCOV_EXCL_LINE */ + + return WIDGET_ERROR_FAULT; /* LCOV_EXCL_LINE */ + } widget_class_h _widget_class_create(widget_class_s *prev, const char *class_id,