+static void __stub_terminate(appcore_multiwindow_base_instance_h context, void *data)
+{
+ struct widget_class_context *class_cxt = data;
+ struct widget_extra *we;
+ bundle *b;
+ char *operation = NULL;
+ bundle *content_info;
+ widget_app_destroy_type_e reason = WIDGET_APP_DESTROY_TYPE_TEMPORARY;
+ int event = WIDGET_INSTANCE_EVENT_TERMINATE;
+ const char *id;
+ const char *class_id;
+
+ id = appcore_multiwindow_base_instance_get_id(context);
+ class_id = appcore_multiwindow_base_instance_get_class_id(context);
+ we = appcore_multiwindow_base_instance_get_extra((appcore_multiwindow_base_instance_h)context);
+ b = we->args;
+
+ if (b) {
+ bundle_get_str(b, WIDGET_K_OPERATION, &operation);
+ if (operation && strcmp(operation, "destroy") == 0)
+ reason = WIDGET_APP_DESTROY_TYPE_PERMANENT;
+ }
+
+ if (we->content)
+ content_info = bundle_decode((const bundle_raw *)we->content, strlen(we->content));
+ else
+ content_info = bundle_create();
+
+ if (class_cxt->callback.destroy)
+ class_cxt->callback.destroy(context, reason, content_info, class_cxt->data);
+ _D("%s is destroyed %d", id, reason);
+
+ if (reason == WIDGET_APP_DESTROY_TYPE_PERMANENT) {
+ event = WIDGET_INSTANCE_EVENT_DESTROY;
+ aul_widget_instance_del(class_id, id);
+ } else {
+ __send_update_status(class_id, id,
+ WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info);
+ }
+
+ if (content_info)
+ bundle_free(content_info);
+
+ __send_update_status(class_id, id, event, NULL);
+ appcore_multiwindow_base_class_on_terminate(context);
+}
+
+static void __stub_pause(appcore_multiwindow_base_instance_h context, void *data)
+{
+ struct widget_class_context *class_cxt = data;
+ const char *id;
+ const char *class_id;
+
+ appcore_multiwindow_base_class_on_pause(context);
+ id = appcore_multiwindow_base_instance_get_id(context);
+ class_id = appcore_multiwindow_base_instance_get_class_id(context);
+
+ if (!class_cxt) {
+ _E("class context is NULL");
+ return;
+ }
+
+ if (class_cxt->callback.pause)
+ class_cxt->callback.pause(context, class_cxt->data);
+ _D("%s is paused", id);
+ __send_update_status(class_id, id,
+ WIDGET_INSTANCE_EVENT_PAUSE, NULL);
+}
+
+static void __stub_resume(appcore_multiwindow_base_instance_h context, void *data)
+{
+ struct widget_class_context *class_cxt = data;
+ const char *id;
+ const char *class_id;
+
+ appcore_multiwindow_base_class_on_resume(context);
+ id = appcore_multiwindow_base_instance_get_id(context);
+ class_id = appcore_multiwindow_base_instance_get_class_id(context);
+
+ if (!class_cxt) {
+ _E("class context is NULL");
+ return;
+ }
+
+ if (class_cxt->callback.resume)
+ class_cxt->callback.resume(context, class_cxt->data);
+ _D("%s is resumed", id);
+ __send_update_status(class_id, id,
+ WIDGET_INSTANCE_EVENT_RESUME, NULL);
+}
+
+EXPORT_API widget_class_h widget_app_class_add(widget_class_h widget_class,
+ const char *class_id,