Fix the boiler plate codes
[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 an orintation event occurs.
129          *
130          * @since 2.1
131          * @param[in]   orientation     The information about the orientation event
132          */
133         virtual void OnDeviceOrientationChanged(app_device_orientation_e orientation);
134
135         /**
136          * Called when the application's state changes to Tizen::App::AppState::INITIALIZING. @n
137          *
138          * @since 2.1
139          * @return      @c true if the method is successful, @n
140          *              else @c false
141          */
142         virtual bool OnAppInitializing(void);
143
144         /**
145          * Called when the application's INITIALIZING state is finished
146          *
147          * @since 2.1
148          * @return      @c true if the method is successful, @n
149          *                      else @c false
150          */
151         virtual bool OnAppInitialized(void);
152
153         /**
154          * Called when the internal window handle is required.
155          *
156          * @since 2.1
157          */
158         virtual long OnWindowHandleRequest(void);
159
160         /**
161         * Called when the application's state change to Tizen::App::AppState::TERMINATING. @n
162         *
163         * @since 2.1
164         * @param[in]    forcedTermination       @c true if the application terminate by system or other application, else @c false.
165         * @return       @c true if the method is successful, @n
166         *               else @c false
167         */
168         bool OnServiceAppImplTerminating(bool forcedTermination);
169
170         /**
171          * Executes an application implemented by inheriting App class.
172          * This method must be called from the UiApp or ServiceApp.
173          *
174          * @since 2.1
175          * @return      An error code
176          * @exception   E_SUCCESS           The method is successful.
177          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
178          * @exception   E_OUT_OF_MEMORY     Insufficient memory.
179          * @exception   E_INIT_FAILED       The initialization failure during OnAppInitializing().
180          * @exception   E_SYSTEM            A system error has occurred.
181          */
182         result Execute(void);
183
184
185         void SetAppTerminatingInternalEventListener(_IAppEventListener* pListener);
186
187         void PauseLifeDurationTimer(void);
188
189         void ResumeLifeDurationTimer(void);
190
191 private:
192         /**
193          * This is the default constructor for this class.
194          *
195          * @since 2.1
196          */
197         _ServiceAppImpl(void);
198
199         /**
200          * This is the constructor for this class.
201          *
202          * @since 2.1
203          */
204         _ServiceAppImpl(ServiceApp* pServiceApp);
205
206         /**
207          * This is the copy constructor for the this class.
208          */
209         _ServiceAppImpl(const _ServiceAppImpl& source);
210
211         /**
212          * This is the assignment operator for this class.
213          */
214         _ServiceAppImpl& operator =(const _ServiceAppImpl& source);
215
216         /**
217          * This is the destructor for this class.
218          *
219          * @since 2.1
220          */
221         virtual ~_ServiceAppImpl(void);
222
223         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
224
225         void SetLifeDurationTimer(int lifeDuration);
226
227
228 private:
229         static _ServiceAppImpl* __pServiceAppImpl;
230
231         _AppImpl* __pAppImpl;
232
233         ServiceApp* __pServiceApp;
234
235         _IAppEventListener* __pAppTerminatingInternalEventListener;
236
237         Tizen::Base::Runtime::Timer* __pLifeDurationTimer;
238
239         int __lifeDuration;
240
241         bool __pauseLifeDurationTimer;
242
243         friend class ServiceApp;
244
245 }; // _ServiceAppImpl
246
247 } } //Tizen::App
248
249 #endif // _FAPP_INTERNAL_SERVICE_APP_IMPL_H_