Handle widget abnormal exit
[platform/core/appfw/aul-1.git] / include / aul.h
index 8fda7ac..b0041b4 100644 (file)
@@ -31,6 +31,7 @@ extern "C" {
  * @brief Return values in AUL.
  */
 typedef enum _aul_return_val {
+       AUL_R_ENOENT = -15,             /**< App directory entry error */
        AUL_R_EREJECTED = -14,          /**< App disable for mode */
        AUL_R_ENOAPP = -13,             /**< Failed to find app ID or pkg ID */
        AUL_R_EHIDDENFORGUEST = -11,    /**< App hidden for guest mode */
@@ -69,6 +70,7 @@ typedef enum _aul_type {
        AUL_WAKE,
        AUL_SUSPEND,
        AUL_WIDGET_CONTENT,
+       AUL_UPDATE_REQUESTED,
 } aul_type;
 
 typedef enum aul_widget_lifecycle_event {
@@ -90,7 +92,8 @@ typedef enum aul_widget_instance_event {
        AUL_WIDGET_INSTANCE_EVENT_SIZE_CHANGED = 7,
        AUL_WIDGET_INSTANCE_EVENT_EXTRA_UPDATED = 8,
        AUL_WIDGET_INSTANCE_EVENT_FAULT = 9,
-       AUL_WIDGET_INSTANCE_EVENT_APP_RESTART_REQUEST = 10
+       AUL_WIDGET_INSTANCE_EVENT_APP_RESTART_REQUEST = 10,
+       AUL_WIDGET_INSTANCE_EVENT_CREATE_ABORTED = 11
 } aul_widget_instance_event_e;
 
 /** AUL public key - To check caller's secuirty */
@@ -146,7 +149,14 @@ typedef enum aul_widget_instance_event {
 #define AUL_K_RUA_ARG "__K_RUA_ARG"
 /** AUL public key - To support rua add */
 #define AUL_K_RUA_TIME "__K_RUA_TIME"
-
+/** AUL public bundle value */
+#define AUL_K_RUA_INSTANCE_ID "__K_RUA_INSTANCE_ID"
+/** AUL public bundle value */
+#define AUL_K_RUA_INSTANCE_NAME "__K_RUA_INSTANCE_NAME"
+/** AUL public bundle value */
+#define AUL_K_RUA_ICON "__K_RUA_ICON"
+/** AUL public bundle value */
+#define AUL_K_RUA_URI "__K_RUA_URI"
 
 /** AUL internal private key */
 #define AUL_K_PKG_NAME         "__AUL_PKG_NAME__"
@@ -246,6 +256,25 @@ typedef enum aul_widget_instance_event {
 #define AUL_K_STATUS           "__AUL_STATUS__"
 /** AUL internal private key */
 #define AUL_K_IS_SUBAPP                "__AUL_IS_SUBAPP__"
+/** AUL internal private key */
+#define AUL_K_INSTANCE_ID      "__AUL_INSTANCE_ID__"
+/** AUL internal private key */
+#define AUL_K_ORG_CALLER_UID   "__AUL_ORG_CALLER_UID__"
+/** AUL internal private key */
+#define AUL_K_CHECKSUM         "__AUL_CHECKSUM__"
+/** AUL internal private key */
+#define AUL_K_PRIVATE          "__AUL_PRIVATE__"
+/** AUL internal private key */
+#define AUL_K_SCREEN_TYPE      "__AUL_SCREEN_TYPE__"
+/** AUL internal private key */
+#define AUL_K_VIEWER_REF       "__AUL_VIEWER_REF__"
+/** AUL internal private key */
+#define AUL_K_PARENT_APPID     "__AUL_PARENT_APPID__"
+/** AUL internal private key */
+#define AUL_K_CHILD_APPID      "__AUL_CHILD_APPID__"
+/** AUL internal private key */
+#define AUL_K_WIDGET_FAULT     "__AUL_WIDGET_FAULT__"
+
 
 /**
  * @brief      This is callback function for aul_launch_init
@@ -893,6 +922,7 @@ typedef struct _aul_app_info {
        char *pkgid;            /**< package id */
        int status;             /**< app's status */
        int is_sub_app;         /**< state whether sub app of app group */
+       char *instance_id;
 } aul_app_info;
 
 /**
@@ -962,7 +992,7 @@ int aul_app_is_running_for_uid(const char *appid, uid_t uid);
  *     In general, this API is used by task manager appllication. (running application list viewer)
  *
  * @param[in]  iter_fn         iterator function
- * @param[in]  data            user-supplied data for iter_fn
+ * @param[in]  user_data       user-supplied data for iter_fn
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_ERROR     - internal error
@@ -992,7 +1022,7 @@ int aul_app_is_running_for_uid(const char *appid, uid_t uid);
  *     Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
  *     This API is only available in User Session.
  */
-int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
+int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *user_data);
 
 /**
  * @par Description:
@@ -1004,7 +1034,7 @@ int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  *     In general, this API is used by task manager appllication. (running application list viewer)
  *
  * @param[in]  iter_fn         iterator function
- * @param[in]  data            user-supplied data for iter_fn
+ * @param[in]  user_data       user-supplied data for iter_fn
  * @param[in]  uid             User ID
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
@@ -1016,7 +1046,7 @@ int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  *     Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
  *     This API is only available to System user.
  */
-int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *data, uid_t uid);
+int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *user_data, uid_t uid);
 
 /**
  * @par Description:
@@ -1028,7 +1058,7 @@ int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *dat
  *     In general, this API is used by task manager application. (running application list viewer)
  *
  * @param[in]  iter_fn         iterator function
- * @param[in]  data            user-supplied data for iter_fn
+ * @param[in]  user_data       user-supplied data for iter_fn
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
  * @retval     AUL_R_ERROR     - internal error
@@ -1061,7 +1091,7 @@ int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *dat
  *     Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
  *     This API is only available in User Session.
  */
-int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
+int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *user_data);
 
 /**
  * @par Description:
@@ -1073,7 +1103,7 @@ int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  *     In general, this API is used by task manager application. (running application list viewer)
  *
  * @param[in]  iter_fn         iterator function
- * @param[in]  data            user-supplied data for iter_fn
+ * @param[in]  user_data       user-supplied data for iter_fn
  * @param[in]  uid             User ID
  * @return     0 if success, negative value(<0) if fail
  * @retval     AUL_R_OK        - success
@@ -1085,7 +1115,7 @@ int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
  *     Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
  *     This API is only available to System user.
  */
