Implement Multi user changes
[platform/core/appfw/ail.git] / include / ail.h
index 7faaae4..e745c61 100755 (executable)
 #define __AIL_H__
 
 #include <stdbool.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <tzplatform_config.h>
+
+#define OWNER_ROOT 0
+#define GROUP_MENU 6010
+#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
+#define BUFSZE 1024
+#define USR_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RO_DESKTOP_APP)
+#define APP_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB,".app_info.db")
+#define APP_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB,".app_info.db-journal")
+#define APP_INFO_DB_LABEL "*"
 
 #ifdef __cplusplus
 extern "C" {
@@ -72,7 +85,8 @@ extern "C" {
 #define        AIL_PROP_X_SLP_APPID_STR                "AIL_PROP_X_SLP_APPID_STR"
 #define        AIL_PROP_X_SLP_PKGID_STR                "AIL_PROP_X_SLP_PKGID_STR"
 #define        AIL_PROP_X_SLP_DOMAIN_STR               "AIL_PROP_X_SLP_DOMAIN_STR"
-
+#define        AIL_PROP_X_SLP_SUBMODEMAINID_STR                "AIL_PROP_X_SLP_SUBMODEMAINID_STR"
+#define        AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR             "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR"
 
 /**
  * @brief integer type properties
@@ -87,8 +101,9 @@ extern "C" {
 #define        AIL_PROP_X_SLP_TASKMANAGE_BOOL          "AIL_PROP_X_SLP_TASKMANAGE_BOOL"
 #define        AIL_PROP_X_SLP_MULTIPLE_BOOL            "AIL_PROP_X_SLP_MULTIPLE_BOOL"
 #define        AIL_PROP_X_SLP_REMOVABLE_BOOL           "AIL_PROP_X_SLP_REMOVABLE_BOOL"
-#define        AIL_PROP_X_SLP_INACTIVATED_BOOL         "AIL_PROP_X_SLP_INACTIVATED_BOOL"
-
+#define        AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL   "AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL"
+#define        AIL_PROP_X_SLP_ENABLED_BOOL             "AIL_PROP_X_SLP_ENABLED_BOOL"
+#define        AIL_PROP_X_SLP_SUBMODE_BOOL             "AIL_PROP_X_SLP_SUBMODE_BOOL"
 
 /**
  * @brief A handle for filters
@@ -424,11 +439,11 @@ typedef enum {
  *
  * @see  ail_filter_list_appinfo_foreach()
  */
-typedef ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void *user_data);
+typedef ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void *user_data,uid_t uid);
 
 /**
  * @fn ail_error_e ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb func, void *user_data)
- *
+ * @fn ail_error_e ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb func, void *user_data, uid_t uid)
  * @brief Calls the callback function for each app filtered by given filter. If the filter is not given (i.e filter handle is NULL), it is invoked for all apps.
  *
  * @par Sync (or) Async : Synchronous API
@@ -436,6 +451,7 @@ typedef ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void
  * @param[in] filter           a filter handle
  * @param[in] func                     the function to call with each app's appinfo
  * @param[in] user_data                user_data to pass to the function
+ * @param[in] uid      ID of the owner of the application
  *
  * @return  0 if success, negative value(<0) if fail\n
  * @retval AIL_ERROR_OK                                        success
@@ -499,18 +515,19 @@ int list_apps()
 ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter,
                                             ail_list_appinfo_cb appinfo_func,
                                             void *user_data);
-
-
-
+ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter,
+                                            ail_list_appinfo_cb appinfo_func,
+                                            void *user_data, uid_t uid);
 /**
- * @fn ail_error_e ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count)
- *
+ * @fn ail_error_e ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count, uid_t uid)
+ * @fn ail_error_e ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *count)
  * @brief Gets the number of app which is filtered by the given filter. If the filter is not given (i.e filter handle is NULL), all app are counted.
  *
  * @par Sync (or) Async : Synchronous API
  *
  * @param[in] filter   a filter handle
  * @param[in] count            the number of appinfo which is filtered
+ * @param[in] uid      ID of the owner of the application
  *
  * @return 0 if success, negative value(<0) if fail\n
  * @retval     AIL_ERROR_OK                                    success
@@ -564,12 +581,11 @@ int count_apps()
  * @endcode
  */
 ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count);
