+bool IsWidgetFeatureEnabled()
+{
+ static bool feature = false;
+ static bool retrieved = false;
+ int ret;
+
+ if(retrieved == true)
+ {
+ return feature;
+ }
+
+ ret = system_info_get_platform_bool("http://tizen.org/feature/shell.appwidget", &feature);
+ if(ret != SYSTEM_INFO_ERROR_NONE)
+ {
+ DALI_LOG_ERROR("failed to get system info");
+ return false;
+ }
+
+ retrieved = true;
+ return feature;
+}
+
+} // anonymous namespace
+
+namespace AppCore
+{
+
+typedef enum
+{
+ LOW_MEMORY, //< The low memory event
+ LOW_BATTERY, //< The low battery event
+ LANGUAGE_CHANGED, //< The system language changed event
+ DEVICE_ORIENTATION_CHANGED, //< The device orientation changed event
+ REGION_FORMAT_CHANGED, //< The region format changed event
+ SUSPENDED_STATE_CHANGED, //< The suspended state changed event of the application
+ UPDATE_REQUESTED, //< The update requested event. This event can occur when an app needs to be updated. It is dependent on target devices.
+} AppEventType;
+
+static int AppEventConverter[APPCORE_BASE_EVENT_MAX] =
+{
+ [LOW_MEMORY] = APPCORE_BASE_EVENT_LOW_MEMORY,
+ [LOW_BATTERY] = APPCORE_BASE_EVENT_LOW_BATTERY,
+ [LANGUAGE_CHANGED] = APPCORE_BASE_EVENT_LANG_CHANGE,
+ [DEVICE_ORIENTATION_CHANGED] = APPCORE_BASE_EVENT_DEVICE_ORIENTATION_CHANGED,
+ [REGION_FORMAT_CHANGED] = APPCORE_BASE_EVENT_REGION_CHANGE,
+ [SUSPENDED_STATE_CHANGED] = APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE,
+};
+
+struct AppEventInfo
+{
+ AppEventType type;
+ void *value;
+};
+
+typedef struct AppEventInfo *AppEventInfoPtr;
+
+typedef void (*AppEventCallback)(AppEventInfoPtr eventInfo, void *userData);
+
+struct AppEventHandler
+{
+ AppEventType type;
+ AppEventCallback cb;
+ void *data;
+ void *raw;
+};
+
+typedef struct AppEventHandler *AppEventHandlerPtr;
+
+int EventCallback(void *event, void *data)
+{
+ AppEventHandlerPtr handler = static_cast<AppEventHandlerPtr>(data);
+
+ struct AppEventInfo appEvent;
+
+ appEvent.type = handler->type;
+ appEvent.value = event;
+
+ if (handler->cb)
+ handler->cb(&appEvent, handler->data);
+
+ return 0;
+}
+
+int AppAddEventHandler(AppEventHandlerPtr *eventHandler, AppEventType eventType, AppEventCallback callback, void *userData)
+{
+ AppEventHandlerPtr handler;
+
+ handler = static_cast<AppEventHandlerPtr>( calloc(1, sizeof(struct AppEventHandler)) );
+ if (!handler)
+ {
+ DALI_LOG_ERROR( "failed to create handler" );
+ return TIZEN_ERROR_UNKNOWN;
+ }
+ else
+ {
+ handler->type = eventType;
+ handler->cb = callback;
+ handler->data = userData;
+ handler->raw = appcore_base_add_event( static_cast<appcore_base_event>(AppEventConverter[static_cast<int>(eventType)]), EventCallback, handler);
+
+ *eventHandler = handler;
+
+ return TIZEN_ERROR_NONE;
+ }
+}
+
+} // namespace Appcore
+