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