X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbase%2Fwidget_base.c;h=678b6f9b010255d10dbde72d205732c20ade6415;hb=126a02df3977ba2e97b4750718f3e8c7d32998c0;hp=ce0f63be161fa15b3e08591ce8b32bbe6490ec06;hpb=a448b7e66de28da8811f466f62b3651dfde4de7f;p=platform%2Fcore%2Fappfw%2Fappcore-widget.git diff --git a/src/base/widget_base.c b/src/base/widget_base.c index ce0f63b..678b6f9 100644 --- a/src/base/widget_base.c +++ b/src/base/widget_base.c @@ -31,8 +31,6 @@ #include #include #include -#include -#include #include #include @@ -154,27 +152,6 @@ static bool __is_widget_feature_enabled(void) return feature; } -/* LCOV_EXCL_START */ -static void __on_poweroff(keynode_t *key, void *data) -{ - int val; - - val = vconf_keynode_get_int(key); - switch (val) { - case VCONFKEY_SYSMAN_POWER_OFF_DIRECT: - case VCONFKEY_SYSMAN_POWER_OFF_RESTART: - LOGI("power off changed: %d", val); - widget_base_exit(); - break; - case VCONFKEY_SYSMAN_POWER_OFF_NONE: - case VCONFKEY_SYSMAN_POWER_OFF_POPUP: - default: - /* DO NOTHING */ - break; - } -} -/* LCOV_EXCL_STOP */ - static void __check_empty_instance(void) { int cnt = appcore_multiwindow_base_instance_get_cnt(); @@ -308,6 +285,11 @@ static void __control_create(const char *class_id, const char *id, bundle *b) widget_base_instance_data *data; char *content = NULL; + if (appcore_multiwindow_base_instance_find(id)) { + LOGE("Already exist id (%s)", id); + return; + } + data = (widget_base_instance_data *) calloc(1, sizeof(widget_base_instance_data)); if (!data) { @@ -320,11 +302,12 @@ static void __control_create(const char *class_id, const char *id, bundle *b) /* call stub create */ appcore_multiwindow_base_instance_run(class_id, id, data); - data->args = NULL; - bundle_get_str(b, WIDGET_K_CONTENT_INFO, &content); - if (content) - data->content = strdup(content); - + if (appcore_multiwindow_base_instance_find(id)) { + data->args = NULL; + bundle_get_str(b, WIDGET_K_CONTENT_INFO, &content); + if (content) + data->content = strdup(content); + } } static void __control_resume(const char *class_id, const char *id, bundle *b) @@ -542,6 +525,8 @@ static void __control_destroy(const char *class_id, const char *id, bundle *b) free(data->id); free(data); __check_empty_instance(); + aul_widget_write_log(LOG_TAG, + "[%s:%d] instance_id(%s)", __FUNCTION__, __LINE__, id); } static void __control_change_period(const char *class_id, const char *id, @@ -602,10 +587,6 @@ static int __multiwindow_create(void *data) } screen_connector_provider_init(); - vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, - __on_poweroff, NULL); - - if (__context.ops.create) ret = __context.ops.create(data); @@ -617,9 +598,6 @@ static int __multiwindow_terminate(void *data) { if (__context.ops.terminate) __context.ops.terminate(data); - - vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, - __on_poweroff); screen_connector_provider_fini(); if (__viewer_endpoint) { @@ -663,6 +641,7 @@ static int __multiwindow_control(bundle *b, void *data) return 0; } + LOGI("app control operation(%s)", operation); if (strcmp(operation, "create") == 0) __control_create(class_id, id, b); else if (strcmp(operation, "resize") == 0) @@ -774,11 +753,25 @@ static void __multiwindow_exit(void *data) __context.ops.exit(data); } +static void __multiwindow_trim_memory(void *data) +{ + if (__context.ops.trim_memory) + __context.ops.trim_memory(data); +} + EXPORT_API int widget_base_exit(void) { + int ret = 0; + int cnt; + appcore_multiwindow_base_exit(); - if (appcore_multiwindow_base_instance_get_cnt() != 0 && __is_permanent) - aul_notify_exit(); + cnt = appcore_multiwindow_base_instance_get_cnt(); + if (cnt == 0 && __is_permanent) + ret = aul_notify_exit(); + + aul_widget_write_log(LOG_TAG, + "[%s:%d] exit : ret(%d), cnt(%d), permanent(%d)", + __FUNCTION__, __LINE__, ret, cnt, __is_permanent); return 0; } @@ -1142,6 +1135,7 @@ EXPORT_API int widget_base_init(widget_base_ops ops, int argc, char **argv, raw_ops.base.finish = __multiwindow_finish; raw_ops.base.run = __multiwindow_run; raw_ops.base.exit = __multiwindow_exit; + raw_ops.base.trim_memory = __multiwindow_trim_memory; if (!__is_widget_feature_enabled()) { LOGE("not supported"); /* LCOV_EXCL_LINE */ @@ -1150,7 +1144,7 @@ EXPORT_API int widget_base_init(widget_base_ops ops, int argc, char **argv, kb = bundle_import_from_argv(argc, argv); if (kb) { - bundle_get_str(kb, WIDGET_K_ENDPOINT, &viewer_endpoint); + bundle_get_str(kb, AUL_K_WIDGET_VIEWER, &viewer_endpoint); if (viewer_endpoint) { LOGD("viewer endpoint :%s", viewer_endpoint); __viewer_endpoint = strdup(viewer_endpoint); @@ -1200,6 +1194,11 @@ static void __on_exit(void *data) widget_base_on_exit(); } +static void __on_trim_memory(void *data) +{ + widget_base_on_trim_memory(); +} + EXPORT_API int widget_base_on_create(void) { appcore_multiwindow_base_on_create(); @@ -1231,6 +1230,13 @@ EXPORT_API void widget_base_on_exit(void) { } +EXPORT_API int widget_base_on_trim_memory(void) +{ + appcore_multiwindow_base_on_trim_memory(); + + return 0; +} + EXPORT_API widget_base_ops widget_base_get_default_ops(void) { widget_base_ops ops; @@ -1242,6 +1248,7 @@ EXPORT_API widget_base_ops widget_base_get_default_ops(void) ops.finish = __on_finish; ops.run = __on_run; ops.exit = __on_exit; + ops.trim_memory = __on_trim_memory; return ops; } @@ -1385,13 +1392,12 @@ static void __multiwindow_instance_create( __instance_drop(instance_h); } else { LOGD("%s is created", id); + aul_widget_instance_add(class_id, id); ret = __send_update_status(class_id, id, WIDGET_INSTANCE_EVENT_CREATE, 0, NULL); if (ret < 0) LOGE("Fail to send create status (%d) ", ret); - aul_widget_instance_add(class_id, id); - ret = bundle_get_byte(b, WIDGET_K_PERIOD, (void **)&period, &size); if (ret == BUNDLE_ERROR_NONE && *period > 0) { @@ -1525,7 +1531,7 @@ static void __multiwindow_instance_terminate( if (cls->ops.destroy) cls->ops.destroy(instance_h, reason, content_info, class_data); - LOGD("%s is destroyed %d", id, reason); + LOGW("%s is destroyed %d", id, reason); if (reason == WIDGET_BASE_DESTROY_TYPE_PERMANENT) { __is_permanent = true; event = WIDGET_INSTANCE_EVENT_DESTROY; @@ -1617,7 +1623,7 @@ EXPORT_API widget_base_class *widget_base_class_add(widget_base_class cls, } if (!class_id) { - LOGE("class is is NULL"); + LOGE("class id is NULL"); set_last_result(WIDGET_ERROR_INVALID_PARAMETER); return NULL; }