-int aul_app_get_all_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *data, uid_t uid);
+int aul_app_get_all_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *user_data, uid_t uid);
 
 /**
  * @par Description:
@@ -2090,11 +2120,6 @@ const char *aul_get_app_specific_path(void);
 /*
  * This API is only for Appfw internally.
  */
-const char *aul_get_app_external_specific_path(void);
-
-/*
- * This API is only for Appfw internally.
- */
 int aul_get_app_shared_data_path_by_appid(const char *app_id, char **path);
 
 /*
@@ -2739,58 +2764,42 @@ int aul_unset_default_app_by_operation(const char *app_id);
 
 /**
  * @par Description:
- *     This API launches application with the given bundle asynchronously.
- *  If the application is not running or a multiple-instance one, this API launches with the given bundle.
- *     If the application is running, this API sends a RESET event to the App.
- *     While the application is running, if the application cannot receive the RESET event,
- *     this API returns a general error(AUL_R_ERROR).\n
- * @par Purpose:
- *      This API is for caller.
- *      This API's purpose is to launch/reset application with given bundle.
- * @par Typical use case:
- *     If you know the target application's pkgname and bundle types,
- *     you can use this API to launch/reset the application.
+ *      Sends the launch request asynchronously.
  *
- * @param[in]  pkgname         package name to be run as callee
- * @param[in]  kb              bundle to be passed to callee
- * @return     0 if success, negative value(<0) if fail
- * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invaild package name
- * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error
+ * @param[in]  appid           The application ID
+ * @param[in]  kb              The Bundle data
+ * @return      a pid of the callee on success,
+ *              otherwise a negative error value
+ * @retval     AUL_R_OK        - Successful
+ * @retval     AUL_R_EINVAL    - Invalid parameter
+ * @retval     AUL_R_ECOM      - Internal AUL IPC error
+ * @retval     AUL_R_ERROR     - General error
  *
  * @remark
  *     This API is only available in User Session.
  *     This API doesn't check whether the callee application is executed successfully.
+ *     If the caller application is equal to the callee application, this API can return AUL_R_OK.
  */
 int aul_launch_app_async(const char *appid, bundle *kb);
 
 /**
  * @par Description:
- *     This API launches application with the given bundle asynchronously.
- *  If the application is not running or a multiple-instance one, this API launches with the given bundle.
- *     If the application is running, this API sends a RESET event to the App.
- *     While the application is running, if the application cannot receive the RESET event,
- *     this API returns a general error(AUL_R_ERROR).\n
- * @par Purpose:
- *      This API is for caller.
- *      This API's purpose is to launch/reset application with given bundle.
- * @par Typical use case:
- *     If you know the target application's pkgname and bundle types,
- *     you can use this API to launch/reset the application.
+ *     Sends the launch request asynchronously.
  *
- * @param[in]  pkgname         package name to be run as callee
- * @param[in]  kb              bundle to be passed to callee
+ * @param[in]  appid           The application ID
+ * @param[in]  kb              The Bundle data
  * @param[in]  uid             User ID
- * @return     0 if success, negative value(<0) if fail
- * @retval     AUL_R_OK        - success
- * @retval     AUL_R_EINVAL    - invaild package name
- * @retval     AUL_R_ECOM      - internal AUL IPC error
- * @retval     AUL_R_ERROR     - general error
+ * @return      a pid of the callee on success,
+ *              otherwise a negative error value
+ * @retval     AUL_R_OK        - Successful
+ * @retval     AUL_R_EINVAL    - Invalid parameter
+ * @retval     AUL_R_ECOM      - Internal AUL IPC error
+ * @retval     AUL_R_ERROR     - General error
  *
  * @remark
  *     This API is only available to System user.
  *     This API doesn't check whether the callee application is executed successfully.
+ *     If the caller application is equal to the callee application, this API can return AUL_R_OK.
  */
 int aul_launch_app_async_for_uid(const char *appid, bundle *kb, uid_t uid);
 
