#define DALI_INTEGRATION_ANDROID_FRAMEWORK_IMPL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/integration-api/adaptor-framework/android/android-framework.h>
// INTERNAL INCLUDES
-#include <dali/internal/adaptor/common/framework.h>
+#include <dali/internal/adaptor/android/framework-android.h>
namespace Dali
{
/**
* @brief Sets an internal framework.
*/
- void SetFramework(Framework* framework)
+ void SetFramework(FrameworkAndroidInterface* framework)
{
mFramework = framework;
}
*
* @return a pointer to the internal framework
*/
- Framework* GetFramework()
+ FrameworkAndroidInterface* GetFramework()
{
return mFramework;
}
private:
AndroidFramework(Dali::Integration::AndroidFramework* androidFramework);
Dali::Integration::AndroidFramework* mAndroidFramework;
- Framework* mFramework;
+ FrameworkAndroidInterface* mFramework;
android_app* mNativeApplication;
ANativeWindow* mWindow;
{
return *androidFramework.mImpl;
}
- static Framework& GetFramework(Dali::Integration::AndroidFramework& androidFramework)
+ static FrameworkAndroidInterface& GetFramework(Dali::Integration::AndroidFramework& androidFramework)
{
return *androidFramework.mImpl->mFramework;
}
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_ANDROID_FRAMEWORK_INTERFACE_H
+#define DALI_INTERNAL_ADAPTOR_ANDROID_FRAMEWORK_INTERFACE_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * FrameworkAndroid interface class
+ */
+class FrameworkAndroidInterface
+{
+public:
+ /**
+ * Called by the App framework when an application lifecycle event occurs.
+ * @param[in] type The type of event occurred.
+ * @param[in] data The data of event occurred.
+ */
+ virtual bool AppStatusHandler(int type, void* data) = 0;
+
+ /**
+ * Called by the adaptor when an idle callback is added.
+ * @param[in] timeout The timeout of the callback.
+ * @param[in] data The data of of the callback.
+ * @param[in] callback The callback.
+ * @return The callback id.
+ */
+ virtual unsigned int AddIdle(int timeout, void* data, bool (*callback)(void* data)) = 0;
+
+ /**
+ * Called by the adaptor when an idle callback is removed.
+ * @param[in] id The callback id.
+ */
+ virtual void RemoveIdle(unsigned int id) = 0;
+
+protected:
+ /**
+ * Destructor
+ */
+ virtual ~FrameworkAndroidInterface() = default;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_ANDROID_FRAMEWORK_INTERFACE_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
// CLASS HEADER
-#include <dali/internal/adaptor/common/framework.h>
+#include <dali/internal/adaptor/android/framework-android.h>
// EXTERNAL INCLUDES
#include <android_native_app_glue.h>
// INTERNAL INCLUDES
#include <dali/internal/adaptor/android/android-framework-impl.h>
-#include <dali/internal/system/common/callback-manager.h>
namespace Dali
{
/**
* Impl to hide android data members
*/
-struct Framework::Impl
+struct FrameworkAndroid::Impl
{
struct IdleCallback
{
// Constructor
- Impl(Framework* framework)
- : mAbortCallBack(nullptr),
- mCallbackManager(CallbackManager::New()),
- mLanguage("NOT_SUPPORTED"),
- mRegion("NOT_SUPPORTED"),
- mFinishRequested(false),
+ Impl(FrameworkAndroid* framework)
+ : mFinishRequested(false),
mIdleId(0),
mIdleReadPipe(-1),
mIdleWritePipe(-1)
~Impl()
{
AndroidFramework::GetImplementation(AndroidFramework::Get()).SetFramework(nullptr);
-
- delete mAbortCallBack;
- mAbortCallBack = nullptr;
-
- // we're quiting the main loop so
- // mCallbackManager->RemoveAllCallBacks() does not need to be called
- // to delete our abort handler
- delete mCallbackManager;
- mCallbackManager = nullptr;
- }
-
- std::string GetLanguage() const
- {
- return mLanguage;
- }
-
- std::string GetRegion() const
- {
- return mRegion;
}
void OnIdle()
}
// Data
- CallbackBase* mAbortCallBack;
- CallbackManager* mCallbackManager;
- std::string mLanguage;
- std::string mRegion;
- bool mFinishRequested;
+ bool mFinishRequested;
int mIdleReadPipe;
int mIdleWritePipe;
/**
* Called by the native activity loop when the application APP_CMD_INIT_WINDOW event is processed.
*/
- static void NativeWindowCreated(Framework* framework, ANativeWindow* window)
+ static void NativeWindowCreated(FrameworkAndroid* framework, ANativeWindow* window)
{
if(framework)
{
/**
* Called by the native activity loop when the application APP_CMD_DESTROY event is processed.
*/
- static void NativeWindowDestroyed(Framework* framework, ANativeWindow* window)
+ static void NativeWindowDestroyed(FrameworkAndroid* framework, ANativeWindow* window)
{
if(framework)
{
/**
* Called by the native activity loop when the application APP_CMD_INIT_WINDOW event is processed.
*/
- static void NativeAppPaused(Framework* framework)
+ static void NativeAppPaused(FrameworkAndroid* framework)
{
if(framework)
{
/**
* Called by the native activity loop when the application APP_CMD_TERM_WINDOW event is processed.
*/
- static void NativeAppResumed(Framework* framework)
+ static void NativeAppResumed(FrameworkAndroid* framework)
{
if(framework)
{
/**
* Called by the native activity loop when the application input touch event is processed.
*/
- static void NativeAppTouchEvent(Framework* framework, Dali::TouchPoint& touchPoint, int64_t timeStamp)
+ static void NativeAppTouchEvent(FrameworkAndroid* framework, Dali::TouchPoint& touchPoint, int64_t timeStamp)
{
Dali::Adaptor::Get().FeedTouchPoint(touchPoint, timeStamp);
}
/**
* Called by the native activity loop when the application input key event is processed.
*/
- static void NativeAppKeyEvent(Framework* framework, Dali::KeyEvent& keyEvent)
+ static void NativeAppKeyEvent(FrameworkAndroid* framework, Dali::KeyEvent& keyEvent)
{
Dali::Adaptor::Get().FeedKeyEvent(keyEvent);
}
/**
* Called by the native activity loop when the application APP_CMD_DESTROY event is processed.
*/
- static void NativeAppDestroyed(Framework* framework)
+ static void NativeAppDestroyed(FrameworkAndroid* framework)
{
if(framework)
{
static void HandleAppCmd(struct android_app* app, int32_t cmd)
{
- Framework* framework = AndroidFramework::GetImplementation(AndroidFramework::Get()).GetFramework();
+ FrameworkAndroid* framework = static_cast<FrameworkAndroid*>(AndroidFramework::GetImplementation(AndroidFramework::Get()).GetFramework());
switch(cmd)
{
case APP_CMD_SAVE_STATE:
case APP_CMD_INIT_WINDOW:
// The window is being shown, get it ready.
AndroidFramework::Get().SetApplicationWindow(app->window);
- Dali::Internal::Adaptor::Framework::Impl::NativeWindowCreated(framework, app->window);
- Dali::Internal::Adaptor::Framework::Impl::NativeAppResumed(framework);
+ Dali::Internal::Adaptor::FrameworkAndroid::Impl::NativeWindowCreated(framework, app->window);
+ Dali::Internal::Adaptor::FrameworkAndroid::Impl::NativeAppResumed(framework);
break;
case APP_CMD_TERM_WINDOW:
// The window is being hidden or closed, clean it up.
AndroidFramework::Get().SetApplicationWindow(nullptr);
- Dali::Internal::Adaptor::Framework::Impl::NativeAppPaused(framework);
- Dali::Internal::Adaptor::Framework::Impl::NativeWindowDestroyed(framework, app->window);
+ Dali::Internal::Adaptor::FrameworkAndroid::Impl::NativeAppPaused(framework);
+ Dali::Internal::Adaptor::FrameworkAndroid::Impl::NativeWindowDestroyed(framework, app->window);
break;
case APP_CMD_GAINED_FOCUS:
break;
case APP_CMD_LOST_FOCUS:
break;
case APP_CMD_DESTROY:
- Dali::Internal::Adaptor::Framework::Impl::NativeAppPaused(framework);
- Dali::Internal::Adaptor::Framework::Impl::NativeAppDestroyed(framework);
+ Dali::Internal::Adaptor::FrameworkAndroid::Impl::NativeAppPaused(framework);
+ Dali::Internal::Adaptor::FrameworkAndroid::Impl::NativeAppDestroyed(framework);
break;
}
}
static int32_t HandleAppInput(struct android_app* app, AInputEvent* event)
{
- Framework* framework = AndroidFramework::GetImplementation(AndroidFramework::Get()).GetFramework();
+ FrameworkAndroid* framework = static_cast<FrameworkAndroid*>(AndroidFramework::GetImplementation(AndroidFramework::Get()).GetFramework());
if(AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION)
{
}
Dali::TouchPoint point(deviceId, state, x, y);
- Dali::Internal::Adaptor::Framework::Impl::NativeAppTouchEvent(framework, point, timeStamp);
+ Dali::Internal::Adaptor::FrameworkAndroid::Impl::NativeAppTouchEvent(framework, point, timeStamp);
return 1;
}
else if(AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY)
break;
}
Dali::KeyEvent keyEvent = Dali::DevelKeyEvent::New(keyName, "", "", keyCode, 0, timeStamp, state, "", "", Device::Class::NONE, Device::Subclass::NONE);
- Dali::Internal::Adaptor::Framework::Impl::NativeAppKeyEvent(framework, keyEvent);
+ Dali::Internal::Adaptor::FrameworkAndroid::Impl::NativeAppKeyEvent(framework, keyEvent);
return 1;
}
static void HandleAppIdle(struct android_app* app, struct android_poll_source* source)
{
- Framework* framework = AndroidFramework::GetImplementation(AndroidFramework::Get()).GetFramework();
+ FrameworkAndroid* framework = static_cast<FrameworkAndroid*>(AndroidFramework::GetImplementation(AndroidFramework::Get()).GetFramework());
if(framework && framework->mImpl)
{
framework->mImpl->OnIdle();
}
};
-Framework::Framework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
-: mObserver(observer),
- mTaskObserver(taskObserver),
+FrameworkAndroid::FrameworkAndroid(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
+: Framework(observer, taskObserver, argc, argv, type, useUiThread),
mInitialised(false),
- mPaused(false),
- mRunning(false),
- mArgc(argc),
- mArgv(argv),
- mBundleName(""),
- mBundleId(""),
- mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
mImpl(NULL)
{
mImpl = new Impl(this);
}
-Framework::~Framework()
+FrameworkAndroid::~FrameworkAndroid()
{
if(mRunning)
{
mImpl = nullptr;
}
-void Framework::Run()
+void FrameworkAndroid::Run()
{
struct android_app* app = AndroidFramework::Get().GetNativeApplication();
- app->onAppCmd = Framework::Impl::HandleAppCmd;
- app->onInputEvent = Framework::Impl::HandleAppInput;
+ app->onAppCmd = FrameworkAndroid::Impl::HandleAppCmd;
+ app->onInputEvent = FrameworkAndroid::Impl::HandleAppInput;
struct android_poll_source* source;
struct android_poll_source idlePollSource;
mRunning = false;
}
-unsigned int Framework::AddIdle(int timeout, void* data, bool (*callback)(void* data))
+unsigned int FrameworkAndroid::AddIdle(int timeout, void* data, bool (*callback)(void* data))
{
if(mImpl)
{
return 0;
}
-void Framework::RemoveIdle(unsigned int id)
+
+void FrameworkAndroid::RemoveIdle(unsigned int id)
{
if(mImpl)
{
}
}
-void Framework::Quit()
+void FrameworkAndroid::Quit()
{
struct android_app* app = AndroidFramework::Get().GetNativeApplication();
if(app && !app->destroyRequested && !mImpl->mFinishRequested)
}
}
-bool Framework::IsMainLoopRunning()
-{
- return mRunning;
-}
-
-void Framework::AddAbortCallback(CallbackBase* callback)
-{
- mImpl->mAbortCallBack = callback;
-}
-
-std::string Framework::GetBundleName() const
-{
- return mBundleName;
-}
-
-void Framework::SetBundleName(const std::string& name)
-{
- mBundleName = name;
-}
-
-std::string Framework::GetBundleId() const
-{
- return mBundleId;
-}
-
-std::string Framework::GetResourcePath()
-{
- return DALI_DATA_RO_DIR;
-}
-
-std::string Framework::GetDataPath()
-{
- return "";
-}
-
-void Framework::SetBundleId(const std::string& id)
-{
- mBundleId = id;
-}
-
-void Framework::AbortCallback()
-{
- // if an abort call back has been installed run it.
- if(mImpl->mAbortCallBack)
- {
- CallbackBase::Execute(*mImpl->mAbortCallBack);
- }
- else
- {
- Quit();
- }
-}
-
-bool Framework::AppStatusHandler(int type, void* data)
+bool FrameworkAndroid::AppStatusHandler(int type, void* data)
{
Dali::Adaptor* adaptor = nullptr;
switch(type)
return true;
}
-void Framework::InitThreads()
-{
-}
-
-std::string Framework::GetLanguage() const
-{
- return mImpl->GetLanguage();
-}
-
-std::string Framework::GetRegion() const
-{
- return mImpl->GetRegion();
-}
-
} // namespace Adaptor
} // namespace Internal
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_ANDROID_FRAMEWORK_H
+#define DALI_INTERNAL_ADAPTOR_ANDROID_FRAMEWORK_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/android/framework-android-interface.h>
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * FrameworkAndroid class provides an Framework Android implementation.
+ */
+class FrameworkAndroid : public Framework, public FrameworkAndroidInterface
+{
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework()
+ */
+ FrameworkAndroid(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
+
+ /**
+ * Destructor
+ */
+ ~FrameworkAndroid();
+
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Run()
+ */
+ void Run() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Quit()
+ */
+ void Quit() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::FrameworkAndroidInterface::AppStatusHandler()
+ */
+ bool AppStatusHandler(int type, void* data) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::FrameworkAndroidInterface::AddIdle()
+ */
+ unsigned int AddIdle(int timeout, void* data, bool (*callback)(void* data)) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::FrameworkAndroidInterface::RemoveIdle()
+ */
+ void RemoveIdle(unsigned int id) override;
+
+private:
+ // Undefined
+ FrameworkAndroid(const FrameworkAndroid&);
+ FrameworkAndroid& operator=(FrameworkAndroid&);
+
+private:
+ bool mInitialised;
+
+private: // impl members
+ struct Impl;
+ Impl* mImpl;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_ANDROID_FRAMEWORK_H
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/android/framework-factory-android.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/adaptor/android/framework-android.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Framework> FrameworkFactoryAndroid::CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread)
+{
+ return Utils::MakeUnique<FrameworkAndroid>(observer, taskObserver, argc, argv, type, useUiThread);
+}
+
+std::unique_ptr<FrameworkFactory> GetFrameworkFactory()
+{
+ return Utils::MakeUnique<FrameworkFactoryAndroid>();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_ANDROID_FRAMEWORK_FACTORY_H
+#define DALI_INTERNAL_ADAPTOR_ANDROID_FRAMEWORK_FACTORY_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/adaptor/common/framework-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class FrameworkFactoryAndroid : public FrameworkFactory
+{
+public:
+ std::unique_ptr<Framework> CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_ANDROID_FRAMEWORK_FACTORY_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
// CLASS HEADER
-#include <dali/internal/adaptor/common/framework.h>
+#include <dali/internal/adaptor/androidjni/framework-androidjni.h>
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/application-devel.h>
// INTERNAL INCLUDES
#include <dali/internal/adaptor/android/android-framework-impl.h>
#include <dali/internal/adaptor/common/application-impl.h>
-#include <dali/internal/system/common/callback-manager.h>
using namespace Dali;
/**
* Impl to hide android data members
*/
-struct Framework::Impl
+struct FrameworkAndroidJni::Impl
{
// Constructor
- Impl(Framework* framework)
- : mAbortCallBack(nullptr),
- mCallbackManager(CallbackManager::New()),
- mLanguage("NOT_SUPPORTED"),
- mRegion("NOT_SUPPORTED")
+ Impl(FrameworkAndroidJni* framework)
{
AndroidFramework::GetImplementation(AndroidFramework::Get()).SetFramework(framework);
}
~Impl()
{
AndroidFramework::GetImplementation(AndroidFramework::Get()).SetFramework(nullptr);
-
- delete mAbortCallBack;
- mAbortCallBack = nullptr;
-
- // we're quiting the main loop so
- // mCallbackManager->RemoveAllCallBacks() does not need to be called
- // to delete our abort handler
- delete mCallbackManager;
- mCallbackManager = nullptr;
}
-
- std::string GetLanguage() const
- {
- return mLanguage;
- }
-
- std::string GetRegion() const
- {
- return mRegion;
- }
-
- CallbackBase* mAbortCallBack;
- CallbackManager* mCallbackManager;
- std::string mLanguage;
- std::string mRegion;
};
-Framework::Framework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
-: mObserver(observer),
- mTaskObserver(taskObserver),
+FrameworkAndroidJni::FrameworkAndroidJni(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
+: Framework(observer, taskObserver, argc, argv, type, useUiThread),
mInitialised(false),
- mPaused(false),
- mRunning(false),
- mArgc(argc),
- mArgv(argv),
- mBundleName(""),
- mBundleId(""),
- mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
mImpl(NULL)
{
mImpl = new Impl(this);
}
-Framework::~Framework()
+FrameworkAndroidJni::~FrameworkAndroidJni()
{
if(mRunning)
{
mImpl = nullptr;
}
-void Framework::Run()
+void FrameworkAndroidJni::Run()
{
AndroidFramework::GetImplementation(AndroidFramework::Get()).SetFramework(this);
mRunning = true;
}
-unsigned int Framework::AddIdle(int timeout, void* data, bool (*callback)(void* data))
+unsigned int FrameworkAndroidJni::AddIdle(int timeout, void* data, bool (*callback)(void* data))
{
JNIEnv* env = nullptr;
JavaVM* javaVM = AndroidFramework::Get().GetJVM();
return static_cast<unsigned int>(id);
}
-void Framework::RemoveIdle(unsigned int id)
+void FrameworkAndroidJni::RemoveIdle(unsigned int id)
{
JNIEnv* env = nullptr;
JavaVM* javaVM = AndroidFramework::Get().GetJVM();
env->CallStaticVoidMethod(clazz, removeIdle, static_cast<jint>(id));
}
-void Framework::Quit()
+void FrameworkAndroidJni::Quit()
{
DALI_LOG_ERROR("Quit does nothing for DaliView!");
}
-bool Framework::IsMainLoopRunning()
-{
- return mRunning;
-}
-
-void Framework::AddAbortCallback(CallbackBase* callback)
-{
- mImpl->mAbortCallBack = callback;
-}
-
-std::string Framework::GetBundleName() const
-{
- return mBundleName;
-}
-
-void Framework::SetBundleName(const std::string& name)
-{
- mBundleName = name;
-}
-
-std::string Framework::GetBundleId() const
-{
- return mBundleId;
-}
-
-std::string Framework::GetResourcePath()
-{
- return DALI_DATA_RO_DIR;
-}
-
-std::string Framework::GetDataPath()
-{
- return "";
-}
-
-void Framework::SetBundleId(const std::string& id)
-{
- mBundleId = id;
-}
-
-void Framework::AbortCallback()
-{
- // if an abort call back has been installed run it.
- if(mImpl->mAbortCallBack)
- {
- CallbackBase::Execute(*mImpl->mAbortCallBack);
- }
- else
- {
- Quit();
- }
-}
-
-bool Framework::AppStatusHandler(int type, void* data)
+bool FrameworkAndroidJni::AppStatusHandler(int type, void* data)
{
Dali::Adaptor* adaptor = nullptr;
switch(type)
case APP_DESTROYED:
mObserver.OnTerminate();
mRunning = false;
- mPaused = false;
mInitialised = false;
break;
return true;
}
-void Framework::InitThreads()
-{
-}
-
-std::string Framework::GetLanguage() const
-{
- return mImpl->GetLanguage();
-}
-
-std::string Framework::GetRegion() const
-{
- return mImpl->GetRegion();
-}
-
} // namespace Adaptor
} // namespace Internal
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_ANDROIDJNI_FRAMEWORK_H
+#define DALI_INTERNAL_ADAPTOR_ANDROIDJNI_FRAMEWORK_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/android/framework-android-interface.h>
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * FrameworkAndroidJni class provides an Framework Android JNI implementation.
+ */
+class FrameworkAndroidJni : public Framework, public FrameworkAndroidInterface
+{
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework()
+ */
+ FrameworkAndroidJni(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
+
+ /**
+ * Destructor
+ */
+ ~FrameworkAndroidJni();
+
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Run()
+ */
+ void Run() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Quit()
+ */
+ void Quit() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::FrameworkAndroidInterface::AppStatusHandler()
+ */
+ bool AppStatusHandler(int type, void* data) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::FrameworkAndroidInterface::AddIdle()
+ */
+ unsigned int AddIdle(int timeout, void* data, bool (*callback)(void* data)) override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::FrameworkAndroidInterface::RemoveIdle()
+ */
+ void RemoveIdle(unsigned int id) override;
+
+private:
+ // Undefined
+ FrameworkAndroidJni(const FrameworkAndroidJni&);
+ FrameworkAndroidJni& operator=(FrameworkAndroidJni&);
+
+private:
+ bool mInitialised;
+
+private: // impl members
+ struct Impl;
+ Impl* mImpl;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_ANDROIDJNI_FRAMEWORK_H
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/androidjni/framework-factory-androidjni.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/adaptor/androidjni/framework-androidjni.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Framework> FrameworkFactoryAndroidJni::CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread)
+{
+ return Utils::MakeUnique<FrameworkAndroidJni>(observer, taskObserver, argc, argv, type, useUiThread);
+}
+
+std::unique_ptr<FrameworkFactory> GetFrameworkFactory()
+{
+ return Utils::MakeUnique<FrameworkFactoryAndroidJni>();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_ANDROIDJNI_FRAMEWORK_FACTORY_H
+#define DALI_INTERNAL_ADAPTOR_ANDROIDJNI_FRAMEWORK_FACTORY_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/adaptor/common/framework-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class FrameworkFactoryAndroidJni : public FrameworkFactory
+{
+public:
+ std::unique_ptr<Framework> CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_ANDROIDJNI_FRAMEWORK_FACTORY_H
#include <dali/devel-api/atspi-interfaces/accessible.h>
#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/adaptor/common/framework-factory.h>
#include <dali/internal/adaptor/common/framework.h>
#include <dali/internal/adaptor/common/lifecycle-controller-impl.h>
#include <dali/internal/system/common/command-line-options.h>
#include <dali/internal/system/common/environment-variables.h>
+#include <dali/internal/system/common/system-settings.h>
#include <dali/internal/window-system/common/render-surface-factory.h>
#include <dali/internal/window-system/common/window-impl.h>
#include <dali/internal/window-system/common/window-render-surface.h>
}
mCommandLineOptions = new CommandLineOptions(argc, argv);
- mFramework = new Framework(*this, *this, argc, argv, applicationType, mUseUiThread);
- mUseRemoteSurface = (applicationType == Framework::WATCH);
+ mFramework = Dali::Internal::Adaptor::GetFrameworkFactory()->CreateFramework(*this, *this, argc, argv, applicationType, mUseUiThread);
+
+ mUseRemoteSurface = (applicationType == Framework::WATCH);
}
Application::~Application()
mMainWindow.Reset();
delete mCommandLineOptions;
- delete mFramework;
// Application is created in Main thread whether UI Threading is enabled or not.
// But some resources are created in Main thread or UI thread.
std::string Application::GetResourcePath()
{
- return Internal::Adaptor::Framework::GetResourcePath();
+ return SystemSettings::GetResourcePath();
}
std::string Application::GetDataPath()
{
- return Internal::Adaptor::Framework::GetDataPath();
+ return SystemSettings::GetDataPath();
}
void Application::SetStyleSheet(const std::string& stylesheet)
LowMemorySignalType mTaskLowMemorySignal;
DeviceOrientationChangedSignalType mTaskDeviceOrientationChangedSignal;
- Framework* mFramework;
+ std::unique_ptr<Framework> mFramework;
CommandLineOptions* mCommandLineOptions;
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_COMMON_FRAMEWORK_FACTORY_H
+#define DALI_INTERNAL_ADAPTOR_COMMON_FRAMEWORK_FACTORY_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class FrameworkFactory
+{
+public:
+ FrameworkFactory() = default;
+ virtual ~FrameworkFactory() = default;
+
+ virtual std::unique_ptr<Framework> CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread) = 0;
+};
+
+extern std::unique_ptr<FrameworkFactory> GetFrameworkFactory();
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_COMMON_FRAMEWORK_FACTORY_H
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace
+{
+constexpr auto NOT_SUPPORTED = "NOT_SUPPORTED";
+} // namespace
+
+Framework::Framework(Framework::Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
+: mObserver(observer),
+ mTaskObserver(taskObserver),
+ mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
+ mArgc(argc),
+ mArgv(argv),
+ mAbortCallBack(),
+ mRunning(false)
+{
+}
+
+Framework::~Framework()
+{
+}
+
+std::string Framework::GetLanguage() const
+{
+ return NOT_SUPPORTED;
+}
+
+std::string Framework::GetRegion() const
+{
+ return NOT_SUPPORTED;
+}
+
+bool Framework::IsMainLoopRunning()
+{
+ return mRunning;
+}
+
+void Framework::AddAbortCallback(CallbackBase* callback)
+{
+ mAbortCallBack = std::unique_ptr<CallbackBase>(callback);
+}
+
+void Framework::AbortCallback()
+{
+ // if an abort call back has been installed run it.
+ if(mAbortCallBack)
+ {
+ CallbackBase::Execute(*mAbortCallBack);
+ }
+ else
+ {
+ Quit();
+ }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
-#ifndef DALI_INTERNAL_FRAMEWORK_H
-#define DALI_INTERNAL_FRAMEWORK_H
+#ifndef DALI_INTERNAL_ADAPTOR_COMMON_FRAMEWORK_H
+#define DALI_INTERNAL_ADAPTOR_COMMON_FRAMEWORK_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* The class is also used to register callbacks with the TIZEN platform so that
* we know when any of the application lifecycle events occur. This includes events
* like when our application is to be initialised, terminated, paused, resumed etc.
- *
*/
class Framework
{
/**
* Destructor
*/
- ~Framework();
+ virtual ~Framework();
public:
/**
* Runs the main loop of framework
*/
- void Run();
+ virtual void Run() = 0;
/**
* Quits the main loop
*/
- void Quit();
+ virtual void Quit() = 0;
+
+ /**
+ * Gets system language.
+ */
+ virtual std::string GetLanguage() const;
+
+ /**
+ * Gets system region.
+ */
+ virtual std::string GetRegion() const;
/**
* Checks whether the main loop of the framework is running.
void AddAbortCallback(CallbackBase* callback);
/**
- * Gets bundle name which was passed in app_reset callback.
- */
- std::string GetBundleName() const;
-
- /**
- * Gets bundle id which was passed in app_reset callback.
- */
- std::string GetBundleId() const;
-
- /**
* Sets a command line options.
* This is used in case of the preinitialized application.
* @param[in] argc A pointer to the number of arguments
mArgv = argv;
}
+private:
/**
- * Gets the path at which application resources are stored.
- */
- static std::string GetResourcePath();
-
- /**
- * Gets the path at which application data are stored.
- */
- static std::string GetDataPath();
-
- /**
- * Sets system language.
- */
- void SetLanguage(const std::string& language);
-
- /**
- * Sets system region.
- */
- void SetRegion(const std::string& region);
-
- /**
- * Gets system language.
- */
- std::string GetLanguage() const;
-
- /**
- * Gets system region.
- */
- std::string GetRegion() const;
-
- /**
- * Called by the App framework when an application lifecycle event occurs.
- * @param[in] type The type of event occurred.
- * @param[in] data The data of event occurred.
- */
- bool AppStatusHandler(int type, void* data);
-
- /**
- * Called by the adaptor when an idle callback is added.
- * @param[in] timeout The timeout of the callback.
- * @param[in] data The data of of the callback.
- * @param[in] callback The callback.
- * @return The callback id.
- */
- unsigned int AddIdle(int timeout, void* data, bool (*callback)(void* data));
-
- /**
- * Called by the adaptor when an idle callback is removed.
- * @param[in] id The callback id.
+ * Called if the application is aborted.
*/
- void RemoveIdle(unsigned int id);
+ void AbortCallback();
private:
// Undefined
Framework(const Framework&);
Framework& operator=(Framework&);
-private:
- /**
- * Called when the application is created.
- */
- bool Create();
-
- /**
- * Called app_reset callback was called with bundle.
- */
- void SetBundleName(const std::string& name);
-
- /**
- * Called app_reset callback was called with bundle.
- */
- void SetBundleId(const std::string& id);
-
- /**
- * Called if the application is aborted.
- */
- void AbortCallback();
-
- /**
- * Called for initializing on specified backend. (X11 or Wayland)
- */
- void InitThreads();
-
-private:
- Observer& mObserver;
- TaskObserver& mTaskObserver;
- bool mInitialised;
- bool mPaused;
- bool mRunning;
- int* mArgc;
- char*** mArgv;
- std::string mBundleName;
- std::string mBundleId;
- AbortHandler mAbortHandler;
-
-private: // impl members
- struct Impl;
- Impl* mImpl;
+protected:
+ Observer& mObserver;
+ TaskObserver& mTaskObserver;
+ AbortHandler mAbortHandler;
+ int* mArgc;
+ char*** mArgv;
+ std::unique_ptr<CallbackBase> mAbortCallBack;
+ bool mRunning;
};
} // namespace Adaptor
} // namespace Dali
-#endif // DALI_INTERNAL_FRAMEWORK_H
+#endif // DALI_INTERNAL_ADAPTOR_COMMON_FRAMEWORK_H
${adaptor_adaptor_dir}/common/adaptor-builder-impl.cpp
${adaptor_adaptor_dir}/common/application-impl.cpp
${adaptor_adaptor_dir}/common/combined-update-render-controller.cpp
+ ${adaptor_adaptor_dir}/common/framework.cpp
${adaptor_adaptor_dir}/common/system-cache-path.cpp
)
# module: adaptor, backend: tizen-wayland
SET( adaptor_adaptor_tizen_wayland_src_files
${adaptor_adaptor_dir}/tizen-wayland/adaptor-impl-tizen.cpp
+ ${adaptor_adaptor_dir}/tizen-wayland/framework-factory-tizen.cpp
${adaptor_adaptor_dir}/tizen-wayland/framework-tizen.cpp
)
# module: adaptor, backend: libuv-x11
SET( adaptor_adaptor_libuv_src_files
${adaptor_adaptor_dir}/generic/adaptor-impl-generic.cpp
+ ${adaptor_adaptor_dir}/libuv/framework-factory-libuv.cpp
${adaptor_adaptor_dir}/libuv/framework-libuv.cpp
)
# module: adaptor, backend: glib-x11
SET( adaptor_adaptor_glib_src_files
${adaptor_adaptor_dir}/generic/adaptor-impl-generic.cpp
+ ${adaptor_adaptor_dir}/glib/framework-factory-glib.cpp
${adaptor_adaptor_dir}/glib/framework-glib.cpp
)
# module: adaptor, backend: ubuntu
SET( adaptor_adaptor_ubuntu_src_files
${adaptor_adaptor_dir}/generic/adaptor-impl-generic.cpp
+ ${adaptor_adaptor_dir}/ubuntu/framework-factory-ubuntu.cpp
${adaptor_adaptor_dir}/ubuntu/framework-ubuntu.cpp
)
SET( adaptor_adaptor_android_src_files
${adaptor_adaptor_dir}/generic/adaptor-impl-generic.cpp
${adaptor_adaptor_dir}/android/android-framework-impl.cpp
+ ${adaptor_adaptor_dir}/android/framework-factory-android.cpp
${adaptor_adaptor_dir}/android/framework-android.cpp
)
SET( adaptor_adaptor_androidjni_src_files
${adaptor_adaptor_dir}/generic/adaptor-impl-generic.cpp
${adaptor_adaptor_dir}/android/android-framework-impl.cpp
+ ${adaptor_adaptor_dir}/androidjni/framework-factory-androidjni.cpp
${adaptor_adaptor_dir}/androidjni/framework-androidjni.cpp
)
# module: adaptor, backend: windows
SET( adaptor_adaptor_windows_src_files
${adaptor_adaptor_dir}/generic/adaptor-impl-generic.cpp
+ ${adaptor_adaptor_dir}/windows/framework-factory-win.cpp
${adaptor_adaptor_dir}/windows/framework-win.cpp
)
# module: adaptor, backend: macos
SET( adaptor_adaptor_macos_src_files
${adaptor_adaptor_dir}/generic/adaptor-impl-generic.cpp
+ ${adaptor_adaptor_dir}/macos/framework-factory-mac.mm
${adaptor_adaptor_dir}/macos/framework-mac.mm
)
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/glib/framework-factory-glib.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/adaptor/glib/framework-glib.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Framework> FrameworkFactoryGlib::CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread)
+{
+ return Utils::MakeUnique<FrameworkGlib>(observer, taskObserver, argc, argv, type, useUiThread);
+}
+
+std::unique_ptr<FrameworkFactory> GetFrameworkFactory()
+{
+ return Utils::MakeUnique<FrameworkFactoryGlib>();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_GLIB_FRAMEWORK_FACTORY_H
+#define DALI_INTERNAL_ADAPTOR_GLIB_FRAMEWORK_FACTORY_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/adaptor/common/framework-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class FrameworkFactoryGlib : public FrameworkFactory
+{
+public:
+ std::unique_ptr<Framework> CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_GLIB_FRAMEWORK_FACTORY_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// CLASS HEADER
-#include <dali/internal/adaptor/common/framework.h>
+#include <dali/internal/adaptor/glib/framework-glib.h>
// EXTERNAL INCLUDES
#include <glib.h>
#include <cstdio>
#include <cstring>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/system/common/callback-manager.h>
-
namespace Dali
{
namespace Internal
/**
* Impl to hide GLib data members
*/
-struct Framework::Impl
+struct FrameworkGlib::Impl
{
// Constructor
Impl(void* data)
- : mAbortCallBack(nullptr),
- mCallbackManager(nullptr),
- mLanguage("NOT_SUPPORTED"),
- mRegion("NOT_SUPPORTED")
{
- mCallbackManager = CallbackManager::New();
-
// In future, may need to change this to have own context or use Tizen context
gMainLoop = mMainLoop = g_main_loop_new(nullptr, false);
}
~Impl()
{
- delete mAbortCallBack;
-
- // we're quiting the main loop so
- // mCallbackManager->RemoveAllCallBacks() does not need to be called
- // to delete our abort handler
- delete mCallbackManager;
-
g_main_loop_unref(mMainLoop);
gMainLoop = nullptr;
}
}
// Data
- CallbackBase* mAbortCallBack;
- CallbackManager* mCallbackManager;
- GMainLoop* mMainLoop{nullptr};
- GMainContext* mContext{nullptr};
-
- std::string mLanguage;
- std::string mRegion;
+ GMainLoop* mMainLoop{nullptr};
+ GMainContext* mContext{nullptr};
private:
Impl(const Impl& impl) = delete;
Impl& operator=(const Impl& impl) = delete;
};
-Framework::Framework(Framework::Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
-: mObserver(observer),
- mTaskObserver(taskObserver),
- mInitialised(false),
- mRunning(false),
- mArgc(argc),
- mArgv(argv),
- mBundleName(""),
- mBundleId(""),
- mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
+FrameworkGlib::FrameworkGlib(Framework::Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
+: Framework(observer, taskObserver, argc, argv, type, useUiThread),
mImpl(NULL)
{
mImpl = new Impl(this);
}
-Framework::~Framework()
+FrameworkGlib::~FrameworkGlib()
{
if(mRunning)
{
delete mImpl;
}
-void Framework::Run()
+void FrameworkGlib::Run()
{
mRunning = true;
mObserver.OnInit();
mRunning = false;
}
-void Framework::Quit()
+void FrameworkGlib::Quit()
{
mObserver.OnTerminate();
mImpl->Quit();
}
-bool Framework::IsMainLoopRunning()
-{
- return mRunning;
-}
-
-void Framework::AddAbortCallback(CallbackBase* callback)
-{
- mImpl->mAbortCallBack = callback;
-}
-
-std::string Framework::GetBundleName() const
-{
- return mBundleName;
-}
-
-void Framework::SetBundleName(const std::string& name)
-{
-}
-
-std::string Framework::GetBundleId() const
-{
- return "";
-}
-
-std::string Framework::GetResourcePath()
-{
- // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path.
- const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
- char* value = getenv(ubuntuEnvironmentVariable);
- std::string resourcePath;
- if(value != NULL)
- {
- resourcePath = value;
- }
-
- if(resourcePath.back() != '/')
- {
- resourcePath += "/";
- }
-
- return resourcePath;
-}
-
-void Framework::SetBundleId(const std::string& id)
-{
-}
-
-void Framework::AbortCallback()
-{
- // if an abort call back has been installed run it.
- if(mImpl->mAbortCallBack)
- {
- CallbackBase::Execute(*mImpl->mAbortCallBack);
- }
- else
- {
- Quit();
- }
-}
-
-bool Framework::AppStatusHandler(int type, void* bundleData)
-{
- return true;
-}
-
-std::string Framework::GetLanguage() const
-{
- return mImpl->mLanguage;
-}
-
-std::string Framework::GetRegion() const
-{
- return mImpl->mRegion;
-}
-
-std::string Framework::GetDataPath()
-{
- const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
- char* value = getenv(ubuntuEnvironmentVariable);
- std::string dataPath;
- if(value != NULL)
- {
- dataPath = value;
- }
-
- return dataPath;
-}
-
} // namespace Adaptor
} // namespace Internal
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_GLIB_FRAMEWORK_H
+#define DALI_INTERNAL_ADAPTOR_GLIB_FRAMEWORK_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * FrameworkGlib class provides an Framework Glib implementation.
+ */
+class FrameworkGlib : public Framework
+{
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework()
+ */
+ FrameworkGlib(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
+
+ /**
+ * Destructor
+ */
+ ~FrameworkGlib();
+
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Run()
+ */
+ void Run() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Quit()
+ */
+ void Quit() override;
+
+private:
+ // Undefined
+ FrameworkGlib(const FrameworkGlib&);
+ FrameworkGlib& operator=(FrameworkGlib&);
+
+private: // impl members
+ struct Impl;
+ Impl* mImpl;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_GLIB_FRAMEWORK_H
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/libuv/framework-factory-libuv.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/adaptor/libuv/framework-libuv.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Framework> FrameworkFactoryLibuv::CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread)
+{
+ return Utils::MakeUnique<FrameworkLibuv>(observer, taskObserver, argc, argv, type, useUiThread);
+}
+
+std::unique_ptr<FrameworkFactory> GetFrameworkFactory()
+{
+ return Utils::MakeUnique<FrameworkFactoryLibuv>();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_LIBUV_FRAMEWORK_FACTORY_H
+#define DALI_INTERNAL_ADAPTOR_LIBUV_FRAMEWORK_FACTORY_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/adaptor/common/framework-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class FrameworkFactoryLibuv : public FrameworkFactory
+{
+public:
+ std::unique_ptr<Framework> CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_LIBUV_FRAMEWORK_FACTORY_H
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
// CLASS HEADER
-#include <dali/internal/adaptor/common/framework.h>
+#include <dali/internal/adaptor/libuv/framework-libuv.h>
// EXTERNAL INCLUDES
#include <X11/Xlib.h>
#include <cstdio>
#include <cstring>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/system/common/callback-manager.h>
-
namespace Dali
{
namespace Internal
/**
* Impl to hide LibUV data members
*/
-struct Framework::Impl
+struct FrameworkLibuv::Impl
{
// Constructor
Impl(void* data)
- : mAbortCallBack(nullptr),
- mCallbackManager(nullptr),
- mLanguage("NOT_SUPPORTED"),
- mRegion("NOT_SUPPORTED")
{
- mCallbackManager = CallbackManager::New();
- mMainLoop = new uv_loop_t;
- gUVLoop = mMainLoop; // "There can be only one!"
+ mMainLoop = new uv_loop_t;
+ gUVLoop = mMainLoop; // "There can be only one!"
uv_loop_init(mMainLoop);
}
~Impl()
{
- delete mAbortCallBack;
-
- // we're quiting the main loop so
- // mCallbackManager->RemoveAllCallBacks() does not need to be called
- // to delete our abort handler
- delete mCallbackManager;
-
delete mMainLoop;
}
}
// Data
-
- CallbackBase* mAbortCallBack;
- CallbackManager* mCallbackManager;
- uv_loop_t* mMainLoop;
-
- std::string mLanguage;
- std::string mRegion;
+ uv_loop_t* mMainLoop;
private:
Impl(const Impl& impl) = delete;
Impl& operator=(const Impl& impl) = delete;
};
-Framework::Framework(Framework::Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
-: mObserver(observer),
- mTaskObserver(taskObserver),
- mInitialised(false),
- mRunning(false),
- mArgc(argc),
- mArgv(argv),
- mBundleName(""),
- mBundleId(""),
- mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
+FrameworkLibuv::FrameworkLibuv(Framework::Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
+: Framework(observer, taskObserver, argc, argv, type, useUiThread),
mImpl(NULL)
{
mImpl = new Impl(this);
}
-Framework::~Framework()
+FrameworkLibuv::~FrameworkLibuv()
{
if(mRunning)
{
delete mImpl;
}
-void Framework::Run()
+void FrameworkLibuv::Run()
{
mRunning = true;
mObserver.OnInit();
mRunning = false;
}
-void Framework::Quit()
+void FrameworkLibuv::Quit()
{
mObserver.OnTerminate();
mImpl->Quit();
}
-bool Framework::IsMainLoopRunning()
-{
- return mRunning;
-}
-
-void Framework::AddAbortCallback(CallbackBase* callback)
-{
- mImpl->mAbortCallBack = callback;
-}
-
-std::string Framework::GetBundleName() const
-{
- return mBundleName;
-}
-
-void Framework::SetBundleName(const std::string& name)
-{
-}
-
-std::string Framework::GetBundleId() const
-{
- return "";
-}
-
-std::string Framework::GetResourcePath()
-{
- // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path.
- const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
- char* value = getenv(ubuntuEnvironmentVariable);
- std::string resourcePath;
- if(value != NULL)
- {
- resourcePath = value;
- }
-
- if(resourcePath.back() != '/')
- {
- resourcePath += "/";
- }
-
- return resourcePath;
-}
-
-void Framework::SetBundleId(const std::string& id)
-{
-}
-
-void Framework::AbortCallback()
-{
- // if an abort call back has been installed run it.
- if(mImpl->mAbortCallBack)
- {
- CallbackBase::Execute(*mImpl->mAbortCallBack);
- }
- else
- {
- Quit();
- }
-}
-
-bool Framework::AppStatusHandler(int type, void* bundleData)
-{
- return true;
-}
-
-std::string Framework::GetLanguage() const
-{
- return mImpl->mLanguage;
-}
-
-std::string Framework::GetRegion() const
-{
- return mImpl->mRegion;
-}
-
-std::string Framework::GetDataPath()
-{
- const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
- char* value = getenv(ubuntuEnvironmentVariable);
- std::string dataPath;
- if(value != NULL)
- {
- dataPath = value;
- }
-
- return dataPath;
-}
-
} // namespace Adaptor
} // namespace Internal
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_LIBUV_FRAMEWORK_H
+#define DALI_INTERNAL_ADAPTOR_LIBUV_FRAMEWORK_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * FrameworkLibuv class provides an Framework Libuv implementation.
+ */
+class FrameworkLibuv : public Framework
+{
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Framework()
+ */
+ FrameworkLibuv(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
+
+ /**
+ * Destructor
+ */
+ ~FrameworkLibuv();
+
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Run()
+ */
+ void Run() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Quit()
+ */
+ void Quit() override;
+
+private:
+ // Undefined
+ FrameworkLibuv(const FrameworkLibuv&);
+ FrameworkLibuv& operator=(FrameworkLibuv&);
+
+private: // impl members
+ struct Impl;
+ Impl* mImpl;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_LIBUV_FRAMEWORK_H
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_MAC_FRAMEWORK_FACTORY_H
+#define DALI_INTERNAL_ADAPTOR_MAC_FRAMEWORK_FACTORY_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/adaptor/common/framework-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class FrameworkFactoryMac : public FrameworkFactory
+{
+public:
+ std::unique_ptr<Framework> CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_MAC_FRAMEWORK_FACTORY_H
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/macos/framework-factory-mac.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/adaptor/macos/framework-mac.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Framework> FrameworkFactoryMac::CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread)
+{
+ return Utils::MakeUnique<FrameworkMac>(observer, taskObserver, argc, argv, type, useUiThread);
+}
+
+std::unique_ptr<FrameworkFactory> GetFrameworkFactory()
+{
+ return Utils::MakeUnique<FrameworkFactoryMac>();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_MACOS_FRAMEWORK_H
+#define DALI_INTERNAL_ADAPTOR_MACOS_FRAMEWORK_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * FrameworkMac class provides an Framework Mac implementation.
+ */
+class FrameworkMac : public Framework
+{
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework()
+ */
+ FrameworkMac(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
+
+ /**
+ * Destructor
+ */
+ ~FrameworkMac();
+
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Run()
+ */
+ void Run() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Quit()
+ */
+ void Quit() override;
+
+ /**
+ * Called by the App framework when an application lifecycle event occurs.
+ * @param[in] type The type of event occurred.
+ * @param[in] data The data of event occurred.
+ */
+ bool AppStatusHandler(int type, void* data);
+
+private:
+ // Undefined
+ FrameworkMac(const FrameworkMac&);
+ FrameworkMac& operator=(FrameworkMac&);
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_MACOS_FRAMEWORK_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
#import <Cocoa/Cocoa.h>
#include "extern-definitions.h"
// CLASS HEADER
-#include <dali/internal/adaptor/common/framework.h>
+#include <dali/internal/adaptor/macos/framework-mac.h>
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-// INTERNAL INCLUDES
-#include <dali/internal/system/common/callback-manager.h>
-
namespace Dali
{
} // Unnamed namespace
-/**
- * Impl to hide WindowsSystem data members
- */
-struct Framework::Impl
+FrameworkMac::FrameworkMac(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
+: Framework(observer, taskObserver, argc, argv, type, useUiThread)
{
- // Constructor
-
- Impl(void* data)
- : mAbortCallBack( nullptr ),
- mLanguage( "NOT_SUPPORTED" ),
- mRegion( "NOT_SUPPORTED" )
- {
- }
-
- ~Impl()
- {
- delete mAbortCallBack;
- }
-
- std::string GetLanguage() const
- {
- return mLanguage;
- }
-
- std::string GetRegion() const
- {
- return mRegion;
- }
+ // ensures the NSApp global object is initialized
+ [NSApplication sharedApplication];
- void SetAbortCallback( CallbackBase *base )
- {
- mAbortCallBack = base;
- }
+ // this is needed for applications without a bundle
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
- bool ExecuteCallback()
- {
- if( nullptr != mAbortCallBack )
- {
- CallbackBase::Execute( *mAbortCallBack );
- return true;
- }
-
- return false;
- }
-
-private:
- // Undefined
- Impl( const Impl& impl ) = delete;
-
- // Undefined
- Impl& operator=( const Impl& impl ) = delete;
-
-private:
- // Data
- CallbackBase* mAbortCallBack;
- std::string mLanguage;
- std::string mRegion;
-};
-
-Framework::Framework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
-: mObserver(observer),
- mTaskObserver(taskObserver),
- mInitialised(false),
- mPaused(false),
- mRunning(false),
- mArgc(argc),
- mArgv(argv),
- mBundleName(""),
- mBundleId(""),
- mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
- mImpl(NULL)
-{
- InitThreads();
- mImpl = new Impl(this);
-
- // ensures the NSApp global object is initialized
- [NSApplication sharedApplication];
-
- // this is needed for applications without a bundle
- [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
-
- // make sure we can become the key window
- [NSApp activateIgnoringOtherApps:YES];
+ // make sure we can become the key window
+ [NSApp activateIgnoringOtherApps:YES];
}
-Framework::~Framework()
+FrameworkMac::~FrameworkMac()
{
if (mRunning)
{
Quit();
}
-
- delete mImpl;
}
-void Framework::Run()
+void FrameworkMac::Run()
{
mRunning = true;
AppStatusHandler(APP_CREATE, nullptr);
mRunning = false;
}
-void Framework::Quit()
+void FrameworkMac::Quit()
{
AppStatusHandler(APP_TERMINATE, nullptr);
}
-bool Framework::IsMainLoopRunning()
-{
- return mRunning;
-}
-
-void Framework::AddAbortCallback( CallbackBase* callback )
-{
- mImpl->SetAbortCallback( callback );
-}
-
-std::string Framework::GetBundleName() const
-{
- return mBundleName;
-}
-
-void Framework::SetBundleName(const std::string& name)
-{
- mBundleName = name;
-}
-
-std::string Framework::GetBundleId() const
-{
- return mBundleId;
-}
-
-std::string Framework::GetResourcePath()
-{
- // "DALI_APPLICATION_PACKAGE" is used by macOS specifically to get the already configured Application package path.
- const char* macEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
- char* value = getenv( macEnvironmentVariable );
-
- std::string resourcePath;
- if ( value != NULL )
- {
- resourcePath = value;
- }
-
- if( resourcePath.back() != '/' )
- {
- resourcePath+="/";
- }
-
- return resourcePath;
-}
-
-std::string Framework::GetDataPath()
-{
- return app_get_data_path();
-}
-
-void Framework::SetBundleId(const std::string& id)
-{
- mBundleId = id;
-}
-
-void Framework::AbortCallback( )
-{
- // if an abort call back has been installed run it.
- if( false == mImpl->ExecuteCallback() )
- {
- Quit();
- }
-}
-
-bool Framework::AppStatusHandler(int type, void *)
+bool FrameworkMac::AppStatusHandler(int type, void *)
{
switch (type)
{
case APP_CREATE:
{
- mInitialised = true;
mObserver.OnInit();
break;
}
return true;
}
-void Framework::InitThreads()
-{
-}
-
-std::string Framework::GetLanguage() const
-{
- return mImpl->GetLanguage();
-}
-
-std::string Framework::GetRegion() const
-{
- return mImpl->GetRegion();
-}
-
} // namespace Adaptor
} // namespace Internal
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/tizen-wayland/framework-factory-tizen.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/adaptor/tizen-wayland/framework-tizen.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Framework> FrameworkFactoryTizen::CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread)
+{
+ return Utils::MakeUnique<FrameworkTizen>(observer, taskObserver, argc, argv, type, useUiThread);
+}
+
+std::unique_ptr<FrameworkFactory> GetFrameworkFactory()
+{
+ return Utils::MakeUnique<FrameworkFactoryTizen>();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_TIZEN_FRAMEWORK_FACTORY_H
+#define DALI_INTERNAL_ADAPTOR_TIZEN_FRAMEWORK_FACTORY_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/adaptor/common/framework-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class FrameworkFactoryTizen : public FrameworkFactory
+{
+public:
+ std::unique_ptr<Framework> CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_TIZEN_FRAMEWORK_FACTORY_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
// CLASS HEADER
-#include <dali/internal/adaptor/common/framework.h>
+#include <dali/internal/adaptor/tizen-wayland/framework-tizen.h>
// EXTERNAL INCLUDES
#include <app_common.h>
#include <Eldbus.h>
#endif // DALI_ELDBUS_AVAILABLE
-#if defined(TIZEN_PLATFORM_CONFIG_SUPPORTED) && TIZEN_PLATFORM_CONFIG_SUPPORTED
-#include <tzplatform_config.h>
-#endif // TIZEN_PLATFORM_CONFIG_SUPPORTED
-
#ifdef COMPONENT_APPLICATION_SUPPORT
#include <component_based_app_base.h>
#endif
#include <dali/integration-api/trace.h>
// INTERNAL INCLUDES
-#include <dali/internal/system/common/callback-manager.h>
#include <dali/internal/system/linux/dali-ecore.h>
using namespace tizen_cpp;
/**
* Impl to hide EFL data members
*/
-struct Framework::Impl
+struct FrameworkTizen::Impl
{
class UiAppContext : public AppCoreUiBase
{
class Task : public AppCoreTaskBase
{
public:
- explicit Task(Framework* framework)
+ explicit Task(FrameworkTizen* framework)
: mFramework(framework),
mNewBatteryStatus(Dali::DeviceStatus::Battery::Status::NORMAL),
mNewMemoryStatus(Dali::DeviceStatus::Memory::NORMAL),
mNewMemoryStatus = AppCore::GetMemoryStatus(static_cast<app_event_low_memory_status_e>(state));
PostToUiThread(
- [](gpointer userData) -> gboolean
- {
+ [](gpointer userData) -> gboolean {
auto* task = static_cast<Task*>(userData);
- auto* framework = static_cast<Framework*>(task->mFramework);
+ auto* framework = static_cast<FrameworkTizen*>(task->mFramework);
framework->mObserver.OnMemoryLow(task->mNewMemoryStatus);
return G_SOURCE_REMOVE;
});
mNewDeviceOrientationStatus = AppCore::GetOrientationStatus(static_cast<app_device_orientation_e>(state));
PostToUiThread(
- [](gpointer userData) -> gboolean
- {
+ [](gpointer userData) -> gboolean {
auto* task = static_cast<Task*>(userData);
- auto* framework = static_cast<Framework*>(task->mFramework);
+ auto* framework = static_cast<FrameworkTizen*>(task->mFramework);
framework->mObserver.OnDeviceOrientationChanged(task->mNewDeviceOrientationStatus);
return G_SOURCE_REMOVE;
});
mNewBatteryStatus = AppCore::GetBatteryStatus(static_cast<app_event_low_battery_status_e>(state));
PostToUiThread(
- [](gpointer userData) -> gboolean
- {
+ [](gpointer userData) -> gboolean {
auto* task = static_cast<Task*>(userData);
- auto* framework = static_cast<Framework*>(task->mFramework);
+ auto* framework = static_cast<FrameworkTizen*>(task->mFramework);
framework->mObserver.OnBatteryLow(task->mNewBatteryStatus);
return G_SOURCE_REMOVE;
});
mFramework->SetLanguage(mNewLanguage);
PostToUiThread(
- [](gpointer userData) -> gboolean
- {
+ [](gpointer userData) -> gboolean {
auto* task = static_cast<Task*>(userData);
- auto* framework = static_cast<Framework*>(task->mFramework);
+ auto* framework = static_cast<FrameworkTizen*>(task->mFramework);
framework->mObserver.OnLanguageChanged();
return G_SOURCE_REMOVE;
});
mFramework->SetRegion(mNewRegion);
PostToUiThread(
- [](gpointer userData) -> gboolean
- {
+ [](gpointer userData) -> gboolean {
auto* task = static_cast<Task*>(userData);
- auto* framework = static_cast<Framework*>(task->mFramework);
+ auto* framework = static_cast<FrameworkTizen*>(task->mFramework);
framework->mObserver.OnRegionChanged();
return G_SOURCE_REMOVE;
});
}
private:
- Framework* mFramework;
+ FrameworkTizen* mFramework;
std::string mNewLanguage;
std::string mNewRegion;
Dali::DeviceStatus::Battery::Status mNewBatteryStatus;
Dali::DeviceStatus::Orientation::Status mNewDeviceOrientationStatus;
};
- explicit UiAppContext(unsigned int hint, Framework* framework)
+ explicit UiAppContext(unsigned int hint, FrameworkTizen* framework)
: AppCoreUiBase(hint),
mFramework(framework),
mUseUiThread(false)
auto* framework = context->mFramework;
Observer* observer = &framework->mObserver;
- char* lang = nullptr;
- auto appEventReturn = app_event_get_language(event_info, &lang);
+ char* lang = nullptr;
+ auto appEventReturn = app_event_get_language(event_info, &lang);
if(appEventReturn == APP_ERROR_NONE && lang)
{
framework->SetLanguage(std::string(lang));
auto* framework = context->mFramework;
Observer* observer = &framework->mObserver;
- char* region = nullptr;
- auto appEventReturn = app_event_get_region_format(event_info, ®ion);
+ char* region = nullptr;
+ auto appEventReturn = app_event_get_region_format(event_info, ®ion);
if(appEventReturn == APP_ERROR_NONE && region)
{
framework->SetRegion(std::string(region));
Observer* observer = &framework->mObserver;
app_event_low_battery_status_e status;
- auto appEventReturn = app_event_get_low_battery_status(event_info, &status);
+ auto appEventReturn = app_event_get_low_battery_status(event_info, &status);
if(appEventReturn == APP_ERROR_NONE)
{
Dali::DeviceStatus::Battery::Status result = AppCore::GetBatteryStatus(status);
Observer* observer = &framework->mObserver;
app_event_low_memory_status_e status;
- auto appEventReturn = app_event_get_low_memory_status(event_info, &status);
+ auto appEventReturn = app_event_get_low_memory_status(event_info, &status);
if(appEventReturn == APP_ERROR_NONE)
{
Dali::DeviceStatus::Memory::Status result = AppCore::GetMemoryStatus(status);
Observer* observer = &framework->mObserver;
app_device_orientation_e status;
- auto appEventReturn = app_event_get_device_orientation(event_info, &status);
+ auto appEventReturn = app_event_get_device_orientation(event_info, &status);
if(appEventReturn == APP_ERROR_NONE)
{
Dali::DeviceStatus::Orientation::Status result = AppCore::GetOrientationStatus(status);
}
}
- void ProcessBundle(Framework* framework, bundle* bundleData)
+ void ProcessBundle(FrameworkTizen* framework, bundle* bundleData)
{
if(bundleData == nullptr)
{
}
private:
- Framework* mFramework;
+ FrameworkTizen* mFramework;
std::shared_ptr<AppEvent> mLanguageChanged;
std::shared_ptr<AppEvent> mDeviceOrientationChanged;
std::shared_ptr<AppEvent> mRegionFormatChanged;
// Constructor
Impl(void* data, Type type, bool useUiThread)
- : mAbortCallBack(NULL),
- mCallbackManager(NULL),
- handlers{nullptr, nullptr, nullptr, nullptr, nullptr},
+ : handlers{nullptr, nullptr, nullptr, nullptr, nullptr},
mUseUiThread(useUiThread)
#ifdef APPCORE_WATCH_AVAILABLE
,
mWatchCallback()
#endif
{
- mFramework = static_cast<Framework*>(data);
+ mFramework = static_cast<FrameworkTizen*>(data);
#ifndef APPCORE_WATCH_AVAILABLE
if(type == WATCH)
}
#endif
mApplicationType = type;
- mCallbackManager = CallbackManager::New();
}
~Impl()
{
- delete mAbortCallBack;
-
- // we're quiting the main loop so
- // mCallbackManager->RemoveAllCallBacks() does not need to be called
- // to delete our abort handler
- delete mCallbackManager;
}
int AppMain()
}
// Data
- Type mApplicationType;
- CallbackBase* mAbortCallBack;
- CallbackManager* mCallbackManager;
- std::string mLanguage{};
- std::string mRegion{};
+ Type mApplicationType;
+ std::string mLanguage{};
+ std::string mRegion{};
- Framework* mFramework;
+ FrameworkTizen* mFramework;
AppCore::AppEventHandlerPtr handlers[5];
std::unique_ptr<UiAppContext> mUiAppContext{nullptr};
bool mUseUiThread{false};
watch_app_lifecycle_callback_s mWatchCallback;
#endif
- static void ProcessBundle(Framework* framework, bundle* bundleData)
+ static void ProcessBundle(FrameworkTizen* framework, bundle* bundleData)
{
if(bundleData == NULL)
{
static void AppLanguageChanged(AppCore::AppEventInfoPtr event, void* data)
{
- Framework* framework = static_cast<Framework*>(data);
- Observer* observer = &framework->mObserver;
+ FrameworkTizen* framework = static_cast<FrameworkTizen*>(data);
+ Observer* observer = &framework->mObserver;
if(event && event->value)
{
static void AppRegionChanged(AppCore::AppEventInfoPtr event, void* data)
{
- Framework* framework = static_cast<Framework*>(data);
- Observer* observer = &framework->mObserver;
+ FrameworkTizen* framework = static_cast<FrameworkTizen*>(data);
+ Observer* observer = &framework->mObserver;
if(event && event->value)
{
static void AppBatteryLow(AppCore::AppEventInfoPtr event, void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
int status = *static_cast<int*>(event->value);
Dali::DeviceStatus::Battery::Status result = Dali::DeviceStatus::Battery::Status::NORMAL;
static void AppMemoryLow(AppCore::AppEventInfoPtr event, void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
int status = *static_cast<int*>(event->value);
Dali::DeviceStatus::Memory::Status result = Dali::DeviceStatus::Memory::Status::NORMAL;
static void AppDeviceOrientationChanged(AppCore::AppEventInfoPtr event, void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
int status = *static_cast<int*>(event->value);
Dali::DeviceStatus::Orientation::Status result = Dali::DeviceStatus::Orientation::Status::ORIENTATION_0;
static int WidgetAppCreate(void* data)
{
widget_base_on_create();
- return static_cast<int>(static_cast<Framework*>(data)->Create());
+ return static_cast<int>(static_cast<FrameworkTizen*>(data)->Create());
}
static int WidgetAppTerminate(void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
observer->OnTerminate();
widget_base_on_terminate();
#ifdef APPCORE_WATCH_AVAILABLE
static bool WatchAppCreate(int width, int height, void* data)
{
- return static_cast<Framework*>(data)->Create();
+ return static_cast<FrameworkTizen*>(data)->Create();
}
static void WatchAppTimeTick(watch_time_h time, void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
WatchTime curTime(time);
observer->OnTimeTick(curTime);
static void WatchAppAmbientTick(watch_time_h time, void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
WatchTime curTime(time);
observer->OnAmbientTick(curTime);
static void WatchAppAmbientChanged(bool ambient, void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
observer->OnAmbientChanged(ambient);
}
static void WatchAppControl(app_control_h app_control, void* data)
{
- Framework* framework = static_cast<Framework*>(data);
- Observer* observer = &framework->mObserver;
- bundle* bundleData = NULL;
+ FrameworkTizen* framework = static_cast<FrameworkTizen*>(data);
+ Observer* observer = &framework->mObserver;
+ bundle* bundleData = NULL;
app_control_to_bundle(app_control, &bundleData);
ProcessBundle(framework, bundleData);
static void WatchAppTerminate(void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
observer->OnTerminate();
}
static void WatchAppPause(void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
observer->OnPause();
}
static void WatchAppResume(void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
observer->OnResume();
}
static void* ComponentAppCreate(void* data)
{
- Framework* framework = static_cast<Framework*>(data);
- Observer* observer = &framework->mObserver;
+ FrameworkTizen* framework = static_cast<FrameworkTizen*>(data);
+ Observer* observer = &framework->mObserver;
observer->OnInit();
return Dali::AnyCast<void*>(observer->OnCreate());
static void ComponentAppTerminate(void* data)
{
- Observer* observer = &static_cast<Framework*>(data)->mObserver;
+ Observer* observer = &static_cast<FrameworkTizen*>(data)->mObserver;
observer->OnTerminate();
}
Impl& operator=(const Impl& impl);
};
-Framework::Framework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
-: mObserver(observer),
- mTaskObserver(taskObserver),
+FrameworkTizen::FrameworkTizen(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
+: Framework(observer, taskObserver, argc, argv, type, useUiThread),
mInitialised(false),
mPaused(false),
- mRunning(false),
- mArgc(argc),
- mArgv(argv),
mBundleName(""),
mBundleId(""),
- mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
mImpl(NULL)
{
if(mArgc == nullptr || mArgv == nullptr)
set_last_result(TIZEN_ERROR_NOT_SUPPORTED);
}
- InitThreads();
-
mImpl = new Impl(this, type, useUiThread);
}
-Framework::~Framework()
+FrameworkTizen::~FrameworkTizen()
{
if(mRunning)
{
delete mImpl;
}
-bool Framework::Create()
+bool FrameworkTizen::Create()
{
mInitialised = true;
mObserver.OnInit();
return true;
}
-void Framework::Run()
+void FrameworkTizen::Run()
{
mRunning = true;
int ret;
mRunning = false;
}
-void Framework::Quit()
+void FrameworkTizen::Quit()
{
mImpl->AppExit();
}
-bool Framework::IsMainLoopRunning()
-{
- return mRunning;
-}
-
-void Framework::AddAbortCallback(CallbackBase* callback)
-{
- mImpl->mAbortCallBack = callback;
-}
-
-std::string Framework::GetBundleName() const
+std::string FrameworkTizen::GetBundleName() const
{
return mBundleName;
}
-void Framework::SetBundleName(const std::string& name)
+void FrameworkTizen::SetBundleName(const std::string& name)
{
mBundleName = name;
}
-std::string Framework::GetBundleId() const
+std::string FrameworkTizen::GetBundleId() const
{
return mBundleId;
}
-std::string Framework::GetResourcePath()
-{
- std::string resourcePath = "";
-#if defined(TIZEN_PLATFORM_CONFIG_SUPPORTED) && TIZEN_PLATFORM_CONFIG_SUPPORTED
- char* app_rsc_path = app_get_resource_path();
- if(app_rsc_path)
- {
- resourcePath = app_rsc_path;
- free(app_rsc_path);
- }
-#else // For backwards compatibility with older Tizen versions
-
- // "DALI_APPLICATION_PACKAGE" is used to get the already configured Application package path.
- const char* environmentVariable = "DALI_APPLICATION_PACKAGE";
- char* value = getenv(environmentVariable);
- if(value != NULL)
- {
- resourcePath = value;
- }
-
- if(resourcePath.back() != '/')
- {
- resourcePath += "/";
- }
-
-#endif // TIZEN_PLATFORM_CONFIG_SUPPORTED
-
- return resourcePath;
-}
-
-std::string Framework::GetDataPath()
-{
- std::string result;
- char* dataPath = app_get_data_path();
- if(dataPath)
- {
- result = dataPath;
- free(dataPath);
- }
- return result;
-}
-
-void Framework::SetBundleId(const std::string& id)
+void FrameworkTizen::SetBundleId(const std::string& id)
{
mBundleId = id;
}
-void Framework::AbortCallback()
-{
- // if an abort call back has been installed run it.
- if(mImpl->mAbortCallBack)
- {
- CallbackBase::Execute(*mImpl->mAbortCallBack);
- }
- else
- {
- Quit();
- }
-}
-
-void Framework::InitThreads()
-{
-}
-
-void Framework::SetLanguage(const std::string& language)
+void FrameworkTizen::SetLanguage(const std::string& language)
{
mImpl->SetLanguage(language);
}
-void Framework::SetRegion(const std::string& region)
+void FrameworkTizen::SetRegion(const std::string& region)
{
mImpl->SetRegion(region);
}
-std::string Framework::GetLanguage() const
+std::string FrameworkTizen::GetLanguage() const
{
return mImpl->GetLanguage();
}
-std::string Framework::GetRegion() const
+std::string FrameworkTizen::GetRegion() const
{
return mImpl->GetRegion();
}
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_TIZEN_FRAMEWORK_H
+#define DALI_INTERNAL_ADAPTOR_TIZEN_FRAMEWORK_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * FrameworkTizen class provides an Framework Tizen implementation.
+ */
+class FrameworkTizen : public Framework
+{
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework()
+ */
+ FrameworkTizen(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
+
+ /**
+ * Destructor
+ */
+ ~FrameworkTizen();
+
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Run()
+ */
+ void Run() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Quit()
+ */
+ void Quit() override;
+
+ /**
+ * Gets bundle name which was passed in app_reset callback.
+ */
+ std::string GetBundleName() const;
+
+ /**
+ * Gets bundle id which was passed in app_reset callback.
+ */
+ std::string GetBundleId() const;
+
+ /**
+ * Sets system language.
+ */
+ void SetLanguage(const std::string& language);
+
+ /**
+ * Sets system region.
+ */
+ void SetRegion(const std::string& region);
+
+ /**
+ * Gets system language.
+ */
+ std::string GetLanguage() const override;
+
+ /**
+ * Gets system region.
+ */
+ std::string GetRegion() const override;
+
+private:
+ // Undefined
+ FrameworkTizen(const FrameworkTizen&);
+ FrameworkTizen& operator=(FrameworkTizen&);
+
+private:
+ /**
+ * Called when the application is created.
+ */
+ bool Create();
+
+ /**
+ * Called app_reset callback was called with bundle.
+ */
+ void SetBundleName(const std::string& name);
+
+ /**
+ * Called app_reset callback was called with bundle.
+ */
+ void SetBundleId(const std::string& id);
+
+private:
+ bool mInitialised;
+ bool mPaused;
+ std::string mBundleName;
+ std::string mBundleId;
+
+private: // impl members
+ struct Impl;
+ Impl* mImpl;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_TIZEN_FRAMEWORK_H
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/ubuntu/framework-factory-ubuntu.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/adaptor/ubuntu/framework-ubuntu.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Framework> FrameworkFactoryUbuntu::CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread)
+{
+ return Utils::MakeUnique<FrameworkUbuntu>(observer, taskObserver, argc, argv, type, useUiThread);
+}
+
+std::unique_ptr<FrameworkFactory> GetFrameworkFactory()
+{
+ return Utils::MakeUnique<FrameworkFactoryUbuntu>();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_UBUNTU_FRAMEWORK_FACTORY_H
+#define DALI_INTERNAL_ADAPTOR_UBUNTU_FRAMEWORK_FACTORY_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/adaptor/common/framework-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class FrameworkFactoryUbuntu : public FrameworkFactory
+{
+public:
+ std::unique_ptr<Framework> CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_UBUNTU_FRAMEWORK_FACTORY_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
// CLASS HEADER
-#include <dali/internal/adaptor/common/framework.h>
+#include <dali/internal/adaptor/ubuntu/framework-ubuntu.h>
// EXTERNAL INCLUDES
#include <X11/Xlib.h>
+
+// INTERNAL INCLUDES
#include <dali/internal/system/linux/dali-ecore.h>
#include <dali/internal/system/linux/dali-efreet.h>
#include <dali/internal/system/linux/dali-elementary.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/system/common/callback-manager.h>
-
namespace Dali
{
namespace Internal
{
namespace Adaptor
{
-namespace
-{
-/// Application Status Enum
-enum
-{
- APP_CREATE,
- APP_TERMINATE,
- APP_PAUSE,
- APP_RESUME,
- APP_RESET,
- APP_LANGUAGE_CHANGE,
-};
-
-} // Unnamed namespace
-
-/**
- * Impl to hide EFL data members
- */
-struct Framework::Impl
-{
- // Constructor
-
- Impl(void* data)
- : mAbortCallBack(NULL),
- mCallbackManager(CallbackManager::New()),
- mLanguage("NOT_SUPPORTED"),
- mRegion("NOT_SUPPORTED")
- {
- }
-
- ~Impl()
- {
- delete mAbortCallBack;
-
- // we're quiting the main loop so
- // mCallbackManager->RemoveAllCallBacks() does not need to be called
- // to delete our abort handler
- delete mCallbackManager;
- }
-
- std::string GetLanguage() const
- {
- return mLanguage;
- }
-
- std::string GetRegion() const
- {
- return mRegion;
- }
-
- // Data
- CallbackBase* mAbortCallBack;
- CallbackManager* mCallbackManager;
- std::string mLanguage;
- std::string mRegion;
-
- // Static methods
-
- /**
- * Called by AppCore on application creation.
- */
- static bool AppCreate(void* data)
- {
- return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);
- }
-
- /**
- * Called by AppCore when the application should terminate.
- */
- static void AppTerminate(void* data)
- {
- static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);
- }
-
- /**
- * Called by AppCore when the application is paused.
- */
- static void AppPause(void* data)
- {
- static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);
- }
-
- /**
- * Called by AppCore when the application is resumed.
- */
- static void AppResume(void* data)
- {
- static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);
- }
-
- /**
- * Called by AppCore when the language changes on the device.
- */
- static void AppLanguageChange(void* data)
- {
- static_cast<Framework*>(data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
- }
-};
-
-Framework::Framework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
-: mObserver(observer),
- mTaskObserver(taskObserver),
- mInitialised(false),
- mPaused(false),
- mRunning(false),
- mArgc(argc),
- mArgv(argv),
- mBundleName(""),
- mBundleId(""),
- mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),
- mImpl(NULL)
+FrameworkUbuntu::FrameworkUbuntu(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)
+: Framework(observer, taskObserver, argc, argv, type, useUiThread)
{
InitThreads();
- mImpl = new Impl(this);
}
-Framework::~Framework()
+FrameworkUbuntu::~FrameworkUbuntu()
{
if(mRunning)
{
Quit();
}
-
- delete mImpl;
}
-void Framework::Run()
+void FrameworkUbuntu::Run()
{
mRunning = true;
efreet_cache_disable();
elm_init(mArgc ? *mArgc : 0, mArgv ? *mArgv : nullptr);
- Impl::AppCreate(this);
+ mObserver.OnInit();
elm_run();
mRunning = false;
}
-void Framework::Quit()
+void FrameworkUbuntu::Quit()
{
- Impl::AppTerminate(this);
+ mObserver.OnTerminate();
elm_exit();
}
-bool Framework::IsMainLoopRunning()
-{
- return mRunning;
-}
-
-void Framework::AddAbortCallback(CallbackBase* callback)
-{
- mImpl->mAbortCallBack = callback;
-}
-
-std::string Framework::GetBundleName() const
-{
- return mBundleName;
-}
-
-void Framework::SetBundleName(const std::string& name)
-{
- mBundleName = name;
-}
-
-std::string Framework::GetBundleId() const
-{
- return mBundleId;
-}
-
-std::string Framework::GetResourcePath()
-{
- // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path.
- const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
- char* value = getenv(ubuntuEnvironmentVariable);
- std::string resourcePath;
- if(value != NULL)
- {
- resourcePath = value;
- }
-
- if(resourcePath.back() != '/')
- {
- resourcePath += "/";
- }
-
- return resourcePath;
-}
-
-std::string Framework::GetDataPath()
-{
- const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
- char* value = getenv(ubuntuEnvironmentVariable);
- std::string dataPath;
- if(value != NULL)
- {
- dataPath = value;
- }
-
- return dataPath;
-}
-
-void Framework::SetBundleId(const std::string& id)
-{
- mBundleId = id;
-}
-
-void Framework::AbortCallback()
-{
- // if an abort call back has been installed run it.
- if(mImpl->mAbortCallBack)
- {
- CallbackBase::Execute(*mImpl->mAbortCallBack);
- }
- else
- {
- Quit();
- }
-}
-
-bool Framework::AppStatusHandler(int type, void* bundleData)
-{
- switch(type)
- {
- case APP_CREATE:
- {
- mInitialised = true;
-
- mObserver.OnInit();
- break;
- }
-
- case APP_RESET:
- mObserver.OnReset();
- break;
-
- case APP_RESUME:
- mObserver.OnResume();
- break;
-
- case APP_TERMINATE:
- mObserver.OnTerminate();
- break;
-
- case APP_PAUSE:
- mObserver.OnPause();
- break;
-
- case APP_LANGUAGE_CHANGE:
- mObserver.OnLanguageChanged();
- break;
-
- default:
- break;
- }
-
- return true;
-}
-
-void Framework::InitThreads()
+void FrameworkUbuntu::InitThreads()
{
XInitThreads();
}
-std::string Framework::GetLanguage() const
-{
- return mImpl->GetLanguage();
-}
-
-std::string Framework::GetRegion() const
-{
- return mImpl->GetRegion();
-}
-
} // namespace Adaptor
} // namespace Internal
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_UBUNTU_FRAMEWORK_H
+#define DALI_INTERNAL_ADAPTOR_UBUNTU_FRAMEWORK_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * FrameworkUbuntu class provides an Framework Ubuntu implementation.
+ */
+class FrameworkUbuntu : public Framework
+{
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework()
+ */
+ FrameworkUbuntu(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
+
+ /**
+ * Destructor
+ */
+ ~FrameworkUbuntu();
+
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Run()
+ */
+ void Run() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Quit()
+ */
+ void Quit() override;
+
+private:
+ // Undefined
+ FrameworkUbuntu(const FrameworkUbuntu&);
+ FrameworkUbuntu& operator=(FrameworkUbuntu&);
+
+private:
+ /**
+ * Called for initializing on specified backend. (X11 or Wayland)
+ */
+ void InitThreads();
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_UBUNTU_FRAMEWORK_H
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/windows/framework-factory-win.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/adaptor/windows/framework-win.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Framework> FrameworkFactoryWin::CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread)
+{
+ return Utils::MakeUnique<FrameworkWin>(observer, taskObserver, argc, argv, type, useUiThread);
+}
+
+std::unique_ptr<FrameworkFactory> GetFrameworkFactory()
+{
+ return Utils::MakeUnique<FrameworkFactoryWin>();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_WINDOWS_FRAMEWORK_FACTORY_H
+#define DALI_INTERNAL_ADAPTOR_WINDOWS_FRAMEWORK_FACTORY_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/adaptor/common/framework-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class FrameworkFactoryWin : public FrameworkFactory
+{
+public:
+ std::unique_ptr<Framework> CreateFramework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Framework::Type type, bool useUiThread) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_WINDOWS_FRAMEWORK_FACTORY_H
/*\r
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.\r
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
- *\r
*/\r
\r
// CLASS HEADER\r
-#include <dali/internal/adaptor/common/framework.h>\r
+#include <dali/internal/adaptor/windows/framework-win.h>\r
\r
// EXTERNAL INCLUDES\r
#include <dali/integration-api/debug.h>\r
{\r
namespace Adaptor\r
{\r
-namespace\r
-{\r
-/// Application Status Enum\r
-enum\r
-{\r
- APP_CREATE,\r
- APP_TERMINATE,\r
- APP_PAUSE,\r
- APP_RESUME,\r
- APP_RESET,\r
- APP_LANGUAGE_CHANGE,\r
-};\r
-\r
-} // Unnamed namespace\r
/**\r
* Impl to hide WindowsSystem data members\r
*/\r
-struct Framework::Impl\r
+struct FrameworkWin::Impl\r
{\r
// Constructor\r
-\r
Impl(void* data)\r
- : mAbortCallBack(NULL),\r
- mCallbackManager(CallbackManager::New()),\r
- mLanguage("NOT_SUPPORTED"),\r
- mRegion("NOT_SUPPORTED")\r
{\r
}\r
\r
~Impl()\r
{\r
- delete mAbortCallBack;\r
-\r
- // we're quiting the main loop so\r
- // mCallbackManager->RemoveAllCallBacks() does not need to be called\r
- // to delete our abort handler\r
- delete mCallbackManager;\r
- }\r
-\r
- std::string GetLanguage() const\r
- {\r
- return mLanguage;\r
- }\r
-\r
- std::string GetRegion() const\r
- {\r
- return mRegion;\r
- }\r
-\r
- // Static methods\r
-\r
- /**\r
- * Called by AppCore on application creation.\r
- */\r
- static bool AppCreate(void* data)\r
- {\r
- return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);\r
- }\r
-\r
- /**\r
- * Called by AppCore when the application should terminate.\r
- */\r
- static void AppTerminate(void* data)\r
- {\r
- static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);\r
- }\r
-\r
- /**\r
- * Called by AppCore when the application is paused.\r
- */\r
- static void AppPause(void* data)\r
- {\r
- static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);\r
- }\r
-\r
- /**\r
- * Called by AppCore when the application is resumed.\r
- */\r
- static void AppResume(void* data)\r
- {\r
- static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);\r
- }\r
-\r
- /**\r
- * Called by AppCore when the language changes on the device.\r
- */\r
- static void AppLanguageChange(void* data)\r
- {\r
- static_cast<Framework*>(data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);\r
}\r
\r
void Run()\r
TranslateMessage(&nMsg);\r
DispatchMessage(&nMsg);\r
\r
- mCallbackManager->ClearIdleCallbacks();\r
-\r
if(WM_CLOSE == nMsg.message)\r
{\r
break;\r
}\r
}\r
\r
- void Quit()\r
- {\r
- }\r
-\r
- void SetCallbackBase(CallbackBase* base)\r
- {\r
- mAbortCallBack = base;\r
- }\r
-\r
- bool ExcuteCallback()\r
- {\r
- if(NULL != mAbortCallBack)\r
- {\r
- CallbackBase::Execute(*mAbortCallBack);\r
- return true;\r
- }\r
- else\r
- {\r
- return false;\r
- }\r
- }\r
-\r
private:\r
// Undefined\r
Impl(const Impl& impl) = delete;\r
\r
// Undefined\r
Impl& operator=(const Impl& impl) = delete;\r
-\r
-private:\r
- // Data\r
- CallbackBase* mAbortCallBack;\r
- CallbackManager* mCallbackManager;\r
- std::string mLanguage;\r
- std::string mRegion;\r
};\r
\r
-Framework::Framework(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)\r
-: mObserver(observer),\r
- mTaskObserver(taskObserver),\r
- mInitialised(false),\r
- mPaused(false),\r
- mRunning(false),\r
- mArgc(argc),\r
- mArgv(argv),\r
- mBundleName(""),\r
- mBundleId(""),\r
- mAbortHandler(MakeCallback(this, &Framework::AbortCallback)),\r
+FrameworkWin::FrameworkWin(Framework::Observer& observer, Framework::TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread)\r
+: Framework(observer, taskObserver, argc, argv, type, useUiThread),\r
mImpl(NULL)\r
{\r
- InitThreads();\r
mImpl = new Impl(this);\r
}\r
\r
-Framework::~Framework()\r
+FrameworkWin::~FrameworkWin()\r
{\r
if(mRunning)\r
{\r
delete mImpl;\r
}\r
\r
-void Framework::Run()\r
+void FrameworkWin::Run()\r
{\r
mRunning = true;\r
\r
- Impl::AppCreate(this);\r
+ mObserver.OnInit();\r
mImpl->Run();\r
mRunning = false;\r
}\r
\r
-void Framework::Quit()\r
-{\r
- Impl::AppTerminate(this);\r
-}\r
-\r
-bool Framework::IsMainLoopRunning()\r
-{\r
- return mRunning;\r
-}\r
-\r
-void Framework::AddAbortCallback(CallbackBase* callback)\r
-{\r
- mImpl->SetCallbackBase(callback);\r
-}\r
-\r
-std::string Framework::GetBundleName() const\r
-{\r
- return mBundleName;\r
-}\r
-\r
-void Framework::SetBundleName(const std::string& name)\r
-{\r
- mBundleName = name;\r
-}\r
-\r
-std::string Framework::GetBundleId() const\r
-{\r
- return mBundleId;\r
-}\r
-\r
-std::string Framework::GetResourcePath()\r
-{\r
- // "DALI_APPLICATION_PACKAGE" is used by Windows specifically to get the already configured Application package path.\r
- const char* winEnvironmentVariable = "DALI_APPLICATION_PACKAGE";\r
- char* value = getenv(winEnvironmentVariable);\r
-\r
- std::string resourcePath;\r
- if(value != NULL)\r
- {\r
- resourcePath = value;\r
- }\r
-\r
- if(resourcePath.back() != '/')\r
- {\r
- resourcePath += "/";\r
- }\r
-\r
- return resourcePath;\r
-}\r
-\r
-std::string Framework::GetDataPath()\r
-{\r
- std::string result = app_get_data_path();\r
- return result;\r
-}\r
-\r
-void Framework::SetBundleId(const std::string& id)\r
-{\r
- mBundleId = id;\r
-}\r
-\r
-void Framework::AbortCallback()\r
-{\r
- // if an abort call back has been installed run it.\r
- if(false == mImpl->ExcuteCallback())\r
- {\r
- Quit();\r
- }\r
-}\r
-\r
-bool Framework::AppStatusHandler(int type, void* bundleData)\r
-{\r
- switch(type)\r
- {\r
- case APP_CREATE:\r
- {\r
- mInitialised = true;\r
-\r
- mObserver.OnInit();\r
- break;\r
- }\r
- case APP_RESET:\r
- {\r
- mObserver.OnReset();\r
- break;\r
- }\r
- case APP_RESUME:\r
- {\r
- mObserver.OnResume();\r
- break;\r
- }\r
- case APP_TERMINATE:\r
- {\r
- mObserver.OnTerminate();\r
- break;\r
- }\r
- case APP_PAUSE:\r
- {\r
- mObserver.OnPause();\r
- break;\r
- }\r
- case APP_LANGUAGE_CHANGE:\r
- {\r
- mObserver.OnLanguageChanged();\r
- break;\r
- }\r
- default:\r
- {\r
- break;\r
- }\r
- }\r
-\r
- return true;\r
-}\r
-\r
-void Framework::InitThreads()\r
-{\r
-}\r
-\r
-std::string Framework::GetLanguage() const\r
-{\r
- return mImpl->GetLanguage();\r
-}\r
-\r
-std::string Framework::GetRegion() const\r
+void FrameworkWin::Quit()\r
{\r
- return mImpl->GetRegion();\r
+ mObserver.OnTerminate();\r
}\r
\r
} // namespace Adaptor\r
--- /dev/null
+#ifndef DALI_INTERNAL_ADAPTOR_WINDOWS_FRAMEWORK_H
+#define DALI_INTERNAL_ADAPTOR_WINDOWS_FRAMEWORK_H
+
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/framework.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * FrameworkWin class provides an Framework Windows implementation.
+ */
+class FrameworkWin : public Framework
+{
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework()
+ */
+ FrameworkWin(Observer& observer, TaskObserver& taskObserver, int* argc, char*** argv, Type type, bool useUiThread);
+
+ /**
+ * Destructor
+ */
+ ~FrameworkWin();
+
+public:
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Run()
+ */
+ void Run() override;
+
+ /**
+ * @copydoc Dali::Internal::Adaptor::Framework::Quit()
+ */
+ void Quit() override;
+
+private:
+ // Undefined
+ FrameworkWin(const FrameworkWin&);
+ FrameworkWin& operator=(FrameworkWin&);
+
+private: // impl members
+ struct Impl;
+ Impl* mImpl;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_WINDOWS_FRAMEWORK_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-// EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
+// CLASS HEADER
#include <dali/internal/system/common/system-settings.h>
namespace Dali
{
namespace Adaptor
{
-int GetElmAccessActionOver()
+namespace SystemSettings
+{
+std::string GetResourcePath()
{
- return 0;
+ return DALI_DATA_RO_DIR;
}
-int GetLongPressTime(int defaultTime)
+std::string GetDataPath()
{
- return defaultTime;
+ return "";
}
+} // namespace SystemSettings
+
} // namespace Adaptor
} // namespace Internal
#define DALI_INTERNAL_SYSTEM_SETTINGS_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+// EXTERNAL INCLUDES
+#include <string>
+
namespace Dali
{
namespace Internal
{
namespace Adaptor
{
-// Get SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY from system setting if available
-int GetLongPressTime(int defaultTime);
+namespace SystemSettings
+{
+/**
+ * Gets the path at which application resources are stored.
+ */
+std::string GetResourcePath();
+
+/**
+ * Gets the path at which application data are stored.
+ */
+std::string GetDataPath();
-// Get ELM_ACCESS_ACTION_OVER from Elementary if available
-int GetElmAccessActionOver();
+} // namespace SystemSettings
} // namespace Adaptor
SET( adaptor_system_macos_src_files
${adaptor_system_dir}/ubuntu-x11/logging-x.cpp
${adaptor_system_dir}/macos/file-descriptor-monitor-macos.cpp
+ ${adaptor_system_dir}/macos/system-settings-mac.cpp
${adaptor_system_dir}/macos/timer-impl-mac.cpp
${adaptor_system_dir}/common/shared-file.cpp
${adaptor_system_dir}/common/trigger-event-factory.cpp
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
mSource = g_idle_source_new();
g_source_set_priority(mSource, G_PRIORITY_HIGH_IDLE);
g_source_set_callback(mSource, &CallbackData::IdleCallback, this, nullptr); // No destroyNotify
- guint id = g_source_attach(mSource, context);
+ g_source_attach(mSource, context);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/system/common/system-settings.h>
+
+// EXTERNAL INCLUDES
+#include <stdlib.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace SystemSettings
+{
+std::string GetResourcePath()
+{
+ // "DALI_APPLICATION_PACKAGE" is used by macOS specifically to get the already configured Application package path.
+ const char* macEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
+ char* value = getenv(macEnvironmentVariable);
+ std::string resourcePath;
+ if(value != NULL)
+ {
+ resourcePath = value;
+ }
+
+ if(resourcePath.back() != '/')
+ {
+ resourcePath += "/";
+ }
+
+ return resourcePath;
+}
+
+std::string GetDataPath()
+{
+ const char* macEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
+ char* value = getenv(macEnvironmentVariable);
+ std::string dataPath;
+ if(value != NULL)
+ {
+ dataPath = value;
+ }
+
+ return dataPath;
+}
+
+} // namespace SystemSettings
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
+// CLASS HEADER
+#include <dali/internal/system/common/system-settings.h>
+
// EXTERNAL INCLUDES
-#include <system_settings.h>
+#include <app_common.h>
-// INTERNAL INCLUDES
-#include <dali/internal/system/common/system-settings.h>
+#if defined(TIZEN_PLATFORM_CONFIG_SUPPORTED) && TIZEN_PLATFORM_CONFIG_SUPPORTED
+#include <tzplatform_config.h>
+#endif // TIZEN_PLATFORM_CONFIG_SUPPORTED
namespace Dali
{
{
namespace Adaptor
{
-int GetLongPressTime(int defaultTime)
+namespace SystemSettings
{
- return defaultTime;
+std::string GetResourcePath()
+{
+ std::string resourcePath = "";
+#if defined(TIZEN_PLATFORM_CONFIG_SUPPORTED) && TIZEN_PLATFORM_CONFIG_SUPPORTED
+ char* app_rsc_path = app_get_resource_path();
+ if(app_rsc_path)
+ {
+ resourcePath = app_rsc_path;
+ free(app_rsc_path);
+ }
+#else // For backwards compatibility with older Tizen versions
+
+ // "DALI_APPLICATION_PACKAGE" is used to get the already configured Application package path.
+ const char* environmentVariable = "DALI_APPLICATION_PACKAGE";
+ char* value = getenv(environmentVariable);
+ if(value != NULL)
+ {
+ resourcePath = value;
+ }
+
+ if(resourcePath.back() != '/')
+ {
+ resourcePath += "/";
+ }
+
+#endif // TIZEN_PLATFORM_CONFIG_SUPPORTED
+
+ return resourcePath;
}
-int GetElmAccessActionOver()
+std::string GetDataPath()
{
- return 0;
+ std::string result;
+ char* dataPath = app_get_data_path();
+ if(dataPath)
+ {
+ result = dataPath;
+ free(dataPath);
+ }
+ return result;
}
+} // namespace SystemSettings
+
} // namespace Adaptor
} // namespace Internal
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-// INTERNAL INCLUDES
+// CLASS HEADER
#include <dali/internal/system/common/system-settings.h>
+// EXTERNAL INCLUDES
+#include <stdlib.h>
+
namespace Dali
{
namespace Internal
{
namespace Adaptor
{
-int GetElmAccessActionOver()
+namespace SystemSettings
+{
+std::string GetResourcePath()
{
- return 0;
+ // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path.
+ const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
+ char* value = getenv(ubuntuEnvironmentVariable);
+ std::string resourcePath;
+ if(value != NULL)
+ {
+ resourcePath = value;
+ }
+
+ if(resourcePath.back() != '/')
+ {
+ resourcePath += "/";
+ }
+
+ return resourcePath;
}
-int GetLongPressTime(int defaultTime)
+std::string GetDataPath()
{
- return defaultTime;
+ const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
+ char* value = getenv(ubuntuEnvironmentVariable);
+ std::string dataPath;
+ if(value != NULL)
+ {
+ dataPath = value;
+ }
+
+ return dataPath;
}
+} // namespace SystemSettings
+
} // namespace Adaptor
} // namespace Internal
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-// INTERNAL INCLUDES
+// CLASS HEADER
#include <dali/internal/system/common/system-settings.h>
+// EXTERNAL INCLUDES
+#include <stdlib.h>
+
namespace Dali
{
namespace Internal
{
namespace Adaptor
{
-int GetLongPressTime(int defaultTime)
+namespace SystemSettings
+{
+std::string GetResourcePath()
{
- return defaultTime;
+ // "DALI_APPLICATION_PACKAGE" is used by Windows specifically to get the already configured Application package path.
+ const char* winEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
+ char* value = getenv(winEnvironmentVariable);
+ std::string resourcePath;
+ if(value != NULL)
+ {
+ resourcePath = value;
+ }
+
+ if(resourcePath.back() != '/')
+ {
+ resourcePath += "/";
+ }
+
+ return resourcePath;
}
-int GetElmAccessActionOver()
+std::string GetDataPath()
{
- return 0;
+ const char* winEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
+ char* value = getenv(winEnvironmentVariable);
+ std::string dataPath;
+ if(value != NULL)
+ {
+ dataPath = value;
+ }
+
+ return dataPath;
}
+} // namespace SystemSettings
+
} // namespace Adaptor
} // namespace Internal
SET( adaptor_windows_platform_src_files
${adaptor_thirdparty_dir}/windows-platform/dlfcn.cpp
- ${adaptor_thirdparty_dir}/windows-platform/environment.cpp
${adaptor_thirdparty_dir}/windows-platform/network.cpp
${adaptor_thirdparty_dir}/windows-platform/thread.cpp
${adaptor_thirdparty_dir}/windows-platform/Win32File/CustomFile.cpp
)
SET( adaptor_macos_platform_src_files
- ${adaptor_thirdparty_dir}/macos-platform/environment.cpp
${adaptor_thirdparty_dir}/macos-platform/thread.cpp
)
+++ /dev/null
-#include <cstdlib>
-#include <string>
-
-const char* app_get_data_path()
-{
- static std::string envValue;
-
- if( envValue.empty() )
- {
- envValue = std::getenv( "DemoData" );
- envValue += "/";
- }
-
- return envValue.c_str();
-}
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <memory>
#include <type_traits>
-const char* app_get_data_path();
-
// Specialiation of std::unique_ptr for Foundation Objects
template<typename T>
using CFRef = std::unique_ptr<
+++ /dev/null
-#include <cstdlib>
-#include <string>
-
-using namespace std;
-
-const char* app_get_data_path()
-{
- static std::string envValue = "";
-
- if( true == envValue.empty() )
- {
- envValue = std::getenv( "DemoData" );
- envValue += "/";
- }
-
- return envValue.c_str();
-}
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <xlocale>
-const char* app_get_data_path();
-
static int strncasecmp(const char *s1, const char *s2, register int n)
{
while (--n >= 0 && toupper((unsigned char)*s1) == toupper((unsigned char)*s2++))