Merge "GetErrorMessage() to print the error log" into tizen_2.1
[platform/framework/native/appfw.git] / inc / FAppAppManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        FAppAppManager.h
20  * @brief       This is the header file for the %AppManager class.
21  *
22  * This header file contains the declarations of the %AppManager class.
23  */
24
25 #ifndef _FAPP_APP_MANAGER_H_
26 #define _FAPP_APP_MANAGER_H_
27
28 #include <FBaseObject.h>
29 #include <FAppTypes.h>
30
31 namespace Tizen { namespace Base {
32 class ByteBuffer;
33 namespace Collection {
34 class IList;
35 class IMap;
36 }
37 }}
38
39 namespace Tizen { namespace App
40 {
41
42 class IAppControlEventListener;
43 class IAppControlListener;
44 class IAppControlResponseListener;
45 class IAppCheckpointEventListener;
46 class IAppLaunchConditionEventListener;
47 class IActiveAppEventListener;
48 class AppControl;
49 class SqlDataControl;
50 class MapDataControl;
51
52 /**
53  * @class               AppManager
54  * @brief               This class manages all the applications.
55  *
56  * @since       2.0
57  *
58  * @final       This class is not intended for extension.
59  *
60  * The %AppManager class manages all the applications.
61  * The application manager supports normal and conditional application launch, and application control search and launch.
62  * It looks up the specific application control from the application control registry and creates an application control instance.
63  * @n
64  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/app/launching_other_apps_within_apps.htm">Launching Other Applications</a> and <a href="../org.tizen.native.appprogramming/html/guide/app/registering_launch_condition.htm">Registering a Launch Condition</a>, and <a href="../org.tizen.native.appprogramming/html/guide/app/app_controls.htm">Application Controls</a>.
65  */
66 class _OSP_EXPORT_ AppManager
67         : public Tizen::Base::Object
68 {
69 public:
70         /**
71          * @enum LaunchOption
72          *
73          * Defines the launch options.
74          *
75          * @since       2.0
76          */
77         enum LaunchOption
78         {
79                 LAUNCH_OPTION_DEFAULT   /**< The launch option: default */
80         };
81
82         /**
83          * Finds the application control that the caller wants to start. @n
84          * It resolves the matched application control with the delivered application ID and operation ID.
85          *
86          * @since       2.0
87          *
88          * @return      A pointer to the newly created AppControl instance if a matched %AppControl is found, @n
89          *                      else @c null
90          * @param[in]   appId                   The application ID
91          * @param[in]   operationId             The operation ID
92          * @exception   E_SUCCESS               The method is successful.
93          * @exception   E_OBJ_NOT_FOUND The application control is not found.
94          * @exception   E_SYSTEM                A system error has occurred. @n
95          *                                                              Either the file operation or the DB operation has failed.
96          * @remarks     The specific error code can be accessed using the GetLastResult() method.
97          * @remarks     %Tizen platform defines platform-defined alias for application ID and this aliased application ID
98          *                      can be used to find the AppControl. For more information, see
99          *                      <a href="../org.tizen.native.appprogramming/html/guide/app/app_controls.htm">here</a>.
100          *
101          * The following example demonstrates how to use the %FindAppControlN() method to find the application control.
102          *
103          * @code
104          * ArrayList dataList(SingleObjectDeleter);
105          * dataList.Construct();
106          * dataList.Add(new String(L"tel:1234567900"));
107          * dataList.Add(new String(L"type:voice"));
108          *
109          * AppControl* pAc = AppManager::FindAppControlN(L"tizen.phone", L"http://tizen.org/appcontrol/operation/call");
110          * pAc->Start(&dataList, null);
111          * @endcode
112          */
113         static AppControl* FindAppControlN(const AppId& appId, const Tizen::Base::String& operationId);
114
115         /**
116          * Finds a list of AppControl instances that matches the specified operation ID, category,
117          * data type, and URI pattern.
118          *
119          * @since               2.0
120          *
121          * @return      A pointer to the list of the AppControl instances that matches the specified operation ID, category, URI, and data type, @n
122          *          else @c null if it fails
123          * @param[in]   pOperationId    The operation ID
124          * @param[in]   pCategory                       The application category
125          * @param[in]   pDataType       The MIME type (RFC 2046) or file extension @n
126          *                          The '.' prefix must be used when specifying the file extension.
127          * @param[in]   pUriPattern                     The URI pattern
128          *
129          * @exception   E_SUCCESS                       The method is successful.
130          * @exception   E_INVALID_ARG           At least one of the specified @c pOperationId, @c pCategory, @c pDataType, or @c pUriScheme must not be @c null.
131          * @exception   E_INVALID_FORMAT        The specified URI scheme is invalid (RFC 2396).
132          * @exception   E_UNSUPPORTED_FORMAT    The specified file extension for @c pDataType is not supported.
133          * @exception   E_OBJ_NOT_FOUND         The application control is not found.
134          * @exception   E_SYSTEM                A system error has occurred. @n
135          *                                                              Either the file operation or the DB operation has failed.
136          * @remarks     The specific error code can be accessed using the GetLastResult() method.
137          * @remarks     For the delivered launch arguments, see App::GetAppArgumentListN().
138          */
139         static Tizen::Base::Collection::IList* FindAppControlsN(const Tizen::Base::String* pOperationId, const Tizen::Base::String* pCategory, const Tizen::Base::String* pDataType, const Tizen::Base::String* pUriPattern);
140
141         /**
142      * @if OSPDEPREC
143          * Starts the application control if there is only one application control that matches the specified URI, operation ID, and data type. @n
144          * If there are more than one application controls, the one that the user selects is started.
145          *
146          * @brief       <i> [Deprecated] </i>
147          * @deprecated  This method is deprecated because IAppControlListener is deprecated and replaced by IAppControlResponselistener.
148          *                              Instead of using this method, use AppControl::FindAndStart().
149          * @since               2.0
150          * @privlevel   public
151          * @privilege   %http://tizen.org/privilege/application.launch
152          *
153          * @return      An error code
154          * @param[in]   uriData                 The URI that has a maximum size of @c 1024 bytes
155          * @param[in]   pOperationId    The operation ID
156          * @param[in]   pDataType       The MIME type (RFC 2046) or file extension @n
157          *                          The '.' prefix must be used for the @c dataType when specifying the file extension.
158          * @param[in]   pListener       A listener that gets notified when the resolved application control has started
159          * @exception   E_SUCCESS                       The method is successful.
160          * @exception   E_MAX_EXCEEDED          The size of @c uri has exceeded the maximum limit.
161          * @exception   E_UNSUPPORTED_FORMAT    The specified file extension for @c pDataType is not supported.
162          * @exception   E_OUT_OF_MEMORY The memory is insufficient.
163          * @exception   E_OBJ_NOT_FOUND         The application control is not found.
164          * @exception   E_IN_PROGRESS           The target application control is in progress.
165          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
166          * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
167          *
168          * @see App::GetAppArgumentListN()
169          * @see FindAppControlN()
170          * @see FindAppControlsN()
171          * @see AppControl::Start()
172          *
173          * The following example demonstrates how to use the %StartAppControl() method.
174          * @code
175          * String operationId = L"http://tizen.org/appcontrol/operation/call";
176          * StartAppControl(L"tel:1234567890", &operationId, null, null);
177          * @endcode
178      * @endif
179          */
180         static result StartAppControl(const Tizen::Base::String& uriData, const Tizen::Base::String* pOperationId, const Tizen::Base::String* pDataType, IAppControlListener* pListener);
181
182         /**
183          * @if OSPDEPREC
184          * Starts the application control if there is only one application control that matches the specified operation ID, category, URI, and data type. @n
185          * If there are more than one application controls, the one that the user selects is started.
186          *
187          * @brief       <i> [Deprecated] </i>
188          * @deprecated  This method is deprecated because IAppControlListener is deprecated and replaced by IAppControlResponselistener.
189          *                              Instead of using this method, use AppControl::FindAndStart().
190          * @since               2.0
191          * @privlevel   public
192          * @privilege   %http://tizen.org/privilege/application.launch
193          *
194          * @return      An error code
195          * @param[in]   pOperationId    The operation ID
196          * @param[in]   pCategory                       The application control category
197          * @param[in]   pDataType       The MIME type (RFC 2046) or file extension @n
198          *                          The '.' prefix must be used when specifying the file extension.
199          * @param[in]   pUriPattern                     A URI pattern which is used for application control resolution and delivered as the argument
200          * @param[in]   pDataList       The data list that is delivered to the resolved application control @n
201          *                       It has a maximum size of @c 1024 bytes.
202          * @param[in]   pListener       A listener that gets notified when the resolved application control has started
203          * @exception   E_SUCCESS                       The method is successful.
204          * @exception   E_INVALID_ARG           At least one of the specified @c pOperationId, @c pCategory, @c pDataType, or @c pUri must not be @c null.
205          * @exception   E_MAX_EXCEEDED          The size of @c pDataList has exceeded the maximum limit.
206          * @exception   E_UNSUPPORTED_FORMAT    The specified file extension for @c pDataType is not supported.
207          * @exception   E_OBJ_NOT_FOUND         The application control is not found.
208          * @exception   E_IN_PROGRESS           The target application control is in progress.
209          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
210          * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
211          * @remarks             For delivered launch arguments, see App::GetAppArgumentListN().
212          * @see App::GetAppArgumentListN()
213          * @see FindAppControlsN()
214          * @see AppControl::Start()
215          * @endif
216          */
217         static result StartAppControl(const Tizen::Base::String* pOperationId, const Tizen::Base::String* pCategory, const Tizen::Base::String* pDataType, const Tizen::Base::String* pUriPattern, const Tizen::Base::Collection::IList* pDataList, IAppControlListener* pListener);
218
219         /**
220          * Gets the SQL-type data control that the caller wants to use. @n
221          * It resolves the matching data control with the specified data control provider ID.
222          *
223          * @since       2.0
224          *
225          * @return              A pointer to the SqlDataControl instance if a matching data control is found, @n
226          *                              else @c null
227          * @param[in]   providerId                      The provider ID
228          * @exception   E_SUCCESS                       The method is successful.
229          * @exception   E_OBJ_NOT_FOUND         The data control specified with the @c providerId is not found.
230          * @exception   E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
231          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
232          * @exception   E_SYSTEM                        A system error has occurred.
233          * @remarks             The specific error code can be accessed using the GetLastResult() method.
234          */
235         static SqlDataControl* GetSqlDataControlN(const Tizen::Base::String& providerId);
236
237         /**
238          * Gets the MAP-type data control that the caller wants to use. @n
239          * It resolves the matching data control with the specified data control provider ID.
240          *
241          * @since       2.0
242          *
243          * @return              A pointer to the MapDataControl instance if a matching data control is found, @n
244          *                              else @c null
245          * @param[in]   providerId                      The provider ID
246          * @exception   E_SUCCESS                       The method is successful.
247          * @exception   E_OBJ_NOT_FOUND         The data control specified with the @c providerId is not found.
248          * @exception   E_ILLEGAL_ACCESS        Access is denied due to insufficient permission.
249          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
250          * @exception   E_SYSTEM                        A system error has occurred.
251          * @remarks             The specific error code can be accessed using the GetLastResult() method.
252          */
253         static MapDataControl* GetMapDataControlN(const Tizen::Base::String& providerId);
254
255         /**
256         * Gets the path of the read-only shared directory exported by an other application specified with an application ID.
257         *
258         * @since        2.0
259         *
260         * @return               The other application's shared directory path, @n
261         *                               else an empty string if an exception occurs
262         * @param[in]    appId                           The application ID
263         * @exception    E_SUCCESS                       The method is successful.
264         * @exception    E_APP_NOT_INSTALLED     The expected shared directory cannot be found
265         *                                                                       because the application specified with @c appId cannot be installed.
266         * @remarks              The returned path can be invalid when the application with specified with @c appId is uninstalled. @n
267         *                               The specific error code can be accessed using the GetLastResult() method.
268         */
269         static Tizen::Base::String GetAppSharedPath(const AppId& appId);
270
271         /**
272          * Gets the application manager instance.
273          *
274          * @since       2.0
275          *
276          * @return      A pointer to the %AppManager instance, @n
277          *                      else @c null if it fails
278          */
279         static AppManager* GetInstance(void);
280
281         /**
282          * @if OSPDEPREC
283          * Launches the default application with the given @c appId. @n
284          * The launch arguments are given as App::OnUserEventReceivedN() or can be obtained by
285          * invoking App::GetAppArgumentListN(), especially within App::OnAppInitializing().
286          *
287          * @brief               <i> [Deprecated] </i>
288          * @deprecated  This method is deprecated because sending argument with %LaunchApplication() is not recommended. @n
289          *                              Instead of using this method, use %LaunchApplication() without launch arguments or AppControl::Start().
290          * @since       2.0
291          * @privlevel   public
292          * @privilege   %http://tizen.org/privilege/application.launch
293          *
294          * @return      An error code
295          * @param[in]   appId                           The application's ID to execute
296          * @param[in]   pArguments                      A pointer to the list of string arguments that has a maximum size of @c 1024 bytes
297          * @param[in]   option                          The launch option (currently only AppManager::LAUNCH_OPTION_DEFAULT is available)
298          * @exception   E_SUCCESS                       The method is successful.
299          * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
300          * @exception   E_INVALID_ARG           The specified @c appId is empty.
301          * @exception   E_OBJ_NOT_FOUND         The target application is not installed.
302          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
303          * @exception   E_MAX_EXCEEDED          The size of @c appId or @c pArguments has exceeded the maximum limit.
304          * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
305          * @exception E_ILLEGAL_ACCESS                          The application is not signed with the same certificate of target application. @b Since: @b 2.1
306          * @endif
307          */
308         result LaunchApplication(const AppId& appId, const Tizen::Base::Collection::IList* pArguments, LaunchOption option = LAUNCH_OPTION_DEFAULT);
309
310         /**
311          * Launches the default application with the given @c appId.
312          *
313          * @since       2.0
314          * @privlevel   public
315          * @privilege   %http://tizen.org/privilege/application.launch
316          *
317          * @return      An error code
318          * @param[in]   appId                           The application's ID to execute
319          * @param[in]   option                          The launch option (currently only AppManager::LAUNCH_OPTION_DEFAULT is available)
320          * @exception   E_SUCCESS                       The method is successful.
321          * @exception   E_SYSTEM                        The method cannot proceed due to a severe system error.
322          * @exception   E_APP_NOT_INSTALLED     The target application is not installed.
323          * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
324          * @exception E_ILLEGAL_ACCESS                          The application is not signed with the same certificate of target application. @b Since: @b 2.1
325          */
326         result LaunchApplication(const AppId& appId, LaunchOption option = LAUNCH_OPTION_DEFAULT);
327
328         /**
329          * Terminates an application.
330          *
331          * @since       2.0
332          * @privlevel   partner
333          * @privilege   %http://tizen.org/privilege/appmanager.kill @n
334          *                              (%http://tizen.org/privilege/application.kill is deprecated.)
335          *
336          * @return      An error code
337          * @param[in]   appId                           The application's ID to execute
338          * @exception   E_SUCCESS                       The method is successful.
339          * @exception   E_SYSTEM                        A system error has occurred.
340          * @exception   E_OBJ_NOT_FOUND         The application is either not installed or is not running.
341          * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
342          */
343         result TerminateApplication(const AppId& appId);
344
345         /**
346          * Checks whether an application is running.
347          *
348          * @since       2.0
349          *
350          * @return      @c true if the application is running, @n
351          *           else @c false
352          * @param[in]   appId               The installed application ID
353          */
354         bool IsRunning(const AppId& appId) const;
355
356         /**
357          * Gets a list of running applications at the time of invocation.
358          *
359          * @since      2.0
360          *
361          * @return      A pointer to the running state application list (AppId), @n
362          *                   else @c null if an error occurs
363          * @exception   E_SUCCESS                       The method is successful.
364          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
365          * @exception   E_SYSTEM                        A system error has occurred.
366          * @remarks     The specific error code can be accessed using the GetLastResult() method.
367          */
368         Tizen::Base::Collection::IList* GetRunningAppListN(void) const;
369
370         /**
371          * Registers an application with a specific condition and launches it if the condition is met. @n
372          * If the requested application is already running, the application is notified through IAppLaunchConditionEventListener::OnAppLaunchConditionMetN().
373          * The launch arguments are given as input parameters to %IAppLaunchConditionEventListener::OnAppLaunchConditionMetN().
374          *
375          * @since       2.0
376          * @privlevel   public
377          * @privilege   %http://tizen.org/privilege/application.launch
378          *
379          * @return              An error code
380          * @param[in]   condition         The launch condition for the application @n
381          *                                                        The condition has L"Key='value'" format and is case sensitive. To use single or double quotes in the condition values, prefix them with a slash (\' or \"). @n
382          *                                                        For more information on the condition formats, see <a href="../org.tizen.native.appprogramming/html/guide/app/registering_launch_condition.htm">Registering a Launch Condition</a>.
383          *                            <table><tr><th>Condition Format</th><th>Meaning</th></tr>
384                                       <tr><td>L"DateTime='mm/dd/yyyy hh:mm:ss'"</td>
385                                       <td>The specified condition is the local due time.</td></tr>
386                                       <tr><td>L"DueTime='mm/dd/yyyy hh:mm:ss' LaunchPeriod='mm'"</td>
387                                       <td>The specific condition is the time period after due time.</td></tr>
388                                       <tr><td>L"WeeklyTime='EEE HH:mm:ss'"</td>
389                                       <td>The specified condition is a day of week with specific time to launch an application for every week. For multiple description, "," delimiter can be used like following example.<br>i"Mon 09:00:00, Tue 09:00:00, Wed 09:00:00, Thu 09:00:00, Fir 09:00:00"<br> The format of a day of week is support following string only.<br>Mon: Monday<br>Tue: Tuesday<br>Wed: Wednesday<br>Thu: Thursday<br>Fri: Friday<br>Sat: Saturday<br>Sun: Sunday</td></tr>
390                                       <tr><td>L"Serial='command'"</td><td>The specified condition is a serial
391                                       communication input command.</td></tr>
392                                       <tr><td>L"NFC='command'"</td><td>The specified condition is a Near Field Communication (NFC) tag that has the NFC Data Exchange Format (NDEF) data.
393                                       </td></tr></table> @n
394
395          *
396          * @param[in]   pArguments        A list of string arguments that has a maximum size of @c 1024 bytes @n
397          *                                                        The parameter can also contain @c null. @n
398          *                                                    For more information on the arguments, see <a href="../org.tizen.native.appprogramming/html/guide/app/launching_other_apps_within_apps.htm">Launching Other Applications</a>.
399          * @param[in]   option         The launch option (currently only AppManager::LAUNCH_OPTION_DEFAULT is available)
400          * @exception   E_SUCCESS                       The method is successful.
401          * @exception   E_INVALID_ARG           The launch condition is empty or too long (Maximum 400 bytes).
402          * @exception   E_INVALID_FORMAT                The specified condition format is invalid.
403          * @exception   E_INVALID_CONDITION  The specified condition format is valid but the condition has at least one or more invalid values.
404          * @exception   E_OBJ_ALREADY_EXIST     The specified @c condition is already registered by a different application.
405          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
406          * @exception   E_MAX_EXCEEDED          The size of @c pArguments has exceeded the maximum limit.
407          * @exception   E_SYSTEM                                A system error has occurred.
408          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
409          *
410          * @remarks             When the registered application is about to be launched, the registered launch condition and arguments are given as parameters to IAppLaunchConditionEventListener::OnAppLaunchConditionMetN().
411          * @remarks             The newly introduced launch condition does not work on the previous SDK version and the E_INVALID_CONDITION exception is returned.
412          * @remarks             Registering the same launch condition overwrites the previous launch argument without throwing an exception.
413          * @remarks             The launch period requires more consideration because an inappropriate short period value may lead
414          *                              to an adverse effect on the device battery.
415          * @remarks             For the NFC launch condition, the detected NDEF message can be acquired using the @c pExtraData parameter of the %IAppLaunchConditionEventListener::OnAppLaunchConditionMetN() method.
416          * @see                 UnregisterAppLaunch()
417          * @see                 IsAppLaunchRegistered()
418          * @see                 LaunchApplication()
419          * @see                 Tizen::Base::DateTime::ToString()
420          * @see                 Tizen::Io::SerialPort
421          *
422          * The following example demonstrates how to use the %RegisterAppLaunch() method.
423          *
424          * @code
425          *
426          *  DateTime time;
427          *  SystemTime::GetCurrentTime(TIME_MODE_WALL, time);
428          *  time.AddMinutes(1);
429          *
430          *  String cond;
431          *  cond.Format(70, L"DueTime='%S' LaunchPeriod='60'", time.ToString().GetPointer());
432          *
433          *  // Registers a periodic condition that fires every 60 minutes starting after one minute
434          *  AppManager::GetInstance()->RegisterAppLaunch(cond, null, AppManager::LAUNCH_OPTION_DEFAULT)
435          *
436          * @endcode
437          */
438         result RegisterAppLaunch(const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pArguments, LaunchOption option);
439
440         /**
441          * Unregisters the previously registered launch condition.
442          *
443          * @since       2.0
444          * @privlevel   public
445          * @privilege   %http://tizen.org/privilege/application.launch
446          *
447          * @return              An error code
448          * @exception   E_SUCCESS                       Either of the following conditions has occurred:
449          *                                                                      - The method is successful.
450          *                                                                      - There is no registered launch condition.
451          * @exception   E_SYSTEM                        A system error has occurred.
452          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
453          * @see                 RegisterAppLaunch()
454          * @see                 IsAppLaunchRegistered()
455          */
456         result UnregisterAppLaunch(void);
457
458         /**
459          * Unregisters the specified launch condition.
460          *
461          * @since               2.0
462          * @privlevel   public
463          * @privilege   %http://tizen.org/privilege/application.launch
464          *
465          * @return              An error code
466          * @param[in]   condition                       The launch condition for the application
467          * @exception   E_SUCCESS                       The method is successful.
468          * @exception   E_OBJ_NOT_FOUND         The specified launch condition is not found.
469          * @exception   E_SYSTEM                        A system error has occurred.
470          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
471          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.
472          * @see                 RegisterAppLaunch()
473          * @see                 IsAppLaunchRegistered()
474          */
475         result UnregisterAppLaunch(const Tizen::Base::String& condition);
476
477         /**
478          * Checks whether a launch condition is registered for the application.
479          *
480          * @since       2.0
481          *
482          * @return     @c true if a condition is already registered to the application invoking this method, @n
483          *             else @c false
484          * @exception  E_SUCCESS                        The method is successful.
485          * @exception  E_SYSTEM                         A system error has occurred.
486          *
487          * @remarks     The specific error code can be accessed using the GetLastResult() method.
488          * @see         RegisterAppLaunch()
489          * @see         UnregisterAppLaunch()
490          */
491         bool IsAppLaunchRegistered(void) const;
492
493         /**
494          * Registers the specified application with a specific condition and launches it if the condition is met. @n
495          * If the requested application is already running, the application is notified through IAppLaunchConditionEventListener::OnAppLaunchConditionMetN().
496          * The launch arguments are given as input parameters to %IAppLaunchConditionEventListener::OnAppLaunchConditionMetN().
497          *
498          * @since               2.0
499          * @privlevel   partner
500          * @privilege   %http://tizen.org/privilege/appmanager.launch
501          *
502          * @return     An error code
503          * @param[in]  appId          The ID of the application registered for launch
504          * @param[in]  condition      The launch condition for the application @n
505          *                                The condition has L"Key='value'" format and is case sensitive. To use single or double quotes in the condition values, prefix them with a slash (\' or \"). @n
506          *                                                        For more information on the condition formats, see <a href="../org.tizen.native.appprogramming/html/guide/app/registering_launch_condition.htm">Registering a Launch Condition</a>.
507          *                             <table><tr><th>Condition Format</th><th>Meaning</th></tr>
508                                      <tr><td>L"DateTime='mm/dd/yyyy hh:mm:ss'"</td>
509                                      <td>The specified condition is the local due time.</td></tr>
510                                      <tr><td>L"DueTime='mm/dd/yyyy hh:mm:ss' LaunchPeriod='mm'"</td>
511                                      <td>The specific condition is the time period after due time.</td></tr>
512                                      <tr><td>L"Serial='command'"</td><td>The specified condition is a serial
513                                      communication input command.</td></tr>
514                                      <tr><td>L"NFC='command'"</td><td>The specified condition is a Near Field Communication (NFC) tag that has the NFC Data Exchange Format (NDEF) data.
515                                      </td></tr></table> @n
516
517          *
518          * @param[in]  pArguments         A list of string arguments that has a maximum size of @c 1024 bytes @n
519          *                                                        The parameter can also contain @c null. @n
520          *                                                    For more information on the arguments, see <a href="../org.tizen.native.appprogramming/html/guide/app/launching_other_apps_within_apps.htm">Launching Other Applications</a>.
521          * @param[in]  option         The launch option (currently only AppManager::LAUNCH_OPTION_DEFAULT is available)
522          * @exception  E_SUCCESS                        The method is successful.
523          * @exception  E_APP_NOT_INSTALLED      The application is not installed.
524          * @exception  E_INVALID_ARG            The launch condition is empty or too long (Maximum 400 bytes).
525          * @exception  E_INVALID_FORMAT         The specified condition format is invalid.
526          * @exception  E_INVALID_CONDITION  The specified condition format is valid but the condition has at least one or more invalid values.
527          * @exception  E_OUT_OF_MEMORY          The memory is insufficient.
528          * @exception  E_MAX_EXCEEDED           The size of @c pArguments has exceeded the maximum limit.
529          * @exception  E_SYSTEM                         A system error has occurred.
530          * @exception  E_PRIVILEGE_DENIED       The application does not have the privilege to call this method.
531          *
532          * @remarks    When the registered application is about to be launched, the registered launch condition and arguments are given as parameters to IAppLaunchConditionEventListener::OnAppLaunchConditionMetN().
533          * @remarks    The newly introduced launch condition does not work on the previous SDK version and the @c E_INVALID_CONDITION exception is returned.
534          * @remarks    Registering the same launch condition overwrites the previous launch argument without throwing an exception.
535          * @remarks    The launch period requires more consideration because an inappropriate short period value may lead
536          *             to an adverse effect on the device battery.
537          * @remarks    For the NFC launch condition, the detected NDEF message can be acquired using the @c pExtraData parameter of the %IAppLaunchConditionEventListener::OnAppLaunchConditionMetN() method.
538          * @see        UnregisterAppLaunch()
539          * @see        IsAppLaunchRegistered()
540          * @see        LaunchApplication()
541          * @see        IAppLaunchConditionEventListener::OnAppLaunchConditionMetN()
542          * @see        Tizen::Base::DateTime::ToString()
543          * @see        Tizen::Io::SerialPort
544          */
545         result RegisterAppLaunch(const AppId& appId, const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pArguments, LaunchOption option);
546
547         /**
548          * Unregisters the launch condition.
549          *
550          * @since               2.0
551          * @privlevel   partner
552          * @privilege   %http://tizen.org/privilege/appmanager.launch
553          *
554          * @return     An error code
555          * @param[in]  appId          The application ID
556          * @param[in]  pCondition           The launch condition to unregister @n
557          *                                  If the parameter contains @c null, all the conditions are unregistered.
558          * @exception  E_SUCCESS                        The method is successful.
559          * @exception  E_APP_NOT_INSTALLED      The application is not installed.
560          * @exception  E_OBJ_NOT_FOUND          The specified launch condition is not found.
561          * @exception  E_SYSTEM                         A system error has occurred.
562          * @exception  E_OUT_OF_MEMORY          The memory is insufficient.
563          * @exception  E_PRIVILEGE_DENIED       The application does not have the privilege to call this method.
564          *
565          * @see         RegisterAppLaunch()
566          * @see         IsAppLaunchRegistered()
567          */
568         result UnregisterAppLaunch(const AppId& appId, const Tizen::Base::String* pCondition);
569
570         /**
571          * Checks whether a previously registered launch condition is present for the specified application.
572          *
573          * @since               2.0
574          * @privlevel   partner
575          * @privilege   %http://tizen.org/privilege/appmanager.launch
576          *
577          * @return     @c true if a condition is already registered to the specified application with the specified condition, @n
578          *             else @c false
579          * @param[in]  appId          The application ID
580          * @param[in]  pCondition     The launch condition to register for the specified @c appId @n
581          *                            If the parameter contains @c null, the method checks for any registered launch condition for the specified @c appId.
582          * @exception  E_SUCCESS                        The method is successful.
583          * @exception  E_APP_NOT_INSTALLED      The application is not installed.
584          * @exception  E_SYSTEM                         A system error has occurred.
585          * @exception  E_OUT_OF_MEMORY          The memory is insufficient.
586          * @exception  E_PRIVILEGE_DENIED       The application does not have the privilege to call this method.
587          *
588          * @remarks     The specific error code can be accessed using the GetLastResult() method.
589          * @see         RegisterAppLaunch()
590          * @see         UnregisterAppLaunch()
591          */
592         bool IsAppLaunchRegistered(const AppId& appId, const Tizen::Base::String* pCondition = null) const;
593
594         /**
595          * Sets a checkpoint event listener. @n
596          * The listener gets notified when a checkpoint event is fired.
597          *
598          * @since       2.0
599          *
600          * @return      An error code
601          * @param[in]   listener                The listener to receive the checkpoint event
602          * @exception  E_SUCCESS                        The method is successful.
603          * @exception  E_OBJ_ALREADY_EXIST      The listener is already set.
604          * @exception  E_SYSTEM         A system error has occurred.
605          * @see         IAppCheckpointEventListener
606          *
607          */
608         result SetCheckpointEventListener(IAppCheckpointEventListener& listener);
609
610         /**
611          * @if OSPDEPREC
612          * Sends the result list for the application control request. @n
613          * The client can get the result list by implementing IAppControlEventListener::OnAppControlCompleted().
614          *
615          * @brief       <i> [Deprecated] </i>
616          * @deprecated  This method is deprecated because a new method has been added. @n
617          *                      Instead of using this method, use AppControlProviderManager::SendAppControlResult().
618          * @since               2.0
619          *
620          * @return              An error code
621          * @param[in]   appControlRequestId     The application control request ID @n
622          *                          The application control request ID is given as an argument for
623          *                          App::GetAppArgumentListN() or App::OnUserEventReceivedN().
624          * @param[in]   pResultList     The list of the result strings of the application control
625          * @exception   E_SUCCESS                               The method is successful.
626          * @exception   E_OBJ_NOT_FOUND                 The application control request is not found.
627          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
628          * @exception   E_SYSTEM                                A system error has occurred.
629          * @see IAppControlEventListener
630          * @endif
631          */
632         static result SendAppControlResult(const Tizen::Base::String& appControlRequestId, const Tizen::Base::Collection::IList* pResultList);
633
634         /**
635      * Sets an IAppLaunchConditionEventListener to the %AppManager. @n
636      * The listener gets notified when the application is launched by the registered condition.
637      *
638      * @since   2.0
639          *
640      * @param[in]  pListener      The event listener @n
641      *                            To unset the listener, pass a @c null value to the listener parameter.
642      * @remarks    If the application is newly launched by the condition, then %SetAppLaunchConditionEventListener() must
643      *             be set within App::OnAppInitializing().
644      *             If the application does not set the listener using %SetAppLaunchConditionEventListener(),
645      *             then the application is launched without invoking any listener for the condition.
646      * @see RegisterAppLaunch()
647      */
648         void SetAppLaunchConditionEventListener(IAppLaunchConditionEventListener* pListener);
649
650         /**
651          * Adds an IActiveAppEventListener to the %AppManager. @n
652          * The listener gets notified when the active application is changed.
653          *
654          * @since       2.0
655          *
656          * @privlevel   partner
657          * @privilege   %http://tizen.org/privilege/appusage
658          *
659          * @return              An error code
660          * @param[in]   listener                                The event listener
661          * @exception   E_SUCCESS                               The method is successful.
662          * @exception   E_OUT_OF_MEMORY                 The memory is insufficient.
663          * @exception   E_OBJ_ALREADY_EXIST             The listener is already added.
664          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
665          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
666          * @remarks             Active application is the top most window with focus.
667          * @see                 GetActiveApp()
668          * @see                 RemoveActiveAppEventListener()
669          * @see                 IActiveAppEventListener
670          */
671         result AddActiveAppEventListener(IActiveAppEventListener& listener);
672
673         /**
674          * Removes an IActiveAppEventListener from the %AppManager.
675          *
676          * @since       2.0
677          *
678          * @privlevel   partner
679          * @privilege   %http://tizen.org/privilege/appusage
680          *
681          * @return              An error code
682          * @param[in]   listener                                The event listener
683          * @exception   E_SUCCESS                               The method is successful.
684          * @exception   E_OBJ_NOT_FOUND                 The specified @c listener is not found.
685          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
686          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
687          * @see                 GetActiveApp()
688          * @see                 AddActiveAppEventListener()
689          * @see                 IActiveAppEventListener
690          */
691         result RemoveActiveAppEventListener(IActiveAppEventListener& listener);
692
693         /**
694          * Gets the current active application AppId.
695          *
696          * @since       2.0
697          *
698          * @privlevel   partner
699          * @privilege   %http://tizen.org/privilege/appusage
700          *
701          * @return              An error code
702          * @param[out]  appId                                   The AppId of the active application
703          * @exception   E_SUCCESS                               The method is successful.
704          * @exception   E_SYSTEM                                The method cannot proceed due to a severe system error.
705          * @exception   E_PRIVILEGE_DENIED              The application does not have the privilege to call this method.
706          * @remarks             Active application is the top most window with focus.
707          * @see                 AddActiveAppEventListener()
708          * @see                 RemoveActiveAppEventListener()
709          */
710         result GetActiveApp(AppId& appId);
711
712 private:
713         /**
714          * This default constructor is intentionally declared as private to implement the %Singleton semantic.
715          *
716          * @since       2.0
717          */
718         AppManager(void);
719
720         /**
721          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
722          *
723          * @since       2.0
724          */
725         AppManager(const AppManager& rhs);
726
727         /**
728          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
729          *
730          * @since       2.0
731          */
732         AppManager& operator =(const AppManager& rhs);
733
734         /**
735          * Constructs the instance of this class.
736          *
737          * @since       2.0
738          *
739          * @return          An error code
740          * @exception   E_SUCCESS       The method is successful.
741          * @exception   E_OUT_OF_MEMORY The memory is insufficient.
742          * @exception   E_SYSTEM                        A system error has occurred.
743          */
744         result Construct(void);
745
746         /**
747          * This destructor is intentionally declared as private to implement the %Singleton semantic.
748          *
749          * @since       2.0
750          */
751         virtual ~AppManager(void);
752
753 private:
754         class _AppManagerImpl* __pAppManagerImpl;
755
756         friend class _AppManagerImpl;
757 }; // AppManager
758
759 }} // Tizen::App
760
761 #endif // _FAPP_APP_MANAGER_H_
762