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 the application's state changes to Tizen::App::AppState::INITIALIZING. @n
131 * @return @c true if the method is successful, @n
134 virtual bool OnAppInitializing(void);
137 * Called when the application's INITIALIZING state is finished
140 * @return @c true if the method is successful, @n
143 virtual bool OnAppInitialized(void);
146 * Called when the internal window handle is required.
150 virtual long OnWindowHandleRequest(void);
153 * Called when the window is requested to be raised.
155 virtual result OnFrameRaiseRequested(void);
158 * Called when the application's state change to Tizen::App::AppState::TERMINATING. @n
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
165 bool OnServiceAppImplTerminating(bool forcedTermination);
168 * Executes an application implemented by inheriting App class.
169 * This method must be called from the UiApp or ServiceApp.
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.
179 result Execute(void);
182 void SetAppTerminatingInternalEventListener(_IAppEventListener* pListener);
184 void PauseLifeDurationTimer(void);
186 void ResumeLifeDurationTimer(void);
188 void ResetLifeDurationTimer(void);
192 * This is the default constructor for this class.
196 _ServiceAppImpl(void);
199 * This is the constructor for this class.
203 _ServiceAppImpl(ServiceApp* pServiceApp);
206 * This is the copy constructor for the this class.
208 _ServiceAppImpl(const _ServiceAppImpl& source);
211 * This is the assignment operator for this class.
213 _ServiceAppImpl& operator =(const _ServiceAppImpl& source);
216 * This is the destructor for this class.
220 virtual ~_ServiceAppImpl(void);
222 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
224 void SetLifeDurationTimer(int lifeDuration);
228 static _ServiceAppImpl* __pServiceAppImpl;
230 _AppImpl* __pAppImpl;
232 ServiceApp* __pServiceApp;
234 _IAppEventListener* __pAppTerminatingInternalEventListener;
236 Tizen::Base::Runtime::Timer* __pLifeDurationTimer;
240 bool __pauseLifeDurationTimer;
242 friend class ServiceApp;
244 }; // _ServiceAppImpl
248 #endif // _FAPP_INTERNAL_SERVICE_APP_IMPL_H_