+ char *classId = NULL;
+ char *id = NULL;
+ char *operation = NULL;
+
+ appcore_multiwindow_base_on_control(bundleData);
+
+ bundle_get_str(bundleData, AUL_K_WIDGET_ID, &classId);
+ bundle_get_str(bundleData, AUL_K_WIDGET_INSTANCE_ID, &id);
+ bundle_get_str(bundleData, "__WIDGET_OP__", &operation);
+
+ if(!operation)
+ {
+ DALI_LOG_ERROR("operation is NULL");
+ return 0;
+ }
+
+ if(strcmp(operation, "create") == 0)
+ {
+ InstanceCreate( classId, id, bundleData );
+ }
+ else if (strcmp(operation, "resize") == 0)
+ {
+ InstanceResize( classId, id, bundleData );
+ }
+ else if (strcmp(operation, "update") == 0)
+ {
+ InstanceUpdate( classId, id, bundleData );
+ }
+ else if (strcmp(operation, "destroy") == 0)
+ {
+ InstanceDestroy( classId, id, bundleData, data );
+ }
+ else if (strcmp(operation, "resume") == 0)
+ {
+ InstanceResume( classId, id, bundleData );
+ }
+ else if (strcmp(operation, "pause") == 0)
+ {
+ InstancePause( classId, id, bundleData );
+ }
+ else if (strcmp(operation, "terminate") == 0)
+ {
+ InstanceDestroy( classId, id, bundleData, data );
+ }
+
+ return 0;
+ }
+
+ static void InstanceCreate(const char* classId, const char* id, bundle* bundleData)
+ {
+ appcore_multiwindow_base_instance_run(classId, id, bundle_dup(bundleData));
+ }
+
+ static void InstanceResize(const char *classId, const char *id, bundle *bundleData)
+ {
+ appcore_multiwindow_base_instance_h context;
+ Internal::Adaptor::Widget *widgetInstance;
+ const appcore_multiwindow_base_class *cls;
+ char *remain = NULL;
+ char *widthStr = NULL;
+ char *heightStr = NULL;
+ uint32_t width = 0;
+ uint32_t height = 0;
+
+ context = appcore_multiwindow_base_instance_find(id);
+
+ if(!context)
+ {
+ DALI_LOG_ERROR("context not found: %s", id);
+ return;
+ }
+
+ cls = appcore_multiwindow_base_instance_get_class(context);
+ if(!cls)
+ {
+ DALI_LOG_ERROR("widget class is NULL");
+ return;
+ }
+
+ widgetInstance = static_cast<Internal::Adaptor::Widget*>(cls->data);
+ if(!widgetInstance)
+ {
+ DALI_LOG_ERROR("widget instance is NULL");
+ return;
+ }
+
+ bundle_get_str(bundleData, "__WIDGET_WIDTH__", &widthStr);
+ bundle_get_str(bundleData, "__WIDGET_HEIGHT__", &heightStr);
+
+ if(widthStr)
+ width = static_cast<uint32_t>(g_ascii_strtoll(widthStr, &remain, 10));
+
+ if(heightStr)
+ height = static_cast<uint32_t>(g_ascii_strtoll(heightStr, &remain, 10));
+
+ widgetInstance->OnResize( context, Dali::Widget::WindowSize(width,height) );
+ }
+
+ static void InstanceUpdate(const char* classId, const char* id, bundle* bundleData)
+ {
+ appcore_multiwindow_base_instance_h context;
+
+ if(!id)
+ {
+ appcore_multiwindow_base_instance_foreach(classId, UpdateCallback, bundleData);
+ return;
+ }
+
+ context = appcore_multiwindow_base_instance_find(id);
+
+ if(!context)
+ {
+ DALI_LOG_ERROR("context not found: %s", id);
+ return;
+ }
+
+ UpdateCallback(classId, id, context, bundleData);
+ }
+
+ static void UpdateCallback(const char* classId, const char* id, appcore_multiwindow_base_instance_h context, void* data)
+ {
+ Internal::Adaptor::Widget *widgetInstance;
+ const appcore_multiwindow_base_class *cls;
+ bundle* content = NULL;
+ char* contentRaw = NULL;
+ char* forceStr = NULL;
+ int force;
+ bundle* bundleData = static_cast<bundle*>(data);
+
+ if(!bundleData)
+ {
+ DALI_LOG_ERROR("bundle is NULL");
+ return;
+ }
+
+ cls = appcore_multiwindow_base_instance_get_class(context);
+ if(!cls)
+ {
+ DALI_LOG_ERROR("class is NULL");
+ return;
+ }
+
+ widgetInstance = static_cast<Internal::Adaptor::Widget*>(cls->data);
+ if(!widgetInstance)
+ {
+ DALI_LOG_ERROR("widget instance is NULL");
+ return;
+ }
+
+ bundle_get_str(bundleData, "__WIDGET_FORCE__", &forceStr);
+
+ if(forceStr && strcmp(forceStr, "true") == 0)
+ {
+ force = 1;
+ }
+ else
+ {
+ force = 0;
+ }
+
+ bundle_get_str(bundleData, "__WIDGET_CONTENT_INFO__", &contentRaw);
+
+ if(contentRaw)
+ {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+ content = bundle_decode((const bundle_raw *)contentRaw, strlen(contentRaw));
+#pragma GCC diagnostic pop
+
+ }
+
+ widgetInstance->OnUpdate(context, content, force);
+
+ if(content)
+ {
+ bundle_free(content);
+ }
+ }
+
+ static void InstanceDestroy(const char* classId, const char* id, bundle* bundleData, void* data)
+ {
+ appcore_multiwindow_base_instance_h context;
+
+ Internal::Adaptor::Widget *widgetInstance;
+ const appcore_multiwindow_base_class *cls;
+
+ context = appcore_multiwindow_base_instance_find(id);
+
+ if(!context)
+ {
+ DALI_LOG_ERROR("could not find widget obj: %s, clear amd info", id);
+ aul_widget_instance_del(classId, id);
+ return;
+ }
+
+ cls = appcore_multiwindow_base_instance_get_class(context);
+ if(!cls)
+ {
+ DALI_LOG_ERROR("widget class is NULL");
+ return;
+ }
+
+ widgetInstance = static_cast<Internal::Adaptor::Widget*>(cls->data);
+ if(!widgetInstance)
+ {
+ DALI_LOG_ERROR("widget instance is NULL");
+ return;
+ }
+
+ Dali::WidgetData *widgetData = widgetInstance->FindWidgetData(id);
+
+ widgetData->SetArgs( bundleData );
+ appcore_multiwindow_base_instance_exit(context);
+ CheckEmptyInstance(data);
+ }
+
+ static void CheckEmptyInstance(void* data)
+ {
+ int cnt = appcore_multiwindow_base_instance_get_cnt();
+
+ if(cnt == 0)
+ {
+ static_cast<Internal::Adaptor::Framework::Impl*>(data)->AppWidgetExit();
+ }
+ }
+
+ static void InstanceResume(const char* classId, const char* id, bundle* bundleData)
+ {
+ appcore_multiwindow_base_instance_h context;
+
+ context = appcore_multiwindow_base_instance_find(id);
+
+ if(!context)
+ {
+ DALI_LOG_ERROR("context not found: %s", id);
+ return;
+ }
+
+ appcore_multiwindow_base_instance_resume(context);
+
+ SendUpdateStatus(classId, id, AUL_WIDGET_INSTANCE_EVENT_RESUME, NULL);
+ if(!gForegroundState)
+ {
+ aul_send_app_status_change_signal(getpid(), gAppId, gPackageId, "fg", "widgetapp" );
+ gForegroundState = true;
+ }
+ }
+
+ static void InstancePause(const char* classId, const char* id, bundle* bundleData)
+ {
+ appcore_multiwindow_base_instance_h context;
+
+ context = appcore_multiwindow_base_instance_find(id);
+
+ if(!context)