-
-
+ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *count, uid_t uid);
 
 /**
  * @fn ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle)
- *
+ * @fn ail_error_e ail_package_get_appinfo(const char *package, uid_t uid, ail_appinfo_h *handle)
  * @brief get an application information related to a package. 
        This API just retrieves all the information of the package from Application Information Database.
        All data related to the package are loaded in the memory after calling this function. 
@@ -578,6 +594,7 @@ ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count);
  * @par Sync (or) Async : Synchronous API.
  *
  * @param[in] package package name what you want to know about.
+ * @param[in] uid      ID of the owner of the application
  * @param[out] handle handle will be used with the functions of ail_appinfo_get_xxx. If no data, it will be NULL.
  *
  * @return 0 if success, negative value(<0) if fail\n
@@ -623,11 +640,10 @@ static ail_error_e _get_name(const char *package)
  * @endcode
  */
 ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle) __attribute__((deprecated));
-
-
+ail_error_e ail_package_get_usr_appinfo(const char *package, uid_t uid, ail_appinfo_h *handle) __attribute__((deprecated));
 /**
  * @fn ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle)
- *
+ * @fn ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *handle)
  * @brief get an application information related to a appid.
        This API just retrieves all the information of the application from Application Information Database.
        All data related to the appid are loaded in the memory after calling this function.
@@ -681,7 +697,7 @@ static ail_error_e _get_name(const char *appid)
  * @endcode
  */
 ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle);
-
+ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *handle);
 
 /**
  * @fn ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value)
@@ -795,11 +811,9 @@ static ail_error_e _get_x_slp_baselayoutwidth(const char *appid)
  */
 ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property, int *value);
 
-
-
 /**
- * @fn ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, char **str)
- *
+ * @fn ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, uid_t uid, char **str)
+ * @fn ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h handle, const char *property, char **str)
  * @brief get a string related to the property. 
        Before using this API, the handle is defined by calling ail_get_appinfo.
        This function needs a out-parameter for the value.
@@ -808,6 +822,7 @@ ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property
  *
  * @param[in] handle   the handle is defined by calling ail_get_appinfo.
  * @param[in] property a property type of string.
+ * @param[in]  uid     the addressee user id of the instruction
  * @param[out] str             a out-parameter string that is mapped with the property. The icon property contains the absolute file path. If there is no data, the value of str is NULL.
  *
  * @return 0 if success, negative value(<0) if fail\n
@@ -851,7 +866,7 @@ static ail_error_e _get_nodisplay(const char *appid)
  * @endcode
  */
 ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, char **str);
-
+ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h handle, const char *property, uid_t uid, char **str);
 
 
 /**
@@ -957,10 +972,64 @@ static ail_error_e _get_name(const char *appid)
  */
 ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle);
 
-
 /**
- * @fn ail_error_e ail_desktop_add(const char *appid)
+ * @fn ail_error_e ail_close_appinfo_db(void)
+ *
+ * @brief close appinfo db.
  *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval     AIL_ERROR_OK                                    success
+ * @retval     AIL_ERROR_DB_FAILED                             database error
+ * @retval     AIL_ERROR_INVALID_PARAMETER             invalid parameter
+ *
+ * @pre need a handle that you don't need anymore.
+ * @post cannot use the handle after destroying.
+ *
+ * @see  ail_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _get_name(const char *appid)
+{
+       ail_appinfo_h handle;
+       ail_error_e ret;
+       char *str;
+
+       ret = ail_get_appinfo(appid, &handle);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+       fprintf(stderr, "Package[%s], Property[%s] : %s\n", appid, property, str);
+
+       ret = ail_destroy_appinfo(handle);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       ret = ail_close_appinfo_db();
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_close_appinfo_db(void);
+
+
+/**
+ * @fn ail_error_e ail_desktop_add(const char *appid, )
+ * @fn ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid)
  * @brief add a app information into Application Information Database.
        A desktop file for this app has to be installed in the desktop directory before using this API.
        If there is no database for Application Information Database, this API will create the DB.
@@ -970,6 +1039,7 @@ ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle);
  * @par Sync (or) Async : Synchronous API.
  *
  * @param[in] appid
+ * @param[in]  uid     the addressee user id of the instruction
  *
  * @return 0 if success, negative value(<0) if fail\n
  * @retval     AIL_ERROR_OK                                    success
@@ -1003,12 +1073,12 @@ static ail_error_e _add_desktop(const char *appid)
  * @endcode
  */
 ail_error_e ail_desktop_add(const char *appid);
