add PauseLifeDurationTimer internal API for AppWidgetPopup
[platform/framework/native/appfw.git] / src / app / inc / FApp_ServiceAppImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FApp_ServiceAppImpl.h
20  * @brief       This is the header file for the %_ServiceAppImpl class.
21  */
22
23 #ifndef _FAPP_INTERNAL_SERVICE_APP_IMPL_H_
24 #define _FAPP_INTERNAL_SERVICE_APP_IMPL_H_
25
26 #include <app.h>
27
28 #include <FAppServiceApp.h>
29 #include <FBaseRtIEventListener.h>
30 #include <FBaseRtITimerEventListener.h>
31 #include "FApp_IAppImpl.h"
32
33 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
34 namespace Tizen { namespace Base { namespace Runtime
35 {
36 class Timer;
37 class IEventListener;
38 class _EventDispatcher;
39 }}}
40
41
42 namespace Tizen { namespace App
43 {
44
45 class _IAppEventListener;
46
47 /**
48  * @class       _ServiceAppImpl
49  * @brief       This class is the Impl class of a ServiceApp class.
50  * @since 2.1
51  *
52  * This class is the Impl class of a ServiceApp class.
53  */
54 class _OSP_EXPORT_ _ServiceAppImpl
55         : public Tizen::Base::Object
56         , public Tizen::App::_IAppImpl
57         , public Tizen::Base::Runtime::ITimerEventListener
58     , virtual public Tizen::Base::Runtime::IEventListener
59 {
60 public:
61         /**
62         * Returns the _ServiceAppImpl's instance pointer.
63         *
64         * @since 2.1
65         * @return       A pointer to the %_ServiceAppImpl instance, @n
66         *                       else @c null if it fails
67         */
68         static _ServiceAppImpl* GetInstance();
69
70         /**
71         * Returns the ServiceApp's instance pointer.
72         *
73         * @since 2.1
74         * @return       A pointer to the %ServiceApp instance, @n
75         *                       else @c null if it fails
76         */
77         ServiceApp* GetServiceAppInstance();
78
79
80         /**
81          * Called when the application is started
82          *
83          * @since 2.1
84          * @return      @c true if the method is successful, @n
85          *              else @c false
86          * @param[in]   user_data       The user data passed from the callback registration function
87          * @remarks     This is a system dependent callback function
88          */
89         virtual bool OnCreate(void);
90
91         /**
92          * Called when other application send the launch request to the application
93          *
94          * @since 2.1
95          * @param[in]   service The handle to the service
96          * @param[in]   user_data       The user data passed from the callback registration function
97          * @remarks     This is a system dependent callback function
98          */
99         virtual void OnService(service_s* service, bool initial);
100
101         /**
102          * Called when the application is completely obscured by another application and becomes invisible
103          *
104          * @since 2.1
105          * @param[in]   user_data       The user data passed from the callback registration function
106          * @remarks     This is a system dependent callback function
107          */
108         virtual void OnPause(void);
109
110         /**
111          * Called when the application becomes visible
112          *
113          * @since 2.1
114          * @param[in]   user_data       The user data passed from the callback registration function
115          * @remarks     This is a system dependent callback function
116          */
117         virtual void OnResume(void);
118
119         /**
120          * Called once after the main loop of application exits
121          *
122          * @since 2.1
123          * @param[in]   user_data       The user data passed from the callback registration function
124          * @remarks     This is a system dependent callback function
125          */
126         virtual void OnTerminate(void);
127
128         /**
129          * Called when an orintation event occurs.
130          *
131          * @since 2.1
132          * @param[in]   orientation     The information about the orientation event
133          */
134         virtual void OnDeviceOrientationChanged(app_device_orientation_e orientation);
135
136         /**
137          * Called when the application's state changes to Tizen::App::AppState::INITIALIZING. @n
138          *
139          * @since 2.1
140          * @return      @c true if the method is successful, @n
141          *              else @c false
142          */
143         virtual bool OnAppInitializing(void);
144
145         /**
146          * Called when the application's INITIALIZING state is finished
147          *
148          * @since 2.1
149          * @return      @c true if the method is successful, @n
150          *                      else @c false
151          */
152         virtual bool OnAppInitialized(void);
153
154         /**
155          * Called when the internal window handle is required.
156          *
157          * @since 2.1
158          */
159         virtual long OnWindowHandleRequest(void);
160
161         /**
162         * Called when the application's state change to Tizen::App::AppState::TERMINATING. @n
163         *
164         * @since 2.1
165         * @param[in]    forcedTermination       @c true if the application terminate by system or other application, else @c false.
166         * @return       @c true if the method is successful, @n
167         *               else @c false
168         */
169         bool OnServiceAppImplTerminating(bool forcedTermination);
170
171         /**
172          * Executes an application implemented by inheriting App class.
173          * This method must be called from the UiApp or ServiceApp.
174          *
175          * @since 2.1
176          * @return      An error code
177          * @exception   E_SUCCESS           The method is successful.
178          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
179          * @exception   E_OUT_OF_MEMORY     Insufficient memory.
180          * @exception   E_INIT_FAILED       The initialization failure during OnAppInitializing().
181          * @exception   E_SYSTEM            A system error has occurred.
182          */
183         result Execute(void);
184
185
186         void SetAppTerminatingInternalEventListener(_IAppEventListener* pListener);
187
188         void PauseLifeDurationTimer(void);
189
190         void ResumeLifeDurationTimer(void);
191
192 private:
193         /**
194          * This is the default constructor for this class.
195          *
196          * @since 2.1
197          */
198         _ServiceAppImpl(void);
199
200         /**
201          * This is the constructor for this class.
202          *
203          * @since 2.1
204          */
205         _ServiceAppImpl(ServiceApp* pServiceApp);
206
207         /**
208          * This is the copy constructor for the this class.
209          */
210         _ServiceAppImpl(const _ServiceAppImpl& source);
211
212         /**
213          * This is the assignment operator for this class.
214          */
215         _ServiceAppImpl& operator =(const _ServiceAppImpl& source);
216
217         /**
218          * This is the destructor for this class.
219          *
220          * @since 2.1
221          */
222         virtual ~_ServiceAppImpl(void);
223
224         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
225
226         void SetLifeDurationTimer(int lifeDuration);
227
228
229 private:
230         static _ServiceAppImpl* __pServiceAppImpl;
231
232         _AppImpl* __pAppImpl;
233
234         ServiceApp* __pServiceApp;
235
236         _IAppEventListener* __pAppTerminatingInternalEventListener;
237
238         Tizen::Base::Runtime::Timer* __pLifeDurationTimer;
239
240         int __lifeDuration;
241
242         bool __pauseLifeDurationTimer;
243
244         friend class ServiceApp;
245
246 }; // _ServiceAppImpl
247
248 } } //Tizen::App
249
250 #endif // _FAPP_INTERNAL_SERVICE_APP_IMPL_H_