2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FApp_ServiceAppImpl.h
20 * @brief This is the header file for the %_ServiceAppImpl class.
23 #ifndef _FAPP_INTERNAL_SERVICE_APP_IMPL_H_
24 #define _FAPP_INTERNAL_SERVICE_APP_IMPL_H_
28 #include <FAppServiceApp.h>
29 #include <FBaseRtIEventListener.h>
30 #include <FBaseRtITimerEventListener.h>
31 #include "FApp_IAppImpl.h"
33 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
34 namespace Tizen { namespace Base { namespace Runtime
38 class _EventDispatcher;
42 namespace Tizen { namespace App
45 class _IAppEventListener;
48 * @class _ServiceAppImpl
49 * @brief This class is the Impl class of a ServiceApp class.
52 * This class is the Impl class of a ServiceApp class.
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
62 * Returns the _ServiceAppImpl's instance pointer.
65 * @return A pointer to the %_ServiceAppImpl instance, @n
66 * else @c null if it fails
68 static _ServiceAppImpl* GetInstance();
71 * Returns the ServiceApp's instance pointer.
74 * @return A pointer to the %ServiceApp instance, @n
75 * else @c null if it fails
77 ServiceApp* GetServiceAppInstance();
81 * Called when the application is started
84 * @return @c true if the method is successful, @n
86 * @param[in] user_data The user data passed from the callback registration function
87 * @remarks This is a system dependent callback function
89 virtual bool OnCreate(void);
92 * Called when other application send the launch request to the application
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
99 virtual void OnService(service_s* service, bool initial);
102 * Called when the application is completely obscured by another application and becomes invisible
105 * @param[in] user_data The user data passed from the callback registration function
106 * @remarks This is a system dependent callback function
108 virtual void OnPause(void);
111 * Called when the application becomes visible
114 * @param[in] user_data The user data passed from the callback registration function
115 * @remarks This is a system dependent callback function
117 virtual void OnResume(void);
120 * Called once after the main loop of application exits
123 * @param[in] user_data The user data passed from the callback registration function
124 * @remarks This is a system dependent callback function
126 virtual void OnTerminate(void);
129 * Called when an orintation event occurs.
132 * @param[in] orientation The information about the orientation event
134 virtual void OnDeviceOrientationChanged(app_device_orientation_e orientation);
137 * Called when the application's state changes to Tizen::App::AppState::INITIALIZING. @n
140 * @return @c true if the method is successful, @n
143 virtual bool OnAppInitializing(void);
146 * Called when the application's INITIALIZING state is finished
149 * @return @c true if the method is successful, @n
152 virtual bool OnAppInitialized(void);
155 * Called when the internal window handle is required.
159 virtual long OnWindowHandleRequest(void);
162 * Called when the application's state change to Tizen::App::AppState::TERMINATING. @n
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
169 bool OnServiceAppImplTerminating(bool forcedTermination);
172 * Executes an application implemented by inheriting App class.
173 * This method must be called from the UiApp or ServiceApp.
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.
183 result Execute(void);
186 void SetAppTerminatingInternalEventListener(_IAppEventListener* pListener);
188 void PauseLifeDurationTimer(void);
190 void ResumeLifeDurationTimer(void);
194 * This is the default constructor for this class.
198 _ServiceAppImpl(void);
201 * This is the constructor for this class.
205 _ServiceAppImpl(ServiceApp* pServiceApp);
208 * This is the copy constructor for the this class.
210 _ServiceAppImpl(const _ServiceAppImpl& source);
213 * This is the assignment operator for this class.
215 _ServiceAppImpl& operator =(const _ServiceAppImpl& source);
218 * This is the destructor for this class.
222 virtual ~_ServiceAppImpl(void);
224 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
226 void SetLifeDurationTimer(int lifeDuration);
230 static _ServiceAppImpl* __pServiceAppImpl;
232 _AppImpl* __pAppImpl;
234 ServiceApp* __pServiceApp;
236 _IAppEventListener* __pAppTerminatingInternalEventListener;
238 Tizen::Base::Runtime::Timer* __pLifeDurationTimer;
242 bool __pauseLifeDurationTimer;
244 friend class ServiceApp;
246 }; // _ServiceAppImpl
250 #endif // _FAPP_INTERNAL_SERVICE_APP_IMPL_H_