Handled pre-resume scenario of watch application
[platform/core/uifw/dali-adaptor.git] / adaptors / wearable / watch-application-impl.h
1 #ifndef __DALI_INTERNAL_WATCH_APPLICATION_H__
2 #define __DALI_INTERNAL_WATCH_APPLICATION_H__
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <wearable/watch/watch-application.h>
23 #include <application-impl.h>
24
25 namespace Dali
26 {
27 class Adaptor;
28
29 namespace Internal
30 {
31
32 namespace Adaptor
33 {
34
35 class WatchApplication;
36 typedef IntrusivePtr<WatchApplication> WatchApplicationPtr;
37
38 enum WatchApplicationState
39 {
40   INITIALIZED,
41   PAUSED,
42   RESUMED = INITIALIZED,
43   TERMINATED
44 };
45
46 /**
47  * Implementation of the WatchApplication class.
48  */
49 class WatchApplication : public Application
50 {
51 public:
52   typedef Dali::WatchApplication::WatchTimeSignal WatchTimeSignal;
53   typedef Dali::WatchApplication::WatchBoolSignal WatchBoolSignal;
54
55   /**
56    * Create a new watch
57    * @param[in]  argc        A pointer to the number of arguments
58    * @param[in]  argv        A pointer to the argument list
59    * @param[in]  stylesheet  The path to user defined theme file
60    * @param[in]  windowMode  A member of Dali::Watch::WINDOW_MODE
61    */
62   static WatchApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
63
64   /**
65    * Private Constructor
66    * @param[in]  argc        A pointer to the number of arguments
67    * @param[in]  argv        A pointer to the argument list
68    * @param[in]  stylesheet  The path to user defined theme file
69    * @param[in]  windowMode  A member of Dali::Watch::WINDOW_MODE
70    */
71   WatchApplication( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode );
72
73   /**
74    * Destructor
75    */
76   virtual ~WatchApplication();
77
78   /**
79    * Called when the framework is initialised.
80    */
81   virtual void OnInit();
82
83   /**
84    * Called when the framework is terminated.
85    */
86   virtual void OnTerminate();
87
88   /**
89    * Called when the framework is paused.
90    */
91   virtual void OnPause();
92
93   /**
94    * Called when the framework resumes from a paused state.
95    */
96   virtual void OnResume();
97
98   /**
99    * Called every second
100    */
101   void OnTimeTick(WatchTime& time);
102
103   /**
104    * Called every second in ambient mode
105    */
106   void OnAmbientTick(WatchTime& time);
107
108   /**
109    * Called when the device enters or exits ambient mode
110    */
111   void OnAmbientChanged(bool ambient);
112
113 private:
114
115   // @brief Undefined copy constructor.
116   WatchApplication( const WatchApplication& );
117
118   // @brief Undefined assignment operator.
119   WatchApplication& operator=( const WatchApplication& );
120
121 public:
122
123   // Signals
124   WatchTimeSignal                        mTickSignal;
125   WatchTimeSignal                        mAmbientTickSignal;
126   WatchBoolSignal                        mAmbientChangeSignal;
127
128 private:
129   WatchApplicationState                  mState;
130 };
131
132 inline WatchApplication& GetImplementation(Dali::WatchApplication& watch)
133 {
134   DALI_ASSERT_ALWAYS(watch && "watch handle is empty");
135
136   BaseObject& handle = watch.GetBaseObject();
137
138   return static_cast<Internal::Adaptor::WatchApplication&>(handle);
139 }
140
141 inline const WatchApplication& GetImplementation(const Dali::WatchApplication& watch)
142 {
143   DALI_ASSERT_ALWAYS(watch && "Time handle is empty");
144
145   const BaseObject& handle = watch.GetBaseObject();
146
147   return static_cast<const Internal::Adaptor::WatchApplication&>(handle);
148 }
149
150
151 } // namespace Adaptor
152
153 } // namespace Internal
154
155 } // namespace Dali
156
157 #endif // __DALI_INTERNAL_WATCH_APPLICATION_H__