#include <bundle.h>
#include <bundle_internal.h>
#include <aul.h>
+#include <aul_widget.h>
#include <dlog.h>
#include <glib.h>
#include <glib-object.h>
#include <widget_errno.h>
#include <widget_instance.h>
#include <aul_app_com.h>
-#include <Ecore_Wayland.h>
+#include <Ecore_Wl2.h>
#include <system_info.h>
-#include <vconf.h>
-#include <vconf-internal-keys.h>
#include <screen_connector_provider.h>
#include <appcore_multiwindow_base.h>
const char *class_id;
cxt = appcore_multiwindow_base_instance_find(data->id);
+
+ if (!cxt) {
+ LOGE("Can't find the instance");
+ return G_SOURCE_REMOVE;
+ }
+
if (appcore_multiwindow_base_instance_is_resumed(cxt)) {
LOGD("Periodic update!");
class_id = appcore_multiwindow_base_instance_get_class_id(cxt);
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();
return cls;
}
-static int __send_lifecycle_event(const char *class_id, const char *instance_id,
- int status)
-{
- bundle *b = bundle_create();
- int ret;
-
- if (b == NULL) {
- LOGE("out of memory"); /* LCOV_EXCL_LINE */
- return -1; /* LCOV_EXCL_LINE */
- }
-
- 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));
- bundle_add_str(b, AUL_K_PKGID, __package_id);
-
- LOGD("send lifecycle %s(%d)", instance_id, status);
- ret = aul_app_com_send("widget.status", b);
- if (ret < 0)
- LOGE("send lifecycle error:%d", ret); /* LCOV_EXCL_LINE */
-
- bundle_free(b);
-
- return ret;
-}
-
static int __send_update_status(const char *class_id, const char *instance_id,
- int status, bundle *extra)
+ int status, int err, bundle *extra)
{
- bundle *b;
- int lifecycle = -1;
- bundle_raw *raw = NULL;
- int len;
+ int lifecycle;
- b = bundle_create();
- if (!b) {
- LOGE("out of memory"); /* LCOV_EXCL_LINE */
- return -1; /* LCOV_EXCL_LINE */
- }
-
- 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 (extra) {
- bundle_encode(extra, &raw, &len);
- bundle_add_str(b, WIDGET_K_CONTENT_INFO, (const char *)raw);
- aul_widget_instance_add(class_id, instance_id);
- }
-
- LOGD("send update %s(%d) to %s", instance_id, status, __viewer_endpoint);
- aul_app_com_send(__viewer_endpoint, b);
-
- switch (status) {
- case WIDGET_INSTANCE_EVENT_CREATE:
- lifecycle = WIDGET_LIFE_CYCLE_EVENT_CREATE;
- break;
- case WIDGET_INSTANCE_EVENT_DESTROY:
- lifecycle = WIDGET_LIFE_CYCLE_EVENT_DESTROY;
- break;
- case WIDGET_INSTANCE_EVENT_PAUSE:
- lifecycle = WIDGET_LIFE_CYCLE_EVENT_PAUSE;
- break;
- case WIDGET_INSTANCE_EVENT_RESUME:
- lifecycle = WIDGET_LIFE_CYCLE_EVENT_RESUME;
- break;
+ aul_widget_send_status_to_viewer(class_id, instance_id,
+ __viewer_endpoint, status, err, extra);
+ lifecycle = widget_instance_convert_event_to_lifecycle_status(status);
+ if (lifecycle > -1) {
+ aul_widget_send_status_to_service(
+ class_id, instance_id, __package_id, lifecycle);
}
- if (lifecycle > -1)
- __send_lifecycle_event(class_id, instance_id, lifecycle);
-
- bundle_free(b);
- if (raw)
- free(raw);
-
return 0;
}
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) {
/* 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)
LOGD("%s is resized to %dx%d", id, w, h);
__send_update_status(class_id, id,
- WIDGET_INSTANCE_EVENT_SIZE_CHANGED, NULL);
+ WIDGET_INSTANCE_EVENT_SIZE_CHANGED, 0, NULL);
}
static void __call_update_cb(const char *class_id, const char *id, int force,
cls->ops.update(instance_h, content, force, class_data);
__send_update_status(class_id, id,
- WIDGET_INSTANCE_EVENT_UPDATE, NULL);
+ WIDGET_INSTANCE_EVENT_UPDATE, 0, NULL);
LOGD("updated:%s", id);
if (content)
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,
}
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);
{
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) {
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)
__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;
}
return WIDGET_BASE_ERROR_FAULT;
ret = __send_update_status(class_id, id,
- WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info);
+ WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, 0, content_info);
if (data->content)
free(data->content);
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 */
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);
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();
{
}
+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;
ops.finish = __on_finish;
ops.run = __on_run;
ops.exit = __on_exit;
+ ops.trim_memory = __on_trim_memory;
return ops;
}
EXPORT_API void widget_base_fini(void)
{
+ appcore_multiwindow_base_fini();
g_list_free_full(__context.classes, __free_class);
__context.classes = NULL;
-
- appcore_multiwindow_base_fini();
}
EXPORT_API int widget_base_context_window_bind(
widget_base_instance_h instance_h, const char *id,
- Ecore_Wl_Window *wl_win)
+ Ecore_Wl2_Window *wl_win)
{
struct wl_surface *surface;
- surface = ecore_wl_window_surface_get(wl_win);
+ surface = ecore_wl2_window_surface_get(wl_win);
if (surface == NULL) {
LOGE("failed to get surface"); /* LCOV_EXCL_LINE */
return WIDGET_BASE_ERROR_FAULT; /* LCOV_EXCL_LINE */
if (ret < 0) {
LOGW("Create callback returns error(%d)", ret);
ret = __send_update_status(class_id, id,
- WIDGET_INSTANCE_EVENT_CREATE_ABORTED, NULL);
+ WIDGET_INSTANCE_EVENT_CREATE_ABORTED, ret, NULL);
if (ret < 0)
LOGE("Fail to send abort status (%d) ", ret);
__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, NULL);
+ 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) {
+ if (ret == BUNDLE_ERROR_NONE && *period > 0) {
+ LOGI("set periodic update timer (%lf)", *period);
instance_data->period = *period;
instance_data->periodic_timer = g_timeout_add_seconds(
instance_data->period,
LOGD("%s is resumed", id);
__send_update_status(class_id, id,
- WIDGET_INSTANCE_EVENT_RESUME, NULL);
+ WIDGET_INSTANCE_EVENT_RESUME, 0, NULL);
if (!__fg_signal) {
LOGD("Send fg signal to resourceD");
- aul_send_app_status_change_signal(getpid(),
- __appid,
- __package_id,
- STATUS_FOREGROUND,
- APP_TYPE_WIDGET);
+ aul_widget_instance_change_status(class_id, STATUS_FOREGROUND);
__fg_signal = true;
}
}
LOGD("%s is paused", id);
__send_update_status(class_id, id,
- WIDGET_INSTANCE_EVENT_PAUSE, NULL);
+ WIDGET_INSTANCE_EVENT_PAUSE, 0, NULL);
if (__fg_signal) {
LOGD("Send bg signal to resourceD");
- aul_send_app_status_change_signal(getpid(),
- __appid,
- __package_id,
- STATUS_BACKGROUND,
- APP_TYPE_WIDGET);
+ aul_widget_instance_change_status(class_id, STATUS_BACKGROUND);
__fg_signal = false;
}
}
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;
} else {
__is_permanent = false;
__send_update_status(class_id, id,
- WIDGET_INSTANCE_EVENT_EXTRA_UPDATED,
+ WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, 0,
content_info);
}
if (data->periodic_timer)
g_source_remove(data->periodic_timer);
- __send_update_status(class_id, id, event, NULL);
+ __send_update_status(class_id, id, event, 0, NULL);
appcore_multiwindow_base_class_on_terminate(instance_h);
}
cls.ops.destroy = __class_on_destroy;
cls.ops.pause = __class_on_pause;
cls.ops.resume = __class_on_resume;
+ cls.id = NULL;
return cls;
}
}
if (!class_id) {
- LOGE("class is is NULL");
+ LOGE("class id is NULL");
set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
return NULL;
}