2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FApp_ServiceAppImpl.h
19 * @brief This is the header file for the %_ServiceAppImpl class.
22 #ifndef _FAPP_INTERNAL_SERVICE_APP_IMPL_H_
23 #define _FAPP_INTERNAL_SERVICE_APP_IMPL_H_
27 #include <FAppServiceApp.h>
28 #include <FBaseRtIEventListener.h>
29 #include <FBaseRtITimerEventListener.h>
30 #include "FApp_IAppImpl.h"
32 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
33 namespace Tizen { namespace Base { namespace Runtime
37 class _EventDispatcher;
41 namespace Tizen { namespace App
44 class _IAppEventListener;
47 * @class _ServiceAppImpl
48 * @brief This class is the Impl class of a ServiceApp class.
51 * This class is the Impl class of a ServiceApp class.
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
61 * Returns the _ServiceAppImpl's instance pointer.
64 * @return A pointer to the %_ServiceAppImpl instance, @n
65 * else @c null if it fails
67 static _ServiceAppImpl* GetInstance();
70 * Returns the ServiceApp's instance pointer.
73 * @return A pointer to the %ServiceApp instance, @n
74 * else @c null if it fails
76 ServiceApp* GetServiceAppInstance();
80 * Called when the application is started
83 * @return @c true if the method is successful, @n
85 * @param[in] user_data The user data passed from the callback registration function
86 * @remarks This is a system dependent callback function
88 virtual bool OnCreate(void);
91 * Called when other application send the launch request to the application
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
98 virtual void OnService(service_s* service, bool initial);
101 * Called when the application is completely obscured by another application and becomes invisible
104 * @param[in] user_data The user data passed from the callback registration function
105 * @remarks This is a system dependent callback function
107 virtual void OnPause(void);
110 * Called when the application becomes visible
113 * @param[in] user_data The user data passed from the callback registration function
114 * @remarks This is a system dependent callback function
116 virtual void OnResume(void);
119 * Called once after the main loop of application exits
122 * @param[in] user_data The user data passed from the callback registration function
123 * @remarks This is a system dependent callback function
125 virtual void OnTerminate(void);
128 * Called when an orintation event occurs.
131 * @param[in] orientation The information about the orientation event
133 virtual void OnDeviceOrientationChanged(app_device_orientation_e orientation);
136 * Called when the application's state changes to Tizen::App::AppState::INITIALIZING. @n
139 * @return @c true if the method is successful, @n
142 virtual bool OnAppInitializing(void);
145 * Called when the application's INITIALIZING state is finished
148 * @return @c true if the method is successful, @n
151 virtual bool OnAppInitialized(void);
154 * Called when the internal window handle is required.
158 virtual long OnWindowHandleRequest(void);
161 * Called when the application's state change to Tizen::App::AppState::TERMINATING. @n
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
168 bool OnServiceAppImplTerminating(bool forcedTermination);
171 * Executes an application implemented by inheriting App class.
172 * This method must be called from the UiApp or ServiceApp.
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.
182 result Execute(void);
185 void SetAppTerminatingInternalEventListener(_IAppEventListener* pListener);
187 void PauseLifeDurationTimer(void);
189 void ResumeLifeDurationTimer(void);
193 * This is the default constructor for this class.
197 _ServiceAppImpl(void);
200 * This is the constructor for this class.
204 _ServiceAppImpl(ServiceApp* pServiceApp);
207 * This is the copy constructor for the this class.
209 _ServiceAppImpl(const _ServiceAppImpl& source);
212 * This is the assignment operator for this class.
214 _ServiceAppImpl& operator =(const _ServiceAppImpl& source);
217 * This is the destructor for this class.
221 virtual ~_ServiceAppImpl(void);
223 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
225 void SetLifeDurationTimer(int lifeDuration);
229 static _ServiceAppImpl* __pServiceAppImpl;
231 _AppImpl* __pAppImpl;
233 ServiceApp* __pServiceApp;
235 _IAppEventListener* __pAppTerminatingInternalEventListener;
237 Tizen::Base::Runtime::Timer* __pLifeDurationTimer;
241 bool __pauseLifeDurationTimer;
243 friend class ServiceApp;
245 }; // _ServiceAppImpl
249 #endif // _FAPP_INTERNAL_SERVICE_APP_IMPL_H_