return strcmp(cls->id, b);
}
-static widget_base_class __get_class(const char *class_id)
+static widget_base_class *__get_class(const char *class_id)
{
widget_base_class *cls;
GList *class_node;
class_node = g_list_find_custom(__context.classes, class_id,
__comp_class);
+ if (class_node == NULL) {
+ LOGE("empty classes");
+ return NULL;
+ }
cls = (widget_base_class *)class_node->data;
- return *cls;
+ return cls;
}
static int __send_lifecycle_event(const char *class_id, const char *instance_id,
int w = 0;
int h = 0;
void *class_data;
- widget_base_class cls;
+ widget_base_class *cls;
const appcore_multiwindow_base_class *raw_cls;
instance_h = appcore_multiwindow_base_instance_find(id);
return;
cls = __get_class(class_id);
+ if (cls == NULL) {
+ LOGE("class not found: %s", class_id);
+ return;
+ }
class_data = raw_cls->data;
bundle_get_str(b, WIDGET_K_WIDTH, &w_str);
bundle_get_str(b, WIDGET_K_HEIGHT, &h_str);
if (h_str)
h = (int)g_ascii_strtoll(h_str, &remain, 10);
- if (cls.ops.resize)
- cls.ops.resize(instance_h, w, h, class_data);
+ if (cls->ops.resize)
+ cls->ops.resize(instance_h, w, h, class_data);
LOGD("%s is resized to %dx%d", id, w, h);
__send_update_status(class_id, id,
char *force_str = NULL;
int force;
bundle *b = data;
- widget_base_class cls;
+ widget_base_class *cls;
if (!b) {
LOGE("bundle is NULL");
class_data = raw_cls->data;
cls = __get_class(class_id);
+ if (cls == NULL) {
+ LOGE("class not found: %s", class_id);
+ return;
+ }
- if (!cls.ops.update) {
+ if (!cls->ops.update) {
LOGE("update callback is NULL");
return;
}
strlen(content_raw));
}
- if (cls.ops.update)
- cls.ops.update(instance_h, content, force, class_data);
+ if (cls->ops.update)
+ cls->ops.update(instance_h, content, force, class_data);
__send_update_status(class_id, id,
WIDGET_INSTANCE_EVENT_UPDATE, NULL);
int w = 0;
int h = 0;
int ret = -1;
- widget_base_class cls;
+ widget_base_class *cls;
appcore_multiwindow_base_class_on_create(instance_h);
instance_data = appcore_multiwindow_base_instance_get_extra(instance_h);
class_id = __appid;
cls = __get_class(class_id);
+ if (cls == NULL) {
+ LOGE("class not found: %s", class_id);
+ return;
+ }
+
bundle_get_str(b, AUL_K_WIDGET_INSTANCE_ID, &id);
bundle_get_str(b, WIDGET_K_OPERATION, &operation);
content_info = bundle_decode((const bundle_raw *)content,
strlen(content));
- if (cls.ops.create)
- ret = cls.ops.create(instance_h, content_info, w, h, class_data);
+ if (cls->ops.create)
+ ret = cls->ops.create(instance_h, content_info, w, h, class_data);
if (ret < 0) {
LOGW("Create callback returns error(%d)", ret);
{
const char *id;
const char *class_id;
- widget_base_class cls;
+ widget_base_class *cls;
appcore_multiwindow_base_class_on_resume(instance_h);
id = appcore_multiwindow_base_instance_get_id(instance_h);
class_id = appcore_multiwindow_base_instance_get_class_id(instance_h);
cls = __get_class(class_id);
+ if (cls == NULL) {
+ LOGE("class not found: %s", class_id);
+ return;
+ }
- if (cls.ops.resume)
- cls.ops.resume(instance_h, class_data);
+ if (cls->ops.resume)
+ cls->ops.resume(instance_h, class_data);
LOGD("%s is resumed", id);
__send_update_status(class_id, id,
{
const char *id;
const char *class_id;
- widget_base_class cls;
+ widget_base_class *cls;
appcore_multiwindow_base_class_on_pause(instance_h);
id = appcore_multiwindow_base_instance_get_id(instance_h);
class_id = appcore_multiwindow_base_instance_get_class_id(instance_h);
cls = __get_class(class_id);
+ if (cls == NULL) {
+ LOGE("class not found: %s", class_id);
+ return;
+ }
- if (cls.ops.pause)
- cls.ops.pause(instance_h, class_data);
+ if (cls->ops.pause)
+ cls->ops.pause(instance_h, class_data);
LOGD("%s is paused", id);
__send_update_status(class_id, id,
int event = WIDGET_INSTANCE_EVENT_TERMINATE;
const char *id;
const char *class_id;
- widget_base_class cls;
+ widget_base_class *cls;
id = appcore_multiwindow_base_instance_get_id(instance_h);
class_id = appcore_multiwindow_base_instance_get_class_id(instance_h);
(appcore_multiwindow_base_instance_h)instance_h);
b = data->args;
cls = __get_class(class_id);
+ if (cls == NULL) {
+ LOGE("class not found: %s", class_id);
+ return;
+ }
if (b) {
bundle_get_str(b, WIDGET_K_OPERATION, &operation);
else
content_info = bundle_create();
- if (cls.ops.destroy)
- cls.ops.destroy(instance_h, reason, content_info, class_data);
+ if (cls->ops.destroy)
+ cls->ops.destroy(instance_h, reason, content_info, class_data);
LOGD("%s is destroyed %d", id, reason);
if (reason == WIDGET_BASE_DESTROY_TYPE_PERMANENT) {