/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
int* argc,
char **argv[],
const std::string& stylesheet,
- Dali::Application::WINDOW_MODE windowMode)
+ Dali::Application::WINDOW_MODE windowMode,
+ Framework::Type applicationType)
{
- ApplicationPtr application ( new Application (argc, argv, stylesheet, windowMode ) );
+ ApplicationPtr application ( new Application (argc, argv, stylesheet, windowMode, applicationType ) );
return application;
}
-Application::Application( int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode )
+Application::Application( int* argc, char** argv[], const std::string& stylesheet,
+ Dali::Application::WINDOW_MODE windowMode, Framework::Type applicationType )
: mInitSignal(),
mTerminateSignal(),
mPauseSignal(),
}
mCommandLineOptions = new CommandLineOptions(argc, argv);
-
- mFramework = new Framework( *this, argc, argv );
+ mFramework = new Framework( *this, argc, argv, applicationType );
}
Application::~Application()
#define __DALI_INTERNAL_APPLICATION_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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 Application : public BaseObject, public Framework::Observer
{
public:
-
typedef Dali::Application::AppSignalType AppSignalType;
typedef Dali::Application::AppControlSignalType AppControlSignalType;
typedef Dali::Application::WINDOW_MODE WINDOW_MODE;
* @param[in] argv A pointer to the argument list
* @param[in] stylesheet The path to user defined theme file
* @param[in] windowMode A member of Dali::Application::WINDOW_MODE
+ * @param[in] applicationType A member of Dali::Framework::Type
*/
- static ApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
+ static ApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet,
+ WINDOW_MODE windowMode, Framework::Type applicationType );
public:
*/
Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
-private:
+protected:
/**
* Private Constructor
* @param[in] stylesheet The path to user defined theme file
* @param[in] windowMode A member of Dali::Application::WINDOW_MODE
*/
- Application( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
+ Application( int* argc, char **argv[], const std::string& stylesheet,
+ WINDOW_MODE windowMode, Framework::Type applicationType );
/**
* Destructor
Application(const Application&);
Application& operator=(Application&);
-private:
/**
* Creates the window
*/
$(adaptor_common_dir)/style-monitor-impl.cpp \
$(adaptor_common_dir)/trigger-event.cpp \
$(adaptor_common_dir)/trigger-event-factory.cpp \
+ $(adaptor_common_dir)/watch-application-impl.cpp \
+ $(adaptor_common_dir)/watch-time.cpp \
$(adaptor_common_dir)/key-impl.cpp \
\
$(adaptor_common_dir)/events/gesture-manager.cpp \
#define __DALI_INTERNAL_FRAMEWORK_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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>
#include <dali/public-api/signals/callback.h>
+#include <watch-application.h>
// INTERNAL INCLUDES
-#include "abort-handler.h"
+#include <abort-handler.h>
namespace Dali
{
class Framework
{
public:
+ enum Type
+ {
+ NORMAL, ///< normal appFramework
+ WATCH ///< watch appFramework
+ };
/**
* Observer class for the framework.
virtual void OnAppControl(void *) {}
/**
+ * Invoked at every second
+ */
+ virtual void OnTimeTick(WatchTime&) {}
+
+ /**
+ * Invoked at every second in ambient mode
+ */
+ virtual void OnAmbientTick(WatchTime&) {}
+
+ /**
+ * Invoked when the device enters or exits ambient mode
+ */
+ virtual void OnAmbientChanged(bool ambient) {}
+
+ /**
* Invoked when the language of the device is changed.
*/
virtual void OnLanguageChanged() {}
* @param[in] observer The observer of the Framework.
* @param[in] argc A pointer to the number of arguments.
* @param[in] argv A pointer the the argument list.
+ * @param[in] type The type of application
*/
- Framework( Observer& observer, int* argc, char ***argv );
+ Framework( Observer& observer, int* argc, char ***argv, Type type = NORMAL );
/**
* Destructor
Framework& operator=(Framework&);
private:
+
+ /**
+ * Called when the application is created.
+ */
+ bool Create();
+
/**
* Called by the App framework when an application lifecycle event occurs.
* @param[in] type The type of event occurred.
struct Impl;
Impl* mImpl;
-
};
} // namespace Adaptor
--- /dev/null
+/*
+ * Copyright (c) 2016 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 "watch-application-impl.h"
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+WatchApplicationPtr WatchApplication::New(
+ int* argc,
+ char **argv[],
+ const std::string& stylesheet,
+ Dali::WatchApplication::WINDOW_MODE windowMode)
+{
+ WatchApplicationPtr watch ( new WatchApplication (argc, argv, stylesheet, windowMode ) );
+ return watch;
+}
+
+WatchApplication::WatchApplication( int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode )
+: Application(argc, argv, stylesheet, windowMode, Framework::WATCH)
+{
+}
+
+WatchApplication::~WatchApplication()
+{
+}
+
+void WatchApplication::OnTimeTick(WatchTime& time)
+{
+ Dali::WatchApplication watch(this);
+ mTickSignal.Emit( watch, time );
+}
+
+void WatchApplication::OnAmbientTick(WatchTime& time)
+{
+ Dali::WatchApplication watch(this);
+ mAmbientTickSignal.Emit( watch, time );
+}
+
+void WatchApplication::OnAmbientChanged(bool ambient)
+{
+ Dali::WatchApplication watch(this);
+ mAmbientChangeSignal.Emit( watch, ambient );
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_WATCH_APPLICATION_H__
+#define __DALI_INTERNAL_WATCH_APPLICATION_H__
+
+/*
+ * Copyright (c) 2016 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 <watch-application.h>
+#include <application-impl.h>
+
+namespace Dali
+{
+class Adaptor;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class WatchApplication;
+typedef IntrusivePtr<WatchApplication> WatchApplicationPtr;
+
+/**
+ * Implementation of the WatchApplication class.
+ */
+class WatchApplication : public Application
+{
+public:
+ typedef Dali::WatchApplication::WatchTimeSignal WatchTimeSignal;
+ typedef Dali::WatchApplication::WatchBoolSignal WatchBoolSignal;
+
+ /**
+ * Create a new watch
+ * @param[in] argc A pointer to the number of arguments
+ * @param[in] argv A pointer to the argument list
+ * @param[in] stylesheet The path to user defined theme file
+ * @param[in] windowMode A member of Dali::Watch::WINDOW_MODE
+ */
+ static WatchApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
+
+ /**
+ * Private Constructor
+ * @param[in] argc A pointer to the number of arguments
+ * @param[in] argv A pointer to the argument list
+ * @param[in] stylesheet The path to user defined theme file
+ * @param[in] windowMode A member of Dali::Watch::WINDOW_MODE
+ */
+ WatchApplication( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
+
+ /**
+ * Destructor
+ */
+ virtual ~WatchApplication();
+
+ /**
+ * Called every second
+ */
+ void OnTimeTick(WatchTime& time);
+
+ /**
+ * Called every second in ambient mode
+ */
+ void OnAmbientTick(WatchTime& time);
+
+ /**
+ * Called when the device enters or exits ambient mode
+ */
+ void OnAmbientChanged(bool ambient);
+
+private:
+
+ // @brief Undefined copy constructor.
+ WatchApplication( const WatchApplication& );
+
+ // @brief Undefined assignment operator.
+ WatchApplication& operator=( const WatchApplication& );
+
+public:
+
+ // Signals
+ WatchTimeSignal mTickSignal;
+ WatchTimeSignal mAmbientTickSignal;
+ WatchBoolSignal mAmbientChangeSignal;
+};
+
+inline WatchApplication& GetImplementation(Dali::WatchApplication& watch)
+{
+ DALI_ASSERT_ALWAYS(watch && "watch handle is empty");
+
+ BaseObject& handle = watch.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::WatchApplication&>(handle);
+}
+
+inline const WatchApplication& GetImplementation(const Dali::WatchApplication& watch)
+{
+ DALI_ASSERT_ALWAYS(watch && "Time handle is empty");
+
+ const BaseObject& handle = watch.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::WatchApplication&>(handle);
+}
+
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_WATCH_APPLICATION_H__
--- /dev/null
+/*
+ * Copyright (c) 2016 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 <watch-time.h>
+
+// EXTERNAL INCLUDES
+#ifdef APPCORE_WATCH_AVAILABLE
+#include <appcore-watch/watch_app.h>
+#endif
+
+namespace Dali
+{
+
+struct WatchTime::Impl
+{
+ Impl(void *time_handle)
+ : mTimeHandle(time_handle)
+ {
+ }
+
+ void *mTimeHandle;
+};
+
+WatchTime::WatchTime()
+ :mImpl(NULL)
+{
+}
+
+WatchTime::WatchTime(void *time_handle)
+{
+ mImpl = new Impl(time_handle);
+}
+
+WatchTime::~WatchTime()
+{
+ if( mImpl )
+ {
+ delete mImpl;
+ mImpl = NULL;
+ }
+}
+
+#ifdef APPCORE_WATCH_AVAILABLE
+
+int WatchTime::GetHour() const
+{
+ int hour;
+
+ watch_time_get_hour(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour);
+ return hour;
+}
+
+int WatchTime::GetHour24() const
+{
+ int hour24;
+
+ watch_time_get_hour24(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &hour24);
+ return hour24;
+}
+
+int WatchTime::GetMinute() const
+{
+ int minute;
+
+ watch_time_get_minute(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &minute);
+ return minute;
+}
+
+int WatchTime::GetSecond() const
+{
+ int second;
+
+ watch_time_get_second(reinterpret_cast<watch_time_h>(mImpl->mTimeHandle), &second);
+ return second;
+}
+
+#else
+
+int WatchTime::GetHour() const
+{
+ return 0;
+}
+
+int WatchTime::GetHour24() const
+{
+ return 0;
+}
+
+int WatchTime::GetMinute() const
+{
+ return 0;
+}
+
+int WatchTime::GetSecond() const
+{
+ return 0;
+}
+
+#endif
+
+} // namespace Dali
Impl& operator=( const Impl& impl );
};
-Framework::Framework( Framework::Observer& observer, int *argc, char ***argv )
+Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
: mObserver(observer),
mInitialised(false),
mRunning(false),
Application Application::New( int* argc, char **argv[] )
{
- Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "", OPAQUE );
+ Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "", OPAQUE,
+ Internal::Adaptor::Framework::NORMAL);
return Application(internal.Get());
}
Application Application::New( int* argc, char **argv[], const std::string& stylesheet )
{
- Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, OPAQUE );
+ Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, OPAQUE,
+ Internal::Adaptor::Framework::NORMAL);
return Application(internal.Get());
}
Application Application::New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode )
{
- Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode );
+ Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode,
+ Internal::Adaptor::Framework::NORMAL);
return Application(internal.Get());
}
--- /dev/null
+/*
+ * Copyright (c) 2016 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 <watch-application.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <watch-application-impl.h>
+
+namespace Dali
+{
+
+WatchApplication WatchApplication::New()
+{
+ return New( NULL, NULL );
+}
+
+WatchApplication WatchApplication::New( int* argc, char **argv[] )
+{
+ Internal::Adaptor::WatchApplicationPtr internal = Internal::Adaptor::WatchApplication::New( argc, argv, "", OPAQUE );
+ return WatchApplication(internal.Get());
+}
+
+WatchApplication WatchApplication::New( int* argc, char **argv[], const std::string& stylesheet )
+{
+ Internal::Adaptor::WatchApplicationPtr internal = Internal::Adaptor::WatchApplication::New( argc, argv, stylesheet, OPAQUE );
+ return WatchApplication(internal.Get());
+}
+
+WatchApplication::~WatchApplication()
+{
+}
+
+WatchApplication::WatchApplication()
+{
+}
+
+WatchApplication::WatchApplication(const WatchApplication& implementation)
+: Application(implementation)
+{
+}
+
+WatchApplication& WatchApplication::operator=(const WatchApplication& application)
+{
+ if( *this != application )
+ {
+ BaseHandle::operator=( application );
+ }
+ return *this;
+}
+
+WatchApplication::WatchTimeSignal& WatchApplication::TimeTickSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).mTickSignal;
+}
+
+WatchApplication::WatchTimeSignal& WatchApplication::AmbientTickSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).mAmbientTickSignal;
+}
+
+WatchApplication::WatchBoolSignal& WatchApplication::AmbientChangedSignal()
+{
+ return Internal::Adaptor::GetImplementation(*this).mAmbientChangeSignal;
+}
+
+WatchApplication::WatchApplication(Internal::Adaptor::WatchApplication* implementation)
+: Application(implementation)
+{
+}
+
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_WATCH_APPLICATION_H__
+#define __DALI_WATCH_APPLICATION_H__
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/signals/callback.h>
+
+// INTERNAL INCLUDES
+#include "application.h"
+#include "watch-time.h"
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class WatchApplication;
+}
+}
+
+/**
+ * @brief A WatchApplication class object should be created by every watch application
+ * that wishes to use Dali.
+ *
+ * It provides a means for initialising the resources required by the Dali::Core.
+ * Like Application class, the WatchApplication class manages Tizen watch application life cycle.
+ *
+ * The WatchApplication class emits additional signals which are availalble only in the watch application
+ * (TimeTick, AmbientTick, AmbientChanged)
+ *
+ * This feature is supported in wearable applications only.
+ *
+ * WatchApplication should follow the example below:
+ *
+ * @code
+ * class ExampleController: public ConnectionTracker
+ * {
+ * public:
+ * ExampleController( WatchApplication& application )
+ * : mApplication( application )
+ * {
+ * mApplication.InitSignal().Connect( this, &ExampleController::Create );
+ * }
+ *
+ * void Create( Application& application )
+ * {
+ * // Create Dali components...
+ * }
+ * ...
+ * private:
+ * WatchApplication& mApplication;
+ * };
+ *
+ * int DALI_EXPORT_API main (int argc, char **argv)
+ * {
+ * WatchApplication app = WatchApplication::New(&argc, &argv);
+ * ExampleController example( app );
+ * app.MainLoop();
+ * }
+ * @endcode
+ *
+ * If required, you can also connect class member functions to a signal:
+ *
+ * @code
+ * MyApplication app;
+ * app.ResumeSignal().Connect(&app, &MyApplication::Resume);
+ * @endcode
+ *
+ * When the above options are found, they are stripped from argv, and argc is updated appropriately.
+ * @SINCE_1_1.36
+ */
+
+class DALI_IMPORT_API WatchApplication : public Application
+{
+public:
+ typedef Signal< void (Application&, const WatchTime &) > WatchTimeSignal; ///< Watch pointer signal callback type @SINCE_1_1.36
+ typedef Signal< void (Application&, bool) > WatchBoolSignal; ///< Watch bool signal callback type @SINCE_1_1.36
+
+public:
+
+ /**
+ * @brief This is the constructor for applications without an argument list.
+ * @SINCE_1_1.36
+ */
+ static WatchApplication New();
+
+ /**
+ * @brief This is the constructor for applications.
+ *
+ * @SINCE_1_1.36
+ * @param[in,out] argc A pointer to the number of arguments
+ * @param[in,out] argv A pointer the the argument list
+ */
+ static WatchApplication New( int* argc, char **argv[] );
+
+ /**
+ * @brief This is the constructor for applications with a name
+ *
+ * @SINCE_1_1.36
+ * @param[in,out] argc A pointer to the number of arguments
+ * @param[in,out] argv A pointer the the argument list
+ * @param[in] stylesheet The path to user defined theme file
+ */
+ static WatchApplication New( int* argc, char **argv[], const std::string& stylesheet );
+
+ /**
+ * @brief Construct an empty handle
+ * @SINCE_1_1.36
+ */
+ WatchApplication();
+
+ /**
+ * @brief Copy Constructor
+ * @SINCE_1_1.36
+ */
+ WatchApplication( const WatchApplication& implementation );
+
+ /**
+ * @brief Assignment operator
+ * @SINCE_1_1.36
+ */
+ WatchApplication& operator=( const WatchApplication& applicaton );
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ * @SINCE_1_1.36
+ */
+ ~WatchApplication();
+
+public:
+ /**
+ * @brief This signal is emitted at every second
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(Application& application, WatchTimeSignal &time);
+ * @endcode
+ * time(watch time handle) will not be available after returning this callback. It will be freed by the framework.
+ * @SINCE_1_1.36
+ */
+ WatchTimeSignal& TimeTickSignal();
+
+ /**
+ * @brief This signal is emitted at every second in ambient mode
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(Application& application, WatchTimeSignal &time);
+ * @endcode
+ * time(watch time handle) will not be available after returning this callback. It will be freed by the framework.
+ * @SINCE_1_1.36
+ */
+ WatchTimeSignal& AmbientTickSignal();
+
+ /**
+ * @brief This signal is emitted when the device enters or exits ambient mode
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(Application& application, bool ambient);
+ * @endcode
+ * ambient_mode If true the device enters the ambient mode, otherwise false
+ * @SINCE_1_1.36
+ */
+ WatchBoolSignal& AmbientChangedSignal();
+
+public: // Not intended for application developers
+ /**
+ * @brief Internal constructor
+ * @SINCE_1_1.36
+ */
+ explicit DALI_INTERNAL WatchApplication(Internal::Adaptor::WatchApplication* implementation);
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // __DALI_WATCH_APPLICATION_H__
--- /dev/null
+#ifndef __DALI_WATCH_TIME_H__
+#define __DALI_WATCH_TIME_H__
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-core.h>
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+/**
+ * @brief The WatchTime class is used to get time for the WatchApplication.
+ *
+ * A WatchTime has a time handle from watch application framework.
+ * You can get time(hour, minute, second) on receiving timeTick signal
+ * @SINCE_1_1.36
+ */
+class DALI_IMPORT_API WatchTime
+{
+public:
+
+ /**
+ * @brief Constructor
+ * @SINCE_1_1.36
+ */
+ WatchTime();
+
+ /**
+ * @brief Destructor
+ * @SINCE_1_1.36
+ */
+ ~WatchTime();
+
+ /**
+ * @brief return current hour
+ *
+ * @SINCE_1_1.36
+ * @pre The WatchTime needs to be initialized.
+ */
+ int GetHour() const;
+
+ /**
+ * @brief return current hour24
+ *
+ * @SINCE_1_1.36
+ * @pre The WatchTime needs to be initialized.
+ */
+ int GetHour24() const;
+
+ /**
+ * @brief return current minute
+ *
+ * @SINCE_1_1.36
+ * @pre The WatchTime needs to be initialized.
+ */
+ int GetMinute() const;
+
+ /**
+ * @brief return current second
+ *
+ * @SINCE_1_1.36
+ * @pre The WatchTime needs to be initialized.
+ */
+ int GetSecond() const;
+
+public: // Not intended for application developers
+ DALI_INTERNAL WatchTime(void *time_handle);
+
+private: // Internal Data
+
+ struct Impl;
+ Impl* mImpl;
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // __DALI_WATCH_TIME_H__
#include <dali/public-api/adaptor-framework/timer.h>
#include <dali/public-api/adaptor-framework/tts-player.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/adaptor-framework/watch-application.h>
#include <dali/public-api/dali-adaptor-version.h>
#endif //__DALI_H__
$(adaptor_public_api_dir)/adaptor-framework/timer.cpp \
$(adaptor_public_api_dir)/adaptor-framework/tts-player.cpp \
$(adaptor_public_api_dir)/adaptor-framework/native-image-source.cpp \
+ $(adaptor_public_api_dir)/adaptor-framework/watch-application.cpp \
$(adaptor_public_api_dir)/dali-adaptor-version.cpp
$(adaptor_public_api_dir)/adaptor-framework/timer.h \
$(adaptor_public_api_dir)/adaptor-framework/tts-player.h \
$(adaptor_public_api_dir)/adaptor-framework/native-image-source.h \
- $(adaptor_public_api_dir)/adaptor-framework/window.h
+ $(adaptor_public_api_dir)/adaptor-framework/window.h \
+ $(adaptor_public_api_dir)/adaptor-framework/watch-application.h \
+ $(adaptor_public_api_dir)/adaptor-framework/watch-time.h
adaptor_dali_header_file = \
$(adaptor_public_api_dir)/dali.h
#include <bundle.h>
#include <Ecore.h>
-#ifndef TIZEN_SDK_2_2_COMPATIBILITY
#include <system_info.h>
#include <app_control_internal.h>
#include <bundle_internal.h>
+#ifdef APPCORE_WATCH_AVAILABLE
+#include <appcore-watch/watch_app.h>
#endif
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
#include <callback-manager.h>
+#include <watch-application-impl.h>
+#include <watch-time.h>
namespace Dali
{
namespace Adaptor
{
-namespace
-{
-
-/// Application Status Enum
-enum
-{
- APP_CREATE,
- APP_TERMINATE,
- APP_PAUSE,
- APP_RESUME,
- APP_RESET,
- APP_CONTROL,
- APP_LANGUAGE_CHANGE,
- APP_DEVICE_ROTATED,
- APP_REGION_CHANGED,
- APP_BATTERY_LOW,
- APP_MEMORY_LOW
-};
-
-} // Unnamed namespace
-
/**
* Impl to hide EFL data members
*/
struct Framework::Impl
{
- // Constructor
-
- Impl(void* data)
+// Constructor
+ Impl(void* data, Type type )
: mAbortCallBack( NULL ),
mCallbackManager( NULL )
{
- mEventCallback.create = AppCreate;
- mEventCallback.terminate = AppTerminate;
- mEventCallback.pause = AppPause;
- mEventCallback.resume = AppResume;
-
-#ifdef TIZEN_SDK_2_2_COMPATIBILITY
- mEventCallback.service = AppService;
-
- mEventCallback.low_memory = NULL;
- mEventCallback.low_battery = NULL;
- mEventCallback.device_orientation = AppDeviceRotated;
- mEventCallback.language_changed = AppLanguageChanged;
- mEventCallback.region_format_changed = NULL;
-
-#else
- mEventCallback.app_control = AppControl;
+ mFramework = static_cast<Framework*>(data);
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, AppBatteryLow, data);
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, AppMemoryLow, data);
- ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, data);
- ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, AppLanguageChanged, data);
- ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, AppRegionChanged, data);
+#ifndef APPCORE_WATCH_AVAILABLE
+ if ( type == WATCH )
+ {
+ throw Dali::DaliException( "", "Watch Application is not supported." );
+ }
#endif
-
+ mApplicationType = type;
mCallbackManager = CallbackManager::New();
}
delete mCallbackManager;
}
- // Data
+ int AppMain()
+ {
+ int ret;
+
+ if (mApplicationType == NORMAL)
+ {
+ ret = AppNormalMain();
+ }
+ else
+ {
+ ret = AppWatchMain();
+ }
+ return ret;
+ }
+ void AppExit()
+ {
+ if (mApplicationType == NORMAL)
+ {
+ AppNormalExit();
+ }
+ else
+ {
+ AppWatchExit();
+ }
+ }
+
+
+ // Data
+ Type mApplicationType;
CallbackBase* mAbortCallBack;
CallbackManager *mCallbackManager;
-#ifdef TIZEN_SDK_2_2_COMPATIBILITY
- app_event_callback_s mEventCallback;
-#else
- ui_app_lifecycle_callback_s mEventCallback;
+ Framework* mFramework;
app_event_handler_h handlers[5];
+ ui_app_lifecycle_callback_s mEventCallback;
+#ifdef APPCORE_WATCH_AVAILABLE
+ watch_app_lifecycle_callback_s mWatchCallback;
#endif
- /**
- * Called by AppCore on application creation.
- */
static bool AppCreate(void *data)
{
- return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);
+ return static_cast<Framework*>(data)->Create();
}
- /**
- * Called by AppCore when the application should terminate.
- */
static void AppTerminate(void *data)
{
- static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+
+ observer->OnTerminate();
}
- /**
- * Called by AppCore when the application is paused.
- */
static void AppPause(void *data)
{
- static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+
+ observer->OnPause();
}
- /**
- * Called by AppCore when the application is resumed.
- */
static void AppResume(void *data)
{
- static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+
+ observer->OnResume();
}
static void ProcessBundle(Framework* framework, bundle *bundleData)
}
}
-#ifdef TIZEN_SDK_2_2_COMPATIBILITY
/**
* Called by AppCore when the application is launched from another module (e.g. homescreen).
* @param[in] b the bundle data which the launcher module sent
*/
- static void AppService(service_h service, void *data)
+ static void AppControl(app_control_h app_control, void *data)
{
Framework* framework = static_cast<Framework*>(data);
-
- if(framework == NULL)
- {
- return;
- }
+ Observer *observer = &framework->mObserver;
bundle *bundleData = NULL;
- service_to_bundle(service, &bundleData);
+ app_control_to_bundle(app_control, &bundleData);
ProcessBundle(framework, bundleData);
- framework->AppStatusHandler(APP_RESET, NULL);
+ observer->OnReset();
+ observer->OnAppControl(app_control);
}
- static void AppLanguageChanged(void* user_data)
+ int AppNormalMain()
{
- static_cast<Framework*>(user_data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
+ int ret;
+
+ mEventCallback.create = AppCreate;
+ mEventCallback.terminate = AppTerminate;
+ mEventCallback.pause = AppPause;
+ mEventCallback.resume = AppResume;
+ mEventCallback.app_control = AppControl;
+
+ ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, AppBatteryLow, mFramework);
+ ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, AppMemoryLow, mFramework);
+ ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, mFramework);
+ ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
+ ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
+
+ ret = ui_app_main(*mFramework->mArgc, *mFramework->mArgv, &mEventCallback, mFramework);
+
+ return ret;
}
- static void AppDeviceRotated(app_device_orientation_e orientation, void *user_data)
+ void AppNormalExit()
{
- static_cast<Framework*>(user_data)->AppStatusHandler(APP_DEVICE_ROTATED, NULL);
+ ui_app_exit();
}
-#else
- /**
- * Called by AppCore when the application is launched from another module (e.g. homescreen).
- * @param[in] b the bundle data which the launcher module sent
- */
- static void AppControl(app_control_h app_control, void *data)
+
+#ifdef APPCORE_WATCH_AVAILABLE
+ static bool AppCreateWatch(int width, int height, void *data)
{
- Framework* framework = static_cast<Framework*>(data);
- if(framework == NULL)
- {
- return;
- }
- bundle *bundleData = NULL;
+ return static_cast<Framework*>(data)->Create();
+ }
- app_control_to_bundle(app_control, &bundleData);
- ProcessBundle(framework, bundleData);
+ static void AppTimeTick(watch_time_h time, void *data)
+ {
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ WatchTime curTime(time);
- framework->AppStatusHandler(APP_RESET, NULL);
- framework->AppStatusHandler(APP_CONTROL, app_control);
+ observer->OnTimeTick(curTime);
}
- static void AppLanguageChanged(app_event_info_h event_info, void *user_data)
+ static void AppAmbientTick(watch_time_h time, void *data)
{
- static_cast<Framework*>(user_data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ WatchTime curTime(time);
+
+ observer->OnAmbientTick(curTime);
}
- static void AppDeviceRotated(app_event_info_h event_info, void *user_data)
+ static void AppAmbientChanged(bool ambient, void *data)
{
- static_cast<Framework*>(user_data)->AppStatusHandler(APP_DEVICE_ROTATED, NULL);
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+
+ observer->OnAmbientChanged(ambient);
}
+#endif
- static void AppRegionChanged(app_event_info_h event_info, void *user_data)
+ int AppWatchMain()
{
- static_cast<Framework*>(user_data)->AppStatusHandler(APP_REGION_CHANGED, NULL);
+ int ret = true;
+
+#ifdef APPCORE_WATCH_AVAILABLE
+ mWatchCallback.create = AppCreateWatch;
+ mWatchCallback.app_control = AppControl;
+ mWatchCallback.terminate = AppTerminate;
+ mWatchCallback.pause = AppPause;
+ mWatchCallback.resume = AppResume;
+ mWatchCallback.time_tick = AppTimeTick;
+ mWatchCallback.ambient_tick = AppAmbientTick;
+ mWatchCallback.ambient_changed = AppAmbientChanged;
+
+ watch_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, AppBatteryLow, mFramework);
+ watch_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, AppMemoryLow, mFramework);
+ watch_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
+ watch_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
+
+ ret = watch_app_main(*mFramework->mArgc, *mFramework->mArgv, &mWatchCallback, mFramework);
+#endif
+ return ret;
}
- static void AppBatteryLow(app_event_info_h event_info, void *user_data)
+ void AppWatchExit()
{
- static_cast<Framework*>(user_data)->AppStatusHandler(APP_BATTERY_LOW, NULL);
+#ifdef APPCORE_WATCH_AVAILABLE
+ watch_app_exit();
+#endif
}
- static void AppMemoryLow(app_event_info_h event_info, void *user_data)
+ static void AppLanguageChanged(app_event_info_h event, void *data)
{
- static_cast<Framework*>(user_data)->AppStatusHandler(APP_MEMORY_LOW, NULL);
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+
+ observer->OnLanguageChanged();
+ }
+
+ static void AppDeviceRotated(app_event_info_h event_info, void *data)
+ {
+ }
+
+ static void AppRegionChanged(app_event_info_h event, void *data)
+ {
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+
+ observer->OnRegionChanged();
+ }
+
+ static void AppBatteryLow(app_event_info_h event, void *data)
+ {
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+
+ observer->OnBatteryLow();
+ }
+
+ static void AppMemoryLow(app_event_info_h event, void *data)
+ {
+ Observer *observer = &static_cast<Framework*>(data)->mObserver;
+
+ observer->OnMemoryLow();
}
-#endif
private:
// Undefined
Impl& operator=( const Impl& impl );
};
-Framework::Framework( Framework::Observer& observer, int *argc, char ***argv )
+Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
: mObserver(observer),
mInitialised(false),
mRunning(false),
mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
mImpl(NULL)
{
-
-#ifndef TIZEN_SDK_2_2_COMPATIBILITY
bool featureFlag = true;
system_info_get_platform_bool( "tizen.org/feature/opengles.version.2_0", &featureFlag );
set_last_result( TIZEN_ERROR_NOT_SUPPORTED );
throw Dali::DaliException( "", "OpenGL ES 2.0 is not supported." );
}
-#endif
-
InitThreads();
- mImpl = new Impl(this);
+
+ mImpl = new Impl(this, type);
}
Framework::~Framework()
delete mImpl;
}
+bool Framework::Create()
+{
+ mInitialised = true;
+ mObserver.OnInit();
+ return true;
+}
+
void Framework::Run()
{
mRunning = true;
+ int ret;
-#ifdef TIZEN_SDK_2_2_COMPATIBILITY
- app_efl_main(mArgc, mArgv, &mImpl->mEventCallback, this);
-#else
- int ret = ui_app_main(*mArgc, *mArgv, &mImpl->mEventCallback, this);
+ ret = mImpl->AppMain();
if (ret != APP_ERROR_NONE)
{
DALI_LOG_ERROR("Framework::Run(), ui_app_main() is failed. err = %d", ret);
}
-#endif
-
mRunning = false;
}
void Framework::Quit()
{
-#ifdef TIZEN_SDK_2_2_COMPATIBILITY
- app_efl_exit();
-#else
- ui_app_exit();
-#endif
+ mImpl->AppExit();
}
bool Framework::IsMainLoopRunning()
}
}
-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_CONTROL:
- {
- mObserver.OnAppControl(bundleData);
- break;
- }
-
- case APP_LANGUAGE_CHANGE:
- {
- mObserver.OnLanguageChanged();
- break;
- }
-
- case APP_REGION_CHANGED:
- {
- mObserver.OnRegionChanged();
- break;
- }
-
- case APP_BATTERY_LOW:
- {
- mObserver.OnBatteryLow();
- break;
- }
-
- case APP_MEMORY_LOW:
- {
- mObserver.OnMemoryLow();
- break;
- }
-
- default:
- break;
- }
-
- return true;
-}
-
} // namespace Adaptor
} // namespace Internal
};
-Framework::Framework( Framework::Observer& observer, int *argc, char ***argv )
+Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
: mObserver(observer),
mInitialised(false),
mRunning(false),
$(HARFBUZZ_LIBS) \
$(TPKP_CURL_LIBS) \
$(UTILX_LIBS) \
+ $(APPCORE_WATCH_LIBS) \
-lgif \
-lpthread \
-lturbojpeg \
[ AC_MSG_NOTICE([Tizen Trace not avaiable]) ]
)
-
# Currently, dali-adaptor always requires EFL on all platforms.
# (on Wayland & X11, on Tizen devices & Ubuntu PC).
enable_efl=yes
if test "x$enable_profile" = "xWEARABLE"; then
PKG_CHECK_MODULES(OPENGLES20, glesv2)
+PKG_CHECK_MODULES(APPFW_WATCH, capi-appfw-watch-application,
+ [watch_available=yes], [watch_available=no] )
+PKG_CHECK_MODULES(APPCORE_WATCH, appcore-watch)
+if test "x$watch_available" = "xyes"; then
+ DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DAPPCORE_WATCH_AVAILABLE"
+fi
fi
if test "x$enable_profile" = "xTV"; then
%define dali_feedback_plugin 0
%define shaderbincache_flag DISABLE
BuildRequires: pkgconfig(gles20)
+BuildRequires: pkgconfig(capi-appfw-watch-application)
+BuildRequires: pkgconfig(appcore-watch)
%define gles_requirement_setup 1
%endif