-
+ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid);
 
 
 /**
  * @fn ail_error_e ail_desktop_update(const char *appid)
- *
+ * @fn ail_error_e ail_usr_desktop_update(const char *appid,  uid_t uid)
  * @brief update a app information in the Application Information Database.
        A desktop file for this app has to be installed in the desktop directory before using this API.
        And a notification is published to the applications who want to know about changing DB. 
@@ -1016,6 +1086,7 @@ ail_error_e ail_desktop_add(const char *appid);
  * @par Sync (or) Async : Synchronous API.
  *
  * @param[in] appid
+ * @param[in] uid      ID of the owner of the application
  *
  * @return 0 if success, negative value(<0) if fail\n
  * @retval     AIL_ERROR_OK                                    success
@@ -1049,18 +1120,19 @@ static ail_error_e _update_desktop(const char *appid)
  * @endcode
  */
 ail_error_e ail_desktop_update(const char *appid);
-
+ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid);
 
 
 /**
  * @fn ail_error_e ail_desktop_remove(const char *appid)
- *
+ * @fn ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid)
  * @brief remove a app information in the Application Information Database.
        And a notification is published to the applications who want to know about changing DB. 
  *
  * @par Sync (or) Async : Synchronous API.
  *
  * @param[in] appid
+ * @param[in]  uid     the addressee user id of the instruction
  *
  * @return 0 if success, negative value(<0) if fail\n
  * @retval     AIL_ERROR_OK                                    success
@@ -1094,7 +1166,149 @@ static ail_error_e _remove_desktop(const char *appid)
  * @endcode
  */
 ail_error_e ail_desktop_remove(const char *appid);
+ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid);
+
+/**
+ * @fn ail_error_e ail_desktop_clean(const char *pkgid)
+ * @fn ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid))
+ * @brief clean a pkg information in the Application Information Database.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] pkgid
+ * @param[in] uid      ID of the owner of the application
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval     AIL_ERROR_OK                                    success
+ * @retval     AIL_ERROR_FAIL                                  internal error
+ * @retval     AIL_ERROR_INVALID_PARAMETER             invalid parameter
+ *
+ * @pre no pre-condition.
+ * @post app information is removed in the Application Information Database.
+ *
+ * @see  ail_desktop_add(), ail_desktop_update()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _clean_desktop(const char *pkgid)
+{
+       ail_error_e ret;
+
+       if (!appid) {
+               return AIL_ERROR_FAIL;
+       }
+
+       ret = ail_desktop_clean(pkgid);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_desktop_clean(const char *pkgid);
+ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid);
+
+/**
+ * @fn ail_error_e ail_desktop_fota(const char *appid)
+ * @fn ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid)
+ * @brief add a app information into Application Information Database.
+       A desktop file for this app has to be installed in the desktop directory before using this API.
+       If there is no database for Application Information Database, this API will create the DB.
+       If there is a DB, this function adds information for the app into the DB.
+       And a notification is not published to the applications who want to know about changing DB.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] appid
+ * @param[in]  uid     the addressee user id of the instruction
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval     AIL_ERROR_OK                                    success
+ * @retval     AIL_ERROR_FAIL                                  internal error
+ * @retval     AIL_ERROR_INVALID_PARAMETER             invalid parameter
+ *
+ * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
+ * @post app information is added into the Application Information Database.
+ *
+ * @see  ail_desktop_update(), ail_desktop_remove()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _add_desktop_fota(const char *appid)
+{
+       ail_error_e ret;
+
+       if (!appid) {
+               return AIL_ERROR_FAIL;
+       }
+
+       ret = ail_desktop_fota(appid);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_desktop_fota(const char *appid);
+ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid);
+/**
+ *@fn ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast)
+ * @fn ail_error_e ail_desktop_appinfo_modify_usr_str(const char *appid, uid_t uid, const char *property, const char *value, bool broadcast)
+ * @brief update a app information db.
+       And a notification is published to the applications who want to know about changing DB.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] appid
+ * @param[in] uid      ID of the owner of the application
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval     AIL_ERROR_OK                                    success
+ * @retval     AIL_ERROR_FAIL                                  internal error
+ * @retval     AIL_ERROR_INVALID_PARAMETER             invalid parameter
+ *
+ * @pre no pre-condition.
+ * @post app information is removed in the Application Information Database.
+ *
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _appinfo_modify_str(const char *appid, uid_t uid, const char *property, const char *value, bool broadcast)
+{
+       ail_error_e ret;
+
+       if (!appid) {
+               return AIL_ERROR_FAIL;
+       }
+       if (!property) {
+               return AIL_ERROR_FAIL;
+       }
+       if (!value) {
+               return AIL_ERROR_FAIL;
+       }
+
+       ret = ail_desktop_appinfo_modify_str(appid, property, value, broadcast);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       return AIL_ERROR_OK;
+}
+ * @endcode
+ */
 
+ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast);
+ail_error_e ail_desktop_appinfo_modify_usr_str(const char *appid, uid_t uid, const char *property, const char *value, bool broadcast);
 /** @} */