double period;
guint periodic_timer;
bool pending_update;
+ char *pending_content;
void *user_data;
} widget_base_instance_data;
data = appcore_multiwindow_base_instance_get_extra(instance_h);
appcore_multiwindow_base_instance_drop(instance_h);
+ free(data->pending_content);
free(data->content);
free(data->id);
free(data);
}
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;
+ char err_str[256];
b = bundle_create();
if (!b) {
return -1; /* LCOV_EXCL_LINE */
}
+ if (err < 0) {
+ snprintf(err_str, sizeof(err_str), "%d", err);
+ bundle_add_str(b, AUL_K_WIDGET_ERROR_CODE, err_str);
+ }
+
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));
{
widget_base_instance_data *data;
char *content = NULL;
- double *period = NULL;
- size_t size;
- int ret;
data = (widget_base_instance_data *)
calloc(1, sizeof(widget_base_instance_data));
data->id = strdup(id);
data->args = b;
- ret = bundle_get_byte(b, WIDGET_K_PERIOD, (void **)&period, &size);
- if (ret == BUNDLE_ERROR_NONE) {
- data->period = *period;
- data->periodic_timer = g_timeout_add_seconds(data->period,
- __timeout_cb, data);
- }
/* call stub create */
appcore_multiwindow_base_instance_run(class_id, id, data);
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)
bundle_free(content);
}
+static void __update_pending_content(
+ appcore_multiwindow_base_instance_h instance_h,
+ const char *content_raw)
+{
+ widget_base_instance_data *data;
+
+ data = (widget_base_instance_data *)
+ appcore_multiwindow_base_instance_get_extra(instance_h);
+
+ if (data->pending_content) {
+ free(data->pending_content);
+ data->pending_content = NULL;
+ }
+
+ if (content_raw) {
+ data->pending_content = strdup(content_raw);
+ if (data->pending_content == NULL)
+ LOGW("Out of memory");
+ }
+
+ data->pending_update = true;
+}
+
static void __update_process(const char *class_id, const char *id,
appcore_multiwindow_base_instance_h instance_h, void *data)
{
force = 0;
bundle_get_str(b, WIDGET_K_CONTENT_INFO, &content_raw);
- __call_update_cb(class_id, id, force, content_raw);
+ if (!appcore_multiwindow_base_instance_is_resumed(instance_h) && !force)
+ __update_pending_content(instance_h, content_raw);
+ else
+ __call_update_cb(class_id, id, force, content_raw);
}
static void __control_update(const char *class_id, const char *id, bundle *b)
/* call stub terminate */
appcore_multiwindow_base_instance_exit(instance_h);
+ free(data->pending_content);
free(data->content);
free(data->id);
free(data);
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);
int h = 0;
int ret = -1;
widget_base_class *cls;
+ double *period = NULL;
+ size_t size;
appcore_multiwindow_base_class_on_create(instance_h);
instance_data = appcore_multiwindow_base_instance_get_extra(instance_h);
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);
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) {
+ instance_data->period = *period;
+ instance_data->periodic_timer = g_timeout_add_seconds(
+ instance_data->period,
+ __timeout_cb, instance_data);
+ }
}
if (content_info)
if (data->pending_update) {
LOGD("pending update!");
data->pending_update = false;
- __control_update(class_id, data->id, data->args);
+ __call_update_cb(class_id, data->id, 0, data->pending_content);
if (data->period > 0) {
LOGD("Restart timer!");
data->periodic_timer = g_timeout_add_seconds(
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");
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");
} 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);
}