static widget_context_s *__find_context_by_id(const char *id)
{
- GList *ret = g_list_find_custom(contexts, id, __comp_by_id);
+ GList *ret;
+ if (id == NULL)
+ return NULL;
+
+ ret = g_list_find_custom(contexts, id, __comp_by_id);
if (ret == NULL)
return NULL;
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);
}
_D("send update %s(%d) to %s", instance_id, status, viewer_endpoint);
}
/* LCOV_EXCL_START */
+static int __instance_update_all(widget_class_h handle, int force, const char *content)
+{
+ widget_context_s *wc;
+ int ret = 0;
+ bundle *b = NULL;
+ GList *context = contexts;
+
+ if (content)
+ b = bundle_decode((const bundle_raw *)content, strlen(content));
+
+ if (handle->ops.update) {
+ while (context) {
+ wc = (widget_context_s *)context->data;
+ handle->ops.update(wc, b, force, handle->user_data);
+ ret = __send_update_status(handle->classid, wc->id,
+ WIDGET_INSTANCE_EVENT_UPDATE, NULL);
+ _D("updated:%s", wc->id);
+ context = context->next;
+ }
+ }
+
+ if (b)
+ bundle_free(b);
+
+ return ret;
+}
+/* LCOV_EXCL_STOP */
+
+/* LCOV_EXCL_START */
static int __instance_update(widget_class_h handle, const char *id, int force, const char *content)
{
widget_context_s *wc = __find_context_by_id(id);
contexts = g_list_append(contexts, wc);
- handle->ops.create(wc, content_info, w, h, handle->user_data);
- ret = __send_update_status(handle->classid, wc->id,
+ ret = handle->ops.create(wc, content_info, w, h, handle->user_data);
+ if (ret < 0) {
+ /* TODO send abort */
+ } else {
+ ret = __send_update_status(handle->classid, wc->id,
WIDGET_INSTANCE_EVENT_CREATE, NULL);
+ if (content == NULL)
+ content = "NULL";
+
+ aul_widget_instance_add(handle->classid, id);
+ }
+
if (content_info)
bundle_free(content_info);
WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info);
}
+ aul_widget_instance_del(handle->classid, id);
+
if (content_info)
bundle_free(content_info);
} else if (strcmp(operation, "resize") == 0) {
__resize_window(id, w, h);
} else if (strcmp(operation, "update") == 0) {
- __instance_update(handle, id, force, content);
+ if (id)
+ __instance_update(handle, id, force, content);
+ else
+ __instance_update_all(handle, force, content);
+
} else if (strcmp(operation, "destroy") == 0) {
__instance_destroy(handle, id, WIDGET_APP_DESTROY_TYPE_PERMANENT, UPDATE_ALL);
} else if (strcmp(operation, "resume") == 0) {