@@ -2976,19 +2985,78 @@ int aul_enable_alias_info(const char *appid);
  */
 int aul_disable_alias_info(const char *appid);
 
-/*
+/**
+ * This API is only for Appfw internally.
+ */
+typedef int (*app_status_cb)(aul_app_info *info, int ctx_status, void *data);
+
+/**
  * This API is only for Appfw internally.
  */
-API int aul_listen_app_status(const char *appid,
-               int (*aul_handler)(const char *appid, const char *pkgid,
-                       int pid, int status, int is_subapp, void *data),
-               void *data);
+typedef struct status_listen_s *status_listen_h;
+
+/**
+ * @par Description:
+ *      Registers a callback function to be invoked when the application change status.
+ *
+ * @param[in]   appid           The application ID to get status
+ * @param[in]   callback        The callback function to register
+ * @param[in]   data            The user data to be passed to the callback function
+ * @param[out]  handle          The status listen handle
+ * @return      @c 0 on success,
+ *             otherwise a negative error value
+ */
+int aul_listen_app_status(const char *appid, app_status_cb callback,
+               void *data, status_listen_h *handle);
+int aul_listen_app_status_for_uid(const char *appid, app_status_cb callback,
+               void *data, status_listen_h *handle, uid_t uid);
 
 /*
  * This API is only for Appfw internally.
  */
 int aul_widget_instance_get_content(const char *widget_id, const char *instance_id, char **content);
 
+/**
+ * @par Description:
+ *      Gets running application instance info
+ *      This API calls the iter_fn with the aul_app_info when running app instance info is found.
+ *
+ * @param[in]   iter_fn         iterative function
+ * @param[in]   user_data       User data
+ * @return      0 if success, negative value(<0) if fail
+ * @retval      AUL_R_OK        Successful
+ * @retval      AUL_R_ERROR     General error
+ * @retval      AUL_R_EINVAL    Invalid parameter
+ */
+int aul_app_get_running_app_instance_info(aul_app_info_iter_fn iter_fn,
+               void *user_data);
+int aul_app_get_running_app_instance_info_for_uid(aul_app_info_iter_fn iter_fn,
+               void *user_data, uid_t uid);
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_app_get_instance_id_bypid(int pid, char *instance_id, int len);
+int aul_app_get_instance_id_bypid_for_uid(int pid, char *instance_id,
+               int len, uid_t uid);
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_resume_app_by_instance_id(const char *appid, const char *instance_id);
+int aul_resume_app_by_instance_id_for_uid(const char *appid,
+               const char *instance_id, uid_t uid);
+
+/**
+ * This API is only for Appfw internally.
+ */
+int aul_ignore_app_status(status_listen_h handle);
+
+/**
+ * This API is only for Appfw internally.
+ */
+int aul_widget_notify_exit(void);
+
 #ifdef __cplusplus
        }
 #endif