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.
20 * @brief This is the header file for the %App class.
22 * This header file contains the declarations of the %App class.
28 #include <FAppTypes.h>
29 #include <FSysBattery.h>
32 int _OSP_EXPORT_ main(int argc, char* pArgv[]);
35 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
37 namespace Tizen { namespace App
45 * @brief This class is the base class of a Tizen native application.
49 * The %App class is the base class of a %Tizen native application.
50 * A %Tizen native application must be inherited from the UiApp or ServiceApp class. These classes are inherited from the %App class. This class provides the basic features necessary to define an application.
52 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/app_namespace.htm">App Guide</a>, <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/tizen_app_model/application_lifecycle.htm">Application Life-cycle</a>, and <a href="../org.tizen.native.appprogramming/html/guide/app/app_system_events.htm">System Events</a>.
55 class _OSP_EXPORT_ App
56 : public Tizen::Base::Object
60 * This destructor overrides Tizen::Base::Object::~Object().
67 * Gets an instance of AppRegistry that manages the application's states and preferences.
71 * @return A pointer to the AppRegistry instance, @n
72 * else @c null if it fails
74 AppRegistry* GetAppRegistry(void) const;
77 * Gets an instance of AppResource that manages the application's resources.
81 * @return A pointer to the AppResource instance, @n
82 * else @c null if it fails
84 AppResource* GetAppResource(void) const;
88 * Gets the list of the launch arguments. @n
89 * For more information on the launch arguments, see <a href="../org.tizen.native.appprogramming/html/guide/app/launching_other_apps_within_apps.htm">Launching Other Applications</a>.
91 * @brief <i> [Deprecated] </i>
92 * @deprecated This method is deprecated. Instead of using this method, it is recommended to use IAppControlProviderEventListener
93 * to acquire delivered arguments list.
96 * @return A pointer to the list that contains the Tizen::Base::String instances of the launch arguments
97 * @see AppManager::LaunchApplication()
98 * @see AppManager::RegisterAppLaunch()
99 * @see AppManager::StartAppControl()
100 * @see AppControl::Start()
103 Tizen::Base::Collection::IList* GetAppArgumentListN(void) const;
106 * Gets the current state of the application.
110 * @return The current state of the application
112 AppState GetAppState(void) const;
115 * Gets the locale-independent name of the application.
118 * @brief <i> [Compatibility] </i>
122 * @compatibility This method has compatibility issues with OSP compatible applications. @n
123 * For more information, see @ref CompGetAppNamePage "here".
125 * @return The name of the application
127 Tizen::Base::String GetAppName(void) const;
130 * @page CompGetAppNamePage Compatibility for GetAppName()
131 * @section CompGetAppNamePageIssue Issues
132 * Implementation of this method in %Tizen API versions prior to 2.1 has the following issue: @n
134 * -# GetAppName() returns the localized name of the application while the meaning of the application name is ambiguous.
135 * There are different use cases for locale-dependent name and localized name and the platform does not provide
136 * a method for obtaining language-neutral name.
138 * @section CompGetAppNamePageResolution Resolutions
139 * The issue mentioned above is resolved in %Tizen API version 2.1 as follows: @n
141 * -# GetAppDisplayName() is introduced to acquire localized name and GetAppName() returns locale-independent application name.
145 * Gets the display name of the application. @n
146 * If the system language setting is changed, the %GetAppDisplayName() method returns the localized application name.
147 * The display name is displayed in applications like Launcher, Setting, Task Manager, and so on.
151 * @return The display name of the application
153 Tizen::Base::String GetAppDisplayName(void) const;
156 * Gets the version of the application.
160 * @return The version of the application
162 Tizen::Base::String GetAppVersion(void) const;
165 * Gets the application ID.
169 * @return The application ID
171 AppId GetAppId(void) const;
174 * Gets the path of the application's root directory where the application is installed.
178 * @return The application's root directory path
180 Tizen::Base::String GetAppRootPath(void) const;
183 * Gets the path of the application's data directory used to store its own private data.
187 * @return The application's data directory path
189 Tizen::Base::String GetAppDataPath(void) const;
192 * Gets the path of the application's resource directory that ships resource files delivered with the application
197 * @return The application's resource directory path
199 Tizen::Base::String GetAppResourcePath(void) const;
202 * Gets the path of the application's shared directory to export data to other applications.
206 * @return The application's shared directory path
208 Tizen::Base::String GetAppSharedPath(void) const;
211 * Terminates the application while it is running. @n
212 * The OnAppTerminating() method is called after the %Terminate() method is executed successfully.
216 * @return An error code
217 * @exception E_SUCCESS The method is successful.
218 * @exception E_INVALID_STATE This instance is in an invalid state.
220 result Terminate(void);
223 * Called when the application's state changes to App::INITIALIZING. @n
224 * In general, most of the activities involved in initializing the application,
225 * including restoring the application's states, must be done in the %OnAppInitializing() method.
226 * If this method fails, the application's state changes to App::TERMINATED.
230 * @return @c true if the method is successful, @n
232 * @param[in] appRegistry The instance of AppRegistry that manages the application's states
233 * @remarks Introducing the modal dialogs (for example, MessageBox) in this method is not allowed,
234 * because it blocks the initialization procedure.
236 virtual bool OnAppInitializing(AppRegistry& appRegistry) = 0;
239 * Called when the application's initialization is finished. @n
240 * After the %OnAppInitialized() method succeeds, the application's state changes to App::RUNNING.
241 * If this method fails, the application's state changes to App::TERMINATING and the App::OnAppTerminating() method is called.
245 * @return @c true if the method is successful, @n
248 virtual bool OnAppInitialized(void);
251 * Called when the application is requested to terminate. @n
252 * The %OnAppWillTerminate() method returns @c false to prevent the application from getting terminated.
253 * If this method returns @c true, the application's state changes to App::TERMINATING and the App::OnAppTerminating() method is called.
257 * @return @c true if the method is successful, @n
260 virtual bool OnAppWillTerminate(void);
263 * Called when the application's state changes to App::TERMINATING. @n
264 * All the activities involved in terminating the application, including saving the application's states, must be done in the %OnAppTerminating() method.
265 * After this method, the application code cannot be executed. The application is destroyed subsequently. @n
267 * An application can be terminated by either system, such as power-off and OOM, or others, such as self and other applications. @n
268 * When the termination by system, called an “urgent termination”, occurs, the method, OnAppTerminating(), cannot be executed properly.
269 * For more details, while power-off, even if OnAppTerminating() is called, it has a short time for executing. If the application is killed by OOM, OnAppTerminating() is not called. @n
270 * Because OnAppTerminating() is not likely to be called due to urgent termination, the application should save the critical data as they can do.
271 * For example, the application can set the check point or use the callback for low memory. @n
272 * When the termination by self or other applications, called a “normal termination”, occurs, the method, OnAppTerminating(), can be executed properly.
273 * It provides more time for executing than urgent termination, but limits to the time to 3 or 5 seconds. @n
274 * The main loop is already quitted when OnAppTerminating() is called.
275 * Thus, the application should not use a kind of asynchronous API of which the callback is triggered by the main loop.
279 * @return @c true if the method is successful, @n
281 * @param[in] appRegistry The instance that manages the application's states
282 * @param[in] urgentTermination Set to @c true if the application is terminated by the system, @n
285 virtual bool OnAppTerminating(AppRegistry& appRegistry, bool urgentTermination = false) = 0;
288 * Called when the system detects that the system wide memory or application heap memory is insufficient to run the application any further. @n
289 * Resources that are not in use currently can be released using the %OnLowMemory() method.
293 virtual void OnLowMemory(void);
296 * Called when the battery level changes. @n
297 * It is recommended that the application consuming more battery power must be terminated if the battery level is Tizen::System::BATTERY_LEVEL_CRITICAL.
301 * @param[in] batteryLevel The device's current battery level
303 virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel);
306 * Sends the user event to the application itself and not to another application.
310 * @return An error code
311 * @param[in] requestId The user defined event ID
312 * @param[in] pArgs A pointer to an argument list of type Tizen::Base::String
313 * @exception E_SUCCESS The method is successful.
314 * @see OnUserEventReceivedN()
316 result SendUserEvent(RequestId requestId, const Tizen::Base::Collection::IList* pArgs);
319 * Called asynchronously when the user event is sent by the SendUserEvent() method. @n
320 * The request ID and argument format for the user event can be defined as per the requirement.
324 * @param[in] requestId The user defined event ID
325 * @param[in] pArgs A pointer to an argument list of type Tizen::Base::String
327 virtual void OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs);
330 * Gets the %App instance's pointer.
334 * @return A pointer to the %App instance, @n
335 * else @c null if it fails
337 static App* GetInstance(void);
341 * This is the default constructor for this class.
348 // This method is for internal use only.
349 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
351 // This method is reserved and may change its name at any time without prior notice.
355 virtual void App_Reserved1(void) {}
358 // This method is for internal use only.
359 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
361 // This method is reserved and may change its name at any time without prior notice.
365 virtual void App_Reserved2(void) {}
369 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
376 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
380 App& operator =(const App& rhs);
383 class _AppImpl* __pAppImpl;
388 #endif // _FAPP_APP_H_